fern-api 0.61.16 → 0.61.17

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 +4 -4
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -1701,7 +1701,7 @@ ${c.indent}`:""}${lQf(o)}:${l.indent?" ":""}`;return u=!1,s=!0,l.objectItem=void
1701
1701
  `}),r.replaceAll(/\n$/g,"")}function n3S(e){return e?Ph.green(T7.radioOn):T7.radioOff}var Amo=li(tDe(),1);function wup(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var Lca=class extends L2{_run(t){this.done=t;let r=PV(this.rl),i=r.line.pipe((0,Amo.map)(this.filterInput.bind(this))),n=this.handleSubmitEvents(i);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,Amo.takeUntil)(n.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),i="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(i=`
1702
1702
  `+Ph.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?Ph.cyan(wup(t,this.opt.mask)):Ph.italic.dim("[hidden]"):this.opt.mask?wup(t,this.opt.mask):Ph.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 Jsp=li(sIs(),1),Ksp=li(tDe(),1);var Yca=class extends L2{_run(t){this.done=t,this.editorResult=new Ksp.Subject;let r=PV(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?Ph.dim("Received"):Ph.dim("Press <enter> to launch your preferred editor."),t&&(r=Ph.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,Jsp.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 Tcp=li(Dcp(),1);var Acp=li(require("readline"),1),qcp=li(Mcp(),1),lzi=class{constructor(t){this.rl||=Acp.default.createInterface(O7S(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 O7S(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let n=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw n.isTtyError=!0,n}let r=new qcp.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var kca=class extends lzi{constructor(t={}){super(t),this.log=(0,Tcp.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return Cca(this.rl,this.bottomBar.split(`
1703
1703
  `).length),this}updateBottomBar(t){return Cca(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+`
