fern-api 0.46.0-rc1 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.cjs +2 -2
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -1786,7 +1786,7 @@ ${l.indent}`:""}${phl(o)}:${f.indent?" ":""}`;return u=!1,c=!0,f.objectItem=void
1786
1786
  `}),r.replaceAll(/\n$/g,"")}function aow(e){return e?Ic.green(WUr.radioOn):WUr.radioOff}var eMa=go(nSe(),1);function X2f(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var wDn=class extends v5{_run(t){this.done=t;let r=mH(this.rl),i=r.line.pipe((0,eMa.map)(this.filterInput.bind(this))),n=this.handleSubmitEvents(i);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,eMa.takeUntil)(n.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),i="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(i=`
1787
1787
  `+Ic.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?Ic.cyan(X2f(t,this.opt.mask)):Ic.italic.dim("[hidden]"):this.opt.mask?X2f(t,this.opt.mask):Ic.italic.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 Pzf=go(TEu(),1),jzf=go(nSe(),1);var BDn=class extends v5{_run(t){this.done=t,this.editorResult=new jzf.Subject;let r=mH(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"?Ic.dim("Received"):Ic.dim("Press <enter> to launch your preferred editor."),t&&(r=Ic.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,Pzf.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 qzf=go(Szf(),1);var Mzf=go(require("readline"),1),Tzf=go(Azf(),1),Oli=class{constructor(t){this.rl||=Mzf.default.createInterface(Kow(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 Kow(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 Tzf.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var IDn=class extends Oli{constructor(t={}){super(t),this.log=(0,qzf.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return yDn(this.rl,this.bottomBar.split(`
1788
1788
  `).length),this}updateBottomBar(t){return yDn(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+`
