fern-api 0.56.0-rc4 → 0.56.0-rc5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.cjs +3 -3
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -1691,7 +1691,7 @@ ${c.indent}`:""}${p8f(o)}:${l.indent?" ":""}`;return u=!1,s=!0,l.objectItem=void
1691
1691
  `}),r.replaceAll(/\n$/g,"")}function LOS(e){return e?Q_.green(Q3.radioOn):Q3.radioOff}var avo=vi(L1e(),1);function YYd(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var Bna=class extends Z6{_run(t){this.done=t;let r=qU(this.rl),i=r.line.pipe((0,avo.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,avo.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=`
1692
1692
  `+Q_.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?Q_.cyan(YYd(t,this.opt.mask)):Q_.italic.dim("[hidden]"):this.opt.mask?YYd(t,this.opt.mask):Q_.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 mZd=vi(HDs(),1),PZd=vi(L1e(),1);var Wna=class extends Z6{_run(t){this.done=t,this.editorResult=new PZd.Subject;let r=qU(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"?Q_.dim("Received"):Q_.dim("Press <enter> to launch your preferred editor."),t&&(r=Q_.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,mZd.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 qZd=vi(SZd(),1);var MZd=vi(require("readline"),1),AZd=vi(EZd(),1),BCi=class{constructor(t){this.rl||=MZd.default.createInterface(qmS(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 qmS(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 AZd.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var Hna=class extends BCi{constructor(t={}){super(t),this.log=(0,qZd.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return Sna(this.rl,this.bottomBar.split(`
1693
1693
  `).length),this}updateBottomBar(t){return Sna(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+`