1704
- `}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&&Smo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var Ucp=li(xcp(),1),Vcp=li(yBs(),1),Wcp=li(Fcp(),1),rq=li(tDe(),1),Hcp=li(Usa(),1);var kmo=li(tDe(),1),Lcp=li(Usa(),1),ePo=function(e,t,r){return typeof e[t]!="function"?(0,kmo.of)(e):(0,kmo.from)((0,Lcp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var ela={isPlainObject:Ucp.default,set:Wcp.default,get:Vcp.default},Zmn=class extends lzi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=ela.isPlainObject(r)?{...r}:{},ela.isPlainObject(t)&&(t=Object.values(t).every(n=>ela.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,rq.from)(t):t;return this.process=i.pipe((0,rq.concatMap)(this.processQuestion.bind(this)),(0,rq.publish)()),this.process.connect(),this.process.pipe((0,rq.reduce)((n,a)=>(ela.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,rq.defer)(()=>(0,rq.of)(t).pipe((0,rq.concatMap)(this.setDefaultType.bind(this)),(0,rq.concatMap)(this.filterIfRunnable.bind(this)),(0,rq.concatMap)(()=>ePo(t,"message",this.answers)),(0,rq.concatMap)(()=>ePo(t,"default",this.answers)),(0,rq.concatMap)(()=>ePo(t,"choices",this.answers)),(0,rq.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,rq.defer)(()=>(0,rq.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,rq.defer)(()=>(0,rq.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&ela.get(this.answers,t.name)!==void 0)return(0,rq.empty)();if(t.when===!1)return(0,rq.empty)();if(typeof t.when!="function")return(0,rq.of)(t);let{answers:r}=this;return(0,rq.defer)(()=>(0,rq.from)((0,Hcp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,rq.filter)(i=>i!=null)))}};function $cp(e){let t=function(r,i){let n;try{n=new Zmn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",xca),this.registerPrompt("input",tzi),this.registerPrompt("number",Ica),this.registerPrompt("confirm",zca),this.registerPrompt("rawlist",Rca),this.registerPrompt("expand",Nca),this.registerPrompt("checkbox",Fca),this.registerPrompt("password",Lca),this.registerPrompt("editor",Yca)},t.restoreDefaultPrompts(),t}var gIs=$cp();function N7S(e,t){gIs.registerPrompt(e,t)}function F7S(){gIs.restoreDefaultPrompts()}var L7S={prompt:gIs,ui:{BottomBar:kca,Prompt:Zmn},createPromptModule:$cp,registerPrompt:N7S,restoreDefaultPrompts:F7S,Separator:Lie},tPo=L7S;var tfp=li(Gcp()),p4S="4.2.1",S5t;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay"})(S5t||(S5t={}));function _4S(e,t){if(!e)throw new Error(t)}function h4S(e){return e?.replace(/\/+$/,"")}async function y4S(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function v4S(){return new Date().getTime()}function Qlp(){return new Date().toISOString()}function rfp(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var fla=String.fromCharCode,Jlp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",yPo={};function b4S(e,t){if(!yPo[e]){yPo[e]={};for(let r=0;r<e.length;r++)yPo[e][e.charAt(r)]=r}return yPo[e][t]}var dla={compressToBase64:function(e){if(e==null)return"";let t=dla._compress(e,6,function(r){return Jlp.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:dla._decompress(e.length,32,function(t){return b4S(Jlp,e.charAt(t))})},compress:function(e){return dla._compress(e,16,function(t){return fla(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,f="",s="",o="",c=2,b=3,g=2,O=0,m=0,P;for(P=0;P<e.length;P+=1)if(f=e.charAt(P),Object.prototype.hasOwnProperty.call(i,f)||(i[f]=b++,n[f]=!0),s=o+f,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(f)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:dla._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,f=3,s="",o,c,b,g,O,m,P;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=fla(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=fla(b);break;case 2:return""}for(i[3]=P,c=P,n.push(P);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,f),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(P=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=fla(b),P=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=fla(b),P=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,f),f++),i[P])s=i[P];else if(P===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,f),f++)}}},izs=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}};var vPo="0123456789abcdef",bPo=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=vPo.charAt(this.bytes[r]>>>4),t+=vPo.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=vPo.charAt(this.bytes[r]>>>4),t+=vPo.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},nzs=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??g4S()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return bPo.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,bPo.ofInner(t)}},g4S=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Klp,Ylp=()=>O4S().toString(),O4S=()=>(Klp||(Klp=new nzs)).generate(),gPo=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},pla=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function Xlp(e){return typeof e=="object"&&(e instanceof gPo||e instanceof pla)}var azs=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new izs,this._isInitialized=!1,_4S(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=h4S(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:Xlp},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(S5t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(S5t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(S5t.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=Ylp();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(f=>f.json()).catch(f=>{this._events.emit("error",f)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!l)return;let f=l[t];return f===void 0&&(f=!1),f}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!l)return;let f=l[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let l=await this.getDecide(t,r,i,n,u),f=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:f,payloads:o}}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:Qlp(),uuid:i?.uuid?i.uuid:Ylp()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty(S5t.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty(S5t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=rfp(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(S5t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(S5t.Queue)||[];this.setPersistedProperty(S5t.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:Qlp()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${v4S()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,f=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(dla.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,f)}catch(s){throw s instanceof pla||n(),this._events.emit("error",s),s}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(l){let f=new AbortController;return setTimeout(()=>f.abort(),l),f.signal}),await y4S(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(f){throw new pla(f)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new gPo(u);return u},{...this._retryOptions,...i})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(S5t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!Xlp(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},ozs=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},uzs=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!uzs){let e=Glp();uzs=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var ifp=uzs,m4S=1152921504606847e3,P4S=["is_not"],OPo=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},U2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},szs=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=l.fetch||ifp,this.onError=l.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let f of this.featureFlags)if(t===f.key){l=f;break}if(l!==void 0)try{u=this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(f){f instanceof U2?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async f=>{try{let s=this.computeFlagLocally(f,t,r,i,n);a[f.key]=s;let o=await this.computeFeatureFlagPayloadLocally(f.key,s);o&&(u[f.key]=o)}catch(s){s instanceof U2||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new U2("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let f=this.groupTypeMapping[String(l)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new U2("Flag has unknown group type index");if(!(f in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[f];return this.matchFeatureFlagProperties(t,i[f],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,f=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of f)try{if(this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof U2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new U2("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let f=l.type,s=!1;if(f==="cohort"?s=afp(l,n,this.cohorts,this.debugMode):s=nfp(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&Zlp(t.key,r)>a/100)}getMatchingVariant(t,r){let i=Zlp(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new OPo("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof OPo&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=rfp(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function Zlp(e,t,r=""){let i=(0,tfp.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/m4S}function nfp(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new U2("Operator is_not_set is not supported")}else throw new U2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!P4S.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function f(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return klp(String(n))&&String(u).match(String(n))!==null;case"not_regex":return klp(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?f(u,String(n),a):f(u,s,a):f(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=j4S(String(n));if(s==null&&(s=efp(n)),s==null)throw new U2(`Invalid date: ${n}`);let o=efp(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new U2(`Unknown operator: ${a}`)}}function afp(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new U2("can't match cohort without a given cohort property value");let a=r[n];return ofp(a,t,r,i)}function ofp(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let f=ofp(l,t,r,i);if(n==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof U2)i&&console.debug(`Failed to compute property ${l} locally: ${f}`),u=!0;else throw f}if(u)throw new U2("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let f;l.type==="cohort"?f=afp(l,t,r,i):f=nfp(l,t);let s=l.negation||!1;if(n==="AND"){if(!f&&!s||f&&s)return!1}else if(f&&!s||!f&&s)return!0}catch(f){if(f instanceof U2)i&&console.debug(`Failed to compute property ${l} locally: ${f}`),u=!0;else throw f}if(u)throw new U2("can't match cohort without a given cohort property value");return n==="AND"}}function klp(e){try{return new RegExp(e),!0}catch{return!1}}function efp(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new U2(`${e} is in an invalid date format`)}else throw new U2(`The date provided ${e} must be a string, number, or date object`)}function j4S(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var w4S=30*1e3,S4S=50*1e3,aPn=class extends azs{constructor(t,r={}){super(t,r),this._memoryStorage=new ozs,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new szs({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:w4S,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||S4S}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):ifp(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return p4S}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture({distinctId:t,event:r,properties:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:l,uuid:f}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:f})},o=(b,g,O)=>super.getFeatureFlagsStateless(b,g,void 0,void 0,O),c=Promise.resolve().then(async()=>{if(a)return await o(t,n,l);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let b={};for(let[g,O]of Object.entries(n||{}))b[g]=String(O);return await this.getAllFlags(t,{groups:b,disableGeoip:l,onlyEvaluateLocally:!0})}return{}}).then(b=>{let g={};if(b)for(let[m,P]of Object.entries(b))g[`$feature/${m}`]=P;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:f,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,f,s);f=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,f,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,f,s,a));let g=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(g))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(g):this.distinctIdHasSentFlagCalls[r]=[g],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,locally_evaluated:b,[`$feature/${t}`]:c},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:f,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),l==null&&(l=!1),f==null&&(f=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},f=this.addLocalPersonAndGroupProperties(t,i,u,l);u=f.allPersonProperties,l=f.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},czs=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},l=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&l!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${l}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};czs.POSTHOG_ID_TAG="posthog_distinct_id";var mPo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new aPn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.61.16",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var _la=class{async sendEvent(){}async identify(){}async flush(){}};var oPn=require("fs/promises"),lfp=require("os"),ffp=require("path");var ufp=li(require("crypto")),jPo=new Uint8Array(256),PPo=jPo.length;function lzs(){return PPo>jPo.length-16&&(ufp.default.randomFillSync(jPo),PPo=0),jPo.slice(PPo,PPo+=16)}var SV=[];for(let e=0;e<256;++e)SV.push((e+256).toString(16).slice(1));function sfp(e,t=0){return SV[e[t+0]]+SV[e[t+1]]+SV[e[t+2]]+SV[e[t+3]]+"-"+SV[e[t+4]]+SV[e[t+5]]+"-"+SV[e[t+6]]+SV[e[t+7]]+"-"+SV[e[t+8]]+SV[e[t+9]]+"-"+SV[e[t+10]]+SV[e[t+11]]+SV[e[t+12]]+SV[e[t+13]]+SV[e[t+14]]+SV[e[t+15]]}var cfp=li(require("crypto")),fzs={randomUUID:cfp.default.randomUUID};function D4S(e,t,r){if(fzs.randomUUID&&!t&&!e)return fzs.randomUUID();e=e||{};let i=e.random||(e.rng||lzs)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return sfp(i)}var $ie=D4S;var E4S="id",M4S=".fern",hla=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new aPn(r),this.userId=t==null?void 0:gMs(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.61.16",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Lu(Ul.of((0,lfp.homedir)()),Qa.of(M4S),Qa.of(E4S));await Af(t)||(await(0,oPn.mkdir)((0,ffp.dirname)(t),{recursive:!0}),await(0,oPn.writeFile)(t,$ie())),this.persistedDistinctId=(await(0,oPn.readFile)(t)).toString()}return this.persistedDistinctId}};var dzs;async function uPn(){return dzs==null&&(dzs=await A4S()),dzs}async function A4S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new _la;let r=await Syo();return r!=null?new hla({token:r,posthogApiKey:e}):await Jgn()!=null?new mPo({posthogApiKey:e}):new hla({token:void 0,posthogApiKey:e})}catch{return new _la}}function yla(e,t){return function(){return e.apply(t,arguments)}}var{toString:q4S}=Object.prototype,{getPrototypeOf:_zs}=Object,SPo=(e=>t=>{let r=q4S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),D5t=e=>(e=e.toLowerCase(),t=>SPo(t)===e),DPo=e=>t=>typeof t===e,{isArray:sPn}=Array,vla=DPo("undefined");function T4S(e){return e!==null&&!vla(e)&&e.constructor!==null&&!vla(e.constructor)&&iDe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var pfp=D5t("ArrayBuffer");function C4S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&pfp(e.buffer),t}var B4S=DPo("string"),iDe=DPo("function"),_fp=DPo("number"),EPo=e=>e!==null&&typeof e=="object",x4S=e=>e===!0||e===!1,wPo=e=>{if(SPo(e)!=="object")return!1;let t=_zs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},I4S=D5t("Date"),z4S=D5t("File"),R4S=D5t("Blob"),N4S=D5t("FileList"),F4S=e=>EPo(e)&&iDe(e.pipe),L4S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||iDe(e.append)&&((t=SPo(e))==="formdata"||t==="object"&&iDe(e.toString)&&e.toString()==="[object FormData]"))},U4S=D5t("URLSearchParams"),[V4S,W4S,H4S,$4S]=["ReadableStream","Request","Response","Headers"].map(D5t),G4S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function bla(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),sPn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function hfp(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var hzi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,yfp=e=>!vla(e)&&e!==hzi;function pzs(){let{caseless:e}=yfp(this)&&this||{},t={},r=(i,n)=>{let a=e&&hfp(t,n)||n;wPo(t[a])&&wPo(i)?t[a]=pzs(t[a],i):wPo(i)?t[a]=pzs({},i):sPn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&bla(arguments[i],r);return t}var Q4S=(e,t,r,{allOwnKeys:i}={})=>(bla(t,(n,a)=>{r&&iDe(n)?e[a]=yla(n,r):e[a]=n},{allOwnKeys:i}),e),J4S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),K4S=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Y4S=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&_zs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},X4S=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},Z4S=e=>{if(!e)return null;if(sPn(e))return e;let t=e.length;if(!_fp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},k4S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&_zs(Uint8Array)),e8S=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},t8S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},r8S=D5t("HTMLFormElement"),i8S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),dfp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),n8S=D5t("RegExp"),vfp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};bla(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},a8S=e=>{vfp(e,(t,r)=>{if(iDe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(iDe(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},o8S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return sPn(e)?i(e):i(String(e).split(t)),r},u8S=()=>{},s8S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function c8S(e){return!!(e&&iDe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var l8S=e=>{let t=new Array(10),r=(i,n)=>{if(EPo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=sPn(i)?[]:{};return bla(i,(u,l)=>{let f=r(u,n+1);!vla(f)&&(a[l]=f)}),t[n]=void 0,a}}return i};return r(e,0)},f8S=D5t("AsyncFunction"),d8S=e=>e&&(EPo(e)||iDe(e))&&iDe(e.then)&&iDe(e.catch),bfp=((e,t)=>e?setImmediate:t?((r,i)=>(hzi.addEventListener("message",({source:n,data:a})=>{n===hzi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),hzi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",iDe(hzi.postMessage)),p8S=typeof queueMicrotask<"u"?queueMicrotask.bind(hzi):typeof process<"u"&&process.nextTick||bfp,ds={isArray:sPn,isArrayBuffer:pfp,isBuffer:T4S,isFormData:L4S,isArrayBufferView:C4S,isString:B4S,isNumber:_fp,isBoolean:x4S,isObject:EPo,isPlainObject:wPo,isReadableStream:V4S,isRequest:W4S,isResponse:H4S,isHeaders:$4S,isUndefined:vla,isDate:I4S,isFile:z4S,isBlob:R4S,isRegExp:n8S,isFunction:iDe,isStream:F4S,isURLSearchParams:U4S,isTypedArray:k4S,isFileList:N4S,forEach:bla,merge:pzs,extend:Q4S,trim:G4S,stripBOM:J4S,inherits:K4S,toFlatObject:Y4S,kindOf:SPo,kindOfTest:D5t,endsWith:X4S,toArray:Z4S,forEachEntry:e8S,matchAll:t8S,isHTMLForm:r8S,hasOwnProperty:dfp,hasOwnProp:dfp,reduceDescriptors:vfp,freezeMethods:a8S,toObjectSet:o8S,toCamelCase:i8S,noop:u8S,toFiniteNumber:s8S,findKey:hfp,global:hzi,isContextDefined:yfp,isSpecCompliantForm:c8S,toJSONObject:l8S,isAsyncFn:f8S,isThenable:d8S,setImmediate:bfp,asap:p8S};function cPn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}ds.inherits(cPn,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:ds.toJSONObject(this.config),code:this.code,status:this.status}}});var gfp=cPn.prototype,Ofp={};["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=>{Ofp[e]={value:e}});Object.defineProperties(cPn,Ofp);Object.defineProperty(gfp,"isAxiosError",{value:!0});cPn.from=(e,t,r,i,n,a)=>{let u=Object.create(gfp);return ds.toFlatObject(e,u,function(f){return f!==Error.prototype},l=>l!=="isAxiosError"),cPn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var Dp=cPn;var mfp=li(Ria(),1),MPo=mfp.default;function hzs(e){return ds.isPlainObject(e)||ds.isArray(e)}function jfp(e){return ds.endsWith(e,"[]")?e.slice(0,-2):e}function Pfp(e,t,r){return e?e.concat(t).map(function(n,a){return n=jfp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function _8S(e){return ds.isArray(e)&&!e.some(hzs)}var h8S=ds.toFlatObject(ds,{},null,function(t){return/^is[A-Z]/.test(t)});function y8S(e,t,r){if(!ds.isObject(e))throw new TypeError("target must be an object");t=t||new(MPo||FormData),r=ds.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,P){return!ds.isUndefined(P[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&ds.isSpecCompliantForm(t);if(!ds.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(ds.isDate(O))return O.toISOString();if(!f&&ds.isBlob(O))throw new Dp("Blob is not supported. Use a Buffer instead.");return ds.isArrayBuffer(O)||ds.isTypedArray(O)?f&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,P){let E=O;if(O&&!P&&typeof O=="object"){if(ds.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(ds.isArray(O)&&_8S(O)||(ds.isFileList(O)||ds.endsWith(m,"[]"))&&(E=ds.toArray(O)))return m=jfp(m),E.forEach(function(A,D){!(ds.isUndefined(A)||A===null)&&t.append(u===!0?Pfp([m],D,a):u===null?m:m+"[]",s(A))}),!1}return hzs(O)?!0:(t.append(Pfp(P,m,a),s(O)),!1)}let c=[],b=Object.assign(h8S,{defaultVisitor:o,convertValue:s,isVisitable:hzs});function g(O,m){if(!ds.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),ds.forEach(O,function(E,q){(!(ds.isUndefined(E)||E===null)&&n.call(t,E,ds.isString(q)?q.trim():q,m,b))===!0&&g(E,m?m.concat(q):[q])}),c.pop()}}if(!ds.isObject(e))throw new TypeError("data must be an object");return g(e),t}var jfi=y8S;function wfp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Sfp(e,t){this._pairs=[],e&&jfi(e,this,t)}var Dfp=Sfp.prototype;Dfp.append=function(t,r){this._pairs.push([t,r])};Dfp.toString=function(t){let r=t?function(i){return t.call(this,i,wfp)}:wfp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var Efp=Sfp;function v8S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function yzi(e,t,r){if(!t)return e;let i=r&&r.encode||v8S;ds.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=ds.isURLSearchParams(t)?t.toString():new Efp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var yzs=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ds.forEach(this.handlers,function(i){i!==null&&t(i)})}},vzs=yzs;var lPn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Tfp=li(require("crypto"),1);var Mfp=li(require("url"),1),Afp=Mfp.default.URLSearchParams;var bzs="abcdefghijklmnopqrstuvwxyz",qfp="0123456789",Cfp={DIGIT:qfp,ALPHA:bzs,ALPHA_DIGIT:bzs+bzs.toUpperCase()+qfp},b8S=(e=16,t=Cfp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);Tfp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},Bfp={isNode:!0,classes:{URLSearchParams:Afp,FormData:MPo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:Cfp,generateString:b8S,protocols:["http","https","file","data"]};var mzs={};Oo(mzs,{hasBrowserEnv:()=>Ozs,hasStandardBrowserEnv:()=>g8S,hasStandardBrowserWebWorkerEnv:()=>O8S,navigator:()=>gzs,origin:()=>m8S});var Ozs=typeof window<"u"&&typeof document<"u",gzs=typeof navigator=="object"&&navigator||void 0,g8S=Ozs&&(!gzs||["ReactNative","NativeScript","NS"].indexOf(gzs.product)<0),O8S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",m8S=Ozs&&window.location.href||"http://localhost";var qM={...mzs,...Bfp};function Pzs(e,t){return jfi(e,new qM.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return qM.isNode&&ds.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function P8S(e){return ds.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function j8S(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function w8S(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),f=a>=r.length;return u=!u&&ds.isArray(n)?n.length:u,f?(ds.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!ds.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&ds.isArray(n[u])&&(n[u]=j8S(n[u])),!l)}if(ds.isFormData(e)&&ds.isFunction(e.entries)){let r={};return ds.forEachEntry(e,(i,n)=>{t(P8S(i),n,r,0)}),r}return null}var APo=w8S;function S8S(e,t,r){if(ds.isString(e))try{return(t||JSON.parse)(e),ds.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var jzs={transitional:lPn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=ds.isObject(t);if(a&&ds.isHTMLForm(t)&&(t=new FormData(t)),ds.isFormData(t))return n?JSON.stringify(APo(t)):t;if(ds.isArrayBuffer(t)||ds.isBuffer(t)||ds.isStream(t)||ds.isFile(t)||ds.isBlob(t)||ds.isReadableStream(t))return t;if(ds.isArrayBufferView(t))return t.buffer;if(ds.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return Pzs(t,this.formSerializer).toString();if((l=ds.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return jfi(l?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),S8S(t)):t}],transformResponse:[function(t){let r=this.transitional||jzs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(ds.isResponse(t)||ds.isReadableStream(t))return t;if(t&&ds.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?Dp.from(l,Dp.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:qM.classes.FormData,Blob:qM.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ds.forEach(["delete","get","head","post","put","patch"],e=>{jzs.headers[e]={}});var fPn=jzs;var D8S=ds.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"]),xfp=e=>{let t={},r,i,n;return e&&e.split(`
1704
+ `}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&&Smo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var Ucp=li(xcp(),1),Vcp=li(yBs(),1),Wcp=li(Fcp(),1),rq=li(tDe(),1),Hcp=li(Usa(),1);var kmo=li(tDe(),1),Lcp=li(Usa(),1),ePo=function(e,t,r){return typeof e[t]!="function"?(0,kmo.of)(e):(0,kmo.from)((0,Lcp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var ela={isPlainObject:Ucp.default,set:Wcp.default,get:Vcp.default},Zmn=class extends lzi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=ela.isPlainObject(r)?{...r}:{},ela.isPlainObject(t)&&(t=Object.values(t).every(n=>ela.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,rq.from)(t):t;return this.process=i.pipe((0,rq.concatMap)(this.processQuestion.bind(this)),(0,rq.publish)()),this.process.connect(),this.process.pipe((0,rq.reduce)((n,a)=>(ela.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,rq.defer)(()=>(0,rq.of)(t).pipe((0,rq.concatMap)(this.setDefaultType.bind(this)),(0,rq.concatMap)(this.filterIfRunnable.bind(this)),(0,rq.concatMap)(()=>ePo(t,"message",this.answers)),(0,rq.concatMap)(()=>ePo(t,"default",this.answers)),(0,rq.concatMap)(()=>ePo(t,"choices",this.answers)),(0,rq.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,rq.defer)(()=>(0,rq.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,rq.defer)(()=>(0,rq.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&ela.get(this.answers,t.name)!==void 0)return(0,rq.empty)();if(t.when===!1)return(0,rq.empty)();if(typeof t.when!="function")return(0,rq.of)(t);let{answers:r}=this;return(0,rq.defer)(()=>(0,rq.from)((0,Hcp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,rq.filter)(i=>i!=null)))}};function $cp(e){let t=function(r,i){let n;try{n=new Zmn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",xca),this.registerPrompt("input",tzi),this.registerPrompt("number",Ica),this.registerPrompt("confirm",zca),this.registerPrompt("rawlist",Rca),this.registerPrompt("expand",Nca),this.registerPrompt("checkbox",Fca),this.registerPrompt("password",Lca),this.registerPrompt("editor",Yca)},t.restoreDefaultPrompts(),t}var gIs=$cp();function N7S(e,t){gIs.registerPrompt(e,t)}function F7S(){gIs.restoreDefaultPrompts()}var L7S={prompt:gIs,ui:{BottomBar:kca,Prompt:Zmn},createPromptModule:$cp,registerPrompt:N7S,restoreDefaultPrompts:F7S,Separator:Lie},tPo=L7S;var tfp=li(Gcp()),p4S="4.2.1",S5t;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay"})(S5t||(S5t={}));function _4S(e,t){if(!e)throw new Error(t)}function h4S(e){return e?.replace(/\/+$/,"")}async function y4S(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function v4S(){return new Date().getTime()}function Qlp(){return new Date().toISOString()}function rfp(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var fla=String.fromCharCode,Jlp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",yPo={};function b4S(e,t){if(!yPo[e]){yPo[e]={};for(let r=0;r<e.length;r++)yPo[e][e.charAt(r)]=r}return yPo[e][t]}var dla={compressToBase64:function(e){if(e==null)return"";let t=dla._compress(e,6,function(r){return Jlp.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:dla._decompress(e.length,32,function(t){return b4S(Jlp,e.charAt(t))})},compress:function(e){return dla._compress(e,16,function(t){return fla(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,f="",s="",o="",c=2,b=3,g=2,O=0,m=0,P;for(P=0;P<e.length;P+=1)if(f=e.charAt(P),Object.prototype.hasOwnProperty.call(i,f)||(i[f]=b++,n[f]=!0),s=o+f,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(f)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:dla._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,f=3,s="",o,c,b,g,O,m,P;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=fla(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=fla(b);break;case 2:return""}for(i[3]=P,c=P,n.push(P);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,f),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(P=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=fla(b),P=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=fla(b),P=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,f),f++),i[P])s=i[P];else if(P===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,f),f++)}}},izs=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}};var vPo="0123456789abcdef",bPo=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=vPo.charAt(this.bytes[r]>>>4),t+=vPo.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=vPo.charAt(this.bytes[r]>>>4),t+=vPo.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},nzs=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??g4S()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return bPo.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,bPo.ofInner(t)}},g4S=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Klp,Ylp=()=>O4S().toString(),O4S=()=>(Klp||(Klp=new nzs)).generate(),gPo=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},pla=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function Xlp(e){return typeof e=="object"&&(e instanceof gPo||e instanceof pla)}var azs=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new izs,this._isInitialized=!1,_4S(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=h4S(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:Xlp},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(S5t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(S5t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(S5t.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=Ylp();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(f=>f.json()).catch(f=>{this._events.emit("error",f)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!l)return;let f=l[t];return f===void 0&&(f=!1),f}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!l)return;let f=l[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let l=await this.getDecide(t,r,i,n,u),f=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:f,payloads:o}}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:Qlp(),uuid:i?.uuid?i.uuid:Ylp()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty(S5t.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty(S5t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=rfp(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(S5t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(S5t.Queue)||[];this.setPersistedProperty(S5t.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:Qlp()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${v4S()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,f=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(dla.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,f)}catch(s){throw s instanceof pla||n(),this._events.emit("error",s),s}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(l){let f=new AbortController;return setTimeout(()=>f.abort(),l),f.signal}),await y4S(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(f){throw new pla(f)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new gPo(u);return u},{...this._retryOptions,...i})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(S5t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!Xlp(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},ozs=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},uzs=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!uzs){let e=Glp();uzs=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var ifp=uzs,m4S=1152921504606847e3,P4S=["is_not"],OPo=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},U2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},szs=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=l.fetch||ifp,this.onError=l.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let f of this.featureFlags)if(t===f.key){l=f;break}if(l!==void 0)try{u=this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(f){f instanceof U2?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async f=>{try{let s=this.computeFlagLocally(f,t,r,i,n);a[f.key]=s;let o=await this.computeFeatureFlagPayloadLocally(f.key,s);o&&(u[f.key]=o)}catch(s){s instanceof U2||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new U2("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let f=this.groupTypeMapping[String(l)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new U2("Flag has unknown group type index");if(!(f in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[f];return this.matchFeatureFlagProperties(t,i[f],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,f=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of f)try{if(this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof U2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new U2("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let f=l.type,s=!1;if(f==="cohort"?s=afp(l,n,this.cohorts,this.debugMode):s=nfp(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&Zlp(t.key,r)>a/100)}getMatchingVariant(t,r){let i=Zlp(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new OPo("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof OPo&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=rfp(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function Zlp(e,t,r=""){let i=(0,tfp.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/m4S}function nfp(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new U2("Operator is_not_set is not supported")}else throw new U2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!P4S.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function f(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return klp(String(n))&&String(u).match(String(n))!==null;case"not_regex":return klp(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?f(u,String(n),a):f(u,s,a):f(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=j4S(String(n));if(s==null&&(s=efp(n)),s==null)throw new U2(`Invalid date: ${n}`);let o=efp(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new U2(`Unknown operator: ${a}`)}}function afp(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new U2("can't match cohort without a given cohort property value");let a=r[n];return ofp(a,t,r,i)}function ofp(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let f=ofp(l,t,r,i);if(n==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof U2)i&&console.debug(`Failed to compute property ${l} locally: ${f}`),u=!0;else throw f}if(u)throw new U2("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let f;l.type==="cohort"?f=afp(l,t,r,i):f=nfp(l,t);let s=l.negation||!1;if(n==="AND"){if(!f&&!s||f&&s)return!1}else if(f&&!s||!f&&s)return!0}catch(f){if(f instanceof U2)i&&console.debug(`Failed to compute property ${l} locally: ${f}`),u=!0;else throw f}if(u)throw new U2("can't match cohort without a given cohort property value");return n==="AND"}}function klp(e){try{return new RegExp(e),!0}catch{return!1}}function efp(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new U2(`${e} is in an invalid date format`)}else throw new U2(`The date provided ${e} must be a string, number, or date object`)}function j4S(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var w4S=30*1e3,S4S=50*1e3,aPn=class extends azs{constructor(t,r={}){super(t,r),this._memoryStorage=new ozs,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new szs({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:w4S,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||S4S}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):ifp(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return p4S}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture({distinctId:t,event:r,properties:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:l,uuid:f}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:f})},o=(b,g,O)=>super.getFeatureFlagsStateless(b,g,void 0,void 0,O),c=Promise.resolve().then(async()=>{if(a)return await o(t,n,l);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let b={};for(let[g,O]of Object.entries(n||{}))b[g]=String(O);return await this.getAllFlags(t,{groups:b,disableGeoip:l,onlyEvaluateLocally:!0})}return{}}).then(b=>{let g={};if(b)for(let[m,P]of Object.entries(b))g[`$feature/${m}`]=P;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:f,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,f,s);f=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,f,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,f,s,a));let g=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(g))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(g):this.distinctIdHasSentFlagCalls[r]=[g],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,locally_evaluated:b,[`$feature/${t}`]:c},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:f,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),l==null&&(l=!1),f==null&&(f=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},f=this.addLocalPersonAndGroupProperties(t,i,u,l);u=f.allPersonProperties,l=f.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},czs=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},l=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&l!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${l}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};czs.POSTHOG_ID_TAG="posthog_distinct_id";var mPo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new aPn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.61.17",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var _la=class{async sendEvent(){}async identify(){}async flush(){}};var oPn=require("fs/promises"),lfp=require("os"),ffp=require("path");var ufp=li(require("crypto")),jPo=new Uint8Array(256),PPo=jPo.length;function lzs(){return PPo>jPo.length-16&&(ufp.default.randomFillSync(jPo),PPo=0),jPo.slice(PPo,PPo+=16)}var SV=[];for(let e=0;e<256;++e)SV.push((e+256).toString(16).slice(1));function sfp(e,t=0){return SV[e[t+0]]+SV[e[t+1]]+SV[e[t+2]]+SV[e[t+3]]+"-"+SV[e[t+4]]+SV[e[t+5]]+"-"+SV[e[t+6]]+SV[e[t+7]]+"-"+SV[e[t+8]]+SV[e[t+9]]+"-"+SV[e[t+10]]+SV[e[t+11]]+SV[e[t+12]]+SV[e[t+13]]+SV[e[t+14]]+SV[e[t+15]]}var cfp=li(require("crypto")),fzs={randomUUID:cfp.default.randomUUID};function D4S(e,t,r){if(fzs.randomUUID&&!t&&!e)return fzs.randomUUID();e=e||{};let i=e.random||(e.rng||lzs)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return sfp(i)}var $ie=D4S;var E4S="id",M4S=".fern",hla=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new aPn(r),this.userId=t==null?void 0:gMs(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.61.17",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Lu(Ul.of((0,lfp.homedir)()),Qa.of(M4S),Qa.of(E4S));await Af(t)||(await(0,oPn.mkdir)((0,ffp.dirname)(t),{recursive:!0}),await(0,oPn.writeFile)(t,$ie())),this.persistedDistinctId=(await(0,oPn.readFile)(t)).toString()}return this.persistedDistinctId}};var dzs;async function uPn(){return dzs==null&&(dzs=await A4S()),dzs}async function A4S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new _la;let r=await Syo();return r!=null?new hla({token:r,posthogApiKey:e}):await Jgn()!=null?new mPo({posthogApiKey:e}):new hla({token:void 0,posthogApiKey:e})}catch{return new _la}}function yla(e,t){return function(){return e.apply(t,arguments)}}var{toString:q4S}=Object.prototype,{getPrototypeOf:_zs}=Object,SPo=(e=>t=>{let r=q4S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),D5t=e=>(e=e.toLowerCase(),t=>SPo(t)===e),DPo=e=>t=>typeof t===e,{isArray:sPn}=Array,vla=DPo("undefined");function T4S(e){return e!==null&&!vla(e)&&e.constructor!==null&&!vla(e.constructor)&&iDe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var pfp=D5t("ArrayBuffer");function C4S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&pfp(e.buffer),t}var B4S=DPo("string"),iDe=DPo("function"),_fp=DPo("number"),EPo=e=>e!==null&&typeof e=="object",x4S=e=>e===!0||e===!1,wPo=e=>{if(SPo(e)!=="object")return!1;let t=_zs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},I4S=D5t("Date"),z4S=D5t("File"),R4S=D5t("Blob"),N4S=D5t("FileList"),F4S=e=>EPo(e)&&iDe(e.pipe),L4S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||iDe(e.append)&&((t=SPo(e))==="formdata"||t==="object"&&iDe(e.toString)&&e.toString()==="[object FormData]"))},U4S=D5t("URLSearchParams"),[V4S,W4S,H4S,$4S]=["ReadableStream","Request","Response","Headers"].map(D5t),G4S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function bla(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),sPn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function hfp(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var hzi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,yfp=e=>!vla(e)&&e!==hzi;function pzs(){let{caseless:e}=yfp(this)&&this||{},t={},r=(i,n)=>{let a=e&&hfp(t,n)||n;wPo(t[a])&&wPo(i)?t[a]=pzs(t[a],i):wPo(i)?t[a]=pzs({},i):sPn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&bla(arguments[i],r);return t}var Q4S=(e,t,r,{allOwnKeys:i}={})=>(bla(t,(n,a)=>{r&&iDe(n)?e[a]=yla(n,r):e[a]=n},{allOwnKeys:i}),e),J4S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),K4S=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Y4S=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&_zs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},X4S=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},Z4S=e=>{if(!e)return null;if(sPn(e))return e;let t=e.length;if(!_fp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},k4S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&_zs(Uint8Array)),e8S=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},t8S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},r8S=D5t("HTMLFormElement"),i8S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),dfp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),n8S=D5t("RegExp"),vfp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};bla(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},a8S=e=>{vfp(e,(t,r)=>{if(iDe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(iDe(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},o8S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return sPn(e)?i(e):i(String(e).split(t)),r},u8S=()=>{},s8S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function c8S(e){return!!(e&&iDe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var l8S=e=>{let t=new Array(10),r=(i,n)=>{if(EPo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=sPn(i)?[]:{};return bla(i,(u,l)=>{let f=r(u,n+1);!vla(f)&&(a[l]=f)}),t[n]=void 0,a}}return i};return r(e,0)},f8S=D5t("AsyncFunction"),d8S=e=>e&&(EPo(e)||iDe(e))&&iDe(e.then)&&iDe(e.catch),bfp=((e,t)=>e?setImmediate:t?((r,i)=>(hzi.addEventListener("message",({source:n,data:a})=>{n===hzi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),hzi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",iDe(hzi.postMessage)),p8S=typeof queueMicrotask<"u"?queueMicrotask.bind(hzi):typeof process<"u"&&process.nextTick||bfp,ds={isArray:sPn,isArrayBuffer:pfp,isBuffer:T4S,isFormData:L4S,isArrayBufferView:C4S,isString:B4S,isNumber:_fp,isBoolean:x4S,isObject:EPo,isPlainObject:wPo,isReadableStream:V4S,isRequest:W4S,isResponse:H4S,isHeaders:$4S,isUndefined:vla,isDate:I4S,isFile:z4S,isBlob:R4S,isRegExp:n8S,isFunction:iDe,isStream:F4S,isURLSearchParams:U4S,isTypedArray:k4S,isFileList:N4S,forEach:bla,merge:pzs,extend:Q4S,trim:G4S,stripBOM:J4S,inherits:K4S,toFlatObject:Y4S,kindOf:SPo,kindOfTest:D5t,endsWith:X4S,toArray:Z4S,forEachEntry:e8S,matchAll:t8S,isHTMLForm:r8S,hasOwnProperty:dfp,hasOwnProp:dfp,reduceDescriptors:vfp,freezeMethods:a8S,toObjectSet:o8S,toCamelCase:i8S,noop:u8S,toFiniteNumber:s8S,findKey:hfp,global:hzi,isContextDefined:yfp,isSpecCompliantForm:c8S,toJSONObject:l8S,isAsyncFn:f8S,isThenable:d8S,setImmediate:bfp,asap:p8S};function cPn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}ds.inherits(cPn,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:ds.toJSONObject(this.config),code:this.code,status:this.status}}});var gfp=cPn.prototype,Ofp={};["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=>{Ofp[e]={value:e}});Object.defineProperties(cPn,Ofp);Object.defineProperty(gfp,"isAxiosError",{value:!0});cPn.from=(e,t,r,i,n,a)=>{let u=Object.create(gfp);return ds.toFlatObject(e,u,function(f){return f!==Error.prototype},l=>l!=="isAxiosError"),cPn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var Dp=cPn;var mfp=li(Ria(),1),MPo=mfp.default;function hzs(e){return ds.isPlainObject(e)||ds.isArray(e)}function jfp(e){return ds.endsWith(e,"[]")?e.slice(0,-2):e}function Pfp(e,t,r){return e?e.concat(t).map(function(n,a){return n=jfp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function _8S(e){return ds.isArray(e)&&!e.some(hzs)}var h8S=ds.toFlatObject(ds,{},null,function(t){return/^is[A-Z]/.test(t)});function y8S(e,t,r){if(!ds.isObject(e))throw new TypeError("target must be an object");t=t||new(MPo||FormData),r=ds.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,P){return!ds.isUndefined(P[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&ds.isSpecCompliantForm(t);if(!ds.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(ds.isDate(O))return O.toISOString();if(!f&&ds.isBlob(O))throw new Dp("Blob is not supported. Use a Buffer instead.");return ds.isArrayBuffer(O)||ds.isTypedArray(O)?f&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,P){let E=O;if(O&&!P&&typeof O=="object"){if(ds.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(ds.isArray(O)&&_8S(O)||(ds.isFileList(O)||ds.endsWith(m,"[]"))&&(E=ds.toArray(O)))return m=jfp(m),E.forEach(function(A,D){!(ds.isUndefined(A)||A===null)&&t.append(u===!0?Pfp([m],D,a):u===null?m:m+"[]",s(A))}),!1}return hzs(O)?!0:(t.append(Pfp(P,m,a),s(O)),!1)}let c=[],b=Object.assign(h8S,{defaultVisitor:o,convertValue:s,isVisitable:hzs});function g(O,m){if(!ds.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),ds.forEach(O,function(E,q){(!(ds.isUndefined(E)||E===null)&&n.call(t,E,ds.isString(q)?q.trim():q,m,b))===!0&&g(E,m?m.concat(q):[q])}),c.pop()}}if(!ds.isObject(e))throw new TypeError("data must be an object");return g(e),t}var jfi=y8S;function wfp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Sfp(e,t){this._pairs=[],e&&jfi(e,this,t)}var Dfp=Sfp.prototype;Dfp.append=function(t,r){this._pairs.push([t,r])};Dfp.toString=function(t){let r=t?function(i){return t.call(this,i,wfp)}:wfp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var Efp=Sfp;function v8S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function yzi(e,t,r){if(!t)return e;let i=r&&r.encode||v8S;ds.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=ds.isURLSearchParams(t)?t.toString():new Efp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var yzs=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ds.forEach(this.handlers,function(i){i!==null&&t(i)})}},vzs=yzs;var lPn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Tfp=li(require("crypto"),1);var Mfp=li(require("url"),1),Afp=Mfp.default.URLSearchParams;var bzs="abcdefghijklmnopqrstuvwxyz",qfp="0123456789",Cfp={DIGIT:qfp,ALPHA:bzs,ALPHA_DIGIT:bzs+bzs.toUpperCase()+qfp},b8S=(e=16,t=Cfp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);Tfp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},Bfp={isNode:!0,classes:{URLSearchParams:Afp,FormData:MPo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:Cfp,generateString:b8S,protocols:["http","https","file","data"]};var mzs={};Oo(mzs,{hasBrowserEnv:()=>Ozs,hasStandardBrowserEnv:()=>g8S,hasStandardBrowserWebWorkerEnv:()=>O8S,navigator:()=>gzs,origin:()=>m8S});var Ozs=typeof window<"u"&&typeof document<"u",gzs=typeof navigator=="object"&&navigator||void 0,g8S=Ozs&&(!gzs||["ReactNative","NativeScript","NS"].indexOf(gzs.product)<0),O8S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",m8S=Ozs&&window.location.href||"http://localhost";var qM={...mzs,...Bfp};function Pzs(e,t){return jfi(e,new qM.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return qM.isNode&&ds.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function P8S(e){return ds.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function j8S(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function w8S(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),f=a>=r.length;return u=!u&&ds.isArray(n)?n.length:u,f?(ds.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!ds.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&ds.isArray(n[u])&&(n[u]=j8S(n[u])),!l)}if(ds.isFormData(e)&&ds.isFunction(e.entries)){let r={};return ds.forEachEntry(e,(i,n)=>{t(P8S(i),n,r,0)}),r}return null}var APo=w8S;function S8S(e,t,r){if(ds.isString(e))try{return(t||JSON.parse)(e),ds.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var jzs={transitional:lPn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=ds.isObject(t);if(a&&ds.isHTMLForm(t)&&(t=new FormData(t)),ds.isFormData(t))return n?JSON.stringify(APo(t)):t;if(ds.isArrayBuffer(t)||ds.isBuffer(t)||ds.isStream(t)||ds.isFile(t)||ds.isBlob(t)||ds.isReadableStream(t))return t;if(ds.isArrayBufferView(t))return t.buffer;if(ds.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return Pzs(t,this.formSerializer).toString();if((l=ds.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return jfi(l?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),S8S(t)):t}],transformResponse:[function(t){let r=this.transitional||jzs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(ds.isResponse(t)||ds.isReadableStream(t))return t;if(t&&ds.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?Dp.from(l,Dp.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:qM.classes.FormData,Blob:qM.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ds.forEach(["delete","get","head","post","put","patch"],e=>{jzs.headers[e]={}});var fPn=jzs;var D8S=ds.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"]),xfp=e=>{let t={},r,i,n;return e&&e.split(`
1705
1705
  `).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&D8S[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var Ifp=Symbol("internals");function gla(e){return e&&String(e).trim().toLowerCase()}function qPo(e){return e===!1||e==null?e:ds.isArray(e)?e.map(qPo):String(e)}function E8S(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,i;for(;i=r.exec(e);)t[i[1]]=i[2];return t}var M8S=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function wzs(e,t,r,i,n){if(ds.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!ds.isString(t)){if(ds.isString(i))return t.indexOf(i)!==-1;if(ds.isRegExp(i))return i.test(t)}}function A8S(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function q8S(e,t){let r=ds.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,u){return this[i].call(this,t,n,a,u)},configurable:!0})})}var dPn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(l,f,s){let o=gla(f);if(!o)throw new Error("header name must be a non-empty string");let c=ds.findKey(n,o);(!c||n[c]===void 0||s===!0||s===void 0&&n[c]!==!1)&&(n[c||f]=qPo(l))}let u=(l,f)=>ds.forEach(l,(s,o)=>a(s,o,f));if(ds.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(ds.isString(t)&&(t=t.trim())&&!M8S(t))u(xfp(t),r);else if(ds.isHeaders(t))for(let[l,f]of t.entries())a(f,l,i);else t!=null&&a(r,t,i);return this}get(t,r){if(t=gla(t),t){let i=ds.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return E8S(n);if(ds.isFunction(r))return r.call(this,n,i);if(ds.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=gla(t),t){let i=ds.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||wzs(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=gla(u),u){let l=ds.findKey(i,u);l&&(!r||wzs(i,i[l],l,r))&&(delete i[l],n=!0)}}return ds.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||wzs(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return ds.forEach(this,(n,a)=>{let u=ds.findKey(i,a);if(u){r[u]=qPo(n),delete r[a];return}let l=t?A8S(a):String(a).trim();l!==a&&delete r[a],r[l]=qPo(n),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return ds.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&ds.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
1706
1706
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[Ifp]=this[Ifp]={accessors:{}}).accessors,n=this.prototype;function a(u){let l=gla(u);i[l]||(q8S(n,u),i[l]=!0)}return ds.isArray(t)?t.forEach(a):a(t),this}};dPn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ds.reduceDescriptors(dPn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});ds.freezeMethods(dPn);var gz=dPn;function Ola(e,t){let r=this||fPn,i=t||r,n=gz.from(i.headers),a=i.data;return ds.forEach(e,function(l){a=l.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function mla(e){return!!(e&&e.__CANCEL__)}function zfp(e,t,r){Dp.call(this,e??"canceled",Dp.ERR_CANCELED,t,r),this.name="CanceledError"}ds.inherits(zfp,Dp,{__CANCEL__:!0});var nDe=zfp;function nXt(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new Dp("Request failed with status code "+r.status,[Dp.ERR_BAD_REQUEST,Dp.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Szs(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Dzs(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function vzi(e,t,r){let i=!Szs(t);return e&&i||r==!1?Dzs(e,t):t}var Zfp=li(rla(),1),kfp=li(require("http"),1),edp=li(require("https"),1),tdp=li(require("util"),1),rdp=li(BIs(),1),QJr=li(require("zlib"),1);var bzi="1.8.2";function Pla(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var T8S=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function Ezs(e,t,r){let i=r&&r.Blob||qM.classes.Blob,n=Pla(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=T8S.exec(e);if(!a)throw new Dp("Invalid URL",Dp.ERR_INVALID_URL);let u=a[1],l=a[2],f=a[3],s=Buffer.from(decodeURIComponent(f),l?"base64":"utf8");if(t){if(!i)throw new Dp("Blob is not supported",Dp.ERR_NOT_SUPPORT);return new i([s],{type:u})}return s}throw new Dp("Unsupported protocol "+n,Dp.ERR_NOT_SUPPORT)}var gzi=li(require("stream"),1);var Rfp=li(require("stream"),1);var Mzs=Symbol("internals"),Azs=class extends Rfp.default.Transform{constructor(t){t=ds.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!ds.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[Mzs]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",i=>{i==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[Mzs];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[Mzs],a=n.maxRate,u=this.readableHighWaterMark,l=n.timeWindow,f=1e3/l,s=a/f,o=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,c=(g,O)=>{let m=Buffer.byteLength(g);n.bytesSeen+=m,n.bytes+=m,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(g)?process.nextTick(O):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(O)}},b=(g,O)=>{let m=Buffer.byteLength(g),P=null,E=u,q,A=0;if(a){let D=Date.now();(!n.ts||(A=D-n.ts)>=l)&&(n.ts=D,q=s-n.bytes,n.bytes=q<0?-q:0,A=0),q=s-n.bytes}if(a){if(q<=0)return setTimeout(()=>{O(null,g)},l-A);q<E&&(E=q)}E&&m>E&&m-E>o&&(P=g.subarray(E),g=g.subarray(0,E)),c(g,P?()=>{process.nextTick(O,null,P)}:O)};b(t,function g(O,m){if(O)return i(O);m?b(m,g):i(null)})}},qzs=Azs;var idp=require("events");var Ffp=li(require("util"),1),Lfp=require("stream");var{asyncIterator:Nfp}=Symbol,C8S=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[Nfp]?yield*e[Nfp]():yield e},TPo=C8S;var B8S=qM.ALPHABET.ALPHA_DIGIT+"-_",jla=typeof TextEncoder=="function"?new TextEncoder:new Ffp.default.TextEncoder,wfi=`\r
1707
1707
  `,x8S=jla.encode(wfi),I8S=2,Tzs=class{constructor(t,r){let{escapeName:i}=this.constructor,n=ds.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${wfi}`;n?r=jla.encode(String(r).replace(/\r?\n|\r\n?/g,wfi)):a+=`Content-Type: ${r.type||"application/octet-stream"}${wfi}`,this.headers=jla.encode(a+wfi),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+I8S,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;ds.isTypedArray(t)?yield t:yield*TPo(t),yield x8S}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},z8S=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+qM.generateString(n,B8S)}=r||{};if(!ds.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=jla.encode("--"+a+wfi),l=jla.encode("--"+a+"--"+wfi+wfi),f=l.byteLength,s=Array.from(e.entries()).map(([c,b])=>{let g=new Tzs(c,b);return f+=g.size,g});f+=u.byteLength*s.length,f=ds.toFiniteNumber(f);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(o["Content-Length"]=f),t&&t(o),Lfp.Readable.from(async function*(){for(let c of s)yield u,yield*c.encode();yield l}())},Ufp=z8S;var Vfp=li(require("stream"),1),Czs=class extends Vfp.default.Transform{__transform(t,r,i){this.push(t),i()}_transform(t,r,i){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let n=Buffer.alloc(2);n[0]=120,n[1]=156,this.push(n,r)}this.__transform(t,r,i)}},Wfp=Czs;var R8S=(e,t)=>ds.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,Hfp=R8S;function N8S(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,u;return t=t!==void 0?t:1e3,function(f){let s=Date.now(),o=i[a];u||(u=s),r[n]=f,i[n]=s;let c=a,b=0;for(;c!==n;)b+=r[c++],c=c%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-u<t)return;let g=o&&s-o;return g?Math.round(b*1e3/g):void 0}}var $fp=N8S;function F8S(e,t){let r=0,i=1e3/t,n,a,u=(s,o=Date.now())=>{r=o,n=null,a&&(clearTimeout(a),a=null),e.apply(null,s)};return[(...s)=>{let o=Date.now(),c=o-r;c>=i?u(s,o):(n=s,a||(a=setTimeout(()=>{a=null,u(n)},i-c)))},()=>n&&u(n)]}var Gfp=F8S;var GJr=(e,t,r=3)=>{let i=0,n=$fp(50,250);return Gfp(a=>{let u=a.loaded,l=a.lengthComputable?a.total:void 0,f=u-i,s=n(f),o=u<=l;i=u;let c={loaded:u,total:l,progress:l?u/l:void 0,bytes:f,rate:s||void 0,estimated:s&&l&&o?(l-u)/s:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(c)},r)},pPn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},_Pn=e=>(...t)=>ds.asap(()=>e(...t));var Qfp={flush:QJr.default.constants.Z_SYNC_FLUSH,finishFlush:QJr.default.constants.Z_SYNC_FLUSH},L8S={flush:QJr.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:QJr.default.constants.BROTLI_OPERATION_FLUSH},Jfp=ds.isFunction(QJr.default.createBrotliDecompress),{http:U8S,https:V8S}=rdp.default,W8S=/https:?/,Kfp=qM.protocols.map(e=>e+":"),Yfp=(e,[t,r])=>(e.on("end",r).on("error",r),t);function H8S(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function ndp(e,t,r){let i=t;if(!i&&i!==!1){let n=Zfp.default.getProxyForUrl(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){ndp(a,t,a.href)}}var $8S=typeof process<"u"&&ds.kindOf(process)==="process",G8S=e=>new Promise((t,r)=>{let i,n,a=(f,s)=>{n||(n=!0,i&&i(f,s))},u=f=>{a(f),t(f)},l=f=>{a(f,!0),r(f)};e(u,l,f=>i=f).catch(l)}),Q8S=({address:e,family:t})=>{if(!ds.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},Xfp=(e,t)=>Q8S(ds.isObject(e)?e:{address:e,family:t}),adp=$8S&&function(t){return G8S(async function(i,n,a){let{data:u,lookup:l,family:f}=t,{responseType:s,responseEncoding:o}=t,c=t.method.toUpperCase(),b,g=!1,O;if(l){let Se=Hfp(l,Qe=>ds.isArray(Qe)?Qe:[Qe]);l=(Qe,Dt,Ee)=>{Se(Qe,Dt,(Te,It,je)=>{if(Te)return Ee(Te);let gt=ds.isArray(It)?It.map(Ot=>Xfp(Ot)):[Xfp(It,je)];Dt.all?Ee(Te,gt):Ee(Te,gt[0].address,gt[0].family)})}}let m=new idp.EventEmitter,P=()=>{t.cancelToken&&t.cancelToken.unsubscribe(E),t.signal&&t.signal.removeEventListener("abort",E),m.removeAllListeners()};a((Se,Qe)=>{b=!0,Qe&&(g=!0,P())});function E(Se){m.emit("abort",!Se||Se.type?new nDe(null,t,O):Se)}m.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(E),t.signal&&(t.signal.aborted?E():t.signal.addEventListener("abort",E)));let q=vzi(t.baseURL,t.url,t.allowAbsoluteUrls),A=new URL(q,qM.hasBrowserEnv?qM.origin:void 0),D=A.protocol||Kfp[0];if(D==="data:"){let Se;if(c!=="GET")return nXt(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{Se=Ezs(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Qe){throw Dp.from(Qe,Dp.ERR_BAD_REQUEST,t)}return s==="text"?(Se=Se.toString(o),(!o||o==="utf8")&&(Se=ds.stripBOM(Se))):s==="stream"&&(Se=gzi.default.Readable.from(Se)),nXt(i,n,{data:Se,status:200,statusText:"OK",headers:new gz,config:t})}if(Kfp.indexOf(D)===-1)return n(new Dp("Unsupported protocol "+D,Dp.ERR_BAD_REQUEST,t));let C=gz.from(t.headers).normalize();C.set("User-Agent","axios/"+bzi,!1);let{onUploadProgress:z,onDownloadProgress:$}=t,x=t.maxRate,L,V;if(ds.isSpecCompliantForm(u)){let Se=C.getContentType(/boundary=([-_\w\d]{10,70})/i);u=Ufp(u,Qe=>{C.set(Qe)},{tag:`axios-${bzi}-boundary`,boundary:Se&&Se[1]||void 0})}else if(ds.isFormData(u)&&ds.isFunction(u.getHeaders)){if(C.set(u.getHeaders()),!C.hasContentLength())try{let Se=await tdp.default.promisify(u.getLength).call(u);Number.isFinite(Se)&&Se>=0&&C.setContentLength(Se)}catch{}}else if(ds.isBlob(u)||ds.isFile(u))u.size&&C.setContentType(u.type||"application/octet-stream"),C.setContentLength(u.size||0),u=gzi.default.Readable.from(TPo(u));else if(u&&!ds.isStream(u)){if(!Buffer.isBuffer(u))if(ds.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(ds.isString(u))u=Buffer.from(u,"utf-8");else return n(new Dp("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Dp.ERR_BAD_REQUEST,t));if(C.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new Dp("Request body larger than maxBodyLength limit",Dp.ERR_BAD_REQUEST,t))}let X=ds.toFiniteNumber(C.getContentLength());ds.isArray(x)?(L=x[0],V=x[1]):L=V=x,u&&(z||L)&&(ds.isStream(u)||(u=gzi.default.Readable.from(u,{objectMode:!1})),u=gzi.default.pipeline([u,new qzs({maxRate:ds.toFiniteNumber(L)})],ds.noop),z&&u.on("progress",Yfp(u,pPn(X,GJr(_Pn(z),!1,3)))));let J;if(t.auth){let Se=t.auth.username||"",Qe=t.auth.password||"";J=Se+":"+Qe}if(!J&&A.username){let Se=A.username,Qe=A.password;J=Se+":"+Qe}J&&C.delete("authorization");let Z;try{Z=yzi(A.pathname+A.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Se){let Qe=new Error(Se.message);return Qe.config=t,Qe.url=t.url,Qe.exists=!0,n(Qe)}C.set("Accept-Encoding","gzip, compress, deflate"+(Jfp?", br":""),!1);let fe={path:Z,method:c,headers:C.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:J,protocol:D,family:f,beforeRedirect:H8S,beforeRedirects:{}};!ds.isUndefined(l)&&(fe.lookup=l),t.socketPath?fe.socketPath=t.socketPath:(fe.hostname=A.hostname.startsWith("[")?A.hostname.slice(1,-1):A.hostname,fe.port=A.port,ndp(fe,t.proxy,D+"//"+A.hostname+(A.port?":"+A.port:"")+fe.path));let me,_e=W8S.test(fe.protocol);if(fe.agent=_e?t.httpsAgent:t.httpAgent,t.transport?me=t.transport:t.maxRedirects===0?me=_e?edp.default:kfp.default:(t.maxRedirects&&(fe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(fe.beforeRedirects.config=t.beforeRedirect),me=_e?V8S:U8S),t.maxBodyLength>-1?fe.maxBodyLength=t.maxBodyLength:fe.maxBodyLength=1/0,t.insecureHTTPParser&&(fe.insecureHTTPParser=t.insecureHTTPParser),O=me.request(fe,function(Qe){if(O.destroyed)return;let Dt=[Qe],Ee=+Qe.headers["content-length"];if($||V){let Ot=new qzs({maxRate:ds.toFiniteNumber(V)});$&&Ot.on("progress",Yfp(Ot,pPn(Ee,GJr(_Pn($),!0,3)))),Dt.push(Ot)}let Te=Qe,It=Qe.req||O;if(t.decompress!==!1&&Qe.headers["content-encoding"])switch((c==="HEAD"||Qe.statusCode===204)&&delete Qe.headers["content-encoding"],(Qe.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":Dt.push(QJr.default.createUnzip(Qfp)),delete Qe.headers["content-encoding"];break;case"deflate":Dt.push(new Wfp),Dt.push(QJr.default.createUnzip(Qfp)),delete Qe.headers["content-encoding"];break;case"br":Jfp&&(Dt.push(QJr.default.createBrotliDecompress(L8S)),delete Qe.headers["content-encoding"])}Te=Dt.length>1?gzi.default.pipeline(Dt,ds.noop):Dt[0];let je=gzi.default.finished(Te,()=>{je(),P()}),gt={status:Qe.statusCode,statusText:Qe.statusMessage,headers:new gz(Qe.headers),config:t,request:It};if(s==="stream")gt.data=Te,nXt(i,n,gt);else{let Ot=[],ye=0;Te.on("data",function(ft){Ot.push(ft),ye+=ft.length,t.maxContentLength>-1&&ye>t.maxContentLength&&(g=!0,Te.destroy(),n(new Dp("maxContentLength size of "+t.maxContentLength+" exceeded",Dp.ERR_BAD_RESPONSE,t,It)))}),Te.on("aborted",function(){if(g)return;let ft=new Dp("stream has been aborted",Dp.ERR_BAD_RESPONSE,t,It);Te.destroy(ft),n(ft)}),Te.on("error",function(ft){O.destroyed||n(Dp.from(ft,null,t,It))}),Te.on("end",function(){try{let ft=Ot.length===1?Ot[0]:Buffer.concat(Ot);s!=="arraybuffer"&&(ft=ft.toString(o),(!o||o==="utf8")&&(ft=ds.stripBOM(ft))),gt.data=ft}catch(ft){return n(Dp.from(ft,null,t,gt.request,gt))}nXt(i,n,gt)})}m.once("abort",Ot=>{Te.destroyed||(Te.emit("error",Ot),Te.destroy())})}),m.once("abort",Se=>{n(Se),O.destroy(Se)}),O.on("error",function(Qe){n(Dp.from(Qe,null,t,O))}),O.on("socket",function(Qe){Qe.setKeepAlive(!0,1e3*60)}),t.timeout){let Se=parseInt(t.timeout,10);if(Number.isNaN(Se)){n(new Dp("error trying to parse `config.timeout` to int",Dp.ERR_BAD_OPTION_VALUE,t,O));return}O.setTimeout(Se,function(){if(b)return;let Dt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",Ee=t.transitional||lPn;t.timeoutErrorMessage&&(Dt=t.timeoutErrorMessage),n(new Dp(Dt,Ee.clarifyTimeoutError?Dp.ETIMEDOUT:Dp.ECONNABORTED,t,O)),E()})}if(ds.isStream(u)){let Se=!1,Qe=!1;u.on("end",()=>{Se=!0}),u.once("error",Dt=>{Qe=!0,O.destroy(Dt)}),u.on("close",()=>{!Se&&!Qe&&E(new nDe("Request stream has been aborted",t,O))}),u.pipe(O)}else O.end(u)})};var odp=qM.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,qM.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(qM.origin),qM.navigator&&/(msie|trident)/i.test(qM.navigator.userAgent)):()=>!0;var udp=qM.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];ds.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),ds.isString(i)&&u.push("path="+i),ds.isString(n)&&u.push("domain="+n),a===!0&&u.push("secure"),document.cookie=u.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var sdp=e=>e instanceof gz?{...e}:e;function E5t(e,t){t=t||{};let r={};function i(s,o,c,b){return ds.isPlainObject(s)&&ds.isPlainObject(o)?ds.merge.call({caseless:b},s,o):ds.isPlainObject(o)?ds.merge({},o):ds.isArray(o)?o.slice():o}function n(s,o,c,b){if(ds.isUndefined(o)){if(!ds.isUndefined(s))return i(void 0,s,c,b)}else return i(s,o,c,b)}function a(s,o){if(!ds.isUndefined(o))return i(void 0,o)}function u(s,o){if(ds.isUndefined(o)){if(!ds.isUndefined(s))return i(void 0,s)}else return i(void 0,o)}function l(s,o,c){if(c in t)return i(s,o);if(c in e)return i(void 0,s)}let f={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:l,headers:(s,o,c)=>n(sdp(s),sdp(o),c,!0)};return ds.forEach(Object.keys(Object.assign({},e,t)),function(o){let c=f[o]||n,b=c(e[o],t[o],o);ds.isUndefined(b)&&c!==l||(r[o]=b)}),r}var CPo=e=>{let t=E5t({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:l}=t;t.headers=u=gz.from(u),t.url=yzi(vzi(t.baseURL,t.url),e.params,e.paramsSerializer),l&&u.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let f;if(ds.isFormData(r)){if(qM.hasStandardBrowserEnv||qM.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((f=u.getContentType())!==!1){let[s,...o]=f?f.split(";").map(c=>c.trim()).filter(Boolean):[];u.setContentType([s||"multipart/form-data",...o].join("; "))}}if(qM.hasStandardBrowserEnv&&(i&&ds.isFunction(i)&&(i=i(t)),i||i!==!1&&odp(t.url))){let s=n&&a&&udp.read(a);s&&u.set(n,s)}return t};var J8S=typeof XMLHttpRequest<"u",cdp=J8S&&function(e){return new Promise(function(r,i){let n=CPo(e),a=n.data,u=gz.from(n.headers).normalize(),{responseType:l,onUploadProgress:f,onDownloadProgress:s}=n,o,c,b,g,O;function m(){g&&g(),O&&O(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let P=new XMLHttpRequest;P.open(n.method.toUpperCase(),n.url,!0),P.timeout=n.timeout;function E(){if(!P)return;let A=gz.from("getAllResponseHeaders"in P&&P.getAllResponseHeaders()),C={data:!l||l==="text"||l==="json"?P.responseText:P.response,status:P.status,statusText:P.statusText,headers:A,config:e,request:P};nXt(function($){r($),m()},function($){i($),m()},C),P=null}"onloadend"in P?P.onloadend=E:P.onreadystatechange=function(){!P||P.readyState!==4||P.status===0&&!(P.responseURL&&P.responseURL.indexOf("file:")===0)||setTimeout(E)},P.onabort=function(){P&&(i(new Dp("Request aborted",Dp.ECONNABORTED,e,P)),P=null)},P.onerror=function(){i(new Dp("Network Error",Dp.ERR_NETWORK,e,P)),P=null},P.ontimeout=function(){let D=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",C=n.transitional||lPn;n.timeoutErrorMessage&&(D=n.timeoutErrorMessage),i(new Dp(D,C.clarifyTimeoutError?Dp.ETIMEDOUT:Dp.ECONNABORTED,e,P)),P=null},a===void 0&&u.setContentType(null),"setRequestHeader"in P&&ds.forEach(u.toJSON(),function(D,C){P.setRequestHeader(C,D)}),ds.isUndefined(n.withCredentials)||(P.withCredentials=!!n.withCredentials),l&&l!=="json"&&(P.responseType=n.responseType),s&&([b,O]=GJr(s,!0),P.addEventListener("progress",b)),f&&P.upload&&([c,g]=GJr(f),P.upload.addEventListener("progress",c),P.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(o=A=>{P&&(i(!A||A.type?new nDe(null,e,P):A),P.abort(),P=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let q=Pla(n.url);if(q&&qM.protocols.indexOf(q)===-1){i(new Dp("Unsupported protocol "+q+":",Dp.ERR_BAD_REQUEST,e));return}P.send(a||null)})};var K8S=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,l();let o=s instanceof Error?s:this.reason;i.abort(o instanceof Dp?o:new nDe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new Dp(`timeout ${t} of ms exceeded`,Dp.ETIMEDOUT))},t),l=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:f}=i;return f.unsubscribe=()=>ds.asap(l),f}},ldp=K8S;var Y8S=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let i=0,n;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},X8S=async function*(e,t){for await(let r of Z8S(e))yield*Y8S(r,t)},Z8S=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:i}=await t.read();if(r)break;yield i}}finally{await t.cancel()}},Bzs=(e,t,r,i)=>{let n=X8S(e,t),a=0,u,l=f=>{u||(u=!0,i&&i(f))};return new ReadableStream({async pull(f){try{let{done:s,value:o}=await n.next();if(s){l(),f.close();return}let c=o.byteLength;if(r){let b=a+=c;r(b)}f.enqueue(new Uint8Array(o))}catch(s){throw l(s),s}},cancel(f){return l(f),n.return()}},{highWaterMark:2})};var xPo=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",ddp=xPo&&typeof ReadableStream=="function",k8S=xPo&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),pdp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},e5S=ddp&&pdp(()=>{let e=!1,t=new Request(qM.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),fdp=64*1024,xzs=ddp&&pdp(()=>ds.isReadableStream(new Response("").body)),BPo={stream:xzs&&(e=>e.body)};xPo&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!BPo[t]&&(BPo[t]=ds.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new Dp(`Response type '${t}' is not supported`,Dp.ERR_NOT_SUPPORT,i)})})})(new Response);var t5S=async e=>{if(e==null)return 0;if(ds.isBlob(e))return e.size;if(ds.isSpecCompliantForm(e))return(await new Request(qM.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(ds.isArrayBufferView(e)||ds.isArrayBuffer(e))return e.byteLength;if(ds.isURLSearchParams(e)&&(e=e+""),ds.isString(e))return(await k8S(e)).byteLength},r5S=async(e,t)=>{let r=ds.toFiniteNumber(e.getContentLength());return r??t5S(t)},_dp=xPo&&(async e=>{let{url:t,method:r,data:i,signal:n,cancelToken:a,timeout:u,onDownloadProgress:l,onUploadProgress:f,responseType:s,headers:o,withCredentials:c="same-origin",fetchOptions:b}=CPo(e);s=s?(s+"").toLowerCase():"text";let g=ldp([n,a&&a.toAbortSignal()],u),O,m=g&&g.unsubscribe&&(()=>{g.unsubscribe()}),P;try{if(f&&e5S&&r!=="get"&&r!=="head"&&(P=await r5S(o,i))!==0){let C=new Request(t,{method:"POST",body:i,duplex:"half"}),z;if(ds.isFormData(i)&&(z=C.headers.get("content-type"))&&o.setContentType(z),C.body){let[$,x]=pPn(P,GJr(_Pn(f)));i=Bzs(C.body,fdp,$,x)}}ds.isString(c)||(c=c?"include":"omit");let E="credentials"in Request.prototype;O=new Request(t,{...b,signal:g,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:i,duplex:"half",credentials:E?c:void 0});let q=await fetch(O),A=xzs&&(s==="stream"||s==="response");if(xzs&&(l||A&&m)){let C={};["status","statusText","headers"].forEach(L=>{C[L]=q[L]});let z=ds.toFiniteNumber(q.headers.get("content-length")),[$,x]=l&&pPn(z,GJr(_Pn(l),!0))||[];q=new Response(Bzs(q.body,fdp,$,()=>{x&&x(),m&&m()}),C)}s=s||"text";let D=await BPo[ds.findKey(BPo,s)||"text"](q,e);return!A&&m&&m(),await new Promise((C,z)=>{nXt(C,z,{data:D,headers:gz.from(q.headers),status:q.status,statusText:q.statusText,config:e,request:O})})}catch(E){throw m&&m(),E&&E.name==="TypeError"&&/fetch/i.test(E.message)?Object.assign(new Dp("Network Error",Dp.ERR_NETWORK,e,O),{cause:E.cause||E}):Dp.from(E,E&&E.code,e,O)}});var Izs={http:adp,xhr:cdp,fetch:_dp};ds.forEach(Izs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var hdp=e=>`- ${e}`,i5S=e=>ds.isFunction(e)||e===null||e===!1,IPo={getAdapter:e=>{e=ds.isArray(e)?e:[e];let{length:t}=e,r,i,n={};for(let a=0;a<t;a++){r=e[a];let u;if(i=r,!i5S(r)&&(i=Izs[(u=String(r)).toLowerCase()],i===void 0))throw new Dp(`Unknown adapter '${u}'`);if(i)break;n[u||"#"+a]=i}if(!i){let a=Object.entries(n).map(([l,f])=>`adapter ${l} `+(f===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
@@ -1940,7 +1940,7 @@ ${A}${q}${D}${lCp.default.cursorHide}`});var eha=li(aci(),1);function w9s(e,t){i
1940
1940
  Run ${Hs.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
1941
1941
  Run ${Hs.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),yPn(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function I9s({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!xCp(e))return;let n=t??"",a=e.filter(l=>l.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((l,f)=>l.generatorName.localeCompare(f.generatorName)||l.currentVersion.localeCompare(f.currentVersion));for(let l of u)n+=`
1942
1942
  ${await G_D(l.generatorName)} (${l.apiName!=null?"API: "+l.apiName+", ":""}Group: ${l.generatorGroup}) `+Hs.dim(l.currentVersion)+Hs.reset(" \u2192 ")+Hs.green(l.latestVersion);return n+=`
1943
- `,i?yPn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function G_D(e){let r=await new BCp.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 Q_D({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await zCp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=nci(o.name,c),g=await pJt({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await zCp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,f,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][f]==null&&(u.versions[l][f]={});let c=nci(s.name,o),b=await pJt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][f][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function zCp({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await K8t({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let f of l.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,u)}})}))}function RCp(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let f=rne(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function zAo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await Q_D({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[f,s]of Object.entries(l.versions))u.push(...RCp(s,f,t.logger));else u.push(...RCp(l.versions,void 0,t.logger))}return u}var sha=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var K1n=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Y1n=e=>e!==null&&typeof e=="object";var cha=(...e)=>{for(let t of e)if((!Y1n(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return N9s({},...e)},z9s=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function RAo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:N9s(e[r]??[],t[r]??[])}var R9s=(e={},t={})=>({beforeRequest:RAo(e,t,"beforeRequest"),beforeRetry:RAo(e,t,"beforeRetry"),afterResponse:RAo(e,t,"afterResponse"),beforeError:RAo(e,t,"beforeError")}),N9s=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(Y1n(n)){for(let[a,u]of Object.entries(n))Y1n(u)&&a in t&&(u=N9s(t[a],u)),t={...t,[a]:u};Y1n(n.hooks)&&(i=R9s(i,n.hooks),t.hooks=i),Y1n(n.headers)&&(r=z9s(r,n.headers),t.headers=r)}return t};var NCp=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),FCp=typeof globalThis.AbortController=="function",LCp=typeof globalThis.ReadableStream=="function",UCp=typeof globalThis.FormData=="function",NAo=["get","post","put","patch","head","delete"],J_D=()=>{};J_D();var VCp={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},FAo=2147483647,LAo=Symbol("stop"),WCp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},HCp={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 GCp=e=>NAo.includes(e)?e.toUpperCase():e,K_D=["get","put","head","delete","options","trace"],Y_D=[408,413,429,500,502,503,504],X_D=[413,429,503],$Cp={limit:2,methods:K_D,statusCodes:Y_D,afterStatusCodes:X_D,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},QCp=(e={})=>{if(typeof e=="number")return{...$Cp,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{...$Cp,...e}};async function F9s(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new K1n(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function L9s(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var JCp=(e,t)=>{let r={};for(let i in t)!(i in HCp)&&!(i in WCp)&&!(i in e)&&(r[i]=t[i]);return r};var lha=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>FAo)throw new RangeError(`The \`timeout\` option cannot be greater than ${FAo}`);await Promise.resolve();let l=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let f=new sha(l,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!LCp)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return i._stream(l.clone(),i._options.onDownloadProgress)}return l},u=i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n();for(let[l,f]of Object.entries(VCp))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let o=(await u).clone();if(l==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:z9s(this._input.headers,r.headers),hooks:R9s({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:GCp(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:QCp(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(FCp){this.abortController=new globalThis.AbortController;let i=this._options.signal??this._input.signal;i?.addEventListener("abort",()=>{this.abortController.abort(i.reason)}),this._options.signal=this.abortController.signal}if(NCp&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(UCp&&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 K1n)throw t;if(t instanceof sha){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),FAo);if(this._retryCount<1)throw r;await L9s(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===LAo)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=JCp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):F9s(r,t,this.abortController,this._options)}_stream(t,r){let i=Number(t.headers.get("content-length"))||0,n=0;return t.status===204?(r&&r({percent:1,totalBytes:i,transferredBytes:n},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:i},new Uint8Array);async function l(){let{done:f,value:s}=await u.read();if(f){a.close();return}if(r){n+=s.byteLength;let o=i===0?0:n/i;r({percent:o,transferredBytes:n,totalBytes:i},s)}a.enqueue(s),await l()}await l()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var U9s=e=>{let t=(r,i)=>lha.create(r,cha(e,i));for(let r of NAo)t[r]=(i,n)=>lha.create(i,cha(e,n,{method:r}));return t.create=r=>U9s(cha(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),U9s(cha(e,r))),t.stop=LAo,t},Z_D=U9s(),KCp=Z_D;var bBp=li(vBp(),1);function G9s(e){let t=(0,bBp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var dxp=li(fxp(),1),pxp=li(aci(),1),oLs=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},uLs=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function sLs(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??G9s(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,dxp.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,l&&(f.authorization=`${l.type} ${l.token}`);let s;try{s=await KCp(u,{headers:f,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new oLs(e):c}if(t.allVersions)return s;let o=new uLs(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=pxp.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function yha(e,t){let{version:r}=await sLs(e.toLowerCase(),t);return r}async function Jdi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:yha(e.packageName,{version:t?"prerelease":"latest"})}var _xp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],ZAo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=rb.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new IAo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(n==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.61.16"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Hs.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new f5}failWithoutThrowing(t,r){this.didSucceed=!1,TAo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await uPn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await ICp({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1943
+ `,i?yPn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function G_D(e){let r=await new BCp.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 Q_D({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await zCp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=nci(o.name,c),g=await pJt({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await zCp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,f,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][f]==null&&(u.versions[l][f]={});let c=nci(s.name,o),b=await pJt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][f][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function zCp({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await K8t({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let f of l.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,u)}})}))}function RCp(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let f=rne(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function zAo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await Q_D({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[f,s]of Object.entries(l.versions))u.push(...RCp(s,f,t.logger));else u.push(...RCp(l.versions,void 0,t.logger))}return u}var sha=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var K1n=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Y1n=e=>e!==null&&typeof e=="object";var cha=(...e)=>{for(let t of e)if((!Y1n(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return N9s({},...e)},z9s=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function RAo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:N9s(e[r]??[],t[r]??[])}var R9s=(e={},t={})=>({beforeRequest:RAo(e,t,"beforeRequest"),beforeRetry:RAo(e,t,"beforeRetry"),afterResponse:RAo(e,t,"afterResponse"),beforeError:RAo(e,t,"beforeError")}),N9s=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(Y1n(n)){for(let[a,u]of Object.entries(n))Y1n(u)&&a in t&&(u=N9s(t[a],u)),t={...t,[a]:u};Y1n(n.hooks)&&(i=R9s(i,n.hooks),t.hooks=i),Y1n(n.headers)&&(r=z9s(r,n.headers),t.headers=r)}return t};var NCp=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),FCp=typeof globalThis.AbortController=="function",LCp=typeof globalThis.ReadableStream=="function",UCp=typeof globalThis.FormData=="function",NAo=["get","post","put","patch","head","delete"],J_D=()=>{};J_D();var VCp={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},FAo=2147483647,LAo=Symbol("stop"),WCp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},HCp={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 GCp=e=>NAo.includes(e)?e.toUpperCase():e,K_D=["get","put","head","delete","options","trace"],Y_D=[408,413,429,500,502,503,504],X_D=[413,429,503],$Cp={limit:2,methods:K_D,statusCodes:Y_D,afterStatusCodes:X_D,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},QCp=(e={})=>{if(typeof e=="number")return{...$Cp,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{...$Cp,...e}};async function F9s(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new K1n(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function L9s(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var JCp=(e,t)=>{let r={};for(let i in t)!(i in HCp)&&!(i in WCp)&&!(i in e)&&(r[i]=t[i]);return r};var lha=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>FAo)throw new RangeError(`The \`timeout\` option cannot be greater than ${FAo}`);await Promise.resolve();let l=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let f=new sha(l,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!LCp)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return i._stream(l.clone(),i._options.onDownloadProgress)}return l},u=i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n();for(let[l,f]of Object.entries(VCp))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let o=(await u).clone();if(l==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:z9s(this._input.headers,r.headers),hooks:R9s({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:GCp(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:QCp(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(FCp){this.abortController=new globalThis.AbortController;let i=this._options.signal??this._input.signal;i?.addEventListener("abort",()=>{this.abortController.abort(i.reason)}),this._options.signal=this.abortController.signal}if(NCp&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(UCp&&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 K1n)throw t;if(t instanceof sha){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),FAo);if(this._retryCount<1)throw r;await L9s(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===LAo)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=JCp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):F9s(r,t,this.abortController,this._options)}_stream(t,r){let i=Number(t.headers.get("content-length"))||0,n=0;return t.status===204?(r&&r({percent:1,totalBytes:i,transferredBytes:n},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:i},new Uint8Array);async function l(){let{done:f,value:s}=await u.read();if(f){a.close();return}if(r){n+=s.byteLength;let o=i===0?0:n/i;r({percent:o,transferredBytes:n,totalBytes:i},s)}a.enqueue(s),await l()}await l()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var U9s=e=>{let t=(r,i)=>lha.create(r,cha(e,i));for(let r of NAo)t[r]=(i,n)=>lha.create(i,cha(e,n,{method:r}));return t.create=r=>U9s(cha(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),U9s(cha(e,r))),t.stop=LAo,t},Z_D=U9s(),KCp=Z_D;var bBp=li(vBp(),1);function G9s(e){let t=(0,bBp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var dxp=li(fxp(),1),pxp=li(aci(),1),oLs=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},uLs=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function sLs(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??G9s(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,dxp.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,l&&(f.authorization=`${l.type} ${l.token}`);let s;try{s=await KCp(u,{headers:f,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new oLs(e):c}if(t.allVersions)return s;let o=new uLs(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=pxp.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function yha(e,t){let{version:r}=await sLs(e.toLowerCase(),t);return r}async function Jdi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:yha(e.packageName,{version:t?"prerelease":"latest"})}var _xp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],ZAo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=rb.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new IAo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(n==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.61.17"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Hs.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new f5}failWithoutThrowing(t,r){this.didSucceed=!1,TAo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await uPn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await ICp({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1944
1944
  `)||(r+=`
1945
1945
  `),this.stderr.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram({code:t}={}){process.exit(t??(this.didSucceed?0:1))}longestWorkspaceName;registerWorkspaces(t){let r=R_s(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new tha(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let i=this.addTaskWithInit(t).start(),n;try{n=await r(i)}catch(a){throw a.message.includes("globalThis")?(i.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),i.failWithoutThrowing()):i.failWithoutThrowing(void 0,a),new f5}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await uPn()).sendEvent(t)}logger=qGt((t,...r)=>this.log(t,...r));stderr=qGt((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=hxp(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?hxp(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=_xp[this.numTasks++%_xp.length],u=Hs.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===NC.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let i=t.filter(n=>msi.indexOf(n.level)>=msi.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===rb.Debug,stderr:r})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await Jdi({cliEnvironment:this.environment,includePreReleases:t}),i=rne(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await zAo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await b9s({message:t,default:r})}async getInput(t){return await g9s({message:t.message,default:t.default})}};function hxp(e){return`[${e}]:`}var eJp=require("fs/promises");function Jze({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Hs.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Hs.dim(r)),i.join(`
1946
1946
  `)}var $Up=require("fs/promises");var n9t=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};var jDe=class extends n9t{definition;sources;type="fern";constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var vha=class{context;constructor(t){this.context=t}};var kAo=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,l]of Object.entries(i.files)){let f=n!=null?Zh.of(`${n}${_8t}${u}`):Zh.of(u);t[f]=l}let a=Object.keys(i.directories).sort();for(let u of a){let l=n!=null?`${n}${_8t}${u}`:u,f=i.directories[u];r(f,l)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(_8t))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Zh.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var PNi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new kAo,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),i!=null&&(u.service["base-path"]=i),n!=null&&(u.service["display-name"]=n),a!=null&&(u.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return MJt(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))yxp(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(yxp(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??Mh((dxe(r)+"/"+fBi(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Zh.of(eF))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=Nto(dxe(bvn.of(`/${t}`)),bvn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=Nto(dxe(bvn.of(`/${t}`)),bvn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===Zh.of(eF))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(l=>vSe(l,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=VR(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:VR(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,u])=>[a,{...u,path:VR(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===sS?this.packageMarkerFile:this.root.getOrCreateFile(t)}getVersionHeader(){if(this.rootApiFile.version!=null)return typeof this.rootApiFile.version.header=="string"?this.rootApiFile.version.header:this.rootApiFile.version.header.value}};function yxp(e){return e?.header!=null}var ine={openapi:e=>({...e,type:"openapi",_visit:function(t){return ine._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return ine._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"openapi":return t.openapi(e);case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var iSn={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return iSn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var $5={basic:e=>({...e,type:"basic",_visit:function(t){return $5._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return $5._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return $5._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return $5._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return $5._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"query":return t.query(e);case"oauth":return t.oauth(e);default:return t._other(e)}}};var Yg={primitive:e=>({value:e,type:"primitive",_visit:function(t){return Yg._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Yg._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return Yg._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return Yg._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return Yg._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return Yg._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Yg._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return Yg._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.value);case"object":return t.object(e);case"array":return t.array(e.value);case"map":return t.map(e.value);case"enum":return t.enum(e.value);case"literal":return t.literal(e.value);case"oneOf":return t.oneOf(e.value);case"unknown":return t.unknown(e.value);default:return t._other(e)}}};var c_={int:e=>({value:e,type:"int",_visit:function(t){return c_._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return c_._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return c_._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return c_._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return c_._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return c_._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return c_._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return c_._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return c_._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return c_._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return c_._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e.value);case"int64":return t.int64(e.value);case"uint":return t.uint(e.value);case"uint64":return t.uint64(e.value);case"float":return t.float(e.value);case"double":return t.double(e.value);case"string":return t.string(e.value);case"datetime":return t.datetime(e.value);case"date":return t.date(e.value);case"base64":return t.base64(e.value);case"boolean":return t.boolean(e.value);default:return t._other(e)}}};var nSn={boolean:e=>({value:e,type:"boolean",_visit:function(t){return nSn._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return nSn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var Kdi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return Kdi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return Kdi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var zV={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case zV.GenerallyAvailable:return t.generallyAvailable();case zV.Beta:return t.beta();case zV.Deprecated:return t.deprecated();default:return t._other()}}};var Kze={cursor:e=>({...e,type:"cursor",_visit:function(t){return Kze._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return Kze._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return Kze._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var zKr={language:e=>({...e,type:"language",_visit:function(t){return zKr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return zKr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"language":return t.language(e);case"sdk":return t.sdk(e);default:return t._other(e)}}};var RV={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Js:"js",Node:"node",Ts:"ts",Nodets:"nodets",Golang:"golang",Dotnet:"dotnet",Jvm:"jvm",_visit:(e,t)=>{switch(e){case RV.Curl:return t.curl();case RV.Python:return t.python();case RV.Javascript:return t.javascript();case RV.Typescript:return t.typescript();case RV.Go:return t.go();case RV.Ruby:return t.ruby();case RV.Csharp:return t.csharp();case RV.Java:return t.java();case RV.Js:return t.js();case RV.Node:return t.node();case RV.Ts:return t.ts();case RV.Nodets:return t.nodets();case RV.Golang:return t.golang();case RV.Dotnet:return t.dotnet();case RV.Jvm:return t.jvm();default:return t._other()}}};var a9t={unknown:e=>({value:e,type:"unknown",_visit:function(t){return a9t._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return a9t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"unknown":return t.unknown(e.value);case"full":return t.full(e);default:return t._other(e)}}};var o9t={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return o9t._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return o9t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var LG={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case LG.Get:return t.get();case LG.Post:return t.post();case LG.Put:return t.put();case LG.Patch:return t.patch();case LG.Delete:return t.delete();case LG.Head:return t.head();case LG.Options:return t.options();case LG.Trace:return t.trace();default:return t._other()}}};var Ydi={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return Ydi._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return Ydi._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Ydi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);default:return t._other(e)}}};var RKr={file:e=>({...e,type:"file",_visit:function(t){return RKr._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return RKr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e.value);default:return t._other(e)}}};var UG={file:e=>({...e,type:"file",_visit:function(t){return UG._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return UG._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return UG._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return UG._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return UG._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return UG._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return UG._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Py={primitive:e=>({...e,type:"primitive",_visit:function(t){return Py._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Py._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Py._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Py._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Py._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Py._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Py._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Py._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Py._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Py._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Py._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var Sj={int:e=>({...e,type:"int",_visit:function(t){return Sj._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Sj._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Sj._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Sj._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Sj._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Sj._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Sj._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Sj._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Sj._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Sj._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Sj._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint();case"uint64":return t.uint64();case"float":return t.float();case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime();case"date":return t.date();case"base64":return t.base64();case"boolean":return t.boolean(e);default:return t._other(e)}}};var Dx={boolean:e=>({value:e,type:"boolean",_visit:function(t){return Dx._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Dx._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var NKr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return NKr._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return NKr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var wDe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return wDe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return wDe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return wDe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);default:return t._other(e)}}};var ET={file:e=>({...e,type:"file",_visit:function(t){return ET._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return ET._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return ET._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return ET._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return ET._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return ET._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return ET._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Cl={primitive:e=>({...e,type:"primitive",_visit:function(t){return Cl._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Cl._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Cl._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Cl._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Cl._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Cl._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Cl._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Cl._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Cl._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Cl._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Cl._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var jX={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return jX._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return jX._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var ip={int:e=>({...e,type:"int",_visit:function(t){return ip._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return ip._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return ip._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return ip._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return ip._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return ip._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return ip._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return ip._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return ip._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return ip._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return ip._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime(e);case"date":return t.date(e);case"base64":return t.base64(e);case"boolean":return t.boolean(e);default:return t._other(e)}}};var lv={};Oo(lv,{AllOfPropertyConflict:()=>ESn,ArraySchema:()=>hTo,ArraySchemaWithExample:()=>WTo,Availability:()=>cqo,Base64WithExample:()=>NTo,BasicSecurityScheme:()=>dqo,BearerSecurityScheme:()=>pqo,BooleanSchema:()=>cTo,BooleanWithExample:()=>FTo,BytesResponse:()=>bSn,CasingOverrides:()=>yqo,CommonProperty:()=>jTo,CommonPropertyWithExample:()=>ZTo,CursorPagination:()=>Gqo,CustomCodeSample:()=>Hqo,CustomCodeSampleLanguage:()=>Uqo,CustomCodeSampleSdk:()=>Wqo,CustomPagination:()=>Jqo,DateWithExample:()=>RTo,DatetimeWithExample:()=>zTo,DiscriminatedOneOfSchema:()=>mTo,DiscriminatedOneOfSchemaWithExample:()=>YTo,DoubleSchema:()=>uTo,DoubleWithExample:()=>xTo,Encoding:()=>sqo,Endpoint:()=>Kqo,EndpointExample:()=>PSn,EndpointResponseExample:()=>Lqo,EndpointSdkName:()=>$Xt,EndpointWithExample:()=>Gxp,EnumSchema:()=>sSn,EnumSchemaWithExample:()=>UTo,EnumValue:()=>kdi,ErrorExample:()=>Iqo,FernExample:()=>Rqo,FileResponse:()=>ySn,FileSchema:()=>Mqo,FloatWithExample:()=>BTo,FullEndpointExample:()=>$qo,FullExample:()=>aq,FullObjectExample:()=>jqo,FullOneOfExample:()=>Sqo,GlobalHeader:()=>fTo,Header:()=>tpi,HeaderExample:()=>mSn,HeaderSecurityScheme:()=>_qo,HeaderWithExample:()=>npi,HttpEndpointServer:()=>gSn,HttpError:()=>zqo,HttpErrorWithExample:()=>MTo,HttpMethod:()=>fSn,IdempotencyHeader:()=>dTo,Int64WithExample:()=>qTo,IntSchema:()=>aTo,IntWithExample:()=>ATo,JsonRequest:()=>Cqo,JsonRequestWithExample:()=>STo,JsonResponse:()=>vSn,JsonResponseWithExample:()=>qSn,KeyValuePair:()=>wqo,LiteralExample:()=>Pqo,LiteralSchema:()=>DSn,LiteralSchemaValue:()=>pTo,LongSchema:()=>oTo,MapSchema:()=>yTo,MapSchemaWithExample:()=>HTo,MultipartRequest:()=>hSn,MultipartRequestProperty:()=>Tqo,MultipartRequestPropertyEncoding:()=>qqo,MultipartSchema:()=>Aqo,NamedFullExample:()=>QXt,Namespace:()=>vqo,NamespaceId:()=>mqo,NullableSchema:()=>bTo,NullableSchemaWithExample:()=>GTo,OauthSecurityScheme:()=>gqo,ObjectProperty:()=>OTo,ObjectPropertyConflictInfo:()=>MSn,ObjectPropertyWithExample:()=>KTo,ObjectSchema:()=>_To,ObjectSchemaWithExample:()=>QTo,OctetStreamRequest:()=>_Sn,OffsetPagination:()=>Qqo,OneOfSchema:()=>gTo,OneOfSchemaWithExample:()=>JTo,OpenApiIntermediateRepresentation:()=>Hxp,OpenApiSource:()=>nqo,OptionalSchema:()=>vTo,OptionalSchemaWithExample:()=>$To,Pagination:()=>jSn,PathParameter:()=>dSn,PathParameterExample:()=>Nqo,PathParameterWithExample:()=>wTo,PrimitiveExample:()=>lSn,PrimitiveSchema:()=>ipi,PrimitiveSchemaValue:()=>lTo,PrimitiveSchemaValueWithExample:()=>LTo,PrimitiveSchemaWithExample:()=>TSn,PropertyKey:()=>cSn,ProtobufEncoding:()=>uqo,ProtobufSource:()=>aqo,QueryParameter:()=>pSn,QueryParameterExample:()=>OSn,QueryParameterWithExample:()=>ASn,QuerySecurityScheme:()=>hqo,ReferencedSchema:()=>GXt,Request:()=>Bqo,RequestWithExample:()=>DTo,Response:()=>xqo,ResponseWithExample:()=>ETo,Schema:()=>ZO,SchemaId:()=>wX,SchemaWithExample:()=>IM,Schemas:()=>nTo,SdkGroup:()=>bqo,SdkGroupInfo:()=>Dqo,SdkGroupName:()=>epi,SecurityScheme:()=>Oqo,SecuritySchemeId:()=>fqo,Server:()=>mha,Source:()=>oqo,StatusCode:()=>HXt,StreamingResponseExample:()=>Fqo,StringSchema:()=>sTo,StringSchemaWithExample:()=>ITo,SupportedSdkLanguage:()=>Vqo,Tag:()=>lqo,TagId:()=>SX,Tags:()=>Eqo,TextResponse:()=>rpi,Uint64WithExample:()=>CTo,UintWithExample:()=>TTo,UnDiscriminatedOneOfSchema:()=>PTo,UnDiscriminatedOneOfSchemaWithExample:()=>XTo,UnknownSchemaWithExample:()=>VTo,Webhook:()=>Yqo,WebhookExampleCall:()=>SSn,WebhookHttpMethod:()=>wSn,WebhookWithExample:()=>Qxp,WebsocketChannel:()=>iTo,WebsocketHandshake:()=>Xqo,WebsocketHandshakeWithExample:()=>$xp,WebsocketMessageExample:()=>tTo,WebsocketMessageOrigin:()=>Zqo,WebsocketMessageSchema:()=>kqo,WebsocketServer:()=>eTo,WebsocketSessionExample:()=>rTo,WithAvailability:()=>dh,WithDescription:()=>_f,WithEncoding:()=>nne,WithInline:()=>yE,WithName:()=>l0,WithNamespace:()=>Bb,WithSdkGroupName:()=>LO,WithSource:()=>Th,WithStatusCode:()=>Yze,WithTitle:()=>FO,commons:()=>pLs,example:()=>_Ls,finalIr:()=>hLs,parseIr:()=>yLs});var pLs={};Oo(pLs,{BasicSecurityScheme:()=>dqo,BearerSecurityScheme:()=>pqo,Encoding:()=>sqo,HeaderSecurityScheme:()=>_qo,Namespace:()=>vqo,NamespaceId:()=>mqo,OauthSecurityScheme:()=>gqo,OpenApiSource:()=>nqo,ProtobufEncoding:()=>uqo,ProtobufSource:()=>aqo,QuerySecurityScheme:()=>hqo,SchemaId:()=>wX,SdkGroup:()=>bqo,SdkGroupName:()=>epi,SecurityScheme:()=>Oqo,SecuritySchemeId:()=>fqo,Server:()=>mha,Source:()=>oqo,StatusCode:()=>HXt,Tag:()=>lqo,TagId:()=>SX,WithAvailability:()=>dh,WithDescription:()=>_f,WithEncoding:()=>nne,WithInline:()=>yE,WithName:()=>l0,WithNamespace:()=>Bb,WithSdkGroupName:()=>LO,WithSource:()=>Th,WithStatusCode:()=>Yze,WithTitle:()=>FO});var At={};Oo(At,{JsonError:()=>aSn,ParseError:()=>oSn,any:()=>Txp,bigint:()=>bxp,boolean:()=>Cxp,booleanLiteral:()=>qxp,date:()=>gxp,discriminant:()=>Uxp,enum_:()=>tqo,getObjectLikeUtils:()=>u9t,getObjectUtils:()=>jNi,getSchemaUtils:()=>nq,isProperty:()=>Zdi,lazy:()=>Oxp,lazyObject:()=>Exp,list:()=>iqo,number:()=>Bxp,object:()=>rqo,objectWithoutOptionalProperties:()=>Dxp,optional:()=>cLs,property:()=>Pxp,record:()=>Rxp,set:()=>Nxp,string:()=>xxp,stringLiteral:()=>Axp,transform:()=>lLs,undiscriminatedUnion:()=>Lxp,union:()=>Wxp,unknown:()=>Ixp,withParsedProperties:()=>dLs});var rj={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function xM(e,t){return`Expected ${t}. Received ${iyD(e)}.`}function iyD(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function G5(e){return{...e,json:vxp(e.json),parse:vxp(e.parse)}}function vxp(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
@@ -1963,10 +1963,10 @@ plugins:
1963
1963
  `+Dd.dump(l)),a.logger.info(Hs.green(`Added ${t} generator`)))})}))}var vJp=require("fs/promises"),bJp=li(aci(),1);async function gJp({context:e,from:t,to:r,fromVersion:i}){let a=await new sba().check({from:await yJp({context:e,filepath:t,flagName:"from"}),to:await yJp({context:e,filepath:r,flagName:"to"})});if(i==null)return{bump:a.bump};let u=bJp.default.inc(i,a.bump);if(!u)throw e.failWithoutThrowing(`Invalid current version: ${i}`),new f5;return{bump:a.bump,nextVersion:u}}async function yJp({context:e,filepath:t,flagName:r}){let i=Ul.of(P0(lz(),t));if(!await Af(i,"file"))throw e.failWithoutThrowing(`File not found: ${i}`),new f5;let n=await(0,vJp.readFile)(i,"utf-8"),a=Vp.IntermediateRepresentation.parse(JSON.parse(n));if(!a.ok)throw e.failWithoutThrowing(`Invalid --${r}; expected a filepath containing a valid IR`),new f5;return a.value}var hv_=li(LYs(),1),Lnc=li(GFo(),1),yv_=li(require("http"),1),n4o=li(require("path"),1);var KZp=require("events"),XFo=li(require("fs"),1),LFi=li(require("path"),1);var TZp=li(require("os"),1),CZp=300,M_i=20,Hba=1e7,BZp=TZp.default.platform();var YYD=BZp==="darwin",zXs=BZp==="win32",A_i=YYD||zXs,xZp=3e3,IZp=2e4,RXs=1250;var TZt;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(TZt||(TZt={}));var FFi;(function(e){e.CHANGE="change",e.RENAME="rename"})(FFi||(FFi={}));var $ba;(function(e){e.CHANGE="change",e.ERROR="error"})($ba||($ba={}));var Ib;(function(e){e.ADD="add",e.ADD_DIR="addDir",e.CHANGE="change",e.RENAME="rename",e.RENAME_DIR="renameDir",e.UNLINK="unlink",e.UNLINK_DIR="unlinkDir"})(Ib||(Ib={}));var WX;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(WX||(WX={}));var XYD=(e,t=1,r)=>{t=Math.max(1,t);let i=r?.leading??!1,n=r?.trailing??!0,a=Math.max(r?.maxWait??1/0,t),u,l,f=0,s=0,o=()=>{let D=Date.now(),C=D-f,z=D-s,$=C>=t||z>=a;return[D,$]},c=D=>{if(s=D,!u)return;let C=u;u=void 0,e.apply(void 0,C)},b=()=>{q(0)},g=()=>{l&&(b(),c(Date.now()))},O=D=>{if(s=D,i)return c(D)},m=D=>{if(n&&u)return c(D);u=void 0},P=()=>{l=void 0;let[D,C]=o();return C?m(D):E(D)},E=D=>{let C=D-f,z=D-s,$=t-C,x=a-z,L=Math.min($,x);return q(L)},q=D=>{l&&clearTimeout(l),!(D<=0)&&(l=setTimeout(P,D))},A=(...D)=>{let[C,z]=o(),$=!!l;if(u=D,f=C,(z||!l)&&q(t),z)return $?c(C):O(C)};return A.cancel=b,A.flush=g,A},QFo=XYD;var VXs=li(require("fs"),1),KFo=li(require("path"),1);var bE=li(require("fs"),1),KV=require("util");var OYr=(e,t)=>function(...i){return e.apply(void 0,i).catch(t)},CZt=(e,t)=>function(...i){try{return e.apply(void 0,i)}catch(n){return t(n)}};var NXs=li(require("process"),1),zZp=NXs.default.getuid?!NXs.default.getuid():!1,RZp=1e4,One=()=>{};var Gba={isChangeErrorOk:e=>{if(!Gba.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!zZp&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!Gba.isNodeError(e))return!1;let{code:t}=e;return t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM"},onChangeError:e=>{if(!Gba.isNodeError(e))throw e;if(!Gba.isChangeErrorOk(e))throw e}},RF=Gba;var FXs=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=RZp,this.queueActive=new Set,this.queueWaiting=new Set,this.init=()=>{this.intervalId||(this.intervalId=setInterval(this.tick,this.interval))},this.reset=()=>{this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId)},this.add=t=>{this.queueWaiting.add(t),this.queueActive.size<this.limit/2?this.tick():this.init()},this.remove=t=>{this.queueWaiting.delete(t),this.queueActive.delete(t)},this.schedule=()=>new Promise(t=>{let r=()=>this.remove(i),i=()=>t(r);this.add(i)}),this.tick=()=>{if(!(this.queueActive.size>=this.limit)){if(!this.queueWaiting.size)return this.reset();for(let t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t),this.queueActive.add(t),t()}}}}},NZp=new FXs;var mYr=(e,t)=>function(i){return function n(...a){return NZp.schedule().then(u=>{let l=s=>(u(),s),f=s=>{if(u(),Date.now()>=i)throw s;if(t(s)){let o=Math.round(100*Math.random());return new Promise(b=>setTimeout(b,o)).then(()=>n.apply(void 0,a))}throw s};return e.apply(void 0,a).then(l,f)})}},PYr=(e,t)=>function(i){return function n(...a){try{return e.apply(void 0,a)}catch(u){if(Date.now()>i)throw u;if(t(u))return n.apply(void 0,a);throw u}}};var ZYD={attempt:{chmod:OYr((0,KV.promisify)(bE.default.chmod),RF.onChangeError),chown:OYr((0,KV.promisify)(bE.default.chown),RF.onChangeError),close:OYr((0,KV.promisify)(bE.default.close),One),fsync:OYr((0,KV.promisify)(bE.default.fsync),One),mkdir:OYr((0,KV.promisify)(bE.default.mkdir),One),realpath:OYr((0,KV.promisify)(bE.default.realpath),One),stat:OYr((0,KV.promisify)(bE.default.stat),One),unlink:OYr((0,KV.promisify)(bE.default.unlink),One),chmodSync:CZt(bE.default.chmodSync,RF.onChangeError),chownSync:CZt(bE.default.chownSync,RF.onChangeError),closeSync:CZt(bE.default.closeSync,One),existsSync:CZt(bE.default.existsSync,One),fsyncSync:CZt(bE.default.fsync,One),mkdirSync:CZt(bE.default.mkdirSync,One),realpathSync:CZt(bE.default.realpathSync,One),statSync:CZt(bE.default.statSync,One),unlinkSync:CZt(bE.default.unlinkSync,One)},retry:{close:mYr((0,KV.promisify)(bE.default.close),RF.isRetriableError),fsync:mYr((0,KV.promisify)(bE.default.fsync),RF.isRetriableError),open:mYr((0,KV.promisify)(bE.default.open),RF.isRetriableError),readFile:mYr((0,KV.promisify)(bE.default.readFile),RF.isRetriableError),rename:mYr((0,KV.promisify)(bE.default.rename),RF.isRetriableError),stat:mYr((0,KV.promisify)(bE.default.stat),RF.isRetriableError),write:mYr((0,KV.promisify)(bE.default.write),RF.isRetriableError),writeFile:mYr((0,KV.promisify)(bE.default.writeFile),RF.isRetriableError),closeSync:PYr(bE.default.closeSync,RF.isRetriableError),fsyncSync:PYr(bE.default.fsyncSync,RF.isRetriableError),openSync:PYr(bE.default.openSync,RF.isRetriableError),readFileSync:PYr(bE.default.readFileSync,RF.isRetriableError),renameSync:PYr(bE.default.renameSync,RF.isRetriableError),statSync:PYr(bE.default.statSync,RF.isRetriableError),writeSync:PYr(bE.default.writeSync,RF.isRetriableError),writeFileSync:PYr(bE.default.writeFileSync,RF.isRetriableError)}},FZp=ZYD;var JFo=li(require("fs"),1),Qba=li(require("path"),1);var LZp={then:e=>{e()}};var LXs=()=>{};var UXs=()=>{let e=LXs,t=LXs,r=!1,i=!1;return{promise:new Promise((f,s)=>{e=o=>(r=!0,f(o)),t=o=>(i=!0,s(o))}),resolve:e,reject:t,isPending:()=>!r&&!i,isResolved:()=>r,isRejected:()=>i}};UXs.wrap=async e=>{let t=UXs();return await e(t),t.promise};var UZp=UXs;var VZp=e=>Array.isArray(e)?e:[e],WZp=e=>typeof e=="function",HZp=()=>{let{promise:e,resolve:t}=UZp(),r=0,i=()=>{r+=1},n=()=>{r-=1,!r&&t()};return(()=>{i(),queueMicrotask(n)})(),{promise:e,increment:i,decrement:n}};var kYD=(e,t)=>{let r=t?.followSymlinks??!1,i=t?.depth??1/0,n=t?.limit??1/0,a=t?.ignore??[],u=VZp(a).map(Ee=>WZp(Ee)?Ee:Te=>Ee.test(Te)),l=Ee=>u.some(Te=>Te(Ee)),f=t?.signal??{aborted:!1},s=t?.onDirents||(()=>{}),o=[],c=new Set,b={},g=[],O=new Set,m={},P=[],E=new Set,q={},A={},D=new Set,C={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},z={directories:o,directoriesNames:c,directoriesNamesToPaths:b,files:g,filesNames:O,filesNamesToPaths:m,symlinks:P,symlinksNames:E,symlinksNamesToPaths:q,map:A},{promise:$,increment:x,decrement:L}=HZp(),V=0,X=(Ee,Te,It,je)=>{D.has(Te)||V>=n||(V+=1,Ee.directories.push(Te),Ee.directoriesNames.add(It),o.push(Te),c.add(It),b.propertyIsEnumerable(It)||(b[It]=[]),b[It].push(Te),D.add(Te),!(je>=i)&&(V>=n||Se(Te,je+1)))},J=(Ee,Te,It)=>{D.has(Te)||V>=n||(V+=1,Ee.files.push(Te),Ee.filesNames.add(It),g.push(Te),O.add(It),m.propertyIsEnumerable(It)||(m[It]=[]),m[It].push(Te),D.add(Te))},Z=(Ee,Te,It,je)=>{D.has(Te)||V>=n||(V+=1,Ee.symlinks.push(Te),Ee.symlinksNames.add(It),P.push(Te),E.add(It),q.propertyIsEnumerable(It)||(q[It]=[]),q[It].push(Te),D.add(Te),r&&(je>=i||V>=n||Qe(Te,je+1)))},fe=(Ee,Te,It,je,gt)=>{f.aborted||l(Te)||(je.isDirectory()?X(Ee,Te,It,gt):je.isFile()?J(Ee,Te,It):je.isSymbolicLink()&&Z(Ee,Te,It,gt))},me=(Ee,Te,It,je)=>{if(f.aborted)return;let gt=Te===Qba.default.sep?"":Qba.default.sep,Ot=It.name,ye=`${Te}${gt}${Ot}`;l(ye)||(It.isDirectory()?X(Ee,ye,Ot,je):It.isFile()?J(Ee,ye,Ot):It.isSymbolicLink()&&Z(Ee,ye,Ot,je))},_e=(Ee,Te,It,je)=>{for(let gt=0,Ot=It.length;gt<Ot;gt++)me(Ee,Te,It[gt],je)},Se=(Ee,Te)=>{f.aborted||Te>i||V>=n||(x(),JFo.default.readdir(Ee,{withFileTypes:!0},(It,je)=>{if(It||f.aborted||!je.length)return L();(s(je)||LZp).then(()=>{let Ot=A[Ee]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};_e(Ot,Ee,je,Te),L()})}))},Qe=async(Ee,Te)=>{x(),JFo.default.realpath(Ee,(It,je)=>{if(It||f.aborted)return L();JFo.default.stat(je,async(gt,Ot)=>{if(gt||f.aborted)return L();let ye=Qba.default.basename(je),Pe=A[Ee]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};fe(Pe,je,ye,Ot,Te),L()})})};return(async(Ee,Te=1)=>(Ee=Qba.default.normalize(Ee),D.add(Ee),Se(Ee,Te),await $,f.aborted?C:z))(e)},$Zp=kYD;var BZt={lang:{debounce:QFo,attempt:e=>{try{return e()}catch(t){return BZt.lang.castError(t)}},castArray:e=>BZt.lang.isArray(e)?e:[e],castError:e=>BZt.lang.isError(e)?e:BZt.lang.isString(e)?new Error(e):new Error("Unknown error"),defer:e=>setTimeout(e,0),isArray:e=>Array.isArray(e),isError:e=>e instanceof Error,isFunction:e=>typeof e=="function",isNaN:e=>Number.isNaN(e),isNumber:e=>typeof e=="number",isPrimitive:e=>{if(e===null)return!0;let t=typeof e;return t!=="object"&&t!=="function"},isShallowEqual:(e,t)=>{if(e===t)return!0;if(BZt.lang.isNaN(e))return BZt.lang.isNaN(t);if(BZt.lang.isPrimitive(e)||BZt.lang.isPrimitive(t))return e===t;for(let r in e)if(!(r in t))return!1;for(let r in t)if(e[r]!==t[r])return!1;return!0},isSet:e=>e instanceof Set,isString:e=>typeof e=="string",isUndefined:e=>e===void 0,noop:()=>{},uniq:e=>e.length<2?e:Array.from(new Set(e))},fs:{getDepth:e=>Math.max(0,e.split(KFo.default.sep).length-1),getRealPath:(e,t)=>{try{return t?VXs.default.realpathSync.native(e):VXs.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===KFo.default.sep&&t.length-e.length>KFo.default.sep.length,poll:(e,t=IZp)=>FZp.retry.stat(t)(e,{bigint:!0}).catch(BZt.lang.noop),readdir:async(e,t,r=1/0,i=1/0,n,a)=>{if(a&&r===1&&e in a){let u=a[e];return[u.directories,u.files]}else{let u=await $Zp(e,{depth:r,limit:i,ignore:t,signal:n});return[u.directories,u.files]}}}},tm=BZt;var YFo=li(require("path"),1);var WXs=class{constructor(t,r,i){this.base=i,this.watcher=t,this.handler=r.handler,this.fswatcher=r.watcher,this.options=r.options,this.folderPath=r.folderPath,this.filePath=r.filePath,this.handlerBatched=this.base?this.base.onWatcherEvent.bind(this.base):this._makeHandlerBatched(this.options.debounce)}_isSubRoot(t){return this.filePath?t===this.filePath:t===this.folderPath||tm.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=CZp){return(()=>{let r=this.watcher._readyWait,i=[],n=new Set,a=async(l,f)=>{let s=this.options.ignoreInitial?[]:l,o=await this.eventsPopulate([...f]),c=this.eventsDeduplicate([...s,...o]);this.onTargetEvents(c)},u=tm.lang.debounce(()=>{this.watcher.isClosed()||(r=a(i,n),i=[],n=new Set)},t);return async(l,f="",s=!1)=>{s?await this.eventsPopulate([f],i,!0):n.add(f),r.then(u)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((i,n)=>{let[a,u]=n,l=r[u];return a===l||a===Ib.CHANGE&&l===Ib.ADD||(r[u]=a,i.push(n)),i},[])}async eventsPopulate(t,r=[],i=!1){return await Promise.all(t.map(async n=>{let a=await this.watcher._poller.update(n,this.options.pollingTimeout);await Promise.all(a.map(async u=>{r.push([u,n]),u===Ib.ADD_DIR?await this.eventsPopulateAddDir(t,n,r,i):u===Ib.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,n,r,i)}))})),r}async eventsPopulateAddDir(t,r,i=[],n=!1){if(n)return i;let a=this.options.recursive?this.options.depth??M_i:Math.min(1,this.options.depth??M_i),u=this.options.limit??Hba,[l,f]=await tm.fs.readdir(r,this.options.ignore,a,u,this.watcher._closeSignal),s=[...l,...f];return await Promise.all(s.map(o=>{if(!this.watcher.isIgnored(o,this.options.ignore)&&!t.includes(o))return this.eventsPopulate([o],i,!0)})),i}async eventsPopulateUnlinkDir(t,r,i=[],n=!1){if(n)return i;for(let a of this.watcher._poller.stats.keys())tm.fs.isSubPath(r,a)&&(t.includes(a)||await this.eventsPopulate([a],i,!0));return i}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(Ib.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!A_i&&this.options.native!==!1&&this.watcher.watchDirectory(t,this.options,this.handler,void 0,this.base||this),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAddDir(t,this.options.renameTimeout):this.watcher.event(Ib.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(Ib.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(YFo.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(Ib.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(YFo.default.dirname(t),t,!1),this.watcher.watchersClose(t),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlinkDir(t,this.options.renameTimeout):this.watcher.event(Ib.UNLINK_DIR,t))}onTargetEvent(t){let[r,i]=t;r===Ib.ADD?this.onTargetAdd(i):r===Ib.ADD_DIR?this.onTargetAddDir(i):r===Ib.CHANGE?this.onTargetChange(i):r===Ib.UNLINK?this.onTargetUnlink(i):r===Ib.UNLINK_DIR&&this.onTargetUnlinkDir(i)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,i=!1){return this.handlerBatched(t,r,i)}onWatcherChange(t=FFi.CHANGE,r){if(this.watcher.isClosed())return;let i=YFo.default.resolve(this.folderPath,r||"");this.filePath&&i!==this.folderPath&&i!==this.filePath||this.watcher.isIgnored(i,this.options.ignore)||this.onWatcherEvent(t,i)}onWatcherError(t){zXs&&t.code==="EPERM"?this.onWatcherChange(FFi.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on($ba.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on($ba.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(FFi.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&A_i&&this.options.native!==!1?this.options.depth??M_i:Math.min(1,this.options.depth??M_i),i=this.options.limit??Hba,[n,a]=await tm.fs.readdir(this.folderPath,this.options.ignore,r,i,this.watcher._closeSignal,this.options.readdirMap),u=[this.folderPath,...n,...a];await Promise.all(u.map(l=>{if(!this.watcher._poller.stats.has(l)&&!this.watcher.isIgnored(l,this.options.ignore))return this.onWatcherEvent(FFi.CHANGE,l,t)}))}}},GZp=WXs;var HX={interval:100,intervalId:void 0,fns:new Map,init:()=>{HX.intervalId||(HX.intervalId=setInterval(HX.resolve,HX.interval))},reset:()=>{HX.intervalId&&(clearInterval(HX.intervalId),delete HX.intervalId)},add:(e,t)=>{HX.fns.set(e,Date.now()+t),HX.init()},remove:e=>{HX.fns.delete(e)},resolve:()=>{if(!HX.fns.size)return HX.reset();let e=Date.now();for(let[t,r]of HX.fns)r>=e||(HX.remove(t),t())}},Jba=HX;var Kba=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=RXs){let{ino:i,targetPath:n,events:a,locks:u}=t,l=()=>{let c=this._watcher._poller.paths.find(i||-1,b=>b!==n);if(c&&c!==n){if(tm.fs.getRealPath(n,!0)===c)return;this._watcher.event(a.rename,c,n)}else this._watcher.event(a.add,n)};if(!i)return l();let f=()=>{u.add.delete(i),Jba.remove(s)},s=()=>{f(),l()};Jba.add(s,r);let o=()=>{let c=u.unlink.get(i);if(!c)return;f();let b=c();n===b?a.change&&this._watcher._poller.stats.has(n)&&this._watcher.event(a.change,n):this._watcher.event(a.rename,b,n)};u.add.set(i,o),o()}getLockUnlink(t,r=RXs){let{ino:i,targetPath:n,events:a,locks:u}=t,l=()=>{this._watcher.event(a.unlink,n)};if(!i)return l();let f=()=>{u.unlink.delete(i),Jba.remove(s)},s=()=>{f(),l()};Jba.add(s,r);let o=()=>(f(),n);u.unlink.set(i,o),u.add.get(i)?.()}getLockTargetAdd(t,r){let i=this._watcher._poller.getIno(t,Ib.ADD,TZt.FILE);return this.getLockAdd({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let i=this._watcher._poller.getIno(t,Ib.ADD_DIR,TZt.DIR);return this.getLockAdd({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let i=this._watcher._poller.getIno(t,Ib.UNLINK,TZt.FILE);return this.getLockUnlink({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let i=this._watcher._poller.getIno(t,Ib.UNLINK_DIR,TZt.DIR);return this.getLockUnlink({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}reset(){this._locksAdd=new Map,this._locksAddDir=new Map,this._locksUnlink=new Map,this._locksUnlinkDir=new Map,this._locksDir={add:this._locksAddDir,unlink:this._locksUnlinkDir},this._locksFile={add:this._locksAdd,unlink:this._locksUnlink}}};Kba.DIR_EVENTS={add:Ib.ADD_DIR,rename:Ib.RENAME_DIR,unlink:Ib.UNLINK_DIR};Kba.FILE_EVENTS={add:Ib.ADD,change:Ib.CHANGE,rename:Ib.RENAME,unlink:Ib.UNLINK};var QZp=Kba;var HXs=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(tm.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let i=this.map.get(t);if(tm.lang.isSet(i)){let n=i.delete(r);return i.size||this.map.delete(t),n}else if(i===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let i=this.map.get(t);if(tm.lang.isSet(i))return Array.from(i).find(r);if(r(i))return i}}get(t){return this.map.get(t)}has(t,r){if(tm.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let i=this.map.get(t);return tm.lang.isSet(i)?i.has(r):i===r}return!1}set(t,r){if(this.map.has(t)){let i=this.map.get(t);tm.lang.isSet(i)?i.add(r):i!==r&&this.map.set(t,new Set([i,r]))}else this.map.set(t,r);return this}},$Xs=HXs;var GXs=class{constructor(t){this.ino=t.ino<=Number.MAX_SAFE_INTEGER?Number(t.ino):t.ino,this.size=Number(t.size),this.atimeMs=Number(t.atimeMs),this.mtimeMs=Number(t.mtimeMs),this.ctimeMs=Number(t.ctimeMs),this.birthtimeMs=Number(t.birthtimeMs),this._isFile=t.isFile(),this._isDirectory=t.isDirectory(),this._isSymbolicLink=t.isSymbolicLink()}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isSymbolicLink(){return this._isSymbolicLink}},JZp=GXs;var QXs=class{constructor(){this.inos={},this.paths=new $Xs,this.stats=new Map}getIno(t,r,i){let n=this.inos[r];if(!n)return;let a=n[t];if(a&&!(i&&a[1]!==i))return a[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let i=await tm.fs.poll(t,r);if(!(!i||!(i.isFile()||i.isDirectory())))return new JZp(i)}reset(){this.inos={},this.paths=new $Xs,this.stats=new Map}async update(t,r){let i=this.getStats(t),n=await this.poll(t,r);if(this.updateStats(t,n),!i&&n){if(n.isFile())return this.updateIno(t,Ib.ADD,n),[Ib.ADD];if(n.isDirectory())return this.updateIno(t,Ib.ADD_DIR,n),[Ib.ADD_DIR]}else if(i&&!n){if(i.isFile())return this.updateIno(t,Ib.UNLINK,i),[Ib.UNLINK];if(i.isDirectory())return this.updateIno(t,Ib.UNLINK_DIR,i),[Ib.UNLINK_DIR]}else if(i&&n){if(i.isFile()){if(n.isFile())return i.ino===n.ino&&!i.size&&!n.size?[]:(this.updateIno(t,Ib.CHANGE,n),[Ib.CHANGE]);if(n.isDirectory())return this.updateIno(t,Ib.UNLINK,i),this.updateIno(t,Ib.ADD_DIR,n),[Ib.UNLINK,Ib.ADD_DIR]}else if(i.isDirectory()){if(n.isFile())return this.updateIno(t,Ib.UNLINK_DIR,i),this.updateIno(t,Ib.ADD,n),[Ib.UNLINK_DIR,Ib.ADD];if(n.isDirectory())return i.ino===n.ino?[]:(this.updateIno(t,Ib.UNLINK_DIR,i),this.updateIno(t,Ib.ADD_DIR,n),[Ib.UNLINK_DIR,Ib.ADD_DIR])}}return[]}updateIno(t,r,i){let n=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=i.isFile()?TZt.FILE:TZt.DIR;n[t]=[i.ino,a]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let i=this.stats.get(t)?.ino||-1;this.paths.delete(i,t),this.stats.delete(t)}}},JXs=QXs;var KXs=class e extends KZp.EventEmitter{constructor(t,r,i){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(WX.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(n=>this.on(WX.CLOSE,n)),this._readyWait=new Promise(n=>this.on(WX.READY,n)),this._locker=new QZp(this),this._roots=new Set,this._poller=new JXs,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,i)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(tm.lang.isFunction(r)?!!r(t):r.test(t))}isReady(){return this._ready}close(){return this._locker.reset(),this._poller.reset(),this._roots.clear(),this.watchersClose(),this.isClosed()?!1:(this._closed=!0,this.emit(WX.CLOSE))}error(t){if(this.isClosed())return!1;let r=tm.lang.castError(t);return this.emit(WX.ERROR,r)}event(t,r,i){return this.isClosed()?!1:(this.emit(WX.ALL,t,r,i),this.emit(t,r,i))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(WX.READY))}pollerExists(t,r){for(let i of this._pollers)if(i.targetPath===t&&tm.lang.isShallowEqual(i.options,r))return!0;return!1}subwatcherExists(t,r){for(let i of this._subwatchers)if(i.targetPath===t&&tm.lang.isShallowEqual(i.options,r))return!0;return!1}watchersClose(t,r,i=!0){if(t){let n=this._watchers[t];if(n)for(let a of[...n])r&&a.filePath!==r||this.watcherClose(a);if(i)for(let a in this._watchers)tm.fs.isSubPath(t,a)&&this.watchersClose(a,r,!1)}else for(let n in this._watchers)this.watchersClose(n,r,!1)}watchersLock(t){return this._watchersLock.then(()=>this._watchersLock=new Promise(async r=>{await t(),r()}))}watchersRestore(){delete this._watchersRestoreTimeout;let t=Object.entries(this._watchersRestorable);this._watchersRestorable={};for(let[r,i]of t)this.watchPath(r,i.options,i.handler)}async watcherAdd(t,r){let{folderPath:i}=t;(this._watchers[i]=this._watchers[i]||[]).push(t);let a=new GZp(this,t,r);return await a.init(),a}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let a=r.indexOf(t);r.splice(a,1),r.length||delete this._watchers[t.folderPath]}let i=t.filePath||t.folderPath;this._roots.has(i)&&(this._watchersRestorable[i]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=tm.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,i,n){if(this._watchers[t]?.find(l=>l.handler===i&&(!l.filePath||l.filePath===n)&&l.options.ignore===r.ignore&&!!l.options.native==!!r.native&&(!r.recursive||l.options.recursive)))return!0;let u=LFi.default.dirname(t);for(let l=1;l<1/0;l++){if(this._watchers[u]?.find(o=>(l===1||o.options.recursive&&l<=(o.options.depth??M_i))&&o.handler===i&&(!o.filePath||o.filePath===n)&&o.options.ignore===r.ignore&&!!o.options.native==!!r.native&&(!r.recursive||o.options.recursive&&A_i&&o.options.native!==!1)))return!0;if(!A_i)break;let s=LFi.default.dirname(t);if(u===s)break;u=s}return!1}async watchDirectories(t,r,i,n,a){if(this.isClosed())return;t=tm.lang.uniq(t).sort();let u;for(let l of t)if(!this.isIgnored(l,r.ignore)&&!this.watcherExists(l,r,i,n))try{let f=!r.recursive||A_i&&r.native!==!1?r:{...r,recursive:!1},o={watcher:XFo.default.watch(l,f),handler:i,options:r,folderPath:l,filePath:n},c=u=await this.watcherAdd(o,a);if(this._roots.has(n||l)){let g={...r,ignoreInitial:!0,recursive:!1},O=LFi.default.dirname(l),m=l;await this.watchDirectories([O],g,i,m,c)}}catch(f){this.error(f)}return u}async watchDirectory(t,r,i,n,a){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||A_i&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,i,n,a));{r={...r,recursive:!0};let u=r.depth??M_i,l=r.limit??Hba,[f]=await tm.fs.readdir(t,r.ignore,u,l,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let s=await this.watchDirectories([t],r,i,n,a);if(f.length){let o=tm.fs.getDepth(t);for(let c of f){let b=tm.fs.getDepth(c),g=Math.max(0,u-(b-o)),O={...r,depth:g};await this.watchDirectories([c],O,i,n,a||s)}}})}}}async watchFileOnce(t,r,i){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let n={targetPath:t,options:r},a=(s,o)=>{o===t&&(f(),i())},u=new e(a),l=()=>{this._subwatchers.add(n),this.on(WX.CLOSE,f),u.watchFile(t,r,a)},f=()=>{this._subwatchers.delete(n),this.removeListener(WX.CLOSE,f),u.close()};return l()}async watchFile(t,r,i){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let n=LFi.default.dirname(t);return this.watchDirectory(n,r,i,t)}async watchPollingOnce(t,r,i){if(this.isClosed())return;let n=!1,a=new JXs,u=await this.watchPolling(t,r,async()=>{n||!(await a.update(t,r.pollingTimeout)).length||n||(n=!0,u(),i())})}async watchPolling(t,r,i){if(this.isClosed())return tm.lang.noop;if(this.pollerExists(t,r))return tm.lang.noop;let n={...r,interval:r.pollingInterval??xZp},a={targetPath:t,options:r},u=()=>{this._pollers.add(a),this.on(WX.CLOSE,l),XFo.default.watchFile(t,n,i)},l=()=>{this._pollers.delete(a),this.removeListener(WX.CLOSE,l),XFo.default.unwatchFile(t,i)};return tm.lang.attempt(u),()=>tm.lang.attempt(l)}async watchUnknownChild(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchFileOnce(t,r,n)}async watchUnknownTarget(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchPollingOnce(t,r,n)}async watchPaths(t,r,i){if(this.isClosed())return;if(t=tm.lang.uniq(t).sort(),t.every((a,u)=>t.every((l,f)=>f===u||!tm.fs.isSubPath(a,l))))await Promise.all(t.map(a=>this.watchPath(a,r,i)));else for(let a of t)await this.watchPath(a,r,i)}async watchPath(t,r,i){if(this.isClosed()||(t=LFi.default.resolve(t),this.isIgnored(t,r.ignore)))return;let n=await tm.fs.poll(t,r.pollingTimeout);if(n){if(n.isFile())return this.watchFile(t,r,i);if(n.isDirectory())return this.watchDirectory(t,r,i);this.error(`"${t}" is not supported`)}else{let a=LFi.default.dirname(t);return(await tm.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,i):this.watchUnknownTarget(t,r,i)}}async watch(t,r,i=tm.lang.noop){if(tm.lang.isFunction(t))return this.watch([],{},t);if(tm.lang.isUndefined(t))return this.watch([],r,i);if(tm.lang.isFunction(r))return this.watch(t,{},r);if(tm.lang.isUndefined(r))return this.watch(t,{},i);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let n=tm.lang.castArray(t);n.forEach(a=>this._roots.add(a)),await this.watchPaths(n,r,i),!this.isClosed()&&(i!==tm.lang.noop&&this.on(WX.ALL,i),r.readdirMap=void 0,this.ready())}},ZFo=KXs;var eXD=li(pps(),1),tXD=li(UYa(),1),rXD=li(WYa(),1),YXs=li(JYa(),1),Yba=li(hps(),1);var ep_=li(kFo(),1),tp_=li(e3o(),1),f2o=require("fs/promises"),Tic=li(lXt(),1);function iXD(e){var t=[];if(e.length===0)return"";if(typeof e[0]!="string")throw new TypeError("Url must be a string. Received "+e[0]);if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var r=e.shift();e[0]=r+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(var i=0;i<e.length;i++){var n=e[i];if(typeof n!="string")throw new TypeError("Url must be a string. Received "+n);n!==""&&(i>0&&(n=n.replace(/^[\/]+/,"")),i<e.length-1?n=n.replace(/[\/]+$/,""):n=n.replace(/[\/]+$/,"/"),t.push(n))}var a=t.join("/");a=a.replace(/\/(\?|&|#[^!])/g,"$1");var u=a.split("?");return a=u.shift()+(u.length>0?"?":"")+u.join("&"),a}function Vv(){var e;return typeof arguments[0]=="object"?e=arguments[0]:e=[].slice.call(arguments),iXD(e)}var YZp=require("fs"),t3o=class{parse({absoluteFilePath:t}){let r=(0,YZp.readFileSync)(t,"utf-8"),i=r.match(/option\s+csharp_namespace\s*=\s*"([^"]+)";/),n=r.match(/package\s+([a-zA-Z_][\w.]*);/),a=r.match(/service\s+([a-zA-Z_]\w*)\s*{/);return{csharpNamespace:i?.[1],packageName:n?.[1],serviceName:a?.[1]}}};var NF=class{context;workspace;sourceCache;constructor(t,r){this.context=t,this.workspace=r,this.sourceCache=new Map}resolveSourceOrThrow({source:t,relativeFilepath:r}){let i=this.resolveSource({source:t});if(i==null){if(vJt(t))throw new Error(`Cannot resolve source ${t.proto} from file ${r}`);this.context.logger.warn(`Cannot resolve source ${t.openapi} from file ${r}`)}return i}resolveSource({source:t}){return vJt(t)?this.resolveProtobufSource({source:t}):this.resolveOpenAPISource({source:t})}resolveProtobufSource({source:t}){let r=Lu(this.workspace.absoluteFilePath,Qa.of(t.proto));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!SQr(r))return;let n=new t3o().parse({absoluteFilePath:r}),a={type:"protobuf",absoluteFilePath:r,relativeFilePath:Qa.of(t.proto),csharpNamespace:n.csharpNamespace,packageName:n.packageName,serviceName:n.serviceName};return this.sourceCache.set(r,a),a}resolveOpenAPISource({source:t}){let r=Lu(this.workspace.absoluteFilePath,Qa.of(t.openapi));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!SQr(r))return;let i={type:"openapi",absoluteFilePath:r,relativeFilePath:Qa.of(t.openapi)};return this.sourceCache.set(r,i),i}};var t0a=li(lXt(),1),ykp=require("path");var PMn=li(VSe(),1);var Xba=class{constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:()=>this.should_skip=!0,remove:()=>this.should_remove=!0,replace:t=>this.replacement=t}}replace(t,r,i,n){t&&r&&(i!=null?t[r][i]=n:t[r]=n)}remove(t,r,i){t&&r&&(i!=null?t[r].splice(i,1):delete t[r])}};var r3o=class extends Xba{constructor(t,r){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:()=>this.should_skip=!0,remove:()=>this.should_remove=!0,replace:i=>this.replacement=i},this.enter=t,this.leave=r}visit(t,r,i,n){if(t){if(this.enter){let u=this.should_skip,l=this.should_remove,f=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,r,i,n),this.replacement&&(t=this.replacement,this.replace(r,i,n,t)),this.should_remove&&this.remove(r,i,n);let s=this.should_skip,o=this.should_remove;if(this.should_skip=u,this.should_remove=l,this.replacement=f,s)return t;if(o)return null}let a;for(a in t){let u=t[a];if(u&&typeof u=="object")if(Array.isArray(u)){let l=u;for(let f=0;f<l.length;f+=1){let s=l[f];XZp(s)&&(this.visit(s,t,a,f)||f--)}}else XZp(u)&&this.visit(u,t,a,null)}if(this.leave){let u=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,r,i,n),this.replacement&&(t=this.replacement,this.replace(r,i,n,t)),this.should_remove&&this.remove(r,i,n);let f=this.should_remove;if(this.replacement=u,this.should_remove=l,f)return null}}return t}};function XZp(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}function xZt(e,{enter:t,leave:r}){return new r3o(t,r).visit(e,null)}function jYr(e){if(e==null)return;let t=[],r=!1;if(xZt(e,{enter(i){(i.type==="FunctionDeclaration"||i.type==="ArrowFunctionExpression"||i.type==="JSXOpeningElement"||i.type==="JSXOpeningFragment"||i.type==="Identifier")&&(r=!0,this.skip()),i.type==="Literal"&&t.push(i.value)}}),!r)return t.length===1?t[0]:void 0}function q_i(e){if(typeof e=="string")return e;if(e?.type==="mdxJsxAttributeValueExpression")return jYr(e.data?.estree)}function i3o(e){return e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement"}function n3o(e){return e.type==="mdxFlowExpression"||e.type==="mdxTextExpression"}function wYr(e){return e.type==="mdxJsxAttribute"}function a3o(e){return e.type==="mdxJsxExpressionAttribute"}var hkp=li(lXt(),1);var ZZp={tokenize:nXD};function nXD(e){let t=e.attempt(this.parser.constructs.contentInitial,i,n),r;return t;function i(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),ey(e,t,"linePrefix")}function n(l){return e.enter("paragraph"),a(l)}function a(l){let f=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=f),r=f,u(l)}function u(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return Gf(l)?(e.consume(l),e.exit("chunkText"),a):(e.consume(l),u)}}var ekp={tokenize:aXD},kZp={tokenize:oXD};function aXD(e){let t=this,r=[],i=0,n,a,u;return l;function l(A){if(i<r.length){let D=r[i];return t.containerState=D[1],e.attempt(D[0].continuation,f,s)(A)}return s(A)}function f(A){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,n&&q();let D=t.events.length,C=D,z;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){z=t.events[C][1].end;break}E(i);let $=D;for(;$<t.events.length;)t.events[$][1].end=Object.assign({},z),$++;return I7(t.events,C+1,0,t.events.slice(D)),t.events.length=$,s(A)}return l(A)}function s(A){if(i===r.length){if(!n)return b(A);if(n.currentConstruct&&n.currentConstruct.concrete)return O(A);t.interrupt=!!(n.currentConstruct&&!n._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(kZp,o,c)(A)}function o(A){return n&&q(),E(i),b(A)}function c(A){return t.parser.lazy[t.now().line]=i!==r.length,u=t.now().offset,O(A)}function b(A){return t.containerState={},e.attempt(kZp,g,O)(A)}function g(A){return i++,r.push([t.currentConstruct,t.containerState]),b(A)}function O(A){if(A===null){n&&q(),E(0),e.consume(A);return}return n=n||t.parser.flow(t.now()),e.enter("chunkFlow",{contentType:"flow",previous:a,_tokenizer:n}),m(A)}function m(A){if(A===null){P(e.exit("chunkFlow"),!0),E(0),e.consume(A);return}return Gf(A)?(e.consume(A),P(e.exit("chunkFlow")),i=0,t.interrupt=void 0,l):(e.consume(A),m)}function P(A,D){let C=t.sliceStream(A);if(D&&C.push(null),A.previous=a,a&&(a.next=A),a=A,n.defineSkip(A.start),n.write(C),t.parser.lazy[A.start.line]){let z=n.events.length;for(;z--;)if(n.events[z][1].start.offset<u&&(!n.events[z][1].end||n.events[z][1].end.offset>u))return;let $=t.events.length,x=$,L,V;for(;x--;)if(t.events[x][0]==="exit"&&t.events[x][1].type==="chunkFlow"){if(L){V=t.events[x][1].end;break}L=!0}for(E(i),z=$;z<t.events.length;)t.events[z][1].end=Object.assign({},V),z++;I7(t.events,x+1,0,t.events.slice($)),t.events.length=z}}function E(A){let D=r.length;for(;D-- >A;){let C=r[D];t.containerState=C[1],C[0].exit.call(t,e)}r.length=A}function q(){n.write([null]),a=void 0,n=void 0,t.containerState._closeFlow=void 0}}function oXD(e,t,r){return ey(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}var tkp={tokenize:uXD};function uXD(e){let t=this,r=e.attempt(yze,i,e.attempt(this.parser.constructs.flowInitial,n,ey(e,e.attempt(this.parser.constructs.flow,n,e.attempt(SFs,n)),"linePrefix")));return r;function i(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function n(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,r}}var rkp={resolveAll:okp()},ikp=akp("string"),nkp=akp("text");function akp(e){return{tokenize:t,resolveAll:okp(e==="text"?sXD:void 0)};function t(r){let i=this,n=this.parser.constructs[e],a=r.attempt(n,u,l);return u;function u(o){return s(o)?a(o):l(o)}function l(o){if(o===null){r.consume(o);return}return r.enter("data"),r.consume(o),f}function f(o){return s(o)?(r.exit("data"),a(o)):(r.consume(o),f)}function s(o){if(o===null)return!0;let c=n[o],b=-1;if(c)for(;++b<c.length;){let g=c[b];if(!g.previous||g.previous.call(i,i.previous))return!0}return!1}}}function okp(e){return t;function t(r,i){let n=-1,a;for(;++n<=r.length;)a===void 0?r[n]&&r[n][1].type==="data"&&(a=n,n++):(!r[n]||r[n][1].type!=="data")&&(n!==a+2&&(r[a][1].end=r[n-1][1].end,r.splice(a+2,n-a-2),n=a+2),a=void 0);return e?e(r,i):r}}function sXD(e,t){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){let i=e[r-1][1],n=t.sliceStream(i),a=n.length,u=-1,l=0,f;for(;a--;){let s=n[a];if(typeof s=="string"){for(u=s.length;s.charCodeAt(u-1)===32;)l++,u--;if(u)break;u=-1}else if(s===-2)f=!0,l++;else if(s!==-1){a++;break}}if(l){let s={type:r===e.length||f||l<2?"lineSuffix":"hardBreakTrailing",start:{line:i.end.line,column:i.end.column-l,offset:i.end.offset-l,_index:i.start._index+a,_bufferIndex:a?u:i.start._bufferIndex+u},end:Object.assign({},i.end)};i.end=Object.assign({},s.start),i.start.offset===i.end.offset?Object.assign(i,s):(e.splice(r,0,["enter",s,t],["exit",s,t]),r+=2)}r++}return e}function ukp(e,t,r){let i=Object.assign(r?Object.assign({},r):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1}),n={},a=[],u=[],l=[],f=!0,s={consume:D,enter:C,exit:z,attempt:L($),check:L(x),interrupt:L(x,{interrupt:!0})},o={previous:null,code:null,containerState:{},events:[],parser:e,sliceStream:m,sliceSerialize:O,now:P,defineSkip:E,write:g},c=t.tokenize.call(o,s),b;return t.resolveAll&&a.push(t),o;function g(Z){return u=lX(u,Z),q(),u[u.length-1]!==null?[]:(V(t,0),o.events=Rfi(a,o.events,o),o.events)}function O(Z,fe){return lXD(m(Z),fe)}function m(Z){return cXD(u,Z)}function P(){let{line:Z,column:fe,offset:me,_index:_e,_bufferIndex:Se}=i;return{line:Z,column:fe,offset:me,_index:_e,_bufferIndex:Se}}function E(Z){n[Z.line]=Z.column,J()}function q(){let Z;for(;i._index<u.length;){let fe=u[i._index];if(typeof fe=="string")for(Z=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===Z&&i._bufferIndex<fe.length;)A(fe.charCodeAt(i._bufferIndex));else A(fe)}}function A(Z){f=void 0,b=Z,c=c(Z)}function D(Z){Gf(Z)?(i.line++,i.column=1,i.offset+=Z===-3?2:1,J()):Z!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===u[i._index].length&&(i._bufferIndex=-1,i._index++)),o.previous=Z,f=!0}function C(Z,fe){let me=fe||{};return me.type=Z,me.start=P(),o.events.push(["enter",me,o]),l.push(me),me}function z(Z){let fe=l.pop();return fe.end=P(),o.events.push(["exit",fe,o]),fe}function $(Z,fe){V(Z,fe.from)}function x(Z,fe){fe.restore()}function L(Z,fe){return me;function me(_e,Se,Qe){let Dt,Ee,Te,It;return Array.isArray(_e)?gt(_e):"tokenize"in _e?gt([_e]):je(_e);function je(ft){return St;function St(hr){let nr=hr!==null&&ft[hr],ti=hr!==null&&ft.null,hn=[...Array.isArray(nr)?nr:nr?[nr]:[],...Array.isArray(ti)?ti:ti?[ti]:[]];return gt(hn)(hr)}}function gt(ft){return Dt=ft,Ee=0,ft.length===0?Qe:Ot(ft[Ee])}function Ot(ft){return St;function St(hr){return It=X(),Te=ft,ft.partial||(o.currentConstruct=ft),ft.name&&o.parser.constructs.disable.null.includes(ft.name)?Pe(hr):ft.tokenize.call(fe?Object.assign(Object.create(o),fe):o,s,ye,Pe)(hr)}}function ye(ft){return f=!0,Z(Te,It),Se}function Pe(ft){return f=!0,It.restore(),++Ee<Dt.length?Ot(Dt[Ee]):Qe}}}function V(Z,fe){Z.resolveAll&&!a.includes(Z)&&a.push(Z),Z.resolve&&I7(o.events,fe,o.events.length-fe,Z.resolve(o.events.slice(fe),o)),Z.resolveTo&&(o.events=Z.resolveTo(o.events,o))}function X(){let Z=P(),fe=o.previous,me=o.currentConstruct,_e=o.events.length,Se=Array.from(l);return{restore:Qe,from:_e};function Qe(){i=Z,o.previous=fe,o.currentConstruct=me,o.events.length=_e,l=Se,J()}}function J(){i.line in n&&i.column<2&&(i.column=n[i.line],i.offset+=n[i.line]-1)}}function cXD(e,t){let r=t.start._index,i=t.start._bufferIndex,n=t.end._index,a=t.end._bufferIndex,u;if(r===n)u=[e[r].slice(i,a)];else{if(u=e.slice(r,n),i>-1){let l=u[0];typeof l=="string"?u[0]=l.slice(i):u.shift()}a>0&&u.push(e[n].slice(0,a))}return u}function lXD(e,t){let r=-1,i=[],n;for(;++r<e.length;){let a=e[r],u;if(typeof a=="string")u=a;else switch(a){case-5:{u="\r";break}case-4:{u=`
1964
1964
  `;break}case-3:{u=`\r
1965
1965
  `;break}case-2:{u=t?" ":" ";break}case-1:{if(!t&&n)continue;u=" ";break}default:u=String.fromCharCode(a)}n=a===-2,i.push(u)}return i.join("")}var tZs={};Oo(tZs,{attentionMarkers:()=>bXD,contentInitial:()=>dXD,disable:()=>gXD,document:()=>fXD,flow:()=>_XD,flowInitial:()=>pXD,insideSpan:()=>vXD,string:()=>hXD,text:()=>yXD});var fXD={42:DG,43:DG,45:DG,48:DG,49:DG,50:DG,51:DG,52:DG,53:DG,54:DG,55:DG,56:DG,57:DG,62:xjo},dXD={91:DFs},pXD={[-2]:tfa,[-1]:tfa,32:tfa},_XD={35:MFs,42:Vzi,45:[Wjo,Vzi],60:qFs,61:Wjo,95:Vzi,96:Rjo,126:Rjo},hXD={38:zjo,92:Ijo},yXD={[-5]:ifa,[-4]:ifa,[-3]:ifa,33:CFs,38:zjo,42:efa,60:[jFs,TFs],91:BFs,92:[EFs,Ijo],93:Uzi,95:efa,96:wFs},vXD={null:[efa,rkp]},bXD={null:[42,95]},gXD={null:[]};function rZs(e){let r=WPn([tZs,...(e||{}).extensions||[]]),i={defined:[],lazy:{},constructs:r,content:n(ZZp),document:n(ekp),flow:n(tkp),string:n(ikp),text:n(nkp)};return i;function n(a){return u;function u(l){return ukp(i,a,l)}}}function iZs(e){for(;!Fjo(e););return e}var skp=/[\0\t\n\r]/g;function nZs(){let e=1,t="",r=!0,i;return n;function n(a,u,l){let f=[],s,o,c,b,g;for(a=t+(typeof a=="string"?a.toString():new TextDecoder(u||void 0).decode(a)),c=0,t="",r&&(a.charCodeAt(0)===65279&&c++,r=void 0);c<a.length;){if(skp.lastIndex=c,s=skp.exec(a),b=s&&s.index!==void 0?s.index:a.length,g=a.charCodeAt(b),!s){t=a.slice(c);break}if(g===10&&c===b&&i)f.push(-3),i=void 0;else switch(i&&(f.push(-5),i=void 0),c<b&&(f.push(a.slice(c,b)),e+=b-c),g){case 0:{f.push(65533),e++;break}case 9:{for(o=Math.ceil(e/4)*4,f.push(-2);e++<o;)f.push(-1);break}case 10:{f.push(-4),e=1;break}default:i=!0,e=1}c=b+1}return l&&(i&&f.push(-5),t&&f.push(t),f.push(null)),f}}var lkp={}.hasOwnProperty;function Zba(e,t,r){return typeof t!="string"&&(r=t,t=void 0),OXD(r)(iZs(rZs(r).document().write(nZs()(e,t,!0))))}function OXD(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(Rt),autolinkProtocol:L,autolinkEmail:L,atxHeading:a(kt),blockQuote:a(hr),characterEscape:L,characterReference:L,codeFenced:a(nr),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:a(nr,u),codeText:a(ti,u),codeTextData:L,data:L,codeFlowValue:L,definition:a(hn),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:a(Bn),hardBreakEscape:a(Tt),hardBreakTrailing:a(Tt),htmlFlow:a(sr,u),htmlFlowData:L,htmlText:a(sr,u),htmlTextData:L,image:a(er),label:u,link:a(Rt),listItem:a(Cr),listItemValue:b,listOrdered:a(qi,c),listUnordered:a(qi),paragraph:a(ri),reference:je,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:a(kt),strong:a(an),thematicBreak:a(ua)},exit:{atxHeading:f(),atxHeadingSequence:C,autolink:f(),autolinkEmail:St,autolinkProtocol:ft,blockQuote:f(),characterEscapeValue:V,characterReferenceMarkerHexadecimal:Ot,characterReferenceMarkerNumeric:Ot,characterReferenceValue:ye,characterReference:Pe,codeFenced:f(P),codeFencedFence:m,codeFencedFenceInfo:g,codeFencedFenceMeta:O,codeFlowValue:V,codeIndented:f(E),codeText:f(me),codeTextData:V,data:V,definition:f(),definitionDestinationString:D,definitionLabelString:q,definitionTitleString:A,emphasis:f(),hardBreakEscape:f(J),hardBreakTrailing:f(J),htmlFlow:f(Z),htmlFlowData:V,htmlText:f(fe),htmlTextData:V,image:f(Se),label:Dt,labelText:Qe,lineEnding:X,link:f(_e),listItem:f(),listOrdered:f(),listUnordered:f(),paragraph:f(),referenceString:gt,resourceDestinationString:Ee,resourceTitleString:Te,resource:It,setextHeading:f(x),setextHeadingLineSequence:$,setextHeadingText:z,strong:f(),thematicBreak:f()}};fkp(t,(e||{}).mdastExtensions||[]);let r={};return i;function i(xt){let Qt={type:"root",children:[]},Me={stack:[Qt],tokenStack:[],config:t,enter:l,exit:s,buffer:u,resume:o,data:r},Ze=[],Xt=-1;for(;++Xt<xt.length;)if(xt[Xt][1].type==="listOrdered"||xt[Xt][1].type==="listUnordered")if(xt[Xt][0]==="enter")Ze.push(Xt);else{let or=Ze.pop();Xt=n(xt,or,Xt)}for(Xt=-1;++Xt<xt.length;){let or=t[xt[Xt][0]];lkp.call(or,xt[Xt][1].type)&&or[xt[Xt][1].type].call(Object.assign({sliceSerialize:xt[Xt][2].sliceSerialize},Me),xt[Xt][1])}if(Me.tokenStack.length>0){let or=Me.tokenStack[Me.tokenStack.length-1];(or[1]||ckp).call(Me,void 0,or[0])}for(Qt.position={start:T_i(xt.length>0?xt[0][1].start:{line:1,column:1,offset:0}),end:T_i(xt.length>0?xt[xt.length-2][1].end:{line:1,column:1,offset:0})},Xt=-1;++Xt<t.transforms.length;)Qt=t.transforms[Xt](Qt)||Qt;return Qt}function n(xt,Qt,Me){let Ze=Qt-1,Xt=-1,or=!1,Ur,Vi,Ji,Vr;for(;++Ze<=Me;){let Je=xt[Ze];switch(Je[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Je[0]==="enter"?Xt++:Xt--,Vr=void 0;break}case"lineEndingBlank":{Je[0]==="enter"&&(Ur&&!Vr&&!Xt&&!Ji&&(Ji=Ze),Vr=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Vr=void 0}if(!Xt&&Je[0]==="enter"&&Je[1].type==="listItemPrefix"||Xt===-1&&Je[0]==="exit"&&(Je[1].type==="listUnordered"||Je[1].type==="listOrdered")){if(Ur){let nt=Ze;for(Vi=void 0;nt--;){let Ce=xt[nt];if(Ce[1].type==="lineEnding"||Ce[1].type==="lineEndingBlank"){if(Ce[0]==="exit")continue;Vi&&(xt[Vi][1].type="lineEndingBlank",or=!0),Ce[1].type="lineEnding",Vi=nt}else if(!(Ce[1].type==="linePrefix"||Ce[1].type==="blockQuotePrefix"||Ce[1].type==="blockQuotePrefixWhitespace"||Ce[1].type==="blockQuoteMarker"||Ce[1].type==="listItemIndent"))break}Ji&&(!Vi||Ji<Vi)&&(Ur._spread=!0),Ur.end=Object.assign({},Vi?xt[Vi][1].start:Je[1].end),xt.splice(Vi||Ze,0,["exit",Ur,Je[2]]),Ze++,Me++}if(Je[1].type==="listItemPrefix"){let nt={type:"listItem",_spread:!1,start:Object.assign({},Je[1].start),end:void 0};Ur=nt,xt.splice(Ze,0,["enter",nt,Je[2]]),Ze++,Me++,Ji=void 0,Vr=!0}}}return xt[Qt][1]._spread=or,Me}function a(xt,Qt){return Me;function Me(Ze){l.call(this,xt(Ze),Ze),Qt&&Qt.call(this,Ze)}}function u(){this.stack.push({type:"fragment",children:[]})}function l(xt,Qt,Me){this.stack[this.stack.length-1].children.push(xt),this.stack.push(xt),this.tokenStack.push([Qt,Me||void 0]),xt.position={start:T_i(Qt.start),end:void 0}}function f(xt){return Qt;function Qt(Me){xt&&xt.call(this,Me),s.call(this,Me)}}function s(xt,Qt){let Me=this.stack.pop(),Ze=this.tokenStack.pop();if(Ze)Ze[0].type!==xt.type&&(Qt?Qt.call(this,xt,Ze[0]):(Ze[1]||ckp).call(this,xt,Ze[0]));else throw new Error("Cannot close `"+xt.type+"` ("+cDe({start:xt.start,end:xt.end})+"): it\u2019s not open");Me.position.end=T_i(xt.end)}function o(){return XJr(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function b(xt){if(this.data.expectingFirstListItemValue){let Qt=this.stack[this.stack.length-2];Qt.start=Number.parseInt(this.sliceSerialize(xt),10),this.data.expectingFirstListItemValue=void 0}}function g(){let xt=this.resume(),Qt=this.stack[this.stack.length-1];Qt.lang=xt}function O(){let xt=this.resume(),Qt=this.stack[this.stack.length-1];Qt.meta=xt}function m(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function P(){let xt=this.resume(),Qt=this.stack[this.stack.length-1];Qt.value=xt.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){let xt=this.resume(),Qt=this.stack[this.stack.length-1];Qt.value=xt.replace(/(\r?\n|\r)$/g,"")}function q(xt){let Qt=this.resume(),Me=this.stack[this.stack.length-1];Me.label=Qt,Me.identifier=SG(this.sliceSerialize(xt)).toLowerCase()}function A(){let xt=this.resume(),Qt=this.stack[this.stack.length-1];Qt.title=xt}function D(){let xt=this.resume(),Qt=this.stack[this.stack.length-1];Qt.url=xt}function C(xt){let Qt=this.stack[this.stack.length-1];if(!Qt.depth){let Me=this.sliceSerialize(xt).length;Qt.depth=Me}}function z(){this.data.setextHeadingSlurpLineEnding=!0}function $(xt){let Qt=this.stack[this.stack.length-1];Qt.depth=this.sliceSerialize(xt).codePointAt(0)===61?1:2}function x(){this.data.setextHeadingSlurpLineEnding=void 0}function L(xt){let Me=this.stack[this.stack.length-1].children,Ze=Me[Me.length-1];(!Ze||Ze.type!=="text")&&(Ze=ja(),Ze.position={start:T_i(xt.start),end:void 0},Me.push(Ze)),this.stack.push(Ze)}function V(xt){let Qt=this.stack.pop();Qt.value+=this.sliceSerialize(xt),Qt.position.end=T_i(xt.end)}function X(xt){let Qt=this.stack[this.stack.length-1];if(this.data.atHardBreak){let Me=Qt.children[Qt.children.length-1];Me.position.end=T_i(xt.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Qt.type)&&(L.call(this,xt),V.call(this,xt))}function J(){this.data.atHardBreak=!0}function Z(){let xt=this.resume(),Qt=this.stack[this.stack.length-1];Qt.value=xt}function fe(){let xt=this.resume(),Qt=this.stack[this.stack.length-1];Qt.value=xt}function me(){let xt=this.resume(),Qt=this.stack[this.stack.length-1];Qt.value=xt}function _e(){let xt=this.stack[this.stack.length-1];if(this.data.inReference){let Qt=this.data.referenceType||"shortcut";xt.type+="Reference",xt.referenceType=Qt,delete xt.url,delete xt.title}else delete xt.identifier,delete xt.label;this.data.referenceType=void 0}function Se(){let xt=this.stack[this.stack.length-1];if(this.data.inReference){let Qt=this.data.referenceType||"shortcut";xt.type+="Reference",xt.referenceType=Qt,delete xt.url,delete xt.title}else delete xt.identifier,delete xt.label;this.data.referenceType=void 0}function Qe(xt){let Qt=this.sliceSerialize(xt),Me=this.stack[this.stack.length-2];Me.label=Bjo(Qt),Me.identifier=SG(Qt).toLowerCase()}function Dt(){let xt=this.stack[this.stack.length-1],Qt=this.resume(),Me=this.stack[this.stack.length-1];if(this.data.inReference=!0,Me.type==="link"){let Ze=xt.children;Me.children=Ze}else Me.alt=Qt}function Ee(){let xt=this.resume(),Qt=this.stack[this.stack.length-1];Qt.url=xt}function Te(){let xt=this.resume(),Qt=this.stack[this.stack.length-1];Qt.title=xt}function It(){this.data.inReference=void 0}function je(){this.data.referenceType="collapsed"}function gt(xt){let Qt=this.resume(),Me=this.stack[this.stack.length-1];Me.label=Qt,Me.identifier=SG(this.sliceSerialize(xt)).toLowerCase(),this.data.referenceType="full"}function Ot(xt){this.data.characterReferenceType=xt.type}function ye(xt){let Qt=this.sliceSerialize(xt),Me=this.data.characterReferenceType,Ze;Me?(Ze=Cjo(Qt,Me==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ze=ZJr(Qt);let Xt=this.stack[this.stack.length-1];Xt.value+=Ze}function Pe(xt){let Qt=this.stack.pop();Qt.position.end=T_i(xt.end)}function ft(xt){V.call(this,xt);let Qt=this.stack[this.stack.length-1];Qt.url=this.sliceSerialize(xt)}function St(xt){V.call(this,xt);let Qt=this.stack[this.stack.length-1];Qt.url="mailto:"+this.sliceSerialize(xt)}function hr(){return{type:"blockquote",children:[]}}function nr(){return{type:"code",lang:null,meta:null,value:""}}function ti(){return{type:"inlineCode",value:""}}function hn(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Bn(){return{type:"emphasis",children:[]}}function kt(){return{type:"heading",depth:0,children:[]}}function Tt(){return{type:"break"}}function sr(){return{type:"html",value:""}}function er(){return{type:"image",title:null,url:"",alt:null}}function Rt(){return{type:"link",title:null,url:"",children:[]}}function qi(xt){return{type:"list",ordered:xt.type==="listOrdered",start:null,spread:xt._spread,children:[]}}function Cr(xt){return{type:"listItem",spread:xt._spread,checked:null,children:[]}}function ri(){return{type:"paragraph",children:[]}}function an(){return{type:"strong",children:[]}}function ja(){return{type:"text",value:""}}function ua(){return{type:"thematicBreak"}}}function T_i(e){return{line:e.line,column:e.column,offset:e.offset}}function fkp(e,t){let r=-1;for(;++r<t.length;){let i=t[r];Array.isArray(i)?fkp(e,i):mXD(e,i)}}function mXD(e,t){let r;for(r in t)if(lkp.call(t,r))switch(r){case"canContainEols":{let i=t[r];i&&e[r].push(...i);break}case"transforms":{let i=t[r];i&&e[r].push(...i);break}case"enter":case"exit":{let i=t[r];i&&Object.assign(e[r],i);break}}}function ckp(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+cDe({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+cDe({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+cDe({start:t.start,end:t.end})+") is still open")}function kba(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:a},exit:{mathFlow:n,mathFlowFence:i,mathFlowFenceMeta:r,mathFlowValue:l,mathText:u,mathTextData:l}};function e(f){let s={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[s]}},f)}function t(){this.buffer()}function r(){let f=this.resume(),s=this.stack[this.stack.length-1];s.type,s.meta=f}function i(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function n(f){let s=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),o=this.stack[this.stack.length-1];o.type,this.exit(f),o.value=s;let c=o.data.hChildren[0];c.type,c.tagName,c.children.push({type:"text",value:s}),this.data.mathFlowInside=void 0}function a(f){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},f),this.buffer()}function u(f){let s=this.resume(),o=this.stack[this.stack.length-1];o.type,this.exit(f),o.value=s,o.data.hChildren.push({type:"text",value:s})}function l(f){this.config.enter.data.call(this,f),this.config.exit.data.call(this,f)}}var pkp={tokenize:PXD,concrete:!0,name:"mathFlow"},dkp={tokenize:jXD,partial:!0};function PXD(e,t,r){let i=this,n=i.events[i.events.length-1],a=n&&n[1].type==="linePrefix"?n[2].sliceSerialize(n[1],!0).length:0,u=0;return l;function l(q){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),f(q)}function f(q){return q===36?(e.consume(q),u++,f):u<2?r(q):(e.exit("mathFlowFenceSequence"),ey(e,s,"whitespace")(q))}function s(q){return q===null||Gf(q)?c(q):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),o(q))}function o(q){return q===null||Gf(q)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),c(q)):q===36?r(q):(e.consume(q),o)}function c(q){return e.exit("mathFlowFence"),i.interrupt?t(q):e.attempt(dkp,b,P)(q)}function b(q){return e.attempt({tokenize:E,partial:!0},P,g)(q)}function g(q){return(a?ey(e,O,"linePrefix",a+1):O)(q)}function O(q){return q===null?P(q):Gf(q)?e.attempt(dkp,b,P)(q):(e.enter("mathFlowValue"),m(q))}function m(q){return q===null||Gf(q)?(e.exit("mathFlowValue"),O(q)):(e.consume(q),m)}function P(q){return e.exit("mathFlow"),t(q)}function E(q,A,D){let C=0;return ey(q,z,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function z(L){return q.enter("mathFlowFence"),q.enter("mathFlowFenceSequence"),$(L)}function $(L){return L===36?(C++,q.consume(L),$):C<u?D(L):(q.exit("mathFlowFenceSequence"),ey(q,x,"whitespace")(L))}function x(L){return L===null||Gf(L)?(q.exit("mathFlowFence"),A(L)):D(L)}}}function jXD(e,t,r){let i=this;return n;function n(u){return u===null?t(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),a)}function a(u){return i.parser.lazy[i.now().line]?r(u):t(u)}}function _kp(e){let r=(e||{}).singleDollarTextMath;return r==null&&(r=!0),{tokenize:i,resolve:wXD,previous:SXD,name:"mathText"};function i(n,a,u){let l=this,f=0,s,o;return c;function c(P){return n.enter("mathText"),n.enter("mathTextSequence"),b(P)}function b(P){return P===36?(n.consume(P),f++,b):f<2&&!r?u(P):(n.exit("mathTextSequence"),g(P))}function g(P){return P===null?u(P):P===36?(o=n.enter("mathTextSequence"),s=0,m(P)):P===32?(n.enter("space"),n.consume(P),n.exit("space"),g):Gf(P)?(n.enter("lineEnding"),n.consume(P),n.exit("lineEnding"),g):(n.enter("mathTextData"),O(P))}function O(P){return P===null||P===32||P===36||Gf(P)?(n.exit("mathTextData"),g(P)):(n.consume(P),O)}function m(P){return P===36?(n.consume(P),s++,m):s===f?(n.exit("mathTextSequence"),n.exit("mathText"),a(P)):(o.type="mathTextData",O(P))}}}function wXD(e){let t=e.length-4,r=3,i,n;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(i=r;++i<t;)if(e[i][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[r][1].type="mathTextPadding",r+=2,t-=2;break}}for(i=r-1,t++;++i<=t;)n===void 0?i!==t&&e[i][1].type!=="lineEnding"&&(n=i):(i===t||e[i][1].type==="lineEnding")&&(e[n][1].type="mathTextData",i!==n+2&&(e[n][1].end=e[i-1][1].end,e.splice(n+2,i-n-2),t-=i-n-2,i=n+2),n=void 0);return e}function SXD(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function e0a(e){return{flow:{36:pkp},text:{36:_kp(e)}}}function gMn(e){let{content:t}=(0,hkp.default)(e);return Zba(t,{extensions:[tjn(),GPn(),e0a()],mdastExtensions:[Wzi(),Nzi(),kba()]})}function OMn(e,t){xZt(e,{enter(r){r.type==="JSXElement"&&r.openingElement.attributes.forEach(i=>{i.type==="JSXAttribute"&&i.name.type==="JSXIdentifier"&&t[i.name.name]&&t[i.name.name]?.(i,r)})}})}function r0a(e,t){let{content:r,data:i}=(0,t0a.default)(e,{}),n=r,a=new Set;function u(s){let o=mMn(s,t);if(s&&o!=null)return a.add(o),o}mkp(i,["image","og:image","og:logo","twitter:image"],u),Pkp(i,u);let l=gMn(r),f=0;return Bf(l,s=>{if(s.position==null)return;let{start:o,length:c}=Okp(r,s.position),b=n.slice(o+f,o+f+c),g=b;if(s.type==="image"){let m=E9t(s.url),P=mMn(m,t);m!=null&&P!=null&&(a.add(P),g=g.replaceAll(m,P))}function O(m){OMn(m,{src:P=>{let E=E9t(jYr(P.value)),q=mMn(E,t);E&&q&&(a.add(q),g=g.replaceAll(E,q))}})}if(i3o(s)){let m=s.attributes.filter(wYr).find(E=>E.name==="src"),P=E9t(q_i(m?.value));if(m&&P){let E=mMn(P,t);E!=null&&(a.add(E),g=g.replaceAll(P,E))}s.attributes.forEach(E=>{wYr(E)&&typeof E.value!="string"&&E.value!=null&&E.value.data?.estree?O(E.value.data.estree):a3o(E)&&E.data?.estree&&O(E.data.estree)})}if(n3o(s)&&s.data?.estree&&O(s.data.estree),!(g===b&&a.size===0))return n=n.slice(0,o+f)+g+n.slice(o+f+c),f+=g.length-c,up}),{filepaths:[...a],markdown:t0a.default.stringify(n,i)}}function mMn(e,{absolutePathToFernFolder:t,absolutePathToMarkdownFile:r}){return e==null||vkp(e)||bkp(e)?void 0:P0(e.startsWith("/")?t:Jd(r),Qa.of(e.replace(/^\//,"")))}function vkp(e){return/^(https?:)?\/\//.test(e)}function bkp(e){return e.startsWith("data:")}function gkp({href:e,metadata:t,markdownFilesToPathName:r}){if(e!=null&&(e.endsWith(".md")||e.endsWith(".mdx"))){let i=mMn(e,t);if(i!=null){let n=r[i];return n!=null?{type:"replace",slug:n,href:e}:{type:"missing-reference",path:i,href:e}}}}function oZs(e,t,r,i,n){let{content:a,data:u}=(0,t0a.default)(e,{}),l=a,f=gMn(a),s=0;function o(c){if(c==null||vkp(c)||bkp(c))return;if((0,ykp.isAbsolute)(c)){let g=Ul.of(c),O=t.get(g);return O?`file:${O}`:void 0}let b=mMn(c,i);if(b){let g=t.get(b);return g?`file:${g}`:void 0}}return mkp(u,["image","og:image","og:logo","twitter:image"],o),Pkp(u,o),Bf(f,c=>{if(c.position==null)return;let{start:b,length:g}=Okp(a,c.position),O=l.slice(b+s,b+s+g),m=O;function P(A){let D=o(A);A&&D&&(m=m.replace(A,D))}function E(A){let D=gkp({href:A,markdownFilesToPathName:r,metadata:i});A!=null&&D!=null&&D.type==="replace"&&(m=m.replace(A,D.slug))}function q(A){OMn(A,{src:D=>P(E9t(jYr(D.value))),href:D=>E(E9t(jYr(D.value)))})}if(c.type==="image"){let A=E9t(c.url);P(E9t(A))}if(c.type==="link"&&E(E9t(c.url)),i3o(c)){let A=c.attributes.filter(wYr).find(C=>C.name==="src");P(E9t(q_i(A?.value)));let D=c.attributes.find(C=>C.type==="mdxJsxAttribute"&&C.name==="href");E(E9t(q_i(D?.value))),c.attributes.forEach(C=>{wYr(C)&&typeof C.value!="string"&&C.value!=null&&C.value.data?.estree?q(C.value.data.estree):a3o(C)&&C.data?.estree&&q(C.data.estree)})}if(n3o(c)&&c.data?.estree&&q(c.data.estree),m!==O)return l=l.slice(0,b+s)+m+l.slice(b+s+g),s+=m.length-g,up}),t0a.default.stringify(l,u)}function Okp(e,t){let r=e.split(`
1966
- `),i=t.start.column-1;for(let a=0;a<t.start.line-1;a++){let u=r[a];if(u==null)break;i+=u.length+1}let n=0-t.start.column+t.end.column;for(let a=t.start.line-1;a<t.end.line-1;a++){let u=r[a];if(u==null)break;n+=u.length+1}return{start:i,length:n}}function E9t(e){if(typeof e=="string")return e.replace(/#.*$/,"")}function mkp(e,t,r){for(let i of t){let n=e[i];if(n!=null){if(typeof n=="object")n.type==="fileId"&&(e[i]={type:"fileId",value:PMn.FernRegistry.FileId(r(n.value)??n.value)});else if(typeof n=="string"){let a=r(n);e[i]=a?{type:"fileId",value:PMn.FernRegistry.FileId(a)}:{type:"url",value:PMn.FernRegistry.Url(n)}}}}}var DXD=pu.union([pu.string(),pu.object({light:pu.string().optional(),dark:pu.string().optional()})]);function aZs(e,t){let r=t(e);return r?{type:"fileId",value:PMn.FernRegistry.FileId(r)}:{type:"url",value:PMn.FernRegistry.Url(e)}}function Pkp(e,t){let r=DXD.safeParse(e.logo);if(!r.success)return;let i=r.data;typeof i=="string"?e.logo=aZs(i,t):(i.light!=null&&(e.logo.light=aZs(i.light,t)),i.dark!=null&&(e.logo.dark=aZs(i.dark,t)))}var jkp=require("fs/promises");async function EXD(e){return(await(0,jkp.readFile)(e)).toString()}async function uZs({markdown:e,absolutePathToFernFolder:t,absolutePathToMarkdownFile:r,context:i,fileLoader:n=EXD}){if(!e.includes("<Code "))return e;let a=/([ \t]*)<Code\s+src={?['"]([^'"]+)['"](?! \+)}?\s*\/>/g,u=e,l;for(;(l=a.exec(e))!=null;){let f=l[0],s=l[1],o=l[2];if(f==null||o==null)throw new Error(`Failed to parse regex "${l}" in ${r}`);let c=P0(o.startsWith("/")?t:Jd(r),Qa.of(o.replace(/^\//,"")));try{let b=await n(c),g="",O=c.split(".").pop();O!=null&&(g+=O);let m=c.split("/").pop();m!=null&&(g+=` title="${m}"`),b=`\`\`\`${g}
1966
+ `),i=t.start.column-1;for(let a=0;a<t.start.line-1;a++){let u=r[a];if(u==null)break;i+=u.length+1}let n=0-t.start.column+t.end.column;for(let a=t.start.line-1;a<t.end.line-1;a++){let u=r[a];if(u==null)break;n+=u.length+1}return{start:i,length:n}}function E9t(e){if(typeof e=="string")return e.replace(/#.*$/,"")}function mkp(e,t,r){for(let i of t){let n=e[i];if(n!=null){if(typeof n=="object")n.type==="fileId"&&(e[i]={type:"fileId",value:PMn.FernRegistry.FileId(r(n.value)??n.value)});else if(typeof n=="string"){let a=r(n);e[i]=a?{type:"fileId",value:PMn.FernRegistry.FileId(a)}:{type:"url",value:PMn.FernRegistry.Url(n)}}}}}var DXD=pu.union([pu.string(),pu.object({light:pu.string().optional(),dark:pu.string().optional()})]);function aZs(e,t){let r=t(e);return r?{type:"fileId",value:PMn.FernRegistry.FileId(r)}:{type:"url",value:PMn.FernRegistry.Url(e)}}function Pkp(e,t){let r=DXD.safeParse(e.logo);if(!r.success)return;let i=r.data;typeof i=="string"?e.logo=aZs(i,t):(i.light!=null&&(e.logo.light=aZs(i.light,t)),i.dark!=null&&(e.logo.dark=aZs(i.dark,t)))}var jkp=require("fs/promises");async function EXD(e){return(await(0,jkp.readFile)(e)).toString()}async function uZs({markdown:e,absolutePathToFernFolder:t,absolutePathToMarkdownFile:r,context:i,fileLoader:n=EXD}){if(!e.includes("<Code "))return e;let a=/([ \t]*)<Code\s+src={?['"]([^'"]+)['"](?! \+)}?((?:\s+[^>]*)?)\/>/g,u=e,l;for(;(l=a.exec(e))!=null;){let f=l[0],s=l[1],o=l[2];if(f==null||o==null)throw new Error(`Failed to parse regex "${l}" in ${r}`);let c=P0(o.startsWith("/")?t:Jd(r),Qa.of(o.replace(/^\//,"")));try{let b=await n(c),g="",O=c.split(".").pop();O!=null&&(g+=O);let m=c.split("/").pop();m!=null&&(g+=` title="${m}"`);let P=l[3]?.trim()||"";if(P){let E=/(\w+)=(?:{([^}]+)}|"([^"]+)")/g,q;for(;(q=E.exec(P))!==null;){let A=q[1],D=q[2]||q[3];A&&D&&A!=="src"&&(g+=` ${A}=${D.includes("{")?D:`{${D}}`}`)}}b=`\`\`\`${g}
1967
1967
  ${b}
1968
1968
  \`\`\``,b=b.split(`
1969
- `).map(P=>s+P).join(`
1969
+ `).map(E=>s+E).join(`
1970
1970
  `),b=b+`
1971
1971
  `,u=u.replace(f,b)}catch(b){i.failAndThrow(`Failed to read markdown file "${o}" referenced in ${r}`,b);break}}return u}var wkp=require("fs/promises"),Skp=li(lXt(),1);async function MXD(e){let{content:t}=(0,Skp.default)(await(0,wkp.readFile)(e));return t}async function sZs({markdown:e,absolutePathToFernFolder:t,absolutePathToMarkdownFile:r,context:i,markdownLoader:n=MXD}){if(!e.includes("<Markdown"))return e;let a=/([ \t]*)<Markdown\s+src={?['"]([^'"]+.mdx?)['"](?! \+)}?\s*\/>/g,u=e,l;for(;(l=a.exec(e))!=null;){let f=l[0],s=l[1],o=l[2];if(f==null||o==null)throw new Error(`Failed to parse regex "${l}" in ${r}`);let c=P0(o.startsWith("/")?t:Jd(r),Qa.of(o.replace(/^\//,"")));try{let b=await n(c);b=b.split(`
1972
1972
  `).map(g=>s+g).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.61.16",
3
+ "version": "0.61.17",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",