fern-api 0.45.0-rc11 → 0.45.0-rc12

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 +3 -3
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -1758,7 +1758,7 @@ ${l.indent}`:""}${h4c(o)}:${f.indent?" ":""}`;return u=!1,c=!0,f.objectItem=void
1758
1758
  `}),r.replaceAll(/\n$/g,"")}function HHP(e){return e?rl.green(O3r.radioOn):O3r.radioOff}var usa=iu(lje(),1);function dYl(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var wli=class extends PR{_run(t){this.done=t;let r=pW(this.rl),n=r.line.pipe((0,usa.map)(this.filterInput.bind(this))),i=this.handleSubmitEvents(n);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,usa.takeUntil)(i.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),n="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(n=`
1759
1759
  `+rl.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?rl.cyan(dYl(t,this.opt.mask)):rl.italic.dim("[hidden]"):this.opt.mask?dYl(t,this.opt.mask):rl.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 RXl=iu(BXl(),1),FXl=iu(lje(),1);var Nli=class extends PR{_run(t){this.done=t,this.editorResult=new FXl.Subject;let r=pW(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let n=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,i=this.handleSubmitEvents(this.editorResult);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,n?this.render():this.startExternalEditor(),this}render(t){let r="",n=this.getQuestion();n+=this.status==="answered"?rl.dim("Received"):rl.dim("Press <enter> to launch your preferred editor."),t&&(r=rl.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),(0,RXl.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 KXl=iu(VXl(),1);var JXl=iu(require("readline"),1),GXl=iu(HXl(),1),nZr=class{constructor(t){this.rl||=JXl.default.createInterface(NJP(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 NJP(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let i=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw i.isTtyError=!0,i}let r=new GXl.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var Ili=class extends nZr{constructor(t={}){super(t),this.log=(0,KXl.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return yli(this.rl,this.bottomBar.split(`
1760
1760
  `).length),this}updateBottomBar(t){return yli(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+`