1694
- `}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&&tvo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var LZd=vi(BZd(),1),UZd=vi(Z1s(),1),VZd=vi(NZd(),1),qA=vi(L1e(),1),WZd=vi(xia(),1);var Svo=vi(L1e(),1),FZd=vi(xia(),1),Dvo=function(e,t,r){return typeof e[t]!="function"?(0,Svo.of)(e):(0,Svo.from)((0,FZd.default)(e[t])(r).then(i=>(e[t]=i,e)))};var $na={isPlainObject:LZd.default,set:VZd.default,get:UZd.default},zbn=class extends BCi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=$na.isPlainObject(r)?{...r}:{},$na.isPlainObject(t)&&(t=Object.values(t).every(n=>$na.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,qA.from)(t):t;return this.process=i.pipe((0,qA.concatMap)(this.processQuestion.bind(this)),(0,qA.publish)()),this.process.connect(),this.process.pipe((0,qA.reduce)((n,a)=>($na.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,qA.defer)(()=>(0,qA.of)(t).pipe((0,qA.concatMap)(this.setDefaultType.bind(this)),(0,qA.concatMap)(this.filterIfRunnable.bind(this)),(0,qA.concatMap)(()=>Dvo(t,"message",this.answers)),(0,qA.concatMap)(()=>Dvo(t,"default",this.answers)),(0,qA.concatMap)(()=>Dvo(t,"choices",this.answers)),(0,qA.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,qA.defer)(()=>(0,qA.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,qA.defer)(()=>(0,qA.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&$na.get(this.answers,t.name)!==void 0)return(0,qA.empty)();if(t.when===!1)return(0,qA.empty)();if(typeof t.when!="function")return(0,qA.of)(t);let{answers:r}=this;return(0,qA.defer)(()=>(0,qA.from)((0,WZd.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,qA.filter)(i=>i!=null)))}};function HZd(e){let t=function(r,i){let n;try{n=new zbn(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",Ena),this.registerPrompt("input",SCi),this.registerPrompt("number",Mna),this.registerPrompt("confirm",Ana),this.registerPrompt("rawlist",qna),this.registerPrompt("expand",Tna),this.registerPrompt("checkbox",Cna),this.registerPrompt("password",Bna),this.registerPrompt("editor",Wna)},t.restoreDefaultPrompts(),t}var QDs=HZd();function JmS(e,t){QDs.registerPrompt(e,t)}function KmS(){QDs.restoreDefaultPrompts()}var YmS={prompt:QDs,ui:{BottomBar:Hna,Prompt:zbn},createPromptModule:HZd,registerPrompt:JmS,restoreDefaultPrompts:KmS,Separator:Tre},Evo=YmS;var eep=vi($Zd()),OwS="4.2.1",i8t;(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"})(i8t||(i8t={}));function mwS(e,t){if(!e)throw new Error(t)}function PwS(e){return e?.replace(/\/+$/,"")}async function jwS(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 wwS(){return new Date().getTime()}function Gkd(){return new Date().toISOString()}function tep(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var iaa=String.fromCharCode,Qkd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Lvo={};function SwS(e,t){if(!Lvo[e]){Lvo[e]={};for(let r=0;r<e.length;r++)Lvo[e][e.charAt(r)]=r}return Lvo[e][t]}var naa={compressToBase64:function(e){if(e==null)return"";let t=naa._compress(e,6,function(r){return Qkd.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:naa._decompress(e.length,32,function(t){return SwS(Qkd,e.charAt(t))})},compress:function(e){return naa._compress(e,16,function(t){return iaa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,d="",s="",o="",c=2,b=3,g=2,O=0,m=0,w;for(w=0;w<e.length;w+=1)if(d=e.charAt(w),Object.prototype.hasOwnProperty.call(i,d)||(i[d]=b++,n[d]=!0),s=o+d,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:naa._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,d=3,s="",o,c,b,g,O,m,w;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=iaa(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=iaa(b);break;case 2:return""}for(i[3]=w,c=w,n.push(w);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,d),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(w=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=iaa(b),w=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=iaa(b),w=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[w])s=i[w];else if(w===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,d),d++)}}},BEs=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 Uvo="0123456789abcdef",Vvo=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+=Uvo.charAt(this.bytes[r]>>>4),t+=Uvo.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+=Uvo.charAt(this.bytes[r]>>>4),t+=Uvo.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}},xEs=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??DwS()}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 Vvo.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,Vvo.ofInner(t)}},DwS=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Jkd,Kkd=()=>EwS().toString(),EwS=()=>(Jkd||(Jkd=new xEs)).generate(),Wvo=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},aaa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function Ykd(e){return typeof e=="object"&&(e instanceof Wvo||e instanceof aaa)}var IEs=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new BEs,this._isInitialized=!1,mwS(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=PwS(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:Ykd},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(i8t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(i8t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(i8t.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=Kkd();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(d=>d.json()).catch(d=>{this._events.emit("error",d)})}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 d=l[t];return d===void 0&&(d=!1),d}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 d=l[t];return d===void 0?null:d}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),d=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:d,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:Gkd(),uuid:i?.uuid?i.uuid:Kkd()};(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(i8t.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(i8t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=tep(()=>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(i8t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(i8t.Queue)||[];this.setPersistedProperty(i8t.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:Gkd()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${wwS()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,d=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(naa.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,d)}catch(s){throw s instanceof aaa||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 d=new AbortController;return setTimeout(()=>d.abort(),l),d.signal}),await jwS(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(d){throw new aaa(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new Wvo(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(i8t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!Ykd(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},zEs=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},REs=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!REs){let e=$kd();REs=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 rep=REs,MwS=1152921504606847e3,AwS=["is_not"],Hvo=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},k6=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},NEs=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||rep,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 d of this.featureFlags)if(t===d.key){l=d;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(d){d instanceof k6?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async d=>{try{let s=this.computeFlagLocally(d,t,r,i,n);a[d.key]=s;let o=await this.computeFeatureFlagPayloadLocally(d.key,s);o&&(u[d.key]=o)}catch(s){s instanceof k6||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new k6("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let d=this.groupTypeMapping[String(l)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new k6("Flag has unknown group type index");if(!(d in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[d];return this.matchFeatureFlagProperties(t,i[d],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,d=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of d)try{if(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 k6)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new k6("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 d=l.type,s=!1;if(d==="cohort"?s=nep(l,n,this.cohorts,this.debugMode):s=iep(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&Xkd(t.key,r)>a/100)}getMatchingVariant(t,r){let i=Xkd(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 Hvo("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 Hvo&&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=tep(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function Xkd(e,t,r=""){let i=(0,eep.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/MwS}function iep(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 k6("Operator is_not_set is not supported")}else throw new k6(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!AwS.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function d(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return Zkd(String(n))&&String(u).match(String(n))!==null;case"not_regex":return Zkd(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?d(u,String(n),a):d(u,s,a):d(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=qwS(String(n));if(s==null&&(s=kkd(n)),s==null)throw new k6(`Invalid date: ${n}`);let o=kkd(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new k6(`Unknown operator: ${a}`)}}function nep(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new k6("can't match cohort without a given cohort property value");let a=r[n];return aep(a,t,r,i)}function aep(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let d=aep(l,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof k6)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new k6("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let d;l.type==="cohort"?d=nep(l,t,r,i):d=iep(l,t);let s=l.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof k6)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new k6("can't match cohort without a given cohort property value");return n==="AND"}}function Zkd(e){try{return new RegExp(e),!0}catch{return!1}}function kkd(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 k6(`${e} is in an invalid date format`)}else throw new k6(`The date provided ${e} must be a string, number, or date object`)}function qwS(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 TwS=30*1e3,CwS=50*1e3,Wbn=class extends IEs{constructor(t,r={}){super(t,r),this._memoryStorage=new zEs,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new NEs({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:TwS,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||CwS}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):rep(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return OwS}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:d}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:d})},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,w]of Object.entries(b))g[`$feature/${m}`]=w;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:d,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,d,s);d=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,d,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:d,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),d==null&&(d=!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||{},d=this.addLocalPersonAndGroupProperties(t,i,u,l);u=d.allPersonProperties,l=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},FEs=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})}};FEs.POSTHOG_ID_TAG="posthog_distinct_id";var $vo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new Wbn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.56.0-rc4",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var oaa=class{async sendEvent(){}async identify(){}async flush(){}};var Hbn=require("fs/promises"),cep=require("os"),lep=require("path");var oep=vi(require("crypto")),Qvo=new Uint8Array(256),Gvo=Qvo.length;function LEs(){return Gvo>Qvo.length-16&&(oep.default.randomFillSync(Qvo),Gvo=0),Qvo.slice(Gvo,Gvo+=16)}var BU=[];for(let e=0;e<256;++e)BU.push((e+256).toString(16).slice(1));function uep(e,t=0){return BU[e[t+0]]+BU[e[t+1]]+BU[e[t+2]]+BU[e[t+3]]+"-"+BU[e[t+4]]+BU[e[t+5]]+"-"+BU[e[t+6]]+BU[e[t+7]]+"-"+BU[e[t+8]]+BU[e[t+9]]+"-"+BU[e[t+10]]+BU[e[t+11]]+BU[e[t+12]]+BU[e[t+13]]+BU[e[t+14]]+BU[e[t+15]]}var sep=vi(require("crypto")),UEs={randomUUID:sep.default.randomUUID};function BwS(e,t,r){if(UEs.randomUUID&&!t&&!e)return UEs.randomUUID();e=e||{};let i=e.random||(e.rng||LEs)();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 uep(i)}var zre=BwS;var xwS="id",IwS=".fern",uaa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new Wbn(r),this.userId=t==null?void 0:tms(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.56.0-rc4",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Xu(Wl.of((0,cep.homedir)()),Xa.of(IwS),Xa.of(xwS));await Cf(t)||(await(0,Hbn.mkdir)((0,lep.dirname)(t),{recursive:!0}),await(0,Hbn.writeFile)(t,zre())),this.persistedDistinctId=(await(0,Hbn.readFile)(t)).toString()}return this.persistedDistinctId}};var VEs;async function $bn(){return VEs==null&&(VEs=await zwS()),VEs}async function zwS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new oaa;let r=await tfo();return r!=null?new uaa({token:r,posthogApiKey:e}):await efo()!=null?new $vo({posthogApiKey:e}):new uaa({token:void 0,posthogApiKey:e})}catch{return new oaa}}function saa(e,t){return function(){return e.apply(t,arguments)}}var{toString:RwS}=Object.prototype,{getPrototypeOf:$Es}=Object,Kvo=(e=>t=>{let r=RwS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),n8t=e=>(e=e.toLowerCase(),t=>Kvo(t)===e),Yvo=e=>t=>typeof t===e,{isArray:Gbn}=Array,caa=Yvo("undefined");function NwS(e){return e!==null&&!caa(e)&&e.constructor!==null&&!caa(e.constructor)&&V1e(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var pep=n8t("ArrayBuffer");function FwS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&pep(e.buffer),t}var LwS=Yvo("string"),V1e=Yvo("function"),_ep=Yvo("number"),Xvo=e=>e!==null&&typeof e=="object",UwS=e=>e===!0||e===!1,Jvo=e=>{if(Kvo(e)!=="object")return!1;let t=$Es(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},VwS=n8t("Date"),WwS=n8t("File"),HwS=n8t("Blob"),$wS=n8t("FileList"),GwS=e=>Xvo(e)&&V1e(e.pipe),QwS=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||V1e(e.append)&&((t=Kvo(e))==="formdata"||t==="object"&&V1e(e.toString)&&e.toString()==="[object FormData]"))},JwS=n8t("URLSearchParams"),[KwS,YwS,XwS,ZwS]=["ReadableStream","Request","Response","Headers"].map(n8t),kwS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function laa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),Gbn(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 hep(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 RCi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,yep=e=>!caa(e)&&e!==RCi;function HEs(){let{caseless:e}=yep(this)&&this||{},t={},r=(i,n)=>{let a=e&&hep(t,n)||n;Jvo(t[a])&&Jvo(i)?t[a]=HEs(t[a],i):Jvo(i)?t[a]=HEs({},i):Gbn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&laa(arguments[i],r);return t}var e1S=(e,t,r,{allOwnKeys:i}={})=>(laa(t,(n,a)=>{r&&V1e(n)?e[a]=saa(n,r):e[a]=n},{allOwnKeys:i}),e),t1S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),r1S=(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)},i1S=(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&&$Es(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},n1S=(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},a1S=e=>{if(!e)return null;if(Gbn(e))return e;let t=e.length;if(!_ep(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},o1S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&$Es(Uint8Array)),u1S=(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])}},s1S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},c1S=n8t("HTMLFormElement"),l1S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),fep=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),f1S=n8t("RegExp"),vep=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};laa(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},d1S=e=>{vep(e,(t,r)=>{if(V1e(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(V1e(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+"'")})}})},p1S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return Gbn(e)?i(e):i(String(e).split(t)),r},_1S=()=>{},h1S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,WEs="abcdefghijklmnopqrstuvwxyz",dep="0123456789",bep={DIGIT:dep,ALPHA:WEs,ALPHA_DIGIT:WEs+WEs.toUpperCase()+dep},y1S=(e=16,t=bep.ALPHA_DIGIT)=>{let r="",{length:i}=t;for(;e--;)r+=t[Math.random()*i|0];return r};function v1S(e){return!!(e&&V1e(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var b1S=e=>{let t=new Array(10),r=(i,n)=>{if(Xvo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=Gbn(i)?[]:{};return laa(i,(u,l)=>{let d=r(u,n+1);!caa(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},g1S=n8t("AsyncFunction"),O1S=e=>e&&(Xvo(e)||V1e(e))&&V1e(e.then)&&V1e(e.catch),gep=((e,t)=>e?setImmediate:t?((r,i)=>(RCi.addEventListener("message",({source:n,data:a})=>{n===RCi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),RCi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",V1e(RCi.postMessage)),m1S=typeof queueMicrotask<"u"?queueMicrotask.bind(RCi):typeof process<"u"&&process.nextTick||gep,us={isArray:Gbn,isArrayBuffer:pep,isBuffer:NwS,isFormData:QwS,isArrayBufferView:FwS,isString:LwS,isNumber:_ep,isBoolean:UwS,isObject:Xvo,isPlainObject:Jvo,isReadableStream:KwS,isRequest:YwS,isResponse:XwS,isHeaders:ZwS,isUndefined:caa,isDate:VwS,isFile:WwS,isBlob:HwS,isRegExp:f1S,isFunction:V1e,isStream:GwS,isURLSearchParams:JwS,isTypedArray:o1S,isFileList:$wS,forEach:laa,merge:HEs,extend:e1S,trim:kwS,stripBOM:t1S,inherits:r1S,toFlatObject:i1S,kindOf:Kvo,kindOfTest:n8t,endsWith:n1S,toArray:a1S,forEachEntry:u1S,matchAll:s1S,isHTMLForm:c1S,hasOwnProperty:fep,hasOwnProp:fep,reduceDescriptors:vep,freezeMethods:d1S,toObjectSet:p1S,toCamelCase:l1S,noop:_1S,toFiniteNumber:h1S,findKey:hep,global:RCi,isContextDefined:yep,ALPHABET:bep,generateString:y1S,isSpecCompliantForm:v1S,toJSONObject:b1S,isAsyncFn:g1S,isThenable:O1S,setImmediate:gep,asap:m1S};function Qbn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}us.inherits(Qbn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:us.toJSONObject(this.config),code:this.code,status:this.status}}});var Oep=Qbn.prototype,mep={};["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=>{mep[e]={value:e}});Object.defineProperties(Qbn,mep);Object.defineProperty(Oep,"isAxiosError",{value:!0});Qbn.from=(e,t,r,i,n,a)=>{let u=Object.create(Oep);return us.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),Qbn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var mp=Qbn;var Pep=vi(JZn(),1),Zvo=Pep.default;function GEs(e){return us.isPlainObject(e)||us.isArray(e)}function wep(e){return us.endsWith(e,"[]")?e.slice(0,-2):e}function jep(e,t,r){return e?e.concat(t).map(function(n,a){return n=wep(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function P1S(e){return us.isArray(e)&&!e.some(GEs)}var j1S=us.toFlatObject(us,{},null,function(t){return/^is[A-Z]/.test(t)});function w1S(e,t,r){if(!us.isObject(e))throw new TypeError("target must be an object");t=t||new(Zvo||FormData),r=us.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,w){return!us.isUndefined(w[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&us.isSpecCompliantForm(t);if(!us.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(us.isDate(O))return O.toISOString();if(!d&&us.isBlob(O))throw new mp("Blob is not supported. Use a Buffer instead.");return us.isArrayBuffer(O)||us.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,w){let E=O;if(O&&!w&&typeof O=="object"){if(us.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(us.isArray(O)&&P1S(O)||(us.isFileList(O)||us.endsWith(m,"[]"))&&(E=us.toArray(O)))return m=wep(m),E.forEach(function(q,D){!(us.isUndefined(q)||q===null)&&t.append(u===!0?jep([m],D,a):u===null?m:m+"[]",s(q))}),!1}return GEs(O)?!0:(t.append(jep(w,m,a),s(O)),!1)}let c=[],b=Object.assign(j1S,{defaultVisitor:o,convertValue:s,isVisitable:GEs});function g(O,m){if(!us.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),us.forEach(O,function(E,A){(!(us.isUndefined(E)||E===null)&&n.call(t,E,us.isString(A)?A.trim():A,m,b))===!0&&g(E,m?m.concat(A):[A])}),c.pop()}}if(!us.isObject(e))throw new TypeError("data must be an object");return g(e),t}var Esi=w1S;function Sep(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Dep(e,t){this._pairs=[],e&&Esi(e,this,t)}var Eep=Dep.prototype;Eep.append=function(t,r){this._pairs.push([t,r])};Eep.toString=function(t){let r=t?function(i){return t.call(this,i,Sep)}:Sep;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var Mep=Dep;function S1S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function NCi(e,t,r){if(!t)return e;let i=r&&r.encode||S1S,n=r&&r.serialize,a;if(n?a=n(t,r):a=us.isURLSearchParams(t)?t.toString():new Mep(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var QEs=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){us.forEach(this.handlers,function(i){i!==null&&t(i)})}},JEs=QEs;var Jbn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Aep=vi(require("url"),1),qep=Aep.default.URLSearchParams;var Tep={isNode:!0,classes:{URLSearchParams:qep,FormData:Zvo,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var XEs={};Io(XEs,{hasBrowserEnv:()=>YEs,hasStandardBrowserEnv:()=>D1S,hasStandardBrowserWebWorkerEnv:()=>E1S,navigator:()=>KEs,origin:()=>M1S});var YEs=typeof window<"u"&&typeof document<"u",KEs=typeof navigator=="object"&&navigator||void 0,D1S=YEs&&(!KEs||["ReactNative","NativeScript","NS"].indexOf(KEs.product)<0),E1S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",M1S=YEs&&window.location.href||"http://localhost";var NT={...XEs,...Tep};function ZEs(e,t){return Esi(e,new NT.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return NT.isNode&&us.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function A1S(e){return us.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function q1S(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 T1S(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),d=a>=r.length;return u=!u&&us.isArray(n)?n.length:u,d?(us.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!us.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&us.isArray(n[u])&&(n[u]=q1S(n[u])),!l)}if(us.isFormData(e)&&us.isFunction(e.entries)){let r={};return us.forEachEntry(e,(i,n)=>{t(A1S(i),n,r,0)}),r}return null}var kvo=T1S;function C1S(e,t,r){if(us.isString(e))try{return(t||JSON.parse)(e),us.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var kEs={transitional:Jbn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=us.isObject(t);if(a&&us.isHTMLForm(t)&&(t=new FormData(t)),us.isFormData(t))return n?JSON.stringify(kvo(t)):t;if(us.isArrayBuffer(t)||us.isBuffer(t)||us.isStream(t)||us.isFile(t)||us.isBlob(t)||us.isReadableStream(t))return t;if(us.isArrayBufferView(t))return t.buffer;if(us.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return ZEs(t,this.formSerializer).toString();if((l=us.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return Esi(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),C1S(t)):t}],transformResponse:[function(t){let r=this.transitional||kEs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(us.isResponse(t)||us.isReadableStream(t))return t;if(t&&us.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?mp.from(l,mp.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:NT.classes.FormData,Blob:NT.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};us.forEach(["delete","get","head","post","put","patch"],e=>{kEs.headers[e]={}});var Kbn=kEs;var B1S=us.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Cep=e=>{let t={},r,i,n;return e&&e.split(`
1694
+ `}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&&tvo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var LZd=vi(BZd(),1),UZd=vi(Z1s(),1),VZd=vi(NZd(),1),qA=vi(L1e(),1),WZd=vi(xia(),1);var Svo=vi(L1e(),1),FZd=vi(xia(),1),Dvo=function(e,t,r){return typeof e[t]!="function"?(0,Svo.of)(e):(0,Svo.from)((0,FZd.default)(e[t])(r).then(i=>(e[t]=i,e)))};var $na={isPlainObject:LZd.default,set:VZd.default,get:UZd.default},zbn=class extends BCi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=$na.isPlainObject(r)?{...r}:{},$na.isPlainObject(t)&&(t=Object.values(t).every(n=>$na.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,qA.from)(t):t;return this.process=i.pipe((0,qA.concatMap)(this.processQuestion.bind(this)),(0,qA.publish)()),this.process.connect(),this.process.pipe((0,qA.reduce)((n,a)=>($na.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,qA.defer)(()=>(0,qA.of)(t).pipe((0,qA.concatMap)(this.setDefaultType.bind(this)),(0,qA.concatMap)(this.filterIfRunnable.bind(this)),(0,qA.concatMap)(()=>Dvo(t,"message",this.answers)),(0,qA.concatMap)(()=>Dvo(t,"default",this.answers)),(0,qA.concatMap)(()=>Dvo(t,"choices",this.answers)),(0,qA.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,qA.defer)(()=>(0,qA.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,qA.defer)(()=>(0,qA.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&$na.get(this.answers,t.name)!==void 0)return(0,qA.empty)();if(t.when===!1)return(0,qA.empty)();if(typeof t.when!="function")return(0,qA.of)(t);let{answers:r}=this;return(0,qA.defer)(()=>(0,qA.from)((0,WZd.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,qA.filter)(i=>i!=null)))}};function HZd(e){let t=function(r,i){let n;try{n=new zbn(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",Ena),this.registerPrompt("input",SCi),this.registerPrompt("number",Mna),this.registerPrompt("confirm",Ana),this.registerPrompt("rawlist",qna),this.registerPrompt("expand",Tna),this.registerPrompt("checkbox",Cna),this.registerPrompt("password",Bna),this.registerPrompt("editor",Wna)},t.restoreDefaultPrompts(),t}var QDs=HZd();function JmS(e,t){QDs.registerPrompt(e,t)}function KmS(){QDs.restoreDefaultPrompts()}var YmS={prompt:QDs,ui:{BottomBar:Hna,Prompt:zbn},createPromptModule:HZd,registerPrompt:JmS,restoreDefaultPrompts:KmS,Separator:Tre},Evo=YmS;var eep=vi($Zd()),OwS="4.2.1",i8t;(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"})(i8t||(i8t={}));function mwS(e,t){if(!e)throw new Error(t)}function PwS(e){return e?.replace(/\/+$/,"")}async function jwS(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 wwS(){return new Date().getTime()}function Gkd(){return new Date().toISOString()}function tep(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var iaa=String.fromCharCode,Qkd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Lvo={};function SwS(e,t){if(!Lvo[e]){Lvo[e]={};for(let r=0;r<e.length;r++)Lvo[e][e.charAt(r)]=r}return Lvo[e][t]}var naa={compressToBase64:function(e){if(e==null)return"";let t=naa._compress(e,6,function(r){return Qkd.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:naa._decompress(e.length,32,function(t){return SwS(Qkd,e.charAt(t))})},compress:function(e){return naa._compress(e,16,function(t){return iaa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,d="",s="",o="",c=2,b=3,g=2,O=0,m=0,w;for(w=0;w<e.length;w+=1)if(d=e.charAt(w),Object.prototype.hasOwnProperty.call(i,d)||(i[d]=b++,n[d]=!0),s=o+d,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:naa._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,d=3,s="",o,c,b,g,O,m,w;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=iaa(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=iaa(b);break;case 2:return""}for(i[3]=w,c=w,n.push(w);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,d),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(w=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=iaa(b),w=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=iaa(b),w=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[w])s=i[w];else if(w===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,d),d++)}}},BEs=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 Uvo="0123456789abcdef",Vvo=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+=Uvo.charAt(this.bytes[r]>>>4),t+=Uvo.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+=Uvo.charAt(this.bytes[r]>>>4),t+=Uvo.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}},xEs=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??DwS()}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 Vvo.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,Vvo.ofInner(t)}},DwS=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Jkd,Kkd=()=>EwS().toString(),EwS=()=>(Jkd||(Jkd=new xEs)).generate(),Wvo=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},aaa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function Ykd(e){return typeof e=="object"&&(e instanceof Wvo||e instanceof aaa)}var IEs=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new BEs,this._isInitialized=!1,mwS(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=PwS(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:Ykd},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(i8t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(i8t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(i8t.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=Kkd();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(d=>d.json()).catch(d=>{this._events.emit("error",d)})}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 d=l[t];return d===void 0&&(d=!1),d}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 d=l[t];return d===void 0?null:d}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),d=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:d,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:Gkd(),uuid:i?.uuid?i.uuid:Kkd()};(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(i8t.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(i8t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=tep(()=>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(i8t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(i8t.Queue)||[];this.setPersistedProperty(i8t.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:Gkd()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${wwS()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,d=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(naa.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,d)}catch(s){throw s instanceof aaa||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 d=new AbortController;return setTimeout(()=>d.abort(),l),d.signal}),await jwS(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(d){throw new aaa(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new Wvo(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(i8t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!Ykd(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},zEs=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},REs=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!REs){let e=$kd();REs=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 rep=REs,MwS=1152921504606847e3,AwS=["is_not"],Hvo=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},k6=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},NEs=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||rep,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 d of this.featureFlags)if(t===d.key){l=d;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(d){d instanceof k6?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async d=>{try{let s=this.computeFlagLocally(d,t,r,i,n);a[d.key]=s;let o=await this.computeFeatureFlagPayloadLocally(d.key,s);o&&(u[d.key]=o)}catch(s){s instanceof k6||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new k6("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let d=this.groupTypeMapping[String(l)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new k6("Flag has unknown group type index");if(!(d in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[d];return this.matchFeatureFlagProperties(t,i[d],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,d=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of d)try{if(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 k6)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new k6("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 d=l.type,s=!1;if(d==="cohort"?s=nep(l,n,this.cohorts,this.debugMode):s=iep(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&Xkd(t.key,r)>a/100)}getMatchingVariant(t,r){let i=Xkd(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 Hvo("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 Hvo&&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=tep(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function Xkd(e,t,r=""){let i=(0,eep.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/MwS}function iep(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 k6("Operator is_not_set is not supported")}else throw new k6(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!AwS.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function d(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return Zkd(String(n))&&String(u).match(String(n))!==null;case"not_regex":return Zkd(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?d(u,String(n),a):d(u,s,a):d(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=qwS(String(n));if(s==null&&(s=kkd(n)),s==null)throw new k6(`Invalid date: ${n}`);let o=kkd(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new k6(`Unknown operator: ${a}`)}}function nep(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new k6("can't match cohort without a given cohort property value");let a=r[n];return aep(a,t,r,i)}function aep(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let d=aep(l,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof k6)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new k6("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let d;l.type==="cohort"?d=nep(l,t,r,i):d=iep(l,t);let s=l.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof k6)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new k6("can't match cohort without a given cohort property value");return n==="AND"}}function Zkd(e){try{return new RegExp(e),!0}catch{return!1}}function kkd(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 k6(`${e} is in an invalid date format`)}else throw new k6(`The date provided ${e} must be a string, number, or date object`)}function qwS(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 TwS=30*1e3,CwS=50*1e3,Wbn=class extends IEs{constructor(t,r={}){super(t,r),this._memoryStorage=new zEs,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new NEs({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:TwS,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||CwS}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):rep(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return OwS}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:d}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:d})},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,w]of Object.entries(b))g[`$feature/${m}`]=w;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:d,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,d,s);d=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,d,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:d,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),d==null&&(d=!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||{},d=this.addLocalPersonAndGroupProperties(t,i,u,l);u=d.allPersonProperties,l=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},FEs=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})}};FEs.POSTHOG_ID_TAG="posthog_distinct_id";var $vo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new Wbn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.56.0-rc5",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var oaa=class{async sendEvent(){}async identify(){}async flush(){}};var Hbn=require("fs/promises"),cep=require("os"),lep=require("path");var oep=vi(require("crypto")),Qvo=new Uint8Array(256),Gvo=Qvo.length;function LEs(){return Gvo>Qvo.length-16&&(oep.default.randomFillSync(Qvo),Gvo=0),Qvo.slice(Gvo,Gvo+=16)}var BU=[];for(let e=0;e<256;++e)BU.push((e+256).toString(16).slice(1));function uep(e,t=0){return BU[e[t+0]]+BU[e[t+1]]+BU[e[t+2]]+BU[e[t+3]]+"-"+BU[e[t+4]]+BU[e[t+5]]+"-"+BU[e[t+6]]+BU[e[t+7]]+"-"+BU[e[t+8]]+BU[e[t+9]]+"-"+BU[e[t+10]]+BU[e[t+11]]+BU[e[t+12]]+BU[e[t+13]]+BU[e[t+14]]+BU[e[t+15]]}var sep=vi(require("crypto")),UEs={randomUUID:sep.default.randomUUID};function BwS(e,t,r){if(UEs.randomUUID&&!t&&!e)return UEs.randomUUID();e=e||{};let i=e.random||(e.rng||LEs)();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 uep(i)}var zre=BwS;var xwS="id",IwS=".fern",uaa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new Wbn(r),this.userId=t==null?void 0:tms(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.56.0-rc5",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Xu(Wl.of((0,cep.homedir)()),Xa.of(IwS),Xa.of(xwS));await Cf(t)||(await(0,Hbn.mkdir)((0,lep.dirname)(t),{recursive:!0}),await(0,Hbn.writeFile)(t,zre())),this.persistedDistinctId=(await(0,Hbn.readFile)(t)).toString()}return this.persistedDistinctId}};var VEs;async function $bn(){return VEs==null&&(VEs=await zwS()),VEs}async function zwS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new oaa;let r=await tfo();return r!=null?new uaa({token:r,posthogApiKey:e}):await efo()!=null?new $vo({posthogApiKey:e}):new uaa({token:void 0,posthogApiKey:e})}catch{return new oaa}}function saa(e,t){return function(){return e.apply(t,arguments)}}var{toString:RwS}=Object.prototype,{getPrototypeOf:$Es}=Object,Kvo=(e=>t=>{let r=RwS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),n8t=e=>(e=e.toLowerCase(),t=>Kvo(t)===e),Yvo=e=>t=>typeof t===e,{isArray:Gbn}=Array,caa=Yvo("undefined");function NwS(e){return e!==null&&!caa(e)&&e.constructor!==null&&!caa(e.constructor)&&V1e(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var pep=n8t("ArrayBuffer");function FwS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&pep(e.buffer),t}var LwS=Yvo("string"),V1e=Yvo("function"),_ep=Yvo("number"),Xvo=e=>e!==null&&typeof e=="object",UwS=e=>e===!0||e===!1,Jvo=e=>{if(Kvo(e)!=="object")return!1;let t=$Es(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},VwS=n8t("Date"),WwS=n8t("File"),HwS=n8t("Blob"),$wS=n8t("FileList"),GwS=e=>Xvo(e)&&V1e(e.pipe),QwS=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||V1e(e.append)&&((t=Kvo(e))==="formdata"||t==="object"&&V1e(e.toString)&&e.toString()==="[object FormData]"))},JwS=n8t("URLSearchParams"),[KwS,YwS,XwS,ZwS]=["ReadableStream","Request","Response","Headers"].map(n8t),kwS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function laa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),Gbn(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 hep(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 RCi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,yep=e=>!caa(e)&&e!==RCi;function HEs(){let{caseless:e}=yep(this)&&this||{},t={},r=(i,n)=>{let a=e&&hep(t,n)||n;Jvo(t[a])&&Jvo(i)?t[a]=HEs(t[a],i):Jvo(i)?t[a]=HEs({},i):Gbn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&laa(arguments[i],r);return t}var e1S=(e,t,r,{allOwnKeys:i}={})=>(laa(t,(n,a)=>{r&&V1e(n)?e[a]=saa(n,r):e[a]=n},{allOwnKeys:i}),e),t1S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),r1S=(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)},i1S=(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&&$Es(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},n1S=(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},a1S=e=>{if(!e)return null;if(Gbn(e))return e;let t=e.length;if(!_ep(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},o1S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&$Es(Uint8Array)),u1S=(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])}},s1S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},c1S=n8t("HTMLFormElement"),l1S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),fep=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),f1S=n8t("RegExp"),vep=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};laa(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},d1S=e=>{vep(e,(t,r)=>{if(V1e(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(V1e(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+"'")})}})},p1S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return Gbn(e)?i(e):i(String(e).split(t)),r},_1S=()=>{},h1S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,WEs="abcdefghijklmnopqrstuvwxyz",dep="0123456789",bep={DIGIT:dep,ALPHA:WEs,ALPHA_DIGIT:WEs+WEs.toUpperCase()+dep},y1S=(e=16,t=bep.ALPHA_DIGIT)=>{let r="",{length:i}=t;for(;e--;)r+=t[Math.random()*i|0];return r};function v1S(e){return!!(e&&V1e(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var b1S=e=>{let t=new Array(10),r=(i,n)=>{if(Xvo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=Gbn(i)?[]:{};return laa(i,(u,l)=>{let d=r(u,n+1);!caa(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},g1S=n8t("AsyncFunction"),O1S=e=>e&&(Xvo(e)||V1e(e))&&V1e(e.then)&&V1e(e.catch),gep=((e,t)=>e?setImmediate:t?((r,i)=>(RCi.addEventListener("message",({source:n,data:a})=>{n===RCi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),RCi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",V1e(RCi.postMessage)),m1S=typeof queueMicrotask<"u"?queueMicrotask.bind(RCi):typeof process<"u"&&process.nextTick||gep,us={isArray:Gbn,isArrayBuffer:pep,isBuffer:NwS,isFormData:QwS,isArrayBufferView:FwS,isString:LwS,isNumber:_ep,isBoolean:UwS,isObject:Xvo,isPlainObject:Jvo,isReadableStream:KwS,isRequest:YwS,isResponse:XwS,isHeaders:ZwS,isUndefined:caa,isDate:VwS,isFile:WwS,isBlob:HwS,isRegExp:f1S,isFunction:V1e,isStream:GwS,isURLSearchParams:JwS,isTypedArray:o1S,isFileList:$wS,forEach:laa,merge:HEs,extend:e1S,trim:kwS,stripBOM:t1S,inherits:r1S,toFlatObject:i1S,kindOf:Kvo,kindOfTest:n8t,endsWith:n1S,toArray:a1S,forEachEntry:u1S,matchAll:s1S,isHTMLForm:c1S,hasOwnProperty:fep,hasOwnProp:fep,reduceDescriptors:vep,freezeMethods:d1S,toObjectSet:p1S,toCamelCase:l1S,noop:_1S,toFiniteNumber:h1S,findKey:hep,global:RCi,isContextDefined:yep,ALPHABET:bep,generateString:y1S,isSpecCompliantForm:v1S,toJSONObject:b1S,isAsyncFn:g1S,isThenable:O1S,setImmediate:gep,asap:m1S};function Qbn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}us.inherits(Qbn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:us.toJSONObject(this.config),code:this.code,status:this.status}}});var Oep=Qbn.prototype,mep={};["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=>{mep[e]={value:e}});Object.defineProperties(Qbn,mep);Object.defineProperty(Oep,"isAxiosError",{value:!0});Qbn.from=(e,t,r,i,n,a)=>{let u=Object.create(Oep);return us.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),Qbn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var mp=Qbn;var Pep=vi(JZn(),1),Zvo=Pep.default;function GEs(e){return us.isPlainObject(e)||us.isArray(e)}function wep(e){return us.endsWith(e,"[]")?e.slice(0,-2):e}function jep(e,t,r){return e?e.concat(t).map(function(n,a){return n=wep(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function P1S(e){return us.isArray(e)&&!e.some(GEs)}var j1S=us.toFlatObject(us,{},null,function(t){return/^is[A-Z]/.test(t)});function w1S(e,t,r){if(!us.isObject(e))throw new TypeError("target must be an object");t=t||new(Zvo||FormData),r=us.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,w){return!us.isUndefined(w[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&us.isSpecCompliantForm(t);if(!us.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(us.isDate(O))return O.toISOString();if(!d&&us.isBlob(O))throw new mp("Blob is not supported. Use a Buffer instead.");return us.isArrayBuffer(O)||us.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,w){let E=O;if(O&&!w&&typeof O=="object"){if(us.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(us.isArray(O)&&P1S(O)||(us.isFileList(O)||us.endsWith(m,"[]"))&&(E=us.toArray(O)))return m=wep(m),E.forEach(function(q,D){!(us.isUndefined(q)||q===null)&&t.append(u===!0?jep([m],D,a):u===null?m:m+"[]",s(q))}),!1}return GEs(O)?!0:(t.append(jep(w,m,a),s(O)),!1)}let c=[],b=Object.assign(j1S,{defaultVisitor:o,convertValue:s,isVisitable:GEs});function g(O,m){if(!us.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),us.forEach(O,function(E,A){(!(us.isUndefined(E)||E===null)&&n.call(t,E,us.isString(A)?A.trim():A,m,b))===!0&&g(E,m?m.concat(A):[A])}),c.pop()}}if(!us.isObject(e))throw new TypeError("data must be an object");return g(e),t}var Esi=w1S;function Sep(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Dep(e,t){this._pairs=[],e&&Esi(e,this,t)}var Eep=Dep.prototype;Eep.append=function(t,r){this._pairs.push([t,r])};Eep.toString=function(t){let r=t?function(i){return t.call(this,i,Sep)}:Sep;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var Mep=Dep;function S1S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function NCi(e,t,r){if(!t)return e;let i=r&&r.encode||S1S,n=r&&r.serialize,a;if(n?a=n(t,r):a=us.isURLSearchParams(t)?t.toString():new Mep(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var QEs=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){us.forEach(this.handlers,function(i){i!==null&&t(i)})}},JEs=QEs;var Jbn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Aep=vi(require("url"),1),qep=Aep.default.URLSearchParams;var Tep={isNode:!0,classes:{URLSearchParams:qep,FormData:Zvo,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var XEs={};Io(XEs,{hasBrowserEnv:()=>YEs,hasStandardBrowserEnv:()=>D1S,hasStandardBrowserWebWorkerEnv:()=>E1S,navigator:()=>KEs,origin:()=>M1S});var YEs=typeof window<"u"&&typeof document<"u",KEs=typeof navigator=="object"&&navigator||void 0,D1S=YEs&&(!KEs||["ReactNative","NativeScript","NS"].indexOf(KEs.product)<0),E1S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",M1S=YEs&&window.location.href||"http://localhost";var NT={...XEs,...Tep};function ZEs(e,t){return Esi(e,new NT.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return NT.isNode&&us.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function A1S(e){return us.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function q1S(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 T1S(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),d=a>=r.length;return u=!u&&us.isArray(n)?n.length:u,d?(us.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!us.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&us.isArray(n[u])&&(n[u]=q1S(n[u])),!l)}if(us.isFormData(e)&&us.isFunction(e.entries)){let r={};return us.forEachEntry(e,(i,n)=>{t(A1S(i),n,r,0)}),r}return null}var kvo=T1S;function C1S(e,t,r){if(us.isString(e))try{return(t||JSON.parse)(e),us.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var kEs={transitional:Jbn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=us.isObject(t);if(a&&us.isHTMLForm(t)&&(t=new FormData(t)),us.isFormData(t))return n?JSON.stringify(kvo(t)):t;if(us.isArrayBuffer(t)||us.isBuffer(t)||us.isStream(t)||us.isFile(t)||us.isBlob(t)||us.isReadableStream(t))return t;if(us.isArrayBufferView(t))return t.buffer;if(us.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return ZEs(t,this.formSerializer).toString();if((l=us.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return Esi(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),C1S(t)):t}],transformResponse:[function(t){let r=this.transitional||kEs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(us.isResponse(t)||us.isReadableStream(t))return t;if(t&&us.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?mp.from(l,mp.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:NT.classes.FormData,Blob:NT.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};us.forEach(["delete","get","head","post","put","patch"],e=>{kEs.headers[e]={}});var Kbn=kEs;var B1S=us.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Cep=e=>{let t={},r,i,n;return e&&e.split(`
1695
1695
  `).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&B1S[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var Bep=Symbol("internals");function faa(e){return e&&String(e).trim().toLowerCase()}function ebo(e){return e===!1||e==null?e:us.isArray(e)?e.map(ebo):String(e)}function x1S(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 I1S=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function eMs(e,t,r,i,n){if(us.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!us.isString(t)){if(us.isString(i))return t.indexOf(i)!==-1;if(us.isRegExp(i))return i.test(t)}}function z1S(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function R1S(e,t){let r=us.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,u){return this[i].call(this,t,n,a,u)},configurable:!0})})}var Ybn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(l,d,s){let o=faa(d);if(!o)throw new Error("header name must be a non-empty string");let c=us.findKey(n,o);(!c||n[c]===void 0||s===!0||s===void 0&&n[c]!==!1)&&(n[c||d]=ebo(l))}let u=(l,d)=>us.forEach(l,(s,o)=>a(s,o,d));if(us.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(us.isString(t)&&(t=t.trim())&&!I1S(t))u(Cep(t),r);else if(us.isHeaders(t))for(let[l,d]of t.entries())a(d,l,i);else t!=null&&a(r,t,i);return this}get(t,r){if(t=faa(t),t){let i=us.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return x1S(n);if(us.isFunction(r))return r.call(this,n,i);if(us.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=faa(t),t){let i=us.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||eMs(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=faa(u),u){let l=us.findKey(i,u);l&&(!r||eMs(i,i[l],l,r))&&(delete i[l],n=!0)}}return us.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||eMs(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return us.forEach(this,(n,a)=>{let u=us.findKey(i,a);if(u){r[u]=ebo(n),delete r[a];return}let l=t?z1S(a):String(a).trim();l!==a&&delete r[a],r[l]=ebo(n),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return us.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&us.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
1696
1696
  `)}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[Bep]=this[Bep]={accessors:{}}).accessors,n=this.prototype;function a(u){let l=faa(u);i[l]||(R1S(n,u),i[l]=!0)}return us.isArray(t)?t.forEach(a):a(t),this}};Ybn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);us.reduceDescriptors(Ybn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});us.freezeMethods(Ybn);var VI=Ybn;function daa(e,t){let r=this||Kbn,i=t||r,n=VI.from(i.headers),a=i.data;return us.forEach(e,function(l){a=l.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function paa(e){return!!(e&&e.__CANCEL__)}function xep(e,t,r){mp.call(this,e??"canceled",mp.ERR_CANCELED,t,r),this.name="CanceledError"}us.inherits(xep,mp,{__CANCEL__:!0});var W1e=xep;function mKt(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new mp("Request failed with status code "+r.status,[mp.ERR_BAD_REQUEST,mp.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function tMs(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function rMs(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function FCi(e,t){return e&&!tMs(t)?rMs(e,t):t}var Yep=vi(Qna(),1),Xep=vi(require("http"),1),Zep=vi(require("https"),1),kep=vi(require("util"),1),etp=vi(uEs(),1),k$r=vi(require("zlib"),1);var LCi="1.7.7";function _aa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var N1S=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function iMs(e,t,r){let i=r&&r.Blob||NT.classes.Blob,n=_aa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=N1S.exec(e);if(!a)throw new mp("Invalid URL",mp.ERR_INVALID_URL);let u=a[1],l=a[2],d=a[3],s=Buffer.from(decodeURIComponent(d),l?"base64":"utf8");if(t){if(!i)throw new mp("Blob is not supported",mp.ERR_NOT_SUPPORT);return new i([s],{type:u})}return s}throw new mp("Unsupported protocol "+n,mp.ERR_NOT_SUPPORT)}var UCi=vi(require("stream"),1);var Iep=vi(require("stream"),1);var nMs=Symbol("internals"),aMs=class extends Iep.default.Transform{constructor(t){t=us.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!us.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[nMs]={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[nMs];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[nMs],a=n.maxRate,u=this.readableHighWaterMark,l=n.timeWindow,d=1e3/l,s=a/d,o=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,c=(g,O)=>{let m=Buffer.byteLength(g);n.bytesSeen+=m,n.bytes+=m,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(g)?process.nextTick(O):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(O)}},b=(g,O)=>{let m=Buffer.byteLength(g),w=null,E=u,A,q=0;if(a){let D=Date.now();(!n.ts||(q=D-n.ts)>=l)&&(n.ts=D,A=s-n.bytes,n.bytes=A<0?-A:0,q=0),A=s-n.bytes}if(a){if(A<=0)return setTimeout(()=>{O(null,g)},l-q);A<E&&(E=A)}E&&m>E&&m-E>o&&(w=g.subarray(E),g=g.subarray(0,E)),c(g,w?()=>{process.nextTick(O,null,w)}:O)};b(t,function g(O,m){if(O)return i(O);m?b(m,g):i(null)})}},oMs=aMs;var ttp=require("events");var Rep=require("util"),Nep=require("stream");var{asyncIterator:zep}=Symbol,F1S=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[zep]?yield*e[zep]():yield e},tbo=F1S;var L1S=us.ALPHABET.ALPHA_DIGIT+"-_",haa=new Rep.TextEncoder,Msi=`\r
1697
1697
  `,U1S=haa.encode(Msi),V1S=2,uMs=class{constructor(t,r){let{escapeName:i}=this.constructor,n=us.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${Msi}`;n?r=haa.encode(String(r).replace(/\r?\n|\r\n?/g,Msi)):a+=`Content-Type: ${r.type||"application/octet-stream"}${Msi}`,this.headers=haa.encode(a+Msi),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+V1S,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;us.isTypedArray(t)?yield t:yield*tbo(t),yield U1S}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},W1S=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+us.generateString(n,L1S)}=r||{};if(!us.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let u=haa.encode("--"+a+Msi),l=haa.encode("--"+a+"--"+Msi+Msi),d=l.byteLength,s=Array.from(e.entries()).map(([c,b])=>{let g=new uMs(c,b);return d+=g.size,g});d+=u.byteLength*s.length,d=us.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),Nep.Readable.from(async function*(){for(let c of s)yield u,yield*c.encode();yield l}())},Fep=W1S;var Lep=vi(require("stream"),1),sMs=class extends Lep.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)}},Uep=sMs;var H1S=(e,t)=>us.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,Vep=H1S;function $1S(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,u;return t=t!==void 0?t:1e3,function(d){let s=Date.now(),o=i[a];u||(u=s),r[n]=d,i[n]=s;let c=a,b=0;for(;c!==n;)b+=r[c++],c=c%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-u<t)return;let g=o&&s-o;return g?Math.round(b*1e3/g):void 0}}var Wep=$1S;function G1S(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 Hep=G1S;var Z$r=(e,t,r=3)=>{let i=0,n=Wep(50,250);return Hep(a=>{let u=a.loaded,l=a.lengthComputable?a.total:void 0,d=u-i,s=n(d),o=u<=l;i=u;let c={loaded:u,total:l,progress:l?u/l:void 0,bytes:d,rate:s||void 0,estimated:s&&l&&o?(l-u)/s:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(c)},r)},Xbn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},Zbn=e=>(...t)=>us.asap(()=>e(...t));var $ep={flush:k$r.default.constants.Z_SYNC_FLUSH,finishFlush:k$r.default.constants.Z_SYNC_FLUSH},Q1S={flush:k$r.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:k$r.default.constants.BROTLI_OPERATION_FLUSH},Gep=us.isFunction(k$r.default.createBrotliDecompress),{http:J1S,https:K1S}=etp.default,Y1S=/https:?/,Qep=NT.protocols.map(e=>e+":"),Jep=(e,[t,r])=>(e.on("end",r).on("error",r),t);function X1S(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function rtp(e,t,r){let i=t;if(!i&&i!==!1){let n=(0,Yep.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){rtp(a,t,a.href)}}var Z1S=typeof process<"u"&&us.kindOf(process)==="process",k1S=e=>new Promise((t,r)=>{let i,n,a=(d,s)=>{n||(n=!0,i&&i(d,s))},u=d=>{a(d),t(d)},l=d=>{a(d,!0),r(d)};e(u,l,d=>i=d).catch(l)}),eSS=({address:e,family:t})=>{if(!us.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},Kep=(e,t)=>eSS(us.isObject(e)?e:{address:e,family:t}),itp=Z1S&&function(t){return k1S(async function(i,n,a){let{data:u,lookup:l,family:d}=t,{responseType:s,responseEncoding:o}=t,c=t.method.toUpperCase(),b,g=!1,O;if(l){let we=Vep(l,Ze=>us.isArray(Ze)?Ze:[Ze]);l=(Ze,Mt,De)=>{we(Ze,Mt,(Te,xt,Ee)=>{if(Te)return De(Te);let It=us.isArray(xt)?xt.map(st=>Kep(st)):[Kep(xt,Ee)];Mt.all?De(Te,It):De(Te,It[0].address,It[0].family)})}}let m=new ttp.EventEmitter,w=()=>{t.cancelToken&&t.cancelToken.unsubscribe(E),t.signal&&t.signal.removeEventListener("abort",E),m.removeAllListeners()};a((we,Ze)=>{b=!0,Ze&&(g=!0,w())});function E(we){m.emit("abort",!we||we.type?new W1e(null,t,O):we)}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 A=FCi(t.baseURL,t.url),q=new URL(A,NT.hasBrowserEnv?NT.origin:void 0),D=q.protocol||Qep[0];if(D==="data:"){let we;if(c!=="GET")return mKt(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{we=iMs(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Ze){throw mp.from(Ze,mp.ERR_BAD_REQUEST,t)}return s==="text"?(we=we.toString(o),(!o||o==="utf8")&&(we=us.stripBOM(we))):s==="stream"&&(we=UCi.default.Readable.from(we)),mKt(i,n,{data:we,status:200,statusText:"OK",headers:new VI,config:t})}if(Qep.indexOf(D)===-1)return n(new mp("Unsupported protocol "+D,mp.ERR_BAD_REQUEST,t));let C=VI.from(t.headers).normalize();C.set("User-Agent","axios/"+LCi,!1);let{onUploadProgress:R,onDownloadProgress:$}=t,I=t.maxRate,U,H;if(us.isSpecCompliantForm(u)){let we=C.getContentType(/boundary=([-_\w\d]{10,70})/i);u=Fep(u,Ze=>{C.set(Ze)},{tag:`axios-${LCi}-boundary`,boundary:we&&we[1]||void 0})}else if(us.isFormData(u)&&us.isFunction(u.getHeaders)){if(C.set(u.getHeaders()),!C.hasContentLength())try{let we=await kep.default.promisify(u.getLength).call(u);Number.isFinite(we)&&we>=0&&C.setContentLength(we)}catch{}}else if(us.isBlob(u))u.size&&C.setContentType(u.type||"application/octet-stream"),C.setContentLength(u.size||0),u=UCi.default.Readable.from(tbo(u));else if(u&&!us.isStream(u)){if(!Buffer.isBuffer(u))if(us.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(us.isString(u))u=Buffer.from(u,"utf-8");else return n(new mp("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",mp.ERR_BAD_REQUEST,t));if(C.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new mp("Request body larger than maxBodyLength limit",mp.ERR_BAD_REQUEST,t))}let k=us.toFiniteNumber(C.getContentLength());us.isArray(I)?(U=I[0],H=I[1]):U=H=I,u&&(R||U)&&(us.isStream(u)||(u=UCi.default.Readable.from(u,{objectMode:!1})),u=UCi.default.pipeline([u,new oMs({maxRate:us.toFiniteNumber(U)})],us.noop),R&&u.on("progress",Jep(u,Xbn(k,Z$r(Zbn(R),!1,3)))));let K;if(t.auth){let we=t.auth.username||"",Ze=t.auth.password||"";K=we+":"+Ze}if(!K&&q.username){let we=q.username,Ze=q.password;K=we+":"+Ze}K&&C.delete("authorization");let te;try{te=NCi(q.pathname+q.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(we){let Ze=new Error(we.message);return Ze.config=t,Ze.url=t.url,Ze.exists=!0,n(Ze)}C.set("Accept-Encoding","gzip, compress, deflate"+(Gep?", br":""),!1);let fe={path:te,method:c,headers:C.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:K,protocol:D,family:d,beforeRedirect:X1S,beforeRedirects:{}};!us.isUndefined(l)&&(fe.lookup=l),t.socketPath?fe.socketPath=t.socketPath:(fe.hostname=q.hostname.startsWith("[")?q.hostname.slice(1,-1):q.hostname,fe.port=q.port,rtp(fe,t.proxy,D+"//"+q.hostname+(q.port?":"+q.port:"")+fe.path));let me,be=Y1S.test(fe.protocol);if(fe.agent=be?t.httpsAgent:t.httpAgent,t.transport?me=t.transport:t.maxRedirects===0?me=be?Zep.default:Xep.default:(t.maxRedirects&&(fe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(fe.beforeRedirects.config=t.beforeRedirect),me=be?K1S:J1S),t.maxBodyLength>-1?fe.maxBodyLength=t.maxBodyLength:fe.maxBodyLength=1/0,t.insecureHTTPParser&&(fe.insecureHTTPParser=t.insecureHTTPParser),O=me.request(fe,function(Ze){if(O.destroyed)return;let Mt=[Ze],De=+Ze.headers["content-length"];if($||H){let st=new oMs({maxRate:us.toFiniteNumber(H)});$&&st.on("progress",Jep(st,Xbn(De,Z$r(Zbn($),!0,3)))),Mt.push(st)}let Te=Ze,xt=Ze.req||O;if(t.decompress!==!1&&Ze.headers["content-encoding"])switch((c==="HEAD"||Ze.statusCode===204)&&delete Ze.headers["content-encoding"],(Ze.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":Mt.push(k$r.default.createUnzip($ep)),delete Ze.headers["content-encoding"];break;case"deflate":Mt.push(new Uep),Mt.push(k$r.default.createUnzip($ep)),delete Ze.headers["content-encoding"];break;case"br":Gep&&(Mt.push(k$r.default.createBrotliDecompress(Q1S)),delete Ze.headers["content-encoding"])}Te=Mt.length>1?UCi.default.pipeline(Mt,us.noop):Mt[0];let Ee=UCi.default.finished(Te,()=>{Ee(),w()}),It={status:Ze.statusCode,statusText:Ze.statusMessage,headers:new VI(Ze.headers),config:t,request:xt};if(s==="stream")It.data=Te,mKt(i,n,It);else{let st=[],ye=0;Te.on("data",function(Ot){st.push(Ot),ye+=Ot.length,t.maxContentLength>-1&&ye>t.maxContentLength&&(g=!0,Te.destroy(),n(new mp("maxContentLength size of "+t.maxContentLength+" exceeded",mp.ERR_BAD_RESPONSE,t,xt)))}),Te.on("aborted",function(){if(g)return;let Ot=new mp("maxContentLength size of "+t.maxContentLength+" exceeded",mp.ERR_BAD_RESPONSE,t,xt);Te.destroy(Ot),n(Ot)}),Te.on("error",function(Ot){O.destroyed||n(mp.from(Ot,null,t,xt))}),Te.on("end",function(){try{let Ot=st.length===1?st[0]:Buffer.concat(st);s!=="arraybuffer"&&(Ot=Ot.toString(o),(!o||o==="utf8")&&(Ot=us.stripBOM(Ot))),It.data=Ot}catch(Ot){return n(mp.from(Ot,null,t,It.request,It))}mKt(i,n,It)})}m.once("abort",st=>{Te.destroyed||(Te.emit("error",st),Te.destroy())})}),m.once("abort",we=>{n(we),O.destroy(we)}),O.on("error",function(Ze){n(mp.from(Ze,null,t,O))}),O.on("socket",function(Ze){Ze.setKeepAlive(!0,1e3*60)}),t.timeout){let we=parseInt(t.timeout,10);if(Number.isNaN(we)){n(new mp("error trying to parse `config.timeout` to int",mp.ERR_BAD_OPTION_VALUE,t,O));return}O.setTimeout(we,function(){if(b)return;let Mt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",De=t.transitional||Jbn;t.timeoutErrorMessage&&(Mt=t.timeoutErrorMessage),n(new mp(Mt,De.clarifyTimeoutError?mp.ETIMEDOUT:mp.ECONNABORTED,t,O)),E()})}if(us.isStream(u)){let we=!1,Ze=!1;u.on("end",()=>{we=!0}),u.once("error",Mt=>{Ze=!0,O.destroy(Mt)}),u.on("close",()=>{!we&&!Ze&&E(new W1e("Request stream has been aborted",t,O))}),u.pipe(O)}else O.end(u)})};var ntp=NT.hasStandardBrowserEnv?function(){let t=NT.navigator&&/(msie|trident)/i.test(NT.navigator.userAgent),r=document.createElement("a"),i;function n(a){let u=a;return t&&(r.setAttribute("href",u),u=r.href),r.setAttribute("href",u),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return i=n(window.location.href),function(u){let l=us.isString(u)?n(u):u;return l.protocol===i.protocol&&l.host===i.host}}():function(){return function(){return!0}}();var atp=NT.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];us.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),us.isString(i)&&u.push("path="+i),us.isString(n)&&u.push("domain="+n),a===!0&&u.push("secure"),document.cookie=u.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var otp=e=>e instanceof VI?{...e}:e;function a8t(e,t){t=t||{};let r={};function i(s,o,c){return us.isPlainObject(s)&&us.isPlainObject(o)?us.merge.call({caseless:c},s,o):us.isPlainObject(o)?us.merge({},o):us.isArray(o)?o.slice():o}function n(s,o,c){if(us.isUndefined(o)){if(!us.isUndefined(s))return i(void 0,s,c)}else return i(s,o,c)}function a(s,o){if(!us.isUndefined(o))return i(void 0,o)}function u(s,o){if(us.isUndefined(o)){if(!us.isUndefined(s))return i(void 0,s)}else return i(void 0,o)}function l(s,o,c){if(c in t)return i(s,o);if(c in e)return i(void 0,s)}let d={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:l,headers:(s,o)=>n(otp(s),otp(o),!0)};return us.forEach(Object.keys(Object.assign({},e,t)),function(o){let c=d[o]||n,b=c(e[o],t[o],o);us.isUndefined(b)&&c!==l||(r[o]=b)}),r}var rbo=e=>{let t=a8t({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:l}=t;t.headers=u=VI.from(u),t.url=NCi(FCi(t.baseURL,t.url),e.params,e.paramsSerializer),l&&u.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let d;if(us.isFormData(r)){if(NT.hasStandardBrowserEnv||NT.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((d=u.getContentType())!==!1){let[s,...o]=d?d.split(";").map(c=>c.trim()).filter(Boolean):[];u.setContentType([s||"multipart/form-data",...o].join("; "))}}if(NT.hasStandardBrowserEnv&&(i&&us.isFunction(i)&&(i=i(t)),i||i!==!1&&ntp(t.url))){let s=n&&a&&atp.read(a);s&&u.set(n,s)}return t};var tSS=typeof XMLHttpRequest<"u",utp=tSS&&function(e){return new Promise(function(r,i){let n=rbo(e),a=n.data,u=VI.from(n.headers).normalize(),{responseType:l,onUploadProgress:d,onDownloadProgress:s}=n,o,c,b,g,O;function m(){g&&g(),O&&O(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let w=new XMLHttpRequest;w.open(n.method.toUpperCase(),n.url,!0),w.timeout=n.timeout;function E(){if(!w)return;let q=VI.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),C={data:!l||l==="text"||l==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:q,config:e,request:w};mKt(function($){r($),m()},function($){i($),m()},C),w=null}"onloadend"in w?w.onloadend=E:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(E)},w.onabort=function(){w&&(i(new mp("Request aborted",mp.ECONNABORTED,e,w)),w=null)},w.onerror=function(){i(new mp("Network Error",mp.ERR_NETWORK,e,w)),w=null},w.ontimeout=function(){let D=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",C=n.transitional||Jbn;n.timeoutErrorMessage&&(D=n.timeoutErrorMessage),i(new mp(D,C.clarifyTimeoutError?mp.ETIMEDOUT:mp.ECONNABORTED,e,w)),w=null},a===void 0&&u.setContentType(null),"setRequestHeader"in w&&us.forEach(u.toJSON(),function(D,C){w.setRequestHeader(C,D)}),us.isUndefined(n.withCredentials)||(w.withCredentials=!!n.withCredentials),l&&l!=="json"&&(w.responseType=n.responseType),s&&([b,O]=Z$r(s,!0),w.addEventListener("progress",b)),d&&w.upload&&([c,g]=Z$r(d),w.upload.addEventListener("progress",c),w.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(o=q=>{w&&(i(!q||q.type?new W1e(null,e,w):q),w.abort(),w=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let A=_aa(n.url);if(A&&NT.protocols.indexOf(A)===-1){i(new mp("Unsupported protocol "+A+":",mp.ERR_BAD_REQUEST,e));return}w.send(a||null)})};var rSS=(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 mp?o:new W1e(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new mp(`timeout ${t} of ms exceeded`,mp.ETIMEDOUT))},t),l=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:d}=i;return d.unsubscribe=()=>us.asap(l),d}},stp=rSS;var iSS=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},nSS=async function*(e,t){for await(let r of aSS(e))yield*iSS(r,t)},aSS=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()}},cMs=(e,t,r,i)=>{let n=nSS(e,t),a=0,u,l=d=>{u||(u=!0,i&&i(d))};return new ReadableStream({async pull(d){try{let{done:s,value:o}=await n.next();if(s){l(),d.close();return}let c=o.byteLength;if(r){let b=a+=c;r(b)}d.enqueue(new Uint8Array(o))}catch(s){throw l(s),s}},cancel(d){return l(d),n.return()}},{highWaterMark:2})};var nbo=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",ltp=nbo&&typeof ReadableStream=="function",oSS=nbo&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),ftp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},uSS=ltp&&ftp(()=>{let e=!1,t=new Request(NT.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),ctp=64*1024,lMs=ltp&&ftp(()=>us.isReadableStream(new Response("").body)),ibo={stream:lMs&&(e=>e.body)};nbo&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!ibo[t]&&(ibo[t]=us.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new mp(`Response type '${t}' is not supported`,mp.ERR_NOT_SUPPORT,i)})})})(new Response);var sSS=async e=>{if(e==null)return 0;if(us.isBlob(e))return e.size;if(us.isSpecCompliantForm(e))return(await new Request(NT.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(us.isArrayBufferView(e)||us.isArrayBuffer(e))return e.byteLength;if(us.isURLSearchParams(e)&&(e=e+""),us.isString(e))return(await oSS(e)).byteLength},cSS=async(e,t)=>{let r=us.toFiniteNumber(e.getContentLength());return r??sSS(t)},dtp=nbo&&(async e=>{let{url:t,method:r,data:i,signal:n,cancelToken:a,timeout:u,onDownloadProgress:l,onUploadProgress:d,responseType:s,headers:o,withCredentials:c="same-origin",fetchOptions:b}=rbo(e);s=s?(s+"").toLowerCase():"text";let g=stp([n,a&&a.toAbortSignal()],u),O,m=g&&g.unsubscribe&&(()=>{g.unsubscribe()}),w;try{if(d&&uSS&&r!=="get"&&r!=="head"&&(w=await cSS(o,i))!==0){let C=new Request(t,{method:"POST",body:i,duplex:"half"}),R;if(us.isFormData(i)&&(R=C.headers.get("content-type"))&&o.setContentType(R),C.body){let[$,I]=Xbn(w,Z$r(Zbn(d)));i=cMs(C.body,ctp,$,I)}}us.isString(c)||(c=c?"include":"omit");let E="credentials"in Request.prototype;O=new Request(t,{...b,signal:g,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:i,duplex:"half",credentials:E?c:void 0});let A=await fetch(O),q=lMs&&(s==="stream"||s==="response");if(lMs&&(l||q&&m)){let C={};["status","statusText","headers"].forEach(U=>{C[U]=A[U]});let R=us.toFiniteNumber(A.headers.get("content-length")),[$,I]=l&&Xbn(R,Z$r(Zbn(l),!0))||[];A=new Response(cMs(A.body,ctp,$,()=>{I&&I(),m&&m()}),C)}s=s||"text";let D=await ibo[us.findKey(ibo,s)||"text"](A,e);return!q&&m&&m(),await new Promise((C,R)=>{mKt(C,R,{data:D,headers:VI.from(A.headers),status:A.status,statusText:A.statusText,config:e,request:O})})}catch(E){throw m&&m(),E&&E.name==="TypeError"&&/fetch/i.test(E.message)?Object.assign(new mp("Network Error",mp.ERR_NETWORK,e,O),{cause:E.cause||E}):mp.from(E,E&&E.code,e,O)}});var fMs={http:itp,xhr:utp,fetch:dtp};us.forEach(fMs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var ptp=e=>`- ${e}`,lSS=e=>us.isFunction(e)||e===null||e===!1,abo={getAdapter:e=>{e=us.isArray(e)?e:[e];let{length:t}=e,r,i,n={};for(let a=0;a<t;a++){r=e[a];let u;if(i=r,!lSS(r)&&(i=fMs[(u=String(r)).toLowerCase()],i===void 0))throw new mp(`Unknown adapter '${u}'`);if(i)break;n[u||"#"+a]=i}if(!i){let a=Object.entries(n).map(([l,d])=>`adapter ${l} `+(d===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
@@ -1929,7 +1929,7 @@ ${q}${A}${D}${HMp.default.cursorHide}`});var ala=vi(Qqi(),1);function i7s(e,t){i
1929
1929
  Run ${Qs.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
1930
1930
  Run ${Qs.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),e0n(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function _7s({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!_Ap(e))return;let n=t??"",a=e.filter(l=>l.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((l,d)=>l.generatorName.localeCompare(d.generatorName)||l.currentVersion.localeCompare(d.currentVersion));for(let l of u)n+=`
1931
1931
  ${await LiD(l.generatorName)} (${l.apiName!=null?"API: "+l.apiName+", ":""}Group: ${l.generatorGroup}) `+Qs.dim(l.currentVersion)+Qs.reset(" \u2192 ")+Qs.green(l.latestVersion);return n+=`
1932
- `,i?e0n(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function LiD(e){let r=await new pAp.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 UiD({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await yAp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=toi(o.name,c),g=await RGt({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 yAp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,d,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][d]==null&&(u.versions[l][d]={});let c=toi(s.name,o),b=await RGt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function yAp({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 A4t({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let d of l.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function vAp(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=Qre(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function aSo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await UiD({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[d,s]of Object.entries(l.versions))u.push(...vAp(s,d,t.logger));else u.push(...vAp(l.versions,void 0,t.logger))}return u}var pla=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 Wmn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Hmn=e=>e!==null&&typeof e=="object";var _la=(...e)=>{for(let t of e)if((!Hmn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return v7s({},...e)},h7s=(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 oSo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:v7s(e[r]??[],t[r]??[])}var y7s=(e={},t={})=>({beforeRequest:oSo(e,t,"beforeRequest"),beforeRetry:oSo(e,t,"beforeRetry"),afterResponse:oSo(e,t,"afterResponse"),beforeError:oSo(e,t,"beforeError")}),v7s=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(Hmn(n)){for(let[a,u]of Object.entries(n))Hmn(u)&&a in t&&(u=v7s(t[a],u)),t={...t,[a]:u};Hmn(n.hooks)&&(i=y7s(i,n.hooks),t.hooks=i),Hmn(n.headers)&&(r=h7s(r,n.headers),t.headers=r)}return t};var bAp=(()=>{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})(),gAp=typeof globalThis.AbortController=="function",OAp=typeof globalThis.ReadableStream=="function",mAp=typeof globalThis.FormData=="function",uSo=["get","post","put","patch","head","delete"],ViD=()=>{};ViD();var PAp={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},sSo=2147483647,cSo=Symbol("stop"),jAp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},wAp={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 DAp=e=>uSo.includes(e)?e.toUpperCase():e,WiD=["get","put","head","delete","options","trace"],HiD=[408,413,429,500,502,503,504],$iD=[413,429,503],SAp={limit:2,methods:WiD,statusCodes:HiD,afterStatusCodes:$iD,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},EAp=(e={})=>{if(typeof e=="number")return{...SAp,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{...SAp,...e}};async function b7s(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new Wmn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function g7s(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 MAp=(e,t)=>{let r={};for(let i in t)!(i in wAp)&&!(i in jAp)&&!(i in e)&&(r[i]=t[i]);return r};var hla=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>sSo)throw new RangeError(`The \`timeout\` option cannot be greater than ${sSo}`);await Promise.resolve();let l=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let d=new pla(l,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!OAp)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,d]of Object.entries(PAp))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);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:h7s(this._input.headers,r.headers),hooks:y7s({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:DAp(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:EAp(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(gAp){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(bAp&&(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);(mAp&&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 Wmn)throw t;if(t instanceof pla){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),sSo);if(this._retryCount<1)throw r;await g7s(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})===cSo)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=MAp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):b7s(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:d,value:s}=await u.read();if(d){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 O7s=e=>{let t=(r,i)=>hla.create(r,_la(e,i));for(let r of uSo)t[r]=(i,n)=>hla.create(i,_la(e,n,{method:r}));return t.create=r=>O7s(_la(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),O7s(_la(e,r))),t.stop=cSo,t},GiD=O7s(),AAp=GiD;var ZAp=vi(XAp(),1);function S7s(e){let t=(0,ZAp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Gqp=vi($qp(),1),Qqp=vi(Qqi(),1),F7s=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},L7s=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function U7s(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??S7s(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,Gqp.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,l&&(d.authorization=`${l.type} ${l.token}`);let s;try{s=await AAp(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new F7s(e):c}if(t.allVersions)return s;let o=new L7s(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=Qqp.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 mla(e,t){let{version:r}=await U7s(e.toLowerCase(),t);return r}async function kci({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:mla(e.packageName,{version:t?"prerelease":"latest"})}var Jqp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],mSo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=B0.Info;constructor(t){this.ttyAwareLogger=new nSo(t);let r=this.getPackageName(),i=this.getPackageVersion(),n=this.getCliName();(r==null||i==null||n==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:i,cliName:n}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.56.0-rc4"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Qs.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new dte}failWithoutThrowing(t,r){this.didSucceed=!1,eSo({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await $bn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await hAp({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1932
+ `,i?e0n(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function LiD(e){let r=await new pAp.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 UiD({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await yAp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=toi(o.name,c),g=await RGt({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 yAp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,d,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][d]==null&&(u.versions[l][d]={});let c=toi(s.name,o),b=await RGt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function yAp({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 A4t({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let d of l.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function vAp(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=Qre(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function aSo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await UiD({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[d,s]of Object.entries(l.versions))u.push(...vAp(s,d,t.logger));else u.push(...vAp(l.versions,void 0,t.logger))}return u}var pla=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 Wmn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Hmn=e=>e!==null&&typeof e=="object";var _la=(...e)=>{for(let t of e)if((!Hmn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return v7s({},...e)},h7s=(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 oSo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:v7s(e[r]??[],t[r]??[])}var y7s=(e={},t={})=>({beforeRequest:oSo(e,t,"beforeRequest"),beforeRetry:oSo(e,t,"beforeRetry"),afterResponse:oSo(e,t,"afterResponse"),beforeError:oSo(e,t,"beforeError")}),v7s=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(Hmn(n)){for(let[a,u]of Object.entries(n))Hmn(u)&&a in t&&(u=v7s(t[a],u)),t={...t,[a]:u};Hmn(n.hooks)&&(i=y7s(i,n.hooks),t.hooks=i),Hmn(n.headers)&&(r=h7s(r,n.headers),t.headers=r)}return t};var bAp=(()=>{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})(),gAp=typeof globalThis.AbortController=="function",OAp=typeof globalThis.ReadableStream=="function",mAp=typeof globalThis.FormData=="function",uSo=["get","post","put","patch","head","delete"],ViD=()=>{};ViD();var PAp={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},sSo=2147483647,cSo=Symbol("stop"),jAp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},wAp={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 DAp=e=>uSo.includes(e)?e.toUpperCase():e,WiD=["get","put","head","delete","options","trace"],HiD=[408,413,429,500,502,503,504],$iD=[413,429,503],SAp={limit:2,methods:WiD,statusCodes:HiD,afterStatusCodes:$iD,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},EAp=(e={})=>{if(typeof e=="number")return{...SAp,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{...SAp,...e}};async function b7s(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new Wmn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function g7s(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 MAp=(e,t)=>{let r={};for(let i in t)!(i in wAp)&&!(i in jAp)&&!(i in e)&&(r[i]=t[i]);return r};var hla=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>sSo)throw new RangeError(`The \`timeout\` option cannot be greater than ${sSo}`);await Promise.resolve();let l=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let d=new pla(l,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!OAp)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,d]of Object.entries(PAp))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);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:h7s(this._input.headers,r.headers),hooks:y7s({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:DAp(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:EAp(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(gAp){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(bAp&&(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);(mAp&&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 Wmn)throw t;if(t instanceof pla){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),sSo);if(this._retryCount<1)throw r;await g7s(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})===cSo)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=MAp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):b7s(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:d,value:s}=await u.read();if(d){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 O7s=e=>{let t=(r,i)=>hla.create(r,_la(e,i));for(let r of uSo)t[r]=(i,n)=>hla.create(i,_la(e,n,{method:r}));return t.create=r=>O7s(_la(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),O7s(_la(e,r))),t.stop=cSo,t},GiD=O7s(),AAp=GiD;var ZAp=vi(XAp(),1);function S7s(e){let t=(0,ZAp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Gqp=vi($qp(),1),Qqp=vi(Qqi(),1),F7s=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},L7s=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function U7s(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??S7s(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,Gqp.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,l&&(d.authorization=`${l.type} ${l.token}`);let s;try{s=await AAp(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new F7s(e):c}if(t.allVersions)return s;let o=new L7s(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=Qqp.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 mla(e,t){let{version:r}=await U7s(e.toLowerCase(),t);return r}async function kci({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:mla(e.packageName,{version:t?"prerelease":"latest"})}var Jqp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],mSo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=B0.Info;constructor(t){this.ttyAwareLogger=new nSo(t);let r=this.getPackageName(),i=this.getPackageVersion(),n=this.getCliName();(r==null||i==null||n==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:i,cliName:n}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.56.0-rc5"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Qs.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new dte}failWithoutThrowing(t,r){this.didSucceed=!1,eSo({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await $bn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await hAp({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1933
1933
  `)||(r+=`
1934
1934
  `),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=Nus(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 ola(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 dte}finally{i.finish()}return n}async instrumentPostHogEvent(t){(await $bn()).sendEvent(t)}logger=CHr(this.log.bind(this));constructTaskInitForWorkspace(t){let r=Kqp(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?Kqp(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=Jqp[this.numTasks++%Jqp.length],u=Qs.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===dC.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logImmediately(t){let r=t.filter(i=>vai.indexOf(i.level)>=vai.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===B0.Debug})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await kci({cliEnvironment:this.environment,includePreReleases:t}),i=Qre(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await aSo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await X3s({message:t,default:r})}async getInput(t){return await Z3s({message:t.message,default:t.default})}};function Kqp(e){return`[${e}]:`}var pHp=require("fs/promises");function Jre({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Qs.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Qs.dim(r)),i.join(`
1935
1935
  `)}var D5p=require("fs/promises");var N8t=class e{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;type=e.Type;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 sSe=class extends N8t{definition;sources;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 Pla=class{context;constructor(t){this.context=t}};var PSo=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,l]of Object.entries(i.files)){let d=n!=null?ry.of(`${n}${Y2t}${u}`):ry.of(u);t[d]=l}let a=Object.keys(i.directories).sort();for(let u of a){let l=n!=null?`${n}${Y2t}${u}`:u,d=i.directories[u];r(d,l)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(Y2t))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[ry.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 Yxi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new PSo,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 o$r(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"]))XnD(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}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??vg((LCe(r)+"/"+XAi(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===ry.of(T3))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=XKa(LCe(Zdn.of(`/${t}`)),Zdn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=XKa(LCe(Zdn.of(`/${t}`)),Zdn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){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=>o1e(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=sR(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:sR(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:sR(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===W1?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 XnD(e){return e?.header!=null}var Kre={openapi:e=>({...e,type:"openapi",_visit:function(t){return Kre._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return Kre._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 Xmn={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return Xmn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var k8={basic:e=>({...e,type:"basic",_visit:function(t){return k8._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return k8._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return k8._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return k8._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return k8._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 Q0={primitive:e=>({value:e,type:"primitive",_visit:function(t){return Q0._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Q0._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return Q0._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return Q0._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return Q0._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return Q0._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Q0._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return Q0._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 i_={int:e=>({value:e,type:"int",_visit:function(t){return i_._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return i_._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return i_._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return i_._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return i_._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return i_._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return i_._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return i_._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return i_._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return i_._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return i_._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 Zmn={boolean:e=>({value:e,type:"boolean",_visit:function(t){return Zmn._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Zmn._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 eli={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return eli._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return eli._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 $U={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case $U.GenerallyAvailable:return t.generallyAvailable();case $U.Beta:return t.beta();case $U.Deprecated:return t.deprecated();default:return t._other()}}};var AIe={cursor:e=>({...e,type:"cursor",_visit(t){return AIe._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit(t){return AIe._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit(t){return AIe._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 GGr={language:e=>({...e,type:"language",_visit:function(t){return GGr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return GGr._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 GU={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 GU.Curl:return t.curl();case GU.Python:return t.python();case GU.Javascript:return t.javascript();case GU.Typescript:return t.typescript();case GU.Go:return t.go();case GU.Ruby:return t.ruby();case GU.Csharp:return t.csharp();case GU.Java:return t.java();case GU.Js:return t.js();case GU.Node:return t.node();case GU.Ts:return t.ts();case GU.Nodets:return t.nodets();case GU.Golang:return t.golang();case GU.Dotnet:return t.dotnet();case GU.Jvm:return t.jvm();default:return t._other()}}};var F8t={unknown:e=>({value:e,type:"unknown",_visit:function(t){return F8t._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return F8t._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 qIe={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return qIe._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return qIe._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 W$={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case W$.Get:return t.get();case W$.Post:return t.post();case W$.Put:return t.put();case W$.Patch:return t.patch();case W$.Delete:return t.delete();case W$.Head:return t.head();case W$.Options:return t.options();case W$.Trace:return t.trace();default:return t._other()}}};var tli={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return tli._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return tli._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return tli._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 TIe={file:e=>({...e,type:"file",_visit:function(t){return TIe._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return TIe._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 Yre={file:e=>({...e,type:"file",_visit:function(t){return Yre._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Yre._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Yre._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Yre._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Yre._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Yre._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var 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 YB={boolean:e=>({value:e,type:"boolean",_visit:function(t){return YB._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return YB._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 QGr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return QGr._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return QGr._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 cSe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return cSe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return cSe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return cSe._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 XB={file:e=>({...e,type:"file",_visit:function(t){return XB._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return XB._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return XB._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return XB._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return XB._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return XB._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var El={primitive:e=>({...e,type:"primitive",_visit:function(t){return El._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return El._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return El._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return El._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return El._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return El._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return El._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return El._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return El._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return El._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return El._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 PY={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return PY._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return PY._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 Jd={int:e=>({...e,type:"int",_visit:function(t){return Jd._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Jd._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Jd._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Jd._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Jd._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Jd._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Jd._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Jd._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Jd._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Jd._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Jd._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 ev={};Io(ev,{AllOfPropertyConflict:()=>OPn,ArraySchema:()=>zDo,ArraySchemaWithExample:()=>lEo,Availability:()=>CSo,Base64WithExample:()=>aEo,BasicSecurityScheme:()=>ISo,BearerSecurityScheme:()=>zSo,BooleanSchema:()=>qDo,BooleanWithExample:()=>oEo,CasingOverrides:()=>FSo,CommonProperty:()=>HDo,CommonPropertyWithExample:()=>gEo,CursorPagination:()=>hDo,CustomCodeSample:()=>pDo,CustomCodeSampleLanguage:()=>lDo,CustomCodeSampleSdk:()=>dDo,CustomPagination:()=>vDo,DateWithExample:()=>nEo,DatetimeWithExample:()=>iEo,DiscriminatedOneOfSchema:()=>VDo,DiscriminatedOneOfSchemaWithExample:()=>vEo,DoubleSchema:()=>MDo,DoubleWithExample:()=>tEo,Encoding:()=>TSo,Endpoint:()=>bDo,EndpointExample:()=>hPn,EndpointResponseExample:()=>cDo,EndpointSdkName:()=>fYt,EndpointWithExample:()=>STp,EnumSchema:()=>rPn,EnumSchemaWithExample:()=>sEo,EnumValue:()=>nli,ErrorExample:()=>nDo,FernExample:()=>oDo,FileResponse:()=>lPn,FileSchema:()=>XSo,FloatWithExample:()=>eEo,FullEndpointExample:()=>_Do,FullExample:()=>BA,FullObjectExample:()=>GSo,FullOneOfExample:()=>JSo,GlobalHeader:()=>CDo,Header:()=>oli,HeaderExample:()=>_Pn,HeaderSecurityScheme:()=>RSo,HeaderWithExample:()=>cli,HttpEndpointServer:()=>dPn,HttpError:()=>aDo,HttpErrorWithExample:()=>KDo,HttpMethod:()=>aPn,IdempotencyHeader:()=>BDo,Int64WithExample:()=>XDo,IntSchema:()=>DDo,IntWithExample:()=>YDo,JsonRequest:()=>tDo,JsonRequestWithExample:()=>GDo,JsonResponse:()=>fPn,JsonResponseWithExample:()=>jPn,KeyValuePair:()=>QSo,LiteralExample:()=>$So,LiteralSchema:()=>gPn,LiteralSchemaValue:()=>xDo,LongSchema:()=>EDo,MapSchema:()=>RDo,MapSchemaWithExample:()=>fEo,MultipartRequest:()=>cPn,MultipartRequestProperty:()=>eDo,MultipartRequestPropertyEncoding:()=>kSo,MultipartSchema:()=>ZSo,NamedFullExample:()=>pYt,Namespace:()=>LSo,NamespaceId:()=>HSo,NullableSchema:()=>FDo,NullableSchemaWithExample:()=>pEo,OauthSecurityScheme:()=>VSo,ObjectProperty:()=>UDo,ObjectPropertyConflictInfo:()=>mPn,ObjectPropertyWithExample:()=>yEo,ObjectSchema:()=>IDo,ObjectSchemaWithExample:()=>_Eo,OctetStreamRequest:()=>sPn,OffsetPagination:()=>yDo,OneOfSchema:()=>LDo,OneOfSchemaWithExample:()=>hEo,OpenApiIntermediateRepresentation:()=>jTp,OpenApiSource:()=>ESo,OptionalSchema:()=>NDo,OptionalSchemaWithExample:()=>dEo,Pagination:()=>yPn,PathParameter:()=>oPn,PathParameterExample:()=>uDo,PathParameterWithExample:()=>$Do,PrimitiveExample:()=>nPn,PrimitiveSchema:()=>sli,PrimitiveSchemaValue:()=>TDo,PrimitiveSchemaValueWithExample:()=>uEo,PrimitiveSchemaWithExample:()=>wPn,PropertyKey:()=>iPn,ProtobufEncoding:()=>qSo,ProtobufSource:()=>MSo,QueryParameter:()=>uPn,QueryParameterExample:()=>pPn,QueryParameterWithExample:()=>PPn,QuerySecurityScheme:()=>NSo,ReferencedSchema:()=>dYt,Request:()=>rDo,RequestWithExample:()=>QDo,Response:()=>iDo,ResponseWithExample:()=>JDo,Schema:()=>EO,SchemaId:()=>jY,SchemaWithExample:()=>vM,Schemas:()=>SDo,SdkGroup:()=>USo,SdkGroupInfo:()=>KSo,SdkGroupName:()=>ali,SecurityScheme:()=>WSo,SecuritySchemeId:()=>xSo,Server:()=>Dla,Source:()=>ASo,StatusCode:()=>sYt,StreamingResponseExample:()=>sDo,StringSchema:()=>ADo,StringSchemaWithExample:()=>rEo,SupportedSdkLanguage:()=>fDo,Tag:()=>BSo,TagId:()=>wY,Tags:()=>YSo,TextResponse:()=>uli,Uint64WithExample:()=>kDo,UintWithExample:()=>ZDo,UnDiscriminatedOneOfSchema:()=>WDo,UnDiscriminatedOneOfSchemaWithExample:()=>bEo,UnknownSchemaWithExample:()=>cEo,Webhook:()=>gDo,WebhookExampleCall:()=>bPn,WebhookHttpMethod:()=>vPn,WebhookWithExample:()=>DTp,WebsocketChannel:()=>wDo,WebsocketHandshake:()=>ODo,WebsocketHandshakeWithExample:()=>wTp,WebsocketMessageExample:()=>PDo,WebsocketServer:()=>mDo,WebsocketSessionExample:()=>jDo,WithAvailability:()=>uh,WithDescription:()=>Of,WithEncoding:()=>Xre,WithInline:()=>XD,WithName:()=>Xb,WithNamespace:()=>lYt,WithSdkGroupName:()=>DO,WithSource:()=>ny,WithStatusCode:()=>cYt,WithTitle:()=>SO,commons:()=>G7s,example:()=>Q7s,finalIr:()=>J7s,parseIr:()=>K7s});var G7s={};Io(G7s,{BasicSecurityScheme:()=>ISo,BearerSecurityScheme:()=>zSo,Encoding:()=>TSo,HeaderSecurityScheme:()=>RSo,Namespace:()=>LSo,NamespaceId:()=>HSo,OauthSecurityScheme:()=>VSo,OpenApiSource:()=>ESo,ProtobufEncoding:()=>qSo,ProtobufSource:()=>MSo,QuerySecurityScheme:()=>NSo,SchemaId:()=>jY,SdkGroup:()=>USo,SdkGroupName:()=>ali,SecurityScheme:()=>WSo,SecuritySchemeId:()=>xSo,Server:()=>Dla,Source:()=>ASo,StatusCode:()=>sYt,Tag:()=>BSo,TagId:()=>wY,WithAvailability:()=>uh,WithDescription:()=>Of,WithEncoding:()=>Xre,WithInline:()=>XD,WithName:()=>Xb,WithNamespace:()=>lYt,WithSdkGroupName:()=>DO,WithSource:()=>ny,WithStatusCode:()=>cYt,WithTitle:()=>SO});var At={};Io(At,{JsonError:()=>kmn,ParseError:()=>ePn,any:()=>lTp,bigint:()=>Xqp,boolean:()=>fTp,booleanLiteral:()=>cTp,date:()=>Zqp,discriminant:()=>OTp,enum_:()=>wSo,getObjectLikeUtils:()=>L8t,getObjectUtils:()=>Xxi,getSchemaUtils:()=>CA,isProperty:()=>ili,lazy:()=>kqp,lazyObject:()=>oTp,list:()=>DSo,number:()=>dTp,object:()=>SSo,objectWithoutOptionalProperties:()=>aTp,optional:()=>V7s,property:()=>tTp,record:()=>yTp,set:()=>vTp,string:()=>pTp,stringLiteral:()=>sTp,transform:()=>W7s,undiscriminatedUnion:()=>gTp,union:()=>PTp,unknown:()=>_Tp,withParsedProperties:()=>$7s});var FP={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 yM(e,t){return`Expected ${t}. Received ${ZnD(e)}.`}function ZnD(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 e5(e){return{...e,json:Yqp(e.json),parse:Yqp(e.parse)}}function Yqp(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(`
@@ -1979,7 +1979,7 @@ ${U.stack}`)),O}};O=await A();let q=g.apiWorkspaces.flatMap($=>$.getAbsoluteFile
1979
1979
  `);u.push({severity:"fatal",message:g})}},undiscriminatedUnion:()=>[],discriminatedUnion:l=>{let d=ef_(Object.entries(l.union),([s,o])=>p1n({unionKey:s,rawSingleUnionType:o}).name);for(let s of d)u.push({severity:"fatal",message:`Name ${s} is used by multiple subtypes of this union.`});for(let[s,o]of Object.entries(l.union)){let c=typeof o=="string"?o:typeof o.type=="string"?o.type:void 0;if(!(typeof o=="object"&&o.key!=null)&&c!=null){let b=t.resolveType({type:c,file:Hb({relativeFilepath:n,definitionFile:a,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents})});if(b==null)continue;if(b._type==="named"&&G1(b.declaration)){let g=Gfi(l).name,O=aie(e,b.filepath);if(O==null)continue;let w=_5t({typeName:b.rawName,objectDeclaration:b.declaration,filepathOfDeclaration:b.filepath,definitionFile:O,workspace:e,typeResolver:t,smartCasing:!1}).filter(E=>E.name===g);if(w.length>0){let E=[`Discriminant "${g}" conflicts with extended ${w.length===1?"property":"properties"}:`,...w.map(A=>` - ${d1n({property:A,prefixBreadcrumbs:[s,c]})}`)].join(`
1980
1980
  `);u.push({severity:"fatal",message:E})}}}}}}),u}}}}};function ef_(e,t){let r={};for(let i of e){let n=r[t(i)]??0;r[t(i)]=n+1}return Object.entries(r).reduce((i,[n,a])=>(a>1&&i.push(n),i),[])}var BXs={name:"no-error-status-code-conflict",create:({workspace:e})=>{if(e.definition.rootApiFile.contents["error-discrimination"]?.strategy!=="status-code")return{};let t=qXD(e);return{definitionFile:{httpEndpoint:({endpoint:r})=>{if(r.errors==null)return[];let i={};for(let a of r.errors){let u=typeof a=="string"?a:a.error,l=t[u];if(l==null)continue;let d=l["status-code"];d in i?i[d]?.push(u):i[d]=[u]}let n=[];for(let[a,u]of Object.entries(i))u.length>1&&n.push({severity:"fatal",message:`Multiple errors have status-code ${a}: ${u.join(", ")}`});return n}}}}};function qXD(e){let t={};return XN(e,(r,i)=>{dV(i,{typeName:F2t,errorDeclaration:({errorName:n,declaration:a})=>{t[n]=a},httpService:F2t})}),t}var xXs={name:"no-extensions-with-file-upload",create:()=>({definitionFile:{httpEndpoint:({endpoint:e})=>e.request==null?[]:cTi(e.request)?.extends==null?[]:[{severity:"fatal",message:"Request body extensions are not supported for file-upload requests."}]}})};var IXs={name:"no-get-request-body",create:()=>({definitionFile:{httpEndpoint:({endpoint:e})=>e.method==="GET"&&kys(e)!=null?[{severity:"fatal",message:"Endpoint is a GET, so it cannot have a request body."}]:[]}})};var zXs={name:"no-missing-auth",create:e=>{let t=e.workspace.definition.rootApiFile.contents.auth!=null;return{definitionFile:{httpService:r=>r.auth&&!t?[{severity:"fatal",message:"Service requires auth, but no auth is defined."}]:[],httpEndpoint:({endpoint:r})=>r.auth!=null&&r.auth&&!t?[{severity:"fatal",message:"Endpoint requires auth, but no auth is defined."}]:[]}}}};var RXs={name:"no-missing-error-discriminant",create:({workspace:e})=>TXD(e)?{rootApiFile:{errorDiscrimination:t=>t!=null?[]:[{severity:"fatal",message:"error-discrimination is required because this API has declared errors."}]}}:{}};function TXD(e){for(let t of Object.values(Uli(e.definition)))if(t.contents.errors!=null&&!Ius(t.contents.errors))return!0;return!1}var NXs={name:"no-missing-request-name",create:()=>({definitionFile:{httpEndpoint:({endpoint:e,service:t})=>{if(typeof e.request!="string"&&e.request?.name!=null)return[];if(e.request!=null&&typeof e.request!="string"){if(e.request.body!=null&&zT(e.request.body))return[{severity:"fatal",message:"Request name is required because request body is defined inline"}];if(e.request["query-parameters"]!=null&&CK(e.request["query-parameters"])>0)return[{severity:"fatal",message:"Request name is required because request has query parameters"}];if(CK(e.request.headers)>0)return[{severity:"fatal",message:"Request name is required because request has headers"}]}return CK(t.headers)>0?[{severity:"fatal",message:"Request name is required because service has headers"}]:[]}}})};var FXs={name:"no-object-single-property-key",create:({workspace:e})=>{let t=new t1(e);return{definitionFile:{typeDeclaration:({declaration:r},{relativeFilepath:i,contents:n})=>{let a=[];if(!Loi(r))return a;let u=({discriminantValue:l,singleUnionType:d})=>{let s=typeof d!="string"&&d.key!=null,o=typeof d=="string"?d:d.type;return typeof o!="string"||s?typeof o!="string"&&s?[{severity:"fatal",message:`Union variant ${l} has no type, so "key" cannot be defined`}]:[]:t.resolveType({type:o,file:Hb({relativeFilepath:i,definitionFile:n,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents})})==null?[]:[]};for(let[l,d]of Object.entries(r.union))a.push(...u({discriminantValue:l,singleUnionType:d}));return a}}}}};var LXs={name:"no-response-property",create:({workspace:e})=>{let t=new t1(e);return{definitionFile:{httpEndpoint:({endpoint:r},{relativeFilepath:i,contents:n})=>{let{response:a}=r;if(a==null)return[];let u=typeof a=="string"?a:a.type;if(u==null)return[];if(DBe(u)!=null)return[];if(dra(u)!=null)return[];let l=typeof a!="string"?a.property:void 0;if(l==null)return[];let d=Hb({relativeFilepath:i,definitionFile:n,rootApiFile:e.definition.rootApiFile.contents,casingsGenerator:X1}),s=typeof a!="string"?a.type:a;if(s==null)return[];let o=t.resolveTypeOrThrow({type:s,file:d}),c=tf_(o,l,d,t);return CXD(c,l)}}}}},hXt;(function(e){e[e.ContainsProperty=0]="ContainsProperty",e[e.DoesNotContainProperty=1]="DoesNotContainProperty",e[e.IsNotObject=2]="IsNotObject"})(hXt||(hXt={}));function CXD(e,t){switch(e){case hXt.ContainsProperty:return[];case hXt.DoesNotContainProperty:return[{severity:"fatal",message:`Response does not have a property named ${t}.`}];case hXt.IsNotObject:return[{severity:"fatal",message:"Response must be an object in order to return a property as a response."}]}}function tf_(e,t,r,i){switch(e._type){case"container":return e.container._type!=="optional"&&e.container._type!=="nullable"?hXt.IsNotObject:tf_(e.container.itemType,t,r,i);case"named":return if_(e.declaration)?BXD(e.declaration,t,r,i)?hXt.ContainsProperty:hXt.DoesNotContainProperty:hXt.IsNotObject;case"primitive":case"unknown":return hXt.IsNotObject;default:Ko(e)}}function BXD(e,t,r,i){return rf_(e,r,i).has(t)}function rf_(e,t,r){let i=[];typeof e.extends=="string"?i=[e.extends]:Array.isArray(e.extends)&&(i=e.extends);let n=new Set;for(let a of i)for(let u of xXD(a,t,r))n.add(u);for(let a of Object.keys(e.properties??{}))n.add(a);return n}function xXD(e,t,r){let i=r.resolveNamedTypeOrThrow({referenceToNamedType:e,file:t});return i._type==="named"&&if_(i.declaration)?rf_(i.declaration,t,r):new Set}function if_(e){return e.extends!=null||e.properties!=null}var UXs={name:"no-undefined-error-reference",create:({workspace:e})=>{let t=IXD(e);function r(n,a){let u=t[a];return u==null?!1:u.has(n)}let i=(n,a,u)=>{let l=mSe({reference:n,referencedIn:a,imports:od(u.imports??{},Xa.of)});return l!=null&&r(l.typeName,l.relativeFilepath)?[]:[{severity:"fatal",message:"Error is not defined."}]};return{rootApiFile:{errorReference:(n,{relativeFilepath:a,contents:u})=>i(n,a,u)},definitionFile:{errorReference:(n,{relativeFilepath:a,contents:u})=>i(n,a,u)}}}};function IXD(e){let t={};return XN(e,(r,i)=>{let n=new Set;t[r]=n,dV(i,{errorDeclaration:({errorName:a})=>{n.add(a)}})}),t}var VXs={name:"no-undefined-example-reference",create:({workspace:e})=>{let t=new jSe(new t1(e));return{definitionFile:{exampleTypeReference:(r,{relativeFilepath:i,contents:n})=>t.parseExampleReference(r)==null?[{severity:"fatal",message:`Example ${Qs.bold(r)} is malformed. Examples should be formatted like ${Qs.bold("$YourType.ExampleName")}`}]:t.resolveExample({example:r,file:Hb({relativeFilepath:i,definitionFile:n,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents})})!=null?[]:[{severity:"fatal",message:`Example ${Qs.bold(r)} is not defined.`}]}}}};var HXs={name:"no-undefined-path-parameters",create:()=>({rootApiFile:{file:e=>e["base-path"]==null?[]:WXs({path:e["base-path"],pathParameters:e["path-parameters"]??{},pathType:"file"})},definitionFile:{httpService:e=>WXs({path:e["base-path"],pathParameters:e["path-parameters"]??{},pathType:"service"}),httpEndpoint:({endpoint:e})=>WXs({path:e["base-path"]!=null?Cv(e["base-path"],e.path):e.path,pathParameters:p5t(e),pathType:"endpoint"})}})};function WXs({path:e,pathParameters:t,pathType:r}){let i=[],n=new Set;iV(e).parts.forEach(s=>{n.has(s.pathParameter)&&i.push({severity:"fatal",message:`${ykn(r)} has duplicate path parameter: ${Qs.bold(s.pathParameter)}.`}),n.add(s.pathParameter)});let u=new Set(Object.keys(t));return nf_(n,u).forEach(s=>{i.push({severity:"fatal",message:`${ykn(r)} has missing path-parameter: ${Qs.bold(s)}.`})}),nf_(u,n).forEach(s=>{i.push({severity:"fatal",message:`Path parameter is unreferenced in ${r}: ${Qs.bold(s)}.`})}),i}function nf_(e,t){return new Set([...e].filter(r=>!t.has(r)))}var $Xs={name:"no-undefined-type-reference",create:({workspace:e})=>{let t=zXD(e);function r(n){if(n.parsed==null)return!1;let a=t[n.parsed.relativeFilepath];if(a==null)return!1;let u=RI(n.parsed.typeName);return u!=null?u.name?a.has(u.name):!1:a.has(n.parsed.typeName)}function i(n,a){if(a!=null){let u=[...a];for(;u.length>0;){let l=u.pop(),d=l?typeof l=="string"?RI(l):RI(l.key):void 0;if(d!=null)return n.parsed?.typeName&&d.arguments?.includes(n.parsed?.typeName)}}return!1}return{definitionFile:{typeReference:({typeReference:n,location:a,nodePath:u},{relativeFilepath:l,contents:d})=>{let s=DBe(n);if(s!=null){if(a===fV.InlinedRequestProperty)return[];if(a===fV.Response)return s.isOptional?[{severity:"fatal",message:"File response cannot be optional"}]:[]}return KGt(n)!=null?a===fV.RequestReference?[]:[{severity:"fatal",message:"The bytes type can only be used as a request"}]:C_n(n)?a===fV.StreamingResponse?[]:a===fV.Response?[]:[{severity:"fatal",message:"The text type can only be used as a response or response-stream."}]:RXD({type:n,relativeFilepath:l,imports:od(d.imports??{},Xa.of)}).reduce((b,g)=>(g.parsed?.typeName!=null&&DBe(g.parsed.typeName)!=null?b.push({severity:"fatal",message:"The file type can only be used as properties in inlined requests."}):g.parsed?.typeName!=null&&C_n(g.parsed.typeName)?b.push({severity:"fatal",message:"The text type can only be used as a response-stream or response."}):!r(g)&&!i(g,u)&&b.push({severity:"fatal",message:`Type ${Qs.bold(g.parsed?.typeName??g.fullyQualifiedName)} is not defined.`}),b),[])}}}}};function zXD(e){let t={};return XN(e,(r,i)=>{let n=new Set;t[r]=n,dV(i,{typeDeclaration:({typeName:a})=>{if(!a.isInlined){let u=RI(a.name);u!=null&&u.name&&n.add(u.name),n.add(a.name)}}})}),t}function RXD({type:e,relativeFilepath:t,imports:r}){return yU({type:e,_default:void 0,validation:void 0,visitor:{primitive:()=>[],unknown:()=>[],map:({keyType:i,valueType:n})=>[...i,...n],list:i=>i,set:i=>i,optional:i=>i,nullable:i=>i,literal:()=>[],named:i=>{let n=mSe({reference:i,referencedIn:t,imports:r});return[{fullyQualifiedName:i,parsed:n!=null?{typeName:n.typeName,relativeFilepath:n.relativeFilepath}:void 0}]}}})}var GXs={name:"no-undefined-variable-reference",create:({workspace:e})=>{let t=new h5t,r=(i,n)=>i.startsWith(h5t.VARIABLE_PREFIX)?t.getDeclaration(i,n)?[]:[{severity:"fatal",message:`Variable ${i} is not defined.`}]:[{severity:"fatal",message:`Variable reference must start with ${h5t.VARIABLE_PREFIX}`}];return{rootApiFile:{variableReference:i=>r(i,NQr({casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents}))},definitionFile:{variableReference:(i,{relativeFilepath:n,contents:a})=>r(i,Hb({casingsGenerator:X1,relativeFilepath:n,definitionFile:a,rootApiFile:e.definition.rootApiFile.contents}))}}}};var QXs={name:"no-unused-generic",create:({workspace:e})=>{let t=new Set;return XN(e,(r,i)=>{dV(i,{typeDeclaration:n=>{xN(n.declaration,{alias:a=>{let u=RI(typeof a=="string"?a:a.type);if(u!=null&&u.name){let[l,d,...s]=u.name.split("."),o=d??l;o&&t.add(o)}},enum:()=>{},object:()=>{},discriminatedUnion:()=>{},undiscriminatedUnion:()=>{}})}})}),{definitionFile:{typeName:r=>{let i=RI(r);return i==null?[]:i.name&&t.has(i.name)?[]:[{severity:"fatal",message:`Generic "${r}" is declared but never used.`}]}}}}};var JXs={name:"only-object-extensions",create:({workspace:e})=>{let t=new t1(e);return{definitionFile:{extension:(r,{relativeFilepath:i,contents:n})=>{let a=t.resolveNamedType({referenceToNamedType:r,file:Hb({relativeFilepath:i,definitionFile:n,rootApiFile:e.definition.rootApiFile.contents,casingsGenerator:X1})});return a==null?[]:a._type==="named"&&G1(a.declaration)?[]:[{severity:"fatal",message:`Objects can only extend other objects, and ${r} is not an object.`}]}}}}};var KXs={name:"valid-base-path",create:()=>({rootApiFile:{file:e=>e["base-path"]!=null?af_(e["base-path"]):[]},definitionFile:{httpService:e=>af_(e["base-path"])}})};function af_(e){if(e==="/"||e.length===0)return[];let t=[];return e.startsWith("/")||t.push({severity:"fatal",message:"base-path must be empty or start with a slash."}),t}var YXs={name:"valid-default-environment",create:({workspace:e})=>{let t=e.definition.rootApiFile.contents.environments;return{rootApiFile:{defaultEnvironment:r=>r!=null&&(t==null||!Object.keys(t).includes(r))?[{severity:"fatal",message:`The default-environment ${r} is not listed as an environment`}]:[]}}}};var XXs={name:"valid-endpoint-path",create:()=>({definitionFile:{httpEndpoint:({endpoint:e})=>{if(e.path==="")return[];let t=[];return e.path.startsWith("/")||t.push({severity:"fatal",message:"Path must start with a slash."}),t}}})};function qNo({allDeclarations:e={},examples:t,parameterDisplayName:r,typeResolver:i,exampleResolver:n,workspace:a,getRawType:u,breadcrumbs:l}){let d=[],s=Object.entries(e).reduce((o,[c,b])=>{let g=u(b);if(g!=null){let O=i.resolveType({type:g.rawType,file:g.file});O!=null&&O._type==="container"&&(O.container._type==="optional"||O.container._type==="nullable")||O?._type==="unknown"||o.push(c)}return o},[]);for(let o of s)t?.[o]==null&&d.push({severity:"fatal",message:`Example is missing required ${r} "${o}"`});if(t!=null)for(let[o,c]of Object.entries(t)){let b=e[o];if(b==null)d.push({severity:"fatal",message:`Unexpected ${r} "${o}"`});else{let g=u(b);g!=null&&d.push(...sG.validateTypeReferenceExample({rawTypeReference:g.rawType,example:c,file:g.file,workspace:a,typeResolver:i,exampleResolver:n,breadcrumbs:l,depth:0}).map(O=>({severity:"fatal",message:O.message})))}}return d}function of_({example:e,endpoint:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let u=[],l=typeof t.request!="string"?t.request?.body:t.request;return l==null?e!=null&&u.push({severity:"fatal",message:"Unexpected request in example."}):zT(l)?u.push(...sG.validateObjectExample({typeName:void 0,typeNameForBreadcrumb:"<Inlined Request>",rawObject:{"extra-properties":l["extra-properties"],extends:l.extends,properties:l.properties??{}},file:n,typeResolver:r,exampleResolver:i,workspace:a,example:e,breadcrumbs:["request"],depth:0}).map(d=>({severity:"fatal",message:d.message}))):u.push(...sG.validateTypeReferenceExample({rawTypeReference:typeof l=="string"?l:l.type,example:e,file:n,workspace:a,typeResolver:r,exampleResolver:i,breadcrumbs:["response","body"],depth:0}).map(d=>({severity:"fatal",message:d.message}))),u}function sf_({example:e,endpoint:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,errorResolver:u}){return e==null?uf_({example:{},endpoint:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,errorResolver:u}):lTi(t,e,{body:l=>uf_({example:l,endpoint:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,errorResolver:u}),stream:l=>NXD({example:l,endpoint:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}),events:l=>FXD({example:l,endpoint:t,typeResolver:r,exampleResolver:i,file:n,workspace:a})})}function uf_({example:e,endpoint:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,errorResolver:u}){let l=[];if(e.error==null)if(t.response!=null){let d=typeof t.response!="string"?t.response.type:t.response;if(d==null)return l;l.push(...sG.validateTypeReferenceExample({rawTypeReference:d,example:e.body,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:["response","body"],depth:0}).map(s=>({severity:"fatal",message:s.message})))}else e.body!=null&&l.push({severity:"fatal",message:`Unexpected response in example. If you're adding an example of an error response, set the "error" property to the error's name`});else{let d=u.getDeclaration(e.error,n);d!=null&&(t.errors!=null&&t.errors.some(o=>(typeof o!="string"?o.error:o)===e.error)||l.push({severity:"fatal",message:`${Qs.bold(e.error)} is not specified as an allowed error for this endpoint. Add ${Qs.bold(e.error)} to the endpoint's "errors" list.`}),d.declaration.type!=null?l.push(...sG.validateTypeReferenceExample({rawTypeReference:d.declaration.type,example:e.body,typeResolver:r,exampleResolver:i,file:d.file,workspace:a,breadcrumbs:["response","body"],depth:0}).map(o=>({severity:"fatal",message:o.message}))):e.body!=null&&l.push({severity:"fatal",message:`Unexpected response in example. ${Qs.bold(e.error)} does not have a body.`}))}return l}function NXD({example:e,endpoint:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let u=[];if(t["response-stream"]==null)u.push({severity:"fatal",message:"Unexpected streaming response in example. Endpoint's schema is missing `response-stream` key."});else if(typeof t["response-stream"]=="string"||t["response-stream"].format==null||t["response-stream"].format==="json")for(let l of e.stream)u.push(...sG.validateTypeReferenceExample({rawTypeReference:typeof t["response-stream"]!="string"?t["response-stream"].type:t["response-stream"],example:l,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:["response","body"],depth:0}).map(d=>({severity:"fatal",message:d.message})));else u.push({severity:"fatal",message:"Endpoint response expects server-sent events (`response-stream.format: sse`), but the provided example is a regular stream. Use the `events` key to provide an list of server-sent event examples."});return u}function FXD({example:e,endpoint:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let u=[];if(t["response-stream"]==null)u.push({severity:"fatal",message:"Unexpected streaming response in example. Endpoint's schema is missing `response-stream` key."});else if(typeof t["response-stream"]!="string"&&t["response-stream"].format==="sse")for(let l of e.stream)u.push(...sG.validateTypeReferenceExample({rawTypeReference:typeof t["response-stream"]!="string"?t["response-stream"].type:t["response-stream"],example:l.data,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:["response","body"],depth:0}).map(d=>({severity:"fatal",message:d.message})));else u.push({severity:"fatal",message:"Endpoint response expects a regular stream, but the provided example is a server-sent event. Use the `stream` key to provide a list of stream examples."});return u}var ZXs={name:"valid-example-endpoint-call",create:({workspace:e})=>{let t=new t1(e),r=new Kzi(e),i=new jSe(t),n=new h5t;return{definitionFile:{exampleHeaders:({service:a,endpoint:u,examples:l},{relativeFilepath:d,contents:s})=>qNo({allDeclarations:{...a.headers,...typeof u.request!="string"?u.request?.headers:void 0},examples:l,parameterDisplayName:"header",typeResolver:t,exampleResolver:i,workspace:e,getRawType:o=>({file:Hb({relativeFilepath:d,definitionFile:s,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents}),rawType:typeof o=="string"?o:o.type}),breadcrumbs:["headers"]}),examplePathParameters:({service:a,endpoint:u,examples:l},{relativeFilepath:d,contents:s})=>qNo({allDeclarations:LXD({workspace:e,service:a,endpoint:u}),examples:l,parameterDisplayName:"path parameter",typeResolver:t,exampleResolver:i,workspace:e,getRawType:o=>vzo({parameter:o,variableResolver:n,file:Hb({relativeFilepath:d,definitionFile:s,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents})}),breadcrumbs:["path-parameters"]}),exampleQueryParameters:({endpoint:a,examples:u},{relativeFilepath:l,contents:d})=>qNo({allDeclarations:typeof a.request!="string"?a.request?.["query-parameters"]:void 0,examples:u,parameterDisplayName:"query parameter",typeResolver:t,exampleResolver:i,workspace:e,getRawType:s=>({file:Hb({relativeFilepath:l,definitionFile:d,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents}),rawType:typeof s=="string"?s:s.type}),breadcrumbs:["query-parameters"]}),exampleRequest:({endpoint:a,example:u},{relativeFilepath:l,contents:d})=>of_({example:u,endpoint:a,typeResolver:t,exampleResolver:i,file:Hb({relativeFilepath:l,definitionFile:d,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents}),workspace:e}),exampleResponse:({endpoint:a,example:u},{relativeFilepath:l,contents:d})=>sf_({example:u,endpoint:a,typeResolver:t,exampleResolver:i,file:Hb({relativeFilepath:l,definitionFile:d,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents}),workspace:e,errorResolver:r})}}}};function LXD({workspace:e,service:t,endpoint:r}){let i=p5t(r);return r["base-path"]!=null?{...i}:{...e.definition.rootApiFile.contents["path-parameters"],...t["path-parameters"],...i}}var kXs={name:"valid-example-error",create:({workspace:e})=>{let t=new t1(e),r=new jSe(t);return{definitionFile:{exampleError:({errorName:i,declaration:n,example:a},{relativeFilepath:u,contents:l})=>n.type==null?[]:sG.validateTypeReferenceExample({rawTypeReference:n.type,example:a.value,file:Hb({relativeFilepath:u,definitionFile:l,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents}),workspace:e,typeResolver:t,exampleResolver:r,breadcrumbs:["response","body"],depth:0}).map(s=>({severity:"fatal",message:s.message}))}}}};var eZs={name:"valid-example-type",create:({workspace:e})=>{let t=new t1(e),r=new jSe(t);return{definitionFile:{exampleType:({typeName:i,typeDeclaration:n,example:a},{relativeFilepath:u,contents:l})=>sG.validateTypeExample({typeName:i,typeDeclaration:n,example:a.value,file:Hb({relativeFilepath:u,definitionFile:l,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents}),typeResolver:t,exampleResolver:r,workspace:e,breadcrumbs:[],depth:0}).map(s=>({severity:"fatal",message:s.message}))}}}};function cf_(e){let t=[];return e.enum.forEach(r=>{let i=y1n(r);DNo.test(i.name)||(i.wasExplicitlySet?t.push({severity:"fatal",message:`Enum name ${Qs.bold(i.name)} is not suitable for code generation. It must start with a letter and only contain letters, numbers, and underscores.`}):t.push({severity:"fatal",message:`Enum value ${Qs.bold(i.name)} is not suitable for code generation. Add a "name" property that starts with a letter and contains only letters, numbers, and underscores.`}))}),t}function lf_(e){let t=[],r=Gfi(e);return DNo.test(r.name)||(r.wasExplicitlySet?t.push({severity:"fatal",message:`Discriminant name ${Qs.bold(r.name)} is not suitable for code generation. It must start with a letter and only contain letters, numbers, and underscores.`}):t.push({severity:"fatal",message:`Discriminant value ${Qs.bold(r.name)} is not suitable for code generation. Add a "name" property that starts with a letter and contains only letters, numbers, and underscores.`})),t}var tZs={name:"valid-field-names",create:()=>({definitionFile:{typeDeclaration:({declaration:e})=>xN(e,{alias:()=>[],enum:cf_,object:()=>[],undiscriminatedUnion:()=>[],discriminatedUnion:lf_})}})};var rZs={name:"valid-generic",create:({workspace:e})=>{let t=UXD(e),r={object:[],discriminatedUnion:[]};return{definitionFile:{typeDeclaration:({typeName:i,declaration:n,nodePath:a})=>{let u=[];return i.isInlined||RI(i.name)!=null&&(xN(n,{alias:()=>!1,enum:()=>!1,object:()=>!0,discriminatedUnion:()=>!1,undiscriminatedUnion:()=>!1})||u.push({severity:"fatal",message:"Generics are only supported for object declarations"})),xN(n,{alias:l=>{let d=typeof l=="string"?l:l.type,s=RI(d);if(s!=null){let[o,c,...b]=s.name.split("."),g=c??o;g&&g in t&&t[g]!==s.arguments.length&&u.push({severity:"fatal",message:`Generic ${g} expects ${t[g]} arguments, but received ${s.arguments.length} <${s.arguments.join(",")}>`})}else d in t&&u.push({severity:"fatal",message:`Generic ${d} expects ${t[d]} arguments, but received none`})},enum:l=>{typeof l!="string"&&l.enum.forEach(d=>{let s=typeof d=="string"?d:d.value;gBe(s)&&u.push({severity:"fatal",message:`Cannot reference generic ${s} from enum`})})},object:l=>{Object.entries(l?.properties??{}).forEach(([d,s])=>{gBe(typeof s=="string"?s:s.type)&&(a?(r.object??=[]).push({key:d,nodePath:a}):u.push({severity:"fatal",message:`Cannot reference generic ${s} from object property ${d}`}))})},discriminatedUnion:l=>{Object.entries(l.union).forEach(([d,s])=>{let o=typeof s=="string"?s:typeof s.type=="string"?s.type:void 0;o&&gBe(o)&&(a?(r.discriminatedUnion??=[]).push({key:d,nodePath:a}):u.push({severity:"fatal",message:`Cannot reference generic ${s} from union property ${d}`}))})},undiscriminatedUnion:l=>{l.union.forEach(d=>{let s=typeof d=="string"?d:d.type;gBe(s)&&u.push({severity:"fatal",message:`Cannot reference generic ${s} from union`})})}}),u},typeReference:({typeReference:i,nodePath:n})=>{let a=[];if(n)for(let u of Object.keys(r))for(let{key:l,nodePath:d}of r[u])d.length>0&&n.join(",").startsWith(d.join(","))&&n.includes(l)&&a.push({severity:"fatal",message:`Cannot reference generic ${i} from ${u.toLowerCase().includes("union")?"union":u}`});return a}}}}};function UXD(e){let t={};return XN(e,(r,i)=>{dV(i,{typeDeclaration:({typeName:n,declaration:a})=>{if(!n.isInlined){let u=RI(n.name);u!=null&&xN(a,{alias:()=>{},enum:()=>{},object:()=>{u.name&&u.arguments&&(t[u.name]=u.arguments.length)},discriminatedUnion:()=>{},undiscriminatedUnion:()=>{}})}}})}),t}var ff_=vi(require("path"),1);var iZs={name:"valid-navigation",create:({workspace:e})=>{let t=N2t(sQr(e.definition)),i=N2t(Uli(e.definition)).reduce((n,a)=>((n[fp(a)]??=new Set).add(ff_.default.basename(a)),n),{});return{packageMarker:{navigation:(n,{relativeFilepath:a})=>{if(n==null)return[];if(typeof n=="string"){let s=Qq(e.definition.absoluteFilePath,Xu(e.definition.absoluteFilePath,fp(a),Xa.of(n)));return t.some(o=>o.startsWith(s))?[]:[{severity:"fatal",message:`${n} does not exist.`}]}let u=i[fp(a)];if(u==null)throw new Error(`Could not find expected contents of ${a}`);let l=[],d=new Set;for(let s of n)s===W1?l.push({severity:"fatal",message:`${W1} cannot be specified in navigation.`}):u.has(s)?d.has(s)&&l.push({severity:"fatal",message:`${s} is specified more than once.`}):l.push({severity:"fatal",message:`Unexpected item: ${s}`}),d.add(s);for(let s of u)d.has(s)||l.push({severity:"fatal",message:`Missing ${s}`});return l}}}}};var Pha="$request.",nZs="$response.";function Q1n({typeResolver:e,file:t,endpoint:r,propertyComponents:i,validate:n}){if(r.request==null)return!1;if(typeof r.request=="string"){let a=e.resolveType({type:r.request,file:t});return m5t({typeResolver:e,file:m7(a)??t,resolvedType:a,propertyComponents:i,validate:n})}return VXD({typeResolver:e,file:t,requestType:r.request,propertyComponents:i,validate:n})}function VXD({typeResolver:e,file:t,requestType:r,propertyComponents:i,validate:n}){if(WXD({typeResolver:e,file:t,requestType:r,propertyComponents:i,validate:n}))return!0;if(r.body==null)return!1;if(typeof r.body=="string"){let u=e.resolveType({type:r.body,file:t});return m5t({typeResolver:e,file:m7(u)??t,resolvedType:u,propertyComponents:i,validate:n})}if(zT(r.body))return df_({typeResolver:e,file:t,objectSchema:r.body,propertyComponents:i,validate:n});let a=e.resolveType({type:r.body.type,file:t});return m5t({typeResolver:e,file:m7(a)??t,resolvedType:e.resolveType({type:r.body.type,file:t}),propertyComponents:i,validate:n})}function WXD({typeResolver:e,file:t,requestType:r,propertyComponents:i,validate:n}){if(i.length!==1||typeof r=="string"||r["query-parameters"]==null)return!1;let a=r["query-parameters"][i[0]??""];if(a==null)return!1;let u=e.resolveType({type:typeof a!="string"?a.type:a,file:t});return n({resolvedType:u})}function m5t({typeResolver:e,file:t,resolvedType:r,propertyComponents:i,validate:n}){if(i.length===0)return n({resolvedType:r});let a=_f_(r);return a==null?!1:df_({typeResolver:e,file:t,objectSchema:a,propertyComponents:i,validate:n})}function yXt({endpoint:e,typeResolver:t,file:r}){let i=typeof e.response!="string"?e.response?.type:e.response;if(i!=null)return t.resolveType({type:i,file:r})}function P5t(e){if(e?._type==="primitive")return e.primitive.v1;if(e?._type==="container"&&(e.container._type==="optional"||e.container._type==="nullable"))return P5t(e.container.itemType)}function m7(e){if(e!=null){if(e._type==="named")return e.file;if(e._type==="container"&&(e.container._type==="optional"||e.container._type==="nullable"))return m7(e.container.itemType)}}function J1n(e){return hf_(e,Pha)?.split(".")}function TNo(e){return hf_(e,nZs)?.split(".")}function df_({typeResolver:e,file:t,objectSchema:r,propertyComponents:i,validate:n}){let a=HXD({typeResolver:e,file:t,objectSchema:r,property:i[0]??""});if(a==null)return!1;let u=e.resolveType({type:a,file:t});return m5t({typeResolver:e,file:m7(u)??t,resolvedType:u,propertyComponents:i.slice(1),validate:n})}function HXD({typeResolver:e,file:t,objectSchema:r,property:i}){return pf_({typeResolver:e,file:t,objectSchema:r})[i]}function pf_({typeResolver:e,file:t,objectSchema:r}){let i=[];typeof r.extends=="string"?i=[r.extends]:Array.isArray(r.extends)&&(i=r.extends);let n={};for(let a of i){let u=$XD({typeResolver:e,file:t,extendedType:a});Object.entries(u).map(([l,d])=>{n[l]=d})}return r.properties!=null&&Object.entries(r.properties).map(([a,u])=>{n[a]=typeof u=="string"?u:u.type}),n}function $XD({typeResolver:e,file:t,extendedType:r}){let i=e.resolveNamedTypeOrThrow({referenceToNamedType:r,file:t});return i._type==="named"&&G1(i.declaration)?pf_({typeResolver:e,file:m7(i)??t,objectSchema:i.declaration}):{}}function _f_(e){if(e!=null){if(e._type==="named"&&G1(e.declaration))return e.declaration;if(e._type==="container"&&(e.container._type==="optional"||e.container._type==="nullable"))return _f_(e.container.itemType)}}function hf_(e,t){return e.startsWith(t)?e.substring(t.length):null}var aZs=`${Pha}client_id`,oZs=`${Pha}client_secret`,K1n=`${nZs}access_token`,uZs=`${Pha}refresh_token`;function sZs({endpointId:e,endpoint:t,typeResolver:r,file:i,clientIdProperty:n}){return xNo({endpointId:e,endpoint:t,typeResolver:r,file:i,requestProperty:n,propertyValidator:{propertyID:"client-id",validate:jha}})}function cZs({endpointId:e,endpoint:t,typeResolver:r,file:i,clientSecretProperty:n}){return xNo({endpointId:e,endpoint:t,typeResolver:r,file:i,requestProperty:n,propertyValidator:{propertyID:"client-secret",validate:jha}})}function yf_({endpointId:e,endpoint:t,typeResolver:r,file:i,scopesProperty:n}){return xNo({endpointId:e,endpoint:t,typeResolver:r,file:i,requestProperty:n,propertyValidator:{propertyID:"scopes",validate:jha}})}function lZs({endpointId:e,endpoint:t,typeResolver:r,file:i,refreshTokenProperty:n}){return xNo({endpointId:e,endpoint:t,typeResolver:r,file:i,requestProperty:n,propertyValidator:{propertyID:"refresh-token",validate:jha}})}function Y1n({endpointId:e,typeResolver:t,file:r,resolvedResponseType:i,accessTokenProperty:n}){return fZs({endpointId:e,typeResolver:t,file:r,resolvedResponseType:i,responseProperty:n,propertyValidator:{propertyID:"access-token",validate:vf_}})}function CNo({endpointId:e,typeResolver:t,file:r,resolvedResponseType:i,refreshTokenProperty:n}){return fZs({endpointId:e,typeResolver:t,file:r,resolvedResponseType:i,responseProperty:n,propertyValidator:{propertyID:"refresh-token",validate:vf_}})}function BNo({endpointId:e,typeResolver:t,file:r,resolvedResponseType:i,expiresInProperty:n}){return fZs({endpointId:e,typeResolver:t,file:r,resolvedResponseType:i,responseProperty:n,propertyValidator:{propertyID:"expires-in",validate:GXD}})}function GXD({typeResolver:e,file:t,resolvedType:r,propertyComponents:i}){return m5t({typeResolver:e,file:t,resolvedType:r,propertyComponents:i,validate:QXD})}function vf_({typeResolver:e,file:t,resolvedType:r,propertyComponents:i}){return m5t({typeResolver:e,file:t,resolvedType:r,propertyComponents:i,validate:jha})}function xNo({endpointId:e,endpoint:t,typeResolver:r,file:i,requestProperty:n,propertyValidator:a}){let u=[],l=J1n(n);return l==null?(u.push({severity:"fatal",message:`OAuth configuration for endpoint ${Qs.bold(e)} must define a dot-delimited '${a.propertyID}' property starting with $request (e.g. $request.${a.propertyID}).`}),u):l.length>1?(u.push({severity:"fatal",message:`OAuth configuration for endpoint ${Qs.bold(e)} cannot reference nested $request properties like '${n}'; expected '$request.${a.propertyID}' instead.`}),u):(Q1n({typeResolver:r,file:i,endpoint:t,propertyComponents:l,validate:a.validate})||u.push({severity:"fatal",message:`OAuth configuration for endpoint ${Qs.bold(e)} specifies '${a.propertyID}' ${n}, which is not a valid '${a.propertyID}' type.`}),u)}function fZs({endpointId:e,typeResolver:t,file:r,resolvedResponseType:i,responseProperty:n,propertyValidator:a}){let u=[],l=TNo(n);return l==null&&u.push({severity:"fatal",message:`OAuth configuration for endpoint ${Qs.bold(e)} must define a dot-delimited '${a.propertyID}' property starting with $response (e.g. $response.${a.propertyID}).`}),l!=null&&!a.validate({typeResolver:t,file:r,resolvedType:i,propertyComponents:l})&&u.push({severity:"fatal",message:`OAuth configuration for endpoint ${Qs.bold(e)} specifies '${a.propertyID}' ${n}, which is not a valid '${a.propertyID}' type.`}),u}function QXD({resolvedType:e}){return P5t(e)==="INTEGER"}function jha({resolvedType:e}){return P5t(e)==="STRING"}function bf_({endpointId:e,endpoint:t,typeResolver:r,file:i,refreshEndpoint:n}){let a=[],u=n["request-properties"]?.["refresh-token"];u!=null?a.push(...lZs({endpointId:e,endpoint:t,typeResolver:r,file:i,refreshTokenProperty:u})):lZs({endpointId:e,endpoint:t,typeResolver:r,file:i,refreshTokenProperty:uZs}).length>0&&a.push({severity:"fatal",message:`OAuth configuration for endpoint ${Qs.bold(e)} is missing a valid refresh-token, such as '${uZs}'.`});let l=yXt({endpoint:t,typeResolver:r,file:i});if(l==null)return a.push({severity:"fatal",message:`OAuth configuration for endpoint ${Qs.bold(e)} must define a response type.`}),a;let d=n["response-properties"]?.["access-token"];d!=null?a.push(...Y1n({endpointId:e,typeResolver:r,file:i,resolvedResponseType:l,accessTokenProperty:d})):Y1n({endpointId:e,typeResolver:r,file:i,resolvedResponseType:l,accessTokenProperty:K1n}).length>0&&a.push({severity:"fatal",message:`OAuth configuration for endpoint ${Qs.bold(e)} is missing a valid access-token, such as '${K1n}'.`});let s=n?.["response-properties"]?.["expires-in"];s!=null&&a.push(...BNo({endpointId:e,typeResolver:r,file:m7(l)??i,resolvedResponseType:l,expiresInProperty:s}));let o=n?.["response-properties"]?.["refresh-token"];return o!=null&&a.push(...CNo({endpointId:e,typeResolver:r,file:m7(l)??i,resolvedResponseType:l,refreshTokenProperty:o})),a}function gf_({endpointId:e,endpoint:t,typeResolver:r,file:i,tokenEndpoint:n}){let a=[],u=n["request-properties"]?.["client-id"];u!=null?a.push(...sZs({endpointId:e,endpoint:t,typeResolver:r,file:i,clientIdProperty:u})):sZs({endpointId:e,endpoint:t,typeResolver:r,file:i,clientIdProperty:aZs}).length>0&&a.push({severity:"fatal",message:`OAuth configuration for endpoint ${Qs.bold(e)} is missing a valid client-id, such as '${aZs}'.`});let l=n["request-properties"]?.["client-secret"];l!=null?a.push(...cZs({endpointId:e,endpoint:t,typeResolver:r,file:i,clientSecretProperty:l})):cZs({endpointId:e,endpoint:t,typeResolver:r,file:i,clientSecretProperty:oZs}).length>0&&a.push({severity:"fatal",message:`OAuth configuration for endpoint ${Qs.bold(e)} is missing a valid client-secret, such as '${oZs}'.`});let d=n?.["request-properties"]?.scopes;d!=null&&a.push(...yf_({endpointId:e,endpoint:t,typeResolver:r,file:i,scopesProperty:d}));let s=yXt({endpoint:t,typeResolver:r,file:i});if(s==null)return a.push({severity:"fatal",message:`OAuth configuration for endpoint ${Qs.bold(e)} must define a response type.`}),a;let o=n["response-properties"]?.["access-token"];o!=null?a.push(...Y1n({endpointId:e,typeResolver:r,file:i,resolvedResponseType:s,accessTokenProperty:o})):Y1n({endpointId:e,typeResolver:r,file:i,resolvedResponseType:s,accessTokenProperty:K1n}).length>0&&a.push({severity:"fatal",message:`OAuth configuration for endpoint ${Qs.bold(e)} is missing a valid access-token, such as '${K1n}'.`});let c=n?.["response-properties"]?.["expires-in"];c!=null&&a.push(...BNo({endpointId:e,typeResolver:r,file:m7(s)??i,resolvedResponseType:s,expiresInProperty:c}));let b=n?.["response-properties"]?.["refresh-token"];return b!=null&&a.push(...CNo({endpointId:e,typeResolver:r,file:m7(s)??i,resolvedResponseType:s,refreshTokenProperty:b})),a}var dZs={name:"valid-oauth",create:({workspace:e})=>{let t=new t1(e),r=new Jzi(e),i=NQr({casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents});return{rootApiFile:{oauth:({name:n,oauth:a},{relativeFilepath:u})=>{let l=[],d=a["get-token"].endpoint,s=r.resolveEndpoint({endpoint:d,file:i});s==null?l.push({severity:"fatal",message:`Failed to resolve endpoint ${d}`}):l.push(...gf_({endpointId:s.endpointId,endpoint:s.endpoint,typeResolver:t,file:s.file,tokenEndpoint:a["get-token"]}));let o=a["refresh-token"]?.endpoint;if(a["refresh-token"]!=null&&o!=null){let c=r.resolveEndpoint({endpoint:o,file:i});c==null?l.push({severity:"fatal",message:`Failed to resolve endpoint ${d}`}):l.push(...bf_({endpointId:c.endpointId,endpoint:c.endpoint,typeResolver:t,file:c.file,refreshEndpoint:a["refresh-token"]}))}return l}}}}};function X1n({endpointId:e,typeResolver:t,file:r,resolvedResponseType:i,resultsProperty:n}){return pZs({endpointId:e,typeResolver:t,file:r,resolvedResponseType:i,responseProperty:n,propertyValidator:{propertyID:"results",validate:JXD}})}function wha({endpointId:e,endpoint:t,typeResolver:r,file:i,requestProperty:n,propertyValidator:a}){let u=[],l=J1n(n);return l==null?(u.push({severity:"fatal",message:`Pagination configuration for endpoint ${Qs.bold(e)} must define a dot-delimited '${a.propertyID}' property starting with $request (e.g. $request.${a.propertyID}).`}),u):(Q1n({typeResolver:r,file:i,endpoint:t,propertyComponents:l,validate:a.validate})||u.push({severity:"fatal",message:`Pagination configuration for endpoint ${Qs.bold(e)} specifies '${a.propertyID}' ${n}, which is not a valid '${a.propertyID}' type.`}),u)}function pZs({endpointId:e,typeResolver:t,file:r,resolvedResponseType:i,responseProperty:n,propertyValidator:a}){let u=[],l=TNo(n);return l==null&&u.push({severity:"fatal",message:`Pagination configuration for endpoint ${Qs.bold(e)} must define a dot-delimited '${a.propertyID}' property starting with $response (e.g. $response.${a.propertyID}).`}),l!=null&&!a.validate({typeResolver:t,file:r,resolvedType:i,propertyComponents:l})&&u.push({severity:"fatal",message:`Pagination configuration for endpoint ${Qs.bold(e)} specifies '${a.propertyID}' ${n}, which is not a valid '${a.propertyID}' type.`}),u}function JXD({typeResolver:e,file:t,resolvedType:r,propertyComponents:i}){return m5t({typeResolver:e,file:t,resolvedType:r,propertyComponents:i,validate:KXD})}function KXD({resolvedType:e}){return!0}function Of_({endpointId:e,endpoint:t,typeResolver:r,file:i,cursorPagination:n}){let a=[];a.push(...YXD({endpointId:e,endpoint:t,typeResolver:r,file:i,cursorPagination:n}));let u=yXt({endpoint:t,typeResolver:r,file:i});return u==null?(a.push({severity:"fatal",message:`Pagination configuration for endpoint ${Qs.bold(e)} must define a response type.`}),a):(a.push(...XXD({endpointId:e,typeResolver:r,file:m7(u)??i,resolvedResponseType:u,nextProperty:n.next_cursor})),a.push(...X1n({endpointId:e,typeResolver:r,file:m7(u)??i,resolvedResponseType:u,resultsProperty:n.results})),a)}function YXD({endpointId:e,endpoint:t,typeResolver:r,file:i,cursorPagination:n}){return wha({endpointId:e,endpoint:t,typeResolver:r,file:i,requestProperty:n.cursor,propertyValidator:{propertyID:"cursor",validate:mf_}})}function XXD({endpointId:e,typeResolver:t,file:r,resolvedResponseType:i,nextProperty:n}){return pZs({endpointId:e,typeResolver:t,file:r,resolvedResponseType:i,responseProperty:n,propertyValidator:{propertyID:"next_cursor",validate:ZXD}})}function ZXD({typeResolver:e,file:t,resolvedType:r,propertyComponents:i}){return m5t({typeResolver:e,file:t,resolvedType:r,propertyComponents:i,validate:mf_})}function mf_({resolvedType:e}){let t=P5t(e);return t==null?!1:t!=="BOOLEAN"}function Pf_({endpointId:e,endpoint:t,typeResolver:r,file:i,customPagination:n}){let a=[],u=yXt({endpoint:t,typeResolver:r,file:i});return u==null?(a.push({severity:"fatal",message:`Pagination configuration for endpoint ${Qs.bold(e)} must define a response type.`}),a):(a.push(...X1n({endpointId:e,typeResolver:r,file:m7(u)??i,resolvedResponseType:u,resultsProperty:n.results})),a)}function jf_(e){return e.split(".").slice(1)}function wf_({path:e,typeResolver:t,file:r,resolvedType:i,validate:n}){let a=i;for(let u of e){if(a==null)return n({resolvedType:void 0});let l=Ef_(a);if(l==null)return n({resolvedType:void 0});let s=Sf_({typeResolver:t,file:r,objectSchema:l})[u];if(s==null)return n({resolvedType:void 0});a=t.resolveType({type:s,file:r})}return n({resolvedType:a})}function Sf_({typeResolver:e,file:t,objectSchema:r}){let i=[];typeof r.extends=="string"?i=[r.extends]:Array.isArray(r.extends)&&(i=r.extends);let n={};for(let a of i){let u=kXD({typeResolver:e,file:t,extendedType:a});Object.entries(u).map(([l,d])=>{n[l]=d})}return r.properties!=null&&Object.entries(r.properties).map(([a,u])=>{n[a]=typeof u=="string"?u:u.type}),n}function kXD({typeResolver:e,file:t,extendedType:r}){let i=e.resolveNamedTypeOrThrow({referenceToNamedType:r,file:t});return i._type==="named"&&G1(i.declaration)?Sf_({typeResolver:e,file:Df_(i)??t,objectSchema:i.declaration}):{}}function Df_(e){if(e!=null){if(e._type==="named")return e.file;if(e._type==="container"&&(e.container._type==="optional"||e.container._type==="nullable"))return Df_(e.container.itemType)}}function Ef_(e){if(e!=null){if(e._type==="named"&&G1(e.declaration))return e.declaration;if(e._type==="container"&&(e.container._type==="optional"||e.container._type==="nullable"))return Ef_(e.container.itemType)}}function Mf_({endpointId:e,endpoint:t,typeResolver:r,file:i,offsetPagination:n}){let a=[];a.push(...eZD({endpointId:e,endpoint:t,typeResolver:r,file:i,offsetPagination:n})),a.push(...tZD({endpointId:e,endpoint:t,typeResolver:r,file:i,offsetPagination:n}));let u=yXt({endpoint:t,typeResolver:r,file:i});return u==null?(a.push({severity:"fatal",message:`Pagination configuration for endpoint ${Qs.bold(e)} must define a response type.`}),a):(a.push(...X1n({endpointId:e,typeResolver:r,file:m7(u)??i,resolvedResponseType:u,resultsProperty:n.results})),a.push(...rZD({endpointId:e,resolvedResponseType:u,typeResolver:r,file:m7(u)??i,offsetPagination:n})),a)}function eZD({endpointId:e,endpoint:t,typeResolver:r,file:i,offsetPagination:n}){return wha({endpointId:e,endpoint:t,typeResolver:r,file:i,requestProperty:n.offset,propertyValidator:{propertyID:"offset",validate:Af_}})}function tZD({endpointId:e,endpoint:t,typeResolver:r,file:i,offsetPagination:n}){return n.step==null?[]:wha({endpointId:e,endpoint:t,typeResolver:r,file:i,requestProperty:n.step,propertyValidator:{propertyID:"step",validate:Af_}})}function Af_({resolvedType:e}){let t=P5t(e);return t==null?!1:t==="INTEGER"||t==="LONG"||t==="DOUBLE"}function rZD({resolvedResponseType:e,typeResolver:t,file:r,offsetPagination:i}){return i["has-next-page"]==null?[]:wf_({typeResolver:t,file:r,path:jf_(i["has-next-page"]),resolvedType:e,validate:({resolvedType:n})=>P5t(n)!=="BOOLEAN"?[{message:`"has-next-page" selector, ${i["has-next-page"]}, does not point to a boolean property`,severity:"fatal"}]:[]})}var _Zs={name:"valid-pagination",create:({workspace:e})=>{let t=new t1(e),r=e.definition.rootApiFile.contents.pagination;return{definitionFile:{httpEndpoint:({endpointId:i,endpoint:n},{relativeFilepath:a,contents:u})=>{let l=typeof n.pagination=="boolean"?r:n.pagination;if(!l)return[];let d=Hb({relativeFilepath:a,definitionFile:u,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents});if(nZD(l))return Of_({endpointId:i,endpoint:n,typeResolver:t,file:d,cursorPagination:l});if(iZD(l))return Mf_({endpointId:i,endpoint:n,typeResolver:t,file:d,offsetPagination:l});if(aZD(l))return Pf_({endpointId:i,endpoint:n,typeResolver:t,file:d,customPagination:l});throw new Error("Invalid pagination schema")}}}}};function iZD(e){return e.offset!=null}function nZD(e){return e.cursor!=null&&e.next_cursor!=null&&e.results!=null}function aZD(e){return"type"in e&&e.type==="custom"}var hZs={name:"valid-path-parameters-configuration",create:()=>({definitionFile:{httpEndpoint:({endpoint:e})=>e["path-parameters"]!=null&&typeof e.request!="string"&&e?.request?.["path-parameters"]!=null?[{severity:"fatal",message:"path-parameters cannot be defined in both endpoint and request."}]:[]}})};var yZs={name:"valid-service-urls",create:({workspace:e})=>{let t=ENo(e),r=i=>t.includes(i)?[]:t.length===0&&e.definition.rootApiFile.contents?.["default-url"]!=null?[]:t.length===0?[{severity:"fatal",message:`"url" cannot be configured unless you specify multiple URLs for each environment in ${T3}`}]:[{severity:"fatal",message:[`URL ${Qs.bold(i)} is not recognized. Please add it to your environments in ${T3} or specify one of the configured environment URLs:`,...t.map(n=>` - ${n}`)].join(`
1981
1981
  `)}];return{definitionFile:{serviceBaseUrl:i=>i==null?[]:r(i),endpointBaseUrl:({baseUrl:i,service:n})=>e.definition.rootApiFile.contents?.["default-url"]?[]:i==null?t.length===0||n.url!=null?[]:[{severity:"fatal",message:['"url" is missing. Please specify one of the configured environment URLs:',...t.map(a=>` - ${a}`)].join(`
1982
- `)}]:r(i)}}}};var vZs={name:"valid-stream-condition",create:({workspace:e})=>({definitionFile:{streamCondition:({endpoint:t,streamCondition:r},{relativeFilepath:i,contents:n})=>{let a=new t1(e),u=Hb({relativeFilepath:i,definitionFile:n,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents});return t.response==null||t["response-stream"]==null?r==null?[]:[{severity:"fatal",message:"stream-condition can only be used if both response and response-stream are specified."}]:r==null?[{severity:"fatal",message:"stream-condition must be specified when both response and response-stream are specified."}]:uZD({endpoint:t,typeResolver:a,file:u,requestProperty:r,propertyValidator:{propertyID:"stream-condition",validate:oZD}})}}})};function oZD({resolvedType:e}){let t=P5t(e);return t==null?!1:t==="BOOLEAN"}function uZD({endpoint:e,typeResolver:t,file:r,requestProperty:i,propertyValidator:n}){let a=[],u=J1n(i);return u==null?[{severity:"fatal",message:"Please specify path to a valid property (e.g. $request.stream)"}]:Q1n({typeResolver:t,file:r,endpoint:e,propertyComponents:u,validate:n.validate})?a:[{severity:"fatal",message:`Property "${i}" does not exist on the request.`}]}var sZD=/^[a-z]/i,bZs={name:"valid-type-name",create:()=>({definitionFile:{typeDeclaration:({typeName:e})=>!e.isInlined&&!sZD.test(e.name)?[{severity:"fatal",message:"Type name must begin with a letter"}]:[]}})};var OZs={name:"valid-type-reference-with-default-and-validation",create:({workspace:e})=>{let t=new t1(e);return{definitionFile:{typeDeclaration:({declaration:r})=>{if(!E4t(r))return[];let i=new Set(r.enum.map(n=>typeof n=="string"?n:n.value));return r.default!=null&&!i.has(r.default)?[{message:`Default value '${r.default}' is not a valid enum value`,severity:"fatal"}]:[]},typeReference:({typeReference:r,_default:i,validation:n,location:a},{relativeFilepath:u,contents:l})=>{let d=Hb({relativeFilepath:u,definitionFile:l,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents}),s=t.resolveType({type:r,file:d});return s==null?[]:qf_({resolvedType:s,_default:i,validation:n})}}}}};function qf_({resolvedType:e,_default:t,validation:r}){let i=[];if(t==null&&r==null)return[];if(e._type==="container"&&(e.container._type==="optional"||e.container._type==="nullable"))return qf_({resolvedType:e.container.itemType,_default:t,validation:r});let n=e._type;if(e._type==="primitive")switch(e.primitive.v1){case"STRING":return lZD({_default:t,validation:r});case"DOUBLE":return fZD({_default:t,validation:r});case"INTEGER":return dZD({_default:t,validation:r});case"BOOLEAN":return pZD({_default:t,validation:r});case"LONG":return _ZD({_default:t,validation:r});case"BIG_INTEGER":return hZD({_default:t,validation:r});case"DATE_TIME":n="datetime";break;case"UUID":n="uuid";break;case"BASE_64":n="base64";break;case"UINT":n="uint";break;case"UINT_64":n="uint64";break}return e._type==="named"&&E4t(e.declaration)?cZD({declaration:e.declaration,_default:t}):(t!=null&&i.push({message:`Default values are not supported for the ${n} type`,severity:"fatal"}),r!=null&&i.push({message:`Validation rules are not supported for the ${n} type`,severity:"fatal"}),i)}function cZD({declaration:e,_default:t}){if(t==null)return[];let r=new Set(e.enum.map(n=>typeof n=="string"?n:n.value)),i=[];return r.has(t)||i.push({message:`Default value '${t}' is not a valid enum value`,severity:"fatal"}),i}function lZD({_default:e,validation:t}){let r=[];return e!=null&&typeof e!="string"&&r.push({message:`Default value '${e}' is not a valid string`,severity:"fatal"}),t!=null&&!yZD(t)&&r.push({message:`Validation rules '${JSON.stringify(t)}' are not compatible with the string type`,severity:"fatal"}),r}function fZD({_default:e,validation:t}){let r=[];return e!=null&&typeof e!="number"&&r.push({message:`Default value '${e}' is not a valid double`,severity:"fatal"}),t!=null&&!Tf_(t)&&r.push({message:`Validation rules '${JSON.stringify(t)}' are not compatible with the double type`,severity:"fatal"}),r}function dZD({_default:e,validation:t}){let r=[];return e!=null&&!Number.isInteger(e)&&r.push({message:`Default value '${e}' is not a valid integer`,severity:"fatal"}),t!=null&&(Tf_(t)?r.push(...gZs({name:"min",value:t.min}),...gZs({name:"max",value:t.max}),...gZs({name:"multipleOf",value:t.multipleOf})):r.push({message:`Validation rules '${JSON.stringify(t)}' are not compatible with the integer type`,severity:"fatal"})),r}function pZD({_default:e,validation:t}){let r=[];return e!=null&&typeof e!="boolean"&&r.push({message:`Default value '${e}' is not a valid boolean`,severity:"fatal"}),t!=null&&r.push({message:`Validation rules '${JSON.stringify(t)}' are not compatible with the boolean type`,severity:"fatal"}),r}function _ZD({_default:e,validation:t}){let r=[];return e!=null&&typeof e!="number"&&r.push({message:`Default value '${e}' is not a valid long`,severity:"fatal"}),t!=null&&r.push({message:`Validation rules '${JSON.stringify(t)}' are not compatible with the long type`,severity:"fatal"}),r}function hZD({_default:e,validation:t}){let r=[];if(e!=null)if(typeof e!="string")r.push({message:`Default value '${e}' is not a valid bigint`,severity:"fatal"});else try{BigInt(e)}catch{r.push({message:`Default value '${e}' is not a valid bigint`,severity:"fatal"})}return t!=null&&r.push({message:`Validation rules '${JSON.stringify(t)}' are not compatible with the bigint type`,severity:"fatal"}),r}function gZs({name:e,value:t}){return t!=null&&!Number.isInteger(t)?[{message:`Validation for '${e}' must be an integer, but found '${t}'`,severity:"fatal"}]:[]}function Tf_(e){let t=e;return t.min!=null||t.max!=null||t.exclusiveMin!=null||t.exclusiveMax!=null||t.multipleOf!=null}function yZD(e){let t=e;return t.minLength!=null||t.maxLength!=null||t.pattern!=null||t.format!=null}var mZs={name:"valid-version",create:({workspace:e})=>{let t=new t1(e);return{rootApiFile:{file:r=>vZD({root:r,typeResolver:t})}}}};function vZD({root:e,typeResolver:t}){let r=[];return e.version==null||e.version.default==null?[]:(new Set(e.version.values.map(n=>typeof n=="string"?n:n.value)).has(e.version.default)||r.push({severity:"fatal",message:`Default version "${e.version.default}" not found in version values`}),r)}function bZD(){return[$Xs,qXs,HXs,OXs,AXs,UXs,PXs,tZs,CXs,FXs,IXs,jXs,YXs,RXs,eZs,BXs,zXs,NXs,wXs,EXs,ZXs,TXs,VXs,mXs,yZs,KXs,XXs,DXs,bZs,xXs,iZs,GXs,JXs,LXs,dZs,_Zs,kXs,OZs,vZs,mZs,QXs,rZs,bXs,hZs,gXs]}function Cf_(){return bZD().filter(({DISABLE_RULE:e=!1})=>!e)}function PZs(e,t){return gZD({workspace:e,rules:Cf_(),logger:t})}function gZD({workspace:e,rules:t,logger:r}){let i=[],n=t.map(u=>u.create({workspace:e,logger:r})),a=mZD({contents:e.definition.rootApiFile.contents,allRuleVisitors:n});return i.push(...a),XN(e,(u,l)=>{let d=OZD({relativeFilepath:u,contents:l,allRuleVisitors:n});i.push(...d)}),CIi(e,(u,l)=>{let d=PZD({relativeFilepath:u,contents:l,allRuleVisitors:n});i.push(...d)}),i}function OZD({relativeFilepath:e,contents:t,allRuleVisitors:r}){let i=[],n=Jl_({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:a=>{i.push(...a)}});return dV(t,n),i}function mZD({contents:e,allRuleVisitors:t}){let r=[],i=Yl_({relativeFilepath:Xa.of(T3),contents:e,allRuleVisitors:t,addViolations:n=>{r.push(...n)}});return vXs(e,i),r}function PZD({relativeFilepath:e,contents:t,allRuleVisitors:r}){let i=[],n=Kl_({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:a=>{i.push(...a)}});return yXs(t,n),i}async function Bf_({groups:e,visitor:t,nodePath:r,cliVersion:i}){if(e!=null)for(let[n,a]of Object.entries(e))await jZD({group:a,visitor:t,nodePath:[...r,n],cliVersion:i})}async function jZD({group:e,visitor:t,nodePath:r,cliVersion:i}){await Promise.all(e.generators.map(async(n,a)=>await t.generatorInvocation?.({invocation:n,cliVersion:i},[...r,"generators",a.toString(),n.name])))}async function xf_(e,t,r){await r.file?.(e,[]),await zHt(e,{"auth-schemes":Qo,api:Qo,whitelabel:Qo,metadata:Qo,readme:Qo,"default-group":Qo,reviewers:Qo,openapi:Qo,"openapi-overrides":Qo,"spec-origin":Qo,"async-api":Qo,"api-settings":Qo,groups:async i=>{await Bf_({groups:i,visitor:r,nodePath:["groups"],cliVersion:t})}})}function If_({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:i}){function n(a){let u=async(l,d)=>{for(let s of r){let o=s.generatorsYml?.[a];if(o!=null){let c=await o(l,{relativeFilepath:e,contents:t});i(c.map(b=>({severity:b.severity,relativeFilepath:e,nodePath:d,message:b.message})))}}};return{[a]:u}}return{...n("file"),...n("generatorInvocation")}}function wZD(e,t,r){if(!Qre(r,t))return[{severity:"fatal",message:`The generator ${e} requires CLI version ${t} or later (current version: ${r}). Please run \`fern upgrade\` to upgrade your CLI version and use this generator.`}]}function SZD(e){return Number(e.replace("v",""))}async function DZD(e){let t=Qco({token:void 0}),r=await t.generators.getGeneratorByImage({dockerImage:e.name});if(!r.ok||r.body==null)return;let i=await t.generators.versions.getGeneratorRelease(r.body.id,e.version);if(i.ok)return i.body.irVersion}var jZs={name:"compatible-ir-version",create:async()=>({generatorsYml:{generatorInvocation:async({invocation:e,cliVersion:t})=>{let r=Qco({token:void 0});if(t==null)return[];let i=await r.generators.cli.getCliRelease(t);if(!i.ok)return[];let n=i.body.irVersion,a;if(e["ir-version"]!=null)a=SZD(e["ir-version"]);else{let l=await DZD(e);if(l==null)return[];a=l}if(a<=n)return[];let u=await r.generators.cli.getMinCliForIr(a);return u.ok?wZD(e.name,u.body.version,t)??[]:[]}}})};function zf_(){return[jZs]}async function wZs(e,t){return EZD({workspace:e,rules:zf_(),logger:t})}async function EZD({workspace:e,rules:t,logger:r}){let i=[],n=await Promise.all(t.map(a=>a.create({workspace:e,logger:r})));if(e.generatorsConfiguration?.rawConfiguration){let a=await MZD({contents:e.generatorsConfiguration.rawConfiguration,allRuleVisitors:n,cliVersion:e.cliVersion});i.push(...a)}return i}async function MZD({contents:e,allRuleVisitors:t,cliVersion:r}){let i=[],n=If_({relativeFilepath:Xa.of(gN),contents:e,allRuleVisitors:t,addViolations:a=>{i.push(...a)}});return await xf_(e,r,n),i}var Rf_=require("fs/promises");var SZs={name:"no-duplicate-overrides",run:async({workspace:e,specs:t,context:r})=>{let i=[],n=new Set,a=new Set;for(let u of t){let l=(await(0,Rf_.readFile)(u.absoluteFilepath)).toString();if(l.includes("openapi")||l.includes("swagger")){let d=await Ida({absolutePathToOpenAPI:u.absoluteFilepath,context:r,absolutePathToOpenAPIOverrides:u.absoluteFilepathToOverrides}),s=Ffa(d)?await Cda(d):d;for(let[o,c]of Object.entries(s.paths??{}))for(let[b,g]of Object.entries(c??{})){if(b==="parameters"||b==="$ref")continue;let O=g,m=O?.["x-fern-sdk-group-name"],w=Array.isArray(m)?m.join("."):m,E=O?.["x-fern-sdk-method-name"];if(w&&E){let A=`${w}:${E}`;n.has(A)&&i.push({severity:"fatal",relativeFilepath:Qq(e.absoluteFilePath,u.source.file),nodePath:["paths",o,b],message:`SDK method ${w}.${E} already exists (x-fern-sdk-group-name: ${w}, x-fern-sdk-method-name: ${E})`}),n.add(A)}}}}return i}};function Nf_(){return[SZs]}async function DZs(e,t){return await AZD({workspace:e,context:t,rules:Nf_()})}async function AZD({workspace:e,context:t,rules:r}){let i=await HIe({context:t,specs:e.specs});return(await Promise.all(r.map(a=>a.run({workspace:e,specs:i,context:t})))).flat()}function Z1n({context:e,violations:t,logWarnings:r,logSummary:i=!0,logBreadcrumbs:n=!0,elapsedMillis:a=0}){let u=IZD(t),l=qZD(t);for(let d of Array.from(l.keys()).sort()){let s=l.get(d);if(s){let o=s[0]?.relativeFilepath??"";TZD({logWarnings:r,logBreadcrumbs:n,configRelativeFilepath:o,nodePath:d,violations:s,context:e})}}return i&&xZD({context:e,stats:u,logWarnings:r,elapsedMillis:a}),{hasErrors:u.numFatal>0}}function qZD(e){let t=new Map;for(let r of e)t.set(r.nodePath,[...t.get(r.nodePath)??[],r]);return t}function TZD({logWarnings:e,logBreadcrumbs:t,configRelativeFilepath:r,nodePath:i,violations:n,context:a}){let u=CZD(n);if(u==="warning"&&!e)return;let l="",d=n.map(s=>s.severity==="warning"&&!e?null:(l===""&&(l=s.relativeFilepath),s.message)).filter(s=>s!=null).join(`
1982
+ `)}]:r(i)}}}};var vZs={name:"valid-stream-condition",create:({workspace:e})=>({definitionFile:{streamCondition:({endpoint:t,streamCondition:r},{relativeFilepath:i,contents:n})=>{let a=new t1(e),u=Hb({relativeFilepath:i,definitionFile:n,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents});return t.response==null||t["response-stream"]==null?r==null?[]:[{severity:"fatal",message:"stream-condition can only be used if both response and response-stream are specified."}]:r==null?[{severity:"fatal",message:"stream-condition must be specified when both response and response-stream are specified."}]:uZD({endpoint:t,typeResolver:a,file:u,requestProperty:r,propertyValidator:{propertyID:"stream-condition",validate:oZD}})}}})};function oZD({resolvedType:e}){let t=P5t(e);return t==null?!1:t==="BOOLEAN"}function uZD({endpoint:e,typeResolver:t,file:r,requestProperty:i,propertyValidator:n}){let a=[],u=J1n(i);return u==null?[{severity:"fatal",message:"Please specify path to a valid property (e.g. $request.stream)"}]:Q1n({typeResolver:t,file:r,endpoint:e,propertyComponents:u,validate:n.validate})?a:[{severity:"fatal",message:`Property "${i}" does not exist on the request.`}]}var sZD=/^[a-z]/i,bZs={name:"valid-type-name",create:()=>({definitionFile:{typeDeclaration:({typeName:e})=>!e.isInlined&&!sZD.test(e.name)?[{severity:"fatal",message:"Type name must begin with a letter"}]:[]}})};var OZs={name:"valid-type-reference-with-default-and-validation",create:({workspace:e})=>{let t=new t1(e);return{definitionFile:{typeDeclaration:({declaration:r})=>{if(!E4t(r))return[];let i=new Set(r.enum.map(n=>typeof n=="string"?n:n.value));return r.default!=null&&!i.has(r.default)?[{message:`Default value '${r.default}' is not a valid enum value`,severity:"fatal"}]:[]},typeReference:({typeReference:r,_default:i,validation:n,location:a},{relativeFilepath:u,contents:l})=>{let d=Hb({relativeFilepath:u,definitionFile:l,casingsGenerator:X1,rootApiFile:e.definition.rootApiFile.contents}),s=t.resolveType({type:r,file:d});return s==null?[]:qf_({resolvedType:s,_default:i,validation:n})}}}}};function qf_({resolvedType:e,_default:t,validation:r}){let i=[];if(t==null&&r==null)return[];if(e._type==="container"&&(e.container._type==="optional"||e.container._type==="nullable"))return qf_({resolvedType:e.container.itemType,_default:t,validation:r});let n=e._type;if(e._type==="primitive")switch(e.primitive.v1){case"STRING":return lZD({_default:t,validation:r});case"DOUBLE":return fZD({_default:t,validation:r});case"INTEGER":return dZD({_default:t,validation:r});case"BOOLEAN":return pZD({_default:t,validation:r});case"LONG":return _ZD({_default:t,validation:r});case"BIG_INTEGER":return hZD({_default:t,validation:r});case"DATE_TIME":n="datetime";break;case"UUID":n="uuid";break;case"BASE_64":n="base64";break;case"UINT":n="uint";break;case"UINT_64":n="uint64";break}return e._type==="named"&&E4t(e.declaration)?cZD({declaration:e.declaration,_default:t}):(t!=null&&i.push({message:`Default values are not supported for the ${n} type`,severity:"fatal"}),r!=null&&i.push({message:`Validation rules are not supported for the ${n} type`,severity:"fatal"}),i)}function cZD({declaration:e,_default:t}){if(t==null)return[];let r=new Set(e.enum.map(n=>typeof n=="string"?n:n.value)),i=[];return r.has(t)||i.push({message:`Default value '${t}' is not a valid enum value`,severity:"fatal"}),i}function lZD({_default:e,validation:t}){let r=[];return e!=null&&typeof e!="string"&&r.push({message:`Default value '${e}' is not a valid string`,severity:"fatal"}),t!=null&&!yZD(t)&&r.push({message:`Validation rules '${JSON.stringify(t)}' are not compatible with the string type`,severity:"fatal"}),r}function fZD({_default:e,validation:t}){let r=[];return e!=null&&typeof e!="number"&&r.push({message:`Default value '${e}' is not a valid double`,severity:"fatal"}),t!=null&&!Tf_(t)&&r.push({message:`Validation rules '${JSON.stringify(t)}' are not compatible with the double type`,severity:"fatal"}),r}function dZD({_default:e,validation:t}){let r=[];return e!=null&&!Number.isInteger(e)&&r.push({message:`Default value '${e}' is not a valid integer`,severity:"fatal"}),t!=null&&(Tf_(t)?r.push(...gZs({name:"min",value:t.min}),...gZs({name:"max",value:t.max}),...gZs({name:"multipleOf",value:t.multipleOf})):r.push({message:`Validation rules '${JSON.stringify(t)}' are not compatible with the integer type`,severity:"fatal"})),r}function pZD({_default:e,validation:t}){let r=[];return e!=null&&typeof e!="boolean"&&r.push({message:`Default value '${e}' is not a valid boolean`,severity:"fatal"}),t!=null&&r.push({message:`Validation rules '${JSON.stringify(t)}' are not compatible with the boolean type`,severity:"fatal"}),r}function _ZD({_default:e,validation:t}){let r=[];return e!=null&&typeof e!="number"&&r.push({message:`Default value '${e}' is not a valid long`,severity:"fatal"}),t!=null&&r.push({message:`Validation rules '${JSON.stringify(t)}' are not compatible with the long type`,severity:"fatal"}),r}function hZD({_default:e,validation:t}){let r=[];if(e!=null)if(typeof e!="string")r.push({message:`Default value '${e}' is not a valid bigint`,severity:"fatal"});else try{BigInt(e)}catch{r.push({message:`Default value '${e}' is not a valid bigint`,severity:"fatal"})}return t!=null&&r.push({message:`Validation rules '${JSON.stringify(t)}' are not compatible with the bigint type`,severity:"fatal"}),r}function gZs({name:e,value:t}){return t!=null&&!Number.isInteger(t)?[{message:`Validation for '${e}' must be an integer, but found '${t}'`,severity:"fatal"}]:[]}function Tf_(e){let t=e;return t.min!=null||t.max!=null||t.exclusiveMin!=null||t.exclusiveMax!=null||t.multipleOf!=null}function yZD(e){let t=e;return t.minLength!=null||t.maxLength!=null||t.pattern!=null||t.format!=null}var mZs={name:"valid-version",create:({workspace:e})=>{let t=new t1(e);return{rootApiFile:{file:r=>vZD({root:r,typeResolver:t})}}}};function vZD({root:e,typeResolver:t}){let r=[];return e.version==null||e.version.default==null?[]:(new Set(e.version.values.map(n=>typeof n=="string"?n:n.value)).has(e.version.default)||r.push({severity:"fatal",message:`Default version "${e.version.default}" not found in version values`}),r)}function bZD(){return[$Xs,qXs,HXs,OXs,AXs,UXs,PXs,tZs,CXs,FXs,IXs,jXs,YXs,RXs,eZs,BXs,zXs,NXs,wXs,EXs,ZXs,TXs,VXs,mXs,yZs,KXs,XXs,DXs,bZs,xXs,iZs,GXs,JXs,LXs,dZs,_Zs,kXs,OZs,vZs,mZs,QXs,rZs,bXs,hZs,gXs]}function Cf_(){return bZD().filter(({DISABLE_RULE:e=!1})=>!e)}function PZs(e,t){return gZD({workspace:e,rules:Cf_(),logger:t})}function gZD({workspace:e,rules:t,logger:r}){let i=[],n=t.map(u=>u.create({workspace:e,logger:r})),a=mZD({contents:e.definition.rootApiFile.contents,allRuleVisitors:n});return i.push(...a),XN(e,(u,l)=>{let d=OZD({relativeFilepath:u,contents:l,allRuleVisitors:n});i.push(...d)}),CIi(e,(u,l)=>{let d=PZD({relativeFilepath:u,contents:l,allRuleVisitors:n});i.push(...d)}),i}function OZD({relativeFilepath:e,contents:t,allRuleVisitors:r}){let i=[],n=Jl_({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:a=>{i.push(...a)}});return dV(t,n),i}function mZD({contents:e,allRuleVisitors:t}){let r=[],i=Yl_({relativeFilepath:Xa.of(T3),contents:e,allRuleVisitors:t,addViolations:n=>{r.push(...n)}});return vXs(e,i),r}function PZD({relativeFilepath:e,contents:t,allRuleVisitors:r}){let i=[],n=Kl_({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:a=>{i.push(...a)}});return yXs(t,n),i}async function Bf_({groups:e,visitor:t,nodePath:r,cliVersion:i}){if(e!=null)for(let[n,a]of Object.entries(e))await jZD({group:a,visitor:t,nodePath:[...r,n],cliVersion:i})}async function jZD({group:e,visitor:t,nodePath:r,cliVersion:i}){await Promise.all(e.generators.map(async(n,a)=>await t.generatorInvocation?.({invocation:n,cliVersion:i},[...r,"generators",a.toString(),n.name])))}async function xf_(e,t,r){await r.file?.(e,[]),await zHt(e,{"auth-schemes":Qo,api:Qo,whitelabel:Qo,metadata:Qo,readme:Qo,"default-group":Qo,reviewers:Qo,openapi:Qo,"openapi-overrides":Qo,"spec-origin":Qo,"async-api":Qo,"api-settings":Qo,groups:async i=>{await Bf_({groups:i,visitor:r,nodePath:["groups"],cliVersion:t})}})}function If_({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:i}){function n(a){let u=async(l,d)=>{for(let s of r){let o=s.generatorsYml?.[a];if(o!=null){let c=await o(l,{relativeFilepath:e,contents:t});i(c.map(b=>({severity:b.severity,relativeFilepath:e,nodePath:d,message:b.message})))}}};return{[a]:u}}return{...n("file"),...n("generatorInvocation")}}function wZD(e,t,r){if(!Qre(r,t))return[{severity:"fatal",message:`The generator ${e} requires CLI version ${t} or later (current version: ${r}). Please run \`fern upgrade\` to upgrade your CLI version and use this generator.`}]}function SZD(e){return Number(e.replace("v",""))}async function DZD(e){let t=Qco({token:void 0}),r=await t.generators.getGeneratorByImage({dockerImage:e.name});if(!r.ok||r.body==null)return;let i=await t.generators.versions.getGeneratorRelease(r.body.id,e.version);if(i.ok)return i.body.irVersion}var jZs={name:"compatible-ir-version",create:async()=>({generatorsYml:{generatorInvocation:async({invocation:e,cliVersion:t})=>{let r=Qco({token:void 0});if(t==null)return[];let i=await r.generators.cli.getCliRelease(t);if(!i.ok)return[];let n=i.body.irVersion,a;if(e["ir-version"]!=null)a=SZD(e["ir-version"]);else{let l=await DZD(e);if(l==null)return[];a=l}if(a<=n)return[];let u=await r.generators.cli.getMinCliForIr(a);return u.ok?wZD(e.name,u.body.version,t)??[]:[]}}})};function zf_(){return[jZs]}async function wZs(e,t){return EZD({workspace:e,rules:zf_(),logger:t})}async function EZD({workspace:e,rules:t,logger:r}){let i=[],n=await Promise.all(t.map(a=>a.create({workspace:e,logger:r})));if(e.generatorsConfiguration?.rawConfiguration){let a=await MZD({contents:e.generatorsConfiguration.rawConfiguration,allRuleVisitors:n,cliVersion:e.cliVersion});i.push(...a)}return i}async function MZD({contents:e,allRuleVisitors:t,cliVersion:r}){let i=[],n=If_({relativeFilepath:Xa.of(gN),contents:e,allRuleVisitors:t,addViolations:a=>{i.push(...a)}});return await xf_(e,r,n),i}var Rf_=require("fs/promises");var SZs={name:"no-duplicate-overrides",run:async({workspace:e,specs:t,context:r})=>{let i=[],n=new Set,a=new Set;for(let u of t){let l=(await(0,Rf_.readFile)(u.absoluteFilepath)).toString();if(l.includes("openapi")||l.includes("swagger")){let d=await Ida({absolutePathToOpenAPI:u.absoluteFilepath,context:r,absolutePathToOpenAPIOverrides:u.absoluteFilepathToOverrides}),s=Ffa(d)?await Cda(d):d;for(let[o,c]of Object.entries(s.paths??{}))for(let[b,g]of Object.entries(c??{})){if(b==="parameters"||b==="$ref")continue;let O=g,m=O?.["x-fern-sdk-group-name"],w=Array.isArray(m)?m.join("."):m,E=O?.["x-fern-sdk-method-name"];if(w&&E){let A=`${w}:${E}`;n.has(A)&&i.push({severity:"fatal",relativeFilepath:Qq(e.absoluteFilePath,u.source.file),nodePath:["paths",o,b],message:`SDK method ${w}.${E} already exists (x-fern-sdk-group-name: ${w}, x-fern-sdk-method-name: ${E})`}),n.add(A)}}}}return i}};function Nf_(){return[SZs]}async function DZs(e,t){return await AZD({workspace:e,context:t,rules:Nf_()})}async function AZD({workspace:e,context:t,rules:r}){let i=await HIe({context:t,specs:e.specs});return(await Promise.all(r.map(a=>a.run({workspace:e,specs:i,context:t})))).flat()}function Z1n({context:e,violations:t,logWarnings:r,logSummary:i=!0,logBreadcrumbs:n=!0,elapsedMillis:a=0}){let u=[],l=new Map;for(let o of t){let c=l.get(o.nodePath)??[];c.some(g=>g.message===o.message&&g.nodePath.length===o.nodePath.length&&g.nodePath.every((O,m)=>O===o.nodePath[m])&&g.relativeFilepath===o.relativeFilepath&&g.severity===o.severity)||(u.push(o),l.set(o.nodePath,[...c,o]))}t=u;let d=IZD(t),s=qZD(t);for(let o of Array.from(s.keys()).sort()){let c=s.get(o);if(c){let b=c[0]?.relativeFilepath??"";TZD({logWarnings:r,logBreadcrumbs:n,configRelativeFilepath:b,nodePath:o,violations:c,context:e})}}return i&&xZD({context:e,stats:d,logWarnings:r,elapsedMillis:a}),{hasErrors:d.numFatal>0}}function qZD(e){let t=new Map;for(let r of e){let i=t.get(r.nodePath)??[];t.set(r.nodePath,[...i,r])}return t}function TZD({logWarnings:e,logBreadcrumbs:t,configRelativeFilepath:r,nodePath:i,violations:n,context:a}){let u=CZD(n);if(u==="warning"&&!e)return;let l="",d=n.map(s=>s.severity==="warning"&&!e?null:(l===""&&(l=s.relativeFilepath),s.message)).filter(s=>s!=null).join(`
1983
1983
  `);a.logger.log(BZD(u),Jre({breadcrumbs:t?[r,...i.map(s=>{let o=typeof s=="string"?s:s.key;return typeof s!="string"&&s.arrayIndex!=null&&(o+=`[${s.arrayIndex}]`),o})]:[],title:l,subtitle:d})+`
1984
1984
  `)}function CZD(e){return e.some(t=>t.severity==="fatal")?"fatal":e.some(t=>t.severity==="error")?"error":"warning"}function BZD(e){switch(e){case"fatal":return B0.Error;case"error":return B0.Error;case"warning":return B0.Warn;default:Ko(e)}}function xZD({stats:e,context:t,logWarnings:r,elapsedMillis:i=0}){let{numFatal:n,numErrors:a,numWarnings:u}=e,l=i>0?` in ${(i/1e3).toFixed(3)} seconds.`:".",d=`Found ${n+a} errors and ${u} warnings`+l;!r&&u>0&&(d+=" Run fern check --warnings to print out the warnings not shown."),n+a>0?t.logger.error(d):u>0?t.logger.warn(d):t.logger.info(Qs.green("\u2713 All checks passed"))}function IZD(e){let t=0,r=0,i=0;for(let n of e)switch(n.severity){case"fatal":t+=1;continue;case"error":r+=1;continue;case"warning":i+=1;continue;default:Ko(n.severity)}return{numFatal:t,numErrors:r,numWarnings:i}}async function EZs({workspace:e,context:t,logWarnings:r,logSummary:i=!0,ossWorkspace:n}){let a=performance.now(),u=PZs(e,t.logger),l=await wZs(e,t.logger),d=[...u,...l];n&&d.concat(await DZs(n,t));let s=performance.now()-a,{hasErrors:o}=Z1n({violations:d,context:t,logWarnings:r,logSummary:i,elapsedMillis:s});return{hasErrors:o}}async function vXt({workspace:e,context:t,logWarnings:r,ossWorkspace:i}){(0,Ff_.default)(e.definition.rootApiFile.contents.name).validForNewPackages||t.failAndThrow("API name is not valid.");let{hasErrors:n}=await EZs({workspace:e,context:t,logWarnings:r,ossWorkspace:i});n&&t.failAndThrow()}var MZs={};Io(MZs,{additionalProperties:()=>FZD,default:()=>UZD,definitions:()=>LZD,properties:()=>RZD,required:()=>NZD,type:()=>zZD});var zZD="object",RZD={tabs:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/docs.TabConfig"}},{type:"null"}]},"landing-page":{oneOf:[{$ref:"#/definitions/docs.PageConfiguration"},{type:"null"}]},navigation:{$ref:"#/definitions/docs.NavigationConfig"}},NZD=["navigation"],FZD=!1,LZD={"docs.RoleId":{type:"string"},"docs.Role":{anyOf:[{$ref:"#/definitions/docs.RoleId"},{type:"array",items:{$ref:"#/definitions/docs.RoleId"}}]},"docs.FeatureFlag":{type:"object",properties:{flag:{type:"string"},"fallback-value":{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},match:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]}},required:["flag"],additionalProperties:!1},"docs.FeatureFlagConfiguration":{anyOf:[{type:"string",description:"The name of the feature flag, We assume that it is a boolean feature flag that needs to be evaluated to true."},{$ref:"#/definitions/docs.FeatureFlag",description:"A single feature flag with a configurable name, fallback value, and match value. Especially useful for non boolean feature flags."},{type:"array",items:{$ref:"#/definitions/docs.FeatureFlag"},description:"A list of feature flags. If any of the feature flags are satisfied, we will show all content."}]},"docs.ChangelogFolderRelativePath":{type:"string"},"docs.TabConfig":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},"display-name":{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},changelog:{oneOf:[{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},{type:"null"}]}},required:["display-name"],additionalProperties:!1},"docs.PageConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},page:{type:"string"},path:{type:"string"},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},noindex:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["page","path"],additionalProperties:!1},"docs.SectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},path:{oneOf:[{type:"string"},{type:"null"}]},contents:{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["section","contents"],additionalProperties:!1},"docs.AudienceId":{type:"string"},"docs.VersionedSnippetLanguageConfiguration":{type:"object",properties:{version:{type:"string"},package:{type:"string"}},required:["version","package"],additionalProperties:!1},"docs.SnippetLanguageConfiguration":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.VersionedSnippetLanguageConfiguration"}]},"docs.SnippetsConfiguration":{type:"object",properties:{python:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},typescript:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},go:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},java:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},ruby:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},csharp:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundButtonSettings":{type:"object",properties:{href:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundSettings":{type:"object",properties:{environments:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},button:{oneOf:[{$ref:"#/definitions/docs.PlaygroundButtonSettings"},{type:"null"}]},oauth:{oneOf:[{type:"boolean"},{type:"null"}]},"limit-websocket-messages-per-connection":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfigurationWithOptions":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},title:{oneOf:[{type:"string"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfiguration":{anyOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{$ref:"#/definitions/docs.ApiReferencePackageConfigurationWithOptions"}]},"docs.ApiReferenceSectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},"referenced-packages":{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["section"],additionalProperties:!1},"docs.ApiReferenceEndpointConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},endpoint:{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"docs.LinkConfiguration":{type:"object",properties:{link:{type:"string"},href:{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]}},required:["link","href"],additionalProperties:!1},"docs.ApiReferenceLayoutItem":{anyOf:[{type:"string",description:"This should be either an endpoint, websocket, webhook, or subpackage ID"},{type:"object",additionalProperties:{$ref:"#/definitions/docs.ApiReferencePackageConfiguration"},description:"Keyed by subpackage name, this object allows you to group endpoints and pages together."},{$ref:"#/definitions/docs.ApiReferenceSectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceEndpointConfiguration"},{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"}]},"docs.ApiReferenceConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},api:{type:"string"},"api-name":{oneOf:[{type:"string"},{type:"null"}]},openrpc:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.AudienceId"}},{type:"null"}]},"display-errors":{oneOf:[{type:"boolean"},{type:"null"}]},snippets:{oneOf:[{$ref:"#/definitions/docs.SnippetsConfiguration"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},alphabetized:{oneOf:[{type:"boolean"},{type:"null"}]},flattened:{oneOf:[{type:"boolean"},{type:"null"}]},paginated:{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["api"],additionalProperties:!1},"docs.ChangelogConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},changelog:{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["changelog"],additionalProperties:!1},"docs.NavigationItem":{anyOf:[{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.SectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"},{$ref:"#/definitions/docs.ChangelogConfiguration"}]},"docs.UntabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},"docs.TabId":{type:"string"},"docs.TabbedNavigationItem":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},{type:"null"}]}},required:["tab"],additionalProperties:!1},"docs.TabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.TabbedNavigationItem"}},"docs.NavigationConfig":{anyOf:[{$ref:"#/definitions/docs.UntabbedNavigationConfig"},{$ref:"#/definitions/docs.TabbedNavigationConfig"}]}},UZD={type:zZD,properties:RZD,required:NZD,additionalProperties:FZD,definitions:LZD};async function INo({value:e}){let t=gHr(e,MZs);if(t.success)return{type:"success",contents:J2t.RawSchemas.Serializer.VersionFileConfig.parseOrThrow(e)};let r=t.error?.instancePath?` at ${t?.error.instancePath}`:"";return{type:"failure",message:`${t.error?.message??"Failed to parse because JSON schema validation failed"}${r}`}}function Lf_(e,t){let r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,r),e.applyData(t,r)}function Uf_(e,t){let r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,r),[e.applyData(t,r),{type:"text",value:`
1985
1985
  `}]}function Vf_(e,t){let r=t.value?t.value+`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.56.0-rc4",
3
+ "version": "0.56.0-rc5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",