1789
- `}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&&YAa(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var Uzf=go(Bzf(),1),Vzf=go(xDu(),1),Wzf=go(Rzf(),1),OC=go(nSe(),1),Hzf=go(w1n(),1);var mMa=go(nSe(),1),Lzf=go(w1n(),1),OMa=function(e,t,r){return typeof e[t]!="function"?(0,mMa.of)(e):(0,mMa.from)((0,Lzf.default)(e[t])(r).then(i=>(e[t]=i,e)))};var zDn={isPlainObject:Uzf.default,set:Wzf.default,get:Vzf.default},K9i=class extends Oli{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=zDn.isPlainObject(r)?{...r}:{},zDn.isPlainObject(t)&&(t=Object.values(t).every(n=>zDn.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,OC.from)(t):t;return this.process=i.pipe((0,OC.concatMap)(this.processQuestion.bind(this)),(0,OC.publish)()),this.process.connect(),this.process.pipe((0,OC.reduce)((n,a)=>(zDn.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,OC.defer)(()=>(0,OC.of)(t).pipe((0,OC.concatMap)(this.setDefaultType.bind(this)),(0,OC.concatMap)(this.filterIfRunnable.bind(this)),(0,OC.concatMap)(()=>OMa(t,"message",this.answers)),(0,OC.concatMap)(()=>OMa(t,"default",this.answers)),(0,OC.concatMap)(()=>OMa(t,"choices",this.answers)),(0,OC.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,OC.defer)(()=>(0,OC.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,OC.defer)(()=>(0,OC.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&zDn.get(this.answers,t.name)!==void 0)return(0,OC.empty)();if(t.when===!1)return(0,OC.empty)();if(typeof t.when!="function")return(0,OC.of)(t);let{answers:r}=this;return(0,OC.defer)(()=>(0,OC.from)((0,Hzf.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,OC.filter)(i=>i!=null)))}};function Jzf(e){let t=function(r,i){let n;try{n=new K9i(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",bDn),this.registerPrompt("input",pli),this.registerPrompt("number",gDn),this.registerPrompt("confirm",mDn),this.registerPrompt("rawlist",ODn),this.registerPrompt("expand",PDn),this.registerPrompt("checkbox",jDn),this.registerPrompt("password",wDn),this.registerPrompt("editor",BDn)},t.restoreDefaultPrompts(),t}var xEu=Jzf();function puw(e,t){xEu.registerPrompt(e,t)}function _uw(){xEu.restoreDefaultPrompts()}var huw={prompt:xEu,ui:{BottomBar:IDn,Prompt:K9i},createPromptModule:Jzf,registerPrompt:puw,restoreDefaultPrompts:_uw,Separator:Jne},PMa=huw;var t7f=go(Qzf()),Rcw="4.2.1",k6t;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",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"})(k6t||(k6t={}));function Lcw(e,t){if(!e)throw new Error(t)}function Ucw(e){return e?.replace(/\/+$/,"")}async function Vcw(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 Wcw(){return new Date().getTime()}function GNf(){return new Date().toISOString()}function r7f(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var GDn=String.fromCharCode,$Nf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",IMa={};function Hcw(e,t){if(!IMa[e]){IMa[e]={};for(let r=0;r<e.length;r++)IMa[e][e.charAt(r)]=r}return IMa[e][t]}var $Dn={compressToBase64:function(e){if(e==null)return"";let t=$Dn._compress(e,6,function(r){return $Nf.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:$Dn._decompress(e.length,32,function(t){return Hcw($Nf,e.charAt(t))})},compress:function(e){return $Dn._compress(e,16,function(t){return GDn(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,f,p="",c="",o="",l=2,m=3,O=2,j=0,A=0,T;for(T=0;T<e.length;T+=1)if(p=e.charAt(T),Object.prototype.hasOwnProperty.call(i,p)||(i[p]=m++,n[p]=!0),c=o+p,Object.prototype.hasOwnProperty.call(i,c))o=c;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,A==t-1?(A=0,a.push(r(j)),j=0):A++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete n[o]}else for(f=i[o],u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++),i[c]=m++,o=String(p)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,A==t-1?(A=0,a.push(r(j)),j=0):A++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete n[o]}else for(f=i[o],u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++)}for(f=2,u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;for(;;)if(j=j<<1,A==t-1){a.push(r(j));break}else A++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:$Dn._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,f=4,p=3,c="",o,l,m,O,j,A,T;for(o=0;o<3;o+=1)i[o]=o;for(m=0,j=Math.pow(2,2),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;switch(m){case 0:for(m=0,j=Math.pow(2,8),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;T=GDn(m);break;case 1:for(m=0,j=Math.pow(2,16),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;T=GDn(m);break;case 2:return""}for(i[3]=T,l=T,n.push(T);;){if(a.index>e)return"";for(m=0,j=Math.pow(2,p),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;switch(T=m){case 0:for(m=0,j=Math.pow(2,8),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;i[f++]=GDn(m),T=f-1,u--;break;case 1:for(m=0,j=Math.pow(2,16),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;i[f++]=GDn(m),T=f-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,p),p++),i[T])c=i[T];else if(T===f)c=l+l.charAt(0);else return null;n.push(c),i[f++]=l+c.charAt(0),u--,l=c,u==0&&(u=Math.pow(2,p),p++)}}},mAu=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)}};var zMa="0123456789abcdef",NMa=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+=zMa.charAt(this.bytes[r]>>>4),t+=zMa.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+=zMa.charAt(this.bytes[r]>>>4),t+=zMa.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}},OAu=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??Jcw()}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 NMa.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,NMa.ofInner(t)}},Jcw=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),KNf,YNf=()=>Qcw().toString(),Qcw=()=>(KNf||(KNf=new OAu)).generate(),FMa=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},KDn=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function XNf(e){return typeof e=="object"&&(e instanceof FMa||e instanceof KDn)}var PAu=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new mAu,this._isInitialized=!1,Lcw(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=Ucw(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.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:XNf},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??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(k6t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(k6t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(k6t.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}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=YNf();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)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("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)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let f=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",f,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,f={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.fetchWithRetry(u,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(p=>p.json()).catch(p=>{this._events.emit("error",p)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let f=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!f)return;let p=f[t];return p===void 0&&(p=!1),p}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let f=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!f)return;let p=f[t];return p===void 0?null:p}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let f=await this.getDecide(t,r,i,n,u),p=f?.featureFlags,c=f?.featureFlagPayloads,o=c;return c&&(o=Object.fromEntries(Object.entries(c).map(([l,m])=>[l,this._parsePayload(m)]))),{flags:p,payloads:o}}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={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:GNf(),uuid:i?.uuid?i.uuid:YNf()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty(k6t.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty(k6t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=r7f(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}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(k6t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(c=>c.message),n=()=>{let c=this.getPersistedProperty(k6t.Queue)||[];this.setPersistedProperty(k6t.Queue,c.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:GNf()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),f=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${Wcw()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,p=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent($Dn.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(f,p)}catch(c){throw c instanceof KDn||n(),this._events.emit("error",c),c}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(f){let p=new AbortController;return setTimeout(()=>p.abort(),f),p.signal}),await Vcw(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(p){throw new KDn(p)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new FMa(u);return u},{...this._retryOptions,...i})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(k6t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!XNf(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},jAu=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},wAu=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!wAu){let e=QNf();wAu=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 i7f=wAu,Gcw=1152921504606847e3,$cw=["is_not"],RMa=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},b5=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},DAu=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...f}){this.debugMode=!1,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=f.fetch||i7f,this.onError=f.onError,this.customHeaders=u,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,f;if(!this.loadedSuccessfullyOnce)return u;for(let p of this.featureFlags)if(t===p.key){f=p;break}if(f!==void 0)try{u=this.computeFlagLocally(f,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(p){p instanceof b5?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${p}`)):p instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${p}`))}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={},f=this.featureFlags.length==0;return this.featureFlags.map(async p=>{try{let c=this.computeFlagLocally(p,t,r,i,n);a[p.key]=c;let o=await this.computeFeatureFlagPayloadLocally(p.key,c);o&&(u[p.key]=o)}catch(c){c instanceof b5||c instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${p.key}: ${c}`)),f=!0}}),{response:a,payloads:u,fallbackToDecide:f}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new b5("Flag has experience continuity enabled");if(!t.active)return!1;let f=(t.filters||{}).aggregation_group_type_index;if(f!=null){let p=this.groupTypeMapping[String(f)];if(!p)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${f} for feature flag ${t.key}`)),new b5("Flag has unknown group type index");if(!(p in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let c=a[p];return this.matchFeatureFlagProperties(t,i[p],c)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,f,p=[...a].sort((c,o)=>{let l=!!c.variant,m=!!o.variant;return l&&m?0:l?-1:m?1:0});for(let c of p)try{if(this.isConditionMatch(t,r,c,i)){let o=c.variant,l=n.multivariate?.variants||[];o&&l.some(m=>m.key===o)?f=o:f=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof b5)u=!0;else throw o}if(f!==void 0)return f;if(u)throw new b5("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=f=>{this.logMsgIfDebug(()=>console.warn(f))};if((i.properties||[]).length>0){for(let f of i.properties){let p=f.type,c=!1;if(p==="cohort"?c=a7f(f,n,this.cohorts,this.debugMode):c=n7f(f,n,u),!c)return!1}if(a==null)return!0}return!(a!=null&&ZNf(t.key,r)>a/100)}getMatchingVariant(t,r){let i=ZNf(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(f=>{n=i+f.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:f.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new RMa("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),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}catch(t){t instanceof RMa&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=r7f(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function ZNf(e,t,r=""){let i=(0,t7f.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/Gcw}function n7f(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 b5("Operator is_not_set is not supported")}else throw new b5(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!$cw.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function f(c,o){return Array.isArray(c)?c.map(l=>String(l).toLowerCase()).includes(String(o).toLowerCase()):String(c).toLowerCase()===String(o).toLowerCase()}function p(c,o,l){if(l==="gt")return c>o;if(l==="gte")return c>=o;if(l==="lt")return c<o;if(l==="lte")return c<=o;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return f(n,u);case"is_not":return!f(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 kNf(String(n))&&String(u).match(String(n))!==null;case"not_regex":return kNf(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let c=typeof n=="number"?n:null;if(typeof n=="string")try{c=parseFloat(n)}catch{}return c!=null&&u!=null?typeof u=="string"?p(u,String(n),a):p(u,c,a):p(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let c=Kcw(String(n));if(c==null&&(c=e7f(n)),c==null)throw new b5(`Invalid date: ${n}`);let o=e7f(u);return["is_date_before"].includes(a)?o<c:o>c}default:throw new b5(`Unknown operator: ${a}`)}}function a7f(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new b5("can't match cohort without a given cohort property value");let a=r[n];return o7f(a,t,r,i)}function o7f(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 f of a)try{let p=o7f(f,t,r,i);if(n==="AND"){if(!p)return!1}else if(p)return!0}catch(p){if(p instanceof b5)i&&console.debug(`Failed to compute property ${f} locally: ${p}`),u=!0;else throw p}if(u)throw new b5("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let f of a)try{let p;f.type==="cohort"?p=a7f(f,t,r,i):p=n7f(f,t);let c=f.negation||!1;if(n==="AND"){if(!p&&!c||p&&c)return!1}else if(p&&!c||!p&&c)return!0}catch(p){if(p instanceof b5)i&&console.debug(`Failed to compute property ${f} locally: ${p}`),u=!0;else throw p}if(u)throw new b5("can't match cohort without a given cohort property value");return n==="AND"}}function kNf(e){try{return new RegExp(e),!0}catch{return!1}}function e7f(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 b5(`${e} is in an invalid date format`)}else throw new b5(`The date provided ${e} must be a string, number, or date object`)}function Kcw(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 Ycw=30*1e3,Xcw=50*1e3,rLi=class extends PAu{constructor(t,r={}){super(t,r),this._memoryStorage=new jAu,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new DAu({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:Ycw,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||Xcw}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):i7f(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return Rcw}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({distinctId:t,event:r,properties:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:f,uuid:p}){let c=m=>{super.captureStateless(t,r,m,{timestamp:u,disableGeoip:f,uuid:p})},o=(m,O,j)=>super.getFeatureFlagsStateless(m,O,void 0,void 0,j),l=Promise.resolve().then(async()=>{if(a)return await o(t,n,f);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let m={};for(let[O,j]of Object.entries(n||{}))m[O]=String(j);return await this.getAllFlags(t,{groups:m,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(m=>{let O={};if(m)for(let[A,T]of Object.entries(m))O[`$feature/${A}`]=T;let j=Object.keys(m||{}).filter(A=>m?.[A]!==!1);return j.length>0&&(O.$active_feature_flags=j),O}).catch(()=>({})).then(m=>{c({...m,...i,$groups:n})});this.addPendingPromise(l)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:f,personProperties:p,groupProperties:c}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,p,c);p=o.allPersonProperties,c=o.allGroupProperties,u==null&&(u=!1),f==null&&(f=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,p,c),m=l!==void 0;!m&&!u&&(l=await super.getFeatureFlagStateless(t,r,n,p,c,a));let O=`${t}_${l}`;return f&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(O))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(O):this.distinctIdHasSentFlagCalls[r]=[O],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,locally_evaluated:m,[`$feature/${t}`]:l},groups:n,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:f,sendFeatureFlagEvents:p,personProperties:c,groupProperties:o}=n||{},l=this.addLocalPersonAndGroupProperties(r,a,c,o);c=l.allPersonProperties,o=l.allGroupProperties;let m;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(m=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),f==null&&(f=!1),p==null&&(p=!0),f==null&&(f=!1),!(m!==void 0)&&!f&&(m=await super.getFeatureFlagPayloadStateless(t,r,a,c,o,u)),m}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:f}=r||{},p=this.addLocalPersonAndGroupProperties(t,i,u,f);u=p.allPersonProperties,f=p.allGroupProperties,a==null&&(a=!1);let c=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,f),o={},l={},m=!0;if(c&&(o=c.response,l=c.payloads,m=c.fallbackToDecide),m&&!a){let O=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,f,n);o={...o,...O.flags||{}},l={...l,...O.payloads||{}}}return{featureFlags:o,featureFlagPayloads:l}}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 f of Object.keys(r))u[f]={$group_key:r[f],...n?.[f]||{}};return{allPersonProperties:a,allGroupProperties:u}}},SAu=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},f=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&f!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${f}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};SAu.POSTHOG_ID_TAG="posthog_distinct_id";var LMa=class{posthog;constructor({posthogApiKey:t}){this.posthog=new rLi(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.46.0-rc1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var YDn=class{async sendEvent(){}async identify(){}async flush(){}};var iLi=require("fs/promises"),l7f=require("os"),f7f=require("path");var u7f=go(require("crypto")),VMa=new Uint8Array(256),UMa=VMa.length;function EAu(){return UMa>VMa.length-16&&(u7f.default.randomFillSync(VMa),UMa=0),VMa.slice(UMa,UMa+=16)}var jH=[];for(let e=0;e<256;++e)jH.push((e+256).toString(16).slice(1));function s7f(e,t=0){return jH[e[t+0]]+jH[e[t+1]]+jH[e[t+2]]+jH[e[t+3]]+"-"+jH[e[t+4]]+jH[e[t+5]]+"-"+jH[e[t+6]]+jH[e[t+7]]+"-"+jH[e[t+8]]+jH[e[t+9]]+"-"+jH[e[t+10]]+jH[e[t+11]]+jH[e[t+12]]+jH[e[t+13]]+jH[e[t+14]]+jH[e[t+15]]}var c7f=go(require("crypto")),AAu={randomUUID:c7f.default.randomUUID};function Zcw(e,t,r){if(AAu.randomUUID&&!t&&!e)return AAu.randomUUID();e=e||{};let i=e.random||(e.rng||EAu)();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 s7f(i)}var _Be=Zcw;var kcw="id",elw=".fern",XDn=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new rLi(r),this.userId=t==null?void 0:UOu(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.46.0-rc1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Sf(f_.of((0,l7f.homedir)()),Pc.of(elw),Pc.of(kcw));await ph(t)||(await(0,iLi.mkdir)((0,f7f.dirname)(t),{recursive:!0}),await(0,iLi.writeFile)(t,_Be())),this.persistedDistinctId=(await(0,iLi.readFile)(t)).toString()}return this.persistedDistinctId}};var MAu;async function nLi(){return MAu==null&&(MAu=await tlw()),MAu}async function tlw(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new YDn;let r=await Rja();return r!=null?new XDn({token:r,posthogApiKey:e}):await Fja()!=null?new LMa({posthogApiKey:e}):new XDn({token:void 0,posthogApiKey:e})}catch{return new YDn}}function ZDn(e,t){return function(){return e.apply(t,arguments)}}var{toString:rlw}=Object.prototype,{getPrototypeOf:CAu}=Object,HMa=(e=>t=>{let r=rlw.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),e3t=e=>(e=e.toLowerCase(),t=>HMa(t)===e),JMa=e=>t=>typeof t===e,{isArray:aLi}=Array,kDn=JMa("undefined");function ilw(e){return e!==null&&!kDn(e)&&e.constructor!==null&&!kDn(e.constructor)&&oSe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var _7f=e3t("ArrayBuffer");function nlw(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&_7f(e.buffer),t}var alw=JMa("string"),oSe=JMa("function"),h7f=JMa("number"),QMa=e=>e!==null&&typeof e=="object",olw=e=>e===!0||e===!1,WMa=e=>{if(HMa(e)!=="object")return!1;let t=CAu(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},ulw=e3t("Date"),slw=e3t("File"),clw=e3t("Blob"),llw=e3t("FileList"),flw=e=>QMa(e)&&oSe(e.pipe),dlw=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||oSe(e.append)&&((t=HMa(e))==="formdata"||t==="object"&&oSe(e.toString)&&e.toString()==="[object FormData]"))},plw=e3t("URLSearchParams"),[_lw,hlw,ylw,vlw]=["ReadableStream","Request","Response","Headers"].map(e3t),blw=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function eSn(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),aLi(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,f;for(i=0;i<u;i++)f=a[i],t.call(null,e[f],f,e)}}function y7f(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 Dli=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,v7f=e=>!kDn(e)&&e!==Dli;function qAu(){let{caseless:e}=v7f(this)&&this||{},t={},r=(i,n)=>{let a=e&&y7f(t,n)||n;WMa(t[a])&&WMa(i)?t[a]=qAu(t[a],i):WMa(i)?t[a]=qAu({},i):aLi(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&eSn(arguments[i],r);return t}var glw=(e,t,r,{allOwnKeys:i}={})=>(eSn(t,(n,a)=>{r&&oSe(n)?e[a]=ZDn(n,r):e[a]=n},{allOwnKeys:i}),e),mlw=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Olw=(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)},Plw=(e,t,r,i)=>{let n,a,u,f={};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))&&!f[u]&&(t[u]=e[u],f[u]=!0);e=r!==!1&&CAu(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},jlw=(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},wlw=e=>{if(!e)return null;if(aLi(e))return e;let t=e.length;if(!h7f(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Dlw=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&CAu(Uint8Array)),Slw=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},Elw=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},Alw=e3t("HTMLFormElement"),Mlw=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),d7f=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Tlw=e3t("RegExp"),b7f=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};eSn(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},qlw=e=>{b7f(e,(t,r)=>{if(oSe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(oSe(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+"'")})}})},Clw=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return aLi(e)?i(e):i(String(e).split(t)),r},xlw=()=>{},Blw=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,TAu="abcdefghijklmnopqrstuvwxyz",p7f="0123456789",g7f={DIGIT:p7f,ALPHA:TAu,ALPHA_DIGIT:TAu+TAu.toUpperCase()+p7f},Ilw=(e=16,t=g7f.ALPHA_DIGIT)=>{let r="",{length:i}=t;for(;e--;)r+=t[Math.random()*i|0];return r};function zlw(e){return!!(e&&oSe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var Nlw=e=>{let t=new Array(10),r=(i,n)=>{if(QMa(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=aLi(i)?[]:{};return eSn(i,(u,f)=>{let p=r(u,n+1);!kDn(p)&&(a[f]=p)}),t[n]=void 0,a}}return i};return r(e,0)},Flw=e3t("AsyncFunction"),Rlw=e=>e&&(QMa(e)||oSe(e))&&oSe(e.then)&&oSe(e.catch),m7f=((e,t)=>e?setImmediate:t?((r,i)=>(Dli.addEventListener("message",({source:n,data:a})=>{n===Dli&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),Dli.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",oSe(Dli.postMessage)),Llw=typeof queueMicrotask<"u"?queueMicrotask.bind(Dli):typeof process<"u"&&process.nextTick||m7f,jl={isArray:aLi,isArrayBuffer:_7f,isBuffer:ilw,isFormData:dlw,isArrayBufferView:nlw,isString:alw,isNumber:h7f,isBoolean:olw,isObject:QMa,isPlainObject:WMa,isReadableStream:_lw,isRequest:hlw,isResponse:ylw,isHeaders:vlw,isUndefined:kDn,isDate:ulw,isFile:slw,isBlob:clw,isRegExp:Tlw,isFunction:oSe,isStream:flw,isURLSearchParams:plw,isTypedArray:Dlw,isFileList:llw,forEach:eSn,merge:qAu,extend:glw,trim:blw,stripBOM:mlw,inherits:Olw,toFlatObject:Plw,kindOf:HMa,kindOfTest:e3t,endsWith:jlw,toArray:wlw,forEachEntry:Slw,matchAll:Elw,isHTMLForm:Alw,hasOwnProperty:d7f,hasOwnProp:d7f,reduceDescriptors:b7f,freezeMethods:qlw,toObjectSet:Clw,toCamelCase:Mlw,noop:xlw,toFiniteNumber:Blw,findKey:y7f,global:Dli,isContextDefined:v7f,ALPHABET:g7f,generateString:Ilw,isSpecCompliantForm:zlw,toJSONObject:Nlw,isAsyncFn:Flw,isThenable:Rlw,setImmediate:m7f,asap:Llw};function oLi(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)}jl.inherits(oLi,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:jl.toJSONObject(this.config),code:this.code,status:this.status}}});var O7f=oLi.prototype,P7f={};["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=>{P7f[e]={value:e}});Object.defineProperties(oLi,P7f);Object.defineProperty(O7f,"isAxiosError",{value:!0});oLi.from=(e,t,r,i,n,a)=>{let u=Object.create(O7f);return jl.toFlatObject(e,u,function(p){return p!==Error.prototype},f=>f!=="isAxiosError"),oLi.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var hy=oLi;var j7f=go(ELr(),1),GMa=j7f.default;function xAu(e){return jl.isPlainObject(e)||jl.isArray(e)}function D7f(e){return jl.endsWith(e,"[]")?e.slice(0,-2):e}function w7f(e,t,r){return e?e.concat(t).map(function(n,a){return n=D7f(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function Ulw(e){return jl.isArray(e)&&!e.some(xAu)}var Vlw=jl.toFlatObject(jl,{},null,function(t){return/^is[A-Z]/.test(t)});function Wlw(e,t,r){if(!jl.isObject(e))throw new TypeError("target must be an object");t=t||new(GMa||FormData),r=jl.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,T){return!jl.isUndefined(T[A])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,p=(r.Blob||typeof Blob<"u"&&Blob)&&jl.isSpecCompliantForm(t);if(!jl.isFunction(n))throw new TypeError("visitor must be a function");function c(j){if(j===null)return"";if(jl.isDate(j))return j.toISOString();if(!p&&jl.isBlob(j))throw new hy("Blob is not supported. Use a Buffer instead.");return jl.isArrayBuffer(j)||jl.isTypedArray(j)?p&&typeof Blob=="function"?new Blob([j]):Buffer.from(j):j}function o(j,A,T){let B=j;if(j&&!T&&typeof j=="object"){if(jl.endsWith(A,"{}"))A=i?A:A.slice(0,-2),j=JSON.stringify(j);else if(jl.isArray(j)&&Ulw(j)||(jl.isFileList(j)||jl.endsWith(A,"[]"))&&(B=jl.toArray(j)))return A=D7f(A),B.forEach(function(C,N){!(jl.isUndefined(C)||C===null)&&t.append(u===!0?w7f([A],N,a):u===null?A:A+"[]",c(C))}),!1}return xAu(j)?!0:(t.append(w7f(T,A,a),c(j)),!1)}let l=[],m=Object.assign(Vlw,{defaultVisitor:o,convertValue:c,isVisitable:xAu});function O(j,A){if(!jl.isUndefined(j)){if(l.indexOf(j)!==-1)throw Error("Circular reference detected in "+A.join("."));l.push(j),jl.forEach(j,function(B,z){(!(jl.isUndefined(B)||B===null)&&n.call(t,B,jl.isString(z)?z.trim():z,A,m))===!0&&O(B,A?A.concat(z):[z])}),l.pop()}}if(!jl.isObject(e))throw new TypeError("data must be an object");return O(e),t}var TVr=Wlw;function S7f(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function E7f(e,t){this._pairs=[],e&&TVr(e,this,t)}var A7f=E7f.prototype;A7f.append=function(t,r){this._pairs.push([t,r])};A7f.toString=function(t){let r=t?function(i){return t.call(this,i,S7f)}:S7f;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var M7f=E7f;function Hlw(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Sli(e,t,r){if(!t)return e;let i=r&&r.encode||Hlw,n=r&&r.serialize,a;if(n?a=n(t,r):a=jl.isURLSearchParams(t)?t.toString():new M7f(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var BAu=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){jl.forEach(this.handlers,function(i){i!==null&&t(i)})}},IAu=BAu;var uLi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var T7f=go(require("url"),1),q7f=T7f.default.URLSearchParams;var C7f={isNode:!0,classes:{URLSearchParams:q7f,FormData:GMa,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var FAu={};Gs(FAu,{hasBrowserEnv:()=>NAu,hasStandardBrowserEnv:()=>Jlw,hasStandardBrowserWebWorkerEnv:()=>Qlw,navigator:()=>zAu,origin:()=>Glw});var NAu=typeof window<"u"&&typeof document<"u",zAu=typeof navigator=="object"&&navigator||void 0,Jlw=NAu&&(!zAu||["ReactNative","NativeScript","NS"].indexOf(zAu.product)<0),Qlw=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Glw=NAu&&window.location.href||"http://localhost";var KB={...FAu,...C7f};function RAu(e,t){return TVr(e,new KB.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return KB.isNode&&jl.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function $lw(e){return jl.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Klw(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 Ylw(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let f=Number.isFinite(+u),p=a>=r.length;return u=!u&&jl.isArray(n)?n.length:u,p?(jl.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!f):((!n[u]||!jl.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&jl.isArray(n[u])&&(n[u]=Klw(n[u])),!f)}if(jl.isFormData(e)&&jl.isFunction(e.entries)){let r={};return jl.forEachEntry(e,(i,n)=>{t($lw(i),n,r,0)}),r}return null}var $Ma=Ylw;function Xlw(e,t,r){if(jl.isString(e))try{return(t||JSON.parse)(e),jl.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var LAu={transitional:uLi,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=jl.isObject(t);if(a&&jl.isHTMLForm(t)&&(t=new FormData(t)),jl.isFormData(t))return n?JSON.stringify($Ma(t)):t;if(jl.isArrayBuffer(t)||jl.isBuffer(t)||jl.isStream(t)||jl.isFile(t)||jl.isBlob(t)||jl.isReadableStream(t))return t;if(jl.isArrayBufferView(t))return t.buffer;if(jl.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let f;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return RAu(t,this.formSerializer).toString();if((f=jl.isFileList(t))||i.indexOf("multipart/form-data")>-1){let p=this.env&&this.env.FormData;return TVr(f?{"files[]":t}:t,p&&new p,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),Xlw(t)):t}],transformResponse:[function(t){let r=this.transitional||LAu.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(jl.isResponse(t)||jl.isReadableStream(t))return t;if(t&&jl.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(f){if(u)throw f.name==="SyntaxError"?hy.from(f,hy.ERR_BAD_RESPONSE,this,null,this.response):f}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:KB.classes.FormData,Blob:KB.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};jl.forEach(["delete","get","head","post","put","patch"],e=>{LAu.headers[e]={}});var sLi=LAu;var Zlw=jl.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"]),x7f=e=>{let t={},r,i,n;return e&&e.split(`
1789
+ `}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&&YAa(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var Uzf=go(Bzf(),1),Vzf=go(xDu(),1),Wzf=go(Rzf(),1),OC=go(nSe(),1),Hzf=go(w1n(),1);var mMa=go(nSe(),1),Lzf=go(w1n(),1),OMa=function(e,t,r){return typeof e[t]!="function"?(0,mMa.of)(e):(0,mMa.from)((0,Lzf.default)(e[t])(r).then(i=>(e[t]=i,e)))};var zDn={isPlainObject:Uzf.default,set:Wzf.default,get:Vzf.default},K9i=class extends Oli{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=zDn.isPlainObject(r)?{...r}:{},zDn.isPlainObject(t)&&(t=Object.values(t).every(n=>zDn.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,OC.from)(t):t;return this.process=i.pipe((0,OC.concatMap)(this.processQuestion.bind(this)),(0,OC.publish)()),this.process.connect(),this.process.pipe((0,OC.reduce)((n,a)=>(zDn.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,OC.defer)(()=>(0,OC.of)(t).pipe((0,OC.concatMap)(this.setDefaultType.bind(this)),(0,OC.concatMap)(this.filterIfRunnable.bind(this)),(0,OC.concatMap)(()=>OMa(t,"message",this.answers)),(0,OC.concatMap)(()=>OMa(t,"default",this.answers)),(0,OC.concatMap)(()=>OMa(t,"choices",this.answers)),(0,OC.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,OC.defer)(()=>(0,OC.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,OC.defer)(()=>(0,OC.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&zDn.get(this.answers,t.name)!==void 0)return(0,OC.empty)();if(t.when===!1)return(0,OC.empty)();if(typeof t.when!="function")return(0,OC.of)(t);let{answers:r}=this;return(0,OC.defer)(()=>(0,OC.from)((0,Hzf.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,OC.filter)(i=>i!=null)))}};function Jzf(e){let t=function(r,i){let n;try{n=new K9i(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",bDn),this.registerPrompt("input",pli),this.registerPrompt("number",gDn),this.registerPrompt("confirm",mDn),this.registerPrompt("rawlist",ODn),this.registerPrompt("expand",PDn),this.registerPrompt("checkbox",jDn),this.registerPrompt("password",wDn),this.registerPrompt("editor",BDn)},t.restoreDefaultPrompts(),t}var xEu=Jzf();function puw(e,t){xEu.registerPrompt(e,t)}function _uw(){xEu.restoreDefaultPrompts()}var huw={prompt:xEu,ui:{BottomBar:IDn,Prompt:K9i},createPromptModule:Jzf,registerPrompt:puw,restoreDefaultPrompts:_uw,Separator:Jne},PMa=huw;var t7f=go(Qzf()),Rcw="4.2.1",k6t;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",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"})(k6t||(k6t={}));function Lcw(e,t){if(!e)throw new Error(t)}function Ucw(e){return e?.replace(/\/+$/,"")}async function Vcw(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 Wcw(){return new Date().getTime()}function GNf(){return new Date().toISOString()}function r7f(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var GDn=String.fromCharCode,$Nf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",IMa={};function Hcw(e,t){if(!IMa[e]){IMa[e]={};for(let r=0;r<e.length;r++)IMa[e][e.charAt(r)]=r}return IMa[e][t]}var $Dn={compressToBase64:function(e){if(e==null)return"";let t=$Dn._compress(e,6,function(r){return $Nf.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:$Dn._decompress(e.length,32,function(t){return Hcw($Nf,e.charAt(t))})},compress:function(e){return $Dn._compress(e,16,function(t){return GDn(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,f,p="",c="",o="",l=2,m=3,O=2,j=0,A=0,T;for(T=0;T<e.length;T+=1)if(p=e.charAt(T),Object.prototype.hasOwnProperty.call(i,p)||(i[p]=m++,n[p]=!0),c=o+p,Object.prototype.hasOwnProperty.call(i,c))o=c;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,A==t-1?(A=0,a.push(r(j)),j=0):A++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete n[o]}else for(f=i[o],u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++),i[c]=m++,o=String(p)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,A==t-1?(A=0,a.push(r(j)),j=0):A++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete n[o]}else for(f=i[o],u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++)}for(f=2,u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;for(;;)if(j=j<<1,A==t-1){a.push(r(j));break}else A++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:$Dn._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,f=4,p=3,c="",o,l,m,O,j,A,T;for(o=0;o<3;o+=1)i[o]=o;for(m=0,j=Math.pow(2,2),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;switch(m){case 0:for(m=0,j=Math.pow(2,8),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;T=GDn(m);break;case 1:for(m=0,j=Math.pow(2,16),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;T=GDn(m);break;case 2:return""}for(i[3]=T,l=T,n.push(T);;){if(a.index>e)return"";for(m=0,j=Math.pow(2,p),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;switch(T=m){case 0:for(m=0,j=Math.pow(2,8),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;i[f++]=GDn(m),T=f-1,u--;break;case 1:for(m=0,j=Math.pow(2,16),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;i[f++]=GDn(m),T=f-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,p),p++),i[T])c=i[T];else if(T===f)c=l+l.charAt(0);else return null;n.push(c),i[f++]=l+c.charAt(0),u--,l=c,u==0&&(u=Math.pow(2,p),p++)}}},mAu=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)}};var zMa="0123456789abcdef",NMa=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+=zMa.charAt(this.bytes[r]>>>4),t+=zMa.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+=zMa.charAt(this.bytes[r]>>>4),t+=zMa.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}},OAu=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??Jcw()}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 NMa.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,NMa.ofInner(t)}},Jcw=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),KNf,YNf=()=>Qcw().toString(),Qcw=()=>(KNf||(KNf=new OAu)).generate(),FMa=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},KDn=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function XNf(e){return typeof e=="object"&&(e instanceof FMa||e instanceof KDn)}var PAu=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new mAu,this._isInitialized=!1,Lcw(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=Ucw(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.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:XNf},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??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(k6t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(k6t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(k6t.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}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=YNf();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)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("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)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let f=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",f,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,f={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.fetchWithRetry(u,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(p=>p.json()).catch(p=>{this._events.emit("error",p)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let f=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!f)return;let p=f[t];return p===void 0&&(p=!1),p}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let f=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!f)return;let p=f[t];return p===void 0?null:p}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let f=await this.getDecide(t,r,i,n,u),p=f?.featureFlags,c=f?.featureFlagPayloads,o=c;return c&&(o=Object.fromEntries(Object.entries(c).map(([l,m])=>[l,this._parsePayload(m)]))),{flags:p,payloads:o}}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={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:GNf(),uuid:i?.uuid?i.uuid:YNf()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty(k6t.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty(k6t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=r7f(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}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(k6t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(c=>c.message),n=()=>{let c=this.getPersistedProperty(k6t.Queue)||[];this.setPersistedProperty(k6t.Queue,c.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:GNf()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),f=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${Wcw()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,p=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent($Dn.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(f,p)}catch(c){throw c instanceof KDn||n(),this._events.emit("error",c),c}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(f){let p=new AbortController;return setTimeout(()=>p.abort(),f),p.signal}),await Vcw(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(p){throw new KDn(p)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new FMa(u);return u},{...this._retryOptions,...i})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(k6t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!XNf(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},jAu=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},wAu=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!wAu){let e=QNf();wAu=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 i7f=wAu,Gcw=1152921504606847e3,$cw=["is_not"],RMa=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},b5=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},DAu=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...f}){this.debugMode=!1,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=f.fetch||i7f,this.onError=f.onError,this.customHeaders=u,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,f;if(!this.loadedSuccessfullyOnce)return u;for(let p of this.featureFlags)if(t===p.key){f=p;break}if(f!==void 0)try{u=this.computeFlagLocally(f,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(p){p instanceof b5?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${p}`)):p instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${p}`))}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={},f=this.featureFlags.length==0;return this.featureFlags.map(async p=>{try{let c=this.computeFlagLocally(p,t,r,i,n);a[p.key]=c;let o=await this.computeFeatureFlagPayloadLocally(p.key,c);o&&(u[p.key]=o)}catch(c){c instanceof b5||c instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${p.key}: ${c}`)),f=!0}}),{response:a,payloads:u,fallbackToDecide:f}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new b5("Flag has experience continuity enabled");if(!t.active)return!1;let f=(t.filters||{}).aggregation_group_type_index;if(f!=null){let p=this.groupTypeMapping[String(f)];if(!p)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${f} for feature flag ${t.key}`)),new b5("Flag has unknown group type index");if(!(p in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let c=a[p];return this.matchFeatureFlagProperties(t,i[p],c)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,f,p=[...a].sort((c,o)=>{let l=!!c.variant,m=!!o.variant;return l&&m?0:l?-1:m?1:0});for(let c of p)try{if(this.isConditionMatch(t,r,c,i)){let o=c.variant,l=n.multivariate?.variants||[];o&&l.some(m=>m.key===o)?f=o:f=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof b5)u=!0;else throw o}if(f!==void 0)return f;if(u)throw new b5("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=f=>{this.logMsgIfDebug(()=>console.warn(f))};if((i.properties||[]).length>0){for(let f of i.properties){let p=f.type,c=!1;if(p==="cohort"?c=a7f(f,n,this.cohorts,this.debugMode):c=n7f(f,n,u),!c)return!1}if(a==null)return!0}return!(a!=null&&ZNf(t.key,r)>a/100)}getMatchingVariant(t,r){let i=ZNf(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(f=>{n=i+f.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:f.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new RMa("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),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}catch(t){t instanceof RMa&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=r7f(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function ZNf(e,t,r=""){let i=(0,t7f.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/Gcw}function n7f(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 b5("Operator is_not_set is not supported")}else throw new b5(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!$cw.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function f(c,o){return Array.isArray(c)?c.map(l=>String(l).toLowerCase()).includes(String(o).toLowerCase()):String(c).toLowerCase()===String(o).toLowerCase()}function p(c,o,l){if(l==="gt")return c>o;if(l==="gte")return c>=o;if(l==="lt")return c<o;if(l==="lte")return c<=o;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return f(n,u);case"is_not":return!f(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 kNf(String(n))&&String(u).match(String(n))!==null;case"not_regex":return kNf(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let c=typeof n=="number"?n:null;if(typeof n=="string")try{c=parseFloat(n)}catch{}return c!=null&&u!=null?typeof u=="string"?p(u,String(n),a):p(u,c,a):p(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let c=Kcw(String(n));if(c==null&&(c=e7f(n)),c==null)throw new b5(`Invalid date: ${n}`);let o=e7f(u);return["is_date_before"].includes(a)?o<c:o>c}default:throw new b5(`Unknown operator: ${a}`)}}function a7f(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new b5("can't match cohort without a given cohort property value");let a=r[n];return o7f(a,t,r,i)}function o7f(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 f of a)try{let p=o7f(f,t,r,i);if(n==="AND"){if(!p)return!1}else if(p)return!0}catch(p){if(p instanceof b5)i&&console.debug(`Failed to compute property ${f} locally: ${p}`),u=!0;else throw p}if(u)throw new b5("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let f of a)try{let p;f.type==="cohort"?p=a7f(f,t,r,i):p=n7f(f,t);let c=f.negation||!1;if(n==="AND"){if(!p&&!c||p&&c)return!1}else if(p&&!c||!p&&c)return!0}catch(p){if(p instanceof b5)i&&console.debug(`Failed to compute property ${f} locally: ${p}`),u=!0;else throw p}if(u)throw new b5("can't match cohort without a given cohort property value");return n==="AND"}}function kNf(e){try{return new RegExp(e),!0}catch{return!1}}function e7f(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 b5(`${e} is in an invalid date format`)}else throw new b5(`The date provided ${e} must be a string, number, or date object`)}function Kcw(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 Ycw=30*1e3,Xcw=50*1e3,rLi=class extends PAu{constructor(t,r={}){super(t,r),this._memoryStorage=new jAu,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new DAu({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:Ycw,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||Xcw}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):i7f(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return Rcw}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({distinctId:t,event:r,properties:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:f,uuid:p}){let c=m=>{super.captureStateless(t,r,m,{timestamp:u,disableGeoip:f,uuid:p})},o=(m,O,j)=>super.getFeatureFlagsStateless(m,O,void 0,void 0,j),l=Promise.resolve().then(async()=>{if(a)return await o(t,n,f);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let m={};for(let[O,j]of Object.entries(n||{}))m[O]=String(j);return await this.getAllFlags(t,{groups:m,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(m=>{let O={};if(m)for(let[A,T]of Object.entries(m))O[`$feature/${A}`]=T;let j=Object.keys(m||{}).filter(A=>m?.[A]!==!1);return j.length>0&&(O.$active_feature_flags=j),O}).catch(()=>({})).then(m=>{c({...m,...i,$groups:n})});this.addPendingPromise(l)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:f,personProperties:p,groupProperties:c}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,p,c);p=o.allPersonProperties,c=o.allGroupProperties,u==null&&(u=!1),f==null&&(f=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,p,c),m=l!==void 0;!m&&!u&&(l=await super.getFeatureFlagStateless(t,r,n,p,c,a));let O=`${t}_${l}`;return f&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(O))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(O):this.distinctIdHasSentFlagCalls[r]=[O],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,locally_evaluated:m,[`$feature/${t}`]:l},groups:n,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:f,sendFeatureFlagEvents:p,personProperties:c,groupProperties:o}=n||{},l=this.addLocalPersonAndGroupProperties(r,a,c,o);c=l.allPersonProperties,o=l.allGroupProperties;let m;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(m=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),f==null&&(f=!1),p==null&&(p=!0),f==null&&(f=!1),!(m!==void 0)&&!f&&(m=await super.getFeatureFlagPayloadStateless(t,r,a,c,o,u)),m}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:f}=r||{},p=this.addLocalPersonAndGroupProperties(t,i,u,f);u=p.allPersonProperties,f=p.allGroupProperties,a==null&&(a=!1);let c=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,f),o={},l={},m=!0;if(c&&(o=c.response,l=c.payloads,m=c.fallbackToDecide),m&&!a){let O=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,f,n);o={...o,...O.flags||{}},l={...l,...O.payloads||{}}}return{featureFlags:o,featureFlagPayloads:l}}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 f of Object.keys(r))u[f]={$group_key:r[f],...n?.[f]||{}};return{allPersonProperties:a,allGroupProperties:u}}},SAu=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},f=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&f!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${f}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};SAu.POSTHOG_ID_TAG="posthog_distinct_id";var LMa=class{posthog;constructor({posthogApiKey:t}){this.posthog=new rLi(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.46.0",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var YDn=class{async sendEvent(){}async identify(){}async flush(){}};var iLi=require("fs/promises"),l7f=require("os"),f7f=require("path");var u7f=go(require("crypto")),VMa=new Uint8Array(256),UMa=VMa.length;function EAu(){return UMa>VMa.length-16&&(u7f.default.randomFillSync(VMa),UMa=0),VMa.slice(UMa,UMa+=16)}var jH=[];for(let e=0;e<256;++e)jH.push((e+256).toString(16).slice(1));function s7f(e,t=0){return jH[e[t+0]]+jH[e[t+1]]+jH[e[t+2]]+jH[e[t+3]]+"-"+jH[e[t+4]]+jH[e[t+5]]+"-"+jH[e[t+6]]+jH[e[t+7]]+"-"+jH[e[t+8]]+jH[e[t+9]]+"-"+jH[e[t+10]]+jH[e[t+11]]+jH[e[t+12]]+jH[e[t+13]]+jH[e[t+14]]+jH[e[t+15]]}var c7f=go(require("crypto")),AAu={randomUUID:c7f.default.randomUUID};function Zcw(e,t,r){if(AAu.randomUUID&&!t&&!e)return AAu.randomUUID();e=e||{};let i=e.random||(e.rng||EAu)();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 s7f(i)}var _Be=Zcw;var kcw="id",elw=".fern",XDn=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new rLi(r),this.userId=t==null?void 0:UOu(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.46.0",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Sf(f_.of((0,l7f.homedir)()),Pc.of(elw),Pc.of(kcw));await ph(t)||(await(0,iLi.mkdir)((0,f7f.dirname)(t),{recursive:!0}),await(0,iLi.writeFile)(t,_Be())),this.persistedDistinctId=(await(0,iLi.readFile)(t)).toString()}return this.persistedDistinctId}};var MAu;async function nLi(){return MAu==null&&(MAu=await tlw()),MAu}async function tlw(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new YDn;let r=await Rja();return r!=null?new XDn({token:r,posthogApiKey:e}):await Fja()!=null?new LMa({posthogApiKey:e}):new XDn({token:void 0,posthogApiKey:e})}catch{return new YDn}}function ZDn(e,t){return function(){return e.apply(t,arguments)}}var{toString:rlw}=Object.prototype,{getPrototypeOf:CAu}=Object,HMa=(e=>t=>{let r=rlw.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),e3t=e=>(e=e.toLowerCase(),t=>HMa(t)===e),JMa=e=>t=>typeof t===e,{isArray:aLi}=Array,kDn=JMa("undefined");function ilw(e){return e!==null&&!kDn(e)&&e.constructor!==null&&!kDn(e.constructor)&&oSe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var _7f=e3t("ArrayBuffer");function nlw(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&_7f(e.buffer),t}var alw=JMa("string"),oSe=JMa("function"),h7f=JMa("number"),QMa=e=>e!==null&&typeof e=="object",olw=e=>e===!0||e===!1,WMa=e=>{if(HMa(e)!=="object")return!1;let t=CAu(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},ulw=e3t("Date"),slw=e3t("File"),clw=e3t("Blob"),llw=e3t("FileList"),flw=e=>QMa(e)&&oSe(e.pipe),dlw=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||oSe(e.append)&&((t=HMa(e))==="formdata"||t==="object"&&oSe(e.toString)&&e.toString()==="[object FormData]"))},plw=e3t("URLSearchParams"),[_lw,hlw,ylw,vlw]=["ReadableStream","Request","Response","Headers"].map(e3t),blw=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function eSn(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),aLi(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,f;for(i=0;i<u;i++)f=a[i],t.call(null,e[f],f,e)}}function y7f(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 Dli=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,v7f=e=>!kDn(e)&&e!==Dli;function qAu(){let{caseless:e}=v7f(this)&&this||{},t={},r=(i,n)=>{let a=e&&y7f(t,n)||n;WMa(t[a])&&WMa(i)?t[a]=qAu(t[a],i):WMa(i)?t[a]=qAu({},i):aLi(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&eSn(arguments[i],r);return t}var glw=(e,t,r,{allOwnKeys:i}={})=>(eSn(t,(n,a)=>{r&&oSe(n)?e[a]=ZDn(n,r):e[a]=n},{allOwnKeys:i}),e),mlw=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Olw=(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)},Plw=(e,t,r,i)=>{let n,a,u,f={};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))&&!f[u]&&(t[u]=e[u],f[u]=!0);e=r!==!1&&CAu(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},jlw=(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},wlw=e=>{if(!e)return null;if(aLi(e))return e;let t=e.length;if(!h7f(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Dlw=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&CAu(Uint8Array)),Slw=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},Elw=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},Alw=e3t("HTMLFormElement"),Mlw=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),d7f=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Tlw=e3t("RegExp"),b7f=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};eSn(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},qlw=e=>{b7f(e,(t,r)=>{if(oSe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(oSe(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+"'")})}})},Clw=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return aLi(e)?i(e):i(String(e).split(t)),r},xlw=()=>{},Blw=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,TAu="abcdefghijklmnopqrstuvwxyz",p7f="0123456789",g7f={DIGIT:p7f,ALPHA:TAu,ALPHA_DIGIT:TAu+TAu.toUpperCase()+p7f},Ilw=(e=16,t=g7f.ALPHA_DIGIT)=>{let r="",{length:i}=t;for(;e--;)r+=t[Math.random()*i|0];return r};function zlw(e){return!!(e&&oSe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var Nlw=e=>{let t=new Array(10),r=(i,n)=>{if(QMa(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=aLi(i)?[]:{};return eSn(i,(u,f)=>{let p=r(u,n+1);!kDn(p)&&(a[f]=p)}),t[n]=void 0,a}}return i};return r(e,0)},Flw=e3t("AsyncFunction"),Rlw=e=>e&&(QMa(e)||oSe(e))&&oSe(e.then)&&oSe(e.catch),m7f=((e,t)=>e?setImmediate:t?((r,i)=>(Dli.addEventListener("message",({source:n,data:a})=>{n===Dli&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),Dli.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",oSe(Dli.postMessage)),Llw=typeof queueMicrotask<"u"?queueMicrotask.bind(Dli):typeof process<"u"&&process.nextTick||m7f,jl={isArray:aLi,isArrayBuffer:_7f,isBuffer:ilw,isFormData:dlw,isArrayBufferView:nlw,isString:alw,isNumber:h7f,isBoolean:olw,isObject:QMa,isPlainObject:WMa,isReadableStream:_lw,isRequest:hlw,isResponse:ylw,isHeaders:vlw,isUndefined:kDn,isDate:ulw,isFile:slw,isBlob:clw,isRegExp:Tlw,isFunction:oSe,isStream:flw,isURLSearchParams:plw,isTypedArray:Dlw,isFileList:llw,forEach:eSn,merge:qAu,extend:glw,trim:blw,stripBOM:mlw,inherits:Olw,toFlatObject:Plw,kindOf:HMa,kindOfTest:e3t,endsWith:jlw,toArray:wlw,forEachEntry:Slw,matchAll:Elw,isHTMLForm:Alw,hasOwnProperty:d7f,hasOwnProp:d7f,reduceDescriptors:b7f,freezeMethods:qlw,toObjectSet:Clw,toCamelCase:Mlw,noop:xlw,toFiniteNumber:Blw,findKey:y7f,global:Dli,isContextDefined:v7f,ALPHABET:g7f,generateString:Ilw,isSpecCompliantForm:zlw,toJSONObject:Nlw,isAsyncFn:Flw,isThenable:Rlw,setImmediate:m7f,asap:Llw};function oLi(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)}jl.inherits(oLi,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:jl.toJSONObject(this.config),code:this.code,status:this.status}}});var O7f=oLi.prototype,P7f={};["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=>{P7f[e]={value:e}});Object.defineProperties(oLi,P7f);Object.defineProperty(O7f,"isAxiosError",{value:!0});oLi.from=(e,t,r,i,n,a)=>{let u=Object.create(O7f);return jl.toFlatObject(e,u,function(p){return p!==Error.prototype},f=>f!=="isAxiosError"),oLi.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var hy=oLi;var j7f=go(ELr(),1),GMa=j7f.default;function xAu(e){return jl.isPlainObject(e)||jl.isArray(e)}function D7f(e){return jl.endsWith(e,"[]")?e.slice(0,-2):e}function w7f(e,t,r){return e?e.concat(t).map(function(n,a){return n=D7f(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function Ulw(e){return jl.isArray(e)&&!e.some(xAu)}var Vlw=jl.toFlatObject(jl,{},null,function(t){return/^is[A-Z]/.test(t)});function Wlw(e,t,r){if(!jl.isObject(e))throw new TypeError("target must be an object");t=t||new(GMa||FormData),r=jl.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,T){return!jl.isUndefined(T[A])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,p=(r.Blob||typeof Blob<"u"&&Blob)&&jl.isSpecCompliantForm(t);if(!jl.isFunction(n))throw new TypeError("visitor must be a function");function c(j){if(j===null)return"";if(jl.isDate(j))return j.toISOString();if(!p&&jl.isBlob(j))throw new hy("Blob is not supported. Use a Buffer instead.");return jl.isArrayBuffer(j)||jl.isTypedArray(j)?p&&typeof Blob=="function"?new Blob([j]):Buffer.from(j):j}function o(j,A,T){let B=j;if(j&&!T&&typeof j=="object"){if(jl.endsWith(A,"{}"))A=i?A:A.slice(0,-2),j=JSON.stringify(j);else if(jl.isArray(j)&&Ulw(j)||(jl.isFileList(j)||jl.endsWith(A,"[]"))&&(B=jl.toArray(j)))return A=D7f(A),B.forEach(function(C,N){!(jl.isUndefined(C)||C===null)&&t.append(u===!0?w7f([A],N,a):u===null?A:A+"[]",c(C))}),!1}return xAu(j)?!0:(t.append(w7f(T,A,a),c(j)),!1)}let l=[],m=Object.assign(Vlw,{defaultVisitor:o,convertValue:c,isVisitable:xAu});function O(j,A){if(!jl.isUndefined(j)){if(l.indexOf(j)!==-1)throw Error("Circular reference detected in "+A.join("."));l.push(j),jl.forEach(j,function(B,z){(!(jl.isUndefined(B)||B===null)&&n.call(t,B,jl.isString(z)?z.trim():z,A,m))===!0&&O(B,A?A.concat(z):[z])}),l.pop()}}if(!jl.isObject(e))throw new TypeError("data must be an object");return O(e),t}var TVr=Wlw;function S7f(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function E7f(e,t){this._pairs=[],e&&TVr(e,this,t)}var A7f=E7f.prototype;A7f.append=function(t,r){this._pairs.push([t,r])};A7f.toString=function(t){let r=t?function(i){return t.call(this,i,S7f)}:S7f;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var M7f=E7f;function Hlw(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Sli(e,t,r){if(!t)return e;let i=r&&r.encode||Hlw,n=r&&r.serialize,a;if(n?a=n(t,r):a=jl.isURLSearchParams(t)?t.toString():new M7f(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var BAu=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){jl.forEach(this.handlers,function(i){i!==null&&t(i)})}},IAu=BAu;var uLi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var T7f=go(require("url"),1),q7f=T7f.default.URLSearchParams;var C7f={isNode:!0,classes:{URLSearchParams:q7f,FormData:GMa,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var FAu={};Gs(FAu,{hasBrowserEnv:()=>NAu,hasStandardBrowserEnv:()=>Jlw,hasStandardBrowserWebWorkerEnv:()=>Qlw,navigator:()=>zAu,origin:()=>Glw});var NAu=typeof window<"u"&&typeof document<"u",zAu=typeof navigator=="object"&&navigator||void 0,Jlw=NAu&&(!zAu||["ReactNative","NativeScript","NS"].indexOf(zAu.product)<0),Qlw=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Glw=NAu&&window.location.href||"http://localhost";var KB={...FAu,...C7f};function RAu(e,t){return TVr(e,new KB.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return KB.isNode&&jl.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function $lw(e){return jl.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Klw(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 Ylw(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let f=Number.isFinite(+u),p=a>=r.length;return u=!u&&jl.isArray(n)?n.length:u,p?(jl.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!f):((!n[u]||!jl.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&jl.isArray(n[u])&&(n[u]=Klw(n[u])),!f)}if(jl.isFormData(e)&&jl.isFunction(e.entries)){let r={};return jl.forEachEntry(e,(i,n)=>{t($lw(i),n,r,0)}),r}return null}var $Ma=Ylw;function Xlw(e,t,r){if(jl.isString(e))try{return(t||JSON.parse)(e),jl.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var LAu={transitional:uLi,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=jl.isObject(t);if(a&&jl.isHTMLForm(t)&&(t=new FormData(t)),jl.isFormData(t))return n?JSON.stringify($Ma(t)):t;if(jl.isArrayBuffer(t)||jl.isBuffer(t)||jl.isStream(t)||jl.isFile(t)||jl.isBlob(t)||jl.isReadableStream(t))return t;if(jl.isArrayBufferView(t))return t.buffer;if(jl.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let f;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return RAu(t,this.formSerializer).toString();if((f=jl.isFileList(t))||i.indexOf("multipart/form-data")>-1){let p=this.env&&this.env.FormData;return TVr(f?{"files[]":t}:t,p&&new p,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),Xlw(t)):t}],transformResponse:[function(t){let r=this.transitional||LAu.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(jl.isResponse(t)||jl.isReadableStream(t))return t;if(t&&jl.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(f){if(u)throw f.name==="SyntaxError"?hy.from(f,hy.ERR_BAD_RESPONSE,this,null,this.response):f}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:KB.classes.FormData,Blob:KB.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};jl.forEach(["delete","get","head","post","put","patch"],e=>{LAu.headers[e]={}});var sLi=LAu;var Zlw=jl.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"]),x7f=e=>{let t={},r,i,n;return e&&e.split(`
1790
1790
  `).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&Zlw[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var B7f=Symbol("internals");function tSn(e){return e&&String(e).trim().toLowerCase()}function KMa(e){return e===!1||e==null?e:jl.isArray(e)?e.map(KMa):String(e)}function klw(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 efw=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function UAu(e,t,r,i,n){if(jl.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!jl.isString(t)){if(jl.isString(i))return t.indexOf(i)!==-1;if(jl.isRegExp(i))return i.test(t)}}function tfw(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function rfw(e,t){let r=jl.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 cLi=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(f,p,c){let o=tSn(p);if(!o)throw new Error("header name must be a non-empty string");let l=jl.findKey(n,o);(!l||n[l]===void 0||c===!0||c===void 0&&n[l]!==!1)&&(n[l||p]=KMa(f))}let u=(f,p)=>jl.forEach(f,(c,o)=>a(c,o,p));if(jl.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(jl.isString(t)&&(t=t.trim())&&!efw(t))u(x7f(t),r);else if(jl.isHeaders(t))for(let[f,p]of t.entries())a(p,f,i);else t!=null&&a(r,t,i);return this}get(t,r){if(t=tSn(t),t){let i=jl.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return klw(n);if(jl.isFunction(r))return r.call(this,n,i);if(jl.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=tSn(t),t){let i=jl.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||UAu(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=tSn(u),u){let f=jl.findKey(i,u);f&&(!r||UAu(i,i[f],f,r))&&(delete i[f],n=!0)}}return jl.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||UAu(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return jl.forEach(this,(n,a)=>{let u=jl.findKey(i,a);if(u){r[u]=KMa(n),delete r[a];return}let f=t?tfw(a):String(a).trim();f!==a&&delete r[a],r[f]=KMa(n),i[f]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return jl.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&jl.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(`
1791
1791
  `)}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[B7f]=this[B7f]={accessors:{}}).accessors,n=this.prototype;function a(u){let f=tSn(u);i[f]||(rfw(n,u),i[f]=!0)}return jl.isArray(t)?t.forEach(a):a(t),this}};cLi.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);jl.reduceDescriptors(cLi.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});jl.freezeMethods(cLi);var r7=cLi;function rSn(e,t){let r=this||sLi,i=t||r,n=r7.from(i.headers),a=i.data;return jl.forEach(e,function(f){a=f.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function iSn(e){return!!(e&&e.__CANCEL__)}function I7f(e,t,r){hy.call(this,e??"canceled",hy.ERR_CANCELED,t,r),this.name="CanceledError"}jl.inherits(I7f,hy,{__CANCEL__:!0});var uSe=I7f;function dHt(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new hy("Request failed with status code "+r.status,[hy.ERR_BAD_REQUEST,hy.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function VAu(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function WAu(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Eli(e,t){return e&&!VAu(t)?WAu(e,t):t}var X7f=go(IEu(),1),Z7f=go(require("http"),1),k7f=go(require("https"),1),e6f=go(require("util"),1),t6f=go($Eu(),1),z2r=go(require("zlib"),1);var Ali="1.7.7";function nSn(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var ifw=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function HAu(e,t,r){let i=r&&r.Blob||KB.classes.Blob,n=nSn(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=ifw.exec(e);if(!a)throw new hy("Invalid URL",hy.ERR_INVALID_URL);let u=a[1],f=a[2],p=a[3],c=Buffer.from(decodeURIComponent(p),f?"base64":"utf8");if(t){if(!i)throw new hy("Blob is not supported",hy.ERR_NOT_SUPPORT);return new i([c],{type:u})}return c}throw new hy("Unsupported protocol "+n,hy.ERR_NOT_SUPPORT)}var Mli=go(require("stream"),1);var z7f=go(require("stream"),1);var JAu=Symbol("internals"),QAu=class extends z7f.default.Transform{constructor(t){t=jl.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!jl.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[JAu]={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[JAu];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[JAu],a=n.maxRate,u=this.readableHighWaterMark,f=n.timeWindow,p=1e3/f,c=a/p,o=n.minChunkSize!==!1?Math.max(n.minChunkSize,c*.01):0,l=(O,j)=>{let A=Buffer.byteLength(O);n.bytesSeen+=A,n.bytes+=A,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(O)?process.nextTick(j):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(j)}},m=(O,j)=>{let A=Buffer.byteLength(O),T=null,B=u,z,C=0;if(a){let N=Date.now();(!n.ts||(C=N-n.ts)>=f)&&(n.ts=N,z=c-n.bytes,n.bytes=z<0?-z:0,C=0),z=c-n.bytes}if(a){if(z<=0)return setTimeout(()=>{j(null,O)},f-C);z<B&&(B=z)}B&&A>B&&A-B>o&&(T=O.subarray(B),O=O.subarray(0,B)),l(O,T?()=>{process.nextTick(j,null,T)}:j)};m(t,function O(j,A){if(j)return i(j);A?m(A,O):i(null)})}},GAu=QAu;var r6f=require("events");var F7f=require("util"),R7f=require("stream");var{asyncIterator:N7f}=Symbol,nfw=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[N7f]?yield*e[N7f]():yield e},YMa=nfw;var afw=jl.ALPHABET.ALPHA_DIGIT+"-_",aSn=new F7f.TextEncoder,qVr=`\r
1792
1792
  `,ofw=aSn.encode(qVr),ufw=2,$Au=class{constructor(t,r){let{escapeName:i}=this.constructor,n=jl.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${qVr}`;n?r=aSn.encode(String(r).replace(/\r?\n|\r\n?/g,qVr)):a+=`Content-Type: ${r.type||"application/octet-stream"}${qVr}`,this.headers=aSn.encode(a+qVr),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+ufw,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;jl.isTypedArray(t)?yield t:yield*YMa(t),yield ofw}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},sfw=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+jl.generateString(n,afw)}=r||{};if(!jl.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=aSn.encode("--"+a+qVr),f=aSn.encode("--"+a+"--"+qVr+qVr),p=f.byteLength,c=Array.from(e.entries()).map(([l,m])=>{let O=new $Au(l,m);return p+=O.size,O});p+=u.byteLength*c.length,p=jl.toFiniteNumber(p);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(p)&&(o["Content-Length"]=p),t&&t(o),R7f.Readable.from(async function*(){for(let l of c)yield u,yield*l.encode();yield f}())},L7f=sfw;var U7f=go(require("stream"),1),KAu=class extends U7f.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)}},V7f=KAu;var cfw=(e,t)=>jl.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,W7f=cfw;function lfw(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(p){let c=Date.now(),o=i[a];u||(u=c),r[n]=p,i[n]=c;let l=a,m=0;for(;l!==n;)m+=r[l++],l=l%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),c-u<t)return;let O=o&&c-o;return O?Math.round(m*1e3/O):void 0}}var H7f=lfw;function ffw(e,t){let r=0,i=1e3/t,n,a,u=(c,o=Date.now())=>{r=o,n=null,a&&(clearTimeout(a),a=null),e.apply(null,c)};return[(...c)=>{let o=Date.now(),l=o-r;l>=i?u(c,o):(n=c,a||(a=setTimeout(()=>{a=null,u(n)},i-l)))},()=>n&&u(n)]}var J7f=ffw;var I2r=(e,t,r=3)=>{let i=0,n=H7f(50,250);return J7f(a=>{let u=a.loaded,f=a.lengthComputable?a.total:void 0,p=u-i,c=n(p),o=u<=f;i=u;let l={loaded:u,total:f,progress:f?u/f:void 0,bytes:p,rate:c||void 0,estimated:c&&f&&o?(f-u)/c:void 0,event:a,lengthComputable:f!=null,[t?"download":"upload"]:!0};e(l)},r)},lLi=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},fLi=e=>(...t)=>jl.asap(()=>e(...t));var Q7f={flush:z2r.default.constants.Z_SYNC_FLUSH,finishFlush:z2r.default.constants.Z_SYNC_FLUSH},dfw={flush:z2r.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:z2r.default.constants.BROTLI_OPERATION_FLUSH},G7f=jl.isFunction(z2r.default.createBrotliDecompress),{http:pfw,https:_fw}=t6f.default,hfw=/https:?/,$7f=KB.protocols.map(e=>e+":"),K7f=(e,[t,r])=>(e.on("end",r).on("error",r),t);function yfw(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function i6f(e,t,r){let i=t;if(!i&&i!==!1){let n=(0,X7f.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){i6f(a,t,a.href)}}var vfw=typeof process<"u"&&jl.kindOf(process)==="process",bfw=e=>new Promise((t,r)=>{let i,n,a=(p,c)=>{n||(n=!0,i&&i(p,c))},u=p=>{a(p),t(p)},f=p=>{a(p,!0),r(p)};e(u,f,p=>i=p).catch(f)}),gfw=({address:e,family:t})=>{if(!jl.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},Y7f=(e,t)=>gfw(jl.isObject(e)?e:{address:e,family:t}),n6f=vfw&&function(t){return bfw(async function(i,n,a){let{data:u,lookup:f,family:p}=t,{responseType:c,responseEncoding:o}=t,l=t.method.toUpperCase(),m,O=!1,j;if(f){let sr=W7f(f,Wr=>jl.isArray(Wr)?Wr:[Wr]);f=(Wr,gi,Yt)=>{sr(Wr,gi,(Mr,Ei,br)=>{if(Mr)return Yt(Mr);let Ii=jl.isArray(Ei)?Ei.map(pi=>Y7f(pi)):[Y7f(Ei,br)];gi.all?Yt(Mr,Ii):Yt(Mr,Ii[0].address,Ii[0].family)})}}let A=new r6f.EventEmitter,T=()=>{t.cancelToken&&t.cancelToken.unsubscribe(B),t.signal&&t.signal.removeEventListener("abort",B),A.removeAllListeners()};a((sr,Wr)=>{m=!0,Wr&&(O=!0,T())});function B(sr){A.emit("abort",!sr||sr.type?new uSe(null,t,j):sr)}A.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(B),t.signal&&(t.signal.aborted?B():t.signal.addEventListener("abort",B)));let z=Eli(t.baseURL,t.url),C=new URL(z,KB.hasBrowserEnv?KB.origin:void 0),N=C.protocol||$7f[0];if(N==="data:"){let sr;if(l!=="GET")return dHt(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{sr=HAu(t.url,c==="blob",{Blob:t.env&&t.env.Blob})}catch(Wr){throw hy.from(Wr,hy.ERR_BAD_REQUEST,t)}return c==="text"?(sr=sr.toString(o),(!o||o==="utf8")&&(sr=jl.stripBOM(sr))):c==="stream"&&(sr=Mli.default.Readable.from(sr)),dHt(i,n,{data:sr,status:200,statusText:"OK",headers:new r7,config:t})}if($7f.indexOf(N)===-1)return n(new hy("Unsupported protocol "+N,hy.ERR_BAD_REQUEST,t));let U=r7.from(t.headers).normalize();U.set("User-Agent","axios/"+Ali,!1);let{onUploadProgress:k,onDownloadProgress:ve}=t,Y=t.maxRate,X,Ae;if(jl.isSpecCompliantForm(u)){let sr=U.getContentType(/boundary=([-_\w\d]{10,70})/i);u=L7f(u,Wr=>{U.set(Wr)},{tag:`axios-${Ali}-boundary`,boundary:sr&&sr[1]||void 0})}else if(jl.isFormData(u)&&jl.isFunction(u.getHeaders)){if(U.set(u.getHeaders()),!U.hasContentLength())try{let sr=await e6f.default.promisify(u.getLength).call(u);Number.isFinite(sr)&&sr>=0&&U.setContentLength(sr)}catch{}}else if(jl.isBlob(u))u.size&&U.setContentType(u.type||"application/octet-stream"),U.setContentLength(u.size||0),u=Mli.default.Readable.from(YMa(u));else if(u&&!jl.isStream(u)){if(!Buffer.isBuffer(u))if(jl.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(jl.isString(u))u=Buffer.from(u,"utf-8");else return n(new hy("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",hy.ERR_BAD_REQUEST,t));if(U.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new hy("Request body larger than maxBodyLength limit",hy.ERR_BAD_REQUEST,t))}let pt=jl.toFiniteNumber(U.getContentLength());jl.isArray(Y)?(X=Y[0],Ae=Y[1]):X=Ae=Y,u&&(k||X)&&(jl.isStream(u)||(u=Mli.default.Readable.from(u,{objectMode:!1})),u=Mli.default.pipeline([u,new GAu({maxRate:jl.toFiniteNumber(X)})],jl.noop),k&&u.on("progress",K7f(u,lLi(pt,I2r(fLi(k),!1,3)))));let ct;if(t.auth){let sr=t.auth.username||"",Wr=t.auth.password||"";ct=sr+":"+Wr}if(!ct&&C.username){let sr=C.username,Wr=C.password;ct=sr+":"+Wr}ct&&U.delete("authorization");let Dt;try{Dt=Sli(C.pathname+C.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(sr){let Wr=new Error(sr.message);return Wr.config=t,Wr.url=t.url,Wr.exists=!0,n(Wr)}U.set("Accept-Encoding","gzip, compress, deflate"+(G7f?", br":""),!1);let Rt={path:Dt,method:l,headers:U.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:ct,protocol:N,family:p,beforeRedirect:yfw,beforeRedirects:{}};!jl.isUndefined(f)&&(Rt.lookup=f),t.socketPath?Rt.socketPath=t.socketPath:(Rt.hostname=C.hostname.startsWith("[")?C.hostname.slice(1,-1):C.hostname,Rt.port=C.port,i6f(Rt,t.proxy,N+"//"+C.hostname+(C.port?":"+C.port:"")+Rt.path));let Xt,Vt=hfw.test(Rt.protocol);if(Rt.agent=Vt?t.httpsAgent:t.httpAgent,t.transport?Xt=t.transport:t.maxRedirects===0?Xt=Vt?k7f.default:Z7f.default:(t.maxRedirects&&(Rt.maxRedirects=t.maxRedirects),t.beforeRedirect&&(Rt.beforeRedirects.config=t.beforeRedirect),Xt=Vt?_fw:pfw),t.maxBodyLength>-1?Rt.maxBodyLength=t.maxBodyLength:Rt.maxBodyLength=1/0,t.insecureHTTPParser&&(Rt.insecureHTTPParser=t.insecureHTTPParser),j=Xt.request(Rt,function(Wr){if(j.destroyed)return;let gi=[Wr],Yt=+Wr.headers["content-length"];if(ve||Ae){let pi=new GAu({maxRate:jl.toFiniteNumber(Ae)});ve&&pi.on("progress",K7f(pi,lLi(Yt,I2r(fLi(ve),!0,3)))),gi.push(pi)}let Mr=Wr,Ei=Wr.req||j;if(t.decompress!==!1&&Wr.headers["content-encoding"])switch((l==="HEAD"||Wr.statusCode===204)&&delete Wr.headers["content-encoding"],(Wr.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":gi.push(z2r.default.createUnzip(Q7f)),delete Wr.headers["content-encoding"];break;case"deflate":gi.push(new V7f),gi.push(z2r.default.createUnzip(Q7f)),delete Wr.headers["content-encoding"];break;case"br":G7f&&(gi.push(z2r.default.createBrotliDecompress(dfw)),delete Wr.headers["content-encoding"])}Mr=gi.length>1?Mli.default.pipeline(gi,jl.noop):gi[0];let br=Mli.default.finished(Mr,()=>{br(),T()}),Ii={status:Wr.statusCode,statusText:Wr.statusMessage,headers:new r7(Wr.headers),config:t,request:Ei};if(c==="stream")Ii.data=Mr,dHt(i,n,Ii);else{let pi=[],Ft=0;Mr.on("data",function(ei){pi.push(ei),Ft+=ei.length,t.maxContentLength>-1&&Ft>t.maxContentLength&&(O=!0,Mr.destroy(),n(new hy("maxContentLength size of "+t.maxContentLength+" exceeded",hy.ERR_BAD_RESPONSE,t,Ei)))}),Mr.on("aborted",function(){if(O)return;let ei=new hy("maxContentLength size of "+t.maxContentLength+" exceeded",hy.ERR_BAD_RESPONSE,t,Ei);Mr.destroy(ei),n(ei)}),Mr.on("error",function(ei){j.destroyed||n(hy.from(ei,null,t,Ei))}),Mr.on("end",function(){try{let ei=pi.length===1?pi[0]:Buffer.concat(pi);c!=="arraybuffer"&&(ei=ei.toString(o),(!o||o==="utf8")&&(ei=jl.stripBOM(ei))),Ii.data=ei}catch(ei){return n(hy.from(ei,null,t,Ii.request,Ii))}dHt(i,n,Ii)})}A.once("abort",pi=>{Mr.destroyed||(Mr.emit("error",pi),Mr.destroy())})}),A.once("abort",sr=>{n(sr),j.destroy(sr)}),j.on("error",function(Wr){n(hy.from(Wr,null,t,j))}),j.on("socket",function(Wr){Wr.setKeepAlive(!0,1e3*60)}),t.timeout){let sr=parseInt(t.timeout,10);if(Number.isNaN(sr)){n(new hy("error trying to parse `config.timeout` to int",hy.ERR_BAD_OPTION_VALUE,t,j));return}j.setTimeout(sr,function(){if(m)return;let gi=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",Yt=t.transitional||uLi;t.timeoutErrorMessage&&(gi=t.timeoutErrorMessage),n(new hy(gi,Yt.clarifyTimeoutError?hy.ETIMEDOUT:hy.ECONNABORTED,t,j)),B()})}if(jl.isStream(u)){let sr=!1,Wr=!1;u.on("end",()=>{sr=!0}),u.once("error",gi=>{Wr=!0,j.destroy(gi)}),u.on("close",()=>{!sr&&!Wr&&B(new uSe("Request stream has been aborted",t,j))}),u.pipe(j)}else j.end(u)})};var a6f=KB.hasStandardBrowserEnv?function(){let t=KB.navigator&&/(msie|trident)/i.test(KB.navigator.userAgent),r=document.createElement("a"),i;function n(a){let u=a;return t&&(r.setAttribute("href",u),u=r.href),r.setAttribute("href",u),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return i=n(window.location.href),function(u){let f=jl.isString(u)?n(u):u;return f.protocol===i.protocol&&f.host===i.host}}():function(){return function(){return!0}}();var o6f=KB.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];jl.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),jl.isString(i)&&u.push("path="+i),jl.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 u6f=e=>e instanceof r7?{...e}:e;function t3t(e,t){t=t||{};let r={};function i(c,o,l){return jl.isPlainObject(c)&&jl.isPlainObject(o)?jl.merge.call({caseless:l},c,o):jl.isPlainObject(o)?jl.merge({},o):jl.isArray(o)?o.slice():o}function n(c,o,l){if(jl.isUndefined(o)){if(!jl.isUndefined(c))return i(void 0,c,l)}else return i(c,o,l)}function a(c,o){if(!jl.isUndefined(o))return i(void 0,o)}function u(c,o){if(jl.isUndefined(o)){if(!jl.isUndefined(c))return i(void 0,c)}else return i(void 0,o)}function f(c,o,l){if(l in t)return i(c,o);if(l in e)return i(void 0,c)}let p={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:f,headers:(c,o)=>n(u6f(c),u6f(o),!0)};return jl.forEach(Object.keys(Object.assign({},e,t)),function(o){let l=p[o]||n,m=l(e[o],t[o],o);jl.isUndefined(m)&&l!==f||(r[o]=m)}),r}var XMa=e=>{let t=t3t({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:f}=t;t.headers=u=r7.from(u),t.url=Sli(Eli(t.baseURL,t.url),e.params,e.paramsSerializer),f&&u.set("Authorization","Basic "+btoa((f.username||"")+":"+(f.password?unescape(encodeURIComponent(f.password)):"")));let p;if(jl.isFormData(r)){if(KB.hasStandardBrowserEnv||KB.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((p=u.getContentType())!==!1){let[c,...o]=p?p.split(";").map(l=>l.trim()).filter(Boolean):[];u.setContentType([c||"multipart/form-data",...o].join("; "))}}if(KB.hasStandardBrowserEnv&&(i&&jl.isFunction(i)&&(i=i(t)),i||i!==!1&&a6f(t.url))){let c=n&&a&&o6f.read(a);c&&u.set(n,c)}return t};var mfw=typeof XMLHttpRequest<"u",s6f=mfw&&function(e){return new Promise(function(r,i){let n=XMa(e),a=n.data,u=r7.from(n.headers).normalize(),{responseType:f,onUploadProgress:p,onDownloadProgress:c}=n,o,l,m,O,j;function A(){O&&O(),j&&j(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let T=new XMLHttpRequest;T.open(n.method.toUpperCase(),n.url,!0),T.timeout=n.timeout;function B(){if(!T)return;let C=r7.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),U={data:!f||f==="text"||f==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:C,config:e,request:T};dHt(function(ve){r(ve),A()},function(ve){i(ve),A()},U),T=null}"onloadend"in T?T.onloadend=B:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(B)},T.onabort=function(){T&&(i(new hy("Request aborted",hy.ECONNABORTED,e,T)),T=null)},T.onerror=function(){i(new hy("Network Error",hy.ERR_NETWORK,e,T)),T=null},T.ontimeout=function(){let N=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",U=n.transitional||uLi;n.timeoutErrorMessage&&(N=n.timeoutErrorMessage),i(new hy(N,U.clarifyTimeoutError?hy.ETIMEDOUT:hy.ECONNABORTED,e,T)),T=null},a===void 0&&u.setContentType(null),"setRequestHeader"in T&&jl.forEach(u.toJSON(),function(N,U){T.setRequestHeader(U,N)}),jl.isUndefined(n.withCredentials)||(T.withCredentials=!!n.withCredentials),f&&f!=="json"&&(T.responseType=n.responseType),c&&([m,j]=I2r(c,!0),T.addEventListener("progress",m)),p&&T.upload&&([l,O]=I2r(p),T.upload.addEventListener("progress",l),T.upload.addEventListener("loadend",O)),(n.cancelToken||n.signal)&&(o=C=>{T&&(i(!C||C.type?new uSe(null,e,T):C),T.abort(),T=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let z=nSn(n.url);if(z&&KB.protocols.indexOf(z)===-1){i(new hy("Unsupported protocol "+z+":",hy.ERR_BAD_REQUEST,e));return}T.send(a||null)})};var Ofw=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(c){if(!n){n=!0,f();let o=c instanceof Error?c:this.reason;i.abort(o instanceof hy?o:new uSe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new hy(`timeout ${t} of ms exceeded`,hy.ETIMEDOUT))},t),f=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(a):c.removeEventListener("abort",a)}),e=null)};e.forEach(c=>c.addEventListener("abort",a));let{signal:p}=i;return p.unsubscribe=()=>jl.asap(f),p}},c6f=Ofw;var Pfw=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},jfw=async function*(e,t){for await(let r of wfw(e))yield*Pfw(r,t)},wfw=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()}},YAu=(e,t,r,i)=>{let n=jfw(e,t),a=0,u,f=p=>{u||(u=!0,i&&i(p))};return new ReadableStream({async pull(p){try{let{done:c,value:o}=await n.next();if(c){f(),p.close();return}let l=o.byteLength;if(r){let m=a+=l;r(m)}p.enqueue(new Uint8Array(o))}catch(c){throw f(c),c}},cancel(p){return f(p),n.return()}},{highWaterMark:2})};var kMa=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",f6f=kMa&&typeof ReadableStream=="function",Dfw=kMa&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),d6f=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Sfw=f6f&&d6f(()=>{let e=!1,t=new Request(KB.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),l6f=64*1024,XAu=f6f&&d6f(()=>jl.isReadableStream(new Response("").body)),ZMa={stream:XAu&&(e=>e.body)};kMa&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!ZMa[t]&&(ZMa[t]=jl.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new hy(`Response type '${t}' is not supported`,hy.ERR_NOT_SUPPORT,i)})})})(new Response);var Efw=async e=>{if(e==null)return 0;if(jl.isBlob(e))return e.size;if(jl.isSpecCompliantForm(e))return(await new Request(KB.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(jl.isArrayBufferView(e)||jl.isArrayBuffer(e))return e.byteLength;if(jl.isURLSearchParams(e)&&(e=e+""),jl.isString(e))return(await Dfw(e)).byteLength},Afw=async(e,t)=>{let r=jl.toFiniteNumber(e.getContentLength());return r??Efw(t)},p6f=kMa&&(async e=>{let{url:t,method:r,data:i,signal:n,cancelToken:a,timeout:u,onDownloadProgress:f,onUploadProgress:p,responseType:c,headers:o,withCredentials:l="same-origin",fetchOptions:m}=XMa(e);c=c?(c+"").toLowerCase():"text";let O=c6f([n,a&&a.toAbortSignal()],u),j,A=O&&O.unsubscribe&&(()=>{O.unsubscribe()}),T;try{if(p&&Sfw&&r!=="get"&&r!=="head"&&(T=await Afw(o,i))!==0){let U=new Request(t,{method:"POST",body:i,duplex:"half"}),k;if(jl.isFormData(i)&&(k=U.headers.get("content-type"))&&o.setContentType(k),U.body){let[ve,Y]=lLi(T,I2r(fLi(p)));i=YAu(U.body,l6f,ve,Y)}}jl.isString(l)||(l=l?"include":"omit");let B="credentials"in Request.prototype;j=new Request(t,{...m,signal:O,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:i,duplex:"half",credentials:B?l:void 0});let z=await fetch(j),C=XAu&&(c==="stream"||c==="response");if(XAu&&(f||C&&A)){let U={};["status","statusText","headers"].forEach(X=>{U[X]=z[X]});let k=jl.toFiniteNumber(z.headers.get("content-length")),[ve,Y]=f&&lLi(k,I2r(fLi(f),!0))||[];z=new Response(YAu(z.body,l6f,ve,()=>{Y&&Y(),A&&A()}),U)}c=c||"text";let N=await ZMa[jl.findKey(ZMa,c)||"text"](z,e);return!C&&A&&A(),await new Promise((U,k)=>{dHt(U,k,{data:N,headers:r7.from(z.headers),status:z.status,statusText:z.statusText,config:e,request:j})})}catch(B){throw A&&A(),B&&B.name==="TypeError"&&/fetch/i.test(B.message)?Object.assign(new hy("Network Error",hy.ERR_NETWORK,e,j),{cause:B.cause||B}):hy.from(B,B&&B.code,e,j)}});var ZAu={http:n6f,xhr:s6f,fetch:p6f};jl.forEach(ZAu,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var _6f=e=>`- ${e}`,Mfw=e=>jl.isFunction(e)||e===null||e===!1,eTa={getAdapter:e=>{e=jl.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,!Mfw(r)&&(i=ZAu[(u=String(r)).toLowerCase()],i===void 0))throw new hy(`Unknown adapter '${u}'`);if(i)break;n[u||"#"+a]=i}if(!i){let a=Object.entries(n).map(([f,p])=>`adapter ${f} `+(p===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
@@ -1933,7 +1933,7 @@ ${n.style.help("(Use arrow keys)")}`);let U=nfi({items:o,active:T,renderItem({it
1933
1933
  ${n.style.description(z.description)}`:"";return[[j,C,ve].filter(Boolean).join(" "),`${k??U}${N}${Y}`]});var LCu=go(GVr(),1);var fLf=go(N9i(),1),RPw={icon:{cursor:SBe.pointer},style:{disabled:e=>LCu.default.dim(`- ${e}`),description:e=>LCu.default.cyan(e)},helpMode:"auto"};function kLi(e){return!NT.isSeparator(e)&&!e.disabled}function LPw(e){return e.map(t=>{if(NT.isSeparator(t))return t;if(typeof t=="string")return{value:t,name:t,short:t,disabled:!1};let r=t.name??String(t.value);return{value:t.value,name:r,description:t.description,short:t.short??r,disabled:t.disabled??!1}})}var UPw=y4((e,t)=>{let{loop:r=!0,pageSize:i=7}=e,n=ABe(!0),a=n7(RPw,e.theme),[u,f]=Im("idle"),p=_4({status:u,theme:a}),c=ABe(),o=ySe(()=>LPw(e.choices),[e.choices]),l=ySe(()=>{let U=o.findIndex(kLi),k=o.findLastIndex(kLi);if(U===-1)throw new QVr("[select prompt] No selectable choices. All choices are disabled.");return{first:U,last:k}},[o]),m=ySe(()=>"default"in e?o.findIndex(U=>kLi(U)&&U.value===e.default):-1,[e.default,o]),[O,j]=Im(m===-1?l.first:m),A=o[O];h4((U,k)=>{if(clearTimeout(c.current),pR(U))f("done"),t(A.value);else if(JVr(U)||YLi(U)){if(k.clearLine(0),r||JVr(U)&&O!==l.first||YLi(U)&&O!==l.last){let ve=JVr(U)?-1:1,Y=O;do Y=(Y+ve+o.length)%o.length;while(!kLi(o[Y]));j(Y)}}else if(Sqa(U)){k.clearLine(0);let ve=Number(U.name)-1,Y=o[ve];Y!=null&&kLi(Y)&&j(ve)}else if(XLi(U))k.clearLine(0);else{let ve=k.line.toLowerCase(),Y=o.findIndex(X=>NT.isSeparator(X)||!kLi(X)?!1:X.name.toLowerCase().startsWith(ve));Y!==-1&&j(Y),c.current=setTimeout(()=>{k.clearLine(0)},700)}}),l3t(()=>()=>{clearTimeout(c.current)},[]);let T=a.style.message(e.message,u),B="",z="";(a.helpMode==="always"||a.helpMode==="auto"&&n.current)&&(n.current=!1,o.length>i?z=`
1934
1934
  ${a.style.help("(Use arrow keys to reveal more choices)")}`:B=a.style.help("(Use arrow keys)"));let C=nfi({items:o,active:O,renderItem({item:U,isActive:k}){if(NT.isSeparator(U))return` ${U.separator}`;if(U.disabled){let X=typeof U.disabled=="string"?U.disabled:"(disabled)";return a.style.disabled(`${U.name} ${X}`)}let ve=k?a.style.highlight:X=>X,Y=k?a.icon.cursor:" ";return ve(`${Y} ${U.name}`)},pageSize:i,loop:r});if(u==="done")return`${p} ${T} ${a.style.answer(A.short)}`;let N=A.description?`
1935
1935
  ${a.style.description(A.description)}`:"";return`${[p,T,B].filter(Boolean).join(" ")}
1936
- ${C}${z}${N}${fLf.default.cursorHide}`});var dLf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Fqa=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=PA.Info;constructor(t){this.ttyAwareLogger=new cqa(t);let r=this.getPackageName(),i=this.getPackageVersion(),n=this.getCliName();(r==null||i==null||n==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:i,cliName:n}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.46.0-rc1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Ic.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new uCe}failWithoutThrowing(t,r){this.didSucceed=!1,aqa({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),await(await nLi()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await t5f({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1936
+ ${C}${z}${N}${fLf.default.cursorHide}`});var dLf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Fqa=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=PA.Info;constructor(t){this.ttyAwareLogger=new cqa(t);let r=this.getPackageName(),i=this.getPackageVersion(),n=this.getCliName();(r==null||i==null||n==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:i,cliName:n}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.46.0"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Ic.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new uCe}failWithoutThrowing(t,r){this.didSucceed=!1,aqa({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),await(await nLi()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await t5f({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1937
1937
  `)||(r+=`
1938
1938
  `),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=auu(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 NSn(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 uCe}finally{i.finish()}return n}async instrumentPostHogEvent(t){(await nLi()).sendEvent(t)}logger=lPn(this.log.bind(this));constructTaskInitForWorkspace(t){let r=pLf(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?pLf(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=dLf[this.numTasks++%dLf.length],u=Ic.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===eN.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}])}logImmediately(t){let r=t.filter(i=>n9r.indexOf(i.level)>=n9r.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===PA.Debug})}_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 KLi({cliEnvironment:this.environment,includePreReleases:t}),i=Yne(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await lqa({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await zCu({message:t,default:r})}};function pLf(e){return`[${e}]:`}function d3t({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Ic.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Ic.dim(r)),i.join(`
1939
1939
  `)}var _Lf=require("fs/promises");async function UCu({absoluteFilePathToOverrides:e,data:t,context:r}){let i=null;try{let n=(await(0,_Lf.readFile)(e,"utf8")).toString();try{i=JSON.parse(n)}catch{i=Ty.load(n,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return luu({data:t,overrides:i})}var Xne={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,cooerceEnumsToLiterals:!0,respectReadonlySchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,filter:void 0,asyncApiNaming:"v1"};function VCu({options:e,overrides:t}){return{disableExamples:t?.disableExamples??Xne.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??Xne.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??Xne.useTitlesAsName,audiences:t?.audiences??e?.audiences??Xne.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??Xne.optionalAdditionalProperties,cooerceEnumsToLiterals:t?.cooerceEnumsToLiterals??e?.cooerceEnumsToLiterals??Xne.cooerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??Xne.respectReadonlySchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??Xne.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??Xne.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??Xne.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??Xne.shouldUseUndiscriminatedUnionsWithLiterals,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??Xne.objectQueryParameters,filter:t?.filter??e?.filter??Xne.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??Xne.asyncApiNaming}}var p3t={openapi:e=>({...e,type:"openapi",_visit:function(t){return p3t._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return p3t._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 eUi={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return eUi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var tU={basic:e=>({...e,type:"basic",_visit:function(t){return tU._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return tU._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return tU._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return tU._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return tU._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 NP={primitive:e=>({value:e,type:"primitive",_visit:function(t){return NP._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return NP._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return NP._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return NP._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return NP._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return NP._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return NP._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return NP._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 Yy={int:e=>({value:e,type:"int",_visit:function(t){return Yy._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return Yy._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return Yy._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return Yy._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return Yy._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return Yy._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Yy._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return Yy._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return Yy._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return Yy._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return Yy._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 tUi={boolean:e=>({value:e,type:"boolean",_visit:function(t){return tUi._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return tUi._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 YVr={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return YVr._visit(this,t)}}),undisciminated:e=>({value:e,type:"undisciminated",_visit:function(t){return YVr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undisciminated":return t.undisciminated(e.value);default:return t._other(e)}}};var SH={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case SH.GenerallyAvailable:return t.generallyAvailable();case SH.Beta:return t.beta();case SH.Deprecated:return t.deprecated();default:return t._other()}}};var V2r={cursor:e=>({...e,type:"cursor",_visit:function(t){return V2r._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return V2r._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);default:return t._other(e)}}};var W2r={language:e=>({...e,type:"language",_visit:function(t){return W2r._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return W2r._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 EH={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 EH.Curl:return t.curl();case EH.Python:return t.python();case EH.Javascript:return t.javascript();case EH.Typescript:return t.typescript();case EH.Go:return t.go();case EH.Ruby:return t.ruby();case EH.Csharp:return t.csharp();case EH.Java:return t.java();case EH.Js:return t.js();case EH.Node:return t.node();case EH.Ts:return t.ts();case EH.Nodets:return t.nodets();case EH.Golang:return t.golang();case EH.Dotnet:return t.dotnet();case EH.Jvm:return t.jvm();default:return t._other()}}};var _3t={unknown:e=>({value:e,type:"unknown",_visit:function(t){return _3t._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return _3t._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 h3t={withStreaming:e=>({value:e,type:"withStreaming",_visit:function(t){return h3t._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return h3t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e.value);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var v$={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case v$.Get:return t.get();case v$.Post:return t.post();case v$.Put:return t.put();case v$.Patch:return t.patch();case v$.Delete:return t.delete();case v$.Head:return t.head();case v$.Options:return t.options();case v$.Trace:return t.trace();default:return t._other()}}};var XVr={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return XVr._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return XVr._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return XVr._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 MBe={file:e=>({...e,type:"file",_visit:function(t){return MBe._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return MBe._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 Zne={file:e=>({...e,type:"file",_visit:function(t){return Zne._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Zne._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Zne._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Zne._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Zne._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Zne._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"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var rb={primitive:e=>({...e,type:"primitive",_visit:function(t){return rb._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return rb._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return rb._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return rb._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return rb._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return rb._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return rb._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return rb._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return rb._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return rb._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return rb._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 Z1={int:e=>({...e,type:"int",_visit:function(t){return Z1._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Z1._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Z1._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Z1._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Z1._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Z1._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Z1._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Z1._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Z1._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Z1._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Z1._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 tz={boolean:e=>({value:e,type:"boolean",_visit:function(t){return tz._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return tz._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 H2r={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return H2r._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return H2r._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undisciminated":return t.undisciminated(e);default:return t._other(e)}}};var vSe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return vSe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return vSe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return vSe._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 rz={file:e=>({...e,type:"file",_visit:function(t){return rz._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return rz._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return rz._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return rz._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return rz._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return rz._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"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Dp={primitive:e=>({...e,type:"primitive",_visit:function(t){return Dp._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Dp._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Dp._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Dp._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Dp._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Dp._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Dp._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Dp._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Dp._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Dp._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Dp._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 GZ={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return GZ._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return GZ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undisciminated":return t.undisciminated(e);default:return t._other(e)}}};var ay={int:e=>({...e,type:"int",_visit:function(t){return ay._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return ay._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return ay._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return ay._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return ay._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return ay._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return ay._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return ay._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return ay._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return ay._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return ay._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 sg={};Gs(sg,{AllOfPropertyConflict:()=>jUi,ArraySchema:()=>KCa,ArraySchemaWithExample:()=>jxa,Availability:()=>$qa,Base64WithExample:()=>bxa,BasicSecurityScheme:()=>Xqa,BearerSecurityScheme:()=>Zqa,BooleanSchema:()=>WCa,BooleanWithExample:()=>gxa,CasingOverrides:()=>tCa,CommonProperty:()=>ixa,CommonPropertyWithExample:()=>Cxa,CursorPagination:()=>TCa,CustomCodeSample:()=>ACa,CustomCodeSampleLanguage:()=>DCa,CustomCodeSampleSdk:()=>ECa,DateWithExample:()=>vxa,DatetimeWithExample:()=>yxa,DiscriminatedOneOfSchema:()=>txa,DiscriminatedOneOfSchemaWithExample:()=>Txa,DoubleSchema:()=>UCa,DoubleWithExample:()=>_xa,Encoding:()=>Gqa,Endpoint:()=>CCa,EndpointExample:()=>bUi,EndpointResponseExample:()=>wCa,EndpointSdkName:()=>mHt,EndpointWithExample:()=>WLf,EnumSchema:()=>oUi,EnumSchemaWithExample:()=>Oxa,EnumValue:()=>eWr,ErrorExample:()=>mCa,FernExample:()=>PCa,FileResponse:()=>_Ui,FileSchema:()=>_Ca,FloatWithExample:()=>pxa,FullEndpointExample:()=>MCa,FullExample:()=>Ax,FullObjectExample:()=>cCa,FullOneOfExample:()=>fCa,GlobalHeader:()=>JCa,Header:()=>iWr,HeaderExample:()=>vUi,HeaderSecurityScheme:()=>kqa,HeaderWithExample:()=>uWr,HttpEndpointServer:()=>hUi,HttpError:()=>OCa,HttpErrorWithExample:()=>sxa,HttpMethod:()=>cUi,IdempotencyHeader:()=>QCa,Int64WithExample:()=>lxa,IntSchema:()=>RCa,IntWithExample:()=>cxa,JsonRequest:()=>vCa,JsonRequestWithExample:()=>axa,JsonResponse:()=>nWr,JsonResponseWithExample:()=>nEn,KeyValuePair:()=>lCa,LiteralExample:()=>sCa,LiteralSchema:()=>PUi,LiteralSchemaValue:()=>GCa,LongSchema:()=>LCa,MapSchema:()=>YCa,MapSchemaWithExample:()=>wxa,MultipartRequest:()=>pUi,MultipartRequestProperty:()=>yCa,MultipartSchema:()=>hCa,NamedFullExample:()=>PHt,Namespace:()=>rCa,NamespaceId:()=>uCa,NullableSchema:()=>ZCa,NullableSchemaWithExample:()=>Sxa,OauthSecurityScheme:()=>nCa,ObjectProperty:()=>exa,ObjectPropertyConflictInfo:()=>wUi,ObjectPropertyWithExample:()=>Mxa,ObjectSchema:()=>$Ca,ObjectSchemaWithExample:()=>Exa,OctetStreamRequest:()=>dUi,OffsetPagination:()=>qCa,OneOfSchema:()=>kCa,OneOfSchemaWithExample:()=>Axa,OpenApiIntermediateRepresentation:()=>ULf,OpenApiSource:()=>Wqa,OptionalSchema:()=>XCa,OptionalSchemaWithExample:()=>Dxa,Pagination:()=>gUi,PathParameter:()=>lUi,PathParameterExample:()=>jCa,PathParameterWithExample:()=>nxa,PrimitiveExample:()=>sUi,PrimitiveSchema:()=>oWr,PrimitiveSchemaValue:()=>HCa,PrimitiveSchemaValueWithExample:()=>mxa,PrimitiveSchemaWithExample:()=>SUi,PropertyKey:()=>uUi,ProtobufEncoding:()=>Qqa,ProtobufSource:()=>Hqa,QueryParameter:()=>fUi,QueryParameterExample:()=>yUi,QueryParameterWithExample:()=>DUi,QuerySecurityScheme:()=>eCa,ReferencedSchema:()=>OHt,Request:()=>bCa,RequestWithExample:()=>oxa,Response:()=>gCa,ResponseWithExample:()=>uxa,Schema:()=>Ej,SchemaId:()=>$Z,SchemaWithExample:()=>_q,Schemas:()=>FCa,SdkGroup:()=>iCa,SdkGroupInfo:()=>dCa,SdkGroupName:()=>tWr,SecurityScheme:()=>aCa,SecuritySchemeId:()=>Yqa,Server:()=>oCa,Source:()=>Jqa,StatusCode:()=>rWr,StringSchema:()=>VCa,StringSchemaWithExample:()=>hxa,SupportedSdkLanguage:()=>SCa,Tag:()=>Kqa,TagId:()=>KZ,Tags:()=>pCa,TextResponse:()=>aWr,Uint64WithExample:()=>dxa,UintWithExample:()=>fxa,UnDiscriminatedOneOfSchema:()=>rxa,UnDiscriminatedOneOfSchemaWithExample:()=>qxa,UnknownSchemaWithExample:()=>Pxa,Webhook:()=>xCa,WebhookExampleCall:()=>OUi,WebhookHttpMethod:()=>mUi,WebhookWithExample:()=>HLf,WebsocketChannel:()=>NCa,WebsocketHandshake:()=>BCa,WebsocketHandshakeWithExample:()=>VLf,WebsocketMessageExample:()=>ICa,WebsocketSessionExample:()=>zCa,WithAvailability:()=>e0,WithDescription:()=>t_,WithEncoding:()=>kne,WithInline:()=>kM,WithName:()=>Hm,WithNamespace:()=>gHt,WithSdkGroupName:()=>Sj,WithSource:()=>$0,WithTitle:()=>Dj,commons:()=>GCu,example:()=>$Cu,finalIr:()=>KCu,parseIr:()=>YCu});var GCu={};Gs(GCu,{BasicSecurityScheme:()=>Xqa,BearerSecurityScheme:()=>Zqa,Encoding:()=>Gqa,HeaderSecurityScheme:()=>kqa,Namespace:()=>rCa,NamespaceId:()=>uCa,OauthSecurityScheme:()=>nCa,OpenApiSource:()=>Wqa,ProtobufEncoding:()=>Qqa,ProtobufSource:()=>Hqa,QuerySecurityScheme:()=>eCa,SchemaId:()=>$Z,SdkGroup:()=>iCa,SdkGroupName:()=>tWr,SecurityScheme:()=>aCa,SecuritySchemeId:()=>Yqa,Server:()=>oCa,Source:()=>Jqa,StatusCode:()=>rWr,Tag:()=>Kqa,TagId:()=>KZ,WithAvailability:()=>e0,WithDescription:()=>t_,WithEncoding:()=>kne,WithInline:()=>kM,WithName:()=>Hm,WithNamespace:()=>gHt,WithSdkGroupName:()=>Sj,WithSource:()=>$0,WithTitle:()=>Dj});var mi={};Gs(mi,{JsonError:()=>rUi,ParseError:()=>iUi,any:()=>ALf,boolean:()=>MLf,booleanLiteral:()=>ELf,date:()=>yLf,discriminant:()=>FLf,enum_:()=>Lqa,getObjectLikeUtils:()=>bHt,getObjectUtils:()=>aUi,getSchemaUtils:()=>YB,isProperty:()=>kVr,lazy:()=>vLf,lazyObject:()=>wLf,list:()=>Vqa,number:()=>TLf,object:()=>Uqa,objectWithoutOptionalProperties:()=>jLf,optional:()=>WCu,property:()=>gLf,record:()=>BLf,set:()=>ILf,string:()=>qLf,stringLiteral:()=>SLf,transform:()=>HCu,undiscriminatedUnion:()=>NLf,union:()=>LLf,unknown:()=>CLf,withParsedProperties:()=>QCu});var JS={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 Ex(e,t){return`Expected ${t}. Received ${VPw(e)}.`}function VPw(e){if(Array.isArray(e))return"list";if(e===null)return"null";switch(typeof e){case"string":return`"${e}"`;case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function b$(e){return{...e,json:hLf(e.json),parse:hLf(e.parse)}}function hLf(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(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.46.0-rc1",
3
+ "version": "0.46.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",