1761
- `}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&&nsa(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var nQl=iu(XXl(),1),iQl=iu(jQo(),1),aQl=iu(tQl(),1),fq=iu(lje(),1),oQl=iu(wci(),1);var Esa=iu(lje(),1),rQl=iu(wci(),1),Msa=function(e,t,r){return typeof e[t]!="function"?(0,Esa.of)(e):(0,Esa.from)((0,rQl.default)(e[t])(r).then(n=>(e[t]=n,e)))};var zli={isPlainObject:nQl.default,set:aQl.default,get:iQl.default},gAn=class extends nZr{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=zli.isPlainObject(r)?{...r}:{},zli.isPlainObject(t)&&(t=Object.values(t).every(i=>zli.isPlainObject(i)&&i.name===void 0)?Object.entries(t).map(([i,a])=>({name:i,...a})):[t]);let n=Array.isArray(t)?(0,fq.from)(t):t;return this.process=n.pipe((0,fq.concatMap)(this.processQuestion.bind(this)),(0,fq.publish)()),this.process.connect(),this.process.pipe((0,fq.reduce)((i,a)=>(zli.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,fq.defer)(()=>(0,fq.of)(t).pipe((0,fq.concatMap)(this.setDefaultType.bind(this)),(0,fq.concatMap)(this.filterIfRunnable.bind(this)),(0,fq.concatMap)(()=>Msa(t,"message",this.answers)),(0,fq.concatMap)(()=>Msa(t,"default",this.answers)),(0,fq.concatMap)(()=>Msa(t,"choices",this.answers)),(0,fq.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,fq.defer)(()=>(0,fq.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,fq.defer)(()=>(0,fq.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&zli.get(this.answers,t.name)!==void 0)return(0,fq.empty)();if(t.when===!1)return(0,fq.empty)();if(typeof t.when!="function")return(0,fq.of)(t);let{answers:r}=this;return(0,fq.defer)(()=>(0,fq.from)((0,oQl.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,fq.filter)(n=>n!=null)))}};function uQl(e){let t=function(r,n){let i;try{i=new gAn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",bli),this.registerPrompt("input",XQr),this.registerPrompt("number",gli),this.registerPrompt("confirm",mli),this.registerPrompt("rawlist",Oli),this.registerPrompt("expand",Pli),this.registerPrompt("checkbox",jli),this.registerPrompt("password",wli),this.registerPrompt("editor",Nli)},t.restoreDefaultPrompts(),t}var mko=uQl();function ZJP(e,t){mko.registerPrompt(e,t)}function kJP(){mko.restoreDefaultPrompts()}var eGP={prompt:mko,ui:{BottomBar:Ili,Prompt:gAn},createPromptModule:uQl,registerPrompt:ZJP,restoreDefaultPrompts:kJP,Separator:one},xsa=eGP;var yQl=iu(sQl()),vQl=iu(NJo()),Pko=function(e,t){return Pko=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},Pko(e,t)};function mAn(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Pko(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var Bg=function(){return Bg=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},Bg.apply(this,arguments)};function tGP(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function B2(e,t,r,n){function i(a){return a instanceof r?a:new r(function(u){u(a)})}return new(r||(r=Promise))(function(a,u){function f(o){try{c(n.next(o))}catch(l){u(l)}}function d(o){try{c(n.throw(o))}catch(l){u(l)}}function c(o){o.done?a(o.value):i(o.value).then(f,d)}c((n=n.apply(e,t||[])).next())})}function R2(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,i,a,u;return u={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function f(c){return function(o){return d([c,o])}}function d(c){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(a=c[0]&2?i.return:c[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,c[1])).done)return a;switch(i=0,a&&(c=[c[0]&2,a.value]),c[0]){case 0:case 1:a=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,i=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){r.label=c[1];break}if(c[0]===6&&r.label<a[1]){r.label=a[1],a=c;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(c);break}a[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r)}catch(o){c=[6,o],i=0}finally{n=a=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function bQl(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,a;n<i;n++)(a||!(n in t))&&(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}var jko="3.1.2",Y1;(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"})(Y1||(Y1={}));function rGP(e,t){if(!e)throw new Error(t)}function nGP(e){return e?.replace(/\/+$/,"")}function iGP(e,t){return t===void 0&&(t={}),B2(this,void 0,void 0,function(){var r,n,i,a,u,f,d,c,o,l;return R2(this,function(g){switch(g.label){case 0:r=t.retryCount,n=r===void 0?3:r,i=t.retryDelay,a=i===void 0?5e3:i,u=t.retryCheck,f=u===void 0?function(){return!0}:u,d=null,c=0,g.label=1;case 1:return c<n+1?c>0?[4,new Promise(function(O){return setTimeout(O,a)})]:[3,3]:[3,7];case 2:g.sent(),g.label=3;case 3:return g.trys.push([3,5,,6]),[4,e()];case 4:return o=g.sent(),[2,o];case 5:if(l=g.sent(),d=l,!f(l))throw l;return[3,6];case 6:return c++,[3,1];case 7:throw d}})})}function wko(e){var t=new Date().getTime(),r=e&&e.performance&&e.performance.now&&e.performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var i=Math.random()*16;return t>0?(i=(t+i)%16|0,t=Math.floor(t/16)):(i=(r+i)%16|0,r=Math.floor(r/16)),(n==="x"?i:i&3|8).toString(16)})}function aGP(){return new Date().getTime()}function cQl(){return new Date().toISOString()}function gQl(e,t){var r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var Rli=String.fromCharCode,lQl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Tsa={};function oGP(e,t){if(!Tsa[e]){Tsa[e]={};for(var r=0;r<e.length;r++)Tsa[e][e.charAt(r)]=r}return Tsa[e][t]}var Fli={compressToBase64:function(e){if(e==null)return"";var t=Fli._compress(e,6,function(r){return lQl.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:Fli._decompress(e.length,32,function(t){return oGP(lQl,e.charAt(t))})},compress:function(e){return Fli._compress(e,16,function(t){return Rli(t)})},_compress:function(e,t,r){if(e==null)return"";var n={},i={},a=[],u,f,d="",c="",o="",l=2,g=3,O=2,j=0,S=0,T;for(T=0;T<e.length;T+=1)if(d=e.charAt(T),Object.prototype.hasOwnProperty.call(n,d)||(n[d]=g++,i[d]=!0),c=o+d,Object.prototype.hasOwnProperty.call(n,c))o=c;else{if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,S==t-1?(S=0,a.push(r(j)),j=0):S++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)j=j<<1|f&1,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++),n[c]=g++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,S==t-1?(S=0,a.push(r(j)),j=0):S++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)j=j<<1|f&1,S==t-1?(S=0,a.push(r(j)),j=0):S++,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,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=f>>1;for(;;)if(j=j<<1,S==t-1){a.push(r(j));break}else S++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:Fli._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){var n=[],i=[],a={val:r(0),position:t,index:1},u=4,f=4,d=3,c="",o,l,g,O,j,S,T;for(o=0;o<3;o+=1)n[o]=o;for(g=0,j=Math.pow(2,2),S=1;S!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*S,S<<=1;switch(g){case 0:for(g=0,j=Math.pow(2,8),S=1;S!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*S,S<<=1;T=Rli(g);break;case 1:for(g=0,j=Math.pow(2,16),S=1;S!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*S,S<<=1;T=Rli(g);break;case 2:return""}for(n[3]=T,l=T,i.push(T);;){if(a.index>e)return"";for(g=0,j=Math.pow(2,d),S=1;S!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*S,S<<=1;switch(T=g){case 0:for(g=0,j=Math.pow(2,8),S=1;S!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*S,S<<=1;n[f++]=Rli(g),T=f-1,u--;break;case 1:for(g=0,j=Math.pow(2,16),S=1;S!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*S,S<<=1;n[f++]=Rli(g),T=f-1,u--;break;case 2:return i.join("")}if(u==0&&(u=Math.pow(2,d),d++),n[T])c=n[T];else if(T===f)c=l+l.charAt(0);else return null;i.push(c),n[f++]=l+c.charAt(0),u--,l=c,u==0&&(u=Math.pow(2,d),d++)}}},uGP=function(){function e(){this.events={},this.events={}}return e.prototype.on=function(t,r){var n=this;return this.events[t]||(this.events[t]=[]),this.events[t].push(r),function(){n.events[t]=n.events[t].filter(function(i){return i!==r})}},e.prototype.emit=function(t,r){for(var n=0,i=this.events[t]||[];n<i.length;n++){var a=i[n];a(r)}for(var u=0,f=this.events["*"]||[];u<f.length;u++){var a=f[u];a(t,r)}},e}(),sGP=function(e){mAn(t,e);function t(r){var n=e.call(this,"HTTP error while fetching PostHog: "+r.status)||this;return n.response=r,n.name="PostHogFetchHttpError",n}return t}(Error),cGP=function(e){mAn(t,e);function t(r){var n=e.call(this,"Network error while fetching PostHog",r instanceof Error?{cause:r}:{})||this;return n.error=r,n.name="PostHogFetchNetworkError",n}return t}(Error);function fQl(e){return typeof e=="object"&&(e.name==="PostHogFetchHttpError"||e.name==="PostHogFetchNetworkError")}var mQl=function(){function e(t,r){var n,i,a,u,f;this.debugMode=!1,this.pendingPromises={},this.disableGeoip=!0,this._events=new uGP,rGP(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=nGP(r?.host||"https://app.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.flushInterval=(n=r?.flushInterval)!==null&&n!==void 0?n:1e4,this.captureMode=r?.captureMode||"form",this._optoutOverride=r?.enable===!1,this._retryOptions={retryCount:(i=r?.fetchRetryCount)!==null&&i!==void 0?i:3,retryDelay:(a=r?.fetchRetryDelay)!==null&&a!==void 0?a:3e3,retryCheck:fQl},this.requestTimeout=(u=r?.requestTimeout)!==null&&u!==void 0?u:1e4,this.disableGeoip=(f=r?.disableGeoip)!==null&&f!==void 0?f:!0}return e.prototype.getCommonEventProperties=function(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}},Object.defineProperty(e.prototype,"optedOut",{get:function(){var t,r;return(r=(t=this.getPersistedProperty(Y1.OptedOut))!==null&&t!==void 0?t:this._optoutOverride)!==null&&r!==void 0?r:!1},enumerable:!1,configurable:!0}),e.prototype.optIn=function(){this.setPersistedProperty(Y1.OptedOut,!1)},e.prototype.optOut=function(){this.setPersistedProperty(Y1.OptedOut,!0)},e.prototype.on=function(t,r){return this._events.on(t,r)},e.prototype.debug=function(t){var r;t===void 0&&(t=!0),(r=this.removeDebugCallback)===null||r===void 0||r.call(this),this.debugMode=t,t&&(this.removeDebugCallback=this.on("*",function(n,i){return console.log("PostHog Debug",n,i)}))},e.prototype.buildPayload=function(t){return{distinct_id:t.distinct_id,event:t.event,properties:Bg(Bg({},t.properties||{}),this.getCommonEventProperties())}},e.prototype.identifyStateless=function(t,r,n){var i=Bg({},this.buildPayload({distinct_id:t,event:"$identify",properties:r}));return this.enqueue("identify",i,n),this},e.prototype.captureStateless=function(t,r,n,i){var a=this.buildPayload({distinct_id:t,event:r,properties:n});return this.enqueue("capture",a,i),this},e.prototype.aliasStateless=function(t,r,n,i){var a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:Bg(Bg({},n||{}),{distinct_id:r,alias:t})});return this.enqueue("alias",a,i),this},e.prototype.groupIdentifyStateless=function(t,r,n,i,a,u){var f=this.buildPayload({distinct_id:a||"$".concat(t,"_").concat(r),event:"$groupidentify",properties:Bg({$group_type:t,$group_key:r,$group_set:n||{}},u||{})});return this.enqueue("capture",f,i),this},e.prototype.getDecide=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),B2(this,void 0,void 0,function(){var u,f;return R2(this,function(d){return u="".concat(this.host,"/decide/?v=3"),f={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Bg({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i},a))},[2,this.fetchWithRetry(u,f).then(function(c){return c.json()}).catch(function(c){console.error("Error fetching feature flags",c)})]})})},e.prototype.getFeatureFlagStateless=function(t,r,n,i,a,u){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),B2(this,void 0,void 0,function(){var f,d;return R2(this,function(c){switch(c.label){case 0:return[4,this.getFeatureFlagsStateless(r,n,i,a,u)];case 1:return f=c.sent(),f?(d=f[t],d===void 0&&(d=!1),[2,d]):[2,void 0]}})})},e.prototype.getFeatureFlagPayloadStateless=function(t,r,n,i,a,u){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),B2(this,void 0,void 0,function(){var f,d;return R2(this,function(c){switch(c.label){case 0:return[4,this.getFeatureFlagPayloadsStateless(r,n,i,a,u)];case 1:return f=c.sent(),f?(d=f[t],d===void 0?[2,null]:[2,this._parsePayload(d)]):[2,void 0]}})})},e.prototype.getFeatureFlagPayloadsStateless=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),B2(this,void 0,void 0,function(){var u,f=this;return R2(this,function(d){switch(d.label){case 0:return[4,this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)];case 1:return u=d.sent().payloads,u?[2,Object.fromEntries(Object.entries(u).map(function(c){var o=c[0],l=c[1];return[o,f._parsePayload(l)]}))]:[2,u]}})})},e.prototype._parsePayload=function(t){try{return JSON.parse(t)}catch{return t}},e.prototype.getFeatureFlagsStateless=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),B2(this,void 0,void 0,function(){return R2(this,function(u){switch(u.label){case 0:return[4,this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)];case 1:return[2,u.sent().flags]}})})},e.prototype.getFeatureFlagsAndPayloadsStateless=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),B2(this,void 0,void 0,function(){var u,f,d,c;return R2(this,function(o){switch(o.label){case 0:return u={},(a??this.disableGeoip)&&(u.geoip_disable=!0),[4,this.getDecide(t,r,n,i,u)];case 1:return f=o.sent(),d=f?.featureFlags,c=f?.featureFlagPayloads,[2,{flags:d,payloads:c}]}})})},e.prototype.enqueue=function(t,r,n){var i=this,a;if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.enable()");return}var u=Bg(Bg({},r),{type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:cQl()}),f=(a=n?.disableGeoip)!==null&&a!==void 0?a:this.disableGeoip;f&&(u.properties||(u.properties={}),u.properties.$geoip_disable=!0),u.distinctId&&(u.distinct_id=u.distinctId,delete u.distinctId);var d=this.getPersistedProperty(Y1.Queue)||[];d.push({message:u}),this.setPersistedProperty(Y1.Queue,d),this._events.emit(t,u),d.length>=this.flushAt&&this.flush(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=gQl(function(){return i.flush()},this.flushInterval))},e.prototype.flushAsync=function(){var t=this;return new Promise(function(r,n){t.flush(function(i,a){return i?n(i):r(a)})})},e.prototype.flush=function(t){var r=this;this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=null);var n=this.getPersistedProperty(Y1.Queue)||[];if(!n.length)return t?.();var i=n.splice(0,this.flushAt);this.setPersistedProperty(Y1.Queue,n);var a=i.map(function(O){return O.message}),u={api_key:this.apiKey,batch:a,sent_at:cQl()},f=wko(),d=function(O){O&&r._events.emit("error",O),t?.(O,a),delete r.pendingPromises[f],r._events.emit("flush",a)};this.getCustomUserAgent();var c=JSON.stringify(u),o=this.captureMode==="form"?"".concat(this.host,"/e/?ip=1&_=").concat(aGP(),"&v=").concat(this.getLibraryVersion()):"".concat(this.host,"/batch/"),l=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"data=".concat(encodeURIComponent(Fli.compressToBase64(c)),"&compression=lz64")}:{method:"POST",headers:{"Content-Type":"application/json"},body:c},g=this.fetchWithRetry(o,l);this.pendingPromises[f]=g,g.then(function(){return d()}).catch(function(O){d(O)})},e.prototype.fetchWithRetry=function(t,r,n){var i,a;return B2(this,void 0,void 0,function(){var u=this;return R2(this,function(f){switch(f.label){case 0:return(i=(a=AbortSignal).timeout)!==null&&i!==void 0||(a.timeout=function(c){var o=new AbortController;return setTimeout(function(){return o.abort()},c),o.signal}),[4,iGP(function(){return B2(u,void 0,void 0,function(){var d,c;return R2(this,function(o){switch(o.label){case 0:d=null,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.fetch(t,Bg({signal:AbortSignal.timeout(this.requestTimeout)},r))];case 2:return d=o.sent(),[3,4];case 3:throw c=o.sent(),new cGP(c);case 4:if(d.status<200||d.status>=400)throw new sGP(d);return[2,d]}})})},Bg(Bg({},this._retryOptions),n))];case 1:return[2,f.sent()]}})})},e.prototype.shutdownAsync=function(){return B2(this,void 0,void 0,function(){var t;return R2(this,function(r){switch(r.label){case 0:clearTimeout(this._flushTimer),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,this.flushAsync()];case 2:return r.sent(),[4,Promise.all(Object.values(this.pendingPromises).map(function(n){return n.catch(function(){})}))];case 3:return r.sent(),[3,5];case 4:if(t=r.sent(),!fQl(t))throw t;return console.error("Error while shutting down PostHog",t),[3,5];case 5:return[2]}})})},e.prototype.shutdown=function(){this.shutdownAsync()},e}();(function(e){mAn(t,e);function t(r,n){var i=this,a,u,f,d=(a=n?.disableGeoip)!==null&&a!==void 0?a:!1;return i=e.call(this,r,Bg(Bg({},n),{disableGeoip:d}))||this,i.flagCallReported={},i.sessionProps={},i.sendFeatureFlagEvent=(u=n?.sendFeatureFlagEvent)!==null&&u!==void 0?u:!0,i._sessionExpirationTimeSeconds=(f=n?.sessionExpirationTimeSeconds)!==null&&f!==void 0?f:1800,i}return t.prototype.setupBootstrap=function(r){var n,i,a,u;if(!((n=r?.bootstrap)===null||n===void 0)&&n.distinctId&&(!((i=r?.bootstrap)===null||i===void 0)&&i.isIdentifiedId?this.setPersistedProperty(Y1.DistinctId,r.bootstrap.distinctId):this.setPersistedProperty(Y1.AnonymousId,r.bootstrap.distinctId)),!((a=r?.bootstrap)===null||a===void 0)&&a.featureFlags){var f=Object.keys(((u=r.bootstrap)===null||u===void 0?void 0:u.featureFlags)||{}).filter(function(d){var c,o;return!!(!((o=(c=r.bootstrap)===null||c===void 0?void 0:c.featureFlags)===null||o===void 0)&&o[d])}).reduce(function(d,c){var o,l;return d[c]=((l=(o=r.bootstrap)===null||o===void 0?void 0:o.featureFlags)===null||l===void 0?void 0:l[c])||!1,d},{});this.setKnownFeatureFlags(f),r?.bootstrap.featureFlagPayloads&&this.setKnownFeatureFlagPayloads(r?.bootstrap.featureFlagPayloads)}},Object.defineProperty(t.prototype,"props",{get:function(){return this._props||(this._props=this.getPersistedProperty(Y1.Props)),this._props||{}},set:function(r){this._props=r},enumerable:!1,configurable:!0}),t.prototype.clearProps=function(){this.props=void 0,this.sessionProps={}},t.prototype.on=function(r,n){return this._events.on(r,n)},t.prototype.reset=function(r){var n=bQl([Y1.Queue],r||[],!0);this.clearProps();for(var i=0,a=Object.keys(Y1);i<a.length;i++){var u=a[i];n.includes(Y1[u])||this.setPersistedProperty(Y1[u],null)}},t.prototype.getCommonEventProperties=function(){var r=this.getFeatureFlags(),n={};if(r)for(var i=0,a=Object.entries(r);i<a.length;i++){var u=a[i],f=u[0],d=u[1];n["$feature/".concat(f)]=d}return Bg(Bg({$active_feature_flags:r?Object.keys(r):void 0},n),e.prototype.getCommonEventProperties.call(this))},t.prototype.enrichProperties=function(r){return Bg(Bg(Bg(Bg(Bg({},this.props),this.sessionProps),r||{}),this.getCommonEventProperties()),{$session_id:this.getSessionId()})},t.prototype.getSessionId=function(){var r=this.getPersistedProperty(Y1.SessionId),n=this.getPersistedProperty(Y1.SessionLastTimestamp)||0;return(!r||Date.now()-n>this._sessionExpirationTimeSeconds*1e3)&&(r=wko(globalThis),this.setPersistedProperty(Y1.SessionId,r)),this.setPersistedProperty(Y1.SessionLastTimestamp,Date.now()),r},t.prototype.resetSessionId=function(){this.setPersistedProperty(Y1.SessionId,null)},t.prototype.getAnonymousId=function(){var r=this.getPersistedProperty(Y1.AnonymousId);return r||(r=wko(globalThis),this.setPersistedProperty(Y1.AnonymousId,r)),r},t.prototype.getDistinctId=function(){return this.getPersistedProperty(Y1.DistinctId)||this.getAnonymousId()},t.prototype.unregister=function(r){delete this.props[r],this.setPersistedProperty(Y1.Props,this.props)},t.prototype.register=function(r){this.props=Bg(Bg({},this.props),r),this.setPersistedProperty(Y1.Props,this.props)},t.prototype.registerForSession=function(r){this.sessionProps=Bg(Bg({},this.sessionProps),r)},t.prototype.unregisterForSession=function(r){delete this.sessionProps[r]},t.prototype.identify=function(r,n,i){var a=this.getDistinctId();r=r||a,n?.$groups&&this.groups(n.$groups);var u=this.enrichProperties(Bg(Bg({},n),{$anon_distinct_id:this.getAnonymousId(),$set:n}));return r!==a&&(this.setPersistedProperty(Y1.AnonymousId,a),this.setPersistedProperty(Y1.DistinctId,r),this.reloadFeatureFlags()),e.prototype.identifyStateless.call(this,r,u,i),this},t.prototype.capture=function(r,n,i){var a=this.getDistinctId();n?.$groups&&this.groups(n.$groups);var u=this.enrichProperties(n);return e.prototype.captureStateless.call(this,a,r,u,i),this},t.prototype.alias=function(r){var n=this.getDistinctId(),i=this.enrichProperties({});return e.prototype.aliasStateless.call(this,r,n,i),this},t.prototype.autocapture=function(r,n,i,a){i===void 0&&(i={});var u=this.getDistinctId(),f={distinct_id:u,event:"$autocapture",properties:Bg(Bg({},this.enrichProperties(i)),{$event_type:r,$elements:n})};return this.enqueue("autocapture",f,a),this},t.prototype.groups=function(r){var n=this.props.$groups||{};return this.register({$groups:Bg(Bg({},n),r)}),Object.keys(r).find(function(i){return n[i]!==r[i]})&&this.reloadFeatureFlags(),this},t.prototype.group=function(r,n,i,a){var u;return this.groups((u={},u[r]=n,u)),i&&this.groupIdentify(r,n,i,a),this},t.prototype.groupIdentify=function(r,n,i,a){var u=this.getDistinctId(),f=this.enrichProperties({});return e.prototype.groupIdentifyStateless.call(this,r,n,i,a,u,f),this},t.prototype.personProperties=function(r){var n=this.getPersistedProperty(Y1.PersonProperties)||{};return this.setPersistedProperty(Y1.PersonProperties,Bg(Bg({},n),r)),this},t.prototype.groupProperties=function(r){var n=this.getPersistedProperty(Y1.GroupProperties)||{};return Object.keys(n).length!==0&&Object.keys(n).forEach(function(i){n[i]=Bg(Bg({},n[i]),r[i]),delete r[i]}),this.setPersistedProperty(Y1.GroupProperties,Bg(Bg({},n),r)),this},t.prototype.decideAsync=function(r){return r===void 0&&(r=!0),this._decideResponsePromise?this._decideResponsePromise:this._decideAsync(r)},t.prototype._decideAsync=function(r){return r===void 0&&(r=!0),B2(this,void 0,void 0,function(){var n,i,a,u,f,d=this;return R2(this,function(c){return n=this.getDistinctId(),i=this.props.$groups||{},a=this.getPersistedProperty(Y1.PersonProperties)||{},u=this.getPersistedProperty(Y1.GroupProperties)||{},f={$anon_distinct_id:r?this.getAnonymousId():void 0},this._decideResponsePromise=e.prototype.getDecide.call(this,n,i,a,u,f).then(function(o){if(o?.featureFlags){var l=o.featureFlags,g=o.featureFlagPayloads;if(o.errorsWhileComputingFlags){var O=d.getPersistedProperty(Y1.FeatureFlags),j=d.getPersistedProperty(Y1.FeatureFlagPayloads);l=Bg(Bg({},O),o.featureFlags),g=Bg(Bg({},j),o.featureFlagPayloads)}d.setKnownFeatureFlags(l),d.setKnownFeatureFlagPayloads(g)}return o}).finally(function(){d._decideResponsePromise=void 0}),[2,this._decideResponsePromise]})})},t.prototype.setKnownFeatureFlags=function(r){this.setPersistedProperty(Y1.FeatureFlags,r),this._events.emit("featureflags",r)},t.prototype.setKnownFeatureFlagPayloads=function(r){this.setPersistedProperty(Y1.FeatureFlagPayloads,r)},t.prototype.getFeatureFlag=function(r){var n=this.getFeatureFlags();if(n){var i=n[r];return i===void 0&&(i=!1),this.sendFeatureFlagEvent&&!this.flagCallReported[r]&&(this.flagCallReported[r]=!0,this.capture("$feature_flag_called",{$feature_flag:r,$feature_flag_response:i})),i}},t.prototype.getFeatureFlagPayload=function(r){var n=this.getFeatureFlagPayloads();if(n){var i=n[r];return i===void 0?null:this._parsePayload(i)}},t.prototype.getFeatureFlagPayloads=function(){var r=this,n=this.getPersistedProperty(Y1.FeatureFlagPayloads);return n&&Object.fromEntries(Object.entries(n).map(function(i){var a=i[0],u=i[1];return[a,r._parsePayload(u)]}))},t.prototype.getFeatureFlags=function(){var r=this.getPersistedProperty(Y1.FeatureFlags),n=this.getPersistedProperty(Y1.OverrideFeatureFlags);if(!n)return r;r=r||{};for(var i in n)n[i]?r[i]=n[i]:delete r[i];return r},t.prototype.getFeatureFlagsAndPayloads=function(){var r=this.getFeatureFlags(),n=this.getFeatureFlagPayloads();return{flags:r,payloads:n}},t.prototype.isFeatureEnabled=function(r){var n=this.getFeatureFlag(r);if(n!==void 0)return!!n},t.prototype.reloadFeatureFlags=function(r){this.decideAsync().then(function(n){r?.(void 0,n?.featureFlags)}).catch(function(n){r?.(n,void 0),r||console.log("[PostHog] Error reloading feature flags",n)})},t.prototype.reloadFeatureFlagsAsync=function(r){var n;return r===void 0&&(r=!0),B2(this,void 0,void 0,function(){return R2(this,function(i){switch(i.label){case 0:return[4,this.decideAsync(r)];case 1:return[2,(n=i.sent())===null||n===void 0?void 0:n.featureFlags]}})})},t.prototype.onFeatureFlags=function(r){var n=this;return this.on("featureflags",function(){return B2(n,void 0,void 0,function(){var i;return R2(this,function(a){return i=this.getFeatureFlags(),i&&r(i),[2]})})})},t.prototype.onFeatureFlag=function(r,n){var i=this;return this.on("featureflags",function(){return B2(i,void 0,void 0,function(){var a;return R2(this,function(u){return a=this.getFeatureFlag(r),a!==void 0&&n(a),[2]})})})},t.prototype.overrideFeatureFlag=function(r){return r===null?this.setPersistedProperty(Y1.OverrideFeatureFlags,null):this.setPersistedProperty(Y1.OverrideFeatureFlags,r)},t})(mQl);var lGP=function(){function e(){this._memoryStorage={}}return e.prototype.getProperty=function(t){return this._memoryStorage[t]},e.prototype.setProperty=function(t,r){this._memoryStorage[t]=r!==null?r:void 0},e}(),OQl=function(e,t){return B2(void 0,void 0,void 0,function(){var r;return R2(this,function(n){switch(n.label){case 0:return[4,vQl.default.request({url:e,headers:t.headers,method:t.method.toLowerCase(),data:t.body,signal:t.signal,validateStatus:function(){return!0}})];case 1:return r=n.sent(),[2,{status:r.status,text:function(){return B2(void 0,void 0,void 0,function(){return R2(this,function(i){return[2,r.data]})})},json:function(){return B2(void 0,void 0,void 0,function(){return R2(this,function(i){return[2,r.data]})})}}]}})})},fGP=1152921504606847e3,dQl=function(e){mAn(t,e);function t(r){var n=e.call(this)||this;return Error.captureStackTrace(n,n.constructor),n.name="ClientError",n.message=r,Object.setPrototypeOf(n,t.prototype),n}return t}(Error),vQ=function(e){mAn(t,e);function t(r){var n=e.call(this,r)||this;return n.name=n.constructor.name,Error.captureStackTrace(n,n.constructor),Object.setPrototypeOf(n,t.prototype),n}return t}(Error),dGP=function(){function e(t){var r=t.pollingInterval,n=t.personalApiKey,i=t.projectApiKey,a=t.timeout,u=t.host,f=tGP(t,["pollingInterval","personalApiKey","projectApiKey","timeout","host"]);this.debugMode=!1,this.pollingInterval=r,this.personalApiKey=n,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=a,this.projectApiKey=i,this.host=u,this.poller=void 0,this.fetch=f.fetch||OQl,this.loadFeatureFlags()}return e.prototype.debug=function(t){t===void 0&&(t=!0),this.debugMode=t},e.prototype.getFeatureFlag=function(t,r,n,i,a){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),B2(this,void 0,void 0,function(){var u,f,d,c,o;return R2(this,function(l){switch(l.label){case 0:return[4,this.loadFeatureFlags()];case 1:if(l.sent(),u=void 0,f=void 0,!this.loadedSuccessfullyOnce)return[2,u];for(d=0,c=this.featureFlags;d<c.length;d++)if(o=c[d],t===o.key){f=o;break}if(f!==void 0)try{u=this.computeFlagLocally(f,r,n,i,a),this.debugMode&&console.debug("Successfully computed flag locally: ".concat(t," -> ").concat(u))}catch(g){g instanceof vQ?this.debugMode&&console.debug("InconclusiveMatchError when computing flag locally: ".concat(t,": ").concat(g)):g instanceof Error&&console.error("Error computing flag locally: ".concat(t,": ").concat(g))}return[2,u]}})})},e.prototype.computeFeatureFlagPayloadLocally=function(t,r){var n,i,a,u,f,d,c,o;return B2(this,void 0,void 0,function(){var l;return R2(this,function(g){switch(g.label){case 0:return[4,this.loadFeatureFlags()];case 1:return g.sent(),l=void 0,this.loadedSuccessfullyOnce?(typeof r=="boolean"?l=(u=(a=(i=(n=this.featureFlagsByKey)===null||n===void 0?void 0:n[t])===null||i===void 0?void 0:i.filters)===null||a===void 0?void 0:a.payloads)===null||u===void 0?void 0:u[r.toString()]:typeof r=="string"&&(l=(o=(c=(d=(f=this.featureFlagsByKey)===null||f===void 0?void 0:f[t])===null||d===void 0?void 0:d.filters)===null||c===void 0?void 0:c.payloads)===null||o===void 0?void 0:o[r]),l===void 0?[2,null]:[2,l]):[2,void 0]}})})},e.prototype.getAllFlagsAndPayloads=function(t,r,n,i){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),B2(this,void 0,void 0,function(){var a,u,f,d=this;return R2(this,function(c){switch(c.label){case 0:return[4,this.loadFeatureFlags()];case 1:return c.sent(),a={},u={},f=this.featureFlags.length==0,this.featureFlags.map(function(o){return B2(d,void 0,void 0,function(){var l,g,O;return R2(this,function(j){switch(j.label){case 0:return j.trys.push([0,2,,3]),l=this.computeFlagLocally(o,t,r,n,i),a[o.key]=l,[4,this.computeFeatureFlagPayloadLocally(o.key,l)];case 1:return g=j.sent(),g&&(u[o.key]=g),[3,3];case 2:return O=j.sent(),O instanceof vQ||O instanceof Error&&console.error("Error computing flag locally: ".concat(o.key,": ").concat(O)),f=!0,[3,3];case 3:return[2]}})})}),[2,{response:a,payloads:u,fallbackToDecide:f}]}})})},e.prototype.computeFlagLocally=function(t,r,n,i,a){if(n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),t.ensure_experience_continuity)throw new vQ("Flag has experience continuity enabled");if(!t.active)return!1;var u=t.filters||{},f=u.aggregation_group_type_index;if(f!=null){var d=this.groupTypeMapping[String(f)];if(!d)throw console.warn("[FEATURE FLAGS] Unknown group type index ".concat(f," for feature flag ").concat(t.key)),new vQ("Flag has unknown group type index");if(!(d in n))return console.warn("[FEATURE FLAGS] Can't compute group feature flag: ".concat(t.key," without group names passed in")),!1;var c=a[d];return this.matchFeatureFlagProperties(t,n[d],c)}else return this.matchFeatureFlagProperties(t,r,i)},e.prototype.matchFeatureFlagProperties=function(t,r,n){for(var i,a=t.filters||{},u=a.groups||[],f=!1,d=void 0,c=bQl([],u,!0).sort(function(T,C){var I=!!T.variant,N=!!C.variant;return I&&N?0:I?-1:N?1:0}),o=function(T){try{if(l.isConditionMatch(t,r,T,n)){var C=T.variant,I=((i=a.multivariate)===null||i===void 0?void 0:i.variants)||[];return C&&I.some(function(N){return N.key===C})?d=C:d=l.getMatchingVariant(t,r)||!0,"break"}}catch(N){if(N instanceof vQ)f=!0;else throw N}},l=this,g=0,O=c;g<O.length;g++){var j=O[g],S=o(j);if(S==="break")break}if(d!==void 0)return d;if(f)throw new vQ("Can't determine if feature flag is enabled or not with given properties");return!1},e.prototype.isConditionMatch=function(t,r,n,i){var a=n.rollout_percentage;if((n.properties||[]).length>0){for(var u=0,f=n.properties;u<f.length;u++){var d=f[u],c=d.type,o=!1;if(c==="cohort"?o=jQl(d,i,this.cohorts):o=PQl(d,i),!o)return!1}if(a==null)return!0}return!(a!=null&&pQl(t.key,r)>a/100)},e.prototype.getMatchingVariant=function(t,r){var n=pQl(t.key,r,"variant"),i=this.variantLookupTable(t).find(function(a){return n>=a.valueMin&&n<a.valueMax});if(i)return i.key},e.prototype.variantLookupTable=function(t){var r,n=[],i=0,a=0,u=t.filters||{},f=((r=u.multivariate)===null||r===void 0?void 0:r.variants)||[];return f.forEach(function(d){a=i+d.rollout_percentage/100,n.push({valueMin:i,valueMax:a,key:d.key}),i=a}),n},e.prototype.loadFeatureFlags=function(t){return t===void 0&&(t=!1),B2(this,void 0,void 0,function(){return R2(this,function(r){switch(r.label){case 0:return!this.loadedSuccessfullyOnce||t?[4,this._loadFeatureFlags()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},e.prototype._loadFeatureFlags=function(){return B2(this,void 0,void 0,function(){var t,r,n,i=this;return R2(this,function(a){switch(a.label){case 0:this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(function(){return i._loadFeatureFlags()},this.pollingInterval),a.label=1;case 1:return a.trys.push([1,4,,5]),[4,this._requestFeatureFlagDefinitions()];case 2:if(t=a.sent(),t&&t.status===401)throw new dQl("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");return t&&t.status!==200?[2]:[4,t.json()];case 3:return r=a.sent(),"flags"in r||console.error("Invalid response when getting feature flags: ".concat(JSON.stringify(r))),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce(function(u,f){return u[f.key]=f,u},{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0,[3,5];case 4:if(n=a.sent(),n instanceof dQl)throw n;return[3,5];case 5:return[2]}})})},e.prototype._requestFeatureFlagDefinitions=function(){return B2(this,void 0,void 0,function(){var t,r,n,i,a;return R2(this,function(u){switch(u.label){case 0:t="".concat(this.host,"/api/feature_flag/local_evaluation?token=").concat(this.projectApiKey,"&send_cohorts"),r={method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.personalApiKey),"user-agent":"posthog-node/".concat(jko)}},n=null,this.timeout&&typeof this.timeout=="number"&&(i=new AbortController,n=gQl(function(){i.abort()},this.timeout),r.signal=i.signal),u.label=1;case 1:return u.trys.push([1,3,4,5]),[4,this.fetch(t,r)];case 2:return[2,u.sent()];case 3:throw a=u.sent(),a;case 4:return clearTimeout(n),[7];case 5:return[2]}})})},e.prototype.stopPoller=function(){clearTimeout(this.poller)},e}();function pQl(e,t,r){r===void 0&&(r="");var n=(0,yQl.createHash)();return n.update("".concat(e,".").concat(t).concat(r)),parseInt(n.digest("hex").slice(0,15),16)/fGP}function PQl(e,t){var r=e.key,n=e.value,i=e.operator||"exact";if(r in t){if(i==="is_not_set")throw new vQ("Operator is_not_set is not supported")}else throw new vQ("Property ".concat(r," not found in propertyValues"));var a=t[r];switch(i){case"exact":return Array.isArray(n)?n.indexOf(a)!==-1:n===a;case"is_not":return Array.isArray(n)?n.indexOf(a)===-1:n!==a;case"is_set":return r in t;case"icontains":return String(a).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(a).toLowerCase().includes(String(n).toLowerCase());case"regex":return _Ql(String(n))&&String(a).match(String(n))!==null;case"not_regex":return _Ql(String(n))&&String(a).match(String(n))===null;case"gt":return typeof a==typeof n&&a>n;case"gte":return typeof a==typeof n&&a>=n;case"lt":return typeof a==typeof n&&a<n;case"lte":return typeof a==typeof n&&a<=n;case"is_date_after":case"is_date_before":var u=hQl(n),f=hQl(a);return i==="is_date_before"?f<u:f>u;default:return console.error("Unknown operator: ".concat(i)),!1}}function jQl(e,t,r){var n=String(e.value);if(!(n in r))throw new vQ("can't match cohort without a given cohort property value");var i=r[n];return wQl(i,t,r)}function wQl(e,t,r){if(!e)return!0;var n=e.type,i=e.values;if(!i||i.length===0)return!0;var a=!1;if("values"in i[0]){for(var u=0,f=i;u<f.length;u++){var d=f[u];try{var c=wQl(d,t,r);if(n==="AND"){if(!c)return!1}else if(c)return!0}catch(O){if(O instanceof vQ)console.debug("Failed to compute property ".concat(d," locally: ").concat(O)),a=!0;else throw O}}if(a)throw new vQ("Can't match cohort without a given cohort property value");return n==="AND"}else{for(var o=0,l=i;o<l.length;o++){var d=l[o];try{var c=void 0;d.type==="cohort"?c=jQl(d,t,r):c=PQl(d,t);var g=d.negation||!1;if(n==="AND"){if(!c&&!g||c&&g)return!1}else if(c&&!g||!c&&g)return!0}catch(j){if(j instanceof vQ)console.debug("Failed to compute property ".concat(d," locally: ").concat(j)),a=!0;else throw j}}if(a)throw new vQ("can't match cohort without a given cohort property value");return n==="AND"}}function _Ql(e){try{return new RegExp(e),!0}catch{return!1}}function hQl(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){var t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new vQ("".concat(e," is in an invalid date format"))}else throw new vQ("The date provided ".concat(e," must be a string, number, or date object"))}var pGP=30*1e3,_GP=50*1e3,qsa=function(e){mAn(t,e);function t(r,n){n===void 0&&(n={});var i=this,a;return n.captureMode=n?.captureMode||"json",i=e.call(this,r,n)||this,i._memoryStorage=new lGP,i.options=n,n.personalApiKey&&(i.featureFlagsPoller=new dGP({pollingInterval:typeof n.featureFlagsPollingInterval=="number"?n.featureFlagsPollingInterval:pGP,personalApiKey:n.personalApiKey,projectApiKey:r,timeout:(a=n.requestTimeout)!==null&&a!==void 0?a:1e4,host:i.host,fetch:n.fetch})),i.distinctIdHasSentFlagCalls={},i.maxCacheSize=n.maxCacheSize||_GP,i}return t.prototype.getPersistedProperty=function(r){return this._memoryStorage.getProperty(r)},t.prototype.setPersistedProperty=function(r,n){return this._memoryStorage.setProperty(r,n)},t.prototype.fetch=function(r,n){return this.options.fetch?this.options.fetch(r,n):OQl(r,n)},t.prototype.getLibraryId=function(){return"posthog-node"},t.prototype.getLibraryVersion=function(){return jko},t.prototype.getCustomUserAgent=function(){return"posthog-node/".concat(jko)},t.prototype.enable=function(){return e.prototype.optIn.call(this)},t.prototype.disable=function(){return e.prototype.optOut.call(this)},t.prototype.debug=function(r){var n;r===void 0&&(r=!0),e.prototype.debug.call(this,r),(n=this.featureFlagsPoller)===null||n===void 0||n.debug(r)},t.prototype.capture=function(r){var n=this,i=r.distinctId,a=r.event,u=r.properties,f=r.groups,d=r.sendFeatureFlags,c=r.timestamp,o=r.disableGeoip,l=function(g){e.prototype.captureStateless.call(n,i,a,g,{timestamp:c,disableGeoip:o})};d?e.prototype.getFeatureFlagsStateless.call(this,i,f,void 0,void 0,o).then(function(g){var O={};if(g)for(var j=0,S=Object.entries(g);j<S.length;j++){var T=S[j],C=T[0],I=T[1];I!==!1&&(O["$feature/".concat(C)]=I)}var N=Object.keys(g||{}).filter(function(U){return g?.[U]!==!1}),A=Bg({$active_feature_flags:N||void 0},O);l(Bg(Bg(Bg({},u),{$groups:f}),A))}):l(Bg(Bg({},u),{$groups:f}))},t.prototype.identify=function(r){var n=r.distinctId,i=r.properties,a=r.disableGeoip,u=i?.$set||i;e.prototype.identifyStateless.call(this,n,{$set:u},{disableGeoip:a})},t.prototype.alias=function(r){e.prototype.aliasStateless.call(this,r.alias,r.distinctId,void 0,{disableGeoip:r.disableGeoip})},t.prototype.getFeatureFlag=function(r,n,i){var a;return B2(this,void 0,void 0,function(){var u,f,d,c,o,l,g,O,j,S,T,C;return R2(this,function(I){switch(I.label){case 0:return u=i||{},f=u.groups,d=u.personProperties,c=u.groupProperties,o=u.disableGeoip,l=i||{},g=l.onlyEvaluateLocally,O=l.sendFeatureFlagEvents,g==null&&(g=!1),O==null&&(O=!0),[4,(a=this.featureFlagsPoller)===null||a===void 0?void 0:a.getFeatureFlag(r,n,f,d,c)];case 1:return j=I.sent(),S=j!==void 0,!S&&!g?[4,e.prototype.getFeatureFlagStateless.call(this,r,n,f,d,c,o)]:[3,3];case 2:j=I.sent(),I.label=3;case 3:return T="".concat(r,"_").concat(j),O&&(!(n in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[n].includes(T))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[n])?this.distinctIdHasSentFlagCalls[n].push(T):this.distinctIdHasSentFlagCalls[n]=[T],this.capture({distinctId:n,event:"$feature_flag_called",properties:(C={$feature_flag:r,$feature_flag_response:j,locally_evaluated:S},C["$feature/".concat(r)]=j,C),groups:f,disableGeoip:o})),[2,j]}})})},t.prototype.getFeatureFlagPayload=function(r,n,i,a){var u;return B2(this,void 0,void 0,function(){var f,d,c,o,l,g,O,j,S;return R2(this,function(T){switch(T.label){case 0:return f=a||{},d=f.groups,c=f.personProperties,o=f.groupProperties,l=f.disableGeoip,g=a||{},O=g.onlyEvaluateLocally,g.sendFeatureFlagEvents,j=void 0,i?[3,2]:[4,this.getFeatureFlag(r,n,Bg(Bg({},a),{onlyEvaluateLocally:!0}))];case 1:i=T.sent(),T.label=2;case 2:return i?[4,(u=this.featureFlagsPoller)===null||u===void 0?void 0:u.computeFeatureFlagPayloadLocally(r,i)]:[3,4];case 3:j=T.sent(),T.label=4;case 4:return O==null&&(O=!1),O==null&&(O=!1),S=j!==void 0,!S&&!O?[4,e.prototype.getFeatureFlagPayloadStateless.call(this,r,n,d,c,o,l)]:[3,6];case 5:j=T.sent(),T.label=6;case 6:try{return[2,JSON.parse(j)]}catch{return[2,j]}return[2]}})})},t.prototype.isFeatureEnabled=function(r,n,i){return B2(this,void 0,void 0,function(){var a;return R2(this,function(u){switch(u.label){case 0:return[4,this.getFeatureFlag(r,n,i)];case 1:return a=u.sent(),a===void 0?[2,void 0]:[2,!!a||!1]}})})},t.prototype.getAllFlags=function(r,n){return B2(this,void 0,void 0,function(){var i;return R2(this,function(a){switch(a.label){case 0:return[4,this.getAllFlagsAndPayloads(r,n)];case 1:return i=a.sent(),[2,i.featureFlags]}})})},t.prototype.getAllFlagsAndPayloads=function(r,n){var i;return B2(this,void 0,void 0,function(){var a,u,f,d,c,o,l,g,O,j,S;return R2(this,function(T){switch(T.label){case 0:return a=n||{},u=a.groups,f=a.personProperties,d=a.groupProperties,c=a.disableGeoip,o=(n||{}).onlyEvaluateLocally,o==null&&(o=!1),[4,(i=this.featureFlagsPoller)===null||i===void 0?void 0:i.getAllFlagsAndPayloads(r,u,f,d)];case 1:return l=T.sent(),g={},O={},j=!0,l&&(g=l.response,O=l.payloads,j=l.fallbackToDecide),j&&!o?[4,e.prototype.getFeatureFlagsAndPayloadsStateless.call(this,r,u,f,d,c)]:[3,3];case 2:S=T.sent(),g=Bg(Bg({},g),S.flags||{}),O=Bg(Bg({},O),S.payloads||{}),T.label=3;case 3:return[2,{featureFlags:g,featureFlagPayloads:O}]}})})},t.prototype.groupIdentify=function(r){var n=r.groupType,i=r.groupKey,a=r.properties,u=r.distinctId,f=r.disableGeoip;e.prototype.groupIdentifyStateless.call(this,n,i,a,{disableGeoip:f},u)},t.prototype.reloadFeatureFlags=function(){var r;return B2(this,void 0,void 0,function(){return R2(this,function(n){switch(n.label){case 0:return[4,(r=this.featureFlagsPoller)===null||r===void 0?void 0:r.loadFeatureFlags(!0)];case 1:return n.sent(),[2]}})})},t.prototype.shutdown=function(){this.shutdownAsync()},t.prototype.shutdownAsync=function(){var r;return B2(this,void 0,void 0,function(){return R2(this,function(n){return(r=this.featureFlagsPoller)===null||r===void 0||r.stopPoller(),[2,e.prototype.shutdownAsync.call(this)]})})},t}(mQl);var Asa=class{posthog;constructor({posthogApiKey:t}){this.posthog=new qsa(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.45.0-rc11",usingAccessToken:!0}})}flush(){this.posthog.flush()}};var Lli=class{async sendEvent(){}async identify(){}async flush(){}};var OAn=require("fs/promises"),MQl=require("os"),xQl=require("path");var DQl=iu(require("crypto")),Nsa=new Uint8Array(256),Csa=Nsa.length;function Dko(){return Csa>Nsa.length-16&&(DQl.default.randomFillSync(Nsa),Csa=0),Nsa.slice(Csa,Csa+=16)}var yW=[];for(let e=0;e<256;++e)yW.push((e+256).toString(16).slice(1));function SQl(e,t=0){return yW[e[t+0]]+yW[e[t+1]]+yW[e[t+2]]+yW[e[t+3]]+"-"+yW[e[t+4]]+yW[e[t+5]]+"-"+yW[e[t+6]]+yW[e[t+7]]+"-"+yW[e[t+8]]+yW[e[t+9]]+"-"+yW[e[t+10]]+yW[e[t+11]]+yW[e[t+12]]+yW[e[t+13]]+yW[e[t+14]]+yW[e[t+15]]}var EQl=iu(require("crypto")),Sko={randomUUID:EQl.default.randomUUID};function hGP(e,t,r){if(Sko.randomUUID&&!t&&!e)return Sko.randomUUID();e=e||{};let n=e.random||(e.rng||Dko)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return SQl(n)}var rNr=hGP;var yGP="id",vGP=".fern",Uli=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new qsa(r),this.userId=t==null?void 0:NGo(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.45.0-rc11",...t,...t.properties}})}flush(){this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=_f(O_.of((0,MQl.homedir)()),Ms.of(vGP),Ms.of(yGP));await Bh(t)||(await(0,OAn.mkdir)((0,xQl.dirname)(t),{recursive:!0}),await(0,OAn.writeFile)(t,rNr())),this.persistedDistinctId=(await(0,OAn.readFile)(t)).toString()}return this.persistedDistinctId}};var Eko;async function PAn(){return Eko==null&&(Eko=await bGP()),Eko}async function bGP(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Lli;let r=await ura();return r!=null?new Uli({token:r,posthogApiKey:e}):await ora()!=null?new Asa({posthogApiKey:e}):new Uli({token:void 0,posthogApiKey:e})}catch{return new Lli}}function Vli(e,t){return function(){return e.apply(t,arguments)}}var{toString:gGP}=Object.prototype,{getPrototypeOf:Tko}=Object,zsa=(e=>t=>{let r=gGP.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),zAt=e=>(e=e.toLowerCase(),t=>zsa(t)===e),Bsa=e=>t=>typeof t===e,{isArray:jAn}=Array,Wli=Bsa("undefined");function mGP(e){return e!==null&&!Wli(e)&&e.constructor!==null&&!Wli(e.constructor)&&fje(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var AQl=zAt("ArrayBuffer");function OGP(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&AQl(e.buffer),t}var PGP=Bsa("string"),fje=Bsa("function"),CQl=Bsa("number"),Rsa=e=>e!==null&&typeof e=="object",jGP=e=>e===!0||e===!1,Isa=e=>{if(zsa(e)!=="object")return!1;let t=Tko(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},wGP=zAt("Date"),DGP=zAt("File"),SGP=zAt("Blob"),EGP=zAt("FileList"),MGP=e=>Rsa(e)&&fje(e.pipe),xGP=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||fje(e.append)&&((t=zsa(e))==="formdata"||t==="object"&&fje(e.toString)&&e.toString()==="[object FormData]"))},TGP=zAt("URLSearchParams"),[qGP,AGP,CGP,NGP]=["ReadableStream","Request","Response","Headers"].map(zAt),IGP=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Hli(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),jAn(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,f;for(n=0;n<u;n++)f=a[n],t.call(null,e[f],f,e)}}function NQl(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var iZr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,IQl=e=>!Wli(e)&&e!==iZr;function xko(){let{caseless:e}=IQl(this)&&this||{},t={},r=(n,i)=>{let a=e&&NQl(t,i)||i;Isa(t[a])&&Isa(n)?t[a]=xko(t[a],n):Isa(n)?t[a]=xko({},n):jAn(n)?t[a]=n.slice():t[a]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Hli(arguments[n],r);return t}var zGP=(e,t,r,{allOwnKeys:n}={})=>(Hli(t,(i,a)=>{r&&fje(i)?e[a]=Vli(i,r):e[a]=i},{allOwnKeys:n}),e),BGP=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),RGP=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},FGP=(e,t,r,n)=>{let i,a,u,f={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)u=i[a],(!n||n(u,e,t))&&!f[u]&&(t[u]=e[u],f[u]=!0);e=r!==!1&&Tko(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},LGP=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},UGP=e=>{if(!e)return null;if(jAn(e))return e;let t=e.length;if(!CQl(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},VGP=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Tko(Uint8Array)),WGP=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},HGP=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},JGP=zAt("HTMLFormElement"),GGP=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),TQl=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),KGP=zAt("RegExp"),zQl=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};Hli(r,(i,a)=>{let u;(u=t(i,a,e))!==!1&&(n[a]=u||i)}),Object.defineProperties(e,n)},$GP=e=>{zQl(e,(t,r)=>{if(fje(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(fje(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},YGP=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return jAn(e)?n(e):n(String(e).split(t)),r},XGP=()=>{},QGP=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,Mko="abcdefghijklmnopqrstuvwxyz",qQl="0123456789",BQl={DIGIT:qQl,ALPHA:Mko,ALPHA_DIGIT:Mko+Mko.toUpperCase()+qQl},ZGP=(e=16,t=BQl.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function kGP(e){return!!(e&&fje(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var eKP=e=>{let t=new Array(10),r=(n,i)=>{if(Rsa(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;let a=jAn(n)?[]:{};return Hli(n,(u,f)=>{let d=r(u,i+1);!Wli(d)&&(a[f]=d)}),t[i]=void 0,a}}return n};return r(e,0)},tKP=zAt("AsyncFunction"),rKP=e=>e&&(Rsa(e)||fje(e))&&fje(e.then)&&fje(e.catch),RQl=((e,t)=>e?setImmediate:t?((r,n)=>(iZr.addEventListener("message",({source:i,data:a})=>{i===iZr&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),iZr.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",fje(iZr.postMessage)),nKP=typeof queueMicrotask<"u"?queueMicrotask.bind(iZr):typeof process<"u"&&process.nextTick||RQl,Hl={isArray:jAn,isArrayBuffer:AQl,isBuffer:mGP,isFormData:xGP,isArrayBufferView:OGP,isString:PGP,isNumber:CQl,isBoolean:jGP,isObject:Rsa,isPlainObject:Isa,isReadableStream:qGP,isRequest:AGP,isResponse:CGP,isHeaders:NGP,isUndefined:Wli,isDate:wGP,isFile:DGP,isBlob:SGP,isRegExp:KGP,isFunction:fje,isStream:MGP,isURLSearchParams:TGP,isTypedArray:VGP,isFileList:EGP,forEach:Hli,merge:xko,extend:zGP,trim:IGP,stripBOM:BGP,inherits:RGP,toFlatObject:FGP,kindOf:zsa,kindOfTest:zAt,endsWith:LGP,toArray:UGP,forEachEntry:WGP,matchAll:HGP,isHTMLForm:JGP,hasOwnProperty:TQl,hasOwnProp:TQl,reduceDescriptors:zQl,freezeMethods:$GP,toObjectSet:YGP,toCamelCase:GGP,noop:XGP,toFiniteNumber:QGP,findKey:NQl,global:iZr,isContextDefined:IQl,ALPHABET:BQl,generateString:ZGP,isSpecCompliantForm:kGP,toJSONObject:eKP,isAsyncFn:tKP,isThenable:rKP,setImmediate:RQl,asap:nKP};function wAn(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Hl.inherits(wAn,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:Hl.toJSONObject(this.config),code:this.code,status:this.status}}});var FQl=wAn.prototype,LQl={};["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=>{LQl[e]={value:e}});Object.defineProperties(wAn,LQl);Object.defineProperty(FQl,"isAxiosError",{value:!0});wAn.from=(e,t,r,n,i,a)=>{let u=Object.create(FQl);return Hl.toFlatObject(e,u,function(d){return d!==Error.prototype},f=>f!=="isAxiosError"),wAn.call(u,e.message,t,r,n,i),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var xy=wAn;var UQl=iu(wXr(),1),Fsa=UQl.default;function qko(e){return Hl.isPlainObject(e)||Hl.isArray(e)}function WQl(e){return Hl.endsWith(e,"[]")?e.slice(0,-2):e}function VQl(e,t,r){return e?e.concat(t).map(function(i,a){return i=WQl(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function iKP(e){return Hl.isArray(e)&&!e.some(qko)}var aKP=Hl.toFlatObject(Hl,{},null,function(t){return/^is[A-Z]/.test(t)});function oKP(e,t,r){if(!Hl.isObject(e))throw new TypeError("target must be an object");t=t||new(Fsa||FormData),r=Hl.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(S,T){return!Hl.isUndefined(T[S])});let n=r.metaTokens,i=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&Hl.isSpecCompliantForm(t);if(!Hl.isFunction(i))throw new TypeError("visitor must be a function");function c(j){if(j===null)return"";if(Hl.isDate(j))return j.toISOString();if(!d&&Hl.isBlob(j))throw new xy("Blob is not supported. Use a Buffer instead.");return Hl.isArrayBuffer(j)||Hl.isTypedArray(j)?d&&typeof Blob=="function"?new Blob([j]):Buffer.from(j):j}function o(j,S,T){let C=j;if(j&&!T&&typeof j=="object"){if(Hl.endsWith(S,"{}"))S=n?S:S.slice(0,-2),j=JSON.stringify(j);else if(Hl.isArray(j)&&iKP(j)||(Hl.isFileList(j)||Hl.endsWith(S,"[]"))&&(C=Hl.toArray(j)))return S=WQl(S),C.forEach(function(N,A){!(Hl.isUndefined(N)||N===null)&&t.append(u===!0?VQl([S],A,a):u===null?S:S+"[]",c(N))}),!1}return qko(j)?!0:(t.append(VQl(T,S,a),c(j)),!1)}let l=[],g=Object.assign(aKP,{defaultVisitor:o,convertValue:c,isVisitable:qko});function O(j,S){if(!Hl.isUndefined(j)){if(l.indexOf(j)!==-1)throw Error("Circular reference detected in "+S.join("."));l.push(j),Hl.forEach(j,function(C,I){(!(Hl.isUndefined(C)||C===null)&&i.call(t,C,Hl.isString(I)?I.trim():I,S,g))===!0&&O(C,S?S.concat(I):[I])}),l.pop()}}if(!Hl.isObject(e))throw new TypeError("data must be an object");return O(e),t}var nNr=oKP;function HQl(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function JQl(e,t){this._pairs=[],e&&nNr(e,this,t)}var GQl=JQl.prototype;GQl.append=function(t,r){this._pairs.push([t,r])};GQl.toString=function(t){let r=t?function(n){return t.call(this,n,HQl)}:HQl;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var KQl=JQl;function uKP(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function aZr(e,t,r){if(!t)return e;let n=r&&r.encode||uKP,i=r&&r.serialize,a;if(i?a=i(t,r):a=Hl.isURLSearchParams(t)?t.toString():new KQl(t,r).toString(n),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Ako=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Hl.forEach(this.handlers,function(n){n!==null&&t(n)})}},Cko=Ako;var DAn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var $Ql=iu(require("url"),1),YQl=$Ql.default.URLSearchParams;var XQl={isNode:!0,classes:{URLSearchParams:YQl,FormData:Fsa,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var zko={};td(zko,{hasBrowserEnv:()=>Iko,hasStandardBrowserEnv:()=>sKP,hasStandardBrowserWebWorkerEnv:()=>cKP,navigator:()=>Nko,origin:()=>lKP});var Iko=typeof window<"u"&&typeof document<"u",Nko=typeof navigator=="object"&&navigator||void 0,sKP=Iko&&(!Nko||["ReactNative","NativeScript","NS"].indexOf(Nko.product)<0),cKP=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",lKP=Iko&&window.location.href||"http://localhost";var wC={...zko,...XQl};function Bko(e,t){return nNr(e,new wC.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,a){return wC.isNode&&Hl.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function fKP(e){return Hl.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function dKP(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function pKP(e){function t(r,n,i,a){let u=r[a++];if(u==="__proto__")return!0;let f=Number.isFinite(+u),d=a>=r.length;return u=!u&&Hl.isArray(i)?i.length:u,d?(Hl.hasOwnProp(i,u)?i[u]=[i[u],n]:i[u]=n,!f):((!i[u]||!Hl.isObject(i[u]))&&(i[u]=[]),t(r,n,i[u],a)&&Hl.isArray(i[u])&&(i[u]=dKP(i[u])),!f)}if(Hl.isFormData(e)&&Hl.isFunction(e.entries)){let r={};return Hl.forEachEntry(e,(n,i)=>{t(fKP(n),i,r,0)}),r}return null}var Lsa=pKP;function _KP(e,t,r){if(Hl.isString(e))try{return(t||JSON.parse)(e),Hl.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var Rko={transitional:DAn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Hl.isObject(t);if(a&&Hl.isHTMLForm(t)&&(t=new FormData(t)),Hl.isFormData(t))return i?JSON.stringify(Lsa(t)):t;if(Hl.isArrayBuffer(t)||Hl.isBuffer(t)||Hl.isStream(t)||Hl.isFile(t)||Hl.isBlob(t)||Hl.isReadableStream(t))return t;if(Hl.isArrayBufferView(t))return t.buffer;if(Hl.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let f;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Bko(t,this.formSerializer).toString();if((f=Hl.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return nNr(f?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),_KP(t)):t}],transformResponse:[function(t){let r=this.transitional||Rko.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Hl.isResponse(t)||Hl.isReadableStream(t))return t;if(t&&Hl.isString(t)&&(n&&!this.responseType||i)){let u=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(f){if(u)throw f.name==="SyntaxError"?xy.from(f,xy.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:wC.classes.FormData,Blob:wC.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Hl.forEach(["delete","get","head","post","put","patch"],e=>{Rko.headers[e]={}});var SAn=Rko;var hKP=Hl.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"]),QQl=e=>{let t={},r,n,i;return e&&e.split(`
1761
+ `}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&&nsa(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var nQl=iu(XXl(),1),iQl=iu(jQo(),1),aQl=iu(tQl(),1),fq=iu(lje(),1),oQl=iu(wci(),1);var Esa=iu(lje(),1),rQl=iu(wci(),1),Msa=function(e,t,r){return typeof e[t]!="function"?(0,Esa.of)(e):(0,Esa.from)((0,rQl.default)(e[t])(r).then(n=>(e[t]=n,e)))};var zli={isPlainObject:nQl.default,set:aQl.default,get:iQl.default},gAn=class extends nZr{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=zli.isPlainObject(r)?{...r}:{},zli.isPlainObject(t)&&(t=Object.values(t).every(i=>zli.isPlainObject(i)&&i.name===void 0)?Object.entries(t).map(([i,a])=>({name:i,...a})):[t]);let n=Array.isArray(t)?(0,fq.from)(t):t;return this.process=n.pipe((0,fq.concatMap)(this.processQuestion.bind(this)),(0,fq.publish)()),this.process.connect(),this.process.pipe((0,fq.reduce)((i,a)=>(zli.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,fq.defer)(()=>(0,fq.of)(t).pipe((0,fq.concatMap)(this.setDefaultType.bind(this)),(0,fq.concatMap)(this.filterIfRunnable.bind(this)),(0,fq.concatMap)(()=>Msa(t,"message",this.answers)),(0,fq.concatMap)(()=>Msa(t,"default",this.answers)),(0,fq.concatMap)(()=>Msa(t,"choices",this.answers)),(0,fq.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,fq.defer)(()=>(0,fq.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,fq.defer)(()=>(0,fq.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&zli.get(this.answers,t.name)!==void 0)return(0,fq.empty)();if(t.when===!1)return(0,fq.empty)();if(typeof t.when!="function")return(0,fq.of)(t);let{answers:r}=this;return(0,fq.defer)(()=>(0,fq.from)((0,oQl.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,fq.filter)(n=>n!=null)))}};function uQl(e){let t=function(r,n){let i;try{i=new gAn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",bli),this.registerPrompt("input",XQr),this.registerPrompt("number",gli),this.registerPrompt("confirm",mli),this.registerPrompt("rawlist",Oli),this.registerPrompt("expand",Pli),this.registerPrompt("checkbox",jli),this.registerPrompt("password",wli),this.registerPrompt("editor",Nli)},t.restoreDefaultPrompts(),t}var mko=uQl();function ZJP(e,t){mko.registerPrompt(e,t)}function kJP(){mko.restoreDefaultPrompts()}var eGP={prompt:mko,ui:{BottomBar:Ili,Prompt:gAn},createPromptModule:uQl,registerPrompt:ZJP,restoreDefaultPrompts:kJP,Separator:one},xsa=eGP;var yQl=iu(sQl()),vQl=iu(NJo()),Pko=function(e,t){return Pko=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},Pko(e,t)};function mAn(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Pko(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var Bg=function(){return Bg=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},Bg.apply(this,arguments)};function tGP(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function B2(e,t,r,n){function i(a){return a instanceof r?a:new r(function(u){u(a)})}return new(r||(r=Promise))(function(a,u){function f(o){try{c(n.next(o))}catch(l){u(l)}}function d(o){try{c(n.throw(o))}catch(l){u(l)}}function c(o){o.done?a(o.value):i(o.value).then(f,d)}c((n=n.apply(e,t||[])).next())})}function R2(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,i,a,u;return u={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function f(c){return function(o){return d([c,o])}}function d(c){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(a=c[0]&2?i.return:c[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,c[1])).done)return a;switch(i=0,a&&(c=[c[0]&2,a.value]),c[0]){case 0:case 1:a=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,i=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){r.label=c[1];break}if(c[0]===6&&r.label<a[1]){r.label=a[1],a=c;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(c);break}a[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r)}catch(o){c=[6,o],i=0}finally{n=a=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function bQl(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,a;n<i;n++)(a||!(n in t))&&(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}var jko="3.1.2",Y1;(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"})(Y1||(Y1={}));function rGP(e,t){if(!e)throw new Error(t)}function nGP(e){return e?.replace(/\/+$/,"")}function iGP(e,t){return t===void 0&&(t={}),B2(this,void 0,void 0,function(){var r,n,i,a,u,f,d,c,o,l;return R2(this,function(g){switch(g.label){case 0:r=t.retryCount,n=r===void 0?3:r,i=t.retryDelay,a=i===void 0?5e3:i,u=t.retryCheck,f=u===void 0?function(){return!0}:u,d=null,c=0,g.label=1;case 1:return c<n+1?c>0?[4,new Promise(function(O){return setTimeout(O,a)})]:[3,3]:[3,7];case 2:g.sent(),g.label=3;case 3:return g.trys.push([3,5,,6]),[4,e()];case 4:return o=g.sent(),[2,o];case 5:if(l=g.sent(),d=l,!f(l))throw l;return[3,6];case 6:return c++,[3,1];case 7:throw d}})})}function wko(e){var t=new Date().getTime(),r=e&&e.performance&&e.performance.now&&e.performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var i=Math.random()*16;return t>0?(i=(t+i)%16|0,t=Math.floor(t/16)):(i=(r+i)%16|0,r=Math.floor(r/16)),(n==="x"?i:i&3|8).toString(16)})}function aGP(){return new Date().getTime()}function cQl(){return new Date().toISOString()}function gQl(e,t){var r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var Rli=String.fromCharCode,lQl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Tsa={};function oGP(e,t){if(!Tsa[e]){Tsa[e]={};for(var r=0;r<e.length;r++)Tsa[e][e.charAt(r)]=r}return Tsa[e][t]}var Fli={compressToBase64:function(e){if(e==null)return"";var t=Fli._compress(e,6,function(r){return lQl.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:Fli._decompress(e.length,32,function(t){return oGP(lQl,e.charAt(t))})},compress:function(e){return Fli._compress(e,16,function(t){return Rli(t)})},_compress:function(e,t,r){if(e==null)return"";var n={},i={},a=[],u,f,d="",c="",o="",l=2,g=3,O=2,j=0,S=0,T;for(T=0;T<e.length;T+=1)if(d=e.charAt(T),Object.prototype.hasOwnProperty.call(n,d)||(n[d]=g++,i[d]=!0),c=o+d,Object.prototype.hasOwnProperty.call(n,c))o=c;else{if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,S==t-1?(S=0,a.push(r(j)),j=0):S++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)j=j<<1|f&1,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++),n[c]=g++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,S==t-1?(S=0,a.push(r(j)),j=0):S++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)j=j<<1|f&1,S==t-1?(S=0,a.push(r(j)),j=0):S++,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,S==t-1?(S=0,a.push(r(j)),j=0):S++,f=f>>1;for(;;)if(j=j<<1,S==t-1){a.push(r(j));break}else S++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:Fli._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){var n=[],i=[],a={val:r(0),position:t,index:1},u=4,f=4,d=3,c="",o,l,g,O,j,S,T;for(o=0;o<3;o+=1)n[o]=o;for(g=0,j=Math.pow(2,2),S=1;S!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*S,S<<=1;switch(g){case 0:for(g=0,j=Math.pow(2,8),S=1;S!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*S,S<<=1;T=Rli(g);break;case 1:for(g=0,j=Math.pow(2,16),S=1;S!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*S,S<<=1;T=Rli(g);break;case 2:return""}for(n[3]=T,l=T,i.push(T);;){if(a.index>e)return"";for(g=0,j=Math.pow(2,d),S=1;S!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*S,S<<=1;switch(T=g){case 0:for(g=0,j=Math.pow(2,8),S=1;S!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*S,S<<=1;n[f++]=Rli(g),T=f-1,u--;break;case 1:for(g=0,j=Math.pow(2,16),S=1;S!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*S,S<<=1;n[f++]=Rli(g),T=f-1,u--;break;case 2:return i.join("")}if(u==0&&(u=Math.pow(2,d),d++),n[T])c=n[T];else if(T===f)c=l+l.charAt(0);else return null;i.push(c),n[f++]=l+c.charAt(0),u--,l=c,u==0&&(u=Math.pow(2,d),d++)}}},uGP=function(){function e(){this.events={},this.events={}}return e.prototype.on=function(t,r){var n=this;return this.events[t]||(this.events[t]=[]),this.events[t].push(r),function(){n.events[t]=n.events[t].filter(function(i){return i!==r})}},e.prototype.emit=function(t,r){for(var n=0,i=this.events[t]||[];n<i.length;n++){var a=i[n];a(r)}for(var u=0,f=this.events["*"]||[];u<f.length;u++){var a=f[u];a(t,r)}},e}(),sGP=function(e){mAn(t,e);function t(r){var n=e.call(this,"HTTP error while fetching PostHog: "+r.status)||this;return n.response=r,n.name="PostHogFetchHttpError",n}return t}(Error),cGP=function(e){mAn(t,e);function t(r){var n=e.call(this,"Network error while fetching PostHog",r instanceof Error?{cause:r}:{})||this;return n.error=r,n.name="PostHogFetchNetworkError",n}return t}(Error);function fQl(e){return typeof e=="object"&&(e.name==="PostHogFetchHttpError"||e.name==="PostHogFetchNetworkError")}var mQl=function(){function e(t,r){var n,i,a,u,f;this.debugMode=!1,this.pendingPromises={},this.disableGeoip=!0,this._events=new uGP,rGP(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=nGP(r?.host||"https://app.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.flushInterval=(n=r?.flushInterval)!==null&&n!==void 0?n:1e4,this.captureMode=r?.captureMode||"form",this._optoutOverride=r?.enable===!1,this._retryOptions={retryCount:(i=r?.fetchRetryCount)!==null&&i!==void 0?i:3,retryDelay:(a=r?.fetchRetryDelay)!==null&&a!==void 0?a:3e3,retryCheck:fQl},this.requestTimeout=(u=r?.requestTimeout)!==null&&u!==void 0?u:1e4,this.disableGeoip=(f=r?.disableGeoip)!==null&&f!==void 0?f:!0}return e.prototype.getCommonEventProperties=function(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}},Object.defineProperty(e.prototype,"optedOut",{get:function(){var t,r;return(r=(t=this.getPersistedProperty(Y1.OptedOut))!==null&&t!==void 0?t:this._optoutOverride)!==null&&r!==void 0?r:!1},enumerable:!1,configurable:!0}),e.prototype.optIn=function(){this.setPersistedProperty(Y1.OptedOut,!1)},e.prototype.optOut=function(){this.setPersistedProperty(Y1.OptedOut,!0)},e.prototype.on=function(t,r){return this._events.on(t,r)},e.prototype.debug=function(t){var r;t===void 0&&(t=!0),(r=this.removeDebugCallback)===null||r===void 0||r.call(this),this.debugMode=t,t&&(this.removeDebugCallback=this.on("*",function(n,i){return console.log("PostHog Debug",n,i)}))},e.prototype.buildPayload=function(t){return{distinct_id:t.distinct_id,event:t.event,properties:Bg(Bg({},t.properties||{}),this.getCommonEventProperties())}},e.prototype.identifyStateless=function(t,r,n){var i=Bg({},this.buildPayload({distinct_id:t,event:"$identify",properties:r}));return this.enqueue("identify",i,n),this},e.prototype.captureStateless=function(t,r,n,i){var a=this.buildPayload({distinct_id:t,event:r,properties:n});return this.enqueue("capture",a,i),this},e.prototype.aliasStateless=function(t,r,n,i){var a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:Bg(Bg({},n||{}),{distinct_id:r,alias:t})});return this.enqueue("alias",a,i),this},e.prototype.groupIdentifyStateless=function(t,r,n,i,a,u){var f=this.buildPayload({distinct_id:a||"$".concat(t,"_").concat(r),event:"$groupidentify",properties:Bg({$group_type:t,$group_key:r,$group_set:n||{}},u||{})});return this.enqueue("capture",f,i),this},e.prototype.getDecide=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),B2(this,void 0,void 0,function(){var u,f;return R2(this,function(d){return u="".concat(this.host,"/decide/?v=3"),f={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Bg({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i},a))},[2,this.fetchWithRetry(u,f).then(function(c){return c.json()}).catch(function(c){console.error("Error fetching feature flags",c)})]})})},e.prototype.getFeatureFlagStateless=function(t,r,n,i,a,u){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),B2(this,void 0,void 0,function(){var f,d;return R2(this,function(c){switch(c.label){case 0:return[4,this.getFeatureFlagsStateless(r,n,i,a,u)];case 1:return f=c.sent(),f?(d=f[t],d===void 0&&(d=!1),[2,d]):[2,void 0]}})})},e.prototype.getFeatureFlagPayloadStateless=function(t,r,n,i,a,u){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),B2(this,void 0,void 0,function(){var f,d;return R2(this,function(c){switch(c.label){case 0:return[4,this.getFeatureFlagPayloadsStateless(r,n,i,a,u)];case 1:return f=c.sent(),f?(d=f[t],d===void 0?[2,null]:[2,this._parsePayload(d)]):[2,void 0]}})})},e.prototype.getFeatureFlagPayloadsStateless=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),B2(this,void 0,void 0,function(){var u,f=this;return R2(this,function(d){switch(d.label){case 0:return[4,this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)];case 1:return u=d.sent().payloads,u?[2,Object.fromEntries(Object.entries(u).map(function(c){var o=c[0],l=c[1];return[o,f._parsePayload(l)]}))]:[2,u]}})})},e.prototype._parsePayload=function(t){try{return JSON.parse(t)}catch{return t}},e.prototype.getFeatureFlagsStateless=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),B2(this,void 0,void 0,function(){return R2(this,function(u){switch(u.label){case 0:return[4,this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)];case 1:return[2,u.sent().flags]}})})},e.prototype.getFeatureFlagsAndPayloadsStateless=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),B2(this,void 0,void 0,function(){var u,f,d,c;return R2(this,function(o){switch(o.label){case 0:return u={},(a??this.disableGeoip)&&(u.geoip_disable=!0),[4,this.getDecide(t,r,n,i,u)];case 1:return f=o.sent(),d=f?.featureFlags,c=f?.featureFlagPayloads,[2,{flags:d,payloads:c}]}})})},e.prototype.enqueue=function(t,r,n){var i=this,a;if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.enable()");return}var u=Bg(Bg({},r),{type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:cQl()}),f=(a=n?.disableGeoip)!==null&&a!==void 0?a:this.disableGeoip;f&&(u.properties||(u.properties={}),u.properties.$geoip_disable=!0),u.distinctId&&(u.distinct_id=u.distinctId,delete u.distinctId);var d=this.getPersistedProperty(Y1.Queue)||[];d.push({message:u}),this.setPersistedProperty(Y1.Queue,d),this._events.emit(t,u),d.length>=this.flushAt&&this.flush(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=gQl(function(){return i.flush()},this.flushInterval))},e.prototype.flushAsync=function(){var t=this;return new Promise(function(r,n){t.flush(function(i,a){return i?n(i):r(a)})})},e.prototype.flush=function(t){var r=this;this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=null);var n=this.getPersistedProperty(Y1.Queue)||[];if(!n.length)return t?.();var i=n.splice(0,this.flushAt);this.setPersistedProperty(Y1.Queue,n);var a=i.map(function(O){return O.message}),u={api_key:this.apiKey,batch:a,sent_at:cQl()},f=wko(),d=function(O){O&&r._events.emit("error",O),t?.(O,a),delete r.pendingPromises[f],r._events.emit("flush",a)};this.getCustomUserAgent();var c=JSON.stringify(u),o=this.captureMode==="form"?"".concat(this.host,"/e/?ip=1&_=").concat(aGP(),"&v=").concat(this.getLibraryVersion()):"".concat(this.host,"/batch/"),l=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"data=".concat(encodeURIComponent(Fli.compressToBase64(c)),"&compression=lz64")}:{method:"POST",headers:{"Content-Type":"application/json"},body:c},g=this.fetchWithRetry(o,l);this.pendingPromises[f]=g,g.then(function(){return d()}).catch(function(O){d(O)})},e.prototype.fetchWithRetry=function(t,r,n){var i,a;return B2(this,void 0,void 0,function(){var u=this;return R2(this,function(f){switch(f.label){case 0:return(i=(a=AbortSignal).timeout)!==null&&i!==void 0||(a.timeout=function(c){var o=new AbortController;return setTimeout(function(){return o.abort()},c),o.signal}),[4,iGP(function(){return B2(u,void 0,void 0,function(){var d,c;return R2(this,function(o){switch(o.label){case 0:d=null,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.fetch(t,Bg({signal:AbortSignal.timeout(this.requestTimeout)},r))];case 2:return d=o.sent(),[3,4];case 3:throw c=o.sent(),new cGP(c);case 4:if(d.status<200||d.status>=400)throw new sGP(d);return[2,d]}})})},Bg(Bg({},this._retryOptions),n))];case 1:return[2,f.sent()]}})})},e.prototype.shutdownAsync=function(){return B2(this,void 0,void 0,function(){var t;return R2(this,function(r){switch(r.label){case 0:clearTimeout(this._flushTimer),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,this.flushAsync()];case 2:return r.sent(),[4,Promise.all(Object.values(this.pendingPromises).map(function(n){return n.catch(function(){})}))];case 3:return r.sent(),[3,5];case 4:if(t=r.sent(),!fQl(t))throw t;return console.error("Error while shutting down PostHog",t),[3,5];case 5:return[2]}})})},e.prototype.shutdown=function(){this.shutdownAsync()},e}();(function(e){mAn(t,e);function t(r,n){var i=this,a,u,f,d=(a=n?.disableGeoip)!==null&&a!==void 0?a:!1;return i=e.call(this,r,Bg(Bg({},n),{disableGeoip:d}))||this,i.flagCallReported={},i.sessionProps={},i.sendFeatureFlagEvent=(u=n?.sendFeatureFlagEvent)!==null&&u!==void 0?u:!0,i._sessionExpirationTimeSeconds=(f=n?.sessionExpirationTimeSeconds)!==null&&f!==void 0?f:1800,i}return t.prototype.setupBootstrap=function(r){var n,i,a,u;if(!((n=r?.bootstrap)===null||n===void 0)&&n.distinctId&&(!((i=r?.bootstrap)===null||i===void 0)&&i.isIdentifiedId?this.setPersistedProperty(Y1.DistinctId,r.bootstrap.distinctId):this.setPersistedProperty(Y1.AnonymousId,r.bootstrap.distinctId)),!((a=r?.bootstrap)===null||a===void 0)&&a.featureFlags){var f=Object.keys(((u=r.bootstrap)===null||u===void 0?void 0:u.featureFlags)||{}).filter(function(d){var c,o;return!!(!((o=(c=r.bootstrap)===null||c===void 0?void 0:c.featureFlags)===null||o===void 0)&&o[d])}).reduce(function(d,c){var o,l;return d[c]=((l=(o=r.bootstrap)===null||o===void 0?void 0:o.featureFlags)===null||l===void 0?void 0:l[c])||!1,d},{});this.setKnownFeatureFlags(f),r?.bootstrap.featureFlagPayloads&&this.setKnownFeatureFlagPayloads(r?.bootstrap.featureFlagPayloads)}},Object.defineProperty(t.prototype,"props",{get:function(){return this._props||(this._props=this.getPersistedProperty(Y1.Props)),this._props||{}},set:function(r){this._props=r},enumerable:!1,configurable:!0}),t.prototype.clearProps=function(){this.props=void 0,this.sessionProps={}},t.prototype.on=function(r,n){return this._events.on(r,n)},t.prototype.reset=function(r){var n=bQl([Y1.Queue],r||[],!0);this.clearProps();for(var i=0,a=Object.keys(Y1);i<a.length;i++){var u=a[i];n.includes(Y1[u])||this.setPersistedProperty(Y1[u],null)}},t.prototype.getCommonEventProperties=function(){var r=this.getFeatureFlags(),n={};if(r)for(var i=0,a=Object.entries(r);i<a.length;i++){var u=a[i],f=u[0],d=u[1];n["$feature/".concat(f)]=d}return Bg(Bg({$active_feature_flags:r?Object.keys(r):void 0},n),e.prototype.getCommonEventProperties.call(this))},t.prototype.enrichProperties=function(r){return Bg(Bg(Bg(Bg(Bg({},this.props),this.sessionProps),r||{}),this.getCommonEventProperties()),{$session_id:this.getSessionId()})},t.prototype.getSessionId=function(){var r=this.getPersistedProperty(Y1.SessionId),n=this.getPersistedProperty(Y1.SessionLastTimestamp)||0;return(!r||Date.now()-n>this._sessionExpirationTimeSeconds*1e3)&&(r=wko(globalThis),this.setPersistedProperty(Y1.SessionId,r)),this.setPersistedProperty(Y1.SessionLastTimestamp,Date.now()),r},t.prototype.resetSessionId=function(){this.setPersistedProperty(Y1.SessionId,null)},t.prototype.getAnonymousId=function(){var r=this.getPersistedProperty(Y1.AnonymousId);return r||(r=wko(globalThis),this.setPersistedProperty(Y1.AnonymousId,r)),r},t.prototype.getDistinctId=function(){return this.getPersistedProperty(Y1.DistinctId)||this.getAnonymousId()},t.prototype.unregister=function(r){delete this.props[r],this.setPersistedProperty(Y1.Props,this.props)},t.prototype.register=function(r){this.props=Bg(Bg({},this.props),r),this.setPersistedProperty(Y1.Props,this.props)},t.prototype.registerForSession=function(r){this.sessionProps=Bg(Bg({},this.sessionProps),r)},t.prototype.unregisterForSession=function(r){delete this.sessionProps[r]},t.prototype.identify=function(r,n,i){var a=this.getDistinctId();r=r||a,n?.$groups&&this.groups(n.$groups);var u=this.enrichProperties(Bg(Bg({},n),{$anon_distinct_id:this.getAnonymousId(),$set:n}));return r!==a&&(this.setPersistedProperty(Y1.AnonymousId,a),this.setPersistedProperty(Y1.DistinctId,r),this.reloadFeatureFlags()),e.prototype.identifyStateless.call(this,r,u,i),this},t.prototype.capture=function(r,n,i){var a=this.getDistinctId();n?.$groups&&this.groups(n.$groups);var u=this.enrichProperties(n);return e.prototype.captureStateless.call(this,a,r,u,i),this},t.prototype.alias=function(r){var n=this.getDistinctId(),i=this.enrichProperties({});return e.prototype.aliasStateless.call(this,r,n,i),this},t.prototype.autocapture=function(r,n,i,a){i===void 0&&(i={});var u=this.getDistinctId(),f={distinct_id:u,event:"$autocapture",properties:Bg(Bg({},this.enrichProperties(i)),{$event_type:r,$elements:n})};return this.enqueue("autocapture",f,a),this},t.prototype.groups=function(r){var n=this.props.$groups||{};return this.register({$groups:Bg(Bg({},n),r)}),Object.keys(r).find(function(i){return n[i]!==r[i]})&&this.reloadFeatureFlags(),this},t.prototype.group=function(r,n,i,a){var u;return this.groups((u={},u[r]=n,u)),i&&this.groupIdentify(r,n,i,a),this},t.prototype.groupIdentify=function(r,n,i,a){var u=this.getDistinctId(),f=this.enrichProperties({});return e.prototype.groupIdentifyStateless.call(this,r,n,i,a,u,f),this},t.prototype.personProperties=function(r){var n=this.getPersistedProperty(Y1.PersonProperties)||{};return this.setPersistedProperty(Y1.PersonProperties,Bg(Bg({},n),r)),this},t.prototype.groupProperties=function(r){var n=this.getPersistedProperty(Y1.GroupProperties)||{};return Object.keys(n).length!==0&&Object.keys(n).forEach(function(i){n[i]=Bg(Bg({},n[i]),r[i]),delete r[i]}),this.setPersistedProperty(Y1.GroupProperties,Bg(Bg({},n),r)),this},t.prototype.decideAsync=function(r){return r===void 0&&(r=!0),this._decideResponsePromise?this._decideResponsePromise:this._decideAsync(r)},t.prototype._decideAsync=function(r){return r===void 0&&(r=!0),B2(this,void 0,void 0,function(){var n,i,a,u,f,d=this;return R2(this,function(c){return n=this.getDistinctId(),i=this.props.$groups||{},a=this.getPersistedProperty(Y1.PersonProperties)||{},u=this.getPersistedProperty(Y1.GroupProperties)||{},f={$anon_distinct_id:r?this.getAnonymousId():void 0},this._decideResponsePromise=e.prototype.getDecide.call(this,n,i,a,u,f).then(function(o){if(o?.featureFlags){var l=o.featureFlags,g=o.featureFlagPayloads;if(o.errorsWhileComputingFlags){var O=d.getPersistedProperty(Y1.FeatureFlags),j=d.getPersistedProperty(Y1.FeatureFlagPayloads);l=Bg(Bg({},O),o.featureFlags),g=Bg(Bg({},j),o.featureFlagPayloads)}d.setKnownFeatureFlags(l),d.setKnownFeatureFlagPayloads(g)}return o}).finally(function(){d._decideResponsePromise=void 0}),[2,this._decideResponsePromise]})})},t.prototype.setKnownFeatureFlags=function(r){this.setPersistedProperty(Y1.FeatureFlags,r),this._events.emit("featureflags",r)},t.prototype.setKnownFeatureFlagPayloads=function(r){this.setPersistedProperty(Y1.FeatureFlagPayloads,r)},t.prototype.getFeatureFlag=function(r){var n=this.getFeatureFlags();if(n){var i=n[r];return i===void 0&&(i=!1),this.sendFeatureFlagEvent&&!this.flagCallReported[r]&&(this.flagCallReported[r]=!0,this.capture("$feature_flag_called",{$feature_flag:r,$feature_flag_response:i})),i}},t.prototype.getFeatureFlagPayload=function(r){var n=this.getFeatureFlagPayloads();if(n){var i=n[r];return i===void 0?null:this._parsePayload(i)}},t.prototype.getFeatureFlagPayloads=function(){var r=this,n=this.getPersistedProperty(Y1.FeatureFlagPayloads);return n&&Object.fromEntries(Object.entries(n).map(function(i){var a=i[0],u=i[1];return[a,r._parsePayload(u)]}))},t.prototype.getFeatureFlags=function(){var r=this.getPersistedProperty(Y1.FeatureFlags),n=this.getPersistedProperty(Y1.OverrideFeatureFlags);if(!n)return r;r=r||{};for(var i in n)n[i]?r[i]=n[i]:delete r[i];return r},t.prototype.getFeatureFlagsAndPayloads=function(){var r=this.getFeatureFlags(),n=this.getFeatureFlagPayloads();return{flags:r,payloads:n}},t.prototype.isFeatureEnabled=function(r){var n=this.getFeatureFlag(r);if(n!==void 0)return!!n},t.prototype.reloadFeatureFlags=function(r){this.decideAsync().then(function(n){r?.(void 0,n?.featureFlags)}).catch(function(n){r?.(n,void 0),r||console.log("[PostHog] Error reloading feature flags",n)})},t.prototype.reloadFeatureFlagsAsync=function(r){var n;return r===void 0&&(r=!0),B2(this,void 0,void 0,function(){return R2(this,function(i){switch(i.label){case 0:return[4,this.decideAsync(r)];case 1:return[2,(n=i.sent())===null||n===void 0?void 0:n.featureFlags]}})})},t.prototype.onFeatureFlags=function(r){var n=this;return this.on("featureflags",function(){return B2(n,void 0,void 0,function(){var i;return R2(this,function(a){return i=this.getFeatureFlags(),i&&r(i),[2]})})})},t.prototype.onFeatureFlag=function(r,n){var i=this;return this.on("featureflags",function(){return B2(i,void 0,void 0,function(){var a;return R2(this,function(u){return a=this.getFeatureFlag(r),a!==void 0&&n(a),[2]})})})},t.prototype.overrideFeatureFlag=function(r){return r===null?this.setPersistedProperty(Y1.OverrideFeatureFlags,null):this.setPersistedProperty(Y1.OverrideFeatureFlags,r)},t})(mQl);var lGP=function(){function e(){this._memoryStorage={}}return e.prototype.getProperty=function(t){return this._memoryStorage[t]},e.prototype.setProperty=function(t,r){this._memoryStorage[t]=r!==null?r:void 0},e}(),OQl=function(e,t){return B2(void 0,void 0,void 0,function(){var r;return R2(this,function(n){switch(n.label){case 0:return[4,vQl.default.request({url:e,headers:t.headers,method:t.method.toLowerCase(),data:t.body,signal:t.signal,validateStatus:function(){return!0}})];case 1:return r=n.sent(),[2,{status:r.status,text:function(){return B2(void 0,void 0,void 0,function(){return R2(this,function(i){return[2,r.data]})})},json:function(){return B2(void 0,void 0,void 0,function(){return R2(this,function(i){return[2,r.data]})})}}]}})})},fGP=1152921504606847e3,dQl=function(e){mAn(t,e);function t(r){var n=e.call(this)||this;return Error.captureStackTrace(n,n.constructor),n.name="ClientError",n.message=r,Object.setPrototypeOf(n,t.prototype),n}return t}(Error),vQ=function(e){mAn(t,e);function t(r){var n=e.call(this,r)||this;return n.name=n.constructor.name,Error.captureStackTrace(n,n.constructor),Object.setPrototypeOf(n,t.prototype),n}return t}(Error),dGP=function(){function e(t){var r=t.pollingInterval,n=t.personalApiKey,i=t.projectApiKey,a=t.timeout,u=t.host,f=tGP(t,["pollingInterval","personalApiKey","projectApiKey","timeout","host"]);this.debugMode=!1,this.pollingInterval=r,this.personalApiKey=n,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=a,this.projectApiKey=i,this.host=u,this.poller=void 0,this.fetch=f.fetch||OQl,this.loadFeatureFlags()}return e.prototype.debug=function(t){t===void 0&&(t=!0),this.debugMode=t},e.prototype.getFeatureFlag=function(t,r,n,i,a){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),B2(this,void 0,void 0,function(){var u,f,d,c,o;return R2(this,function(l){switch(l.label){case 0:return[4,this.loadFeatureFlags()];case 1:if(l.sent(),u=void 0,f=void 0,!this.loadedSuccessfullyOnce)return[2,u];for(d=0,c=this.featureFlags;d<c.length;d++)if(o=c[d],t===o.key){f=o;break}if(f!==void 0)try{u=this.computeFlagLocally(f,r,n,i,a),this.debugMode&&console.debug("Successfully computed flag locally: ".concat(t," -> ").concat(u))}catch(g){g instanceof vQ?this.debugMode&&console.debug("InconclusiveMatchError when computing flag locally: ".concat(t,": ").concat(g)):g instanceof Error&&console.error("Error computing flag locally: ".concat(t,": ").concat(g))}return[2,u]}})})},e.prototype.computeFeatureFlagPayloadLocally=function(t,r){var n,i,a,u,f,d,c,o;return B2(this,void 0,void 0,function(){var l;return R2(this,function(g){switch(g.label){case 0:return[4,this.loadFeatureFlags()];case 1:return g.sent(),l=void 0,this.loadedSuccessfullyOnce?(typeof r=="boolean"?l=(u=(a=(i=(n=this.featureFlagsByKey)===null||n===void 0?void 0:n[t])===null||i===void 0?void 0:i.filters)===null||a===void 0?void 0:a.payloads)===null||u===void 0?void 0:u[r.toString()]:typeof r=="string"&&(l=(o=(c=(d=(f=this.featureFlagsByKey)===null||f===void 0?void 0:f[t])===null||d===void 0?void 0:d.filters)===null||c===void 0?void 0:c.payloads)===null||o===void 0?void 0:o[r]),l===void 0?[2,null]:[2,l]):[2,void 0]}})})},e.prototype.getAllFlagsAndPayloads=function(t,r,n,i){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),B2(this,void 0,void 0,function(){var a,u,f,d=this;return R2(this,function(c){switch(c.label){case 0:return[4,this.loadFeatureFlags()];case 1:return c.sent(),a={},u={},f=this.featureFlags.length==0,this.featureFlags.map(function(o){return B2(d,void 0,void 0,function(){var l,g,O;return R2(this,function(j){switch(j.label){case 0:return j.trys.push([0,2,,3]),l=this.computeFlagLocally(o,t,r,n,i),a[o.key]=l,[4,this.computeFeatureFlagPayloadLocally(o.key,l)];case 1:return g=j.sent(),g&&(u[o.key]=g),[3,3];case 2:return O=j.sent(),O instanceof vQ||O instanceof Error&&console.error("Error computing flag locally: ".concat(o.key,": ").concat(O)),f=!0,[3,3];case 3:return[2]}})})}),[2,{response:a,payloads:u,fallbackToDecide:f}]}})})},e.prototype.computeFlagLocally=function(t,r,n,i,a){if(n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),t.ensure_experience_continuity)throw new vQ("Flag has experience continuity enabled");if(!t.active)return!1;var u=t.filters||{},f=u.aggregation_group_type_index;if(f!=null){var d=this.groupTypeMapping[String(f)];if(!d)throw console.warn("[FEATURE FLAGS] Unknown group type index ".concat(f," for feature flag ").concat(t.key)),new vQ("Flag has unknown group type index");if(!(d in n))return console.warn("[FEATURE FLAGS] Can't compute group feature flag: ".concat(t.key," without group names passed in")),!1;var c=a[d];return this.matchFeatureFlagProperties(t,n[d],c)}else return this.matchFeatureFlagProperties(t,r,i)},e.prototype.matchFeatureFlagProperties=function(t,r,n){for(var i,a=t.filters||{},u=a.groups||[],f=!1,d=void 0,c=bQl([],u,!0).sort(function(T,C){var I=!!T.variant,N=!!C.variant;return I&&N?0:I?-1:N?1:0}),o=function(T){try{if(l.isConditionMatch(t,r,T,n)){var C=T.variant,I=((i=a.multivariate)===null||i===void 0?void 0:i.variants)||[];return C&&I.some(function(N){return N.key===C})?d=C:d=l.getMatchingVariant(t,r)||!0,"break"}}catch(N){if(N instanceof vQ)f=!0;else throw N}},l=this,g=0,O=c;g<O.length;g++){var j=O[g],S=o(j);if(S==="break")break}if(d!==void 0)return d;if(f)throw new vQ("Can't determine if feature flag is enabled or not with given properties");return!1},e.prototype.isConditionMatch=function(t,r,n,i){var a=n.rollout_percentage;if((n.properties||[]).length>0){for(var u=0,f=n.properties;u<f.length;u++){var d=f[u],c=d.type,o=!1;if(c==="cohort"?o=jQl(d,i,this.cohorts):o=PQl(d,i),!o)return!1}if(a==null)return!0}return!(a!=null&&pQl(t.key,r)>a/100)},e.prototype.getMatchingVariant=function(t,r){var n=pQl(t.key,r,"variant"),i=this.variantLookupTable(t).find(function(a){return n>=a.valueMin&&n<a.valueMax});if(i)return i.key},e.prototype.variantLookupTable=function(t){var r,n=[],i=0,a=0,u=t.filters||{},f=((r=u.multivariate)===null||r===void 0?void 0:r.variants)||[];return f.forEach(function(d){a=i+d.rollout_percentage/100,n.push({valueMin:i,valueMax:a,key:d.key}),i=a}),n},e.prototype.loadFeatureFlags=function(t){return t===void 0&&(t=!1),B2(this,void 0,void 0,function(){return R2(this,function(r){switch(r.label){case 0:return!this.loadedSuccessfullyOnce||t?[4,this._loadFeatureFlags()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},e.prototype._loadFeatureFlags=function(){return B2(this,void 0,void 0,function(){var t,r,n,i=this;return R2(this,function(a){switch(a.label){case 0:this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(function(){return i._loadFeatureFlags()},this.pollingInterval),a.label=1;case 1:return a.trys.push([1,4,,5]),[4,this._requestFeatureFlagDefinitions()];case 2:if(t=a.sent(),t&&t.status===401)throw new dQl("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");return t&&t.status!==200?[2]:[4,t.json()];case 3:return r=a.sent(),"flags"in r||console.error("Invalid response when getting feature flags: ".concat(JSON.stringify(r))),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce(function(u,f){return u[f.key]=f,u},{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0,[3,5];case 4:if(n=a.sent(),n instanceof dQl)throw n;return[3,5];case 5:return[2]}})})},e.prototype._requestFeatureFlagDefinitions=function(){return B2(this,void 0,void 0,function(){var t,r,n,i,a;return R2(this,function(u){switch(u.label){case 0:t="".concat(this.host,"/api/feature_flag/local_evaluation?token=").concat(this.projectApiKey,"&send_cohorts"),r={method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.personalApiKey),"user-agent":"posthog-node/".concat(jko)}},n=null,this.timeout&&typeof this.timeout=="number"&&(i=new AbortController,n=gQl(function(){i.abort()},this.timeout),r.signal=i.signal),u.label=1;case 1:return u.trys.push([1,3,4,5]),[4,this.fetch(t,r)];case 2:return[2,u.sent()];case 3:throw a=u.sent(),a;case 4:return clearTimeout(n),[7];case 5:return[2]}})})},e.prototype.stopPoller=function(){clearTimeout(this.poller)},e}();function pQl(e,t,r){r===void 0&&(r="");var n=(0,yQl.createHash)();return n.update("".concat(e,".").concat(t).concat(r)),parseInt(n.digest("hex").slice(0,15),16)/fGP}function PQl(e,t){var r=e.key,n=e.value,i=e.operator||"exact";if(r in t){if(i==="is_not_set")throw new vQ("Operator is_not_set is not supported")}else throw new vQ("Property ".concat(r," not found in propertyValues"));var a=t[r];switch(i){case"exact":return Array.isArray(n)?n.indexOf(a)!==-1:n===a;case"is_not":return Array.isArray(n)?n.indexOf(a)===-1:n!==a;case"is_set":return r in t;case"icontains":return String(a).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(a).toLowerCase().includes(String(n).toLowerCase());case"regex":return _Ql(String(n))&&String(a).match(String(n))!==null;case"not_regex":return _Ql(String(n))&&String(a).match(String(n))===null;case"gt":return typeof a==typeof n&&a>n;case"gte":return typeof a==typeof n&&a>=n;case"lt":return typeof a==typeof n&&a<n;case"lte":return typeof a==typeof n&&a<=n;case"is_date_after":case"is_date_before":var u=hQl(n),f=hQl(a);return i==="is_date_before"?f<u:f>u;default:return console.error("Unknown operator: ".concat(i)),!1}}function jQl(e,t,r){var n=String(e.value);if(!(n in r))throw new vQ("can't match cohort without a given cohort property value");var i=r[n];return wQl(i,t,r)}function wQl(e,t,r){if(!e)return!0;var n=e.type,i=e.values;if(!i||i.length===0)return!0;var a=!1;if("values"in i[0]){for(var u=0,f=i;u<f.length;u++){var d=f[u];try{var c=wQl(d,t,r);if(n==="AND"){if(!c)return!1}else if(c)return!0}catch(O){if(O instanceof vQ)console.debug("Failed to compute property ".concat(d," locally: ").concat(O)),a=!0;else throw O}}if(a)throw new vQ("Can't match cohort without a given cohort property value");return n==="AND"}else{for(var o=0,l=i;o<l.length;o++){var d=l[o];try{var c=void 0;d.type==="cohort"?c=jQl(d,t,r):c=PQl(d,t);var g=d.negation||!1;if(n==="AND"){if(!c&&!g||c&&g)return!1}else if(c&&!g||!c&&g)return!0}catch(j){if(j instanceof vQ)console.debug("Failed to compute property ".concat(d," locally: ").concat(j)),a=!0;else throw j}}if(a)throw new vQ("can't match cohort without a given cohort property value");return n==="AND"}}function _Ql(e){try{return new RegExp(e),!0}catch{return!1}}function hQl(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){var t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new vQ("".concat(e," is in an invalid date format"))}else throw new vQ("The date provided ".concat(e," must be a string, number, or date object"))}var pGP=30*1e3,_GP=50*1e3,qsa=function(e){mAn(t,e);function t(r,n){n===void 0&&(n={});var i=this,a;return n.captureMode=n?.captureMode||"json",i=e.call(this,r,n)||this,i._memoryStorage=new lGP,i.options=n,n.personalApiKey&&(i.featureFlagsPoller=new dGP({pollingInterval:typeof n.featureFlagsPollingInterval=="number"?n.featureFlagsPollingInterval:pGP,personalApiKey:n.personalApiKey,projectApiKey:r,timeout:(a=n.requestTimeout)!==null&&a!==void 0?a:1e4,host:i.host,fetch:n.fetch})),i.distinctIdHasSentFlagCalls={},i.maxCacheSize=n.maxCacheSize||_GP,i}return t.prototype.getPersistedProperty=function(r){return this._memoryStorage.getProperty(r)},t.prototype.setPersistedProperty=function(r,n){return this._memoryStorage.setProperty(r,n)},t.prototype.fetch=function(r,n){return this.options.fetch?this.options.fetch(r,n):OQl(r,n)},t.prototype.getLibraryId=function(){return"posthog-node"},t.prototype.getLibraryVersion=function(){return jko},t.prototype.getCustomUserAgent=function(){return"posthog-node/".concat(jko)},t.prototype.enable=function(){return e.prototype.optIn.call(this)},t.prototype.disable=function(){return e.prototype.optOut.call(this)},t.prototype.debug=function(r){var n;r===void 0&&(r=!0),e.prototype.debug.call(this,r),(n=this.featureFlagsPoller)===null||n===void 0||n.debug(r)},t.prototype.capture=function(r){var n=this,i=r.distinctId,a=r.event,u=r.properties,f=r.groups,d=r.sendFeatureFlags,c=r.timestamp,o=r.disableGeoip,l=function(g){e.prototype.captureStateless.call(n,i,a,g,{timestamp:c,disableGeoip:o})};d?e.prototype.getFeatureFlagsStateless.call(this,i,f,void 0,void 0,o).then(function(g){var O={};if(g)for(var j=0,S=Object.entries(g);j<S.length;j++){var T=S[j],C=T[0],I=T[1];I!==!1&&(O["$feature/".concat(C)]=I)}var N=Object.keys(g||{}).filter(function(U){return g?.[U]!==!1}),A=Bg({$active_feature_flags:N||void 0},O);l(Bg(Bg(Bg({},u),{$groups:f}),A))}):l(Bg(Bg({},u),{$groups:f}))},t.prototype.identify=function(r){var n=r.distinctId,i=r.properties,a=r.disableGeoip,u=i?.$set||i;e.prototype.identifyStateless.call(this,n,{$set:u},{disableGeoip:a})},t.prototype.alias=function(r){e.prototype.aliasStateless.call(this,r.alias,r.distinctId,void 0,{disableGeoip:r.disableGeoip})},t.prototype.getFeatureFlag=function(r,n,i){var a;return B2(this,void 0,void 0,function(){var u,f,d,c,o,l,g,O,j,S,T,C;return R2(this,function(I){switch(I.label){case 0:return u=i||{},f=u.groups,d=u.personProperties,c=u.groupProperties,o=u.disableGeoip,l=i||{},g=l.onlyEvaluateLocally,O=l.sendFeatureFlagEvents,g==null&&(g=!1),O==null&&(O=!0),[4,(a=this.featureFlagsPoller)===null||a===void 0?void 0:a.getFeatureFlag(r,n,f,d,c)];case 1:return j=I.sent(),S=j!==void 0,!S&&!g?[4,e.prototype.getFeatureFlagStateless.call(this,r,n,f,d,c,o)]:[3,3];case 2:j=I.sent(),I.label=3;case 3:return T="".concat(r,"_").concat(j),O&&(!(n in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[n].includes(T))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[n])?this.distinctIdHasSentFlagCalls[n].push(T):this.distinctIdHasSentFlagCalls[n]=[T],this.capture({distinctId:n,event:"$feature_flag_called",properties:(C={$feature_flag:r,$feature_flag_response:j,locally_evaluated:S},C["$feature/".concat(r)]=j,C),groups:f,disableGeoip:o})),[2,j]}})})},t.prototype.getFeatureFlagPayload=function(r,n,i,a){var u;return B2(this,void 0,void 0,function(){var f,d,c,o,l,g,O,j,S;return R2(this,function(T){switch(T.label){case 0:return f=a||{},d=f.groups,c=f.personProperties,o=f.groupProperties,l=f.disableGeoip,g=a||{},O=g.onlyEvaluateLocally,g.sendFeatureFlagEvents,j=void 0,i?[3,2]:[4,this.getFeatureFlag(r,n,Bg(Bg({},a),{onlyEvaluateLocally:!0}))];case 1:i=T.sent(),T.label=2;case 2:return i?[4,(u=this.featureFlagsPoller)===null||u===void 0?void 0:u.computeFeatureFlagPayloadLocally(r,i)]:[3,4];case 3:j=T.sent(),T.label=4;case 4:return O==null&&(O=!1),O==null&&(O=!1),S=j!==void 0,!S&&!O?[4,e.prototype.getFeatureFlagPayloadStateless.call(this,r,n,d,c,o,l)]:[3,6];case 5:j=T.sent(),T.label=6;case 6:try{return[2,JSON.parse(j)]}catch{return[2,j]}return[2]}})})},t.prototype.isFeatureEnabled=function(r,n,i){return B2(this,void 0,void 0,function(){var a;return R2(this,function(u){switch(u.label){case 0:return[4,this.getFeatureFlag(r,n,i)];case 1:return a=u.sent(),a===void 0?[2,void 0]:[2,!!a||!1]}})})},t.prototype.getAllFlags=function(r,n){return B2(this,void 0,void 0,function(){var i;return R2(this,function(a){switch(a.label){case 0:return[4,this.getAllFlagsAndPayloads(r,n)];case 1:return i=a.sent(),[2,i.featureFlags]}})})},t.prototype.getAllFlagsAndPayloads=function(r,n){var i;return B2(this,void 0,void 0,function(){var a,u,f,d,c,o,l,g,O,j,S;return R2(this,function(T){switch(T.label){case 0:return a=n||{},u=a.groups,f=a.personProperties,d=a.groupProperties,c=a.disableGeoip,o=(n||{}).onlyEvaluateLocally,o==null&&(o=!1),[4,(i=this.featureFlagsPoller)===null||i===void 0?void 0:i.getAllFlagsAndPayloads(r,u,f,d)];case 1:return l=T.sent(),g={},O={},j=!0,l&&(g=l.response,O=l.payloads,j=l.fallbackToDecide),j&&!o?[4,e.prototype.getFeatureFlagsAndPayloadsStateless.call(this,r,u,f,d,c)]:[3,3];case 2:S=T.sent(),g=Bg(Bg({},g),S.flags||{}),O=Bg(Bg({},O),S.payloads||{}),T.label=3;case 3:return[2,{featureFlags:g,featureFlagPayloads:O}]}})})},t.prototype.groupIdentify=function(r){var n=r.groupType,i=r.groupKey,a=r.properties,u=r.distinctId,f=r.disableGeoip;e.prototype.groupIdentifyStateless.call(this,n,i,a,{disableGeoip:f},u)},t.prototype.reloadFeatureFlags=function(){var r;return B2(this,void 0,void 0,function(){return R2(this,function(n){switch(n.label){case 0:return[4,(r=this.featureFlagsPoller)===null||r===void 0?void 0:r.loadFeatureFlags(!0)];case 1:return n.sent(),[2]}})})},t.prototype.shutdown=function(){this.shutdownAsync()},t.prototype.shutdownAsync=function(){var r;return B2(this,void 0,void 0,function(){return R2(this,function(n){return(r=this.featureFlagsPoller)===null||r===void 0||r.stopPoller(),[2,e.prototype.shutdownAsync.call(this)]})})},t}(mQl);var Asa=class{posthog;constructor({posthogApiKey:t}){this.posthog=new qsa(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.45.0-rc12",usingAccessToken:!0}})}flush(){this.posthog.flush()}};var Lli=class{async sendEvent(){}async identify(){}async flush(){}};var OAn=require("fs/promises"),MQl=require("os"),xQl=require("path");var DQl=iu(require("crypto")),Nsa=new Uint8Array(256),Csa=Nsa.length;function Dko(){return Csa>Nsa.length-16&&(DQl.default.randomFillSync(Nsa),Csa=0),Nsa.slice(Csa,Csa+=16)}var yW=[];for(let e=0;e<256;++e)yW.push((e+256).toString(16).slice(1));function SQl(e,t=0){return yW[e[t+0]]+yW[e[t+1]]+yW[e[t+2]]+yW[e[t+3]]+"-"+yW[e[t+4]]+yW[e[t+5]]+"-"+yW[e[t+6]]+yW[e[t+7]]+"-"+yW[e[t+8]]+yW[e[t+9]]+"-"+yW[e[t+10]]+yW[e[t+11]]+yW[e[t+12]]+yW[e[t+13]]+yW[e[t+14]]+yW[e[t+15]]}var EQl=iu(require("crypto")),Sko={randomUUID:EQl.default.randomUUID};function hGP(e,t,r){if(Sko.randomUUID&&!t&&!e)return Sko.randomUUID();e=e||{};let n=e.random||(e.rng||Dko)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return SQl(n)}var rNr=hGP;var yGP="id",vGP=".fern",Uli=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new qsa(r),this.userId=t==null?void 0:NGo(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.45.0-rc12",...t,...t.properties}})}flush(){this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=_f(O_.of((0,MQl.homedir)()),Ms.of(vGP),Ms.of(yGP));await Bh(t)||(await(0,OAn.mkdir)((0,xQl.dirname)(t),{recursive:!0}),await(0,OAn.writeFile)(t,rNr())),this.persistedDistinctId=(await(0,OAn.readFile)(t)).toString()}return this.persistedDistinctId}};var Eko;async function PAn(){return Eko==null&&(Eko=await bGP()),Eko}async function bGP(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Lli;let r=await ura();return r!=null?new Uli({token:r,posthogApiKey:e}):await ora()!=null?new Asa({posthogApiKey:e}):new Uli({token:void 0,posthogApiKey:e})}catch{return new Lli}}function Vli(e,t){return function(){return e.apply(t,arguments)}}var{toString:gGP}=Object.prototype,{getPrototypeOf:Tko}=Object,zsa=(e=>t=>{let r=gGP.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),zAt=e=>(e=e.toLowerCase(),t=>zsa(t)===e),Bsa=e=>t=>typeof t===e,{isArray:jAn}=Array,Wli=Bsa("undefined");function mGP(e){return e!==null&&!Wli(e)&&e.constructor!==null&&!Wli(e.constructor)&&fje(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var AQl=zAt("ArrayBuffer");function OGP(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&AQl(e.buffer),t}var PGP=Bsa("string"),fje=Bsa("function"),CQl=Bsa("number"),Rsa=e=>e!==null&&typeof e=="object",jGP=e=>e===!0||e===!1,Isa=e=>{if(zsa(e)!=="object")return!1;let t=Tko(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},wGP=zAt("Date"),DGP=zAt("File"),SGP=zAt("Blob"),EGP=zAt("FileList"),MGP=e=>Rsa(e)&&fje(e.pipe),xGP=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||fje(e.append)&&((t=zsa(e))==="formdata"||t==="object"&&fje(e.toString)&&e.toString()==="[object FormData]"))},TGP=zAt("URLSearchParams"),[qGP,AGP,CGP,NGP]=["ReadableStream","Request","Response","Headers"].map(zAt),IGP=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Hli(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),jAn(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,f;for(n=0;n<u;n++)f=a[n],t.call(null,e[f],f,e)}}function NQl(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var iZr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,IQl=e=>!Wli(e)&&e!==iZr;function xko(){let{caseless:e}=IQl(this)&&this||{},t={},r=(n,i)=>{let a=e&&NQl(t,i)||i;Isa(t[a])&&Isa(n)?t[a]=xko(t[a],n):Isa(n)?t[a]=xko({},n):jAn(n)?t[a]=n.slice():t[a]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Hli(arguments[n],r);return t}var zGP=(e,t,r,{allOwnKeys:n}={})=>(Hli(t,(i,a)=>{r&&fje(i)?e[a]=Vli(i,r):e[a]=i},{allOwnKeys:n}),e),BGP=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),RGP=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},FGP=(e,t,r,n)=>{let i,a,u,f={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)u=i[a],(!n||n(u,e,t))&&!f[u]&&(t[u]=e[u],f[u]=!0);e=r!==!1&&Tko(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},LGP=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},UGP=e=>{if(!e)return null;if(jAn(e))return e;let t=e.length;if(!CQl(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},VGP=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Tko(Uint8Array)),WGP=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},HGP=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},JGP=zAt("HTMLFormElement"),GGP=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),TQl=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),KGP=zAt("RegExp"),zQl=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};Hli(r,(i,a)=>{let u;(u=t(i,a,e))!==!1&&(n[a]=u||i)}),Object.defineProperties(e,n)},$GP=e=>{zQl(e,(t,r)=>{if(fje(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(fje(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},YGP=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return jAn(e)?n(e):n(String(e).split(t)),r},XGP=()=>{},QGP=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,Mko="abcdefghijklmnopqrstuvwxyz",qQl="0123456789",BQl={DIGIT:qQl,ALPHA:Mko,ALPHA_DIGIT:Mko+Mko.toUpperCase()+qQl},ZGP=(e=16,t=BQl.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function kGP(e){return!!(e&&fje(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var eKP=e=>{let t=new Array(10),r=(n,i)=>{if(Rsa(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;let a=jAn(n)?[]:{};return Hli(n,(u,f)=>{let d=r(u,i+1);!Wli(d)&&(a[f]=d)}),t[i]=void 0,a}}return n};return r(e,0)},tKP=zAt("AsyncFunction"),rKP=e=>e&&(Rsa(e)||fje(e))&&fje(e.then)&&fje(e.catch),RQl=((e,t)=>e?setImmediate:t?((r,n)=>(iZr.addEventListener("message",({source:i,data:a})=>{i===iZr&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),iZr.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",fje(iZr.postMessage)),nKP=typeof queueMicrotask<"u"?queueMicrotask.bind(iZr):typeof process<"u"&&process.nextTick||RQl,Hl={isArray:jAn,isArrayBuffer:AQl,isBuffer:mGP,isFormData:xGP,isArrayBufferView:OGP,isString:PGP,isNumber:CQl,isBoolean:jGP,isObject:Rsa,isPlainObject:Isa,isReadableStream:qGP,isRequest:AGP,isResponse:CGP,isHeaders:NGP,isUndefined:Wli,isDate:wGP,isFile:DGP,isBlob:SGP,isRegExp:KGP,isFunction:fje,isStream:MGP,isURLSearchParams:TGP,isTypedArray:VGP,isFileList:EGP,forEach:Hli,merge:xko,extend:zGP,trim:IGP,stripBOM:BGP,inherits:RGP,toFlatObject:FGP,kindOf:zsa,kindOfTest:zAt,endsWith:LGP,toArray:UGP,forEachEntry:WGP,matchAll:HGP,isHTMLForm:JGP,hasOwnProperty:TQl,hasOwnProp:TQl,reduceDescriptors:zQl,freezeMethods:$GP,toObjectSet:YGP,toCamelCase:GGP,noop:XGP,toFiniteNumber:QGP,findKey:NQl,global:iZr,isContextDefined:IQl,ALPHABET:BQl,generateString:ZGP,isSpecCompliantForm:kGP,toJSONObject:eKP,isAsyncFn:tKP,isThenable:rKP,setImmediate:RQl,asap:nKP};function wAn(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Hl.inherits(wAn,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:Hl.toJSONObject(this.config),code:this.code,status:this.status}}});var FQl=wAn.prototype,LQl={};["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=>{LQl[e]={value:e}});Object.defineProperties(wAn,LQl);Object.defineProperty(FQl,"isAxiosError",{value:!0});wAn.from=(e,t,r,n,i,a)=>{let u=Object.create(FQl);return Hl.toFlatObject(e,u,function(d){return d!==Error.prototype},f=>f!=="isAxiosError"),wAn.call(u,e.message,t,r,n,i),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var xy=wAn;var UQl=iu(wXr(),1),Fsa=UQl.default;function qko(e){return Hl.isPlainObject(e)||Hl.isArray(e)}function WQl(e){return Hl.endsWith(e,"[]")?e.slice(0,-2):e}function VQl(e,t,r){return e?e.concat(t).map(function(i,a){return i=WQl(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function iKP(e){return Hl.isArray(e)&&!e.some(qko)}var aKP=Hl.toFlatObject(Hl,{},null,function(t){return/^is[A-Z]/.test(t)});function oKP(e,t,r){if(!Hl.isObject(e))throw new TypeError("target must be an object");t=t||new(Fsa||FormData),r=Hl.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(S,T){return!Hl.isUndefined(T[S])});let n=r.metaTokens,i=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&Hl.isSpecCompliantForm(t);if(!Hl.isFunction(i))throw new TypeError("visitor must be a function");function c(j){if(j===null)return"";if(Hl.isDate(j))return j.toISOString();if(!d&&Hl.isBlob(j))throw new xy("Blob is not supported. Use a Buffer instead.");return Hl.isArrayBuffer(j)||Hl.isTypedArray(j)?d&&typeof Blob=="function"?new Blob([j]):Buffer.from(j):j}function o(j,S,T){let C=j;if(j&&!T&&typeof j=="object"){if(Hl.endsWith(S,"{}"))S=n?S:S.slice(0,-2),j=JSON.stringify(j);else if(Hl.isArray(j)&&iKP(j)||(Hl.isFileList(j)||Hl.endsWith(S,"[]"))&&(C=Hl.toArray(j)))return S=WQl(S),C.forEach(function(N,A){!(Hl.isUndefined(N)||N===null)&&t.append(u===!0?VQl([S],A,a):u===null?S:S+"[]",c(N))}),!1}return qko(j)?!0:(t.append(VQl(T,S,a),c(j)),!1)}let l=[],g=Object.assign(aKP,{defaultVisitor:o,convertValue:c,isVisitable:qko});function O(j,S){if(!Hl.isUndefined(j)){if(l.indexOf(j)!==-1)throw Error("Circular reference detected in "+S.join("."));l.push(j),Hl.forEach(j,function(C,I){(!(Hl.isUndefined(C)||C===null)&&i.call(t,C,Hl.isString(I)?I.trim():I,S,g))===!0&&O(C,S?S.concat(I):[I])}),l.pop()}}if(!Hl.isObject(e))throw new TypeError("data must be an object");return O(e),t}var nNr=oKP;function HQl(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function JQl(e,t){this._pairs=[],e&&nNr(e,this,t)}var GQl=JQl.prototype;GQl.append=function(t,r){this._pairs.push([t,r])};GQl.toString=function(t){let r=t?function(n){return t.call(this,n,HQl)}:HQl;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var KQl=JQl;function uKP(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function aZr(e,t,r){if(!t)return e;let n=r&&r.encode||uKP,i=r&&r.serialize,a;if(i?a=i(t,r):a=Hl.isURLSearchParams(t)?t.toString():new KQl(t,r).toString(n),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Ako=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Hl.forEach(this.handlers,function(n){n!==null&&t(n)})}},Cko=Ako;var DAn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var $Ql=iu(require("url"),1),YQl=$Ql.default.URLSearchParams;var XQl={isNode:!0,classes:{URLSearchParams:YQl,FormData:Fsa,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var zko={};td(zko,{hasBrowserEnv:()=>Iko,hasStandardBrowserEnv:()=>sKP,hasStandardBrowserWebWorkerEnv:()=>cKP,navigator:()=>Nko,origin:()=>lKP});var Iko=typeof window<"u"&&typeof document<"u",Nko=typeof navigator=="object"&&navigator||void 0,sKP=Iko&&(!Nko||["ReactNative","NativeScript","NS"].indexOf(Nko.product)<0),cKP=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",lKP=Iko&&window.location.href||"http://localhost";var wC={...zko,...XQl};function Bko(e,t){return nNr(e,new wC.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,a){return wC.isNode&&Hl.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function fKP(e){return Hl.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function dKP(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function pKP(e){function t(r,n,i,a){let u=r[a++];if(u==="__proto__")return!0;let f=Number.isFinite(+u),d=a>=r.length;return u=!u&&Hl.isArray(i)?i.length:u,d?(Hl.hasOwnProp(i,u)?i[u]=[i[u],n]:i[u]=n,!f):((!i[u]||!Hl.isObject(i[u]))&&(i[u]=[]),t(r,n,i[u],a)&&Hl.isArray(i[u])&&(i[u]=dKP(i[u])),!f)}if(Hl.isFormData(e)&&Hl.isFunction(e.entries)){let r={};return Hl.forEachEntry(e,(n,i)=>{t(fKP(n),i,r,0)}),r}return null}var Lsa=pKP;function _KP(e,t,r){if(Hl.isString(e))try{return(t||JSON.parse)(e),Hl.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var Rko={transitional:DAn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Hl.isObject(t);if(a&&Hl.isHTMLForm(t)&&(t=new FormData(t)),Hl.isFormData(t))return i?JSON.stringify(Lsa(t)):t;if(Hl.isArrayBuffer(t)||Hl.isBuffer(t)||Hl.isStream(t)||Hl.isFile(t)||Hl.isBlob(t)||Hl.isReadableStream(t))return t;if(Hl.isArrayBufferView(t))return t.buffer;if(Hl.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let f;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Bko(t,this.formSerializer).toString();if((f=Hl.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return nNr(f?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),_KP(t)):t}],transformResponse:[function(t){let r=this.transitional||Rko.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Hl.isResponse(t)||Hl.isReadableStream(t))return t;if(t&&Hl.isString(t)&&(n&&!this.responseType||i)){let u=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(f){if(u)throw f.name==="SyntaxError"?xy.from(f,xy.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:wC.classes.FormData,Blob:wC.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Hl.forEach(["delete","get","head","post","put","patch"],e=>{Rko.headers[e]={}});var SAn=Rko;var hKP=Hl.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"]),QQl=e=>{let t={},r,n,i;return e&&e.split(`
1762
1762
  `).forEach(function(u){i=u.indexOf(":"),r=u.substring(0,i).trim().toLowerCase(),n=u.substring(i+1).trim(),!(!r||t[r]&&hKP[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var ZQl=Symbol("internals");function Jli(e){return e&&String(e).trim().toLowerCase()}function Usa(e){return e===!1||e==null?e:Hl.isArray(e)?e.map(Usa):String(e)}function yKP(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var vKP=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Fko(e,t,r,n,i){if(Hl.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!Hl.isString(t)){if(Hl.isString(n))return t.indexOf(n)!==-1;if(Hl.isRegExp(n))return n.test(t)}}function bKP(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function gKP(e,t){let r=Hl.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,a,u){return this[n].call(this,t,i,a,u)},configurable:!0})})}var EAn=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(f,d,c){let o=Jli(d);if(!o)throw new Error("header name must be a non-empty string");let l=Hl.findKey(i,o);(!l||i[l]===void 0||c===!0||c===void 0&&i[l]!==!1)&&(i[l||d]=Usa(f))}let u=(f,d)=>Hl.forEach(f,(c,o)=>a(c,o,d));if(Hl.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(Hl.isString(t)&&(t=t.trim())&&!vKP(t))u(QQl(t),r);else if(Hl.isHeaders(t))for(let[f,d]of t.entries())a(d,f,n);else t!=null&&a(r,t,n);return this}get(t,r){if(t=Jli(t),t){let n=Hl.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return yKP(i);if(Hl.isFunction(r))return r.call(this,i,n);if(Hl.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Jli(t),t){let n=Hl.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Fko(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(u){if(u=Jli(u),u){let f=Hl.findKey(n,u);f&&(!r||Fko(n,n[f],f,r))&&(delete n[f],i=!0)}}return Hl.isArray(t)?t.forEach(a):a(t),i}clear(t){let r=Object.keys(this),n=r.length,i=!1;for(;n--;){let a=r[n];(!t||Fko(this,this[a],a,t,!0))&&(delete this[a],i=!0)}return i}normalize(t){let r=this,n={};return Hl.forEach(this,(i,a)=>{let u=Hl.findKey(n,a);if(u){r[u]=Usa(i),delete r[a];return}let f=t?bKP(a):String(a).trim();f!==a&&delete r[a],r[f]=Usa(i),n[f]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Hl.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&Hl.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
1763
1763
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){let n=(this[ZQl]=this[ZQl]={accessors:{}}).accessors,i=this.prototype;function a(u){let f=Jli(u);n[f]||(gKP(i,u),n[f]=!0)}return Hl.isArray(t)?t.forEach(a):a(t),this}};EAn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Hl.reduceDescriptors(EAn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Hl.freezeMethods(EAn);var T3=EAn;function Gli(e,t){let r=this||SAn,n=t||r,i=T3.from(n.headers),a=n.data;return Hl.forEach(e,function(f){a=f.call(r,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function Kli(e){return!!(e&&e.__CANCEL__)}function kQl(e,t,r){xy.call(this,e??"canceled",xy.ERR_CANCELED,t,r),this.name="CanceledError"}Hl.inherits(kQl,xy,{__CANCEL__:!0});var dje=kQl;function _Bt(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new xy("Request failed with status code "+r.status,[xy.ERR_BAD_REQUEST,xy.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Lko(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Uko(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function oZr(e,t){return e&&!Lko(t)?Uko(e,t):t}var vZl=iu(tZl(),1),bZl=iu(require("http"),1),gZl=iu(require("https"),1),mZl=iu(require("util"),1),OZl=iu(Wta(),1),Gwr=iu(require("zlib"),1);var uZr="1.7.7";function $li(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var DKP=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function Vko(e,t,r){let n=r&&r.Blob||wC.classes.Blob,i=$li(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=DKP.exec(e);if(!a)throw new xy("Invalid URL",xy.ERR_INVALID_URL);let u=a[1],f=a[2],d=a[3],c=Buffer.from(decodeURIComponent(d),f?"base64":"utf8");if(t){if(!n)throw new xy("Blob is not supported",xy.ERR_NOT_SUPPORT);return new n([c],{type:u})}return c}throw new xy("Unsupported protocol "+i,xy.ERR_NOT_SUPPORT)}var sZr=iu(require("stream"),1);var rZl=iu(require("stream"),1);var Wko=Symbol("internals"),Hko=class extends rZl.default.Transform{constructor(t){t=Hl.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!Hl.isUndefined(i[n])),super({readableHighWaterMark:t.chunkSize});let r=this[Wko]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",n=>{n==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[Wko];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[Wko],a=i.maxRate,u=this.readableHighWaterMark,f=i.timeWindow,d=1e3/f,c=a/d,o=i.minChunkSize!==!1?Math.max(i.minChunkSize,c*.01):0,l=(O,j)=>{let S=Buffer.byteLength(O);i.bytesSeen+=S,i.bytes+=S,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(O)?process.nextTick(j):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(j)}},g=(O,j)=>{let S=Buffer.byteLength(O),T=null,C=u,I,N=0;if(a){let A=Date.now();(!i.ts||(N=A-i.ts)>=f)&&(i.ts=A,I=c-i.bytes,i.bytes=I<0?-I:0,N=0),I=c-i.bytes}if(a){if(I<=0)return setTimeout(()=>{j(null,O)},f-N);I<C&&(C=I)}C&&S>C&&S-C>o&&(T=O.subarray(C),O=O.subarray(0,C)),l(O,T?()=>{process.nextTick(j,null,T)}:j)};g(t,function O(j,S){if(j)return n(j);S?g(S,O):n(null)})}},Jko=Hko;var PZl=require("events");var iZl=require("util"),aZl=require("stream");var{asyncIterator:nZl}=Symbol,SKP=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[nZl]?yield*e[nZl]():yield e},Vsa=SKP;var EKP=Hl.ALPHABET.ALPHA_DIGIT+"-_",Yli=new iZl.TextEncoder,iNr=`\r
1764
1764
  `,MKP=Yli.encode(iNr),xKP=2,Gko=class{constructor(t,r){let{escapeName:n}=this.constructor,i=Hl.isString(r),a=`Content-Disposition: form-data; name="${n(t)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${iNr}`;i?r=Yli.encode(String(r).replace(/\r?\n|\r\n?/g,iNr)):a+=`Content-Type: ${r.type||"application/octet-stream"}${iNr}`,this.headers=Yli.encode(a+iNr),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+xKP,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Hl.isTypedArray(t)?yield t:yield*Vsa(t),yield MKP}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},TKP=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+Hl.generateString(i,EKP)}=r||{};if(!Hl.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=Yli.encode("--"+a+iNr),f=Yli.encode("--"+a+"--"+iNr+iNr),d=f.byteLength,c=Array.from(e.entries()).map(([l,g])=>{let O=new Gko(l,g);return d+=O.size,O});d+=u.byteLength*c.length,d=Hl.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),aZl.Readable.from(async function*(){for(let l of c)yield u,yield*l.encode();yield f}())},oZl=TKP;var uZl=iu(require("stream"),1),Kko=class extends uZl.default.Transform{__transform(t,r,n){this.push(t),n()}_transform(t,r,n){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let i=Buffer.alloc(2);i[0]=120,i[1]=156,this.push(i,r)}this.__transform(t,r,n)}},sZl=Kko;var qKP=(e,t)=>Hl.isAsyncFn(e)?function(...r){let n=r.pop();e.apply(this,r).then(i=>{try{t?n(null,...t(i)):n(null,i)}catch(a){n(a)}},n)}:e,cZl=qKP;function AKP(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,a=0,u;return t=t!==void 0?t:1e3,function(d){let c=Date.now(),o=n[a];u||(u=c),r[i]=d,n[i]=c;let l=a,g=0;for(;l!==i;)g+=r[l++],l=l%e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-u<t)return;let O=o&&c-o;return O?Math.round(g*1e3/O):void 0}}var lZl=AKP;function CKP(e,t){let r=0,n=1e3/t,i,a,u=(c,o=Date.now())=>{r=o,i=null,a&&(clearTimeout(a),a=null),e.apply(null,c)};return[(...c)=>{let o=Date.now(),l=o-r;l>=n?u(c,o):(i=c,a||(a=setTimeout(()=>{a=null,u(i)},n-l)))},()=>i&&u(i)]}var fZl=CKP;var Jwr=(e,t,r=3)=>{let n=0,i=lZl(50,250);return fZl(a=>{let u=a.loaded,f=a.lengthComputable?a.total:void 0,d=u-n,c=i(d),o=u<=f;n=u;let l={loaded:u,total:f,progress:f?u/f:void 0,bytes:d,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)},xAn=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},TAn=e=>(...t)=>Hl.asap(()=>e(...t));var dZl={flush:Gwr.default.constants.Z_SYNC_FLUSH,finishFlush:Gwr.default.constants.Z_SYNC_FLUSH},NKP={flush:Gwr.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:Gwr.default.constants.BROTLI_OPERATION_FLUSH},pZl=Hl.isFunction(Gwr.default.createBrotliDecompress),{http:IKP,https:zKP}=OZl.default,BKP=/https:?/,_Zl=wC.protocols.map(e=>e+":"),hZl=(e,[t,r])=>(e.on("end",r).on("error",r),t);function RKP(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function jZl(e,t,r){let n=t;if(!n&&n!==!1){let i=(0,vZl.getProxyForUrl)(r);i&&(n=new URL(i))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){(n.auth.username||n.auth.password)&&(n.auth=(n.auth.username||"")+":"+(n.auth.password||""));let a=Buffer.from(n.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let i=n.hostname||n.host;e.hostname=i,e.host=i,e.port=n.port,e.path=r,n.protocol&&(e.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}e.beforeRedirects.proxy=function(a){jZl(a,t,a.href)}}var FKP=typeof process<"u"&&Hl.kindOf(process)==="process",LKP=e=>new Promise((t,r)=>{let n,i,a=(d,c)=>{i||(i=!0,n&&n(d,c))},u=d=>{a(d),t(d)},f=d=>{a(d,!0),r(d)};e(u,f,d=>n=d).catch(f)}),UKP=({address:e,family:t})=>{if(!Hl.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},yZl=(e,t)=>UKP(Hl.isObject(e)?e:{address:e,family:t}),wZl=FKP&&function(t){return LKP(async function(n,i,a){let{data:u,lookup:f,family:d}=t,{responseType:c,responseEncoding:o}=t,l=t.method.toUpperCase(),g,O=!1,j;if(f){let ur=cZl(f,jr=>Hl.isArray(jr)?jr:[jr]);f=(jr,Vr,Nt)=>{ur(jr,Vr,(lr,Hr,Kt)=>{if(lr)return Nt(lr);let wn=Hl.isArray(Hr)?Hr.map(xn=>yZl(xn)):[yZl(Hr,Kt)];Vr.all?Nt(lr,wn):Nt(lr,wn[0].address,wn[0].family)})}}let S=new PZl.EventEmitter,T=()=>{t.cancelToken&&t.cancelToken.unsubscribe(C),t.signal&&t.signal.removeEventListener("abort",C),S.removeAllListeners()};a((ur,jr)=>{g=!0,jr&&(O=!0,T())});function C(ur){S.emit("abort",!ur||ur.type?new dje(null,t,j):ur)}S.once("abort",i),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(C),t.signal&&(t.signal.aborted?C():t.signal.addEventListener("abort",C)));let I=oZr(t.baseURL,t.url),N=new URL(I,wC.hasBrowserEnv?wC.origin:void 0),A=N.protocol||_Zl[0];if(A==="data:"){let ur;if(l!=="GET")return _Bt(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{ur=Vko(t.url,c==="blob",{Blob:t.env&&t.env.Blob})}catch(jr){throw xy.from(jr,xy.ERR_BAD_REQUEST,t)}return c==="text"?(ur=ur.toString(o),(!o||o==="utf8")&&(ur=Hl.stripBOM(ur))):c==="stream"&&(ur=sZr.default.Readable.from(ur)),_Bt(n,i,{data:ur,status:200,statusText:"OK",headers:new T3,config:t})}if(_Zl.indexOf(A)===-1)return i(new xy("Unsupported protocol "+A,xy.ERR_BAD_REQUEST,t));let U=T3.from(t.headers).normalize();U.set("User-Agent","axios/"+uZr,!1);let{onUploadProgress:X,onDownloadProgress:ue}=t,G=t.maxRate,$,re;if(Hl.isSpecCompliantForm(u)){let ur=U.getContentType(/boundary=([-_\w\d]{10,70})/i);u=oZl(u,jr=>{U.set(jr)},{tag:`axios-${uZr}-boundary`,boundary:ur&&ur[1]||void 0})}else if(Hl.isFormData(u)&&Hl.isFunction(u.getHeaders)){if(U.set(u.getHeaders()),!U.hasContentLength())try{let ur=await mZl.default.promisify(u.getLength).call(u);Number.isFinite(ur)&&ur>=0&&U.setContentLength(ur)}catch{}}else if(Hl.isBlob(u))u.size&&U.setContentType(u.type||"application/octet-stream"),U.setContentLength(u.size||0),u=sZr.default.Readable.from(Vsa(u));else if(u&&!Hl.isStream(u)){if(!Buffer.isBuffer(u))if(Hl.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(Hl.isString(u))u=Buffer.from(u,"utf-8");else return i(new xy("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",xy.ERR_BAD_REQUEST,t));if(U.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return i(new xy("Request body larger than maxBodyLength limit",xy.ERR_BAD_REQUEST,t))}let et=Hl.toFiniteNumber(U.getContentLength());Hl.isArray(G)?($=G[0],re=G[1]):$=re=G,u&&(X||$)&&(Hl.isStream(u)||(u=sZr.default.Readable.from(u,{objectMode:!1})),u=sZr.default.pipeline([u,new Jko({maxRate:Hl.toFiniteNumber($)})],Hl.noop),X&&u.on("progress",hZl(u,xAn(et,Jwr(TAn(X),!1,3)))));let Ve;if(t.auth){let ur=t.auth.username||"",jr=t.auth.password||"";Ve=ur+":"+jr}if(!Ve&&N.username){let ur=N.username,jr=N.password;Ve=ur+":"+jr}Ve&&U.delete("authorization");let Dt;try{Dt=aZr(N.pathname+N.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(ur){let jr=new Error(ur.message);return jr.config=t,jr.url=t.url,jr.exists=!0,i(jr)}U.set("Accept-Encoding","gzip, compress, deflate"+(pZl?", br":""),!1);let At={path:Dt,method:l,headers:U.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:Ve,protocol:A,family:d,beforeRedirect:RKP,beforeRedirects:{}};!Hl.isUndefined(f)&&(At.lookup=f),t.socketPath?At.socketPath=t.socketPath:(At.hostname=N.hostname.startsWith("[")?N.hostname.slice(1,-1):N.hostname,At.port=N.port,jZl(At,t.proxy,A+"//"+N.hostname+(N.port?":"+N.port:"")+At.path));let Wt,It=BKP.test(At.protocol);if(At.agent=It?t.httpsAgent:t.httpAgent,t.transport?Wt=t.transport:t.maxRedirects===0?Wt=It?gZl.default:bZl.default:(t.maxRedirects&&(At.maxRedirects=t.maxRedirects),t.beforeRedirect&&(At.beforeRedirects.config=t.beforeRedirect),Wt=It?zKP:IKP),t.maxBodyLength>-1?At.maxBodyLength=t.maxBodyLength:At.maxBodyLength=1/0,t.insecureHTTPParser&&(At.insecureHTTPParser=t.insecureHTTPParser),j=Wt.request(At,function(jr){if(j.destroyed)return;let Vr=[jr],Nt=+jr.headers["content-length"];if(ue||re){let xn=new Jko({maxRate:Hl.toFiniteNumber(re)});ue&&xn.on("progress",hZl(xn,xAn(Nt,Jwr(TAn(ue),!0,3)))),Vr.push(xn)}let lr=jr,Hr=jr.req||j;if(t.decompress!==!1&&jr.headers["content-encoding"])switch((l==="HEAD"||jr.statusCode===204)&&delete jr.headers["content-encoding"],(jr.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":Vr.push(Gwr.default.createUnzip(dZl)),delete jr.headers["content-encoding"];break;case"deflate":Vr.push(new sZl),Vr.push(Gwr.default.createUnzip(dZl)),delete jr.headers["content-encoding"];break;case"br":pZl&&(Vr.push(Gwr.default.createBrotliDecompress(NKP)),delete jr.headers["content-encoding"])}lr=Vr.length>1?sZr.default.pipeline(Vr,Hl.noop):Vr[0];let Kt=sZr.default.finished(lr,()=>{Kt(),T()}),wn={status:jr.statusCode,statusText:jr.statusMessage,headers:new T3(jr.headers),config:t,request:Hr};if(c==="stream")wn.data=lr,_Bt(n,i,wn);else{let xn=[],Ht=0;lr.on("data",function(pn){xn.push(pn),Ht+=pn.length,t.maxContentLength>-1&&Ht>t.maxContentLength&&(O=!0,lr.destroy(),i(new xy("maxContentLength size of "+t.maxContentLength+" exceeded",xy.ERR_BAD_RESPONSE,t,Hr)))}),lr.on("aborted",function(){if(O)return;let pn=new xy("maxContentLength size of "+t.maxContentLength+" exceeded",xy.ERR_BAD_RESPONSE,t,Hr);lr.destroy(pn),i(pn)}),lr.on("error",function(pn){j.destroyed||i(xy.from(pn,null,t,Hr))}),lr.on("end",function(){try{let pn=xn.length===1?xn[0]:Buffer.concat(xn);c!=="arraybuffer"&&(pn=pn.toString(o),(!o||o==="utf8")&&(pn=Hl.stripBOM(pn))),wn.data=pn}catch(pn){return i(xy.from(pn,null,t,wn.request,wn))}_Bt(n,i,wn)})}S.once("abort",xn=>{lr.destroyed||(lr.emit("error",xn),lr.destroy())})}),S.once("abort",ur=>{i(ur),j.destroy(ur)}),j.on("error",function(jr){i(xy.from(jr,null,t,j))}),j.on("socket",function(jr){jr.setKeepAlive(!0,1e3*60)}),t.timeout){let ur=parseInt(t.timeout,10);if(Number.isNaN(ur)){i(new xy("error trying to parse `config.timeout` to int",xy.ERR_BAD_OPTION_VALUE,t,j));return}j.setTimeout(ur,function(){if(g)return;let Vr=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",Nt=t.transitional||DAn;t.timeoutErrorMessage&&(Vr=t.timeoutErrorMessage),i(new xy(Vr,Nt.clarifyTimeoutError?xy.ETIMEDOUT:xy.ECONNABORTED,t,j)),C()})}if(Hl.isStream(u)){let ur=!1,jr=!1;u.on("end",()=>{ur=!0}),u.once("error",Vr=>{jr=!0,j.destroy(Vr)}),u.on("close",()=>{!ur&&!jr&&C(new dje("Request stream has been aborted",t,j))}),u.pipe(j)}else j.end(u)})};var DZl=wC.hasStandardBrowserEnv?function(){let t=wC.navigator&&/(msie|trident)/i.test(wC.navigator.userAgent),r=document.createElement("a"),n;function i(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 n=i(window.location.href),function(u){let f=Hl.isString(u)?i(u):u;return f.protocol===n.protocol&&f.host===n.host}}():function(){return function(){return!0}}();var SZl=wC.hasStandardBrowserEnv?{write(e,t,r,n,i,a){let u=[e+"="+encodeURIComponent(t)];Hl.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),Hl.isString(n)&&u.push("path="+n),Hl.isString(i)&&u.push("domain="+i),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 EZl=e=>e instanceof T3?{...e}:e;function BAt(e,t){t=t||{};let r={};function n(c,o,l){return Hl.isPlainObject(c)&&Hl.isPlainObject(o)?Hl.merge.call({caseless:l},c,o):Hl.isPlainObject(o)?Hl.merge({},o):Hl.isArray(o)?o.slice():o}function i(c,o,l){if(Hl.isUndefined(o)){if(!Hl.isUndefined(c))return n(void 0,c,l)}else return n(c,o,l)}function a(c,o){if(!Hl.isUndefined(o))return n(void 0,o)}function u(c,o){if(Hl.isUndefined(o)){if(!Hl.isUndefined(c))return n(void 0,c)}else return n(void 0,o)}function f(c,o,l){if(l in t)return n(c,o);if(l in e)return n(void 0,c)}let d={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:f,headers:(c,o)=>i(EZl(c),EZl(o),!0)};return Hl.forEach(Object.keys(Object.assign({},e,t)),function(o){let l=d[o]||i,g=l(e[o],t[o],o);Hl.isUndefined(g)&&l!==f||(r[o]=g)}),r}var Wsa=e=>{let t=BAt({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:u,auth:f}=t;t.headers=u=T3.from(u),t.url=aZr(oZr(t.baseURL,t.url),e.params,e.paramsSerializer),f&&u.set("Authorization","Basic "+btoa((f.username||"")+":"+(f.password?unescape(encodeURIComponent(f.password)):"")));let d;if(Hl.isFormData(r)){if(wC.hasStandardBrowserEnv||wC.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((d=u.getContentType())!==!1){let[c,...o]=d?d.split(";").map(l=>l.trim()).filter(Boolean):[];u.setContentType([c||"multipart/form-data",...o].join("; "))}}if(wC.hasStandardBrowserEnv&&(n&&Hl.isFunction(n)&&(n=n(t)),n||n!==!1&&DZl(t.url))){let c=i&&a&&SZl.read(a);c&&u.set(i,c)}return t};var VKP=typeof XMLHttpRequest<"u",MZl=VKP&&function(e){return new Promise(function(r,n){let i=Wsa(e),a=i.data,u=T3.from(i.headers).normalize(),{responseType:f,onUploadProgress:d,onDownloadProgress:c}=i,o,l,g,O,j;function S(){O&&O(),j&&j(),i.cancelToken&&i.cancelToken.unsubscribe(o),i.signal&&i.signal.removeEventListener("abort",o)}let T=new XMLHttpRequest;T.open(i.method.toUpperCase(),i.url,!0),T.timeout=i.timeout;function C(){if(!T)return;let N=T3.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),U={data:!f||f==="text"||f==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:N,config:e,request:T};_Bt(function(ue){r(ue),S()},function(ue){n(ue),S()},U),T=null}"onloadend"in T?T.onloadend=C:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(C)},T.onabort=function(){T&&(n(new xy("Request aborted",xy.ECONNABORTED,e,T)),T=null)},T.onerror=function(){n(new xy("Network Error",xy.ERR_NETWORK,e,T)),T=null},T.ontimeout=function(){let A=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",U=i.transitional||DAn;i.timeoutErrorMessage&&(A=i.timeoutErrorMessage),n(new xy(A,U.clarifyTimeoutError?xy.ETIMEDOUT:xy.ECONNABORTED,e,T)),T=null},a===void 0&&u.setContentType(null),"setRequestHeader"in T&&Hl.forEach(u.toJSON(),function(A,U){T.setRequestHeader(U,A)}),Hl.isUndefined(i.withCredentials)||(T.withCredentials=!!i.withCredentials),f&&f!=="json"&&(T.responseType=i.responseType),c&&([g,j]=Jwr(c,!0),T.addEventListener("progress",g)),d&&T.upload&&([l,O]=Jwr(d),T.upload.addEventListener("progress",l),T.upload.addEventListener("loadend",O)),(i.cancelToken||i.signal)&&(o=N=>{T&&(n(!N||N.type?new dje(null,e,T):N),T.abort(),T=null)},i.cancelToken&&i.cancelToken.subscribe(o),i.signal&&(i.signal.aborted?o():i.signal.addEventListener("abort",o)));let I=$li(i.url);if(I&&wC.protocols.indexOf(I)===-1){n(new xy("Unsupported protocol "+I+":",xy.ERR_BAD_REQUEST,e));return}T.send(a||null)})};var WKP=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,a=function(c){if(!i){i=!0,f();let o=c instanceof Error?c:this.reason;n.abort(o instanceof xy?o:new dje(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new xy(`timeout ${t} of ms exceeded`,xy.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:d}=n;return d.unsubscribe=()=>Hl.asap(f),d}},xZl=WKP;var HKP=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},JKP=async function*(e,t){for await(let r of GKP(e))yield*HKP(r,t)},GKP=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},$ko=(e,t,r,n)=>{let i=JKP(e,t),a=0,u,f=d=>{u||(u=!0,n&&n(d))};return new ReadableStream({async pull(d){try{let{done:c,value:o}=await i.next();if(c){f(),d.close();return}let l=o.byteLength;if(r){let g=a+=l;r(g)}d.enqueue(new Uint8Array(o))}catch(c){throw f(c),c}},cancel(d){return f(d),i.return()}},{highWaterMark:2})};var Jsa=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",qZl=Jsa&&typeof ReadableStream=="function",KKP=Jsa&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),AZl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},$KP=qZl&&AZl(()=>{let e=!1,t=new Request(wC.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),TZl=64*1024,Yko=qZl&&AZl(()=>Hl.isReadableStream(new Response("").body)),Hsa={stream:Yko&&(e=>e.body)};Jsa&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Hsa[t]&&(Hsa[t]=Hl.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new xy(`Response type '${t}' is not supported`,xy.ERR_NOT_SUPPORT,n)})})})(new Response);var YKP=async e=>{if(e==null)return 0;if(Hl.isBlob(e))return e.size;if(Hl.isSpecCompliantForm(e))return(await new Request(wC.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(Hl.isArrayBufferView(e)||Hl.isArrayBuffer(e))return e.byteLength;if(Hl.isURLSearchParams(e)&&(e=e+""),Hl.isString(e))return(await KKP(e)).byteLength},XKP=async(e,t)=>{let r=Hl.toFiniteNumber(e.getContentLength());return r??YKP(t)},CZl=Jsa&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:a,timeout:u,onDownloadProgress:f,onUploadProgress:d,responseType:c,headers:o,withCredentials:l="same-origin",fetchOptions:g}=Wsa(e);c=c?(c+"").toLowerCase():"text";let O=xZl([i,a&&a.toAbortSignal()],u),j,S=O&&O.unsubscribe&&(()=>{O.unsubscribe()}),T;try{if(d&&$KP&&r!=="get"&&r!=="head"&&(T=await XKP(o,n))!==0){let U=new Request(t,{method:"POST",body:n,duplex:"half"}),X;if(Hl.isFormData(n)&&(X=U.headers.get("content-type"))&&o.setContentType(X),U.body){let[ue,G]=xAn(T,Jwr(TAn(d)));n=$ko(U.body,TZl,ue,G)}}Hl.isString(l)||(l=l?"include":"omit");let C="credentials"in Request.prototype;j=new Request(t,{...g,signal:O,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:n,duplex:"half",credentials:C?l:void 0});let I=await fetch(j),N=Yko&&(c==="stream"||c==="response");if(Yko&&(f||N&&S)){let U={};["status","statusText","headers"].forEach($=>{U[$]=I[$]});let X=Hl.toFiniteNumber(I.headers.get("content-length")),[ue,G]=f&&xAn(X,Jwr(TAn(f),!0))||[];I=new Response($ko(I.body,TZl,ue,()=>{G&&G(),S&&S()}),U)}c=c||"text";let A=await Hsa[Hl.findKey(Hsa,c)||"text"](I,e);return!N&&S&&S(),await new Promise((U,X)=>{_Bt(U,X,{data:A,headers:T3.from(I.headers),status:I.status,statusText:I.statusText,config:e,request:j})})}catch(C){throw S&&S(),C&&C.name==="TypeError"&&/fetch/i.test(C.message)?Object.assign(new xy("Network Error",xy.ERR_NETWORK,e,j),{cause:C.cause||C}):xy.from(C,C&&C.code,e,j)}});var Xko={http:wZl,xhr:MZl,fetch:CZl};Hl.forEach(Xko,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var NZl=e=>`- ${e}`,QKP=e=>Hl.isFunction(e)||e===null||e===!1,Gsa={getAdapter:e=>{e=Hl.isArray(e)?e:[e];let{length:t}=e,r,n,i={};for(let a=0;a<t;a++){r=e[a];let u;if(n=r,!QKP(r)&&(n=Xko[(u=String(r)).toLowerCase()],n===void 0))throw new xy(`Unknown adapter '${u}'`);if(n)break;i[u||"#"+a]=n}if(!n){let a=Object.entries(i).map(([f,d])=>`adapter ${f} `+(d===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
@@ -1881,7 +1881,7 @@ errors:
1881
1881
  Run ${rl.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
1882
1882
  Run ${rl.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),AAn(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function $ru({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!mif(e))return;let i=t??"",a=e.filter(f=>f.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((f,d)=>f.generatorName.localeCompare(d.generatorName)||f.currentVersion.localeCompare(d.currentVersion));for(let f of u)i+=`
1883
1883
  ${await _i1(f.generatorName)} (${f.apiName!=null?"API: "+f.apiName+", ":""}Group: ${f.generatorGroup}) `+rl.dim(f.currentVersion)+rl.reset(" \u2192 ")+rl.green(f.latestVersion);return i+=`
1884
- `,n?AAn(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function _i1(e){let r=await new gif.FernRegistryClient({environment:"https://registry.buildwithfern.com"}).generators.getGeneratorByImage({dockerImage:e});if(!r.ok||r.body==null)throw new Error(`Generator ${e} not found`);return r.body.displayName}async function hi1({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await Pif({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,c,o,l)=>{f.versions[c]==null&&(f.versions[c]={});let g=rP.getGeneratorNameOrThrow(o.name,l),O=await rP.getLatestGeneratorVersion({generatorName:g,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});O!=null&&(f.versions[c][o.name]={previousVersion:o.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),f}let u={type:"multiApi",versions:{}};return await Pif({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,d,c,o)=>{if(f==null)return;u.versions[f]==null&&(u.versions[f]={}),u.versions[f][d]==null&&(u.versions[f][d]={});let l=rP.getGeneratorNameOrThrow(c.name,o),g=await rP.getLatestGeneratorVersion({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:a,context:o});g!=null&&(u.versions[f][d][c.name]={previousVersion:c.version,latestVersion:g})},generatorFilter:r,groupFilter:n}),u}async function Pif({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let f=await rP.loadGeneratorsConfiguration({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(f==null||f.groups==null)){for(let d of f.groups)if(!(i!=null&&d.groupName!==i))for(let c of d.generators)n!=null&&c.name!==n||await r(a.workspaceName,d.groupName,c,u)}})}))}function jif(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,f]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let d=cne(f.latestVersion,f.previousVersion);r.debug(`Latest version: ${f.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:f.previousVersion,latestVersion:f.latestVersion})}return n}async function rla({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await hi1({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(f.type==="multiApi")for(let[d,c]of Object.entries(f.versions))u.push(...jif(c,d,t.logger));else u.push(...jif(f.versions,void 0,t.logger))}return u}var Nfi=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${i} ${a}`.trim(),f=u?`status code ${u}`:"an unknown error";super(`Request failed with ${f}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var oCn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var uCn=e=>e!==null&&typeof e=="object";var Ifi=(...e)=>{for(let t of e)if((!uCn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Qru({},...e)},Yru=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,u]of i.entries())n&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function nla(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Qru(e[r]??[],t[r]??[])}var Xru=(e={},t={})=>({beforeRequest:nla(e,t,"beforeRequest"),beforeRetry:nla(e,t,"beforeRetry"),afterResponse:nla(e,t,"afterResponse"),beforeError:nla(e,t,"beforeError")}),Qru=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(uCn(i)){for(let[a,u]of Object.entries(i))uCn(u)&&a in t&&(u=Qru(t[a],u)),t={...t,[a]:u};uCn(i.hooks)&&(n=Xru(n,i.hooks),t.hooks=n),uCn(i.headers)&&(r=Yru(r,i.headers),t.headers=r)}return t};var wif=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),Dif=typeof globalThis.AbortController=="function",Sif=typeof globalThis.ReadableStream=="function",Eif=typeof globalThis.FormData=="function",ila=["get","post","put","patch","head","delete"],yi1=()=>{};yi1();var Mif={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},ala=2147483647,ola=Symbol("stop"),xif={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},Tif={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var Aif=e=>ila.includes(e)?e.toUpperCase():e,vi1=["get","put","head","delete","options","trace"],bi1=[408,413,429,500,502,503,504],gi1=[413,429,503],qif={limit:2,methods:vi1,statusCodes:bi1,afterStatusCodes:gi1,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Cif=(e={})=>{if(typeof e=="number")return{...qif,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...qif,...e}};async function Zru(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new oCn(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function kru(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var Nif=(e,t)=>{let r={};for(let n in t)!(n in Tif)&&!(n in xif)&&!(n in e)&&(r[n]=t[n]);return r};var zfi=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>ala)throw new RangeError(`The \`timeout\` option cannot be greater than ${ala}`);await Promise.resolve();let f=await n._fetch();for(let d of n._options.hooks.afterResponse){let c=await d(n.request,n._options,n._decorateResponse(f.clone()));c instanceof globalThis.Response&&(f=c)}if(n._decorateResponse(f),!f.ok&&n._options.throwHttpErrors){let d=new Nfi(f,n.request,n._options);for(let c of n._options.hooks.beforeError)d=await c(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Sif)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(f.clone(),n._options.onDownloadProgress)}return f},u=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[f,d]of Object.entries(Mif))u[f]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let o=(await u).clone();if(f==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[f]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Yru(this._input.headers,r.headers),hooks:Xru({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Aif(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:Cif(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(Dif){this.abortController=new globalThis.AbortController;let n=this._options.signal??this._input.signal;n?.addEventListener("abort",()=>{this.abortController.abort(n.reason)}),this._options.signal=this.abortController.signal}if(wif&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(Eif&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof oCn)throw t;if(t instanceof Nfi){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),ala);if(this._retryCount<1)throw r;await kru(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===ola)return;return this._retry(t)}}async _fetch(){for(let n of this._options.hooks.beforeRequest){let i=await n(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=Nif(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):Zru(r,t,this.abortController,this._options)}_stream(t,r){let n=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function f(){let{done:d,value:c}=await u.read();if(d){a.close();return}if(r){i+=c.byteLength;let o=n===0?0:i/n;r({percent:o,transferredBytes:i,totalBytes:n},c)}a.enqueue(c),await f()}await f()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var enu=e=>{let t=(r,n)=>zfi.create(r,Ifi(e,n));for(let r of ila)t[r]=(n,i)=>zfi.create(n,Ifi(e,i,{method:r}));return t.create=r=>enu(Ifi(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),enu(Ifi(e,r))),t.stop=ola,t},mi1=enu(),Iif=mi1;var iaf=iu(naf(),1);function anu(e){let t=(0,iaf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Wuf=iu(Qaf(),1),Huf=iu(Vuf(),1),Bnu=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Rnu=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function Fnu(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??anu(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,Wuf.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,f&&(d.authorization=`${f.type} ${f.token}`);let c;try{c=await Iif(u,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new Bnu(e):l}if(t.allVersions)return c;let o=new Rnu(e,r);if(c["dist-tags"][r]){let{time:l}=c;c=c.versions[c["dist-tags"][r]],c.time=l}else if(r){let l=!!c.versions[r];if(n&&!l)for(let[O,j]of Object.entries(c.versions))j.deprecated&&delete c.versions[O];if(!l){let O=Object.keys(c.versions);if(r=Huf.default.maxSatisfying(O,r),!r)throw o}let{time:g}=c;if(c=c.versions[r],c.time=g,!c)throw o}return c}async function Yfi(e,t){let{version:r}=await Fnu(e.toLowerCase(),t);return r}async function yCn({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:Yfi(e.packageName,{version:t?"prerelease":"latest"})}var Juf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Mla=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=OM.Info;constructor(t){this.ttyAwareLogger=new tla(t);let r=this.getPackageName(),n=this.getPackageVersion(),i=this.getCliName();(r==null||n==null||i==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:n,cliName:i}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.45.0-rc11"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${rl.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new JMe}failWithoutThrowing(t,r){this.didSucceed=!1,Qca({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),(await PAn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await Oif({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1884
+ `,n?AAn(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function _i1(e){let r=await new gif.FernRegistryClient({environment:"https://registry.buildwithfern.com"}).generators.getGeneratorByImage({dockerImage:e});if(!r.ok||r.body==null)throw new Error(`Generator ${e} not found`);return r.body.displayName}async function hi1({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await Pif({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,c,o,l)=>{f.versions[c]==null&&(f.versions[c]={});let g=rP.getGeneratorNameOrThrow(o.name,l),O=await rP.getLatestGeneratorVersion({generatorName:g,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});O!=null&&(f.versions[c][o.name]={previousVersion:o.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),f}let u={type:"multiApi",versions:{}};return await Pif({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,d,c,o)=>{if(f==null)return;u.versions[f]==null&&(u.versions[f]={}),u.versions[f][d]==null&&(u.versions[f][d]={});let l=rP.getGeneratorNameOrThrow(c.name,o),g=await rP.getLatestGeneratorVersion({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:a,context:o});g!=null&&(u.versions[f][d][c.name]={previousVersion:c.version,latestVersion:g})},generatorFilter:r,groupFilter:n}),u}async function Pif({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let f=await rP.loadGeneratorsConfiguration({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(f==null||f.groups==null)){for(let d of f.groups)if(!(i!=null&&d.groupName!==i))for(let c of d.generators)n!=null&&c.name!==n||await r(a.workspaceName,d.groupName,c,u)}})}))}function jif(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,f]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let d=cne(f.latestVersion,f.previousVersion);r.debug(`Latest version: ${f.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:f.previousVersion,latestVersion:f.latestVersion})}return n}async function rla({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await hi1({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(f.type==="multiApi")for(let[d,c]of Object.entries(f.versions))u.push(...jif(c,d,t.logger));else u.push(...jif(f.versions,void 0,t.logger))}return u}var Nfi=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${i} ${a}`.trim(),f=u?`status code ${u}`:"an unknown error";super(`Request failed with ${f}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var oCn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var uCn=e=>e!==null&&typeof e=="object";var Ifi=(...e)=>{for(let t of e)if((!uCn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Qru({},...e)},Yru=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,u]of i.entries())n&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function nla(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Qru(e[r]??[],t[r]??[])}var Xru=(e={},t={})=>({beforeRequest:nla(e,t,"beforeRequest"),beforeRetry:nla(e,t,"beforeRetry"),afterResponse:nla(e,t,"afterResponse"),beforeError:nla(e,t,"beforeError")}),Qru=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(uCn(i)){for(let[a,u]of Object.entries(i))uCn(u)&&a in t&&(u=Qru(t[a],u)),t={...t,[a]:u};uCn(i.hooks)&&(n=Xru(n,i.hooks),t.hooks=n),uCn(i.headers)&&(r=Yru(r,i.headers),t.headers=r)}return t};var wif=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),Dif=typeof globalThis.AbortController=="function",Sif=typeof globalThis.ReadableStream=="function",Eif=typeof globalThis.FormData=="function",ila=["get","post","put","patch","head","delete"],yi1=()=>{};yi1();var Mif={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},ala=2147483647,ola=Symbol("stop"),xif={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},Tif={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var Aif=e=>ila.includes(e)?e.toUpperCase():e,vi1=["get","put","head","delete","options","trace"],bi1=[408,413,429,500,502,503,504],gi1=[413,429,503],qif={limit:2,methods:vi1,statusCodes:bi1,afterStatusCodes:gi1,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Cif=(e={})=>{if(typeof e=="number")return{...qif,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...qif,...e}};async function Zru(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new oCn(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function kru(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var Nif=(e,t)=>{let r={};for(let n in t)!(n in Tif)&&!(n in xif)&&!(n in e)&&(r[n]=t[n]);return r};var zfi=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>ala)throw new RangeError(`The \`timeout\` option cannot be greater than ${ala}`);await Promise.resolve();let f=await n._fetch();for(let d of n._options.hooks.afterResponse){let c=await d(n.request,n._options,n._decorateResponse(f.clone()));c instanceof globalThis.Response&&(f=c)}if(n._decorateResponse(f),!f.ok&&n._options.throwHttpErrors){let d=new Nfi(f,n.request,n._options);for(let c of n._options.hooks.beforeError)d=await c(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Sif)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(f.clone(),n._options.onDownloadProgress)}return f},u=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[f,d]of Object.entries(Mif))u[f]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let o=(await u).clone();if(f==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[f]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Yru(this._input.headers,r.headers),hooks:Xru({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Aif(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:Cif(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(Dif){this.abortController=new globalThis.AbortController;let n=this._options.signal??this._input.signal;n?.addEventListener("abort",()=>{this.abortController.abort(n.reason)}),this._options.signal=this.abortController.signal}if(wif&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(Eif&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof oCn)throw t;if(t instanceof Nfi){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),ala);if(this._retryCount<1)throw r;await kru(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===ola)return;return this._retry(t)}}async _fetch(){for(let n of this._options.hooks.beforeRequest){let i=await n(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=Nif(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):Zru(r,t,this.abortController,this._options)}_stream(t,r){let n=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function f(){let{done:d,value:c}=await u.read();if(d){a.close();return}if(r){i+=c.byteLength;let o=n===0?0:i/n;r({percent:o,transferredBytes:i,totalBytes:n},c)}a.enqueue(c),await f()}await f()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var enu=e=>{let t=(r,n)=>zfi.create(r,Ifi(e,n));for(let r of ila)t[r]=(n,i)=>zfi.create(n,Ifi(e,i,{method:r}));return t.create=r=>enu(Ifi(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),enu(Ifi(e,r))),t.stop=ola,t},mi1=enu(),Iif=mi1;var iaf=iu(naf(),1);function anu(e){let t=(0,iaf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Wuf=iu(Qaf(),1),Huf=iu(Vuf(),1),Bnu=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Rnu=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function Fnu(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??anu(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,Wuf.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,f&&(d.authorization=`${f.type} ${f.token}`);let c;try{c=await Iif(u,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new Bnu(e):l}if(t.allVersions)return c;let o=new Rnu(e,r);if(c["dist-tags"][r]){let{time:l}=c;c=c.versions[c["dist-tags"][r]],c.time=l}else if(r){let l=!!c.versions[r];if(n&&!l)for(let[O,j]of Object.entries(c.versions))j.deprecated&&delete c.versions[O];if(!l){let O=Object.keys(c.versions);if(r=Huf.default.maxSatisfying(O,r),!r)throw o}let{time:g}=c;if(c=c.versions[r],c.time=g,!c)throw o}return c}async function Yfi(e,t){let{version:r}=await Fnu(e.toLowerCase(),t);return r}async function yCn({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:Yfi(e.packageName,{version:t?"prerelease":"latest"})}var Juf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Mla=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=OM.Info;constructor(t){this.ttyAwareLogger=new tla(t);let r=this.getPackageName(),n=this.getPackageVersion(),i=this.getCliName();(r==null||n==null||i==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:n,cliName:i}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.45.0-rc12"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${rl.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new JMe}failWithoutThrowing(t,r){this.didSucceed=!1,Qca({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),(await PAn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await Oif({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1885
1885
  `)||(r+=`
1886
1886
  `),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=R5o(t.map(n=>n.type==="docs"?"docs":n.workspaceName??"api"),n=>n.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new Efi(t);return this.ttyAwareLogger.registerTask(r),r}async runTaskWithInit(t,r){let n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(a){throw n.failWithoutThrowing(void 0,a),new JMe}finally{n.finish()}return i}async instrumentPostHogEvent(t){(await PAn()).sendEvent(t)}logger=uoi(this.log.bind(this));constructTaskInitForWorkspace(t){let r=Guf(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?Guf(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=Juf[this.numTasks++%Juf.length],u=rl.hex(a)(i);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===M4.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(n=>R6r.indexOf(n.level)>=R6r.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===OM.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 yCn({cliEnvironment:this.environment,includePreReleases:t}),n=cne(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await rla({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}};function Guf(e){return`[${e}]:`}var mcf=iu(gcf(),1);async function Oje(e,t,r=[],{doNotPipeOutput:n=!1,secrets:i=[],substitutions:a={},...u}={}){let f=i.reduce((o,l)=>({...o,[l]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[o,l]of Object.entries(f))d=d.replaceAll(o,l);e?.debug(`+ ${d}`);let c=(0,mcf.default)(t,r,u);return n||(c.stdout?.pipe(process.stdout),c.stderr?.pipe(process.stderr)),c}function zla(e,{logger:t,...r}={}){return(n,i)=>Oje(t,e,n,{...r,...i})}var Rla=require("fs/promises"),Ocf=iu(Vte(),1),fl1="buf.gen.yaml",Pcf="output",dl1=`${Pcf}/openapi.yaml`,pl1=`
1887
1887
  version: v1
@@ -2258,7 +2258,7 @@ error-discriminant: error`;await(0,nqo.writeFile)(r,i)}}};var P9C={version:"0.0.
2258
2258
  `));if(await r.takeOverTerminal(async()=>{await yWC(n)||r.failAndThrow("Canceled.")}),r.getResult()===M4.Failure)return;let i=n.flatMap(({migrations:a,version:u})=>a.map(f=>({migration:f,context:r.addInteractiveTask({name:`${u} ${f.name}`})})));for(let{migration:a,context:u}of i){let f=u.start();if(await a.run({context:f}),f.finish(),f.getResult()===M4.Failure){r.logger.error("Failed to run migrations. You may need to undo changes to files.");return}}}async function yWC(e){let t="wantsToContinue",r=["Some migrations need to be run:"];for(let{migrations:i}of e)for(let a of i)r.push(UX({prefix:" \u25E6 ",content:`${a.name}
2259
2259
  ${rl.dim(a.summary)}`}));r.push("Do you wish to continue?");let{[t]:n}=await xsa.prompt({name:t,type:"confirm",message:r.join(`
2260
2260
  `)});return n}var xgg=require("fs/promises");function DJ(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(process.env.NODE_ENV!=="production"){var i=wWC[e],a=i?typeof i=="function"?i.apply(null,r):i:"unknown error nr: "+e;throw Error("[Immer] "+a)}throw Error("[Immer] minified error nr: "+e+(r.length?" "+r.map(function(u){return"'"+u+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function QZn(e){return!!e&&!!e[ZSe]}function P1n(e){return!!e&&(function(t){if(!t||typeof t!="object")return!1;var r=Object.getPrototypeOf(t);if(r===null)return!0;var n=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return n===Object||typeof n=="function"&&Function.toString.call(n)===DWC}(e)||Array.isArray(e)||!!e[jgg]||!!e.constructor[jgg]||p1c(e)||_1c(e))}function xzi(e,t,r){r===void 0&&(r=!1),kZn(e)===0?(r?Object.keys:g1c)(e).forEach(function(n){r&&typeof n=="symbol"||t(n,e[n],e)}):e.forEach(function(n,i){return t(i,n,e)})}function kZn(e){var t=e[ZSe];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:p1c(e)?2:_1c(e)?3:0}function s1c(e,t){return kZn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function vWC(e,t){return kZn(e)===2?e.get(t):e[t]}function wgg(e,t,r){var n=kZn(e);n===2?e.set(t,r):n===3?(e.delete(t),e.add(r)):e[t]=r}function bWC(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function p1c(e){return PWC&&e instanceof Map}function _1c(e){return jWC&&e instanceof Set}function O1n(e){return e.o||e.t}function h1c(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=SWC(e);delete t[ZSe];for(var r=g1c(t),n=0;n<r.length;n++){var i=r[n],a=t[i];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(t[i]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[i]})}return Object.create(Object.getPrototypeOf(e),t)}function y1c(e,t){return t===void 0&&(t=!1),v1c(e)||QZn(e)||!P1n(e)||(kZn(e)>1&&(e.set=e.add=e.clear=e.delete=gWC),Object.freeze(e),t&&xzi(e,function(r,n){return y1c(n,!0)},!0)),e}function gWC(){DJ(2)}function v1c(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function CPr(e){var t=EWC[e];return t||DJ(18,e),t}function ygg(){return process.env.NODE_ENV==="production"||ZZn||DJ(0),ZZn}function i1c(e,t){t&&(CPr("Patches"),e.u=[],e.s=[],e.v=t)}function hAo(e){c1c(e),e.p.forEach(mWC),e.p=null}function c1c(e){e===ZZn&&(ZZn=e.l)}function vgg(e){return ZZn={p:[],l:ZZn,h:e,m:!0,_:0}}function mWC(e){var t=e[ZSe];t.i===0||t.i===1?t.j():t.O=!0}function a1c(e,t){t._=t.p.length;var r=t.p[0],n=e!==void 0&&e!==r;return t.h.g||CPr("ES5").S(t,e,n),n?(r[ZSe].P&&(hAo(t),DJ(4)),P1n(e)&&(e=yAo(t,e),t.l||vAo(t,e)),t.u&&CPr("Patches").M(r[ZSe].t,e,t.u,t.s)):e=yAo(t,r,[]),hAo(t),t.u&&t.v(t.u,t.s),e!==Dgg?e:void 0}function yAo(e,t,r){if(v1c(t))return t;var n=t[ZSe];if(!n)return xzi(t,function(a,u){return bgg(e,n,t,a,u,r)},!0),t;if(n.A!==e)return t;if(!n.P)return vAo(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=n.i===4||n.i===5?n.o=h1c(n.k):n.o;xzi(n.i===3?new Set(i):i,function(a,u){return bgg(e,n,i,a,u,r)}),vAo(e,i,!1),r&&e.u&&CPr("Patches").R(n,r,e.u,e.s)}return n.o}function bgg(e,t,r,n,i,a){if(process.env.NODE_ENV!=="production"&&i===r&&DJ(5),QZn(i)){var u=yAo(e,i,a&&t&&t.i!==3&&!s1c(t.D,n)?a.concat(n):void 0);if(wgg(r,n,u),!QZn(u))return;e.m=!1}if(P1n(i)&&!v1c(i)){if(!e.h.F&&e._<1)return;yAo(e,i),t&&t.A.l||vAo(e,i)}}function vAo(e,t,r){r===void 0&&(r=!1),e.h.F&&e.m&&y1c(t,r)}function o1c(e,t){var r=e[ZSe];return(r?O1n(r):e)[t]}function ggg(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function l1c(e){e.P||(e.P=!0,e.l&&l1c(e.l))}function u1c(e){e.o||(e.o=h1c(e.t))}function f1c(e,t,r){var n=p1c(t)?CPr("MapSet").N(t,r):_1c(t)?CPr("MapSet").T(t,r):e.g?function(i,a){var u=Array.isArray(i),f={i:u?1:0,A:a?a.A:ygg(),P:!1,I:!1,D:{},l:a,t:i,k:null,o:null,j:null,C:!1},d=f,c=d1c;u&&(d=[f],c=Mzi);var o=Proxy.revocable(d,c),l=o.revoke,g=o.proxy;return f.k=g,f.j=l,g}(t,r):CPr("ES5").J(t,r);return(r?r.A:ygg()).p.push(n),n}function OWC(e){return QZn(e)||DJ(22,e),function t(r){if(!P1n(r))return r;var n,i=r[ZSe],a=kZn(r);if(i){if(!i.P&&(i.i<4||!CPr("ES5").K(i)))return i.t;i.I=!0,n=mgg(r,a),i.I=!1}else n=mgg(r,a);return xzi(n,function(u,f){i&&vWC(i.t,u)===f||wgg(n,u,t(f))}),a===3?new Set(n):n}(e)}function mgg(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return h1c(e)}var Ogg,ZZn,b1c=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",PWC=typeof Map<"u",jWC=typeof Set<"u",Pgg=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",Dgg=b1c?Symbol.for("immer-nothing"):((Ogg={})["immer-nothing"]=!0,Ogg),jgg=b1c?Symbol.for("immer-draftable"):"__$immer_draftable",ZSe=b1c?Symbol.for("immer-state"):"__$immer_state";var wWC={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(e){return"Cannot apply patch, path doesn't resolve: "+e},16:'Sets cannot have "replace" patches.',17:function(e){return"Unsupported patch operation: "+e},18:function(e){return"The plugin for '"+e+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+e+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(e){return"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+e+"'"},22:function(e){return"'current' expects a draft, got: "+e},23:function(e){return"'original' expects a draft, got: "+e},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},DWC=""+Object.prototype.constructor,g1c=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,SWC=Object.getOwnPropertyDescriptors||function(e){var t={};return g1c(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},EWC={},d1c={get:function(e,t){if(t===ZSe)return e;var r=O1n(e);if(!s1c(r,t))return function(i,a,u){var f,d=ggg(a,u);return d?"value"in d?d.value:(f=d.get)===null||f===void 0?void 0:f.call(i.k):void 0}(e,r,t);var n=r[t];return e.I||!P1n(n)?n:n===o1c(e.t,t)?(u1c(e),e.o[t]=f1c(e.A.h,n,e)):n},has:function(e,t){return t in O1n(e)},ownKeys:function(e){return Reflect.ownKeys(O1n(e))},set:function(e,t,r){var n=ggg(O1n(e),t);if(n?.set)return n.set.call(e.k,r),!0;if(!e.P){var i=o1c(O1n(e),t),a=i?.[ZSe];if(a&&a.t===r)return e.o[t]=r,e.D[t]=!1,!0;if(bWC(r,i)&&(r!==void 0||s1c(e.t,t)))return!0;u1c(e),l1c(e)}return e.o[t]===r&&typeof r!="number"&&(r!==void 0||t in e.o)||(e.o[t]=r,e.D[t]=!0,!0)},deleteProperty:function(e,t){return o1c(e.t,t)!==void 0||t in e.t?(e.D[t]=!1,u1c(e),l1c(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=O1n(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.i!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty:function(){DJ(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){DJ(12)}},Mzi={};xzi(d1c,function(e,t){Mzi[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),Mzi.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&DJ(13),Mzi.set.call(this,e,t,void 0)},Mzi.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&DJ(14),d1c.set.call(this,e[0],t,r,e[0])};var MWC=function(){function e(r){var n=this;this.g=Pgg,this.F=!0,this.produce=function(i,a,u){if(typeof i=="function"&&typeof a!="function"){var f=a;a=i;var d=n;return function(S){var T=this;S===void 0&&(S=f);for(var C=arguments.length,I=Array(C>1?C-1:0),N=1;N<C;N++)I[N-1]=arguments[N];return d.produce(S,function(A){var U;return(U=a).call.apply(U,[T,A].concat(I))})}}var c;if(typeof a!="function"&&DJ(6),u!==void 0&&typeof u!="function"&&DJ(7),P1n(i)){var o=vgg(n),l=f1c(n,i,void 0),g=!0;try{c=a(l),g=!1}finally{g?hAo(o):c1c(o)}return typeof Promise<"u"&&c instanceof Promise?c.then(function(S){return i1c(o,u),a1c(S,o)},function(S){throw hAo(o),S}):(i1c(o,u),a1c(c,o))}if(!i||typeof i!="object"){if((c=a(i))===void 0&&(c=i),c===Dgg&&(c=void 0),n.F&&y1c(c,!0),u){var O=[],j=[];CPr("Patches").M(i,c,O,j),u(O,j)}return c}DJ(21,i)},this.produceWithPatches=function(i,a){if(typeof i=="function")return function(c){for(var o=arguments.length,l=Array(o>1?o-1:0),g=1;g<o;g++)l[g-1]=arguments[g];return n.produceWithPatches(c,function(O){return i.apply(void 0,[O].concat(l))})};var u,f,d=n.produce(i,a,function(c,o){u=c,f=o});return typeof Promise<"u"&&d instanceof Promise?d.then(function(c){return[c,u,f]}):[d,u,f]},typeof r?.useProxies=="boolean"&&this.setUseProxies(r.useProxies),typeof r?.autoFreeze=="boolean"&&this.setAutoFreeze(r.autoFreeze)}var t=e.prototype;return t.createDraft=function(r){P1n(r)||DJ(8),QZn(r)&&(r=OWC(r));var n=vgg(this),i=f1c(this,r,void 0);return i[ZSe].C=!0,c1c(n),i},t.finishDraft=function(r,n){var i=r&&r[ZSe];process.env.NODE_ENV!=="production"&&(i&&i.C||DJ(9),i.I&&DJ(10));var a=i.A;return i1c(a,n),a1c(void 0,a)},t.setAutoFreeze=function(r){this.F=r},t.setUseProxies=function(r){r&&!Pgg&&DJ(20),this.g=r},t.applyPatches=function(r,n){var i;for(i=n.length-1;i>=0;i--){var a=n[i];if(a.path.length===0&&a.op==="replace"){r=a.value;break}}i>-1&&(n=n.slice(i+1));var u=CPr("Patches").$;return QZn(r)?u(r,n):this.produce(r,function(f){return u(f,n)})},e}(),kSe=new MWC,xWC=kSe.produce,jdz=kSe.produceWithPatches.bind(kSe),wdz=kSe.setAutoFreeze.bind(kSe),Ddz=kSe.setUseProxies.bind(kSe),Sdz=kSe.applyPatches.bind(kSe),Edz=kSe.createDraft.bind(kSe),Mdz=kSe.finishDraft.bind(kSe),Sgg=xWC;async function Egg({cliEnvironment:e,version:t}){try{return await Yfi(e.packageName,{version:t}),!0}catch{return!1}}var Tzi="FERN_CWD";async function qzi({version:e,cliContext:t,env:r}){t.suppressUpgradeMessage();let n=["--quiet","--yes",`${t.environment.packageName}@${e}`,...process.argv.slice(2)];t.logger.debug([`Re-running CLI at version ${e}.`,`${rl.dim(`+ npx ${n.map(f=>`"${f}"`).join(" ")}`)}`].join(`
2261
- `));let{failed:i,stdout:a,stderr:u}=await Oje(t.logger,"npx",["--quiet",...n],{stdio:"inherit",reject:!1,env:{...r,[Tzi]:process.env[Tzi]??process.cwd()}});if(a?.includes("code EEXIST")||u?.includes("code EEXIST"))return await qzi({version:e,cliContext:t});i&&t.failWithoutThrowing()}var Mgg="FERN_PRE_UPGRADE_VERSION";async function Tgg({cliContext:e,includePreReleases:t,targetVersion:r}){r!=null&&(await Egg({cliEnvironment:e.environment,version:r})||e.failAndThrow(`Failed to upgrade to ${r} because it does not exist. See https://www.npmjs.com/package/${e.environment.packageName}?activeTab=versions.`),cne(r,e.environment.packageVersion)||e.failAndThrow(`Cannot upgrade because target version (${r}) is behind existing version ${e.environment.packageVersion}`));let n=r!=null?{latestVersion:r,isUpgradeAvailable:!0}:(await e.isUpgradeAvailable({includePreReleases:t})).cliUpgradeInfo;if(n&&!n.isUpgradeAvailable){let i=process.env[Mgg];if(i==null){e.logger.info("No upgrade available.");return}await e.runTask(async a=>{await n1c({fromVersion:i,toVersion:n.latestVersion,context:a})}),await e.exitIfFailed()}else if(n!=null){let i=await F4r();if(i==null)return e.failAndThrow(`Directory "${Sqt}" not found.`);let a=await e.runTask(f=>g8t.loadProjectConfig({directory:i,context:f})),u=Sgg(a.rawConfig,f=>{f.version=n.latestVersion});await(0,xgg.writeFile)(a._absolutePath,JSON.stringify(u,void 0,2)),e.logger.info(`Upgrading from ${rl.dim(e.environment.packageVersion)} \u2192 ${rl.green(n.latestVersion)}`),await Oje(e.logger,"npm",["install","-g",`${e.environment.packageName}@${n.latestVersion}`]),await qzi({version:n.latestVersion,cliContext:e,env:{[Mgg]:e.environment.packageVersion}})}}async function qgg({project:e,cliContext:t,logWarnings:r}){let n=e.docsWorkspaces;n!=null&&await t.runTaskForWorkspace(n,async i=>{await pja({workspace:n,context:i,logWarnings:r,loadAPIWorkspace:e.loadAPIWorkspace})}),await Promise.all(e.apiWorkspaces.map(async i=>{await t.runTaskForWorkspace(i,async a=>{let u=await i.toFernWorkspace({context:a});await wRt({workspace:u,context:a,logWarnings:r})})}))}var NPr=require("fs/promises");var m1c=iu(require("path"),1);async function Agg({project:e,cliContext:t,sdkLanguage:r}){await Promise.all(e.apiWorkspaces.map(async n=>{await t.runTaskForWorkspace(n,async i=>{n instanceof YAt?await TWC({workspace:n,context:i}):await qWC({workspace:await n.toFernWorkspace({context:i}),context:i})})}))}async function TWC({workspace:e,context:t}){for(let[r,n]of Object.entries(e.definition.importedDefinitions)){let i=_f(e.absoluteFilePath,Ms.of(j9),Ms.of(r),Ms.of(`.${j9}`));await Cgg({definition:n.definition,absolutePathToOutputDirectory:i}),t.logger.info(rl.green(`Wrote imported definition at ${m1c.default.relative(process.cwd(),i)}`))}}async function qWC({workspace:e,context:t}){let r=_f(e.absoluteFilePath,Ms.of(`.${j9}`));await Cgg({definition:e.definition,absolutePathToOutputDirectory:r}),t.logger.info(rl.green(`Wrote definition to ${m1c.default.relative(process.cwd(),r)}`))}async function Cgg({definition:e,absolutePathToOutputDirectory:t}){let r=(n,i)=>{let a={imports:0,types:1,services:2},u=n in a?a[n]:Object.keys(a).length,f=i in a?a[i]:Object.keys(a).length;return u==null?-1:f==null?1:u!==f?u-f:n.localeCompare(i)};await Bh(t)&&await(0,NPr.rmdir)(t,{recursive:!0}),await(0,NPr.mkdir)(t,{recursive:!0}),await(0,NPr.writeFile)(_f(t,Ms.of(oz)),a0.dump(e.rootApiFile.contents,{sortKeys:r}));for(let[n,i]of Object.entries(e.packageMarkers)){let a=_f(t,Ms.of(n));await(0,NPr.mkdir)(eb(a),{recursive:!0}),await(0,NPr.writeFile)(a,a0.dump(i.contents,{sortKeys:r}))}for(let[n,i]of Object.entries(e.namedDefinitionFiles)){let a=_f(t,Ms.of(n));await(0,NPr.mkdir)(eb(a),{recursive:!0}),await(0,NPr.writeFile)(a,a0.dump(i.contents,{sortKeys:r}))}}function Ngg(e){try{return new URL(e),!0}catch{return!1}}var bAo=class{context;ir;buildingTypeIds=new Set;definitions={};constructor(t,r){this.context=t,this.ir=r}getTypeDeclarationForId({typeName:t,typeId:r}){let n=this.ir.types[r];return n??(t!=null&&this.context.logger.error(`Type ${t} not found`),this.context.failAndThrow())}isOptional(t){if(t.type==="container"&&t.container.type==="optional")return!0;if(t.type==="named"){let r=this.getTypeDeclarationForId({typeId:t.typeId});if(r.shape.type==="alias")return this.isOptional(r.shape.aliasOf)}return!1}registerDefinition(t,r){let n=this.getTypeDeclarationForId({typeId:t});this.definitions[this.getDefinitionKey(n)]=r}getDefinitions(){return this.definitions}hasDefinition(t){let r=this.getTypeDeclarationForId({typeId:t});return this.getDefinitionKey(r)in this.definitions}getDefinitionKey(t){return[...t.name.fernFilepath.allParts.map(r=>r.originalName),t.name.name.originalName].join(".")}buildingTypeDeclaration(t){this.buildingTypeIds.add(t)}finishedBuildingTypeDeclaration(t){this.buildingTypeIds.delete(t)}isBuildingTypeDeclaration(t){return this.buildingTypeIds.has(t)}};function Igg({container:e,context:t}){switch(e.type){case"list":return{type:"array",items:eEe({typeReference:e.list,context:t})};case"map":return{type:"object",additionalProperties:eEe({typeReference:e.valueType,context:t})};case"optional":return eEe({typeReference:e.optional,context:t});case"set":return{type:"array",items:eEe({typeReference:e.set,context:t}),uniqueItems:!0};case"literal":switch(e.literal.type){case"string":return{const:e.literal.string};case"boolean":return{const:e.literal.boolean};default:$c(e.literal)}default:$c(e)}}function eEe({typeReference:e,context:t}){switch(e.type){case"named":{let r=t.getTypeDeclarationForId({typeId:e.typeId});if(!t.hasDefinition(e.typeId)&&!t.isBuildingTypeDeclaration(e.typeId)){t.buildingTypeDeclaration(e.typeId);let n=ekn({typeDeclaration:r,context:t});t.registerDefinition(e.typeId,n),t.finishedBuildingTypeDeclaration(e.typeId)}return{$ref:`#/definitions/${t.getDefinitionKey(r)}`}}case"container":return Igg({container:e.container,context:t});case"primitive":return AWC(e.primitive.v1);case"unknown":return{type:["string","number","boolean","object","array","null"]};default:$c(e)}}function AWC(e){switch(e){case tP.String:return{type:"string"};case tP.Integer:return{type:"integer"};case tP.Long:return{type:"integer"};case tP.Uint:return{type:"integer",minimum:0};case tP.Uint64:return{type:"integer",minimum:0};case tP.Float:return{type:"number"};case tP.Double:return{type:"number"};case tP.Boolean:return{type:"boolean"};case tP.Date:return{type:"string",format:"date"};case tP.DateTime:return{type:"string",format:"date-time"};case tP.Uuid:return{type:"string",format:"uuid"};case tP.Base64:return{type:"string",contentEncoding:"base64"};case tP.BigInteger:return{type:"string",pattern:"^-?[0-9]+$"};default:$c(e)}}function zgg({object:e,context:t}){let r={type:"object"},n=[...e.extendedProperties??[],...e.properties],i=n.map(u=>{let f=u.name.wireValue,d=eEe({typeReference:u.valueType,context:t});return[f,d]}),a=n.filter(u=>!t.isOptional(u.valueType)).map(u=>u.name.wireValue);return i.length>0&&(r.properties=Object.fromEntries(i)),a.length>0&&(r.required=a),r.additionalProperties=e.extraProperties,r}function Bgg({enum:e,context:t}){return{type:"string",enum:e.values.map(r=>r.name.wireValue)}}function Rgg({union:e,context:t}){let r=e.discriminant.wireValue;return{type:"object",properties:{[r]:{type:"string",enum:e.types.map(n=>n.discriminantValue.wireValue)}},required:[r],oneOf:e.types.map(n=>{let i={},a=[];switch(n.shape.propertiesType){case"samePropertiesAsObject":{let u=t.getTypeDeclarationForId({typeId:n.shape.typeId}),f=ekn({typeDeclaration:u,context:t});i=f.properties??{},a=Array.isArray(f.required)?f.required:[];break}case"singleProperty":i.value=eEe({typeReference:n.shape.type,context:t});break;case"noProperties":break;default:$c(n.shape)}return{properties:{[r]:{const:n.discriminantValue.wireValue},...i},required:[r,...a]}})}}function Fgg({undiscriminatedUnion:e,context:t}){return{oneOf:e.members.map(r=>{let n=eEe({typeReference:r.type,context:t});return r.docs&&(n.description=r.docs),n})}}function ekn({typeDeclaration:e,context:t}){switch(e.shape.type){case"object":return zgg({object:e.shape,context:t});case"alias":return eEe({typeReference:e.shape.aliasOf,context:t});case"enum":return Bgg({enum:e.shape,context:t});case"union":return Rgg({union:e.shape,context:t});case"undiscriminatedUnion":return Fgg({undiscriminatedUnion:e.shape,context:t});default:$c(e.shape)}}function O1c(e){let t=new bAo(e.context,e.ir),r=t.getTypeDeclarationForId({typeId:e.typeId,typeName:e.typeName});return{...ekn({typeDeclaration:r,context:t}),definitions:t.getDefinitions()}}var gAo=require("fs/promises");async function Lgg({typeLocator:e,project:t,jsonschemaFilepath:r,cliContext:n}){await Promise.all(t.apiWorkspaces.map(async i=>{await n.runTaskForWorkspace(i,async a=>{let u=await i.toFernWorkspace({context:a}),f=await AW({workspace:u,context:a,generationLanguage:void 0,audiences:{type:"all"},keywords:void 0,smartCasing:!1,disableExamples:!0,version:void 0,packageName:void 0,readme:void 0}),d=e.split("."),c=uRt({generationLanguage:void 0,keywords:void 0,smartCasing:!1}),o=d[d.length-1]??e,l=d.length>1?`${d.slice(0,-1).join("/")}.yml`:mM,g=WP.generateTypeId({fernFilepath:xne({relativeFilepath:Ms.of(`${d.slice(0,-1).join("/")}.yml`),casingsGenerator:c}),name:c.generateName(o)}),O=O1c({ir:f,typeName:o,typeId:g,context:a});await Bh(eb(r))||await(0,gAo.mkdir)(eb(r),{recursive:!0}),await(0,gAo.writeFile)(r,JSON.stringify(O,null,2)),a.logger.info(rl.green(`Wrote JSON Schema to ${r}`))})}))}CWC();async function CWC(){let e=new Mla(process.stdout),t=async()=>{await e.exit()};process.on("SIGINT",async()=>{e.suppressUpgradeMessage(),await t()});try{let r=process.env[Tzi];r!=null&&process.chdir(r);let n=await IWC(e);e.environment.packageVersion===n?await NWC(e):await qzi({version:n,cliContext:e})}catch(r){await e.instrumentPostHogEvent({command:process.argv.join(" "),properties:{failed:!0,error:r}}),r instanceof JMe?e.failWithoutThrowing():r instanceof Ojr?e.logger.error(`Failed. ${r.log}`):e.failWithoutThrowing("Failed.",r)}await t()}async function NWC(e){let t=Gnf(Gtu(process.argv)).scriptName(e.environment.cliName).version(!1).fail((r,n,i)=>{n==null&&(i.showHelp(),e.logger.error(r))}).strict().exitProcess(!1).command("$0",!1,r=>r.option("version",{describe:"Print current version",alias:"v"}).version(!1),r=>{r.version!=null?e.logger.info(e.environment.packageVersion):(t.showHelp(),e.failAndThrow())}).option("log-level",{default:OM.Info,choices:R6r}).demandCommand().recommendCommands();zWC(t,e),BWC(t,e),RWC(t,e),FWC(t,e),LWC(t,e),VWC(t,e),UWC(t,e),JWC(t,e),WWC(t,e),HWC(t,e),$WC(t,e),YWC(t,e),kWC(t,e),eHC(t,e),QWC(t,e),ZWC(t,e),XWC(t,e),KWC(t,e),GWC({cli:t,cliContext:e,onRun:()=>{e.suppressUpgradeMessage()}}),tHC(t,e),xMf(t,e),TMf(t,e),t.middleware(async r=>{e.setLogLevel(r["log-level"]),e.logDebugInfo()}),await t.parse()}async function IWC(e){if(process.env.FERN_NO_VERSION_REDIRECTION==="true")return e.environment.packageVersion;let t=await F4r();if(t!=null){let r=await e.runTask(n=>g8t.loadProjectConfig({directory:t,context:n}));return r.version==="*"?e.environment.packageVersion:r.version}return yCn({cliEnvironment:e.environment})}function zWC(e,t){e.command("init","Initialize a Fern API",r=>r.option("api",{boolean:!0,description:"Initialize an api."}).option("docs",{boolean:!0,description:"Initialize a docs website."}).option("organization",{alias:"org",type:"string",description:"Organization name"}).option("openapi",{type:"string",description:"Filepath or url to an existing OpenAPI spec"}),async r=>{if(r.api!=null&&r.docs!=null)return t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one.");if(r.docs!=null)await t.runTask(async n=>{await Jtu({organization:r.organization,versionOfCli:await yCn({cliEnvironment:t.environment}),taskContext:n})});else{let n;if(r.openapi!=null){if(Ngg(r.openapi)){let a=await Xnf({url:r.openapi,logger:t.logger});a.status==="failure"&&t.failAndThrow(a.errorMessage);let u=a.filePath;n=O_.of(u)}else n=O_.of(A2(yjr(),r.openapi));await Bh(n)||t.failAndThrow(`${n} does not exist`)}await t.runTask(async i=>{await Htu({organization:r.organization,versionOfCli:await yCn({cliEnvironment:t.environment}),context:i,openApiPath:n})})}})}function BWC(e,t){e.command("token","Generate a Fern Token",r=>r.option("organization",{alias:"org",type:"string",description:"The organization to create a token for. Defaults to the one in `fern.config.json`"}),async r=>{await t.runTask(async n=>{await ihg({orgId:r.organization??(await p6(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0})).config.organization,taskContext:n})})})}function RWC(e,t){e.command("add <generator>",`Add a code generator to ${c5}`,r=>r.positional("generator",{type:"string",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("group",{string:!0,description:"Add the generator to the specified group"}),async r=>{await AMf({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),generatorName:r.generator,groupName:r.group,cliContext:t})})}function FWC(e,t){e.command(["generate"],"Generate all generators in the specified group",r=>r.option("api",{string:!0,description:"If multiple APIs, specify the name with --api <name>. Otherwise, just --api."}).option("docs",{string:!0,description:"If multiple docs sites, specify the name with --docs <name>. Otherwise just --docs."}).option("instance",{string:!0,description:"The url for the instance of docs (e.g. --instance acme.docs.buildwithfern.com)"}).option("preview",{boolean:!0,default:!1,description:"Whether to generate a preview link for the docs"}).option("group",{type:"string",description:"The group to generate"}).option("mode",{choices:Object.values(H_g),description:"Defaults to the mode specified in generators.yml"}).option("version",{type:"string",description:"The version for the generated packages"}).option("printZipUrl",{boolean:!0,hidden:!0,default:!1}).option("local",{boolean:!0,default:!1,description:"Run the generator(s) locally, using Docker"}).option("keepDocker",{boolean:!0,default:!1,description:"Prevent auto-deletion of the Docker containers."}),async r=>r.api!=null&&r.docs!=null?t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one."):r.local&&r.preview?t.failWithoutThrowing("The --local flag is incompatible with --preview."):r.api!=null?await rPc({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local,preview:r.preview,mode:r.mode}):r.docs!=null?(r.group!=null&&t.logger.warn("--group is ignored when generating docs"),r.version!=null&&t.logger.warn("--version is ignored when generating docs"),await J_g({project:await p6(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0},!0),cliContext:t,instance:r.instance,preview:r.preview})):await rPc({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local,preview:r.preview,mode:r.mode}))}function LWC(e,t){e.command("ir <path-to-output>","Generate IR (Intermediate Representation)",r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("version",{string:!0,description:"The version of IR to produce"}).option("language",{choices:Object.values(rP.GenerationLanguage),description:"Generate IR for a particular language"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the IR for certain audiences"}),async r=>{await lrg({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:A2(yjr(),r.pathToOutput),cliContext:t,generationLanguage:r.language,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"},version:r.version,keywords:void 0,smartCasing:!1,readme:void 0})})}function UWC(e,t){e.command("openapi-ir <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("language",{choices:Object.values(rP.GenerationLanguage),description:"Generate IR for a particular language"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await prg({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:A2(yjr(),r.pathToOutput),cliContext:t,sdkLanguage:r.language})})}function VWC(e,t){e.command("fdr <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write FDR API definition",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the FDR API definition for certain audiences"}),async r=>{await zYf({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:A2(yjr(),r.pathToOutput),cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}})})}function WWC(e,t){e.command(["register"],!1,r=>r.option("version",{type:"string",description:"The version for the registered api"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let n=await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),i=await t.runTask(a=>UTe(a));await ehg({project:n,cliContext:t,token:i,version:r.version})})}function HWC(e,t){e.command(["register-v2"],!1,r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let n=await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),i=await t.runTask(a=>UTe(a));await thg({project:n,cliContext:t,token:i})})}function JWC(e,t){e.command("check","Validates your Fern Definition. Logs errors.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("warnings",{boolean:!0,description:"Log warnings in addition to errors.",default:!1}),async r=>{await qgg({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,logWarnings:r.warnings})})}function GWC({cli:e,cliContext:t,onRun:r}){e.command("upgrade",`Upgrades version in ${n8t}. Also upgrades generators in ${c5} to their minimum-compatible versions.`,n=>n.option("rc",{boolean:!0,hidden:!0,default:!1}).option("version",{string:!0,description:"The version to upgrade to. Defaults to the latest release."}),async n=>{await Tgg({cliContext:t,includePreReleases:n.rc,targetVersion:n.version}),r()})}function KWC(e,t){e.command("api update",`Pulls the latest OpenAPI spec from the specified origin in ${c5} and updates the local spec.`,r=>r.option("api",{string:!0,description:"The API to update the spec for. If not specified, all APIs with a declared origin will be updated."}),async r=>{await t.instrumentPostHogEvent({command:"fern api update"}),await shg({cliContext:t,project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0})})})}function $WC(e,t){e.command("login","Log in to Fern via GitHub",r=>r.option("device-code",{boolean:!0,default:!1,description:"Use device code authorization"}),async r=>{await t.runTask(async n=>{await t.instrumentPostHogEvent({command:"fern login"}),await tfi(n,{useDeviceCodeFlow:r.deviceCode})})})}function YWC(e,t){e.command("format","Formats your Fern Definition",r=>r.option("ci",{boolean:!0,default:!1,description:"Fail with non-zero exit status if files are not formatted correctly."}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await t.instrumentPostHogEvent({command:"fern format"}),await CYf({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,shouldFix:!r.ci})})}function XWC(e,t){e.command("test","Runs tests specified in --command, this spins up a mock server in the background that is terminated upon completion of the tests.",r=>r.option("api",{string:!0,description:"The API to mock."}).option("command",{string:!0,description:"The command to run to test your SDK."}).option("language",{choices:Object.values(rP.GenerationLanguage),description:"Run the tests configured to a specific language"}),async r=>{await t.instrumentPostHogEvent({command:"fern test"}),await rhg({cliContext:t,project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,nameOverride:".mock",sdkLanguage:r.language}),testCommand:r.command,generationLanguage:r.language})})}function QWC(e,t){e.command("mock","Starts a mock server for an API.",r=>r.option("port",{number:!0,description:"The port the server binds to."}).option("api",{string:!0,description:"The API to mock."}),async r=>{await t.instrumentPostHogEvent({command:"fern mock"}),await $_g({cliContext:t,project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),port:r.port})})}function ZWC(e,t){e.command("write-overrides","Generate a basic openapi overrides file.",r=>[r.option("api",{string:!0,description:"Only run the command on the provided API"}),r.option("exclude-models",{boolean:!0,description:"When generating the initial overrides, also stub the models (in addition to the endpoints)",default:!1})],async r=>{await t.instrumentPostHogEvent({command:"fern generate-overrides"}),await hrg({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),includeModels:!r.excludeModels,cliContext:t})})}function kWC(e,t){e.command("write-definition","Write underlying Fern Definition for OpenAPI specs and API Dependencies.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("language",{choices:Object.values(rP.GenerationLanguage),description:"Write the definition for a particular SDK language"}),async r=>{await t.instrumentPostHogEvent({command:"fern write-definition"}),await Agg({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0,sdkLanguage:r.language}),cliContext:t,sdkLanguage:r.language})})}function eHC(e,t){e.command("docs dev","Run a local development server to preview your docs",r=>r.option("port",{number:!0,description:"Run the development server on the following port"}).option("bundle-path",{string:!0,hidden:!0,description:"Path of the local docs bundle to use"}),async r=>{let n;r.port!=null?n=r.port:n=await _fi({port:[3e3,3001,3002,3003,3004,3005,3006,3007,3008,3009,3010]});let i=r.bundlePath;await AYf({loadProject:()=>p6(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),cliContext:t,port:n,bundlePath:i})})}function tHC(e,t){e.command("jsonschema <path-to-output>","Generate JSON Schema for a specific type",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).positional("path-to-output",{type:"string",description:"Path to write JSON Schema",demandOption:!0}).option("type",{string:!0,demandOption:!0,description:"The type to generate JSON Schema for (e.g. 'MySchema' or 'mypackage.MySchema')"}),async r=>{await t.instrumentPostHogEvent({command:"fern jsonschema",properties:{output:r.output}}),await Lgg({typeLocator:r.type,project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),jsonschemaFilepath:A2(yjr(),r.pathToOutput),cliContext:t})})}
2261
+ `));let{failed:i,stdout:a,stderr:u}=await Oje(t.logger,"npx",["--quiet",...n],{stdio:"inherit",reject:!1,env:{...r,[Tzi]:process.env[Tzi]??process.cwd()}});if(a?.includes("code EEXIST")||u?.includes("code EEXIST"))return await qzi({version:e,cliContext:t});i&&t.failWithoutThrowing()}var Mgg="FERN_PRE_UPGRADE_VERSION";async function Tgg({cliContext:e,includePreReleases:t,targetVersion:r}){r!=null&&(await Egg({cliEnvironment:e.environment,version:r})||e.failAndThrow(`Failed to upgrade to ${r} because it does not exist. See https://www.npmjs.com/package/${e.environment.packageName}?activeTab=versions.`),cne(r,e.environment.packageVersion)||e.failAndThrow(`Cannot upgrade because target version (${r}) is behind existing version ${e.environment.packageVersion}`));let n=r!=null?{latestVersion:r,isUpgradeAvailable:!0}:(await e.isUpgradeAvailable({includePreReleases:t})).cliUpgradeInfo;if(n&&!n.isUpgradeAvailable){let i=process.env[Mgg];if(i==null){e.logger.info("No upgrade available.");return}await e.runTask(async a=>{await n1c({fromVersion:i,toVersion:n.latestVersion,context:a})}),await e.exitIfFailed()}else if(n!=null){let i=await F4r();if(i==null)return e.failAndThrow(`Directory "${Sqt}" not found.`);let a=await e.runTask(f=>g8t.loadProjectConfig({directory:i,context:f})),u=Sgg(a.rawConfig,f=>{f.version=n.latestVersion});await(0,xgg.writeFile)(a._absolutePath,JSON.stringify(u,void 0,2)),e.logger.info(`Upgrading from ${rl.dim(e.environment.packageVersion)} \u2192 ${rl.green(n.latestVersion)}`),await Oje(e.logger,"npm",["install","-g",`${e.environment.packageName}@${n.latestVersion}`]),await qzi({version:n.latestVersion,cliContext:e,env:{[Mgg]:e.environment.packageVersion}})}}async function qgg({project:e,cliContext:t,logWarnings:r}){let n=e.docsWorkspaces;n!=null&&await t.runTaskForWorkspace(n,async i=>{await pja({workspace:n,context:i,logWarnings:r,loadAPIWorkspace:e.loadAPIWorkspace})}),await Promise.all(e.apiWorkspaces.map(async i=>{await t.runTaskForWorkspace(i,async a=>{let u=await i.toFernWorkspace({context:a});await wRt({workspace:u,context:a,logWarnings:r})})}))}var NPr=require("fs/promises");var m1c=iu(require("path"),1);async function Agg({project:e,cliContext:t,sdkLanguage:r}){await Promise.all(e.apiWorkspaces.map(async n=>{await t.runTaskForWorkspace(n,async i=>{n instanceof YAt?await TWC({workspace:n,context:i}):await qWC({workspace:await n.toFernWorkspace({context:i}),context:i})})}))}async function TWC({workspace:e,context:t}){for(let[r,n]of Object.entries(e.definition.importedDefinitions)){let i=_f(e.absoluteFilePath,Ms.of(j9),Ms.of(r),Ms.of(`.${j9}`));await Cgg({definition:n.definition,absolutePathToOutputDirectory:i}),t.logger.info(rl.green(`Wrote imported definition at ${m1c.default.relative(process.cwd(),i)}`))}}async function qWC({workspace:e,context:t}){let r=_f(e.absoluteFilePath,Ms.of(`.${j9}`));await Cgg({definition:e.definition,absolutePathToOutputDirectory:r}),t.logger.info(rl.green(`Wrote definition to ${m1c.default.relative(process.cwd(),r)}`))}async function Cgg({definition:e,absolutePathToOutputDirectory:t}){let r=(n,i)=>{let a={imports:0,types:1,services:2},u=n in a?a[n]:Object.keys(a).length,f=i in a?a[i]:Object.keys(a).length;return u==null?-1:f==null?1:u!==f?u-f:n.localeCompare(i)};await Bh(t)&&await(0,NPr.rmdir)(t,{recursive:!0}),await(0,NPr.mkdir)(t,{recursive:!0}),await(0,NPr.writeFile)(_f(t,Ms.of(oz)),a0.dump(e.rootApiFile.contents,{sortKeys:r}));for(let[n,i]of Object.entries(e.packageMarkers)){let a=_f(t,Ms.of(n));await(0,NPr.mkdir)(eb(a),{recursive:!0}),await(0,NPr.writeFile)(a,a0.dump(i.contents,{sortKeys:r}))}for(let[n,i]of Object.entries(e.namedDefinitionFiles)){let a=_f(t,Ms.of(n));await(0,NPr.mkdir)(eb(a),{recursive:!0}),await(0,NPr.writeFile)(a,a0.dump(i.contents,{sortKeys:r}))}}function Ngg(e){try{return new URL(e),!0}catch{return!1}}var bAo=class{context;ir;buildingTypeIds=new Set;definitions={};constructor(t,r){this.context=t,this.ir=r}getTypeDeclarationForId({typeName:t,typeId:r}){let n=this.ir.types[r];return n??(t!=null&&this.context.logger.error(`Type ${t} not found`),this.context.failAndThrow())}isOptional(t){if(t.type==="container"&&t.container.type==="optional")return!0;if(t.type==="named"){let r=this.getTypeDeclarationForId({typeId:t.typeId});if(r.shape.type==="alias")return this.isOptional(r.shape.aliasOf)}return!1}registerDefinition(t,r){let n=this.getTypeDeclarationForId({typeId:t});this.definitions[this.getDefinitionKey(n)]=r}getDefinitions(){return this.definitions}hasDefinition(t){let r=this.getTypeDeclarationForId({typeId:t});return this.getDefinitionKey(r)in this.definitions}getDefinitionKey(t){return[...t.name.fernFilepath.allParts.map(r=>r.originalName),t.name.name.originalName].join(".")}buildingTypeDeclaration(t){this.buildingTypeIds.add(t)}finishedBuildingTypeDeclaration(t){this.buildingTypeIds.delete(t)}isBuildingTypeDeclaration(t){return this.buildingTypeIds.has(t)}};function Igg({container:e,context:t}){switch(e.type){case"list":return{type:"array",items:eEe({typeReference:e.list,context:t})};case"map":return{type:"object",additionalProperties:eEe({typeReference:e.valueType,context:t})};case"optional":return{oneOf:[eEe({typeReference:e.optional,context:t}),{type:"null"}]};case"set":return{type:"array",items:eEe({typeReference:e.set,context:t}),uniqueItems:!0};case"literal":switch(e.literal.type){case"string":return{const:e.literal.string};case"boolean":return{const:e.literal.boolean};default:$c(e.literal)}default:$c(e)}}function eEe({typeReference:e,context:t}){switch(e.type){case"named":{let r=t.getTypeDeclarationForId({typeId:e.typeId});if(!t.hasDefinition(e.typeId)&&!t.isBuildingTypeDeclaration(e.typeId)){t.buildingTypeDeclaration(e.typeId);let n=ekn({typeDeclaration:r,context:t});t.registerDefinition(e.typeId,n),t.finishedBuildingTypeDeclaration(e.typeId)}return{$ref:`#/definitions/${t.getDefinitionKey(r)}`}}case"container":return Igg({container:e.container,context:t});case"primitive":return AWC(e.primitive.v1);case"unknown":return{type:["string","number","boolean","object","array","null"]};default:$c(e)}}function AWC(e){switch(e){case tP.String:return{type:"string"};case tP.Integer:return{type:"integer"};case tP.Long:return{type:"integer"};case tP.Uint:return{type:"integer",minimum:0};case tP.Uint64:return{type:"integer",minimum:0};case tP.Float:return{type:"number"};case tP.Double:return{type:"number"};case tP.Boolean:return{type:"boolean"};case tP.Date:return{type:"string",format:"date"};case tP.DateTime:return{type:"string",format:"date-time"};case tP.Uuid:return{type:"string",format:"uuid"};case tP.Base64:return{type:"string",contentEncoding:"base64"};case tP.BigInteger:return{type:"string",pattern:"^-?[0-9]+$"};default:$c(e)}}function zgg({object:e,context:t}){let r={type:"object"},n=[...e.extendedProperties??[],...e.properties],i=n.map(u=>{let f=u.name.wireValue,d=eEe({typeReference:u.valueType,context:t});return[f,d]}),a=n.filter(u=>!t.isOptional(u.valueType)).map(u=>u.name.wireValue);return i.length>0&&(r.properties=Object.fromEntries(i)),a.length>0&&(r.required=a),r.additionalProperties=e.extraProperties,r}function Bgg({enum:e,context:t}){return{type:"string",enum:e.values.map(r=>r.name.wireValue)}}function Rgg({union:e,context:t}){let r=e.discriminant.wireValue;return{type:"object",properties:{[r]:{type:"string",enum:e.types.map(n=>n.discriminantValue.wireValue)}},required:[r],oneOf:e.types.map(n=>{let i={},a=[];switch(n.shape.propertiesType){case"samePropertiesAsObject":{let u=t.getTypeDeclarationForId({typeId:n.shape.typeId}),f=ekn({typeDeclaration:u,context:t});i=f.properties??{},a=Array.isArray(f.required)?f.required:[];break}case"singleProperty":i.value=eEe({typeReference:n.shape.type,context:t});break;case"noProperties":break;default:$c(n.shape)}return{properties:{[r]:{const:n.discriminantValue.wireValue},...i},required:[r,...a]}})}}function Fgg({undiscriminatedUnion:e,context:t}){return{anyOf:e.members.map(r=>{let n=eEe({typeReference:r.type,context:t});return r.docs&&(n.description=r.docs),n})}}function ekn({typeDeclaration:e,context:t}){switch(e.shape.type){case"object":return zgg({object:e.shape,context:t});case"alias":return eEe({typeReference:e.shape.aliasOf,context:t});case"enum":return Bgg({enum:e.shape,context:t});case"union":return Rgg({union:e.shape,context:t});case"undiscriminatedUnion":return Fgg({undiscriminatedUnion:e.shape,context:t});default:$c(e.shape)}}function O1c(e){let t=new bAo(e.context,e.ir),r=t.getTypeDeclarationForId({typeId:e.typeId,typeName:e.typeName});return{...ekn({typeDeclaration:r,context:t}),definitions:t.getDefinitions()}}var gAo=require("fs/promises");async function Lgg({typeLocator:e,project:t,jsonschemaFilepath:r,cliContext:n}){await Promise.all(t.apiWorkspaces.map(async i=>{await n.runTaskForWorkspace(i,async a=>{let u=await i.toFernWorkspace({context:a}),f=await AW({workspace:u,context:a,generationLanguage:void 0,audiences:{type:"all"},keywords:void 0,smartCasing:!1,disableExamples:!0,version:void 0,packageName:void 0,readme:void 0}),d=e.split("."),c=uRt({generationLanguage:void 0,keywords:void 0,smartCasing:!1}),o=d[d.length-1]??e,l=d.length>1?`${d.slice(0,-1).join("/")}.yml`:mM,g=WP.generateTypeId({fernFilepath:xne({relativeFilepath:Ms.of(`${d.slice(0,-1).join("/")}.yml`),casingsGenerator:c}),name:c.generateName(o)}),O=O1c({ir:f,typeName:o,typeId:g,context:a});await Bh(eb(r))||await(0,gAo.mkdir)(eb(r),{recursive:!0}),await(0,gAo.writeFile)(r,JSON.stringify(O,null,2)),a.logger.info(rl.green(`Wrote JSON Schema to ${r}`))})}))}CWC();async function CWC(){let e=new Mla(process.stdout),t=async()=>{await e.exit()};process.on("SIGINT",async()=>{e.suppressUpgradeMessage(),await t()});try{let r=process.env[Tzi];r!=null&&process.chdir(r);let n=await IWC(e);e.environment.packageVersion===n?await NWC(e):await qzi({version:n,cliContext:e})}catch(r){await e.instrumentPostHogEvent({command:process.argv.join(" "),properties:{failed:!0,error:r}}),r instanceof JMe?e.failWithoutThrowing():r instanceof Ojr?e.logger.error(`Failed. ${r.log}`):e.failWithoutThrowing("Failed.",r)}await t()}async function NWC(e){let t=Gnf(Gtu(process.argv)).scriptName(e.environment.cliName).version(!1).fail((r,n,i)=>{n==null&&(i.showHelp(),e.logger.error(r))}).strict().exitProcess(!1).command("$0",!1,r=>r.option("version",{describe:"Print current version",alias:"v"}).version(!1),r=>{r.version!=null?e.logger.info(e.environment.packageVersion):(t.showHelp(),e.failAndThrow())}).option("log-level",{default:OM.Info,choices:R6r}).demandCommand().recommendCommands();zWC(t,e),BWC(t,e),RWC(t,e),FWC(t,e),LWC(t,e),VWC(t,e),UWC(t,e),JWC(t,e),WWC(t,e),HWC(t,e),$WC(t,e),YWC(t,e),kWC(t,e),eHC(t,e),QWC(t,e),ZWC(t,e),XWC(t,e),KWC(t,e),GWC({cli:t,cliContext:e,onRun:()=>{e.suppressUpgradeMessage()}}),tHC(t,e),xMf(t,e),TMf(t,e),t.middleware(async r=>{e.setLogLevel(r["log-level"]),e.logDebugInfo()}),await t.parse()}async function IWC(e){if(process.env.FERN_NO_VERSION_REDIRECTION==="true")return e.environment.packageVersion;let t=await F4r();if(t!=null){let r=await e.runTask(n=>g8t.loadProjectConfig({directory:t,context:n}));return r.version==="*"?e.environment.packageVersion:r.version}return yCn({cliEnvironment:e.environment})}function zWC(e,t){e.command("init","Initialize a Fern API",r=>r.option("api",{boolean:!0,description:"Initialize an api."}).option("docs",{boolean:!0,description:"Initialize a docs website."}).option("organization",{alias:"org",type:"string",description:"Organization name"}).option("openapi",{type:"string",description:"Filepath or url to an existing OpenAPI spec"}),async r=>{if(r.api!=null&&r.docs!=null)return t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one.");if(r.docs!=null)await t.runTask(async n=>{await Jtu({organization:r.organization,versionOfCli:await yCn({cliEnvironment:t.environment}),taskContext:n})});else{let n;if(r.openapi!=null){if(Ngg(r.openapi)){let a=await Xnf({url:r.openapi,logger:t.logger});a.status==="failure"&&t.failAndThrow(a.errorMessage);let u=a.filePath;n=O_.of(u)}else n=O_.of(A2(yjr(),r.openapi));await Bh(n)||t.failAndThrow(`${n} does not exist`)}await t.runTask(async i=>{await Htu({organization:r.organization,versionOfCli:await yCn({cliEnvironment:t.environment}),context:i,openApiPath:n})})}})}function BWC(e,t){e.command("token","Generate a Fern Token",r=>r.option("organization",{alias:"org",type:"string",description:"The organization to create a token for. Defaults to the one in `fern.config.json`"}),async r=>{await t.runTask(async n=>{await ihg({orgId:r.organization??(await p6(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0})).config.organization,taskContext:n})})})}function RWC(e,t){e.command("add <generator>",`Add a code generator to ${c5}`,r=>r.positional("generator",{type:"string",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("group",{string:!0,description:"Add the generator to the specified group"}),async r=>{await AMf({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),generatorName:r.generator,groupName:r.group,cliContext:t})})}function FWC(e,t){e.command(["generate"],"Generate all generators in the specified group",r=>r.option("api",{string:!0,description:"If multiple APIs, specify the name with --api <name>. Otherwise, just --api."}).option("docs",{string:!0,description:"If multiple docs sites, specify the name with --docs <name>. Otherwise just --docs."}).option("instance",{string:!0,description:"The url for the instance of docs (e.g. --instance acme.docs.buildwithfern.com)"}).option("preview",{boolean:!0,default:!1,description:"Whether to generate a preview link for the docs"}).option("group",{type:"string",description:"The group to generate"}).option("mode",{choices:Object.values(H_g),description:"Defaults to the mode specified in generators.yml"}).option("version",{type:"string",description:"The version for the generated packages"}).option("printZipUrl",{boolean:!0,hidden:!0,default:!1}).option("local",{boolean:!0,default:!1,description:"Run the generator(s) locally, using Docker"}).option("keepDocker",{boolean:!0,default:!1,description:"Prevent auto-deletion of the Docker containers."}),async r=>r.api!=null&&r.docs!=null?t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one."):r.local&&r.preview?t.failWithoutThrowing("The --local flag is incompatible with --preview."):r.api!=null?await rPc({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local,preview:r.preview,mode:r.mode}):r.docs!=null?(r.group!=null&&t.logger.warn("--group is ignored when generating docs"),r.version!=null&&t.logger.warn("--version is ignored when generating docs"),await J_g({project:await p6(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0},!0),cliContext:t,instance:r.instance,preview:r.preview})):await rPc({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local,preview:r.preview,mode:r.mode}))}function LWC(e,t){e.command("ir <path-to-output>","Generate IR (Intermediate Representation)",r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("version",{string:!0,description:"The version of IR to produce"}).option("language",{choices:Object.values(rP.GenerationLanguage),description:"Generate IR for a particular language"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the IR for certain audiences"}),async r=>{await lrg({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:A2(yjr(),r.pathToOutput),cliContext:t,generationLanguage:r.language,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"},version:r.version,keywords:void 0,smartCasing:!1,readme:void 0})})}function UWC(e,t){e.command("openapi-ir <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("language",{choices:Object.values(rP.GenerationLanguage),description:"Generate IR for a particular language"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await prg({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:A2(yjr(),r.pathToOutput),cliContext:t,sdkLanguage:r.language})})}function VWC(e,t){e.command("fdr <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write FDR API definition",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the FDR API definition for certain audiences"}),async r=>{await zYf({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:A2(yjr(),r.pathToOutput),cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}})})}function WWC(e,t){e.command(["register"],!1,r=>r.option("version",{type:"string",description:"The version for the registered api"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let n=await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),i=await t.runTask(a=>UTe(a));await ehg({project:n,cliContext:t,token:i,version:r.version})})}function HWC(e,t){e.command(["register-v2"],!1,r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let n=await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),i=await t.runTask(a=>UTe(a));await thg({project:n,cliContext:t,token:i})})}function JWC(e,t){e.command("check","Validates your Fern Definition. Logs errors.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("warnings",{boolean:!0,description:"Log warnings in addition to errors.",default:!1}),async r=>{await qgg({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,logWarnings:r.warnings})})}function GWC({cli:e,cliContext:t,onRun:r}){e.command("upgrade",`Upgrades version in ${n8t}. Also upgrades generators in ${c5} to their minimum-compatible versions.`,n=>n.option("rc",{boolean:!0,hidden:!0,default:!1}).option("version",{string:!0,description:"The version to upgrade to. Defaults to the latest release."}),async n=>{await Tgg({cliContext:t,includePreReleases:n.rc,targetVersion:n.version}),r()})}function KWC(e,t){e.command("api update",`Pulls the latest OpenAPI spec from the specified origin in ${c5} and updates the local spec.`,r=>r.option("api",{string:!0,description:"The API to update the spec for. If not specified, all APIs with a declared origin will be updated."}),async r=>{await t.instrumentPostHogEvent({command:"fern api update"}),await shg({cliContext:t,project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0})})})}function $WC(e,t){e.command("login","Log in to Fern via GitHub",r=>r.option("device-code",{boolean:!0,default:!1,description:"Use device code authorization"}),async r=>{await t.runTask(async n=>{await t.instrumentPostHogEvent({command:"fern login"}),await tfi(n,{useDeviceCodeFlow:r.deviceCode})})})}function YWC(e,t){e.command("format","Formats your Fern Definition",r=>r.option("ci",{boolean:!0,default:!1,description:"Fail with non-zero exit status if files are not formatted correctly."}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await t.instrumentPostHogEvent({command:"fern format"}),await CYf({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,shouldFix:!r.ci})})}function XWC(e,t){e.command("test","Runs tests specified in --command, this spins up a mock server in the background that is terminated upon completion of the tests.",r=>r.option("api",{string:!0,description:"The API to mock."}).option("command",{string:!0,description:"The command to run to test your SDK."}).option("language",{choices:Object.values(rP.GenerationLanguage),description:"Run the tests configured to a specific language"}),async r=>{await t.instrumentPostHogEvent({command:"fern test"}),await rhg({cliContext:t,project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,nameOverride:".mock",sdkLanguage:r.language}),testCommand:r.command,generationLanguage:r.language})})}function QWC(e,t){e.command("mock","Starts a mock server for an API.",r=>r.option("port",{number:!0,description:"The port the server binds to."}).option("api",{string:!0,description:"The API to mock."}),async r=>{await t.instrumentPostHogEvent({command:"fern mock"}),await $_g({cliContext:t,project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),port:r.port})})}function ZWC(e,t){e.command("write-overrides","Generate a basic openapi overrides file.",r=>[r.option("api",{string:!0,description:"Only run the command on the provided API"}),r.option("exclude-models",{boolean:!0,description:"When generating the initial overrides, also stub the models (in addition to the endpoints)",default:!1})],async r=>{await t.instrumentPostHogEvent({command:"fern generate-overrides"}),await hrg({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),includeModels:!r.excludeModels,cliContext:t})})}function kWC(e,t){e.command("write-definition","Write underlying Fern Definition for OpenAPI specs and API Dependencies.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("language",{choices:Object.values(rP.GenerationLanguage),description:"Write the definition for a particular SDK language"}),async r=>{await t.instrumentPostHogEvent({command:"fern write-definition"}),await Agg({project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0,sdkLanguage:r.language}),cliContext:t,sdkLanguage:r.language})})}function eHC(e,t){e.command("docs dev","Run a local development server to preview your docs",r=>r.option("port",{number:!0,description:"Run the development server on the following port"}).option("bundle-path",{string:!0,hidden:!0,description:"Path of the local docs bundle to use"}),async r=>{let n;r.port!=null?n=r.port:n=await _fi({port:[3e3,3001,3002,3003,3004,3005,3006,3007,3008,3009,3010]});let i=r.bundlePath;await AYf({loadProject:()=>p6(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),cliContext:t,port:n,bundlePath:i})})}function tHC(e,t){e.command("jsonschema <path-to-output>","Generate JSON Schema for a specific type",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).positional("path-to-output",{type:"string",description:"Path to write JSON Schema",demandOption:!0}).option("type",{string:!0,demandOption:!0,description:"The type to generate JSON Schema for (e.g. 'MySchema' or 'mypackage.MySchema')"}),async r=>{await t.instrumentPostHogEvent({command:"fern jsonschema",properties:{output:r.output}}),await Lgg({typeLocator:r.type,project:await p6(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),jsonschemaFilepath:A2(yjr(),r.pathToOutput),cliContext:t})})}
2262
2262
  /*! Bundled license information:
2263
2263
 
2264
2264
  tmp/lib/tmp.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.45.0-rc11",
3
+ "version": "0.45.0-rc12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",