fern-api 0.57.6 → 0.57.7

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
@@ -1701,7 +1701,7 @@ ${c.indent}`:""}${TQf(o)}:${l.indent?" ":""}`;return u=!1,s=!0,l.objectItem=void
1701
1701
  `}),r.replaceAll(/\n$/g,"")}function i5S(e){return e?k_.green(P7.radioOn):P7.radioOff}var pmo=di(NSe(),1);function gup(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var Pca=class extends T2{_run(t){this.done=t;let r=fV(this.rl),i=r.line.pipe((0,pmo.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,pmo.takeUntil)(n.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),i="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(i=`
1702
1702
  `+k_.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?k_.cyan(gup(t,this.opt.mask)):k_.italic.dim("[hidden]"):this.opt.mask?gup(t,this.opt.mask):k_.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 Wsp=di(Sxs(),1),Hsp=di(NSe(),1);var Cca=class extends T2{_run(t){this.done=t,this.editorResult=new Hsp.Subject;let r=fV(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"?k_.dim("Received"):k_.dim("Press <enter> to launch your preferred editor."),t&&(r=k_.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,Wsp.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 Scp=di(Ocp(),1);var jcp=di(require("readline"),1),wcp=di(Pcp(),1),JIi=class{constructor(t){this.rl||=jcp.default.createInterface(g9S(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 g9S(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 wcp.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var Ica=class extends JIi{constructor(t={}){super(t),this.log=(0,Scp.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return _ca(this.rl,this.bottomBar.split(`
1703
1703
  `).length),this}updateBottomBar(t){return _ca(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=t,this.render(),this.rl.output.mute(),this}writeLog(t){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(t.toString())),this.render(),this.rl.output.mute(),this}enforceLF(t){return/[\n\r]$/.test(t)?t:t+`
1704
- `}write(t){let r=t.split(/\n/);this.height=r.length,this.rl.setPrompt(r.at(-1)),this.rl.output.rows===0&&this.rl.output.columns===0&&cmo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var Icp=di(Mcp(),1),zcp=di(BCs(),1),Rcp=di(Bcp(),1),YA=di(NSe(),1),Ncp=di(jsa(),1);var Nmo=di(NSe(),1),xcp=di(jsa(),1),Fmo=function(e,t,r){return typeof e[t]!="function"?(0,Nmo.of)(e):(0,Nmo.from)((0,xcp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var zca={isPlainObject:Icp.default,set:Rcp.default,get:zcp.default},$mn=class extends JIi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=zca.isPlainObject(r)?{...r}:{},zca.isPlainObject(t)&&(t=Object.values(t).every(n=>zca.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,YA.from)(t):t;return this.process=i.pipe((0,YA.concatMap)(this.processQuestion.bind(this)),(0,YA.publish)()),this.process.connect(),this.process.pipe((0,YA.reduce)((n,a)=>(zca.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,YA.defer)(()=>(0,YA.of)(t).pipe((0,YA.concatMap)(this.setDefaultType.bind(this)),(0,YA.concatMap)(this.filterIfRunnable.bind(this)),(0,YA.concatMap)(()=>Fmo(t,"message",this.answers)),(0,YA.concatMap)(()=>Fmo(t,"default",this.answers)),(0,YA.concatMap)(()=>Fmo(t,"choices",this.answers)),(0,YA.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,YA.defer)(()=>(0,YA.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,YA.defer)(()=>(0,YA.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&zca.get(this.answers,t.name)!==void 0)return(0,YA.empty)();if(t.when===!1)return(0,YA.empty)();if(typeof t.when!="function")return(0,YA.of)(t);let{answers:r}=this;return(0,YA.defer)(()=>(0,YA.from)((0,Ncp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,YA.filter)(i=>i!=null)))}};function Fcp(e){let t=function(r,i){let n;try{n=new $mn(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",yca),this.registerPrompt("input",NIi),this.registerPrompt("number",vca),this.registerPrompt("confirm",bca),this.registerPrompt("rawlist",gca),this.registerPrompt("expand",Oca),this.registerPrompt("checkbox",mca),this.registerPrompt("password",Pca),this.registerPrompt("editor",Cca)},t.restoreDefaultPrompts(),t}var Ixs=Fcp();function R9S(e,t){Ixs.registerPrompt(e,t)}function N9S(){Ixs.restoreDefaultPrompts()}var F9S={prompt:Ixs,ui:{BottomBar:Ica,Prompt:$mn},createPromptModule:Fcp,registerPrompt:R9S,restoreDefaultPrompts:N9S,Separator:Die},Lmo=F9S;var Klp=di(Lcp()),dVS="4.2.1",h5t;(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"})(h5t||(h5t={}));function pVS(e,t){if(!e)throw new Error(t)}function _VS(e){return e?.replace(/\/+$/,"")}async function hVS(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 yVS(){return new Date().getTime()}function Ulp(){return new Date().toISOString()}function Ylp(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var Qca=String.fromCharCode,Vlp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",tPo={};function vVS(e,t){if(!tPo[e]){tPo[e]={};for(let r=0;r<e.length;r++)tPo[e][e.charAt(r)]=r}return tPo[e][t]}var Jca={compressToBase64:function(e){if(e==null)return"";let t=Jca._compress(e,6,function(r){return Vlp.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:Jca._decompress(e.length,32,function(t){return vVS(Vlp,e.charAt(t))})},compress:function(e){return Jca._compress(e,16,function(t){return Qca(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,P;for(P=0;P<e.length;P+=1)if(d=e.charAt(P),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:Jca._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,P;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=Qca(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=Qca(b);break;case 2:return""}for(i[3]=P,c=P,n.push(P);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,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(P=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=Qca(b),P=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=Qca(b),P=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[P])s=i[P];else if(P===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,d),d++)}}},gIs=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 rPo="0123456789abcdef",iPo=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+=rPo.charAt(this.bytes[r]>>>4),t+=rPo.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+=rPo.charAt(this.bytes[r]>>>4),t+=rPo.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}},OIs=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??bVS()}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 iPo.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,iPo.ofInner(t)}},bVS=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Wlp,Hlp=()=>gVS().toString(),gVS=()=>(Wlp||(Wlp=new OIs)).generate(),nPo=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},Kca=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function $lp(e){return typeof e=="object"&&(e instanceof nPo||e instanceof Kca)}var mIs=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new gIs,this._isInitialized=!1,pVS(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=_VS(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:$lp},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(h5t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(h5t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(h5t.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=Hlp();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:Ulp(),uuid:i?.uuid?i.uuid:Hlp()};(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(h5t.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(h5t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Ylp(()=>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(h5t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(h5t.Queue)||[];this.setPersistedProperty(h5t.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:Ulp()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${yVS()}&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(Jca.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 Kca||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 hVS(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(d){throw new Kca(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new nPo(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(h5t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!$lp(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},PIs=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},jIs=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!jIs){let e=Llp();jIs=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 Xlp=jIs,OVS=1152921504606847e3,mVS=["is_not"],aPo=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},C2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},wIs=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||Xlp,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 C2?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 C2||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 C2("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 C2("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 C2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new C2("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=klp(l,n,this.cohorts,this.debugMode):s=Zlp(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&Glp(t.key,r)>a/100)}getMatchingVariant(t,r){let i=Glp(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 aPo("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 aPo&&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=Ylp(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function Glp(e,t,r=""){let i=(0,Klp.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/OVS}function Zlp(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 C2("Operator is_not_set is not supported")}else throw new C2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!mVS.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 Qlp(String(n))&&String(u).match(String(n))!==null;case"not_regex":return Qlp(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=PVS(String(n));if(s==null&&(s=Jlp(n)),s==null)throw new C2(`Invalid date: ${n}`);let o=Jlp(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new C2(`Unknown operator: ${a}`)}}function klp(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new C2("can't match cohort without a given cohort property value");let a=r[n];return efp(a,t,r,i)}function efp(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=efp(l,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof C2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new C2("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=klp(l,t,r,i):d=Zlp(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 C2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new C2("can't match cohort without a given cohort property value");return n==="AND"}}function Qlp(e){try{return new RegExp(e),!0}catch{return!1}}function Jlp(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 C2(`${e} is in an invalid date format`)}else throw new C2(`The date provided ${e} must be a string, number, or date object`)}function PVS(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 jVS=30*1e3,wVS=50*1e3,Zmn=class extends mIs{constructor(t,r={}){super(t,r),this._memoryStorage=new PIs,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new wIs({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:jVS,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||wVS}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):Xlp(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return dVS}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,P]of Object.entries(b))g[`$feature/${m}`]=P;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties: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}}},SIs=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})}};SIs.POSTHOG_ID_TAG="posthog_distinct_id";var oPo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new Zmn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.57.6",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var Yca=class{async sendEvent(){}async identify(){}async flush(){}};var kmn=require("fs/promises"),nfp=require("os"),afp=require("path");var tfp=di(require("crypto")),sPo=new Uint8Array(256),uPo=sPo.length;function DIs(){return uPo>sPo.length-16&&(tfp.default.randomFillSync(sPo),uPo=0),sPo.slice(uPo,uPo+=16)}var _V=[];for(let e=0;e<256;++e)_V.push((e+256).toString(16).slice(1));function rfp(e,t=0){return _V[e[t+0]]+_V[e[t+1]]+_V[e[t+2]]+_V[e[t+3]]+"-"+_V[e[t+4]]+_V[e[t+5]]+"-"+_V[e[t+6]]+_V[e[t+7]]+"-"+_V[e[t+8]]+_V[e[t+9]]+"-"+_V[e[t+10]]+_V[e[t+11]]+_V[e[t+12]]+_V[e[t+13]]+_V[e[t+14]]+_V[e[t+15]]}var ifp=di(require("crypto")),EIs={randomUUID:ifp.default.randomUUID};function SVS(e,t,r){if(EIs.randomUUID&&!t&&!e)return EIs.randomUUID();e=e||{};let i=e.random||(e.rng||DIs)();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 rfp(i)}var Tie=SVS;var DVS="id",EVS=".fern",Xca=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new Zmn(r),this.userId=t==null?void 0:zEs(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.57.6",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=es(Wl.of((0,nfp.homedir)()),uo.of(EVS),uo.of(DVS));await Cf(t)||(await(0,kmn.mkdir)((0,afp.dirname)(t),{recursive:!0}),await(0,kmn.writeFile)(t,Tie())),this.persistedDistinctId=(await(0,kmn.readFile)(t)).toString()}return this.persistedDistinctId}};var MIs;async function ePn(){return MIs==null&&(MIs=await MVS()),MIs}async function MVS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Yca;let r=await cyo();return r!=null?new Xca({token:r,posthogApiKey:e}):await syo()!=null?new oPo({posthogApiKey:e}):new Xca({token:void 0,posthogApiKey:e})}catch{return new Yca}}function Zca(e,t){return function(){return e.apply(t,arguments)}}var{toString:AVS}=Object.prototype,{getPrototypeOf:qIs}=Object,lPo=(e=>t=>{let r=AVS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),y5t=e=>(e=e.toLowerCase(),t=>lPo(t)===e),fPo=e=>t=>typeof t===e,{isArray:tPn}=Array,kca=fPo("undefined");function qVS(e){return e!==null&&!kca(e)&&e.constructor!==null&&!kca(e.constructor)&&LSe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var ufp=y5t("ArrayBuffer");function TVS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ufp(e.buffer),t}var CVS=fPo("string"),LSe=fPo("function"),sfp=fPo("number"),dPo=e=>e!==null&&typeof e=="object",BVS=e=>e===!0||e===!1,cPo=e=>{if(lPo(e)!=="object")return!1;let t=qIs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},xVS=y5t("Date"),IVS=y5t("File"),zVS=y5t("Blob"),RVS=y5t("FileList"),NVS=e=>dPo(e)&&LSe(e.pipe),FVS=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||LSe(e.append)&&((t=lPo(e))==="formdata"||t==="object"&&LSe(e.toString)&&e.toString()==="[object FormData]"))},LVS=y5t("URLSearchParams"),[UVS,VVS,WVS,HVS]=["ReadableStream","Request","Response","Headers"].map(y5t),$VS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ela(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),tPn(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 cfp(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 kIi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,lfp=e=>!kca(e)&&e!==kIi;function AIs(){let{caseless:e}=lfp(this)&&this||{},t={},r=(i,n)=>{let a=e&&cfp(t,n)||n;cPo(t[a])&&cPo(i)?t[a]=AIs(t[a],i):cPo(i)?t[a]=AIs({},i):tPn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&ela(arguments[i],r);return t}var GVS=(e,t,r,{allOwnKeys:i}={})=>(ela(t,(n,a)=>{r&&LSe(n)?e[a]=Zca(n,r):e[a]=n},{allOwnKeys:i}),e),QVS=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),JVS=(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)},KVS=(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&&qIs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},YVS=(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},XVS=e=>{if(!e)return null;if(tPn(e))return e;let t=e.length;if(!sfp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},ZVS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&qIs(Uint8Array)),kVS=(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])}},eWS=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},tWS=y5t("HTMLFormElement"),rWS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),ofp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),iWS=y5t("RegExp"),ffp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};ela(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},nWS=e=>{ffp(e,(t,r)=>{if(LSe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(LSe(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+"'")})}})},aWS=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return tPn(e)?i(e):i(String(e).split(t)),r},oWS=()=>{},uWS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function sWS(e){return!!(e&&LSe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var cWS=e=>{let t=new Array(10),r=(i,n)=>{if(dPo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=tPn(i)?[]:{};return ela(i,(u,l)=>{let d=r(u,n+1);!kca(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},lWS=y5t("AsyncFunction"),fWS=e=>e&&(dPo(e)||LSe(e))&&LSe(e.then)&&LSe(e.catch),dfp=((e,t)=>e?setImmediate:t?((r,i)=>(kIi.addEventListener("message",({source:n,data:a})=>{n===kIi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),kIi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",LSe(kIi.postMessage)),dWS=typeof queueMicrotask<"u"?queueMicrotask.bind(kIi):typeof process<"u"&&process.nextTick||dfp,ds={isArray:tPn,isArrayBuffer:ufp,isBuffer:qVS,isFormData:FVS,isArrayBufferView:TVS,isString:CVS,isNumber:sfp,isBoolean:BVS,isObject:dPo,isPlainObject:cPo,isReadableStream:UVS,isRequest:VVS,isResponse:WVS,isHeaders:HVS,isUndefined:kca,isDate:xVS,isFile:IVS,isBlob:zVS,isRegExp:iWS,isFunction:LSe,isStream:NVS,isURLSearchParams:LVS,isTypedArray:ZVS,isFileList:RVS,forEach:ela,merge:AIs,extend:GVS,trim:$VS,stripBOM:QVS,inherits:JVS,toFlatObject:KVS,kindOf:lPo,kindOfTest:y5t,endsWith:YVS,toArray:XVS,forEachEntry:kVS,matchAll:eWS,isHTMLForm:tWS,hasOwnProperty:ofp,hasOwnProp:ofp,reduceDescriptors:ffp,freezeMethods:nWS,toObjectSet:aWS,toCamelCase:rWS,noop:oWS,toFiniteNumber:uWS,findKey:cfp,global:kIi,isContextDefined:lfp,isSpecCompliantForm:sWS,toJSONObject:cWS,isAsyncFn:lWS,isThenable:fWS,setImmediate:dfp,asap:dWS};function rPn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}ds.inherits(rPn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ds.toJSONObject(this.config),code:this.code,status:this.status}}});var pfp=rPn.prototype,_fp={};["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=>{_fp[e]={value:e}});Object.defineProperties(rPn,_fp);Object.defineProperty(pfp,"isAxiosError",{value:!0});rPn.from=(e,t,r,i,n,a)=>{let u=Object.create(pfp);return ds.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),rPn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var wp=rPn;var hfp=di(qia(),1),pPo=hfp.default;function TIs(e){return ds.isPlainObject(e)||ds.isArray(e)}function vfp(e){return ds.endsWith(e,"[]")?e.slice(0,-2):e}function yfp(e,t,r){return e?e.concat(t).map(function(n,a){return n=vfp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function pWS(e){return ds.isArray(e)&&!e.some(TIs)}var _WS=ds.toFlatObject(ds,{},null,function(t){return/^is[A-Z]/.test(t)});function hWS(e,t,r){if(!ds.isObject(e))throw new TypeError("target must be an object");t=t||new(pPo||FormData),r=ds.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,P){return!ds.isUndefined(P[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&ds.isSpecCompliantForm(t);if(!ds.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(ds.isDate(O))return O.toISOString();if(!d&&ds.isBlob(O))throw new wp("Blob is not supported. Use a Buffer instead.");return ds.isArrayBuffer(O)||ds.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,P){let E=O;if(O&&!P&&typeof O=="object"){if(ds.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(ds.isArray(O)&&pWS(O)||(ds.isFileList(O)||ds.endsWith(m,"[]"))&&(E=ds.toArray(O)))return m=vfp(m),E.forEach(function(q,D){!(ds.isUndefined(q)||q===null)&&t.append(u===!0?yfp([m],D,a):u===null?m:m+"[]",s(q))}),!1}return TIs(O)?!0:(t.append(yfp(P,m,a),s(O)),!1)}let c=[],b=Object.assign(_WS,{defaultVisitor:o,convertValue:s,isVisitable:TIs});function g(O,m){if(!ds.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),ds.forEach(O,function(E,A){(!(ds.isUndefined(E)||E===null)&&n.call(t,E,ds.isString(A)?A.trim():A,m,b))===!0&&g(E,m?m.concat(A):[A])}),c.pop()}}if(!ds.isObject(e))throw new TypeError("data must be an object");return g(e),t}var mfi=hWS;function bfp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function gfp(e,t){this._pairs=[],e&&mfi(e,this,t)}var Ofp=gfp.prototype;Ofp.append=function(t,r){this._pairs.push([t,r])};Ofp.toString=function(t){let r=t?function(i){return t.call(this,i,bfp)}:bfp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var mfp=gfp;function yWS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ezi(e,t,r){if(!t)return e;let i=r&&r.encode||yWS;ds.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=ds.isURLSearchParams(t)?t.toString():new mfp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var CIs=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ds.forEach(this.handlers,function(i){i!==null&&t(i)})}},BIs=CIs;var iPn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Sfp=di(require("crypto"),1);var Pfp=di(require("url"),1),jfp=Pfp.default.URLSearchParams;var xIs="abcdefghijklmnopqrstuvwxyz",wfp="0123456789",Dfp={DIGIT:wfp,ALPHA:xIs,ALPHA_DIGIT:xIs+xIs.toUpperCase()+wfp},vWS=(e=16,t=Dfp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);Sfp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},Efp={isNode:!0,classes:{URLSearchParams:jfp,FormData:pPo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:Dfp,generateString:vWS,protocols:["http","https","file","data"]};var RIs={};Eo(RIs,{hasBrowserEnv:()=>zIs,hasStandardBrowserEnv:()=>bWS,hasStandardBrowserWebWorkerEnv:()=>gWS,navigator:()=>IIs,origin:()=>OWS});var zIs=typeof window<"u"&&typeof document<"u",IIs=typeof navigator=="object"&&navigator||void 0,bWS=zIs&&(!IIs||["ReactNative","NativeScript","NS"].indexOf(IIs.product)<0),gWS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",OWS=zIs&&window.location.href||"http://localhost";var SM={...RIs,...Efp};function NIs(e,t){return mfi(e,new SM.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return SM.isNode&&ds.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function mWS(e){return ds.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function PWS(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 jWS(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&&ds.isArray(n)?n.length:u,d?(ds.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!ds.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&ds.isArray(n[u])&&(n[u]=PWS(n[u])),!l)}if(ds.isFormData(e)&&ds.isFunction(e.entries)){let r={};return ds.forEachEntry(e,(i,n)=>{t(mWS(i),n,r,0)}),r}return null}var _Po=jWS;function wWS(e,t,r){if(ds.isString(e))try{return(t||JSON.parse)(e),ds.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var FIs={transitional:iPn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=ds.isObject(t);if(a&&ds.isHTMLForm(t)&&(t=new FormData(t)),ds.isFormData(t))return n?JSON.stringify(_Po(t)):t;if(ds.isArrayBuffer(t)||ds.isBuffer(t)||ds.isStream(t)||ds.isFile(t)||ds.isBlob(t)||ds.isReadableStream(t))return t;if(ds.isArrayBufferView(t))return t.buffer;if(ds.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return NIs(t,this.formSerializer).toString();if((l=ds.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return mfi(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),wWS(t)):t}],transformResponse:[function(t){let r=this.transitional||FIs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(ds.isResponse(t)||ds.isReadableStream(t))return t;if(t&&ds.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?wp.from(l,wp.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:SM.classes.FormData,Blob:SM.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ds.forEach(["delete","get","head","post","put","patch"],e=>{FIs.headers[e]={}});var nPn=FIs;var SWS=ds.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Mfp=e=>{let t={},r,i,n;return e&&e.split(`
1704
+ `}write(t){let r=t.split(/\n/);this.height=r.length,this.rl.setPrompt(r.at(-1)),this.rl.output.rows===0&&this.rl.output.columns===0&&cmo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var Icp=di(Mcp(),1),zcp=di(BCs(),1),Rcp=di(Bcp(),1),YA=di(NSe(),1),Ncp=di(jsa(),1);var Nmo=di(NSe(),1),xcp=di(jsa(),1),Fmo=function(e,t,r){return typeof e[t]!="function"?(0,Nmo.of)(e):(0,Nmo.from)((0,xcp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var zca={isPlainObject:Icp.default,set:Rcp.default,get:zcp.default},$mn=class extends JIi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=zca.isPlainObject(r)?{...r}:{},zca.isPlainObject(t)&&(t=Object.values(t).every(n=>zca.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,YA.from)(t):t;return this.process=i.pipe((0,YA.concatMap)(this.processQuestion.bind(this)),(0,YA.publish)()),this.process.connect(),this.process.pipe((0,YA.reduce)((n,a)=>(zca.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,YA.defer)(()=>(0,YA.of)(t).pipe((0,YA.concatMap)(this.setDefaultType.bind(this)),(0,YA.concatMap)(this.filterIfRunnable.bind(this)),(0,YA.concatMap)(()=>Fmo(t,"message",this.answers)),(0,YA.concatMap)(()=>Fmo(t,"default",this.answers)),(0,YA.concatMap)(()=>Fmo(t,"choices",this.answers)),(0,YA.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,YA.defer)(()=>(0,YA.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,YA.defer)(()=>(0,YA.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&zca.get(this.answers,t.name)!==void 0)return(0,YA.empty)();if(t.when===!1)return(0,YA.empty)();if(typeof t.when!="function")return(0,YA.of)(t);let{answers:r}=this;return(0,YA.defer)(()=>(0,YA.from)((0,Ncp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,YA.filter)(i=>i!=null)))}};function Fcp(e){let t=function(r,i){let n;try{n=new $mn(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",yca),this.registerPrompt("input",NIi),this.registerPrompt("number",vca),this.registerPrompt("confirm",bca),this.registerPrompt("rawlist",gca),this.registerPrompt("expand",Oca),this.registerPrompt("checkbox",mca),this.registerPrompt("password",Pca),this.registerPrompt("editor",Cca)},t.restoreDefaultPrompts(),t}var Ixs=Fcp();function R9S(e,t){Ixs.registerPrompt(e,t)}function N9S(){Ixs.restoreDefaultPrompts()}var F9S={prompt:Ixs,ui:{BottomBar:Ica,Prompt:$mn},createPromptModule:Fcp,registerPrompt:R9S,restoreDefaultPrompts:N9S,Separator:Die},Lmo=F9S;var Klp=di(Lcp()),dVS="4.2.1",h5t;(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"})(h5t||(h5t={}));function pVS(e,t){if(!e)throw new Error(t)}function _VS(e){return e?.replace(/\/+$/,"")}async function hVS(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 yVS(){return new Date().getTime()}function Ulp(){return new Date().toISOString()}function Ylp(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var Qca=String.fromCharCode,Vlp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",tPo={};function vVS(e,t){if(!tPo[e]){tPo[e]={};for(let r=0;r<e.length;r++)tPo[e][e.charAt(r)]=r}return tPo[e][t]}var Jca={compressToBase64:function(e){if(e==null)return"";let t=Jca._compress(e,6,function(r){return Vlp.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:Jca._decompress(e.length,32,function(t){return vVS(Vlp,e.charAt(t))})},compress:function(e){return Jca._compress(e,16,function(t){return Qca(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,P;for(P=0;P<e.length;P+=1)if(d=e.charAt(P),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:Jca._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,P;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=Qca(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=Qca(b);break;case 2:return""}for(i[3]=P,c=P,n.push(P);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,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(P=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=Qca(b),P=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=Qca(b),P=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[P])s=i[P];else if(P===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,d),d++)}}},gIs=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 rPo="0123456789abcdef",iPo=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+=rPo.charAt(this.bytes[r]>>>4),t+=rPo.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+=rPo.charAt(this.bytes[r]>>>4),t+=rPo.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}},OIs=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??bVS()}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 iPo.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,iPo.ofInner(t)}},bVS=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Wlp,Hlp=()=>gVS().toString(),gVS=()=>(Wlp||(Wlp=new OIs)).generate(),nPo=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},Kca=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function $lp(e){return typeof e=="object"&&(e instanceof nPo||e instanceof Kca)}var mIs=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new gIs,this._isInitialized=!1,pVS(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=_VS(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:$lp},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(h5t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(h5t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(h5t.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=Hlp();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:Ulp(),uuid:i?.uuid?i.uuid:Hlp()};(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(h5t.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(h5t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Ylp(()=>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(h5t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(h5t.Queue)||[];this.setPersistedProperty(h5t.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:Ulp()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${yVS()}&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(Jca.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 Kca||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 hVS(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(d){throw new Kca(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new nPo(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(h5t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!$lp(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},PIs=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},jIs=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!jIs){let e=Llp();jIs=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 Xlp=jIs,OVS=1152921504606847e3,mVS=["is_not"],aPo=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},C2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},wIs=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||Xlp,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 C2?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 C2||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 C2("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 C2("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 C2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new C2("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=klp(l,n,this.cohorts,this.debugMode):s=Zlp(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&Glp(t.key,r)>a/100)}getMatchingVariant(t,r){let i=Glp(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 aPo("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 aPo&&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=Ylp(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function Glp(e,t,r=""){let i=(0,Klp.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/OVS}function Zlp(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 C2("Operator is_not_set is not supported")}else throw new C2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!mVS.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 Qlp(String(n))&&String(u).match(String(n))!==null;case"not_regex":return Qlp(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=PVS(String(n));if(s==null&&(s=Jlp(n)),s==null)throw new C2(`Invalid date: ${n}`);let o=Jlp(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new C2(`Unknown operator: ${a}`)}}function klp(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new C2("can't match cohort without a given cohort property value");let a=r[n];return efp(a,t,r,i)}function efp(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=efp(l,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof C2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new C2("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=klp(l,t,r,i):d=Zlp(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 C2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new C2("can't match cohort without a given cohort property value");return n==="AND"}}function Qlp(e){try{return new RegExp(e),!0}catch{return!1}}function Jlp(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 C2(`${e} is in an invalid date format`)}else throw new C2(`The date provided ${e} must be a string, number, or date object`)}function PVS(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 jVS=30*1e3,wVS=50*1e3,Zmn=class extends mIs{constructor(t,r={}){super(t,r),this._memoryStorage=new PIs,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new wIs({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:jVS,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||wVS}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):Xlp(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return dVS}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,P]of Object.entries(b))g[`$feature/${m}`]=P;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties: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}}},SIs=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})}};SIs.POSTHOG_ID_TAG="posthog_distinct_id";var oPo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new Zmn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.57.7",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var Yca=class{async sendEvent(){}async identify(){}async flush(){}};var kmn=require("fs/promises"),nfp=require("os"),afp=require("path");var tfp=di(require("crypto")),sPo=new Uint8Array(256),uPo=sPo.length;function DIs(){return uPo>sPo.length-16&&(tfp.default.randomFillSync(sPo),uPo=0),sPo.slice(uPo,uPo+=16)}var _V=[];for(let e=0;e<256;++e)_V.push((e+256).toString(16).slice(1));function rfp(e,t=0){return _V[e[t+0]]+_V[e[t+1]]+_V[e[t+2]]+_V[e[t+3]]+"-"+_V[e[t+4]]+_V[e[t+5]]+"-"+_V[e[t+6]]+_V[e[t+7]]+"-"+_V[e[t+8]]+_V[e[t+9]]+"-"+_V[e[t+10]]+_V[e[t+11]]+_V[e[t+12]]+_V[e[t+13]]+_V[e[t+14]]+_V[e[t+15]]}var ifp=di(require("crypto")),EIs={randomUUID:ifp.default.randomUUID};function SVS(e,t,r){if(EIs.randomUUID&&!t&&!e)return EIs.randomUUID();e=e||{};let i=e.random||(e.rng||DIs)();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 rfp(i)}var Tie=SVS;var DVS="id",EVS=".fern",Xca=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new Zmn(r),this.userId=t==null?void 0:zEs(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.57.7",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=es(Wl.of((0,nfp.homedir)()),uo.of(EVS),uo.of(DVS));await Cf(t)||(await(0,kmn.mkdir)((0,afp.dirname)(t),{recursive:!0}),await(0,kmn.writeFile)(t,Tie())),this.persistedDistinctId=(await(0,kmn.readFile)(t)).toString()}return this.persistedDistinctId}};var MIs;async function ePn(){return MIs==null&&(MIs=await MVS()),MIs}async function MVS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Yca;let r=await cyo();return r!=null?new Xca({token:r,posthogApiKey:e}):await syo()!=null?new oPo({posthogApiKey:e}):new Xca({token:void 0,posthogApiKey:e})}catch{return new Yca}}function Zca(e,t){return function(){return e.apply(t,arguments)}}var{toString:AVS}=Object.prototype,{getPrototypeOf:qIs}=Object,lPo=(e=>t=>{let r=AVS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),y5t=e=>(e=e.toLowerCase(),t=>lPo(t)===e),fPo=e=>t=>typeof t===e,{isArray:tPn}=Array,kca=fPo("undefined");function qVS(e){return e!==null&&!kca(e)&&e.constructor!==null&&!kca(e.constructor)&&LSe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var ufp=y5t("ArrayBuffer");function TVS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ufp(e.buffer),t}var CVS=fPo("string"),LSe=fPo("function"),sfp=fPo("number"),dPo=e=>e!==null&&typeof e=="object",BVS=e=>e===!0||e===!1,cPo=e=>{if(lPo(e)!=="object")return!1;let t=qIs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},xVS=y5t("Date"),IVS=y5t("File"),zVS=y5t("Blob"),RVS=y5t("FileList"),NVS=e=>dPo(e)&&LSe(e.pipe),FVS=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||LSe(e.append)&&((t=lPo(e))==="formdata"||t==="object"&&LSe(e.toString)&&e.toString()==="[object FormData]"))},LVS=y5t("URLSearchParams"),[UVS,VVS,WVS,HVS]=["ReadableStream","Request","Response","Headers"].map(y5t),$VS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ela(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),tPn(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 cfp(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 kIi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,lfp=e=>!kca(e)&&e!==kIi;function AIs(){let{caseless:e}=lfp(this)&&this||{},t={},r=(i,n)=>{let a=e&&cfp(t,n)||n;cPo(t[a])&&cPo(i)?t[a]=AIs(t[a],i):cPo(i)?t[a]=AIs({},i):tPn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&ela(arguments[i],r);return t}var GVS=(e,t,r,{allOwnKeys:i}={})=>(ela(t,(n,a)=>{r&&LSe(n)?e[a]=Zca(n,r):e[a]=n},{allOwnKeys:i}),e),QVS=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),JVS=(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)},KVS=(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&&qIs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},YVS=(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},XVS=e=>{if(!e)return null;if(tPn(e))return e;let t=e.length;if(!sfp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},ZVS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&qIs(Uint8Array)),kVS=(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])}},eWS=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},tWS=y5t("HTMLFormElement"),rWS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),ofp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),iWS=y5t("RegExp"),ffp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};ela(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},nWS=e=>{ffp(e,(t,r)=>{if(LSe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(LSe(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+"'")})}})},aWS=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return tPn(e)?i(e):i(String(e).split(t)),r},oWS=()=>{},uWS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function sWS(e){return!!(e&&LSe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var cWS=e=>{let t=new Array(10),r=(i,n)=>{if(dPo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=tPn(i)?[]:{};return ela(i,(u,l)=>{let d=r(u,n+1);!kca(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},lWS=y5t("AsyncFunction"),fWS=e=>e&&(dPo(e)||LSe(e))&&LSe(e.then)&&LSe(e.catch),dfp=((e,t)=>e?setImmediate:t?((r,i)=>(kIi.addEventListener("message",({source:n,data:a})=>{n===kIi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),kIi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",LSe(kIi.postMessage)),dWS=typeof queueMicrotask<"u"?queueMicrotask.bind(kIi):typeof process<"u"&&process.nextTick||dfp,ds={isArray:tPn,isArrayBuffer:ufp,isBuffer:qVS,isFormData:FVS,isArrayBufferView:TVS,isString:CVS,isNumber:sfp,isBoolean:BVS,isObject:dPo,isPlainObject:cPo,isReadableStream:UVS,isRequest:VVS,isResponse:WVS,isHeaders:HVS,isUndefined:kca,isDate:xVS,isFile:IVS,isBlob:zVS,isRegExp:iWS,isFunction:LSe,isStream:NVS,isURLSearchParams:LVS,isTypedArray:ZVS,isFileList:RVS,forEach:ela,merge:AIs,extend:GVS,trim:$VS,stripBOM:QVS,inherits:JVS,toFlatObject:KVS,kindOf:lPo,kindOfTest:y5t,endsWith:YVS,toArray:XVS,forEachEntry:kVS,matchAll:eWS,isHTMLForm:tWS,hasOwnProperty:ofp,hasOwnProp:ofp,reduceDescriptors:ffp,freezeMethods:nWS,toObjectSet:aWS,toCamelCase:rWS,noop:oWS,toFiniteNumber:uWS,findKey:cfp,global:kIi,isContextDefined:lfp,isSpecCompliantForm:sWS,toJSONObject:cWS,isAsyncFn:lWS,isThenable:fWS,setImmediate:dfp,asap:dWS};function rPn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}ds.inherits(rPn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ds.toJSONObject(this.config),code:this.code,status:this.status}}});var pfp=rPn.prototype,_fp={};["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=>{_fp[e]={value:e}});Object.defineProperties(rPn,_fp);Object.defineProperty(pfp,"isAxiosError",{value:!0});rPn.from=(e,t,r,i,n,a)=>{let u=Object.create(pfp);return ds.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),rPn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var wp=rPn;var hfp=di(qia(),1),pPo=hfp.default;function TIs(e){return ds.isPlainObject(e)||ds.isArray(e)}function vfp(e){return ds.endsWith(e,"[]")?e.slice(0,-2):e}function yfp(e,t,r){return e?e.concat(t).map(function(n,a){return n=vfp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function pWS(e){return ds.isArray(e)&&!e.some(TIs)}var _WS=ds.toFlatObject(ds,{},null,function(t){return/^is[A-Z]/.test(t)});function hWS(e,t,r){if(!ds.isObject(e))throw new TypeError("target must be an object");t=t||new(pPo||FormData),r=ds.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,P){return!ds.isUndefined(P[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&ds.isSpecCompliantForm(t);if(!ds.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(ds.isDate(O))return O.toISOString();if(!d&&ds.isBlob(O))throw new wp("Blob is not supported. Use a Buffer instead.");return ds.isArrayBuffer(O)||ds.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,P){let E=O;if(O&&!P&&typeof O=="object"){if(ds.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(ds.isArray(O)&&pWS(O)||(ds.isFileList(O)||ds.endsWith(m,"[]"))&&(E=ds.toArray(O)))return m=vfp(m),E.forEach(function(q,D){!(ds.isUndefined(q)||q===null)&&t.append(u===!0?yfp([m],D,a):u===null?m:m+"[]",s(q))}),!1}return TIs(O)?!0:(t.append(yfp(P,m,a),s(O)),!1)}let c=[],b=Object.assign(_WS,{defaultVisitor:o,convertValue:s,isVisitable:TIs});function g(O,m){if(!ds.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),ds.forEach(O,function(E,A){(!(ds.isUndefined(E)||E===null)&&n.call(t,E,ds.isString(A)?A.trim():A,m,b))===!0&&g(E,m?m.concat(A):[A])}),c.pop()}}if(!ds.isObject(e))throw new TypeError("data must be an object");return g(e),t}var mfi=hWS;function bfp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function gfp(e,t){this._pairs=[],e&&mfi(e,this,t)}var Ofp=gfp.prototype;Ofp.append=function(t,r){this._pairs.push([t,r])};Ofp.toString=function(t){let r=t?function(i){return t.call(this,i,bfp)}:bfp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var mfp=gfp;function yWS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ezi(e,t,r){if(!t)return e;let i=r&&r.encode||yWS;ds.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=ds.isURLSearchParams(t)?t.toString():new mfp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var CIs=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ds.forEach(this.handlers,function(i){i!==null&&t(i)})}},BIs=CIs;var iPn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Sfp=di(require("crypto"),1);var Pfp=di(require("url"),1),jfp=Pfp.default.URLSearchParams;var xIs="abcdefghijklmnopqrstuvwxyz",wfp="0123456789",Dfp={DIGIT:wfp,ALPHA:xIs,ALPHA_DIGIT:xIs+xIs.toUpperCase()+wfp},vWS=(e=16,t=Dfp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);Sfp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},Efp={isNode:!0,classes:{URLSearchParams:jfp,FormData:pPo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:Dfp,generateString:vWS,protocols:["http","https","file","data"]};var RIs={};Eo(RIs,{hasBrowserEnv:()=>zIs,hasStandardBrowserEnv:()=>bWS,hasStandardBrowserWebWorkerEnv:()=>gWS,navigator:()=>IIs,origin:()=>OWS});var zIs=typeof window<"u"&&typeof document<"u",IIs=typeof navigator=="object"&&navigator||void 0,bWS=zIs&&(!IIs||["ReactNative","NativeScript","NS"].indexOf(IIs.product)<0),gWS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",OWS=zIs&&window.location.href||"http://localhost";var SM={...RIs,...Efp};function NIs(e,t){return mfi(e,new SM.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return SM.isNode&&ds.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function mWS(e){return ds.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function PWS(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 jWS(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&&ds.isArray(n)?n.length:u,d?(ds.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!ds.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&ds.isArray(n[u])&&(n[u]=PWS(n[u])),!l)}if(ds.isFormData(e)&&ds.isFunction(e.entries)){let r={};return ds.forEachEntry(e,(i,n)=>{t(mWS(i),n,r,0)}),r}return null}var _Po=jWS;function wWS(e,t,r){if(ds.isString(e))try{return(t||JSON.parse)(e),ds.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var FIs={transitional:iPn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=ds.isObject(t);if(a&&ds.isHTMLForm(t)&&(t=new FormData(t)),ds.isFormData(t))return n?JSON.stringify(_Po(t)):t;if(ds.isArrayBuffer(t)||ds.isBuffer(t)||ds.isStream(t)||ds.isFile(t)||ds.isBlob(t)||ds.isReadableStream(t))return t;if(ds.isArrayBufferView(t))return t.buffer;if(ds.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return NIs(t,this.formSerializer).toString();if((l=ds.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return mfi(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),wWS(t)):t}],transformResponse:[function(t){let r=this.transitional||FIs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(ds.isResponse(t)||ds.isReadableStream(t))return t;if(t&&ds.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?wp.from(l,wp.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:SM.classes.FormData,Blob:SM.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ds.forEach(["delete","get","head","post","put","patch"],e=>{FIs.headers[e]={}});var nPn=FIs;var SWS=ds.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Mfp=e=>{let t={},r,i,n;return e&&e.split(`
1705
1705
  `).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&SWS[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var Afp=Symbol("internals");function tla(e){return e&&String(e).trim().toLowerCase()}function hPo(e){return e===!1||e==null?e:ds.isArray(e)?e.map(hPo):String(e)}function DWS(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 EWS=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function LIs(e,t,r,i,n){if(ds.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!ds.isString(t)){if(ds.isString(i))return t.indexOf(i)!==-1;if(ds.isRegExp(i))return i.test(t)}}function MWS(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function AWS(e,t){let r=ds.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,u){return this[i].call(this,t,n,a,u)},configurable:!0})})}var aPn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(l,d,s){let o=tla(d);if(!o)throw new Error("header name must be a non-empty string");let c=ds.findKey(n,o);(!c||n[c]===void 0||s===!0||s===void 0&&n[c]!==!1)&&(n[c||d]=hPo(l))}let u=(l,d)=>ds.forEach(l,(s,o)=>a(s,o,d));if(ds.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(ds.isString(t)&&(t=t.trim())&&!EWS(t))u(Mfp(t),r);else if(ds.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=tla(t),t){let i=ds.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return DWS(n);if(ds.isFunction(r))return r.call(this,n,i);if(ds.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=tla(t),t){let i=ds.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||LIs(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=tla(u),u){let l=ds.findKey(i,u);l&&(!r||LIs(i,i[l],l,r))&&(delete i[l],n=!0)}}return ds.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||LIs(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return ds.forEach(this,(n,a)=>{let u=ds.findKey(i,a);if(u){r[u]=hPo(n),delete r[a];return}let l=t?MWS(a):String(a).trim();l!==a&&delete r[a],r[l]=hPo(n),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return ds.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&ds.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
1706
1706
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[Afp]=this[Afp]={accessors:{}}).accessors,n=this.prototype;function a(u){let l=tla(u);i[l]||(AWS(n,u),i[l]=!0)}return ds.isArray(t)?t.forEach(a):a(t),this}};aPn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ds.reduceDescriptors(aPn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});ds.freezeMethods(aPn);var pz=aPn;function rla(e,t){let r=this||nPn,i=t||r,n=pz.from(i.headers),a=i.data;return ds.forEach(e,function(l){a=l.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function ila(e){return!!(e&&e.__CANCEL__)}function qfp(e,t,r){wp.call(this,e??"canceled",wp.ERR_CANCELED,t,r),this.name="CanceledError"}ds.inherits(qfp,wp,{__CANCEL__:!0});var USe=qfp;function WYt(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new wp("Request failed with status code "+r.status,[wp.ERR_BAD_REQUEST,wp.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function UIs(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function VIs(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function tzi(e,t,r){let i=!UIs(t);return e&&i||r==!1?VIs(e,t):t}var Gfp=di(Nca(),1),Qfp=di(require("http"),1),Jfp=di(require("https"),1),Kfp=di(require("util"),1),Yfp=di(Kxs(),1),BJr=di(require("zlib"),1);var rzi="1.8.2";function nla(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var qWS=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function WIs(e,t,r){let i=r&&r.Blob||SM.classes.Blob,n=nla(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=qWS.exec(e);if(!a)throw new wp("Invalid URL",wp.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 wp("Blob is not supported",wp.ERR_NOT_SUPPORT);return new i([s],{type:u})}return s}throw new wp("Unsupported protocol "+n,wp.ERR_NOT_SUPPORT)}var izi=di(require("stream"),1);var Tfp=di(require("stream"),1);var HIs=Symbol("internals"),$Is=class extends Tfp.default.Transform{constructor(t){t=ds.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!ds.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[HIs]={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[HIs];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[HIs],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),P=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&&(P=g.subarray(E),g=g.subarray(0,E)),c(g,P?()=>{process.nextTick(O,null,P)}:O)};b(t,function g(O,m){if(O)return i(O);m?b(m,g):i(null)})}},GIs=$Is;var Xfp=require("events");var Bfp=di(require("util"),1),xfp=require("stream");var{asyncIterator:Cfp}=Symbol,TWS=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[Cfp]?yield*e[Cfp]():yield e},yPo=TWS;var CWS=SM.ALPHABET.ALPHA_DIGIT+"-_",ala=typeof TextEncoder=="function"?new TextEncoder:new Bfp.default.TextEncoder,Pfi=`\r
1707
1707
  `,BWS=ala.encode(Pfi),xWS=2,QIs=class{constructor(t,r){let{escapeName:i}=this.constructor,n=ds.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${Pfi}`;n?r=ala.encode(String(r).replace(/\r?\n|\r\n?/g,Pfi)):a+=`Content-Type: ${r.type||"application/octet-stream"}${Pfi}`,this.headers=ala.encode(a+Pfi),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+xWS,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;ds.isTypedArray(t)?yield t:yield*yPo(t),yield BWS}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},IWS=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+SM.generateString(n,CWS)}=r||{};if(!ds.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let u=ala.encode("--"+a+Pfi),l=ala.encode("--"+a+"--"+Pfi+Pfi),d=l.byteLength,s=Array.from(e.entries()).map(([c,b])=>{let g=new QIs(c,b);return d+=g.size,g});d+=u.byteLength*s.length,d=ds.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),xfp.Readable.from(async function*(){for(let c of s)yield u,yield*c.encode();yield l}())},Ifp=IWS;var zfp=di(require("stream"),1),JIs=class extends zfp.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)}},Rfp=JIs;var zWS=(e,t)=>ds.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,Nfp=zWS;function RWS(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 Ffp=RWS;function NWS(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 Lfp=NWS;var CJr=(e,t,r=3)=>{let i=0,n=Ffp(50,250);return Lfp(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)},oPn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},uPn=e=>(...t)=>ds.asap(()=>e(...t));var Ufp={flush:BJr.default.constants.Z_SYNC_FLUSH,finishFlush:BJr.default.constants.Z_SYNC_FLUSH},FWS={flush:BJr.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:BJr.default.constants.BROTLI_OPERATION_FLUSH},Vfp=ds.isFunction(BJr.default.createBrotliDecompress),{http:LWS,https:UWS}=Yfp.default,VWS=/https:?/,Wfp=SM.protocols.map(e=>e+":"),Hfp=(e,[t,r])=>(e.on("end",r).on("error",r),t);function WWS(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function Zfp(e,t,r){let i=t;if(!i&&i!==!1){let n=Gfp.default.getProxyForUrl(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){Zfp(a,t,a.href)}}var HWS=typeof process<"u"&&ds.kindOf(process)==="process",$WS=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)}),GWS=({address:e,family:t})=>{if(!ds.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},$fp=(e,t)=>GWS(ds.isObject(e)?e:{address:e,family:t}),kfp=HWS&&function(t){return $WS(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 Se=Nfp(l,Qe=>ds.isArray(Qe)?Qe:[Qe]);l=(Qe,St,Ee)=>{Se(Qe,St,(Te,xt,Pe)=>{if(Te)return Ee(Te);let Ot=ds.isArray(xt)?xt.map(at=>$fp(at)):[$fp(xt,Pe)];St.all?Ee(Te,Ot):Ee(Te,Ot[0].address,Ot[0].family)})}}let m=new Xfp.EventEmitter,P=()=>{t.cancelToken&&t.cancelToken.unsubscribe(E),t.signal&&t.signal.removeEventListener("abort",E),m.removeAllListeners()};a((Se,Qe)=>{b=!0,Qe&&(g=!0,P())});function E(Se){m.emit("abort",!Se||Se.type?new USe(null,t,O):Se)}m.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(E),t.signal&&(t.signal.aborted?E():t.signal.addEventListener("abort",E)));let A=tzi(t.baseURL,t.url,t.allowAbsoluteUrls),q=new URL(A,SM.hasBrowserEnv?SM.origin:void 0),D=q.protocol||Wfp[0];if(D==="data:"){let Se;if(c!=="GET")return WYt(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{Se=WIs(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Qe){throw wp.from(Qe,wp.ERR_BAD_REQUEST,t)}return s==="text"?(Se=Se.toString(o),(!o||o==="utf8")&&(Se=ds.stripBOM(Se))):s==="stream"&&(Se=izi.default.Readable.from(Se)),WYt(i,n,{data:Se,status:200,statusText:"OK",headers:new pz,config:t})}if(Wfp.indexOf(D)===-1)return n(new wp("Unsupported protocol "+D,wp.ERR_BAD_REQUEST,t));let C=pz.from(t.headers).normalize();C.set("User-Agent","axios/"+rzi,!1);let{onUploadProgress:z,onDownloadProgress:$}=t,x=t.maxRate,L,V;if(ds.isSpecCompliantForm(u)){let Se=C.getContentType(/boundary=([-_\w\d]{10,70})/i);u=Ifp(u,Qe=>{C.set(Qe)},{tag:`axios-${rzi}-boundary`,boundary:Se&&Se[1]||void 0})}else if(ds.isFormData(u)&&ds.isFunction(u.getHeaders)){if(C.set(u.getHeaders()),!C.hasContentLength())try{let Se=await Kfp.default.promisify(u.getLength).call(u);Number.isFinite(Se)&&Se>=0&&C.setContentLength(Se)}catch{}}else if(ds.isBlob(u)||ds.isFile(u))u.size&&C.setContentType(u.type||"application/octet-stream"),C.setContentLength(u.size||0),u=izi.default.Readable.from(yPo(u));else if(u&&!ds.isStream(u)){if(!Buffer.isBuffer(u))if(ds.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(ds.isString(u))u=Buffer.from(u,"utf-8");else return n(new wp("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",wp.ERR_BAD_REQUEST,t));if(C.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new wp("Request body larger than maxBodyLength limit",wp.ERR_BAD_REQUEST,t))}let Z=ds.toFiniteNumber(C.getContentLength());ds.isArray(x)?(L=x[0],V=x[1]):L=V=x,u&&(z||L)&&(ds.isStream(u)||(u=izi.default.Readable.from(u,{objectMode:!1})),u=izi.default.pipeline([u,new GIs({maxRate:ds.toFiniteNumber(L)})],ds.noop),z&&u.on("progress",Hfp(u,oPn(Z,CJr(uPn(z),!1,3)))));let K;if(t.auth){let Se=t.auth.username||"",Qe=t.auth.password||"";K=Se+":"+Qe}if(!K&&q.username){let Se=q.username,Qe=q.password;K=Se+":"+Qe}K&&C.delete("authorization");let X;try{X=ezi(q.pathname+q.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Se){let Qe=new Error(Se.message);return Qe.config=t,Qe.url=t.url,Qe.exists=!0,n(Qe)}C.set("Accept-Encoding","gzip, compress, deflate"+(Vfp?", br":""),!1);let le={path:X,method:c,headers:C.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:K,protocol:D,family:d,beforeRedirect:WWS,beforeRedirects:{}};!ds.isUndefined(l)&&(le.lookup=l),t.socketPath?le.socketPath=t.socketPath:(le.hostname=q.hostname.startsWith("[")?q.hostname.slice(1,-1):q.hostname,le.port=q.port,Zfp(le,t.proxy,D+"//"+q.hostname+(q.port?":"+q.port:"")+le.path));let ge,_e=VWS.test(le.protocol);if(le.agent=_e?t.httpsAgent:t.httpAgent,t.transport?ge=t.transport:t.maxRedirects===0?ge=_e?Jfp.default:Qfp.default:(t.maxRedirects&&(le.maxRedirects=t.maxRedirects),t.beforeRedirect&&(le.beforeRedirects.config=t.beforeRedirect),ge=_e?UWS:LWS),t.maxBodyLength>-1?le.maxBodyLength=t.maxBodyLength:le.maxBodyLength=1/0,t.insecureHTTPParser&&(le.insecureHTTPParser=t.insecureHTTPParser),O=ge.request(le,function(Qe){if(O.destroyed)return;let St=[Qe],Ee=+Qe.headers["content-length"];if($||V){let at=new GIs({maxRate:ds.toFiniteNumber(V)});$&&at.on("progress",Hfp(at,oPn(Ee,CJr(uPn($),!0,3)))),St.push(at)}let Te=Qe,xt=Qe.req||O;if(t.decompress!==!1&&Qe.headers["content-encoding"])switch((c==="HEAD"||Qe.statusCode===204)&&delete Qe.headers["content-encoding"],(Qe.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":St.push(BJr.default.createUnzip(Ufp)),delete Qe.headers["content-encoding"];break;case"deflate":St.push(new Rfp),St.push(BJr.default.createUnzip(Ufp)),delete Qe.headers["content-encoding"];break;case"br":Vfp&&(St.push(BJr.default.createBrotliDecompress(FWS)),delete Qe.headers["content-encoding"])}Te=St.length>1?izi.default.pipeline(St,ds.noop):St[0];let Pe=izi.default.finished(Te,()=>{Pe(),P()}),Ot={status:Qe.statusCode,statusText:Qe.statusMessage,headers:new pz(Qe.headers),config:t,request:xt};if(s==="stream")Ot.data=Te,WYt(i,n,Ot);else{let at=[],he=0;Te.on("data",function(bt){at.push(bt),he+=bt.length,t.maxContentLength>-1&&he>t.maxContentLength&&(g=!0,Te.destroy(),n(new wp("maxContentLength size of "+t.maxContentLength+" exceeded",wp.ERR_BAD_RESPONSE,t,xt)))}),Te.on("aborted",function(){if(g)return;let bt=new wp("stream has been aborted",wp.ERR_BAD_RESPONSE,t,xt);Te.destroy(bt),n(bt)}),Te.on("error",function(bt){O.destroyed||n(wp.from(bt,null,t,xt))}),Te.on("end",function(){try{let bt=at.length===1?at[0]:Buffer.concat(at);s!=="arraybuffer"&&(bt=bt.toString(o),(!o||o==="utf8")&&(bt=ds.stripBOM(bt))),Ot.data=bt}catch(bt){return n(wp.from(bt,null,t,Ot.request,Ot))}WYt(i,n,Ot)})}m.once("abort",at=>{Te.destroyed||(Te.emit("error",at),Te.destroy())})}),m.once("abort",Se=>{n(Se),O.destroy(Se)}),O.on("error",function(Qe){n(wp.from(Qe,null,t,O))}),O.on("socket",function(Qe){Qe.setKeepAlive(!0,1e3*60)}),t.timeout){let Se=parseInt(t.timeout,10);if(Number.isNaN(Se)){n(new wp("error trying to parse `config.timeout` to int",wp.ERR_BAD_OPTION_VALUE,t,O));return}O.setTimeout(Se,function(){if(b)return;let St=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",Ee=t.transitional||iPn;t.timeoutErrorMessage&&(St=t.timeoutErrorMessage),n(new wp(St,Ee.clarifyTimeoutError?wp.ETIMEDOUT:wp.ECONNABORTED,t,O)),E()})}if(ds.isStream(u)){let Se=!1,Qe=!1;u.on("end",()=>{Se=!0}),u.once("error",St=>{Qe=!0,O.destroy(St)}),u.on("close",()=>{!Se&&!Qe&&E(new USe("Request stream has been aborted",t,O))}),u.pipe(O)}else O.end(u)})};var edp=SM.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,SM.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(SM.origin),SM.navigator&&/(msie|trident)/i.test(SM.navigator.userAgent)):()=>!0;var tdp=SM.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];ds.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),ds.isString(i)&&u.push("path="+i),ds.isString(n)&&u.push("domain="+n),a===!0&&u.push("secure"),document.cookie=u.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var rdp=e=>e instanceof pz?{...e}:e;function v5t(e,t){t=t||{};let r={};function i(s,o,c,b){return ds.isPlainObject(s)&&ds.isPlainObject(o)?ds.merge.call({caseless:b},s,o):ds.isPlainObject(o)?ds.merge({},o):ds.isArray(o)?o.slice():o}function n(s,o,c,b){if(ds.isUndefined(o)){if(!ds.isUndefined(s))return i(void 0,s,c,b)}else return i(s,o,c,b)}function a(s,o){if(!ds.isUndefined(o))return i(void 0,o)}function u(s,o){if(ds.isUndefined(o)){if(!ds.isUndefined(s))return i(void 0,s)}else return i(void 0,o)}function l(s,o,c){if(c in t)return i(s,o);if(c in e)return i(void 0,s)}let d={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:l,headers:(s,o,c)=>n(rdp(s),rdp(o),c,!0)};return ds.forEach(Object.keys(Object.assign({},e,t)),function(o){let c=d[o]||n,b=c(e[o],t[o],o);ds.isUndefined(b)&&c!==l||(r[o]=b)}),r}var vPo=e=>{let t=v5t({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:l}=t;t.headers=u=pz.from(u),t.url=ezi(tzi(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(ds.isFormData(r)){if(SM.hasStandardBrowserEnv||SM.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(SM.hasStandardBrowserEnv&&(i&&ds.isFunction(i)&&(i=i(t)),i||i!==!1&&edp(t.url))){let s=n&&a&&tdp.read(a);s&&u.set(n,s)}return t};var QWS=typeof XMLHttpRequest<"u",idp=QWS&&function(e){return new Promise(function(r,i){let n=vPo(e),a=n.data,u=pz.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 P=new XMLHttpRequest;P.open(n.method.toUpperCase(),n.url,!0),P.timeout=n.timeout;function E(){if(!P)return;let q=pz.from("getAllResponseHeaders"in P&&P.getAllResponseHeaders()),C={data:!l||l==="text"||l==="json"?P.responseText:P.response,status:P.status,statusText:P.statusText,headers:q,config:e,request:P};WYt(function($){r($),m()},function($){i($),m()},C),P=null}"onloadend"in P?P.onloadend=E:P.onreadystatechange=function(){!P||P.readyState!==4||P.status===0&&!(P.responseURL&&P.responseURL.indexOf("file:")===0)||setTimeout(E)},P.onabort=function(){P&&(i(new wp("Request aborted",wp.ECONNABORTED,e,P)),P=null)},P.onerror=function(){i(new wp("Network Error",wp.ERR_NETWORK,e,P)),P=null},P.ontimeout=function(){let D=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",C=n.transitional||iPn;n.timeoutErrorMessage&&(D=n.timeoutErrorMessage),i(new wp(D,C.clarifyTimeoutError?wp.ETIMEDOUT:wp.ECONNABORTED,e,P)),P=null},a===void 0&&u.setContentType(null),"setRequestHeader"in P&&ds.forEach(u.toJSON(),function(D,C){P.setRequestHeader(C,D)}),ds.isUndefined(n.withCredentials)||(P.withCredentials=!!n.withCredentials),l&&l!=="json"&&(P.responseType=n.responseType),s&&([b,O]=CJr(s,!0),P.addEventListener("progress",b)),d&&P.upload&&([c,g]=CJr(d),P.upload.addEventListener("progress",c),P.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(o=q=>{P&&(i(!q||q.type?new USe(null,e,P):q),P.abort(),P=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let A=nla(n.url);if(A&&SM.protocols.indexOf(A)===-1){i(new wp("Unsupported protocol "+A+":",wp.ERR_BAD_REQUEST,e));return}P.send(a||null)})};var JWS=(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 wp?o:new USe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new wp(`timeout ${t} of ms exceeded`,wp.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=()=>ds.asap(l),d}},ndp=JWS;var KWS=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},YWS=async function*(e,t){for await(let r of XWS(e))yield*KWS(r,t)},XWS=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()}},KIs=(e,t,r,i)=>{let n=YWS(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 gPo=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",odp=gPo&&typeof ReadableStream=="function",ZWS=gPo&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),udp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},kWS=odp&&udp(()=>{let e=!1,t=new Request(SM.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),adp=64*1024,YIs=odp&&udp(()=>ds.isReadableStream(new Response("").body)),bPo={stream:YIs&&(e=>e.body)};gPo&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!bPo[t]&&(bPo[t]=ds.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new wp(`Response type '${t}' is not supported`,wp.ERR_NOT_SUPPORT,i)})})})(new Response);var eHS=async e=>{if(e==null)return 0;if(ds.isBlob(e))return e.size;if(ds.isSpecCompliantForm(e))return(await new Request(SM.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(ds.isArrayBufferView(e)||ds.isArrayBuffer(e))return e.byteLength;if(ds.isURLSearchParams(e)&&(e=e+""),ds.isString(e))return(await ZWS(e)).byteLength},tHS=async(e,t)=>{let r=ds.toFiniteNumber(e.getContentLength());return r??eHS(t)},sdp=gPo&&(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}=vPo(e);s=s?(s+"").toLowerCase():"text";let g=ndp([n,a&&a.toAbortSignal()],u),O,m=g&&g.unsubscribe&&(()=>{g.unsubscribe()}),P;try{if(d&&kWS&&r!=="get"&&r!=="head"&&(P=await tHS(o,i))!==0){let C=new Request(t,{method:"POST",body:i,duplex:"half"}),z;if(ds.isFormData(i)&&(z=C.headers.get("content-type"))&&o.setContentType(z),C.body){let[$,x]=oPn(P,CJr(uPn(d)));i=KIs(C.body,adp,$,x)}}ds.isString(c)||(c=c?"include":"omit");let E="credentials"in Request.prototype;O=new Request(t,{...b,signal:g,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:i,duplex:"half",credentials:E?c:void 0});let A=await fetch(O),q=YIs&&(s==="stream"||s==="response");if(YIs&&(l||q&&m)){let C={};["status","statusText","headers"].forEach(L=>{C[L]=A[L]});let z=ds.toFiniteNumber(A.headers.get("content-length")),[$,x]=l&&oPn(z,CJr(uPn(l),!0))||[];A=new Response(KIs(A.body,adp,$,()=>{x&&x(),m&&m()}),C)}s=s||"text";let D=await bPo[ds.findKey(bPo,s)||"text"](A,e);return!q&&m&&m(),await new Promise((C,z)=>{WYt(C,z,{data:D,headers:pz.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 wp("Network Error",wp.ERR_NETWORK,e,O),{cause:E.cause||E}):wp.from(E,E&&E.code,e,O)}});var XIs={http:kfp,xhr:idp,fetch:sdp};ds.forEach(XIs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var cdp=e=>`- ${e}`,rHS=e=>ds.isFunction(e)||e===null||e===!1,OPo={getAdapter:e=>{e=ds.isArray(e)?e:[e];let{length:t}=e,r,i,n={};for(let a=0;a<t;a++){r=e[a];let u;if(i=r,!rHS(r)&&(i=XIs[(u=String(r)).toLowerCase()],i===void 0))throw new wp(`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 :
@@ -1939,7 +1939,7 @@ ${q}${A}${D}${LFp.default.cursorHide}`});var Y_a=di(axi(),1);function WLs(e,t){i
1939
1939
  Run ${Js.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
1940
1940
  Run ${Js.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),cPn(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function eUs({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!l3p(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+=`
1941
1941
  ${await BMD(l.generatorName)} (${l.apiName!=null?"API: "+l.apiName+", ":""}Group: ${l.generatorGroup}) `+Js.dim(l.currentVersion)+Js.reset(" \u2192 ")+Js.green(l.latestVersion);return n+=`
1942
- `,i?cPn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function BMD(e){let r=await new c3p.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 xMD({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await d3p({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=Xsi(o.name,c),g=await iJt({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 d3p({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=Xsi(s.name,o),b=await iJt({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 d3p({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 L8t({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 p3p(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=Vie(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 Oqo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await xMD({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(...p3p(s,d,t.logger));else u.push(...p3p(l.versions,void 0,t.logger))}return u}var nha=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 X1n=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Z1n=e=>e!==null&&typeof e=="object";var aha=(...e)=>{for(let t of e)if((!Z1n(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return iUs({},...e)},tUs=(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 mqo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:iUs(e[r]??[],t[r]??[])}var rUs=(e={},t={})=>({beforeRequest:mqo(e,t,"beforeRequest"),beforeRetry:mqo(e,t,"beforeRetry"),afterResponse:mqo(e,t,"afterResponse"),beforeError:mqo(e,t,"beforeError")}),iUs=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(Z1n(n)){for(let[a,u]of Object.entries(n))Z1n(u)&&a in t&&(u=iUs(t[a],u)),t={...t,[a]:u};Z1n(n.hooks)&&(i=rUs(i,n.hooks),t.hooks=i),Z1n(n.headers)&&(r=tUs(r,n.headers),t.headers=r)}return t};var _3p=(()=>{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})(),h3p=typeof globalThis.AbortController=="function",y3p=typeof globalThis.ReadableStream=="function",v3p=typeof globalThis.FormData=="function",Pqo=["get","post","put","patch","head","delete"],IMD=()=>{};IMD();var b3p={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},jqo=2147483647,wqo=Symbol("stop"),g3p={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},O3p={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 P3p=e=>Pqo.includes(e)?e.toUpperCase():e,zMD=["get","put","head","delete","options","trace"],RMD=[408,413,429,500,502,503,504],NMD=[413,429,503],m3p={limit:2,methods:zMD,statusCodes:RMD,afterStatusCodes:NMD,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},j3p=(e={})=>{if(typeof e=="number")return{...m3p,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{...m3p,...e}};async function nUs(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new X1n(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function aUs(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 w3p=(e,t)=>{let r={};for(let i in t)!(i in O3p)&&!(i in g3p)&&!(i in e)&&(r[i]=t[i]);return r};var oha=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>jqo)throw new RangeError(`The \`timeout\` option cannot be greater than ${jqo}`);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 nha(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(!y3p)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(b3p))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:tUs(this._input.headers,r.headers),hooks:rUs({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:P3p(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:j3p(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(h3p){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(_3p&&(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);(v3p&&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 X1n)throw t;if(t instanceof nha){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),jqo);if(this._retryCount<1)throw r;await aUs(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})===wqo)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=w3p(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):nUs(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 oUs=e=>{let t=(r,i)=>oha.create(r,aha(e,i));for(let r of Pqo)t[r]=(i,n)=>oha.create(i,aha(e,n,{method:r}));return t.create=r=>oUs(aha(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),oUs(aha(e,r))),t.stop=wqo,t},FMD=oUs(),S3p=FMD;var J3p=di(Q3p(),1);function fUs(e){let t=(0,J3p.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var V7p=di(U7p(),1),W7p=di(axi(),1),SUs=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},DUs=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function EUs(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??fUs(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,V7p.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 S3p(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new SUs(e):c}if(t.allVersions)return s;let o=new DUs(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=W7p.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 dha(e,t){let{version:r}=await EUs(e.toLowerCase(),t);return r}async function Qdi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:dha(e.packageName,{version:t?"prerelease":"latest"})}var H7p=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],zqo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=V0.Info;constructor(t){this.ttyAwareLogger=new gqo(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.57.6"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Js.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new ure}failWithoutThrowing(t,r){this.didSucceed=!1,hqo({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await ePn()).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 f3p({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1942
+ `,i?cPn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function BMD(e){let r=await new c3p.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 xMD({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await d3p({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=Xsi(o.name,c),g=await iJt({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 d3p({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=Xsi(s.name,o),b=await iJt({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 d3p({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 L8t({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 p3p(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=Vie(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 Oqo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await xMD({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(...p3p(s,d,t.logger));else u.push(...p3p(l.versions,void 0,t.logger))}return u}var nha=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 X1n=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Z1n=e=>e!==null&&typeof e=="object";var aha=(...e)=>{for(let t of e)if((!Z1n(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return iUs({},...e)},tUs=(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 mqo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:iUs(e[r]??[],t[r]??[])}var rUs=(e={},t={})=>({beforeRequest:mqo(e,t,"beforeRequest"),beforeRetry:mqo(e,t,"beforeRetry"),afterResponse:mqo(e,t,"afterResponse"),beforeError:mqo(e,t,"beforeError")}),iUs=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(Z1n(n)){for(let[a,u]of Object.entries(n))Z1n(u)&&a in t&&(u=iUs(t[a],u)),t={...t,[a]:u};Z1n(n.hooks)&&(i=rUs(i,n.hooks),t.hooks=i),Z1n(n.headers)&&(r=tUs(r,n.headers),t.headers=r)}return t};var _3p=(()=>{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})(),h3p=typeof globalThis.AbortController=="function",y3p=typeof globalThis.ReadableStream=="function",v3p=typeof globalThis.FormData=="function",Pqo=["get","post","put","patch","head","delete"],IMD=()=>{};IMD();var b3p={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},jqo=2147483647,wqo=Symbol("stop"),g3p={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},O3p={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 P3p=e=>Pqo.includes(e)?e.toUpperCase():e,zMD=["get","put","head","delete","options","trace"],RMD=[408,413,429,500,502,503,504],NMD=[413,429,503],m3p={limit:2,methods:zMD,statusCodes:RMD,afterStatusCodes:NMD,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},j3p=(e={})=>{if(typeof e=="number")return{...m3p,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{...m3p,...e}};async function nUs(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new X1n(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function aUs(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 w3p=(e,t)=>{let r={};for(let i in t)!(i in O3p)&&!(i in g3p)&&!(i in e)&&(r[i]=t[i]);return r};var oha=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>jqo)throw new RangeError(`The \`timeout\` option cannot be greater than ${jqo}`);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 nha(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(!y3p)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(b3p))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:tUs(this._input.headers,r.headers),hooks:rUs({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:P3p(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:j3p(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(h3p){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(_3p&&(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);(v3p&&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 X1n)throw t;if(t instanceof nha){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),jqo);if(this._retryCount<1)throw r;await aUs(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})===wqo)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=w3p(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):nUs(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 oUs=e=>{let t=(r,i)=>oha.create(r,aha(e,i));for(let r of Pqo)t[r]=(i,n)=>oha.create(i,aha(e,n,{method:r}));return t.create=r=>oUs(aha(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),oUs(aha(e,r))),t.stop=wqo,t},FMD=oUs(),S3p=FMD;var J3p=di(Q3p(),1);function fUs(e){let t=(0,J3p.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var V7p=di(U7p(),1),W7p=di(axi(),1),SUs=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},DUs=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function EUs(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??fUs(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,V7p.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 S3p(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new SUs(e):c}if(t.allVersions)return s;let o=new DUs(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=W7p.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 dha(e,t){let{version:r}=await EUs(e.toLowerCase(),t);return r}async function Qdi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:dha(e.packageName,{version:t?"prerelease":"latest"})}var H7p=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],zqo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=V0.Info;constructor(t){this.ttyAwareLogger=new gqo(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.57.7"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Js.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new ure}failWithoutThrowing(t,r){this.didSucceed=!1,hqo({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await ePn()).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 f3p({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1943
1943
  `)||(r+=`
1944
1944
  `),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=B_s(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new X_a(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 ure}finally{i.finish()}return n}async instrumentPostHogEvent(t){(await ePn()).sendEvent(t)}logger=vQr(this.log.bind(this));constructTaskInitForWorkspace(t){let r=$7p(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?$7p(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=H7p[this.numTasks++%H7p.length],u=Js.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===BC.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=>_si.indexOf(i.level)>=_si.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===V0.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 Qdi({cliEnvironment:this.environment,includePreReleases:t}),i=Vie(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await Oqo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await RLs({message:t,default:r})}async getInput(t){return await NLs({message:t.message,default:t.default})}};function $7p(e){return`[${e}]:`}var ft_=require("fs/promises");function Wie({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Js.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Js.dim(r)),i.join(`
1945
1945
  `)}var gKp=require("fs/promises");var Y5t=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 oDe=class extends Y5t{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 pha=class{context;constructor(t){this.context=t}};var Rqo=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,l]of Object.entries(i.files)){let d=n!=null?Yh.of(`${n}${t8t}${u}`):Yh.of(u);t[d]=l}let a=Object.keys(i.directories).sort();for(let u of a){let l=n!=null?`${n}${t8t}${u}`:u,d=i.directories[u];r(d,l)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(t8t))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Yh.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 dNi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new Rqo,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 LQr(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"]))HAD(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??L0((QBe(r)+"/"+uBi(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Yh.of(QN))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=Ato(QBe(rvn.of(`/${t}`)),rvn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=Ato(QBe(rvn.of(`/${t}`)),rvn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===Yh.of(QN))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(l=>oSe(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=xR(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:xR(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:xR(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===iS?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 HAD(e){return e?.header!=null}var Hie={openapi:e=>({...e,type:"openapi",_visit:function(t){return Hie._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return Hie._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 aSn={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return aSn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var C5={basic:e=>({...e,type:"basic",_visit:function(t){return C5._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return C5._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return C5._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return C5._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return C5._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 ig={primitive:e=>({value:e,type:"primitive",_visit:function(t){return ig._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ig._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return ig._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return ig._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return ig._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return ig._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ig._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return ig._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 s_={int:e=>({value:e,type:"int",_visit:function(t){return s_._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return s_._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return s_._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return s_._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return s_._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return s_._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return s_._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return s_._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return s_._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return s_._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return s_._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 oSn={boolean:e=>({value:e,type:"boolean",_visit:function(t){return oSn._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return oSn._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 Jdi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return Jdi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return Jdi._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 EV={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case EV.GenerallyAvailable:return t.generallyAvailable();case EV.Beta:return t.beta();case EV.Deprecated:return t.deprecated();default:return t._other()}}};var Cze={cursor:e=>({...e,type:"cursor",_visit:function(t){return Cze._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return Cze._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return Cze._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 DKr={language:e=>({...e,type:"language",_visit:function(t){return DKr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return DKr._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 MV={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 MV.Curl:return t.curl();case MV.Python:return t.python();case MV.Javascript:return t.javascript();case MV.Typescript:return t.typescript();case MV.Go:return t.go();case MV.Ruby:return t.ruby();case MV.Csharp:return t.csharp();case MV.Java:return t.java();case MV.Js:return t.js();case MV.Node:return t.node();case MV.Ts:return t.ts();case MV.Nodets:return t.nodets();case MV.Golang:return t.golang();case MV.Dotnet:return t.dotnet();case MV.Jvm:return t.jvm();default:return t._other()}}};var X5t={unknown:e=>({value:e,type:"unknown",_visit:function(t){return X5t._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return X5t._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 Bze={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return Bze._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return Bze._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 MG={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case MG.Get:return t.get();case MG.Post:return t.post();case MG.Put:return t.put();case MG.Patch:return t.patch();case MG.Delete:return t.delete();case MG.Head:return t.head();case MG.Options:return t.options();case MG.Trace:return t.trace();default:return t._other()}}};var Kdi={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return Kdi._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return Kdi._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Kdi._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 xze={file:e=>({...e,type:"file",_visit:function(t){return xze._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return xze._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 AG={file:e=>({...e,type:"file",_visit:function(t){return AG._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return AG._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return AG._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return AG._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return AG._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return AG._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return AG._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Oy={primitive:e=>({...e,type:"primitive",_visit:function(t){return Oy._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Oy._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Oy._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Oy._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Oy._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Oy._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Oy._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Oy._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Oy._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Oy._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Oy._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 mj={int:e=>({...e,type:"int",_visit:function(t){return mj._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return mj._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return mj._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return mj._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return mj._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return mj._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return mj._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return mj._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return mj._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return mj._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return mj._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 jx={boolean:e=>({value:e,type:"boolean",_visit:function(t){return jx._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return jx._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 EKr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return EKr._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return EKr._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 uDe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return uDe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return uDe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return uDe._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 PT={file:e=>({...e,type:"file",_visit:function(t){return PT._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return PT._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return PT._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return PT._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return PT._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return PT._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return PT._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var 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 pX={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return pX._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return pX._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 Xd={int:e=>({...e,type:"int",_visit:function(t){return Xd._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Xd._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Xd._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Xd._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Xd._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Xd._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Xd._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Xd._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Xd._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Xd._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Xd._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 cv={};Eo(cv,{AllOfPropertyConflict:()=>ASn,ArraySchema:()=>kTo,ArraySchemaWithExample:()=>ECo,Availability:()=>Qqo,Base64WithExample:()=>PCo,BasicSecurityScheme:()=>Yqo,BearerSecurityScheme:()=>Xqo,BooleanSchema:()=>QTo,BooleanWithExample:()=>jCo,BytesResponse:()=>OSn,CasingOverrides:()=>eTo,CommonProperty:()=>uCo,CommonPropertyWithExample:()=>zCo,CursorPagination:()=>qTo,CustomCodeSample:()=>MTo,CustomCodeSampleLanguage:()=>STo,CustomCodeSampleSdk:()=>ETo,CustomPagination:()=>CTo,DateWithExample:()=>mCo,DatetimeWithExample:()=>OCo,DiscriminatedOneOfSchema:()=>aCo,DiscriminatedOneOfSchemaWithExample:()=>xCo,DoubleSchema:()=>$To,DoubleWithExample:()=>bCo,Encoding:()=>Gqo,Endpoint:()=>BTo,EndpointExample:()=>wSn,EndpointResponseExample:()=>wTo,EndpointSdkName:()=>CXt,EndpointWithExample:()=>m6p,EnumSchema:()=>lSn,EnumSchemaWithExample:()=>SCo,EnumValue:()=>Zdi,ErrorExample:()=>gTo,FernExample:()=>mTo,FileResponse:()=>bSn,FileSchema:()=>dTo,FloatWithExample:()=>vCo,FullEndpointExample:()=>ATo,FullExample:()=>kA,FullObjectExample:()=>uTo,FullOneOfExample:()=>cTo,GlobalHeader:()=>KTo,Header:()=>epi,HeaderExample:()=>jSn,HeaderSecurityScheme:()=>Zqo,HeaderWithExample:()=>ipi,HttpEndpointServer:()=>mSn,HttpError:()=>OTo,HttpErrorWithExample:()=>dCo,HttpMethod:()=>pSn,IdempotencyHeader:()=>YTo,Int64WithExample:()=>_Co,IntSchema:()=>WTo,IntWithExample:()=>pCo,JsonRequest:()=>yTo,JsonRequestWithExample:()=>cCo,JsonResponse:()=>gSn,JsonResponseWithExample:()=>CSn,KeyValuePair:()=>sTo,LiteralExample:()=>oTo,LiteralSchema:()=>MSn,LiteralSchemaValue:()=>XTo,LongSchema:()=>HTo,MapSchema:()=>eCo,MapSchemaWithExample:()=>MCo,MultipartRequest:()=>vSn,MultipartRequestProperty:()=>hTo,MultipartRequestPropertyEncoding:()=>_To,MultipartSchema:()=>pTo,NamedFullExample:()=>xXt,Namespace:()=>tTo,NamespaceId:()=>aTo,NullableSchema:()=>rCo,NullableSchemaWithExample:()=>qCo,OauthSecurityScheme:()=>iTo,ObjectProperty:()=>nCo,ObjectPropertyConflictInfo:()=>qSn,ObjectPropertyWithExample:()=>BCo,ObjectSchema:()=>ZTo,ObjectSchemaWithExample:()=>TCo,OctetStreamRequest:()=>ySn,OffsetPagination:()=>TTo,OneOfSchema:()=>iCo,OneOfSchemaWithExample:()=>CCo,OpenApiIntermediateRepresentation:()=>g6p,OpenApiSource:()=>Vqo,OptionalSchema:()=>tCo,OptionalSchemaWithExample:()=>ACo,Pagination:()=>SSn,PathParameter:()=>_Sn,PathParameterExample:()=>PTo,PathParameterWithExample:()=>sCo,PrimitiveExample:()=>dSn,PrimitiveSchema:()=>rpi,PrimitiveSchemaValue:()=>JTo,PrimitiveSchemaValueWithExample:()=>wCo,PrimitiveSchemaWithExample:()=>BSn,PropertyKey:()=>fSn,ProtobufEncoding:()=>$qo,ProtobufSource:()=>Wqo,QueryParameter:()=>hSn,QueryParameterExample:()=>PSn,QueryParameterWithExample:()=>TSn,QuerySecurityScheme:()=>kqo,ReferencedSchema:()=>BXt,Request:()=>vTo,RequestWithExample:()=>lCo,Response:()=>bTo,ResponseWithExample:()=>fCo,Schema:()=>KO,SchemaId:()=>_X,SchemaWithExample:()=>qM,Schemas:()=>VTo,SdkGroup:()=>rTo,SdkGroupInfo:()=>lTo,SdkGroupName:()=>kdi,SecurityScheme:()=>nTo,SecuritySchemeId:()=>Kqo,Server:()=>vha,Source:()=>Hqo,StatusCode:()=>qXt,StreamingResponseExample:()=>jTo,StringSchema:()=>GTo,StringSchemaWithExample:()=>gCo,SupportedSdkLanguage:()=>DTo,Tag:()=>Jqo,TagId:()=>hX,Tags:()=>fTo,TextResponse:()=>tpi,Uint64WithExample:()=>yCo,UintWithExample:()=>hCo,UnDiscriminatedOneOfSchema:()=>oCo,UnDiscriminatedOneOfSchemaWithExample:()=>ICo,UnknownSchemaWithExample:()=>DCo,Webhook:()=>xTo,WebhookExampleCall:()=>ESn,WebhookHttpMethod:()=>DSn,WebhookWithExample:()=>P6p,WebsocketChannel:()=>UTo,WebsocketHandshake:()=>ITo,WebsocketHandshakeWithExample:()=>O6p,WebsocketMessageExample:()=>FTo,WebsocketMessageOrigin:()=>zTo,WebsocketMessageSchema:()=>RTo,WebsocketServer:()=>NTo,WebsocketSessionExample:()=>LTo,WithAvailability:()=>dh,WithDescription:()=>pf,WithEncoding:()=>$ie,WithInline:()=>dE,WithName:()=>o0,WithNamespace:()=>TXt,WithSdkGroupName:()=>IO,WithSource:()=>Ah,WithStatusCode:()=>Ize,WithTitle:()=>xO,commons:()=>CUs,example:()=>BUs,finalIr:()=>xUs,parseIr:()=>IUs});var CUs={};Eo(CUs,{BasicSecurityScheme:()=>Yqo,BearerSecurityScheme:()=>Xqo,Encoding:()=>Gqo,HeaderSecurityScheme:()=>Zqo,Namespace:()=>tTo,NamespaceId:()=>aTo,OauthSecurityScheme:()=>iTo,OpenApiSource:()=>Vqo,ProtobufEncoding:()=>$qo,ProtobufSource:()=>Wqo,QuerySecurityScheme:()=>kqo,SchemaId:()=>_X,SdkGroup:()=>rTo,SdkGroupName:()=>kdi,SecurityScheme:()=>nTo,SecuritySchemeId:()=>Kqo,Server:()=>vha,Source:()=>Hqo,StatusCode:()=>qXt,Tag:()=>Jqo,TagId:()=>hX,WithAvailability:()=>dh,WithDescription:()=>pf,WithEncoding:()=>$ie,WithInline:()=>dE,WithName:()=>o0,WithNamespace:()=>TXt,WithSdkGroupName:()=>IO,WithSource:()=>Ah,WithStatusCode:()=>Ize,WithTitle:()=>xO});var qt={};Eo(qt,{JsonError:()=>uSn,ParseError:()=>sSn,any:()=>o6p,bigint:()=>Q7p,boolean:()=>u6p,booleanLiteral:()=>a6p,date:()=>J7p,discriminant:()=>y6p,enum_:()=>Fqo,getObjectLikeUtils:()=>Z5t,getObjectUtils:()=>pNi,getSchemaUtils:()=>ZA,isProperty:()=>Xdi,lazy:()=>K7p,lazyObject:()=>r6p,list:()=>Uqo,number:()=>s6p,object:()=>Lqo,objectWithoutOptionalProperties:()=>t6p,optional:()=>MUs,property:()=>X7p,record:()=>d6p,set:()=>p6p,string:()=>c6p,stringLiteral:()=>n6p,transform:()=>AUs,undiscriminatedUnion:()=>h6p,union:()=>b6p,unknown:()=>l6p,withParsedProperties:()=>TUs});var ZP={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 AM(e,t){return`Expected ${t}. Received ${$AD(e)}.`}function $AD(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 B5(e){return{...e,json:G7p(e.json),parse:G7p(e.parse)}}function G7p(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(`
@@ -1953,7 +1953,7 @@ plugins:
1953
1953
  - enum_type=string
1954
1954
  - default_response=false
1955
1955
  - source_root=${e}
1956
- `}async function Jze({context:e,specs:t,relativePathToDependency:r}){let i=new TRo({context:e}),n=t.filter(l=>l.type==="openapi").map(l=>({...l,relativePathToDependency:r})),a=t.filter(l=>l.type==="protobuf"),u=await Promise.all(a.map(async l=>veE({generator:i,protobufSpec:l,relativePathToDependency:r})));return[...n,...u]}async function veE({generator:e,protobufSpec:t,relativePathToDependency:r}){return{type:"openapi",absoluteFilepath:await e.generate({absoluteFilepathToProtobufRoot:t.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:t.absoluteFilepathToProtobufTarget,relativeFilepathToProtobufRoot:t.relativeFilepathToProtobufRoot,local:t.generateLocally}),absoluteFilepathToOverrides:t.absoluteFilepathToOverrides,settings:t.settings,source:{type:"protobuf",relativePathToDependency:r,root:t.absoluteFilepathToProtobufRoot,file:t.absoluteFilepathToProtobufTarget}}}var Qkp=require("fs"),IEn=require("fs/promises");var Jkp=require("os"),Kkp=di(require("path"),1),Ykp=require("stream/promises"),Xkp=di(FNo(),1),Zkp=di(ore(),1);var hXs=di(Hxi(),1);var uP;(function(e){e.FILE_READ="FILE_READ",e.FILE_PARSE="FILE_PARSE",e.FILE_MISSING="FILE_MISSING",e.STRUCTURE_VALIDATION="STRUCTURE_VALIDATION",e.JSONSCHEMA_VALIDATION="JSONSCHEMA_VALIDATION",e.DEPENDENCY_NOT_LISTED="DEPENDENCY_NOT_LISTED",e.FAILED_TO_LOAD_DEPENDENCY="FAILED_TO_LOAD_DEPENDENCY",e.EXPORTING_PACKAGE_MARKER_OTHER_KEYS="EXPORTING_PACKAGE_MARKER_OTHER_KEYS",e.EXPORT_PACKAGE_HAS_DEFINITIONS="EXPORT_PACKAGE_HAS_DEFINITIONS",e.MISCONFIGURED_DIRECTORY="MISCONFIGURED_DIRECTORY"})(uP||(uP={}));var QrE=oJr();async function kkp({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:i,cliVersion:n,settings:a,loadAPIWorkspace:u}){let l,d={type:uP.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:uP.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${eiE(s)}`},async o=>{switch(s.type){case"version":l=await ZrE({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;case"local":l=await XrE({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;default:Fo(s)}}),l!=null?{didSucceed:!0,definition:l}:{didSucceed:!1,failure:d}}var ee_="dependencies";var JrE="metadata.json",KrE=".fern";function YrE(e){return es(Wl.of((0,Jkp.homedir)()),uo.of(KrE),uo.of(ee_),uo.of(e.organization),uo.of(e.apiName),uo.of(e.version))}async function XrE({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){if(n==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await n({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!a.didSucceed){t.failWithoutThrowing("Failed to load api definition",a.failures);return}t.logger.info("Modifying source filepath ...");let u=await a.workspace.getDefinition({context:t,relativePathToDependency:uo.of(e.path)},i);return t.logger.info("Loaded..."),u}async function ZrE({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){let a=YrE(e),u=es(a,uo.of(ee_)),l=es(a,uo.of(JrE)),d;if(!await Cf(u)||!await Cf(l)){t.logger.info("Downloading manifest...");let c=await QrE.definitionRegistry.get(hXs.FernFiddle.OrganizationId(e.organization),hXs.FernFiddle.ApiId(e.apiName),e.version);if(!c.ok){c.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:m=>{t.failWithoutThrowing("Failed to download API manifest",m)}});return}let b=c.body.yamlSchemaVersion!=null?parseInt(c.body.yamlSchemaVersion):void 0,g=iNi(r),O=iNi(c.body.cliVersion);if(b!=null){if(b>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${c.body.cliVersion}`);return}else if(b<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(g.major!==O.major||g.minor!==O.minor){t.failWithoutThrowing(`CLI version is ${c.body.cliVersion}. Expected ${g.major}.${g.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+c.body.definitionS3DownloadUrl),await(0,IEn.mkdir)(u,{recursive:!0});try{await krE({s3PreSignedReadUrl:c.body.definitionS3DownloadUrl,absolutePathToLocalOutput:u})}catch(m){t.failWithoutThrowing("Failed to download API",m);return}d=c.body,await(0,IEn.writeFile)(l,JSON.stringify(d))}else d=JSON.parse((await(0,IEn.readFile)(l)).toString());if(t.logger.info("Parsing..."),n==null){t.failWithoutThrowing("Failed to load API");return}let s=await n({absolutePathToWorkspace:u,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!s.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",s.failures);return}if(s.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await s.workspace.getDefinition({context:t},i)}async function krE({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await QR.get(e,{responseType:"stream"}),i=await Zkp.default.dir(),n=Kkp.default.join(i.path,"api.tgz");await(0,Ykp.pipeline)(r.data,(0,Qkp.createWriteStream)(n)),await(0,Xkp.extract)({file:n,cwd:t})}function eiE(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:Fo(e)}}var pe_=di(oe_(),1);function LNo(e,t){for(let[r,i]of $N(e))riE({relativeFilepath:r,failure:i,logger:t})}function riE({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case uP.MISCONFIGURED_DIRECTORY:r.error("Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder");break;case uP.FILE_READ:r.error("Failed to open file: "+e);break;case uP.FILE_MISSING:r.error("Missing file: "+e);break;case uP.FILE_PARSE:t.error instanceof Vaa?r.error(Wie({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case uP.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of iiE(i))r.error(Wie({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case uP.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case uP.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${zZa}: `+t.dependencyName);break;case uP.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case uP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case uP.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(Wie({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));for(let i of t.error.allErrors)i!==t.error.error&&r.debug(Wie({title:i.message??"Unknown error",breadcrumbs:[e,...i.instancePath.split("/").filter(n=>n!=="")]}));break;default:Fo(t)}}function iiE(e){switch(e.code){case Hl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Js.underline(e.expected)} but received ${Js.underline(e.received)}`}];case Hl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Js.underline(t)}`}));case Hl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Js.underline(t)).join(", ")}`}];case Hl.invalid_union:case Hl.invalid_arguments:case Hl.invalid_return_type:case Hl.invalid_date:case Hl.invalid_string:case Hl.too_small:case Hl.too_big:case Hl.invalid_intersection_types:case Hl.not_multiple_of:case Hl.custom:default:return[{title:e.message}]}}var ue_=require("fs/promises");async function se_(e,t){let r=[];for(let i of await XBe(e,t))r.push(await niE({relativeFilepath:HA(e,i),absoluteFilepath:i}));return r}async function niE({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,ue_.readFile)(t)).toString()}}async function ce_(e){let t={},r={};function i(n){try{t[n.relativeFilepath]={defaultUrl:void 0,contents:Kd.load(n.fileContents,{schema:Kd.CORE_SCHEMA}),rawContents:n.fileContents}}catch(a){r[n.relativeFilepath]={type:uP.FILE_PARSE,error:a}}}return await Promise.all(e.map(i)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}async function le_({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:i,settings:n,loadAPIWorkspace:a}){let u={},l={},d={};return await Promise.all($N(t.packageMarkers).map(async([s,o])=>{if(o.contents.export==null)u[s]=o;else{let{export:c,...b}=o.contents;if(jY(b)>0)d[s]={type:uP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let g=_p(s);if(W4t(t.namedDefinitionFiles).some(m=>m!==s&&m.startsWith(g)))d[s]={type:uP.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:g};else{let m=await kkp({dependencyName:typeof o.contents.export=="string"?o.contents.export:o.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:i,settings:n,loadAPIWorkspace:a});m.didSucceed?l[_p(s)]={definition:m.definition,url:typeof o.contents.export=="object"?o.contents.export.url:void 0}:d[s]=m.failure}}}})),jY(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:u,importedDefinitions:l}}var fe_=di(require("path"),1);var bXs={};Eo(bXs,{additionalProperties:()=>siE,default:()=>liE,definitions:()=>ciE,properties:()=>oiE,required:()=>uiE,type:()=>aiE});var aiE="object",oiE={docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},"default-url":{oneOf:[{type:"string"},{type:"null"}]},"default-environment":{oneOf:[{type:"string"},{type:"null"}]},environments:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/environments.EnvironmentSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/auth.ApiAuthSchema"},{type:"null"}]},"auth-schemes":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/auth.AuthSchemeDeclarationSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},name:{type:"string"},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},"error-discrimination":{oneOf:[{$ref:"#/definitions/file.ErrorDiscriminationSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},errors:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"idempotency-headers":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},variables:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/variables.VariableDeclarationSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"null"}]},version:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},uiE=["name"],siE=!1,ciE={"environments.SingleBaseUrlEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},url:{type:"string"}},required:["url"],additionalProperties:!1},"environments.MultipleBaseUrlsEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},urls:{type:"object",additionalProperties:{type:"string"}}},required:["urls"],additionalProperties:!1},"environments.EnvironmentSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/environments.SingleBaseUrlEnvironmentSchema"},{$ref:"#/definitions/environments.MultipleBaseUrlsEnvironmentSchema"}]},"auth.AuthSchemeReferenceSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{type:"string"}},required:["scheme"],additionalProperties:!1},"auth.AnyAuthItem":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"}]},"auth.AnyAuthSchemesSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},any:{type:"array",items:{$ref:"#/definitions/auth.AnyAuthItem"}}},required:["any"],additionalProperties:!1},"auth.ApiAuthSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"},{$ref:"#/definitions/auth.AnyAuthSchemesSchema"}]},"auth.OAuthAccessTokenRequestPropertiesSchema":{type:"object",properties:{"client-id":{oneOf:[{type:"string"},{type:"null"}]},"client-secret":{oneOf:[{type:"string"},{type:"null"}]},scopes:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthAccessTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthGetTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthRefreshTokenRequestPropertiesSchema":{type:"object",properties:{"refresh-token":{type:"string"}},required:["refresh-token"],additionalProperties:!1},"auth.OAuthRefreshTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthRefreshTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"oauth"},type:{const:"client-credentials"},scopes:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"client-id-env":{oneOf:[{type:"string"},{type:"null"}]},"client-secret-env":{oneOf:[{type:"string"},{type:"null"}]},"token-prefix":{oneOf:[{type:"string"},{type:"null"}]},"token-header":{oneOf:[{type:"string"},{type:"null"}]},"get-token":{$ref:"#/definitions/auth.OAuthGetTokenEndpointSchema"},"refresh-token":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenEndpointSchema"},{type:"null"}]}},required:["scheme","type","get-token"],additionalProperties:!1},"auth.HeaderAuthSchemeSchema":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},header:{type:"string"},type:{oneOf:[{type:"string"},{type:"null"}]},prefix:{oneOf:[{type:"string"},{type:"null"}]}},required:["header"],additionalProperties:!1},"auth.AuthVariable":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.BasicAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"basic"},username:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]},password:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.BearerAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},token:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.AuthSchemeDeclarationSchema":{anyOf:[{$ref:"#/definitions/auth.OAuthSchemeSchema"},{$ref:"#/definitions/auth.HeaderAuthSchemeSchema"},{$ref:"#/definitions/auth.BasicAuthSchemeSchema"},{$ref:"#/definitions/auth.BearerAuthSchemeSchema"}]},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"file.PropertyBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"property"},"property-name":{type:"string"}},required:["strategy","property-name"],additionalProperties:!1},"file.StatusCodeBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"status-code"}},required:["strategy"],additionalProperties:!1},"file.ErrorDiscriminationSchema":{anyOf:[{$ref:"#/definitions/file.PropertyBasedErrorDiscrimination"},{$ref:"#/definitions/file.StatusCodeBasedErrorDiscrimination"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"variables.VariableDeclarationDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"variables.VariableDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/variables.VariableDeclarationDetailed"}]},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"versioning.VersionValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionValue":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionValueDetailed"}]},"versioning.VersionDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionDeclarationHeaderObjectSchema"}]},"versioning.VersionDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/versioning.VersionValue"}},header:{$ref:"#/definitions/versioning.VersionDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1}},liE={type:aiE,properties:oiE,required:uiE,additionalProperties:siE,definitions:ciE};var gXs={};Eo(gXs,{additionalProperties:()=>piE,default:()=>hiE,definitions:()=>_iE,properties:()=>diE,type:()=>fiE});var fiE="object",diE={docs:{oneOf:[{type:"string"},{type:"null"}]},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]}},piE=!1,_iE={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1}},hiE={type:fiE,properties:diE,additionalProperties:piE,definitions:_iE};var OXs={};Eo(OXs,{additionalProperties:()=>biE,default:()=>OiE,definitions:()=>giE,properties:()=>viE,type:()=>yiE});var yiE="object",viE={imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},navigation:{oneOf:[{$ref:"#/definitions/file.Navigation"},{type:"null"}]},export:{oneOf:[{$ref:"#/definitions/file.Export"},{type:"null"}]}},biE=!1,giE={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1},"file.Navigation":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"file.ExportDetailed":{type:"object",properties:{dependency:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]}},required:["dependency"],additionalProperties:!1},"file.Export":{anyOf:[{type:"string"},{$ref:"#/definitions/file.ExportDetailed"}]}},OiE={type:yiE,properties:viE,additionalProperties:biE,definitions:giE};function de_({files:e,absolutePathToDefinition:t}){let r,i={},n={},a={};for(let[u,l]of $N(e)){let d=l.contents,s=o=>{a[u]={type:uP.JSONSCHEMA_VALIDATION,error:o}};if(u===QN){let o=nQr(d,bXs);if(o.success){let c=S2.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:c["default-url"],contents:c,rawContents:l.rawContents}}else s(o)}else if(fe_.default.basename(u)===iS){let o=nQr(d,OXs);if(o.success){let c=S2.serialization.PackageMarkerFileSchema.parseOrThrow(d);n[u]={defaultUrl:typeof c.export=="object"?c.export.url:void 0,contents:c,rawContents:l.rawContents}}else s(o)}else{let o=nQr(d,gXs);if(o.success){let c=S2.serialization.DefinitionFileSchema.parseOrThrow(d);i[u]={defaultUrl:void 0,contents:c,rawContents:l.rawContents,absoluteFilePath:es(t,u)}}else s(o)}}return r==null?{didSucceed:!1,failures:{[uo.of(QN)]:{type:uP.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:i,rootApiFile:r,packageMarkers:n}}var p_i=class extends Y5t{context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...i}){super(i),this.context=t,this.loadAPIWorkspace=r}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let i=(0,pe_.default)(r??{}),n=this.fernWorkspaces[i];if(n==null){let a=t||this.context,u=es(this.absoluteFilePath,uo.of(X8)),l=await Ybs({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await se_(u,"{yml,yaml}"),s=await ce_(d);if(!s.didSucceed)return LNo(s.failures,a.logger),a.failAndThrow();let o=de_({files:s.files,absolutePathToDefinition:u});if(!o.didSucceed)return LNo(o.failures,a.logger),a.failAndThrow();let c=await le_({dependenciesConfiguration:l,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!c.didSucceed)return LNo(c.failures,a.logger),a.failAndThrow();n=new oDe({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:l,workspaceName:this.workspaceName,definition:{absoluteFilePath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:c.packageMarkers,importedDefinitions:c.importedDefinitions},cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[i]=n}return n}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};function LV(e){let t=PiE(e),{value:r,done:i}=mXs(t,"{");return i?{head:r,parts:[]}:{head:r,parts:[...miE(t)]}}function*miE(e){let t;do{let{value:r}=mXs(e,"}"),i=mXs(e,"{");t=i.done,yield{pathParameter:r,tail:i.value}}while(!t)}function*PiE(e){for(let t of e)yield t}function mXs(e,t){let r="",i=e.next();for(;i.done!==!0&&i.value!==t;)r+=i.value,i=e.next();return{value:r,done:i.done??!1}}function eba(e){let t=2166136261;function r(n,a){if(typeof n=="object"&&n!=null){if(a>64){i("[MaxDepthExceeded]");return}if(Array.isArray(n)){i("[");for(let u=0;u<n.length;u++)u>0&&i(","),r(n[u],a+1);i("]")}else i("{"),Object.keys(n).sort().forEach((l,d)=>{d>0&&i(","),i(l),i(":"),r(n[l],a+1)}),i("}")}else i(String(n))}function i(n){for(let a=0;a<n.length;a++){let u=n.charCodeAt(a);t^=u,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24),t>>>=0}}return r(e,0),t.toString(16)}function _e_({fieldName:e,containerType:t,maxDepth:r,currentDepth:i,typeDeclarations:n,skipOptionalProperties:a}){if(i>=r)return cZt({containerType:t});switch(t.type){case"list":{let u=uC({fieldName:e,typeReference:t.list,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?cZt({containerType:t}):{type:"success",example:QO.list({list:[u.example,u.example],itemType:t.list}),jsonExample:[u.jsonExample,u.jsonExample]}}case"literal":return{type:"success",example:QO.literal({literal:t.literal._visit({boolean:u=>Cd.boolean(u),string:u=>Cd.string({original:u}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:t.literal._visit({boolean:u=>u,string:u=>u,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":{if(a)return cZt({containerType:t});let u=uC({fieldName:e,typeReference:t.optional,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?cZt({containerType:t}):{type:"success",example:QO.optional({optional:u.example,valueType:t.optional}),jsonExample:u.jsonExample}}case"nullable":{if(a)return cZt({containerType:t});let u=uC({fieldName:e,typeReference:t.nullable,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?cZt({containerType:t}):{type:"success",example:QO.nullable({nullable:u.example,valueType:t.nullable}),jsonExample:u.jsonExample}}case"set":{let u=uC({fieldName:e,typeReference:t.set,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?cZt({containerType:t}):{type:"success",example:QO.set({set:[u.example],itemType:t.set}),jsonExample:[u.jsonExample]}}case"map":{let u=uC({fieldName:e,typeReference:t.keyType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a}),l=uC({fieldName:e,typeReference:t.valueType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"||l.type==="failure"?cZt({containerType:t}):{type:"success",example:QO.map({map:[{key:u.example,value:l.example}],keyType:t.keyType,valueType:t.valueType}),jsonExample:{[u.jsonExample]:l.jsonExample}}}default:Fo(t)}}function cZt({containerType:e}){switch(e.type){case"list":return{type:"success",example:QO.list({list:[],itemType:e.list}),jsonExample:[]};case"literal":return{type:"success",example:QO.literal({literal:e.literal._visit({boolean:t=>Cd.boolean(t),string:t=>Cd.string({original:t}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:e.literal._visit({boolean:t=>t,string:t=>t,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":return{type:"success",example:QO.optional({optional:void 0,valueType:e.optional}),jsonExample:void 0};case"nullable":return{type:"success",example:QO.nullable({nullable:void 0,valueType:e.nullable}),jsonExample:void 0};case"set":return{type:"success",example:QO.set({set:[],itemType:e.set}),jsonExample:[]};case"map":return{type:"success",example:QO.map({map:[],keyType:e.keyType,valueType:e.valueType}),jsonExample:{}};default:Fo(e)}}function ye_({fieldName:e,primitiveType:t}){switch(t.v1){case"STRING":return DiE({fieldName:e,validation:jiE(t.v2)});case"BASE_64":return{type:"success",example:Cd.base64(Ey.BASE64),jsonExample:Ey.BASE64};case"BOOLEAN":return{type:"success",example:Cd.boolean(Ey.BOOLEAN),jsonExample:Ey.BOOLEAN};case"DATE":return{type:"success",example:Cd.date(Ey.DATE),jsonExample:Ey.DATE};case"DATE_TIME":return{type:"success",example:Cd.datetime({datetime:new Date(Ey.DATE_TIME),raw:Ey.DATE_TIME}),jsonExample:Ey.DATE_TIME};case"DOUBLE":return EiE({fieldName:e,validation:wiE(t.v2)});case"FLOAT":return{type:"success",example:Cd.float(Ey.FLOAT),jsonExample:Ey.FLOAT};case"INTEGER":return MiE({fieldName:e,validation:SiE(t.v2)});case"UINT_64":return{type:"success",example:Cd.uint64(Ey.INT64),jsonExample:Ey.INT64};case"UINT":return{type:"success",example:Cd.uint(Ey.UINT),jsonExample:Ey.UINT};case"BIG_INTEGER":return{type:"success",example:Cd.bigInteger(Ey.INT64.toString()),jsonExample:`${Ey.INT64}`};case"LONG":return{type:"success",example:Cd.long(Ey.INT64),jsonExample:Ey.INT64};case"UUID":return{type:"success",example:Cd.uuid(Ey.UUID),jsonExample:Ey.UUID};default:Fo(t.v1)}}function jiE(e){if(e?.type==="string")return e.validation}function wiE(e){if(e?.type==="double")return e.validation}function SiE(e){if(e?.type==="integer")return e.validation}function he_(e){if(e<=Ey.SAMPLE_STRINGS.length){let t=Ey.SAMPLE_STRINGS[e-1];if(t)return t;throw new Error(`Unexpected undefined value in SAMPLE_STRINGS at index ${e-1}`)}return Ey.SAMPLE_STRINGS[Ey.SAMPLE_STRINGS.length-1]+".".repeat(e-Ey.SAMPLE_STRINGS.length)}function DiE({fieldName:e,validation:t}){if(t){let i=t.minLength,n=t.maxLength;if(i){let a=he_(i);return{type:"success",example:Cd.string({original:a}),jsonExample:a}}else if(n){let a=he_(n);return{type:"success",example:Cd.string({original:a}),jsonExample:a}}}let r=e??Ey.STRING;return{type:"success",example:Cd.string({original:r}),jsonExample:r}}function EiE({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Cd.double(r),jsonExample:r};if(i)return{type:"success",example:Cd.double(i),jsonExample:i}}return{type:"success",example:Cd.double(Ey.DOUBLE),jsonExample:Ey.DOUBLE}}function MiE({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Cd.integer(r),jsonExample:r};if(i)return{type:"success",example:Cd.integer(i),jsonExample:i}}return{type:"success",example:Cd.integer(Ey.INT),jsonExample:Ey.INT}}function uC({fieldName:e,typeReference:t,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){if(n>i)return{type:"failure",message:"Exceeded max depth"};switch(t.type){case"named":{let u=r[t.typeId];if(u==null)return{type:"failure",message:`Failed to find type declaration with id ${t.typeId}`};let l=NEn({fieldName:e,typeDeclaration:u,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(l==null)return{type:"failure",message:"Failed to generate example for type declaration"};if(l.type==="failure")return l;let{example:d,jsonExample:s}=l;return{type:"success",example:{jsonExample:s,shape:mh.named({shape:d,typeName:u.name})},jsonExample:s}}case"container":{let u=_e_({fieldName:e,containerType:t.container,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(u.type==="failure"){let{example:s,jsonExample:o}=cZt({containerType:t.container});return{type:"success",example:{jsonExample:o,shape:mh.container(s)},jsonExample:o}}let{example:l,jsonExample:d}=u;return{type:"success",example:{jsonExample:d,shape:mh.container(l)},jsonExample:d}}case"primitive":{let{jsonExample:u,example:l}=ye_({fieldName:e,primitiveType:t.primitive});return{type:"success",example:{jsonExample:u,shape:mh.primitive(l)},jsonExample:u}}case"unknown":{let u={key:"value"};return{type:"success",example:{jsonExample:u,shape:mh.unknown(u)},jsonExample:u}}}}function FEn({typeReference:e,typeDeclarations:t}){if(e.type==="container"&&e.container.type==="optional")return!0;if(e.type==="named"){let r=t[e.typeId];if(r?.shape.type==="alias"&&r?.shape.resolvedType.type==="container"&&r?.shape.resolvedType.container.type==="optional")return!0}return!1}function NEn({fieldName:e,typeDeclarations:t,typeDeclaration:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){switch(r.shape.type){case"alias":{let u=uC({fieldName:e,typeDeclarations:t,typeReference:r.shape.aliasOf,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(u.type==="failure")return u;let{example:l,jsonExample:d}=u;return{type:"success",example:ow.alias({value:l}),jsonExample:d}}case"enum":{let u=r.shape.values[0];return u==null?{type:"failure",message:"No enum values present"}:{type:"success",example:ow.enum({value:u.name}),jsonExample:u.name.wireValue}}case"object":{let u={},l=[];if(r.shape.extends!=null)for(let c of r.shape.extends){let b=t[c.typeId];if(b==null)continue;let g=NEn({fieldName:e,typeDeclaration:b,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});g!=null&&g.type==="success"&&g.example.type==="object"&&(Object.assign(u,g.jsonExample),l.push(...g.example.properties))}let d=AiE({fieldName:e,typeDeclaration:r,objectTypeDeclaration:r.shape,typeDeclarations:t,currentDepth:n,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure")return d;let{example:s,jsonExample:o}=d;return{type:"success",example:ow.object({...s,properties:[...l,...s.properties]}),jsonExample:Object.assign({},u,o)}}case"undiscriminatedUnion":{let u=0;for(let l of r.shape.members){let d=uC({fieldName:e,typeReference:l.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure"){++u;continue}let{example:s,jsonExample:o}=d;return{type:"success",example:ow.undiscriminatedUnion({index:u,singleUnionType:s}),jsonExample:o}}break}case"union":{let u=r.shape.discriminant,l={};if(r.shape.baseProperties!=null)for(let d of r.shape.baseProperties){let s=uC({fieldName:d.name.wireValue,typeReference:d.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});s.type==="success"&&(l[d.name.wireValue]=s.jsonExample)}for(let d of r.shape.types){let s=d.shape._visit({noProperties:()=>({type:"success",example:ow.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:oF.noProperties()}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,...l}}),samePropertiesAsObject:o=>{let c=t[o.typeId];if(c==null)return{type:"failure",message:`Failed to find type declaration with id ${o.typeId}`};let b=NEn({currentDepth:n,maxDepth:i,fieldName:e,typeDeclaration:c,typeDeclarations:t,skipOptionalProperties:a});if(b==null)return{type:"failure",message:"Failed to generate example for type reference"};if(b.type==="failure")return b;let{example:g,jsonExample:O}=b;return{type:"success",example:ow.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:oF.samePropertiesAsObject({typeId:c.name.typeId,object:g.type==="object"?g:{properties:[]}})}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,...typeof O=="object"?O:{},...l}}},singleProperty:o=>{let c=uC({currentDepth:n+1,maxDepth:i,fieldName:e,typeReference:o.type,typeDeclarations:t,skipOptionalProperties:a});if(c.type==="failure")return c;let{example:b,jsonExample:g}=c;return{type:"success",example:ow.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:oF.singleProperty(b)}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,[o.name.wireValue]:g,...l}}},_other:()=>{throw new Error("Encountered unknown union type")}});if(s.type!=="failure")return s}}}return{type:"failure",message:"Failed to generate example for type reference"}}function AiE({fieldName:e,typeDeclaration:t,objectTypeDeclaration:r,typeDeclarations:i,maxDepth:n,currentDepth:a,skipOptionalProperties:u}){let l={},d=[];for(let s of[...r.properties??[],...r.extendedProperties??[]]){let o=uC({fieldName:s.name.wireValue,typeReference:s.valueType,typeDeclarations:i,currentDepth:a+1,maxDepth:n,skipOptionalProperties:u});if(o.type==="failure"&&!FEn({typeDeclarations:i,typeReference:s.valueType}))return{type:"failure",message:`Failed to generate required property ${s.name.wireValue} b/c ${o.message}`};if(o.type==="failure")continue;let{example:c,jsonExample:b}=o;d.push({name:s.name,originalTypeDeclaration:t.name,value:c}),l[s.name.wireValue]=b}return{type:"success",example:ow.object({properties:d}),jsonExample:l}}var PXs=a_.primitive({v1:b0.String,v2:Dv.string({default:void 0,validation:void 0})});function tba({ir:e,endpoint:t,service:r,typeDeclarations:i,skipOptionalRequestProperties:n,generationResponse:a}){let u={name:void 0,endpointHeaders:[],endpointPathParameters:[],queryParameters:[],servicePathParameters:[],serviceHeaders:[],rootPathParameters:[],request:void 0,response:Wq.ok(nC.body(void 0)),docs:void 0},l=[{params:t.pathParameters,add:s=>u.endpointPathParameters.push(s)},{params:r.pathParameters,add:s=>u.servicePathParameters.push(s)},{params:e.pathParameters,add:s=>u.rootPathParameters.push(s)}];for(let s of l)for(let o of s.params){let c=uC({fieldName:o.name.originalName,currentDepth:0,maxDepth:1,typeDeclarations:i,typeReference:o.valueType,skipOptionalProperties:n});if(c.type==="failure")return c;let{example:b}=c;s.add({name:o.name,value:b})}for(let s of t.queryParameters){if(n&&FEn({typeDeclarations:i,typeReference:s.valueType}))continue;let o=uC({fieldName:s.name.name.originalName,currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:s.valueType,skipOptionalProperties:n});if(o.type==="failure")return o;let{example:c}=o;u.queryParameters.push({name:s.name,shape:s.allowMultiple?D2.exploded():D2.single(),value:c})}let d=[{params:t.headers,add:s=>u.endpointHeaders.push(s)},{params:r.headers,add:s=>u.serviceHeaders.push(s)}];for(let s of d)for(let o of s.params){if(n&&FEn({typeDeclarations:i,typeReference:o.valueType}))continue;let c=uC({fieldName:o.name.name.originalName,currentDepth:0,maxDepth:1,typeDeclarations:i,typeReference:o.valueType,skipOptionalProperties:n});if(c.type==="failure")return c;let{example:b}=c;s.add({name:o.name,value:b})}if(t.requestBody!=null)switch(t.requestBody.type){case"bytes":return{type:"failure",message:"Bytes request unsupported"};case"fileUpload":return{type:"failure",message:"File upload unsupported"};case"inlinedRequestBody":{let s={},o=[];if(t.requestBody.extends!=null)for(let c of t.requestBody.extends){let b=i[c.typeId];if(b==null)throw new Error(`Failed to find extended type declaration with id ${c.typeId}`);let g=NEn({typeDeclaration:b,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});g!=null&&g.type==="success"&&Object.assign(s,g.jsonExample)}for(let c of[...t.requestBody.properties??[],...t.requestBody.extendedProperties??[]]){let b=uC({fieldName:c.name.wireValue,typeReference:c.valueType,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});if(b.type==="failure"&&!FEn({typeDeclarations:i,typeReference:c.valueType}))return{type:"failure",message:`Failed to generate required property ${c.name.wireValue} b/c ${b.message}`};if(b.type==="failure")continue;let{example:g,jsonExample:O}=b;o.push({name:c.name,originalTypeDeclaration:void 0,value:g}),s[c.name.wireValue]=O}u.request=tG.inlinedRequestBody({jsonExample:s,properties:o});break}case"reference":{let s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.requestBody.requestBodyType,skipOptionalProperties:n});if(s.type==="failure")return s;let{example:o}=s;u.request=tG.reference(o);break}default:Fo(t.requestBody)}if(a.type==="success"&&t.response?.body!=null)switch(t.response.body.type){case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":{let s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.responseBodyType,skipOptionalProperties:!1});if(s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Wq.ok(nC.body({...o,jsonExample:c}));break}case"streamParameter":{let s;switch(t.response.body.nonStreamResponse.type){case"bytes":return{type:"failure",message:"Bytes unsupported"};case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.nonStreamResponse.value.responseBodyType,skipOptionalProperties:!1});break;case"text":s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:PXs,skipOptionalProperties:!1});break;default:Fo(t.response.body.nonStreamResponse)}if(s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Wq.ok(nC.body({...o,jsonExample:c}));break}case"streaming":{let s;switch(t.response.body.value.type){case"sse":{if(s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Wq.ok(nC.sse([{data:{...o,jsonExample:c},event:""}]));break}case"json":{if(s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Wq.ok(nC.stream([{...o,jsonExample:c}]));break}case"text":{if(s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:PXs,skipOptionalProperties:!1}),s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Wq.ok(nC.stream([{...o,jsonExample:c}]));break}default:Fo(t.response.body.value)}break}case"text":{let s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:PXs,skipOptionalProperties:!1});if(s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Wq.ok(nC.body({...o,jsonExample:c}));break}case"bytes":return{type:"failure",message:"Bytes unsupported"};default:Fo(t.response.body)}else if(a.type==="error")if(a.declaration.type==null)u.response=Wq.error({body:void 0,error:a.declaration.name});else{let s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:a.declaration.type,skipOptionalProperties:n});if(s.type==="failure")return s;let{example:o}=s;u.response=Wq.error({body:o,error:a.declaration.name})}try{return{type:"success",example:{id:eba(u),url:qiE(t,u),...u},jsonExample:void 0}}catch(s){return{type:"failure",message:`Parse failure with exceptions ${s}`}}}function qiE(e,t){let r={};[...t.rootPathParameters,...t.servicePathParameters,...t.endpointPathParameters].forEach(n=>{let a=n.value.jsonExample,u=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=u});let i=e.fullPath.head+e.fullPath.parts.map(n=>r[n.pathParameter]+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function vFi({ir:e,exampleGeneration:t}){for(let[r,i]of Object.entries(e.services))for(let n of i.endpoints){if(n.userSpecifiedExamples.length>0&&t?.skipAutogenerationIfManualExamplesExist===!0)continue;let a=tba({ir:e,service:i,endpoint:n,typeDeclarations:e.types,skipOptionalRequestProperties:!t?.includeOptionalRequestPropertyExamples,generationResponse:{type:"success"}});if(a.type==="failure")continue;let{example:u}=a;n.autogeneratedExamples=[{example:u}]}return e}function jXs(e,t,r){let{environments:i,changedBaseUrlIds1:n,changedBaseUrlIds2:a}=TiE(e.environments,t.environments,r),{services:u,websocketChannels:l}=CiE(e,t,n,a);return{apiName:e.apiName,basePath:e.basePath,apiDisplayName:e.apiDisplayName??t.apiDisplayName,apiDocs:e.apiDocs??t.apiDocs,auth:e.auth??t.auth,headers:[...e.headers??[],...t.headers??[]],environments:i,types:{...e.types??{},...t.types??{}},constants:{...e.constants??{},...t.constants??{}},errors:{...e.errors??{},...t.errors??{}},services:u,webhookGroups:{...e.webhookGroups??{},...t.webhookGroups??{}},subpackages:{...e.subpackages??{},...t.subpackages??{}},websocketChannels:l,rootPackage:{service:e.rootPackage.service??t.rootPackage.service,types:[...e.rootPackage.types??[],...t.rootPackage.types??[]],errors:[...e.rootPackage.errors??[],...t.rootPackage.errors??[]],subpackages:[...e.rootPackage.subpackages??[],...t.rootPackage.subpackages??[]],fernFilepath:e.rootPackage.fernFilepath??t.rootPackage.fernFilepath,webhooks:e.rootPackage.webhooks??t.rootPackage.webhooks,websocket:e.rootPackage.websocket??t.rootPackage.websocket,hasEndpointsInTree:e.rootPackage.hasEndpointsInTree||t.rootPackage.hasEndpointsInTree,navigationConfig:e.rootPackage.navigationConfig??t.rootPackage.navigationConfig,docs:e.rootPackage.docs??t.rootPackage.docs},fdrApiDefinitionId:e.fdrApiDefinitionId??t.fdrApiDefinitionId,apiVersion:e.apiVersion??t.apiVersion,idempotencyHeaders:[...e.idempotencyHeaders??[],...t.idempotencyHeaders??[]],pathParameters:[...e.pathParameters??[],...t.pathParameters??[]],errorDiscriminationStrategy:e.errorDiscriminationStrategy??t.errorDiscriminationStrategy,variables:[...e.variables??[],...t.variables??[]],serviceTypeReferenceInfo:e.serviceTypeReferenceInfo??t.serviceTypeReferenceInfo,readmeConfig:e.readmeConfig??t.readmeConfig,sourceConfig:e.sourceConfig??t.sourceConfig,publishConfig:e.publishConfig??t.publishConfig,dynamic:e.dynamic??t.dynamic,sdkConfig:e.sdkConfig??t.sdkConfig}}function TiE(e,t,r){if(e==null&&t==null)return{environments:void 0,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(t==null)return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(e==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(JSON.stringify(e)===JSON.stringify(t))return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let i=ve_(e),n=ve_(t);if(i&&n&&e.environments.type==="singleBaseUrl"&&t.environments.type==="singleBaseUrl")return{environments:{defaultEnvironment:e.defaultEnvironment??t.defaultEnvironment,environments:NC.singleBaseUrl({environments:[...e.environments.environments,...t.environments.environments]})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let a=i?t.defaultEnvironment:e.defaultEnvironment,u=e.environments,l=t.environments;if(u.type==="singleBaseUrl"&&l.type==="singleBaseUrl"){let d=i?l:u,s=i?u:l,o={},{deconflictedEnvironments2:c,changedBaseUrlIds2:b}=BiE(d,s,r);if(d.environments[0]==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let g="Base",O=r.generateName("Base");return d.environments.forEach(m=>{o[m.id]=g}),{environments:{defaultEnvironment:a,environments:NC.multipleBaseUrls({baseUrls:[{id:g,name:O},...c.environments.map(m=>({id:m.id,name:m.name}))],environments:d.environments.map(m=>({id:m.id,name:m.name,urls:{[g]:m.url,...Object.fromEntries(c.environments.map(P=>[P.id,P.url]))},docs:void 0}))})},changedBaseUrlIds1:o,changedBaseUrlIds2:b}}if(u.type==="multipleBaseUrls"&&l.type==="singleBaseUrl"||u.type==="singleBaseUrl"&&l.type==="multipleBaseUrls"){let d=u.type==="singleBaseUrl"?u:l,s=u.type==="multipleBaseUrls"?u:l,{deconflictedEnvironments1:o,changedBaseUrlIds1:c}=xiE(d,s,r);return{environments:{defaultEnvironment:a,environments:NC.multipleBaseUrls({baseUrls:[...s.baseUrls,...o.environments.map(b=>({id:b.id,name:b.name}))],environments:s.environments.map(b=>({...b,urls:{...b.urls,...Object.fromEntries(o.environments.map(g=>[g.id,g.url]))}}))})},changedBaseUrlIds1:u.type==="singleBaseUrl"?c:void 0,changedBaseUrlIds2:u.type==="singleBaseUrl"?void 0:c}}if(u.type==="multipleBaseUrls"&&l.type==="multipleBaseUrls"){let{deconflictedEnvironments:d,changedBaseUrlIds:s}=IiE(u,l,r);return{environments:{defaultEnvironment:a,environments:NC.multipleBaseUrls({baseUrls:[...u.baseUrls,...d.baseUrls],environments:u.environments.flatMap(o=>d.environments.map(c=>({...o,urls:{...o.urls,...c.urls}})))})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:s}}return{environments:e??t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0}}function CiE(e,t,r,i){if(r!=null)for(let[u,l]of Object.entries(r)){for(let d of Object.values(e.services))for(let s of Object.values(d.endpoints))s.baseUrl==u&&(s.baseUrl=l);for(let d of Object.values(e.websocketChannels??{}))d.baseUrl==u&&(d.baseUrl=l)}if(i!=null)for(let[u,l]of Object.entries(i)){for(let d of Object.values(t.services))for(let s of Object.values(d.endpoints))s.baseUrl==u&&(s.baseUrl=l);for(let d of Object.values(t.websocketChannels??{}))d.baseUrl==u&&(d.baseUrl=l)}let n={...e.services??{},...t.services??{}},a={...e.websocketChannels??{},...t.websocketChannels??{}};return{services:n,websocketChannels:a}}function BiE(e,t,r){let i={},n=new Set(e.environments.map(s=>s.id)),a=new Set(e.environments.map(s=>s.name)),u=new Map(e.environments.map(s=>[s.url,s.id])),l=t.environments.filter(s=>{let o=u.get(s.url);return o!=null?(i[s.id]=o,!1):!0}).map(s=>{if(n.has(s.id)||a.has(s.name)){let o=wXs(s.id,n);return i[s.id]=o,{...s,id:o,name:r.generateName(o)}}return s});return{deconflictedEnvironments2:NC.singleBaseUrl({environments:l}),changedBaseUrlIds2:i}}function xiE(e,t,r){let i={},n=new Set(t.baseUrls.map(d=>d.id)),a=new Set(t.baseUrls.map(d=>d.name)),u=e.environments.map(d=>{if(n.has(d.id)||a.has(d.name)){let s=wXs(d.id,n);return i[d.id]=s,{...d,id:s,name:r.generateName(s)}}return d});return{deconflictedEnvironments1:NC.singleBaseUrl({environments:u}),changedBaseUrlIds1:i}}function IiE(e,t,r){let i={},n=new Set(e.baseUrls.map(s=>s.id)),a=new Set(e.baseUrls.map(s=>s.name)),u=t.baseUrls.map(s=>{if(n.has(s.id)||a.has(s.name)){let o=wXs(s.id,n);return i[s.id]=o,{...s,id:o,name:r.generateName(o)}}return s}),l=t.environments.map(s=>({...s,urls:Object.fromEntries(Object.entries(s.urls).map(([o,c])=>[i[o]??o,c]))}));return{deconflictedEnvironments:NC.multipleBaseUrls({baseUrls:u,environments:l}),changedBaseUrlIds:i}}function ve_(e){return e.environments.type==="singleBaseUrl"?e.environments.environments.some(t=>t.url&&(t.url.startsWith("ws://")||t.url.startsWith("wss://"))):e.environments.type==="multipleBaseUrls"?e.environments.environments.some(t=>Object.values(t.urls).some(r=>r&&(r.startsWith("ws://")||r.startsWith("wss://")))):!1}function wXs(e,t){let r=e,i=1;for(;t.has(r);)r=`${e}-${i}`,i++;return r}var og=class{breadcrumbs=[];constructor({breadcrumbs:t=[]}={}){this.breadcrumbs=t}};var be_={[My.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,lx(e)])),[My.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[My.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[My.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all"]),[My.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[My.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime"]),[My.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[My.GenerationLanguage.SWIFT]:new Set([])};var ziE=["go","ruby"];function vDe({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let u=c=>({unsafeName:c,safeName:RiE({name:c,keywords:NiE({generationLanguage:e,keywords:t})})}),l=L0(n),d=lx(l),s=qCi(n),o=DCi(l);return r&&(!UiE(o)&&(e==null||ziE.includes(e))&&(l=o.map((c,b)=>{if(b>0){let g=UNo(c);if(g!=null)return g;if(VNo(c))return c.toUpperCase()}return c}).join(""),d=o.map((c,b)=>{let g=UNo(c);return g??(VNo(c)?c.toUpperCase():b===0?lx(c):c)}).join("")),s=n.split(" ").map(c=>c.split(/(\d+)/).map(qCi).join("")).join("_")),{originalName:n,camelCase:u(a?.casingOverrides?.camel??l),snakeCase:u(a?.casingOverrides?.snake??s),screamingSnakeCase:u(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:u(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:n,wireValue:a,opts:u})=>({name:i.generateName(n,u),wireValue:a})};return i}function RiE({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":LiE(e)?"_"+e:e}function NiE({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return be_[e]}var FiE=/^[0-9]/;function LiE(e){return FiE.test(e)}function UiE(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=UNo(i)!=null||VNo(i),a=UNo(t)!=null||VNo(t);return n&&a})}function UNo(e){return WiE.get(e.toUpperCase())}function VNo(e){return ViE.has(e.toUpperCase())}var ViE=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),WiE=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var bFi=class e{args;spec;settings;logger;generationLanguage;smartCasing;casingsGenerator;namespace;constructor(t){this.args=t,this.spec=t.spec,this.settings=t.settings,this.logger=t.logger,this.generationLanguage=t.generationLanguage,this.smartCasing=t.smartCasing,this.namespace=t.namespace,this.casingsGenerator=vDe({generationLanguage:t.generationLanguage,keywords:void 0,smartCasing:t.smartCasing})}static BREADCRUMBS_TO_IGNORE=["properties","allOf","anyOf"];convertBreadcrumbsToName(t){let r=t.filter((n,a)=>!(/^\d+$/.test(n)||e.BREADCRUMBS_TO_IGNORE.includes(n)||a===0&&n==="components"||a===1&&n==="schemas"||t[0]==="paths"&&(a===0||a===1&&["get","post","put","delete","patch"].includes(n)||a===2&&t[1]!=null&&["get","post","put","delete","patch"].includes(t[1])&&n==="parameters"))),i=L0(r.join("_"));return i.charAt(0).toUpperCase()+i.slice(1)}createPackage(t={}){return{fernFilepath:this.createFernFilepath(t),service:void 0,types:[],errors:[],subpackages:[],docs:void 0,webhooks:void 0,websocket:void 0,hasEndpointsInTree:!1,navigationConfig:void 0}}createFernFilepath(t={}){let r=this.namespace!=null?[this.casingsGenerator.generateName(this.namespace)]:[],i=t.name!=null?this.casingsGenerator.generateName(t.name):void 0;return{allParts:i?[...r,i]:r,packagePath:r,file:i}}async resolveReference(t){let r=this.spec,i;if(t.$ref.startsWith("http://")||t.$ref.startsWith("https://")){let a=t.$ref.split("#"),u=a[0];if(i=a[1],!u)return{resolved:!1};let l=await fetch(u);if(!l.ok)return{resolved:!1};try{let d=await l.text();try{r=JSON.parse(d)}catch{r=Kd.load(d)}if(r==null)return{resolved:!1}}catch{return{resolved:!1}}if(!i)return{resolved:!0,value:r}}let n=(i??t.$ref).replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(a=>a.replace(/~1/g,"/"));for(let a of n){if(typeof r!="object"||r==null)return{resolved:!1};r=r[a]}return r==null?{resolved:!1}:{resolved:!0,value:r}}async getPropertyAccess(t){let r=t;for(;this.isReferenceObject(r);){let i=await this.resolveReference(r);if(!i.resolved)return;r=i.value}if(!(r.readOnly&&r.writeOnly)){if(r.readOnly)return cJt.ReadOnly;if(r.writeOnly)return cJt.WriteOnly}}async getAvailability({node:t,breadcrumbs:r,errorCollector:i}){for(;this.isReferenceObject(t);){let u=await this.resolveReference(t);if(!u.resolved)return;t=u.value}let a=await new HG.FernAvailabilityExtension({node:t,breadcrumbs:r}).convert({context:this,errorCollector:i});if(a!=null)return{status:a,message:void 0};if(t.deprecated===!0)return{status:d5.Deprecated,message:void 0}}getTypeIdFromSchemaReference(t){let r=t.$ref.match(/\/schemas\/(.+)$/);if(!(!r||!r[1]))return r[1]}createNamedTypeReference(t){return a_.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(t??"defaultName"),typeId:t,default:void 0,inline:!1})}typeReferenceToDeclaredTypeName(t){if(t.type!=="named")return;let r=t.typeId;return{typeId:r,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r)}}removeSchemaFromInlinedTypes({id:t,inlinedTypes:r}){return Object.fromEntries(Object.entries(r).filter(([i])=>i!==t))}maybeTrimPrefix(t,r){return t.startsWith(r)?t.slice(r.length):t}isReferenceObject(t){return typeof t=="object"&&t!==null&&"$ref"in t}isOptional(t){return t.type==="container"&&t.container.type==="optional"}isList(t){return t.type==="container"&&t.container.type==="list"}isFile(t){return t.type==="primitive"&&t.primitive.v2?.type==="string"&&t.primitive.v2.validation?.format==="binary"}getAsString(t){if(typeof t=="string")return t}getAsInteger(t){if(typeof t=="number"&&Number.isInteger(t))return t}getAsNumber(t){if(typeof t=="number")return t}getAsBoolean(t){if(typeof t=="boolean")return t}getAsArray(t){if(Array.isArray(t))return t}getAsObject(t){if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}};var mz=class extends og{getExtensionValue(t){if(!(typeof t!="object"||t==null))return t[this.key]}};var H2={};Eo(H2,{SchemaConverters:()=>SXs});var SXs={};Eo(SXs,{ArraySchemaConverter:()=>HEn,EnumSchemaConverter:()=>LEn,ObjectSchemaConverter:()=>UEn,OneOfSchemaConverter:()=>VEn,PrimitiveSchemaConverter:()=>WEn,SchemaConverter:()=>__i,SchemaOrReferenceConverter:()=>_9t});var LEn=class extends og{schema;maybeFernEnum;constructor({breadcrumbs:t,schema:r,maybeFernEnum:i}){super({breadcrumbs:t}),this.schema=r,this.maybeFernEnum=i}convert({context:t,errorCollector:r}){if(!this.schema.enum)return;let n=this.schema.enum.filter(u=>typeof u=="string").map(u=>{let l=this.maybeFernEnum?.[u],d=l?.name??u.toString();return{name:t.casingsGenerator.generateNameAndWireValue({name:d,wireValue:u.toString()}),docs:l?.description,availability:void 0,casing:l?.casing}});if(n.length===0)return;let a=t.getAsString(this.schema.default);return{enum:aw.enum({default:a!=null?n.find(u=>u.name.wireValue===a):void 0,values:n})}}};var UEn=class extends og{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){if(!this.schema.properties&&!this.schema.allOf)return{object:aw.object({properties:[],extends:[],extendedProperties:[],extraProperties:this.schema.additionalProperties!=null})};let i=[],n={};for(let[u,l]of Object.entries(this.schema.properties??{})){let d=[...this.breadcrumbs,"properties",u],s="nullable"in l?l.nullable:!1,o=t.convertBreadcrumbsToName(d),b=await new _9t({breadcrumbs:d,schemaOrReference:l,schemaIdOverride:o,wrapAsOptional:!this.schema.required?.includes(u),wrapAsNullable:s}).convert({context:t,errorCollector:r});b!=null&&(i.push({name:t.casingsGenerator.generateNameAndWireValue({name:u,wireValue:u}),valueType:b.type,docs:l.description,availability:b.availability,propertyAccess:await t.getPropertyAccess(l)}),n={...n,...b.inlinedTypes})}let a=[];for(let[u,l]of(this.schema.allOf??[]).entries()){let d=[...this.breadcrumbs,"allOf",u.toString()];if(t.isReferenceObject(l)){let s=await t.convertReferenceToTypeReference(l);s.ok&&a.push(s.reference);continue}for(let[s,o]of Object.entries(l.properties??{})){let c=[...d,s],b=t.convertBreadcrumbsToName(c),O=await new _9t({breadcrumbs:c,schemaOrReference:o,schemaIdOverride:b,wrapAsOptional:!l.required?.includes(s),wrapAsNullable:"nullable"in o?o.nullable:!1}).convert({context:t,errorCollector:r});O!=null&&(i.push({name:t.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),valueType:O.type,docs:o.description,availability:O.availability,propertyAccess:await t.getPropertyAccess(o)}),n={...n,...O.inlinedTypes})}}return{object:aw.object({properties:i,extends:a.map(u=>t.typeReferenceToDeclaredTypeName(u)).filter(y0),extendedProperties:[],extraProperties:this.schema.additionalProperties!=null}),inlinedTypes:n}}};var VEn=class extends og{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){return this.schema.discriminator!=null?await this.convertAsDiscriminatedUnion({context:t,errorCollector:r}):this.convertAsUndiscriminatedUnion({context:t,errorCollector:r})}async convertAsDiscriminatedUnion({context:t,errorCollector:r}){let i=[],n={};if(this.schema.discriminator!=null){for(let[a,u]of Object.entries(this.schema.discriminator.mapping??{})){let l=new _9t({schemaOrReference:{$ref:u},breadcrumbs:[...this.breadcrumbs,"discriminator","mapping",a]}),d=t.getTypeIdFromSchemaReference({$ref:u}),s=await l.convert({context:t,errorCollector:r});if(s?.type!=null&&d!=null){let o=t.casingsGenerator.generateNameAndWireValue({name:a,wireValue:a});i.push({docs:void 0,discriminantValue:o,availability:s.availability,displayName:void 0,shape:rG.samePropertiesAsObject({typeId:d,name:t.casingsGenerator.generateName(d),fernFilepath:{allParts:[],packagePath:[],file:void 0}})}),n={...n,...s.inlinedTypes}}}return{union:aw.union({baseProperties:[],discriminant:t.casingsGenerator.generateNameAndWireValue({name:this.schema.discriminator.propertyName,wireValue:this.schema.discriminator.propertyName}),extends:[],types:i}),inlinedTypes:n}}}async convertAsUndiscriminatedUnion({context:t,errorCollector:r}){if(!this.schema.oneOf||this.schema.oneOf.length===0)return;let i=[],n={};for(let[a,u]of this.schema.oneOf.entries()){let l=[...this.breadcrumbs,"oneOf",rba(a)??""];if(t.isReferenceObject(u)){let c=await t.convertReferenceToTypeReference(u);c.ok&&i.push({type:c.reference,docs:u.description});continue}let d=t.convertBreadcrumbsToName(l),o=await new __i({id:d,breadcrumbs:l,schema:u}).convert({context:t,errorCollector:r});o!=null&&(i.push({type:t.createNamedTypeReference(d),docs:u.description}),n={...n,...o.inlinedTypes,[d]:o.typeDeclaration})}return{union:aw.undiscriminatedUnion({members:i}),inlinedTypes:n}}};var WEn=class extends og{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}convert({context:t,errorCollector:r}){switch(this.schema.type){case"string":{let i=t.getAsString(this.schema.const);return i!=null?a_.container(eg.literal(LY.string(i))):a_.primitive({v1:"STRING",v2:Dv.string({default:t.getAsString(this.schema.default),validation:this.getStringValidation(this.schema)})})}case"number":case"integer":switch(this.schema.format){case"double":case void 0:return a_.primitive({v1:"DOUBLE",v2:Dv.double({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return a_.primitive({v1:"FLOAT",v2:Dv.float({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return a_.primitive({v1:"INTEGER",v2:Dv.integer({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return a_.primitive({v1:"LONG",v2:Dv.long({default:t.getAsNumber(this.schema.default)})});case"uint32":return a_.primitive({v1:"UINT",v2:Dv.uint({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return a_.primitive({v1:"UINT_64",v2:Dv.uint64({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return a_.primitive({v1:"INTEGER",v2:Dv.integer({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"boolean":{let i=t.getAsBoolean(this.schema.const);return i!=null?a_.container(eg.literal(LY.boolean(i))):a_.primitive({v1:"BOOLEAN",v2:Dv.boolean({default:this.schema.default})})}default:return}}getNumberValidation(t){return{max:t.maximum,min:t.minimum,exclusiveMax:typeof t.exclusiveMaximum=="boolean"?t.exclusiveMaximum:void 0,exclusiveMin:typeof t.exclusiveMinimum=="boolean"?t.exclusiveMinimum:void 0,multipleOf:t.multipleOf}}getStringValidation(t){return{minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,format:t.format}}};var __i=class extends og{schema;id;inlined;constructor({breadcrumbs:t,schema:r,id:i,inlined:n=!1}){super({breadcrumbs:t}),this.schema=r,this.id=i,this.inlined=n}async convert({context:t,errorCollector:r}){if(this.schema.enum?.length){let u=new HG.FernEnumExtension({breadcrumbs:this.breadcrumbs,schema:this.schema}).convert({context:t,errorCollector:r}),d=new LEn({breadcrumbs:this.breadcrumbs,schema:this.schema,maybeFernEnum:u}).convert({context:t,errorCollector:r});if(d!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:d.enum,context:t,errorCollector:r}),inlinedTypes:{}}}let n=new WEn({schema:this.schema}).convert({context:t,errorCollector:r});if(n!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:aw.alias({aliasOf:n,resolvedType:n}),context:t,errorCollector:r}),inlinedTypes:{}};if(this.schema.type==="array"){let u=await new HEn({breadcrumbs:this.breadcrumbs,schema:this.schema}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:aw.alias({aliasOf:u.typeReference,resolvedType:u.typeReference}),context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}if(this.schema.oneOf!=null){let u=await new VEn({breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:u.union,context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}if(this.schema.type==="object"||this.schema.properties!=null||this.schema.allOf!=null){let u=await new UEn({breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:u.object,context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}}async createTypeDeclaration({shape:t,context:r,errorCollector:i}){return{name:this.convertDeclaredTypeName({context:r}),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:await r.getAvailability({node:this.schema,breadcrumbs:this.breadcrumbs,errorCollector:i}),docs:this.schema.description,referencedTypes:new Set,source:void 0,inline:this.inlined}}convertDeclaredTypeName({context:t}){return{typeId:this.id,fernFilepath:t.createFernFilepath(),name:t.casingsGenerator.generateName(this.id)}}};var _9t=class extends og{schemaOrReference;schemaIdOverride;wrapAsOptional;wrapAsNullable;constructor({breadcrumbs:t,schemaOrReference:r,schemaIdOverride:i,wrapAsOptional:n=!1,wrapAsNullable:a=!1}){super({breadcrumbs:t}),this.schemaOrReference=r,this.schemaIdOverride=i,this.wrapAsOptional=n,this.wrapAsNullable=a}async convert({context:t,errorCollector:r}){if(t.isReferenceObject(this.schemaOrReference)){let l=await t.convertReferenceToTypeReference(this.schemaOrReference);return l.ok?{type:l.reference,inlinedTypes:{}}:void 0}let i=this.schemaIdOverride??t.convertBreadcrumbsToName(this.breadcrumbs),n=new __i({breadcrumbs:this.breadcrumbs,schema:this.schemaOrReference,id:i}),a=await t.getAvailability({node:this.schemaOrReference,breadcrumbs:this.breadcrumbs,errorCollector:r}),u=await n.convert({context:t,errorCollector:r});if(u!=null){if(u.typeDeclaration.shape.type==="alias"){let d=u.typeDeclaration.shape.aliasOf;return{type:this.wrapTypeReference(d),inlinedTypes:u.inlinedTypes,availability:a}}let l=t.createNamedTypeReference(i);return{type:this.wrapTypeReference(l),schema:u.typeDeclaration,inlinedTypes:{...u.inlinedTypes,[i]:u.typeDeclaration},availability:a}}}wrapTypeReference(t){return this.wrapAsOptional&&this.wrapAsNullable?this.wrapInOptional(this.wrapInNullable(t)):this.wrapAsOptional?this.wrapInOptional(t):this.wrapAsNullable?this.wrapInNullable(t):t}wrapInOptional(t){return a_.container(eg.optional(t))}wrapInNullable(t){return a_.container(eg.nullable(t))}};var HEn=class e extends og{static LIST_UNKNOWN=a_.container(eg.list(a_.unknown()));schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){if(this.schema.items==null)return{typeReference:e.LIST_UNKNOWN};let n=await new _9t({breadcrumbs:[...this.breadcrumbs,"items"],schemaOrReference:this.schema.items}).convert({context:t,errorCollector:r});return n!=null?{typeReference:a_.container(eg.list(n.type)),inlinedTypes:n.inlinedTypes}:{typeReference:e.LIST_UNKNOWN}}};var iba=class{errors=[];logger;constructor({logger:t}){this.logger=t}collect(t){this.errors.push(t)}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}logErrors(){for(let t of this.errors)this.logger.log(V0.Info,Wie({title:t.message,breadcrumbs:t.path,subtitle:t.path!=null?k_.dim(t.path.join(" -> ")):void 0}))}};var HG={};Eo(HG,{FernAvailabilityExtension:()=>WNo,FernEnumExtension:()=>HNo,FernIgnoreExtension:()=>$No,SdkGroupNameExtension:()=>GNo,SdkMethodNameExtension:()=>QNo});var WNo=class extends mz{node;key="x-fern-availability";constructor({breadcrumbs:t,node:r}){super({breadcrumbs:t}),this.node=r}async convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.node);if(i==null||typeof i!="string")return;switch(i.toUpperCase().replace(/[-_\s]/g,"_")){case"IN_DEVELOPMENT":return d5.InDevelopment;case"PRE_RELEASE":return d5.PreRelease;case"GENERAL_AVAILABILITY":return d5.GeneralAvailability;case"DEPRECATED":return d5.Deprecated;default:return}}};var HiE=Yu.object({snake:Yu.string().optional(),camel:Yu.string().optional(),screamingSnake:Yu.string().optional(),pascal:Yu.string().optional()}),$iE=Yu.object({description:Yu.string().optional(),name:Yu.string().optional(),casing:HiE.optional()}),ge_=Yu.record($iE);var HNo=class extends mz{schema;key="x-fern-enum";constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.schema);if(i==null)return;let n=ge_.safeParse(i);if(!n.success){r.collect({message:`Invalid x-fern-enum extension: ${n.error.message}`,path:this.breadcrumbs});return}return n.data}};var $No=class extends mz{operation;key="x-fern-ignore";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null){if(typeof i!="boolean"){r.collect({message:"Received unexpected non-boolean value for x-fern-ignore",path:this.breadcrumbs});return}return i}}};var GNo=class extends mz{operation;key="x-fern-sdk-group-name";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i==null)return;let n=Array.isArray(i)?i.filter(a=>typeof a=="string"):typeof i=="string"?[i]:[];if(n.length!==0)return{groups:n}}};var QNo=class extends mz{operation;key="x-fern-sdk-method-name";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null&&typeof i=="string")return{methodName:i}}};function rba(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),l=e%10;return l===0?i[u]:`${i[u]}_${t[l]}`}if(e<1e3){let u=Math.floor(e/100),l=e%100;return l===0?`${t[u]}_hundred`:`${t[u]}_hundred_${rba(l)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${rba(a)}`}var h_i=class e extends og{static STRING=a_.primitive({v1:"STRING",v2:Dv.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=a_.container(eg.optional(e.STRING));parameter;constructor({breadcrumbs:t,parameter:r}){super({breadcrumbs:t}),this.parameter=r}async convert({context:t,errorCollector:r}){let i,n={};if(this.parameter.schema!=null){let l=await new H2.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert({context:t,errorCollector:r});l!=null&&(i=l.type,n=l.inlinedTypes??{})}let a=await t.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs,errorCollector:r});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??(this.parameter.required?e.STRING:e.OPTIONAL_STRING),allowMultiple:this.parameter.explode??!1,availability:a},inlinedTypes:n};case"header":return{type:"header",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??(this.parameter.required?e.STRING:e.OPTIONAL_STRING),env:void 0,availability:a},inlinedTypes:n};case"path":return{type:"path",parameter:{name:t.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:i??(this.parameter.required?e.STRING:e.OPTIONAL_STRING),location:"ENDPOINT",variable:void 0},inlinedTypes:n};default:r.collect({message:`Unsupported parameter location: ${this.parameter.in}`,path:this.breadcrumbs});return}}};var JNo=class extends og{channel;channelPath;group;inlinedTypes={};constructor({breadcrumbs:t,channel:r,channelPath:i,group:n}){super({breadcrumbs:t}),this.channel=r,this.channelPath=i,this.group=n}async convert({context:t,errorCollector:r}){let i=[],n=[],a=[],u=this.group?this.group.join("."):this.channelPath;this.channel.parameters&&await this.convertQueryParameters({context:t,errorCollector:r,queryParameters:n}),this.channel.bindings?.ws!=null&&(await this.convertHeaders({context:t,errorCollector:r,headers:a}),await this.convertBindingQueryParameters({context:t,errorCollector:r,queryParameters:n}));let l;this.channel.subscribe!=null&&(l=await this.convertMessage({context:t,errorCollector:r,origin:"server",operation:this.channel.subscribe,defaultId:"subscribeEvent",breadcrumbName:"subscribeEvent"}));let d;this.channel.publish!=null&&(d=await this.convertMessage({context:t,errorCollector:r,origin:"client",operation:this.channel.publish,defaultId:"publishEvent",breadcrumbName:"publishEvent"}));let s=[];l!=null&&s.push(l),d!=null&&s.push(d);let o=this.channel.servers?.[0]??Object.keys(t.spec.servers??{})[0];return{channel:{name:t.casingsGenerator.generateName(u),displayName:u,baseUrl:o,path:{head:this.transformToValidPath(this.channel.address??this.channelPath),parts:[]},auth:!1,headers:a,queryParameters:n,pathParameters:i,messages:s,examples:[],availability:await t.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.channel.description},inlinedTypes:this.inlinedTypes}}async convertMessage({context:t,errorCollector:r,origin:i,operation:n,defaultId:a,breadcrumbName:u}){let l;if(t.isReferenceObject(n.message)){let d=await t.resolveReference(n.message);d.resolved&&(n.message=d.value)}if("oneOf"in n.message){let s=await new H2.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[...this.breadcrumbs,u],schemaOrReference:n.message,schemaIdOverride:n.operationId??a}).convert({context:t,errorCollector:r});s!=null&&s.schema!=null&&(l=s.schema,this.inlinedTypes={...this.inlinedTypes,...s.inlinedTypes})}else if(t.isMessageWithPayload(n.message)){let d;if(t.isReferenceObject(n.message.payload)){let s=await t.resolveReference(n.message.payload);s.resolved&&(d=s.value)}else d=n.message.payload;if(d!=null){let o=await new H2.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[...this.breadcrumbs,u],schemaOrReference:d,schemaIdOverride:n.operationId??a}).convert({context:t,errorCollector:r});o!=null&&o.schema!=null&&(l=o.schema,this.inlinedTypes={...this.inlinedTypes,...o.inlinedTypes})}}if(l!=null){let d=l,s=sc.TypeReference.named({fernFilepath:t.createFernFilepath(),name:d.name.name,typeId:d.name.typeId,default:void 0,inline:!1}),o=sc.WebSocketMessageBody.reference({bodyType:s,docs:n.description});return{type:d.name.typeId,displayName:d.name.name.originalName,origin:i,body:o,availability:await t.getAvailability({node:n,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:n.description}}}async convertQueryParameters({context:t,errorCollector:r,queryParameters:i}){for(let[n,a]of Object.entries(this.channel.parameters??{})){let u=a;if(t.isReferenceObject(a)){let s=await t.resolveReference(a);if(s.resolved)u=s.value;else continue}let d=await new h_i({breadcrumbs:this.breadcrumbs,parameter:{...u,name:n,in:"query",description:a.description,required:a.required??!1}}).convert({context:t,errorCollector:r});d!=null&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},d.type==="query"&&i.push(d.parameter))}}async convertHeaders({context:t,errorCollector:r,headers:i}){if(this.channel.bindings?.ws?.headers!=null){let n=this.channel.bindings.ws.headers.required??[];for(let[a,u]of Object.entries(this.channel.bindings.ws.headers.properties??{})){let l=u;if(t.isReferenceObject(u)){let o=await t.resolveReference(u);if(!o.resolved)continue;l=o.value}let s=await new h_i({breadcrumbs:[...this.breadcrumbs,a],parameter:{name:a,in:"header",required:n.includes(a),schema:l,description:"description"in l?l.description:void 0}}).convert({context:t,errorCollector:r});s!=null&&s.type==="header"&&(this.inlinedTypes={...this.inlinedTypes,...s.inlinedTypes},i.push(s.parameter))}}}async convertBindingQueryParameters({context:t,errorCollector:r,queryParameters:i}){if(this.channel.bindings?.ws?.query!=null){let n=this.channel.bindings.ws.query.required??[];for(let[a,u]of Object.entries(this.channel.bindings.ws.query.properties??{})){let l=u;if(t.isReferenceObject(u)){let o=await t.resolveReference(u);if(!o.resolved)continue;l=o.value}let s=await new h_i({breadcrumbs:[...this.breadcrumbs,a],parameter:{name:a,in:"query",required:n.includes(a),schema:l,description:"description"in l?l.description:void 0}}).convert({context:t,errorCollector:r});s!=null&&s.type==="query"&&(this.inlinedTypes={...this.inlinedTypes,...s.inlinedTypes},i.push(s.parameter))}}}transformToValidPath(t){return t.startsWith("/")?t:"/"+t}};var KNo=class extends og{servers;constructor({breadcrumbs:t,servers:r}){super({breadcrumbs:t}),this.servers=r}convert({context:t,errorCollector:r}){if(this.servers==null||Object.keys(this.servers).length===0)return;let i=[],n;for(let[a,u]of Object.entries(this.servers)){let l={id:a,name:t.casingsGenerator.generateName(a),url:this.constructServerUrl(u.protocol,u.url),docs:void 0};i.push(l),n==null&&(n=l.id)}return{defaultEnvironment:n,environments:NC.singleBaseUrl({environments:i})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var DXs="$message.",Oe_="#/channels/",me_="#/servers/",YNo=class extends og{channel;channelPath;operations;group;inlinedTypes={};constructor({breadcrumbs:t,channel:r,channelPath:i,operations:n,group:a}){super({breadcrumbs:t}),this.channel=r,this.channelPath=i,this.operations=n,this.group=a}async convert({context:t,errorCollector:r}){let i=[],n=[],a=[],u=this.group?this.group.join("."):this.channelPath;this.channel.parameters&&await this.convertChannelParameters({context:t,errorCollector:r,pathParameters:i,queryParameters:n,headers:a});let l=Object.entries(this.operations).reduce((o,[c,b])=>{try{this.getChannelPathFromOperation(b)===this.channelPath&&(o[c]=b)}catch{}return o},{}),d=[];for(let[o,c]of Object.entries(l))for(let b of c.messages){let g=await t.convertReferenceToTypeReference(b);if(g.ok){let O=sc.WebSocketMessageBody.reference({bodyType:g.reference,docs:c.description});d.push({type:o,displayName:o,origin:c.action==="send"?"client":"server",body:O,availability:await t.getAvailability({node:c,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:c.description})}}let s=this.resolveChannelServersFromReference(this.channel.servers??[],r)??Object.keys(t.spec.servers??{})[0];return{channel:{name:t.casingsGenerator.generateName(u),displayName:u,baseUrl:s,path:{head:this.transformToValidPath(this.channel.address??this.channelPath),parts:[]},auth:!1,headers:a,queryParameters:n,pathParameters:i,messages:d,examples:[],availability:await t.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.channel.description},inlinedTypes:this.inlinedTypes}}async convertChannelParameters({context:t,errorCollector:r,pathParameters:i,queryParameters:n,headers:a}){for(let u of Object.values(this.channel.parameters??{})){let l=u;if(t.isReferenceObject(u)){let g=await t.resolveReference(u);if(g.resolved)l=g.value;else continue}let d=this.convertChannelParameterLocation(u.location,r);if(d==null)continue;let{type:s,parameterKey:o}=d,b=await new h_i({breadcrumbs:this.breadcrumbs,parameter:{...l,name:o,in:s,required:!0}}).convert({context:t,errorCollector:r});if(b!=null)switch(this.inlinedTypes={...this.inlinedTypes,...b.inlinedTypes},b.type){case"path":i.push(b.parameter);break;case"query":n.push(b.parameter);break;case"header":a.push(b.parameter);break}}}convertChannelParameterLocation(t,r){try{let[i,n]=t.split("#/");if(i==null||n==null){r.collect({message:`Invalid location format: ${t}; unable to parse message type and parameter key`,path:this.breadcrumbs});return}if(!i.startsWith(DXs)){r.collect({message:`Invalid location format: ${t}; expected ${DXs} prefix`,path:this.breadcrumbs});return}let a=i.substring(DXs.length);if(a!=="header"&&a!=="path"&&a!=="payload"){r.collect({message:`Invalid message type: ${a}. Must be one of: header, path, payload`,path:this.breadcrumbs});return}return a==="payload"?{type:"query",parameterKey:n}:{type:a,parameterKey:n}}catch{r.collect({message:`Invalid location format: ${t}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`,path:this.breadcrumbs});return}}resolveChannelServersFromReference(t,r){if(t==null||t.length===0||t[0]==null)return;let i=t[0];if(!i.$ref.startsWith(me_)){r.collect({message:`Failed to resolve server name from server ref ${i.$ref}`,path:this.breadcrumbs});return}let n=i.$ref.substring(me_.length);if(n==null){r.collect({message:`Failed to find server with name ${n}`,path:this.breadcrumbs});return}return n}getChannelPathFromOperation(t){if(!t.channel.$ref.startsWith(Oe_))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring(Oe_.length)}transformToValidPath(t){return t.startsWith("/")?t:"/"+t}};var XNo=class extends og{servers;constructor({breadcrumbs:t,servers:r}){super({breadcrumbs:t}),this.servers=r}convert({context:t,errorCollector:r}){if(this.servers==null||Object.keys(this.servers).length===0)return;let i=[],n;for(let[a,u]of Object.entries(this.servers)){let l={id:a,name:t.casingsGenerator.generateName(a),url:this.constructServerUrl(u.protocol,u.host),docs:void 0};i.push(l),n==null&&(n=l.id)}return{defaultEnvironment:n,environments:NC.singleBaseUrl({environments:i})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var nba=class extends og{ir;constructor({breadcrumbs:t,context:r}){super({breadcrumbs:t}),this.ir={auth:{docs:void 0,requirement:sc.AuthSchemesRequirement.All,schemes:[]},types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:sc.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:r.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}}}}async convert({context:t,errorCollector:r}){t.spec=this.removeXFernIgnores({document:t.spec,context:t,errorCollector:r}),this.isAsyncAPIV3(t)?await this.convertChannelMessages({context:t,errorCollector:r}):await this.convertComponentMessages({context:t,errorCollector:r}),await this.convertSchemas({context:t,errorCollector:r}),await this.convertServers({context:t,errorCollector:r}),await this.convertChannels({context:t,errorCollector:r});let i={...this.ir,apiName:t.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:t.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}};return i={...i,...vFi({ir:i,exampleGeneration:{disabled:!1}})},i}isAsyncAPIV3(t){return parseFloat(t.spec.asyncapi)>=3}removeXFernIgnores({document:t,context:r,errorCollector:i,breadcrumbs:n=[]}){return Array.isArray(t)?t.filter((a,u)=>!new HG.FernIgnoreExtension({breadcrumbs:[...n,String(u)],operation:a}).convert({context:r,errorCollector:i})).map((a,u)=>this.removeXFernIgnores({document:a,context:r,errorCollector:i,breadcrumbs:[...n,String(u)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([a,u])=>!new HG.FernIgnoreExtension({breadcrumbs:[...n,a],operation:u}).convert({context:r,errorCollector:i})).map(([a,u])=>[a,this.removeXFernIgnores({document:u,context:r,errorCollector:i,breadcrumbs:[...n,a]})])):t}async convertChannelMessages({context:t,errorCollector:r}){let i=t.spec;for(let[n,a]of Object.entries(i.channels??{}))for(let[u,l]of Object.entries(a.messages??{})){if(!t.isMessageWithPayload(l)&&!t.isReferenceObject(l))continue;let d;if(t.isMessageWithPayload(l))if(t.isReferenceObject(l.payload)){let b=await t.resolveReference(l.payload);b.resolved&&(d=b.value)}else d=l.payload;else if(t.isReferenceObject(l)){let b=await t.resolveReference(l);if(b.resolved){let g=b.value.payload;if(t.isReferenceObject(g)){let O=await t.resolveReference(g);O.resolved&&(d=O.value)}else d=g}}if(d==null)continue;let s=`${n}_${u}`,c=await new H2.SchemaConverters.SchemaConverter({id:s,breadcrumbs:["channels",n,"messages",u],schema:d}).convert({context:t,errorCollector:r});c!=null&&(this.ir.rootPackage.types.push(s),this.ir.types={...this.ir.types,...c.inlinedTypes,[s]:c.typeDeclaration})}}async convertComponentMessages({context:t,errorCollector:r}){for(let[i,n]of Object.entries(t.spec.components?.messages??{})){if(n.payload==null)continue;let a;if(t.isReferenceObject(n.payload)){let d=await t.resolveReference(n.payload);d.resolved&&(a=d.value)}else a=n.payload;if(a==null)continue;let l=await new H2.SchemaConverters.SchemaConverter({id:i,breadcrumbs:["components","messages",i],schema:a}).convert({context:t,errorCollector:r});l!=null&&(this.ir.rootPackage.types.push(i),this.ir.types={...this.ir.types,...l.inlinedTypes,[i]:l.typeDeclaration})}}async convertSchemas({context:t,errorCollector:r}){for(let[i,n]of Object.entries(t.spec.components?.schemas??{})){let u=await new H2.SchemaConverters.SchemaConverter({id:i,breadcrumbs:["components","schemas",i],schema:n}).convert({context:t,errorCollector:r});u!=null&&(this.ir.rootPackage.types.push(i),this.ir.types={...this.ir.types,...u.inlinedTypes,[i]:u.typeDeclaration})}}async convertServers({context:t,errorCollector:r}){if(this.isAsyncAPIV3(t)){let i=t.spec.servers,a=new XNo({breadcrumbs:["servers"],servers:i}).convert({context:t,errorCollector:r});a!=null&&(this.ir.environments=a)}else{let i=t.spec.servers,a=new KNo({breadcrumbs:["servers"],servers:i}).convert({context:t,errorCollector:r});a!=null&&(this.ir.environments=a)}}async convertChannels({context:t,errorCollector:r}){for(let[i,n]of Object.entries(t.spec.channels??{})){let u=new HG.SdkGroupNameExtension({breadcrumbs:["channels",i],operation:n}).convert({context:t,errorCollector:r})?.groups;if(this.isAsyncAPIV3(t)){let d=t.spec.operations??{},o=await new YNo({breadcrumbs:["channels",i],channel:n,channelPath:i,operations:d,group:u}).convert({context:t,errorCollector:r});o!=null&&(this.ir.websocketChannels={...this.ir.websocketChannels,[u?u.join("."):i]:o.channel},this.ir.types={...this.ir.types,...o.inlinedTypes})}else{let d=await new JNo({breadcrumbs:["channels",i],channel:n,channelPath:i,group:u}).convert({context:t,errorCollector:r});d!=null&&(this.ir.websocketChannels={...this.ir.websocketChannels,[u?u.join("."):i]:d.channel},this.ir.types={...this.ir.types,...d.inlinedTypes})}}this.addWebsocketsToIr({websocketChannels:this.ir.websocketChannels,context:t})}addWebsocketsToIr({websocketChannels:t,context:r}){if(t!=null)for(let[i,n]of Object.entries(t))i!==""?(this.ir.subpackages[i]==null&&(this.ir.subpackages[i]={name:r.casingsGenerator.generateName(i),...r.createPackage({name:i})}),this.ir.subpackages[i].websocket=i,this.ir.rootPackage.subpackages.push(i)):this.ir.rootPackage.websocket=i}};var aba=class extends bFi{isReferenceObject(t){return t!=null&&"$ref"in t}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}getTypeIdFromMessageReference(t){let r=t.$ref.match(/\/messages\/(.+)$/);if(!(!r||!r[1]))return r[1]}async convertReferenceToTypeReference(t){let r,i=t.$ref.match(/^.*\/schemas\/(.+)$/),n=t.$ref.match(/^.*\/messages\/(.+)$/);return i&&i[1]?r=i[1]:n&&n[1]&&(r=n[1]),r==null?{ok:!1}:(await this.resolveReference(t)).resolved?{ok:!0,reference:a_.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(r),typeId:r,default:void 0,inline:!1})}:{ok:!1}}};var we_=di(EXs(),1);var TXs=di(EXs(),1);var Pe_=["get","post","put","delete","patch"];var ZNo=class extends mz{operation;key="x-fern-idempotent";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null){if(typeof i!="boolean"){r.collect({message:"Received unexpected non-boolean value for x-fern-idempotent",path:this.breadcrumbs});return}return i}}};var JiE=Yu.object({cursor:Yu.string(),next_cursor:Yu.string(),results:Yu.string()}),KiE=Yu.object({offset:Yu.string(),results:Yu.string(),step:Yu.string().optional(),"has-next-page":Yu.string().optional()}),MXs=Yu.union([Yu.boolean(),JiE,KiE]);var AXs="$request.",kNo="$response.",eFo=class extends mz{operation;document;key="x-fern-pagination";constructor({breadcrumbs:t,operation:r,document:i}){super({breadcrumbs:t}),this.operation=r,this.document=i}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i==null)return;let n=MXs.safeParse(i);if(!n.success){r.collect({message:`Invalid x-fern-pagination extension: ${n.error.message}`,path:this.breadcrumbs});return}if(typeof n.data=="boolean"){let a=this.getExtensionValue(this.document);if(a==null)return;if(typeof a=="boolean"){r.collect({message:"Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.",path:this.breadcrumbs});return}let u=MXs.safeParse(a);if(!u.success){r.collect({message:`Invalid x-fern-pagination extension: ${u.error.message}`,path:this.breadcrumbs});return}if(typeof u.data=="boolean"){r.collect({message:"Global pagination extension is a boolean, expected an object.",path:this.breadcrumbs});return}return this.convertPaginationConfig(u.data,t)}if(typeof n.data=="boolean"){r.collect({message:"Pagination extension is a boolean with no global configuration.",path:this.breadcrumbs});return}return this.convertPaginationConfig(n.data,t)}convertPaginationConfig(t,r){let i=t;if("cursor"in i)return{type:"cursor",cursor:r.maybeTrimPrefix(i.cursor,AXs),nextCursor:r.maybeTrimPrefix(i.next_cursor,kNo),results:r.maybeTrimPrefix(i.results,kNo)};let n=t;return{type:"offset",offset:r.maybeTrimPrefix(n.offset,AXs),results:r.maybeTrimPrefix(n.results,kNo),step:n.step!=null?r.maybeTrimPrefix(n.step,AXs):void 0,hasNextPage:n["has-next-page"]!=null?r.maybeTrimPrefix(n["has-next-page"],kNo):void 0}}};var YiE="$request.",XiE=Yu.object({"stream-condition":Yu.string().optional(),format:Yu.enum(["sse","json"]).optional(),"stream-description":Yu.string().optional(),"response-stream":Yu.any(),response:Yu.any()}),ZiE=Yu.union([Yu.boolean(),XiE]),$En=class extends mz{operation;key="x-fern-streaming";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i==null)return;let n=ZiE.safeParse(i);if(!n.success){r.collect({message:`Invalid x-fern-streaming extension: ${n.error.message}`,path:this.breadcrumbs});return}if(typeof n.data=="boolean")return n.data?{type:"stream",format:"json"}:void 0;if(n.data["stream-condition"]==null&&n.data.format!=null)return{type:"stream",format:n.data.format};if(n.data["stream-condition"]==null){r.collect({message:"Missing required stream-condition property",path:this.breadcrumbs});return}return{type:"streamCondition",format:n.data.format??"json",streamDescription:n.data["stream-description"],streamConditionProperty:t.maybeTrimPrefix(n.data["stream-condition"],YiE),responseStream:n.data["response-stream"],response:n.data.response}}};var tFo=class extends mz{operation;key="x-fern-webhook";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null){if(typeof i!="boolean"){r.collect({message:"Received unexpected non-boolean value for x-fern-webhook",path:this.breadcrumbs});return}return i}}};var rFo=class extends mz{server;key="x-fern-server-name";constructor({breadcrumbs:t,server:r}){super({breadcrumbs:t}),this.server=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.server);if(!(i==null||typeof i!="string"))return i}};var qXs="Base",GEn=class e extends og{servers;endpointLevelServers;constructor({breadcrumbs:t,servers:r,endpointLevelServers:i}){super({breadcrumbs:t}),this.servers=r,this.endpointLevelServers=i}convert({context:t,errorCollector:r}){if(this.servers==null||this.servers.length===0||this.servers[0]==null)return;if(this.endpointLevelServers!=null&&this.endpointLevelServers.length>0){let n={id:qXs,name:t.casingsGenerator.generateName(qXs)},a=this.endpointLevelServers.map(d=>{let s=e.getServerName({server:d,errorCollector:r,context:t});return{id:s,name:t.casingsGenerator.generateName(s)}}).filter((d,s,o)=>o.findIndex(c=>c.id===d.id)===s),u=[n,...a],l=this.servers.map(d=>{let s=e.getServerName({server:d,errorCollector:r,context:t}),o=this.endpointLevelServers?.map(c=>[e.getServerName({server:c,errorCollector:r,context:t}),this.getServerUrl(c)]);return{id:s,name:t.casingsGenerator.generateName(s),urls:{[qXs]:this.getServerUrl(d),...Object.fromEntries(o??[])},docs:d.description}});return{value:{defaultEnvironment:l[0]?.id,environments:NC.multipleBaseUrls({baseUrls:u,environments:l})},defaultUrl:e.getServerName({server:this.servers[0],errorCollector:r,context:t})}}let i=this.servers.map(n=>{let a=e.getServerName({server:n,context:t,errorCollector:r});return{id:a,name:t.casingsGenerator.generateName(a),url:this.getServerUrl(n),docs:n.description}}).filter(y0);return{value:{defaultEnvironment:i[0]?.id,environments:NC.singleBaseUrl({environments:i})}}}static getServerName({server:t,context:r,errorCollector:i}){return new rFo({breadcrumbs:[],server:t}).convert({context:r,errorCollector:i})??t.description??t.url}getServerUrl(t){if(t.variables==null)return t.url;let r=t.url;for(let[i,n]of Object.entries(t.variables))n.default!=null&&(r=r.replace(`{${i}}`,n.default));return r}};var oba=class e extends og{static STRING=a_.primitive({v1:"STRING",v2:Dv.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=a_.container(eg.optional(e.STRING));parameter;constructor({breadcrumbs:t,parameter:r}){super({breadcrumbs:t}),this.parameter=r}async convert({context:t,errorCollector:r}){let i,n={};if(this.parameter.schema!=null){let l=await new H2.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert({context:t,errorCollector:r});l!=null&&(i=l.type,n=l.inlinedTypes??{})}let a=await t.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs,errorCollector:r});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??e.OPTIONAL_STRING,allowMultiple:this.parameter.explode??!1,availability:a},inlinedTypes:n};case"header":return{type:"header",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??e.OPTIONAL_STRING,env:void 0,availability:a},inlinedTypes:n};case"path":return{type:"path",parameter:{name:t.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:i??e.STRING,location:"ENDPOINT",variable:void 0},inlinedTypes:n};default:return}}};var iFo=class extends og{requestBody;group;method;constructor({breadcrumbs:t,requestBody:r,group:i,method:n}){super({breadcrumbs:t}),this.requestBody=r,this.group=i,this.method=n}async convert({context:t,errorCollector:r}){if(!this.requestBody.content)return;let i=Object.keys(this.requestBody.content).filter(u=>u.includes("json"));for(let u of i){let l=this.handleJsonOrFormContent({contentType:u,context:t,errorCollector:r});if(l!=null)return l}let n=Object.keys(this.requestBody.content).filter(u=>u.includes("multipart"));for(let u of n){let l=[...this.group,this.method,"Request"].join("_"),d=await this.convertRequestSchemaForMediaType({schemaId:l,contentType:u,context:t,errorCollector:r});if(d!=null&&d.schema?.shape.type==="object")return{requestBody:pI.fileUpload({docs:this.requestBody.description,name:t.casingsGenerator.generateName(l),properties:d.schema?.shape.properties.map(o=>this.convertRequestBodyProperty({context:t,property:o,contentType:u}))}),inlinedTypes:t.removeSchemaFromInlinedTypes({id:l,inlinedTypes:d.inlinedTypes}),examples:d.examples}}let a=Object.keys(this.requestBody.content).filter(u=>u.includes("urlencoded"));for(let u of a){let l=this.handleJsonOrFormContent({contentType:u,context:t,errorCollector:r});if(l!=null)return l}}async convertRequestSchemaForMediaType({schemaId:t,contentType:r,context:i,errorCollector:n}){let a=this.requestBody.content[r];if(a==null||a.schema==null)return;let l=await new H2.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:a.schema,schemaIdOverride:t}).convert({context:i,errorCollector:n});if(l==null)return;let d=a.examples!=null?Object.fromEntries(await Promise.all(Object.entries(a.examples).map(async([s,o])=>[s,i.isReferenceObject(o)?await i.resolveReference(o):o]))):void 0;return{...l,examples:d}}async handleJsonOrFormContent({contentType:t,context:r,errorCollector:i}){let n=[...this.group,this.method,"Request"].join("_"),a=await this.convertRequestSchemaForMediaType({schemaId:n,contentType:t,context:r,errorCollector:i});if(a!=null)return a.schema?.shape.type==="object"?{requestBody:pI.inlinedRequestBody({contentType:t,docs:this.requestBody.description,name:r.casingsGenerator.generateName(n),extendedProperties:a.schema?.shape.extendedProperties,extends:a.schema?.shape.extends,properties:a.schema?.shape.properties,extraProperties:a.schema?.shape.extraProperties}),inlinedTypes:r.removeSchemaFromInlinedTypes({id:n,inlinedTypes:a.inlinedTypes})}:{requestBody:pI.reference({contentType:t,docs:this.requestBody.description,requestBodyType:a.type}),inlinedTypes:r.removeSchemaFromInlinedTypes({id:n,inlinedTypes:a.inlinedTypes})}}convertRequestBodyProperty({context:t,property:r,contentType:i}){return t.isFile(r.valueType)?aF.file(QU.file({key:r.name,isOptional:!1,contentType:i,docs:r.docs})):t.isOptional(r.valueType)&&t.isFile(r.valueType.container.optional)?aF.file(QU.file({key:r.name,isOptional:!0,contentType:i,docs:r.docs})):t.isList(r.valueType)&&t.isFile(r.valueType.container.list)?aF.file(QU.fileArray({key:r.name,isOptional:!1,contentType:i,docs:r.docs})):t.isList(r.valueType)&&t.isOptional(r.valueType.container.list)&&t.isFile(r.valueType.container.list.container.optional)?aF.file(QU.fileArray({key:r.name,isOptional:!1,contentType:i,docs:r.docs})):t.isOptional(r.valueType)&&t.isList(r.valueType.container.optional)&&t.isFile(r.valueType.container.optional.container.list)?aF.file(QU.fileArray({key:r.name,isOptional:!0,contentType:i,docs:r.docs})):aF.bodyProperty({...r,contentType:i,style:void 0,name:r.name})}};var nFo=class extends og{responseBody;group;method;statusCode;streamingExtension;constructor({breadcrumbs:t,responseBody:r,group:i,method:n,statusCode:a,streamingExtension:u}){super({breadcrumbs:t}),this.responseBody=r,this.group=i,this.method=n,this.statusCode=a,this.streamingExtension=u}async convert({context:t,errorCollector:r}){if(!this.responseBody.content)return;let i=Object.keys(this.responseBody.content).filter(a=>a.includes("json"));for(let a of[...i]){let u=await this.parseMediaTypeObject({context:t,errorCollector:r,contentType:a});if(u!=null&&a.includes("json"))return{responseBody:JA.json(MSe.response({responseBodyType:u.convertedSchema.type,docs:this.responseBody.description})),inlinedTypes:u.convertedSchema.inlinedTypes,examples:u.examples}}let n=Object.keys(this.responseBody.content).filter(a=>!a.includes("json"));for(let a of n){let u=await this.parseMediaTypeObject({context:t,errorCollector:r,contentType:a});if(u!=null&&this.isBinarySchema(u.convertedSchema))return t.settings?.useBytesForBinaryResponse&&this.streamingExtension==null?{responseBody:JA.bytes({docs:this.responseBody.description}),inlinedTypes:{}}:{responseBody:JA.fileDownload({docs:this.responseBody.description}),inlinedTypes:{}}}}async parseMediaTypeObject({context:t,errorCollector:r,contentType:i}){let n=this.responseBody.content?.[i];if(n==null||n.schema==null)return;let a=[...this.group,this.method,"Response",this.statusCode].join("_"),l=await new H2.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:n.schema,schemaIdOverride:a}).convert({context:t,errorCollector:r});if(l==null)return;let d=n.examples!=null?Object.fromEntries(await Promise.all(Object.entries(n.examples).map(async([s,o])=>[s,t.isReferenceObject(o)?await t.resolveReference(o):o]))):void 0;return{convertedSchema:l,examples:d}}isBinarySchema(t){let r=t.type;switch(r.type){case"container":case"named":case"unknown":return!1;case"primitive":return r.primitive.v2==null?!1:r.primitive.v2.type==="string"&&r.primitive.v2.validation?.format==="binary";default:return!1}}};var kiE=/{([^}]+)}/g,QEn=class extends og{operation;method;path;inlinedTypes={};constructor({breadcrumbs:t,operation:r,method:i,path:n}){super({breadcrumbs:t}),this.operation=r,this.method=i,this.path=n}convertHttpMethod(){switch(this.method){case"get":return b7.Get;case"post":return b7.Post;case"put":return b7.Put;case"delete":return b7.Delete;case"patch":return b7.Patch;default:return}}async convertParameters({context:t,errorCollector:r,breadcrumbs:i}){let n=[],a=[],u=[];if(!this.operation.parameters)return{pathParameters:n,queryParameters:a,headers:u};for(let s of this.operation.parameters){if(t.isReferenceObject(s)){let b=await t.resolveReference(s);if(b.resolved)s=b.value;else continue}let c=await new oba({breadcrumbs:i,parameter:s}).convert({context:t,errorCollector:r});if(c!=null)switch(this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},c.type){case"path":n.push(c.parameter);break;case"query":a.push(c.parameter);break;case"header":u.push(c.parameter);break}}let d=[...this.path.matchAll(kiE)].map(s=>s[1]).filter(s=>!n.some(o=>o.name.originalName===s));for(let s of d)s!=null&&n.push({name:t.casingsGenerator.generateName(s),valueType:oba.STRING,docs:void 0,location:"ENDPOINT",variable:void 0});return{pathParameters:n,queryParameters:a,headers:u}}async convertRequestBody({context:t,errorCollector:r,breadcrumbs:i,group:n,method:a}){if(this.operation.requestBody==null)return;let u;if(t.isReferenceObject(this.operation.requestBody)){let s=await t.resolveReference(this.operation.requestBody);s.resolved&&(u=s.value)}else u=this.operation.requestBody;if(u==null)return null;let d=await new iFo({breadcrumbs:i,requestBody:u,group:n??[],method:a}).convert({context:t,errorCollector:r});if(d!=null)return this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},{value:d.requestBody,examples:d.examples}}async convertResponseBody({context:t,errorCollector:r,breadcrumbs:i,group:n,method:a,streamingExtension:u}){if(this.operation.responses!=null)for(let[l,d]of Object.entries(this.operation.responses)){let s=parseInt(l);if(isNaN(s)||s<200||s>=300)continue;let o;if(t.isReferenceObject(d)){let g=await t.resolveReference(d);g.resolved&&(o=g.value)}else o=d;if(o==null)continue;let b=await new nFo({breadcrumbs:[...i,l],responseBody:o,group:n??[],method:a,statusCode:l,streamingExtension:u}).convert({context:t,errorCollector:r});if(b!=null)return this.inlinedTypes={...this.inlinedTypes,...b.inlinedTypes},{value:{statusCode:s,body:b.responseBody},examples:b.examples}}}computeGroupNameAndLocationFromExtensions({context:t,errorCollector:r}){let n=new HG.SdkMethodNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation}).convert({context:t,errorCollector:r})?.methodName,u=new HG.SdkGroupNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation}).convert({context:t,errorCollector:r})?.groups??[];if(n!=null)return{group:u,method:n}}computeGroupNameFromTagAndOperationId({context:t,errorCollector:r}){let i=this.operation.tags?.[0],n=this.operation.operationId;if(n==null){let l=this.operation.summary!=null?L0(this.operation.summary):L0(`${this.method}_${this.path.split("/").join("_")}`);return i!=null?{group:[i],method:l}:{method:l}}if(i==null)return{method:n};let a=je_(i),u=je_(n);return oSe(a,u)?{method:i}:this.computeGroupAndMethodFromTokens({tag:i,tagTokens:a,operationId:n,operationIdTokens:u})}computeGroupAndMethodFromTokens({tag:t,tagTokens:r,operationId:i,operationIdTokens:n}){if(r.some((l,d)=>l!==n[d]))return{group:[t],method:i};let u=n.slice(r.length);return{group:[t],method:L0(u.join("_"))}}};function je_(e){let t=enE(e)?tnE(e):rnE(e);return t=t.map(r=>r.toLowerCase()),t=NBe(t),t}function enE(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function tnE(e){return e.split(/(?=[A-Z])/)}function rnE(e){return e.split(/[^a-zA-Z0-9]+/)}var aFo=class extends QEn{idempotent;servers;streamingExtensionConverter;constructor({breadcrumbs:t,operation:r,method:i,path:n,idempotent:a,servers:u}){super({breadcrumbs:t,operation:r,method:i,path:n}),this.idempotent=a,this.servers=u,this.streamingExtensionConverter=new $En({breadcrumbs:this.breadcrumbs,operation:this.operation})}async convert({context:t,errorCollector:r}){let i=this.convertHttpMethod();if(i==null)return;let{group:n,method:a}=this.computeGroupNameAndLocationFromExtensions({context:t,errorCollector:r})??this.computeGroupNameFromTagAndOperationId({context:t,errorCollector:r}),u=this.streamingExtensionConverter.convert({context:t,errorCollector:r}),{headers:l,pathParameters:d,queryParameters:s}=await this.convertParameters({context:t,errorCollector:r,breadcrumbs:[...this.breadcrumbs,"parameters"]}),o=await this.convertRequestBody({context:t,errorCollector:r,breadcrumbs:[...this.breadcrumbs,"requestBody"],group:n,method:a}),c=o?.value,b=await this.convertResponseBody({context:t,errorCollector:r,breadcrumbs:[...this.breadcrumbs,"responses"],group:n,method:a,streamingExtension:u}),g=this.operation.servers?.[0]??this.servers?.[0]??t.spec.servers?.[0],O=[];return t.namespace!=null&&O.push(t.namespace),O.push(...n??[]),O.push(a),{group:n,endpoint:{id:O.join("."),displayName:this.operation.summary,method:i,name:t.casingsGenerator.generateName(a),baseUrl:g!=null?GEn.getServerName({server:g,context:t,errorCollector:r}):void 0,path:LV(this.path),pathParameters:d,queryParameters:s,headers:l,requestBody:c,sdkRequest:void 0,response:b?.value,errors:[],auth:this.operation.security!=null||t.spec.security!=null,availability:await t.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.operation.description,userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:this.idempotent??!1,basePath:void 0,fullPath:LV(this.path),allPathParameters:d,pagination:void 0,transport:void 0},inlinedTypes:this.inlinedTypes,servers:this.operation.servers}}convertExamples({requestExamples:t,responseExamples:r,context:i}){return[]}};var JEn=class extends QEn{constructor({breadcrumbs:t,operation:r,method:i,path:n}){super({breadcrumbs:t,operation:r,method:i,path:n})}async convert({context:t,errorCollector:r}){if(this.operation.operationId==null){r.collect({message:"Skipping webhook because no operation id present",path:this.breadcrumbs});return}if(this.operation.requestBody==null){r.collect({message:"Skipping webhook because no request body present",path:this.breadcrumbs});return}let i=this.convertHttpMethod();if(i==null)return;if(i!=="POST"&&i!=="GET"){r.collect({message:"Skipping webhook because non-POST or GET method",path:this.breadcrumbs});return}let{group:n,method:a}=this.computeGroupNameAndLocationFromExtensions({context:t,errorCollector:r})??this.computeGroupNameFromTagAndOperationId({context:t,errorCollector:r}),u=[...this.breadcrumbs,"Payload"],{headers:l,pathParameters:d,queryParameters:s}=await this.convertParameters({context:t,errorCollector:r,breadcrumbs:u}),o=await this.convertRequestBody({context:t,errorCollector:r,breadcrumbs:u,group:n,method:a}),c;if(o?.value.type==="inlinedRequestBody")c=YU.inlinedPayload({name:o.value.name,extends:o.value.extends,properties:o.value.properties});else if(o?.value.type==="reference")c=YU.reference({payloadType:o.value.requestBodyType,docs:o.value.docs});else return;return{group:n,webhook:{id:`${n?.join(".")??""}.${a}`,name:t.casingsGenerator.generateName(a),displayName:this.operation.summary,method:i,headers:l,payload:c,examples:[],availability:await t.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.operation.description},inlinedTypes:this.inlinedTypes}}};var oFo=class extends og{pathItem;path;servers;constructor({breadcrumbs:t,pathItem:r,path:i,servers:n}){super({breadcrumbs:t}),this.pathItem=r,this.path=i,this.servers=n}async convert({context:t,errorCollector:r}){let i=[],n=[],a={};for(let u of Pe_){let l=this.pathItem[u];if(l==null)continue;let d=[...this.breadcrumbs,u],s=await this.tryParseAsWebhook({operationBreadcrumbs:d,operation:l,method:u,context:t,errorCollector:r});if(s!=null){n.push(s),Object.assign(a,s.inlinedTypes);continue}new $En({breadcrumbs:d,operation:l}).convert({context:t,errorCollector:r})!=null;let b=await this.tryParseAsHttpEndpoint({operationBreadcrumbs:d,operation:l,method:u,context:t,errorCollector:r});b!=null&&(i.push(b),Object.assign(a,b.inlinedTypes))}return{endpoints:i,webhooks:n,inlinedTypes:a}}async tryParseAsWebhook({operation:t,method:r,operationBreadcrumbs:i,context:n,errorCollector:a}){return new tFo({breadcrumbs:i,operation:t}).convert({context:n,errorCollector:a})?await new JEn({breadcrumbs:i,operation:t,method:TXs.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert({context:n,errorCollector:a}):void 0}async tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:i,context:n,errorCollector:a}){new eFo({breadcrumbs:i,operation:t,document:n.spec}).convert({context:n,errorCollector:a})!=null;let s=new ZNo({breadcrumbs:i,operation:t}).convert({context:n,errorCollector:a});return await new aFo({breadcrumbs:i,operation:t,method:TXs.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:s}).convert({context:n,errorCollector:a})}};var uFo=class extends og{securityScheme;constructor({breadcrumbs:t,securityScheme:r}){super({breadcrumbs:t}),this.securityScheme=r}convert({context:t,errorCollector:r}){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme==="bearer")return FR.bearer({token:t.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description});if(this.securityScheme.scheme==="basic")return FR.basic({username:t.casingsGenerator.generateName("username"),password:t.casingsGenerator.generateName("password"),usernameEnvVar:void 0,passwordEnvVar:void 0,docs:this.securityScheme.description});break}case"apiKey":{if(this.securityScheme.in==="header")return FR.header({name:{name:t.casingsGenerator.generateName(this.securityScheme.name),wireValue:this.securityScheme.name},valueType:a_.container(eg.optional(a_.primitive({v1:"STRING",v2:Dv.string({default:void 0,validation:void 0})}))),prefix:void 0,headerEnvVar:void 0,docs:this.securityScheme.description});break}case"oauth2":return FR.bearer({token:t.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var uba=class extends og{ir;constructor({breadcrumbs:t,context:r}){super({breadcrumbs:t}),this.ir={auth:{docs:void 0,requirement:sc.AuthSchemesRequirement.All,schemes:[]},types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:sc.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:r.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}}}}async convert({context:t,errorCollector:r}){t.spec=this.removeXFernIgnores({document:t.spec,context:t,errorCollector:r}),await this.convertSecuritySchemes({context:t,errorCollector:r}),await this.convertSchemas({context:t,errorCollector:r}),await this.convertWebhooks({context:t,errorCollector:r});let{endpointLevelServers:i}=await this.convertPaths({context:t,errorCollector:r});this.convertServers({context:t,errorCollector:r,endpointLevelServers:i});let n={...this.ir,apiName:t.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:t.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}};return n={...n,...vFi({ir:n,exampleGeneration:{disabled:!1}})},n}removeXFernIgnores({document:t,context:r,errorCollector:i,breadcrumbs:n=[]}){return Array.isArray(t)?t.filter((a,u)=>!new HG.FernIgnoreExtension({breadcrumbs:[...n,String(u)],operation:a}).convert({context:r,errorCollector:i})).map((a,u)=>this.removeXFernIgnores({document:a,context:r,errorCollector:i,breadcrumbs:[...n,String(u)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([a,u])=>!new HG.FernIgnoreExtension({breadcrumbs:[...n,a],operation:u}).convert({context:r,errorCollector:i})).map(([a,u])=>[a,this.removeXFernIgnores({document:u,context:r,errorCollector:i,breadcrumbs:[...n,a]})])):t}async convertSecuritySchemes({context:t,errorCollector:r}){let i=[];for(let[n,a]of Object.entries(t.spec.components?.securitySchemes??{})){let u;if(t.isReferenceObject(a)){let s=await t.resolveReference(a);if(!s.resolved)continue;u=s.value}else u=a;let d=new uFo({breadcrumbs:["components","securitySchemes",n],securityScheme:u}).convert({context:t,errorCollector:r});d!=null&&i.push(d)}i.length>0&&(this.ir.auth={requirement:"ANY",schemes:i,docs:void 0})}convertServers({context:t,errorCollector:r,endpointLevelServers:i}){let a=new GEn({breadcrumbs:["servers"],servers:t.spec.servers,endpointLevelServers:i}).convert({context:t,errorCollector:r});a!=null&&(this.ir.environments=a.value)}async convertSchemas({context:t,errorCollector:r}){let i=this.getGroup({groupParts:[],namespace:t.namespace}),n=this.getOrCreatePackage({context:t,group:i});for(let[a,u]of Object.entries(t.spec.components?.schemas??{})){let d=await new H2.SchemaConverters.SchemaConverter({id:a,breadcrumbs:["components","schemas",a],schema:u}).convert({context:t,errorCollector:r});d!=null&&(n.types.push(a),this.ir.types={...this.ir.types,...d.inlinedTypes,[a]:d.typeDeclaration})}}async convertWebhooks({context:t,errorCollector:r}){let i={};for(let[,n]of Object.entries(t.spec.webhooks??{})){if(n==null||!("post"in n)||!n.post?.operationId)continue;let a=n.post.operationId,l=await new JEn({breadcrumbs:["webhooks",a],operation:n.post,method:we_.OpenAPIV3.HttpMethods.POST,path:a}).convert({context:t,errorCollector:r});if(l!=null){let d=l.group?.join(".")??a;i[d]==null&&(i[d]=[]),i[d].push(a),this.ir.webhookGroups[d]==null&&(this.ir.webhookGroups[d]=[]),this.ir.webhookGroups[d].push(l.webhook),this.ir.types={...this.ir.types,...l.inlinedTypes}}}}async convertPaths({context:t,errorCollector:r}){let i=[];for(let[n,a]of Object.entries(t.spec.paths??{})){if(a==null)continue;let l=await new oFo({breadcrumbs:["paths",n],pathItem:a,path:n,servers:t.spec.servers}).convert({context:t,errorCollector:r});if(l!=null){for(let d of l.endpoints){let s=this.getGroup({groupParts:d.group,namespace:t.namespace}),o=s.join("."),c=this.getOrCreatePackage({context:t,group:d.group}),b=[...s].map(O=>t.casingsGenerator.generateName(O)),g=b[b.length-1];c.service==null&&(c.service=`service_${o}`),this.ir.services[c.service]==null&&(this.ir.services[c.service]={name:{fernFilepath:{allParts:b,packagePath:b.slice(0,-1),file:g}},displayName:void 0,basePath:LV(""),headers:[],pathParameters:[],availability:void 0,endpoints:[],transport:void 0,encoding:void 0}),this.ir.services[c.service]?.endpoints.push(d.endpoint),d.servers&&d.servers[0]!=null&&i.push(d.servers[0])}for(let d of l.webhooks){let o=this.getGroup({groupParts:d.group,namespace:t.namespace}).join("."),c=this.getOrCreatePackage({context:t,group:d.group});this.ir.webhookGroups[o]??=[],this.ir.webhookGroups[o].push(d.webhook),c.webhooks=o}this.ir.types={...this.ir.types,...l.inlinedTypes}}}return{endpointLevelServers:i}}getOrCreatePackage({context:t,group:r}){let i=[];if(t.namespace!=null&&i.push(t.namespace),i.push(...r??[]),i.length==0)return this.ir.rootPackage;let n=this.ir.rootPackage;for(let a=0;a<i.length;a++){let u=i[a],l=i.slice(0,a+1).join(".");this.ir.subpackages[l]==null&&(this.ir.subpackages[l]={name:t.casingsGenerator.generateName(u),...t.createPackage({name:u})});let d=this.ir.subpackages[l];n.subpackages.includes(l)||n.subpackages.push(l),n=d}return n}getGroup({groupParts:t,namespace:r}){let i=[];return r!=null&&i.push(r),i.push(...t??[]),i}};var sba=class extends bFi{isReferenceObject(t){return t!=null&&"$ref"in t}async convertReferenceToTypeReference(t){let r=this.getTypeIdFromSchemaReference(t);return r==null?{ok:!1}:(await this.resolveReference(t)).resolved?{ok:!0,reference:a_.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r),typeId:r,default:void 0,inline:!1})}:{ok:!1}}};var Se_={[My.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,lx(e)])),[My.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[My.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[My.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all"]),[My.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[My.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime"]),[My.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[My.GenerationLanguage.SWIFT]:new Set([])};var inE=["go","ruby"];function De_({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let u=c=>({unsafeName:c,safeName:nnE({name:c,keywords:anE({generationLanguage:e,keywords:t})})}),l=L0(n),d=lx(l),s=qCi(n),o=DCi(l);return r&&(!snE(o)&&(e==null||inE.includes(e))&&(l=o.map((c,b)=>{if(b>0){let g=sFo(c);if(g!=null)return g;if(cFo(c))return c.toUpperCase()}return c}).join(""),d=o.map((c,b)=>{let g=sFo(c);return g??(cFo(c)?c.toUpperCase():b===0?lx(c):c)}).join("")),s=n.split(" ").map(c=>c.split(/(\d+)/).map(qCi).join("")).join("_")),{originalName:n,camelCase:u(a?.casingOverrides?.camel??l),snakeCase:u(a?.casingOverrides?.snake??s),screamingSnakeCase:u(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:u(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:n,wireValue:a,opts:u})=>({name:i.generateName(n,u),wireValue:a})};return i}function nnE({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":unE(e)?"_"+e:e}function anE({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return Se_[e]}var onE=/^[0-9]/;function unE(e){return onE.test(e)}function snE(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=sFo(i)!=null||cFo(i),a=sFo(t)!=null||cFo(t);return n&&a})}function sFo(e){return lnE.get(e.toUpperCase())}function cFo(e){return cnE.has(e.toUpperCase())}var cnE=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),lnE=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var $7=class extends jha{specs;sources;loader;constructor({specs:t,...r}){super({...r,respectReadonlySchemas:t.every(i=>i.settings?.respectReadonlySchemas),respectNullableSchemas:t.every(i=>i.settings?.respectNullableSchemas),onlyIncludeReferencedSchemas:t.every(i=>i.settings?.onlyIncludeReferencedSchemas),inlinePathParameters:t.every(i=>i.settings?.inlinePathParameters),objectQueryParameters:t.every(i=>i.settings?.objectQueryParameters),useBytesForBinaryResponse:t.filter(i=>i.type==="openapi"&&i.source.type==="openapi").some(i=>i.settings?.useBytesForBinaryResponse),exampleGeneration:t[0]?.settings?.exampleGeneration}),this.specs=t,this.sources=this.convertSpecsToIdentifiableSources(t),this.loader=new f9t(this.absoluteFilePath)}async getOpenAPIIr({context:t,relativePathToDependency:r},i){let n=await Jze({context:t,specs:this.specs,relativePathToDependency:r});return GNi({context:t,documents:await this.loader.loadDocuments({context:t,specs:n}),options:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.objectQueryParameters,exampleGeneration:i?.exampleGeneration??this.exampleGeneration,useBytesForBinaryResponse:i?.useBytesForBinaryResponse??this.useBytesForBinaryResponse}})}async getIntermediateRepresentation({context:t}){let r=await Jze({context:t,specs:this.specs}),i=await this.loader.loadDocuments({context:t,specs:r}),n;for(let a of i){let u=new iba({logger:t.logger}),l;if(a.type==="openapi"){let s=new sba({namespace:a.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:a.value});l=await new uba({context:s}).convert({context:s,errorCollector:u})}else if(a.type==="asyncapi"){let s=new aba({namespace:a.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:a.value});l=await new nba({context:s}).convert({context:s,errorCollector:u})}else u.collect({message:`Unsupported document type: ${a}`,path:[]});u.hasErrors()&&(t.logger.info(`${a.type==="openapi"?"OpenAPI":"AsyncAPI"} Importer encountered errors:`),u.logErrors());let d=De_({generationLanguage:"typescript",keywords:void 0,smartCasing:!1});l!=null&&(n=n===void 0?l:jXs(n,l,d))}if(n===void 0)throw new Error("Failed to generate intermediate representation");return n}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new oDe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(y0)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,i=[];return t.reduce((n,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),n.push({type:a.type,id:Tie(),absoluteFilePath:u})),n},i)}};var Ee_={None:"none",Header:"header"};var CFo={};Eo(CFo,{ConjureAliasDeclaration:()=>yFo,ConjureArgument:()=>AFo,ConjureArgumentWithParamType:()=>MFo,ConjureAuthDefinition:()=>ZEn,ConjureAuthDefinitionType:()=>DFo,ConjureDefinitions:()=>wFo,ConjureEndpointDefinition:()=>qFo,ConjureEnumDeclaration:()=>PFo,ConjureEnumVariant:()=>mFo,ConjureEnumWithDocs:()=>OFo,ConjureObjectDeclaration:()=>gFo,ConjureParamType:()=>EFo,ConjurePrimitive:()=>hFo,ConjureService:()=>TFo,ConjureServiceName:()=>_Fo,ConjureType:()=>g_i,ConjureTypeDeclaration:()=>jFo,ConjureTypeReference:()=>O_i,ConjureTypeWithDocs:()=>vFo,ConjureTypes:()=>SFo,ConjureUnionDeclaration:()=>bFo,DefinitionFile:()=>tt_,WithDocs:()=>lZt,commons:()=>zXs,conjure:()=>RXs,services:()=>NXs,types:()=>FXs});var zXs={};Eo(zXs,{WithDocs:()=>lZt});var kd={};Eo(kd,{JsonError:()=>KEn,ParseError:()=>YEn,any:()=>Ve_,bigint:()=>Ae_,boolean:()=>We_,booleanLiteral:()=>Ue_,date:()=>qe_,discriminant:()=>Ze_,enum_:()=>fFo,getObjectLikeUtils:()=>h9t,getObjectUtils:()=>gFi,getSchemaUtils:()=>tq,isProperty:()=>b_i,lazy:()=>Te_,lazyObject:()=>Ne_,list:()=>pFo,number:()=>He_,object:()=>dFo,objectWithoutOptionalProperties:()=>Re_,optional:()=>CXs,property:()=>Be_,record:()=>Je_,set:()=>Ke_,string:()=>$e_,stringLiteral:()=>Le_,transform:()=>BXs,undiscriminatedUnion:()=>Xe_,union:()=>et_,unknown:()=>Ge_,withParsedProperties:()=>IXs});var ej={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 BM(e,t){return`Expected ${t}. Received ${fnE(e)}.`}function fnE(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 V5(e){return{...e,json:Me_(e.json),parse:Me_(e.parse)}}function Me_(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(`
1956
+ `}async function Jze({context:e,specs:t,relativePathToDependency:r}){let i=new TRo({context:e}),n=t.filter(l=>l.type==="openapi").map(l=>({...l,relativePathToDependency:r})),a=t.filter(l=>l.type==="protobuf"),u=await Promise.all(a.map(async l=>veE({generator:i,protobufSpec:l,relativePathToDependency:r})));return[...n,...u]}async function veE({generator:e,protobufSpec:t,relativePathToDependency:r}){return{type:"openapi",absoluteFilepath:await e.generate({absoluteFilepathToProtobufRoot:t.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:t.absoluteFilepathToProtobufTarget,relativeFilepathToProtobufRoot:t.relativeFilepathToProtobufRoot,local:t.generateLocally}),absoluteFilepathToOverrides:t.absoluteFilepathToOverrides,settings:t.settings,source:{type:"protobuf",relativePathToDependency:r,root:t.absoluteFilepathToProtobufRoot,file:t.absoluteFilepathToProtobufTarget}}}var Qkp=require("fs"),IEn=require("fs/promises");var Jkp=require("os"),Kkp=di(require("path"),1),Ykp=require("stream/promises"),Xkp=di(FNo(),1),Zkp=di(ore(),1);var hXs=di(Hxi(),1);var uP;(function(e){e.FILE_READ="FILE_READ",e.FILE_PARSE="FILE_PARSE",e.FILE_MISSING="FILE_MISSING",e.STRUCTURE_VALIDATION="STRUCTURE_VALIDATION",e.JSONSCHEMA_VALIDATION="JSONSCHEMA_VALIDATION",e.DEPENDENCY_NOT_LISTED="DEPENDENCY_NOT_LISTED",e.FAILED_TO_LOAD_DEPENDENCY="FAILED_TO_LOAD_DEPENDENCY",e.EXPORTING_PACKAGE_MARKER_OTHER_KEYS="EXPORTING_PACKAGE_MARKER_OTHER_KEYS",e.EXPORT_PACKAGE_HAS_DEFINITIONS="EXPORT_PACKAGE_HAS_DEFINITIONS",e.MISCONFIGURED_DIRECTORY="MISCONFIGURED_DIRECTORY"})(uP||(uP={}));var QrE=oJr();async function kkp({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:i,cliVersion:n,settings:a,loadAPIWorkspace:u}){let l,d={type:uP.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:uP.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${eiE(s)}`},async o=>{switch(s.type){case"version":l=await ZrE({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;case"local":l=await XrE({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;default:Fo(s)}}),l!=null?{didSucceed:!0,definition:l}:{didSucceed:!1,failure:d}}var ee_="dependencies";var JrE="metadata.json",KrE=".fern";function YrE(e){return es(Wl.of((0,Jkp.homedir)()),uo.of(KrE),uo.of(ee_),uo.of(e.organization),uo.of(e.apiName),uo.of(e.version))}async function XrE({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){if(n==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await n({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!a.didSucceed){t.failWithoutThrowing("Failed to load api definition",a.failures);return}t.logger.info("Modifying source filepath ...");let u=await a.workspace.getDefinition({context:t,relativePathToDependency:uo.of(e.path)},i);return t.logger.info("Loaded..."),u}async function ZrE({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){let a=YrE(e),u=es(a,uo.of(ee_)),l=es(a,uo.of(JrE)),d;if(!await Cf(u)||!await Cf(l)){t.logger.info("Downloading manifest...");let c=await QrE.definitionRegistry.get(hXs.FernFiddle.OrganizationId(e.organization),hXs.FernFiddle.ApiId(e.apiName),e.version);if(!c.ok){c.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:m=>{t.failWithoutThrowing("Failed to download API manifest",m)}});return}let b=c.body.yamlSchemaVersion!=null?parseInt(c.body.yamlSchemaVersion):void 0,g=iNi(r),O=iNi(c.body.cliVersion);if(b!=null){if(b>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${c.body.cliVersion}`);return}else if(b<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(g.major!==O.major||g.minor!==O.minor){t.failWithoutThrowing(`CLI version is ${c.body.cliVersion}. Expected ${g.major}.${g.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+c.body.definitionS3DownloadUrl),await(0,IEn.mkdir)(u,{recursive:!0});try{await krE({s3PreSignedReadUrl:c.body.definitionS3DownloadUrl,absolutePathToLocalOutput:u})}catch(m){t.failWithoutThrowing("Failed to download API",m);return}d=c.body,await(0,IEn.writeFile)(l,JSON.stringify(d))}else d=JSON.parse((await(0,IEn.readFile)(l)).toString());if(t.logger.info("Parsing..."),n==null){t.failWithoutThrowing("Failed to load API");return}let s=await n({absolutePathToWorkspace:u,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!s.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",s.failures);return}if(s.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await s.workspace.getDefinition({context:t},i)}async function krE({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await QR.get(e,{responseType:"stream"}),i=await Zkp.default.dir(),n=Kkp.default.join(i.path,"api.tgz");await(0,Ykp.pipeline)(r.data,(0,Qkp.createWriteStream)(n)),await(0,Xkp.extract)({file:n,cwd:t})}function eiE(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:Fo(e)}}var pe_=di(oe_(),1);function LNo(e,t){for(let[r,i]of $N(e))riE({relativeFilepath:r,failure:i,logger:t})}function riE({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case uP.MISCONFIGURED_DIRECTORY:r.error("Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder");break;case uP.FILE_READ:r.error("Failed to open file: "+e);break;case uP.FILE_MISSING:r.error("Missing file: "+e);break;case uP.FILE_PARSE:t.error instanceof Vaa?r.error(Wie({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case uP.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of iiE(i))r.error(Wie({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case uP.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case uP.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${zZa}: `+t.dependencyName);break;case uP.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case uP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case uP.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(Wie({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));for(let i of t.error.allErrors)i!==t.error.error&&r.debug(Wie({title:i.message??"Unknown error",breadcrumbs:[e,...i.instancePath.split("/").filter(n=>n!=="")]}));break;default:Fo(t)}}function iiE(e){switch(e.code){case Hl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Js.underline(e.expected)} but received ${Js.underline(e.received)}`}];case Hl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Js.underline(t)}`}));case Hl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Js.underline(t)).join(", ")}`}];case Hl.invalid_union:case Hl.invalid_arguments:case Hl.invalid_return_type:case Hl.invalid_date:case Hl.invalid_string:case Hl.too_small:case Hl.too_big:case Hl.invalid_intersection_types:case Hl.not_multiple_of:case Hl.custom:default:return[{title:e.message}]}}var ue_=require("fs/promises");async function se_(e,t){let r=[];for(let i of await XBe(e,t))r.push(await niE({relativeFilepath:HA(e,i),absoluteFilepath:i}));return r}async function niE({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,ue_.readFile)(t)).toString()}}async function ce_(e){let t={},r={};function i(n){try{t[n.relativeFilepath]={defaultUrl:void 0,contents:Kd.load(n.fileContents,{schema:Kd.CORE_SCHEMA}),rawContents:n.fileContents}}catch(a){r[n.relativeFilepath]={type:uP.FILE_PARSE,error:a}}}return await Promise.all(e.map(i)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}async function le_({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:i,settings:n,loadAPIWorkspace:a}){let u={},l={},d={};return await Promise.all($N(t.packageMarkers).map(async([s,o])=>{if(o.contents.export==null)u[s]=o;else{let{export:c,...b}=o.contents;if(jY(b)>0)d[s]={type:uP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let g=_p(s);if(W4t(t.namedDefinitionFiles).some(m=>m!==s&&m.startsWith(g)))d[s]={type:uP.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:g};else{let m=await kkp({dependencyName:typeof o.contents.export=="string"?o.contents.export:o.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:i,settings:n,loadAPIWorkspace:a});m.didSucceed?l[_p(s)]={definition:m.definition,url:typeof o.contents.export=="object"?o.contents.export.url:void 0}:d[s]=m.failure}}}})),jY(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:u,importedDefinitions:l}}var fe_=di(require("path"),1);var bXs={};Eo(bXs,{additionalProperties:()=>siE,default:()=>liE,definitions:()=>ciE,properties:()=>oiE,required:()=>uiE,type:()=>aiE});var aiE="object",oiE={docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},"default-url":{oneOf:[{type:"string"},{type:"null"}]},"default-environment":{oneOf:[{type:"string"},{type:"null"}]},environments:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/environments.EnvironmentSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/auth.ApiAuthSchema"},{type:"null"}]},"auth-schemes":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/auth.AuthSchemeDeclarationSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},name:{type:"string"},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},"error-discrimination":{oneOf:[{$ref:"#/definitions/file.ErrorDiscriminationSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},errors:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"idempotency-headers":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},variables:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/variables.VariableDeclarationSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"null"}]},version:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},uiE=["name"],siE=!1,ciE={"environments.SingleBaseUrlEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},url:{type:"string"}},required:["url"],additionalProperties:!1},"environments.MultipleBaseUrlsEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},urls:{type:"object",additionalProperties:{type:"string"}}},required:["urls"],additionalProperties:!1},"environments.EnvironmentSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/environments.SingleBaseUrlEnvironmentSchema"},{$ref:"#/definitions/environments.MultipleBaseUrlsEnvironmentSchema"}]},"auth.AuthSchemeReferenceSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{type:"string"}},required:["scheme"],additionalProperties:!1},"auth.AnyAuthItem":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"}]},"auth.AnyAuthSchemesSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},any:{type:"array",items:{$ref:"#/definitions/auth.AnyAuthItem"}}},required:["any"],additionalProperties:!1},"auth.ApiAuthSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"},{$ref:"#/definitions/auth.AnyAuthSchemesSchema"}]},"auth.OAuthAccessTokenRequestPropertiesSchema":{type:"object",properties:{"client-id":{oneOf:[{type:"string"},{type:"null"}]},"client-secret":{oneOf:[{type:"string"},{type:"null"}]},scopes:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthAccessTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthGetTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthRefreshTokenRequestPropertiesSchema":{type:"object",properties:{"refresh-token":{type:"string"}},required:["refresh-token"],additionalProperties:!1},"auth.OAuthRefreshTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthRefreshTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"oauth"},type:{const:"client-credentials"},scopes:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"client-id-env":{oneOf:[{type:"string"},{type:"null"}]},"client-secret-env":{oneOf:[{type:"string"},{type:"null"}]},"token-prefix":{oneOf:[{type:"string"},{type:"null"}]},"token-header":{oneOf:[{type:"string"},{type:"null"}]},"get-token":{$ref:"#/definitions/auth.OAuthGetTokenEndpointSchema"},"refresh-token":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenEndpointSchema"},{type:"null"}]}},required:["scheme","type","get-token"],additionalProperties:!1},"auth.HeaderAuthSchemeSchema":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},header:{type:"string"},type:{oneOf:[{type:"string"},{type:"null"}]},prefix:{oneOf:[{type:"string"},{type:"null"}]}},required:["header"],additionalProperties:!1},"auth.AuthVariable":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.BasicAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"basic"},username:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]},password:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.BearerAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},token:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.AuthSchemeDeclarationSchema":{anyOf:[{$ref:"#/definitions/auth.OAuthSchemeSchema"},{$ref:"#/definitions/auth.HeaderAuthSchemeSchema"},{$ref:"#/definitions/auth.BasicAuthSchemeSchema"},{$ref:"#/definitions/auth.BearerAuthSchemeSchema"}]},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"file.PropertyBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"property"},"property-name":{type:"string"}},required:["strategy","property-name"],additionalProperties:!1},"file.StatusCodeBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"status-code"}},required:["strategy"],additionalProperties:!1},"file.ErrorDiscriminationSchema":{anyOf:[{$ref:"#/definitions/file.PropertyBasedErrorDiscrimination"},{$ref:"#/definitions/file.StatusCodeBasedErrorDiscrimination"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"variables.VariableDeclarationDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"variables.VariableDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/variables.VariableDeclarationDetailed"}]},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"versioning.VersionValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionValue":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionValueDetailed"}]},"versioning.VersionDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionDeclarationHeaderObjectSchema"}]},"versioning.VersionDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/versioning.VersionValue"}},header:{$ref:"#/definitions/versioning.VersionDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1}},liE={type:aiE,properties:oiE,required:uiE,additionalProperties:siE,definitions:ciE};var gXs={};Eo(gXs,{additionalProperties:()=>piE,default:()=>hiE,definitions:()=>_iE,properties:()=>diE,type:()=>fiE});var fiE="object",diE={docs:{oneOf:[{type:"string"},{type:"null"}]},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]}},piE=!1,_iE={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1}},hiE={type:fiE,properties:diE,additionalProperties:piE,definitions:_iE};var OXs={};Eo(OXs,{additionalProperties:()=>biE,default:()=>OiE,definitions:()=>giE,properties:()=>viE,type:()=>yiE});var yiE="object",viE={imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},navigation:{oneOf:[{$ref:"#/definitions/file.Navigation"},{type:"null"}]},export:{oneOf:[{$ref:"#/definitions/file.Export"},{type:"null"}]}},biE=!1,giE={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1},"file.Navigation":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"file.ExportDetailed":{type:"object",properties:{dependency:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]}},required:["dependency"],additionalProperties:!1},"file.Export":{anyOf:[{type:"string"},{$ref:"#/definitions/file.ExportDetailed"}]}},OiE={type:yiE,properties:viE,additionalProperties:biE,definitions:giE};function de_({files:e,absolutePathToDefinition:t}){let r,i={},n={},a={};for(let[u,l]of $N(e)){let d=l.contents,s=o=>{a[u]={type:uP.JSONSCHEMA_VALIDATION,error:o}};if(u===QN){let o=nQr(d,bXs);if(o.success){let c=S2.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:c["default-url"],contents:c,rawContents:l.rawContents}}else s(o)}else if(fe_.default.basename(u)===iS){let o=nQr(d,OXs);if(o.success){let c=S2.serialization.PackageMarkerFileSchema.parseOrThrow(d);n[u]={defaultUrl:typeof c.export=="object"?c.export.url:void 0,contents:c,rawContents:l.rawContents}}else s(o)}else{let o=nQr(d,gXs);if(o.success){let c=S2.serialization.DefinitionFileSchema.parseOrThrow(d);i[u]={defaultUrl:void 0,contents:c,rawContents:l.rawContents,absoluteFilePath:es(t,u)}}else s(o)}}return r==null?{didSucceed:!1,failures:{[uo.of(QN)]:{type:uP.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:i,rootApiFile:r,packageMarkers:n}}var p_i=class extends Y5t{context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...i}){super(i),this.context=t,this.loadAPIWorkspace=r}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let i=(0,pe_.default)(r??{}),n=this.fernWorkspaces[i];if(n==null){let a=t||this.context,u=es(this.absoluteFilePath,uo.of(X8)),l=await Ybs({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await se_(u,"{yml,yaml}"),s=await ce_(d);if(!s.didSucceed)return LNo(s.failures,a.logger),a.failAndThrow();let o=de_({files:s.files,absolutePathToDefinition:u});if(!o.didSucceed)return LNo(o.failures,a.logger),a.failAndThrow();let c=await le_({dependenciesConfiguration:l,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!c.didSucceed)return LNo(c.failures,a.logger),a.failAndThrow();n=new oDe({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:l,workspaceName:this.workspaceName,definition:{absoluteFilePath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:c.packageMarkers,importedDefinitions:c.importedDefinitions},cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[i]=n}return n}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};function LV(e){let t=PiE(e),{value:r,done:i}=mXs(t,"{");return i?{head:r,parts:[]}:{head:r,parts:[...miE(t)]}}function*miE(e){let t;do{let{value:r}=mXs(e,"}"),i=mXs(e,"{");t=i.done,yield{pathParameter:r,tail:i.value}}while(!t)}function*PiE(e){for(let t of e)yield t}function mXs(e,t){let r="",i=e.next();for(;i.done!==!0&&i.value!==t;)r+=i.value,i=e.next();return{value:r,done:i.done??!1}}function eba(e){let t=2166136261;function r(n,a){if(typeof n=="object"&&n!=null){if(a>64){i("[MaxDepthExceeded]");return}if(Array.isArray(n)){i("[");for(let u=0;u<n.length;u++)u>0&&i(","),r(n[u],a+1);i("]")}else i("{"),Object.keys(n).sort().forEach((l,d)=>{d>0&&i(","),i(l),i(":"),r(n[l],a+1)}),i("}")}else i(String(n))}function i(n){for(let a=0;a<n.length;a++){let u=n.charCodeAt(a);t^=u,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24),t>>>=0}}return r(e,0),t.toString(16)}function _e_({fieldName:e,containerType:t,maxDepth:r,currentDepth:i,typeDeclarations:n,skipOptionalProperties:a}){if(i>=r)return cZt({containerType:t});switch(t.type){case"list":{let u=uC({fieldName:e,typeReference:t.list,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?cZt({containerType:t}):{type:"success",example:QO.list({list:[u.example,u.example],itemType:t.list}),jsonExample:[u.jsonExample,u.jsonExample]}}case"literal":return{type:"success",example:QO.literal({literal:t.literal._visit({boolean:u=>Cd.boolean(u),string:u=>Cd.string({original:u}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:t.literal._visit({boolean:u=>u,string:u=>u,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":{if(a)return cZt({containerType:t});let u=uC({fieldName:e,typeReference:t.optional,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?cZt({containerType:t}):{type:"success",example:QO.optional({optional:u.example,valueType:t.optional}),jsonExample:u.jsonExample}}case"nullable":{if(a)return cZt({containerType:t});let u=uC({fieldName:e,typeReference:t.nullable,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?cZt({containerType:t}):{type:"success",example:QO.nullable({nullable:u.example,valueType:t.nullable}),jsonExample:u.jsonExample}}case"set":{let u=uC({fieldName:e,typeReference:t.set,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?cZt({containerType:t}):{type:"success",example:QO.set({set:[u.example],itemType:t.set}),jsonExample:[u.jsonExample]}}case"map":{let u=uC({fieldName:e,typeReference:t.keyType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a}),l=uC({fieldName:e,typeReference:t.valueType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"||l.type==="failure"?cZt({containerType:t}):{type:"success",example:QO.map({map:[{key:u.example,value:l.example}],keyType:t.keyType,valueType:t.valueType}),jsonExample:{[u.jsonExample]:l.jsonExample}}}default:Fo(t)}}function cZt({containerType:e}){switch(e.type){case"list":return{type:"success",example:QO.list({list:[],itemType:e.list}),jsonExample:[]};case"literal":return{type:"success",example:QO.literal({literal:e.literal._visit({boolean:t=>Cd.boolean(t),string:t=>Cd.string({original:t}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:e.literal._visit({boolean:t=>t,string:t=>t,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":return{type:"success",example:QO.optional({optional:void 0,valueType:e.optional}),jsonExample:void 0};case"nullable":return{type:"success",example:QO.nullable({nullable:void 0,valueType:e.nullable}),jsonExample:void 0};case"set":return{type:"success",example:QO.set({set:[],itemType:e.set}),jsonExample:[]};case"map":return{type:"success",example:QO.map({map:[],keyType:e.keyType,valueType:e.valueType}),jsonExample:{}};default:Fo(e)}}function ye_({fieldName:e,primitiveType:t}){switch(t.v1){case"STRING":return DiE({fieldName:e,validation:jiE(t.v2)});case"BASE_64":return{type:"success",example:Cd.base64(Ey.BASE64),jsonExample:Ey.BASE64};case"BOOLEAN":return{type:"success",example:Cd.boolean(Ey.BOOLEAN),jsonExample:Ey.BOOLEAN};case"DATE":return{type:"success",example:Cd.date(Ey.DATE),jsonExample:Ey.DATE};case"DATE_TIME":return{type:"success",example:Cd.datetime({datetime:new Date(Ey.DATE_TIME),raw:Ey.DATE_TIME}),jsonExample:Ey.DATE_TIME};case"DOUBLE":return EiE({fieldName:e,validation:wiE(t.v2)});case"FLOAT":return{type:"success",example:Cd.float(Ey.FLOAT),jsonExample:Ey.FLOAT};case"INTEGER":return MiE({fieldName:e,validation:SiE(t.v2)});case"UINT_64":return{type:"success",example:Cd.uint64(Ey.INT64),jsonExample:Ey.INT64};case"UINT":return{type:"success",example:Cd.uint(Ey.UINT),jsonExample:Ey.UINT};case"BIG_INTEGER":return{type:"success",example:Cd.bigInteger(Ey.INT64.toString()),jsonExample:`${Ey.INT64}`};case"LONG":return{type:"success",example:Cd.long(Ey.INT64),jsonExample:Ey.INT64};case"UUID":return{type:"success",example:Cd.uuid(Ey.UUID),jsonExample:Ey.UUID};default:Fo(t.v1)}}function jiE(e){if(e?.type==="string")return e.validation}function wiE(e){if(e?.type==="double")return e.validation}function SiE(e){if(e?.type==="integer")return e.validation}function he_(e){if(e<=Ey.SAMPLE_STRINGS.length){let t=Ey.SAMPLE_STRINGS[e-1];if(t)return t;throw new Error(`Unexpected undefined value in SAMPLE_STRINGS at index ${e-1}`)}return Ey.SAMPLE_STRINGS[Ey.SAMPLE_STRINGS.length-1]+".".repeat(e-Ey.SAMPLE_STRINGS.length)}function DiE({fieldName:e,validation:t}){if(t){let i=t.minLength,n=t.maxLength;if(i){let a=he_(i);return{type:"success",example:Cd.string({original:a}),jsonExample:a}}else if(n){let a=he_(n);return{type:"success",example:Cd.string({original:a}),jsonExample:a}}}let r=e??Ey.STRING;return{type:"success",example:Cd.string({original:r}),jsonExample:r}}function EiE({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Cd.double(r),jsonExample:r};if(i)return{type:"success",example:Cd.double(i),jsonExample:i}}return{type:"success",example:Cd.double(Ey.DOUBLE),jsonExample:Ey.DOUBLE}}function MiE({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Cd.integer(r),jsonExample:r};if(i)return{type:"success",example:Cd.integer(i),jsonExample:i}}return{type:"success",example:Cd.integer(Ey.INT),jsonExample:Ey.INT}}function uC({fieldName:e,typeReference:t,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){if(n>i)return{type:"failure",message:"Exceeded max depth"};switch(t.type){case"named":{let u=r[t.typeId];if(u==null)return{type:"failure",message:`Failed to find type declaration with id ${t.typeId}`};let l=NEn({fieldName:e,typeDeclaration:u,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(l==null)return{type:"failure",message:"Failed to generate example for type declaration"};if(l.type==="failure")return l;let{example:d,jsonExample:s}=l;return{type:"success",example:{jsonExample:s,shape:mh.named({shape:d,typeName:u.name})},jsonExample:s}}case"container":{let u=_e_({fieldName:e,containerType:t.container,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(u.type==="failure"){let{example:s,jsonExample:o}=cZt({containerType:t.container});return{type:"success",example:{jsonExample:o,shape:mh.container(s)},jsonExample:o}}let{example:l,jsonExample:d}=u;return{type:"success",example:{jsonExample:d,shape:mh.container(l)},jsonExample:d}}case"primitive":{let{jsonExample:u,example:l}=ye_({fieldName:e,primitiveType:t.primitive});return{type:"success",example:{jsonExample:u,shape:mh.primitive(l)},jsonExample:u}}case"unknown":{let u={key:"value"};return{type:"success",example:{jsonExample:u,shape:mh.unknown(u)},jsonExample:u}}}}function FEn({typeReference:e,typeDeclarations:t}){if(e.type==="container"&&e.container.type==="optional")return!0;if(e.type==="named"){let r=t[e.typeId];if(r?.shape.type==="alias"&&r?.shape.resolvedType.type==="container"&&r?.shape.resolvedType.container.type==="optional")return!0}return!1}function NEn({fieldName:e,typeDeclarations:t,typeDeclaration:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){switch(r.shape.type){case"alias":{let u=uC({fieldName:e,typeDeclarations:t,typeReference:r.shape.aliasOf,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(u.type==="failure")return u;let{example:l,jsonExample:d}=u;return{type:"success",example:ow.alias({value:l}),jsonExample:d}}case"enum":{let u=r.shape.values[0];return u==null?{type:"failure",message:"No enum values present"}:{type:"success",example:ow.enum({value:u.name}),jsonExample:u.name.wireValue}}case"object":{let u={},l=[];if(r.shape.extends!=null)for(let c of r.shape.extends){let b=t[c.typeId];if(b==null)continue;let g=NEn({fieldName:e,typeDeclaration:b,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});g!=null&&g.type==="success"&&g.example.type==="object"&&(Object.assign(u,g.jsonExample),l.push(...g.example.properties))}let d=AiE({fieldName:e,typeDeclaration:r,objectTypeDeclaration:r.shape,typeDeclarations:t,currentDepth:n,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure")return d;let{example:s,jsonExample:o}=d;return{type:"success",example:ow.object({...s,properties:[...l,...s.properties]}),jsonExample:Object.assign({},u,o)}}case"undiscriminatedUnion":{let u=0;for(let l of r.shape.members){let d=uC({fieldName:e,typeReference:l.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure"){++u;continue}let{example:s,jsonExample:o}=d;return{type:"success",example:ow.undiscriminatedUnion({index:u,singleUnionType:s}),jsonExample:o}}break}case"union":{let u=r.shape.discriminant,l={};if(r.shape.baseProperties!=null)for(let d of r.shape.baseProperties){let s=uC({fieldName:d.name.wireValue,typeReference:d.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});s.type==="success"&&(l[d.name.wireValue]=s.jsonExample)}for(let d of r.shape.types){let s=d.shape._visit({noProperties:()=>({type:"success",example:ow.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:oF.noProperties()}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,...l}}),samePropertiesAsObject:o=>{let c=t[o.typeId];if(c==null)return{type:"failure",message:`Failed to find type declaration with id ${o.typeId}`};let b=NEn({currentDepth:n,maxDepth:i,fieldName:e,typeDeclaration:c,typeDeclarations:t,skipOptionalProperties:a});if(b==null)return{type:"failure",message:"Failed to generate example for type reference"};if(b.type==="failure")return b;let{example:g,jsonExample:O}=b;return{type:"success",example:ow.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:oF.samePropertiesAsObject({typeId:c.name.typeId,object:g.type==="object"?g:{properties:[]}})}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,...typeof O=="object"?O:{},...l}}},singleProperty:o=>{let c=uC({currentDepth:n+1,maxDepth:i,fieldName:e,typeReference:o.type,typeDeclarations:t,skipOptionalProperties:a});if(c.type==="failure")return c;let{example:b,jsonExample:g}=c;return{type:"success",example:ow.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:oF.singleProperty(b)}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,[o.name.wireValue]:g,...l}}},_other:()=>{throw new Error("Encountered unknown union type")}});if(s.type!=="failure")return s}}}return{type:"failure",message:"Failed to generate example for type reference"}}function AiE({fieldName:e,typeDeclaration:t,objectTypeDeclaration:r,typeDeclarations:i,maxDepth:n,currentDepth:a,skipOptionalProperties:u}){let l={},d=[];for(let s of[...r.properties??[],...r.extendedProperties??[]]){let o=uC({fieldName:s.name.wireValue,typeReference:s.valueType,typeDeclarations:i,currentDepth:a+1,maxDepth:n,skipOptionalProperties:u});if(o.type==="failure"&&!FEn({typeDeclarations:i,typeReference:s.valueType}))return{type:"failure",message:`Failed to generate required property ${s.name.wireValue} b/c ${o.message}`};if(o.type==="failure")continue;let{example:c,jsonExample:b}=o;d.push({name:s.name,originalTypeDeclaration:t.name,value:c}),l[s.name.wireValue]=b}return{type:"success",example:ow.object({properties:d}),jsonExample:l}}var PXs=a_.primitive({v1:b0.String,v2:Dv.string({default:void 0,validation:void 0})});function tba({ir:e,endpoint:t,service:r,typeDeclarations:i,skipOptionalRequestProperties:n,generationResponse:a}){let u={name:void 0,endpointHeaders:[],endpointPathParameters:[],queryParameters:[],servicePathParameters:[],serviceHeaders:[],rootPathParameters:[],request:void 0,response:Wq.ok(nC.body(void 0)),docs:void 0},l=[{params:t.pathParameters,add:s=>u.endpointPathParameters.push(s)},{params:r.pathParameters,add:s=>u.servicePathParameters.push(s)},{params:e.pathParameters,add:s=>u.rootPathParameters.push(s)}];for(let s of l)for(let o of s.params){let c=uC({fieldName:o.name.originalName,currentDepth:0,maxDepth:1,typeDeclarations:i,typeReference:o.valueType,skipOptionalProperties:n});if(c.type==="failure")return c;let{example:b}=c;s.add({name:o.name,value:b})}for(let s of t.queryParameters){if(n&&FEn({typeDeclarations:i,typeReference:s.valueType}))continue;let o=uC({fieldName:s.name.name.originalName,currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:s.valueType,skipOptionalProperties:n});if(o.type==="failure")return o;let{example:c}=o;u.queryParameters.push({name:s.name,shape:s.allowMultiple?D2.exploded():D2.single(),value:c})}let d=[{params:t.headers,add:s=>u.endpointHeaders.push(s)},{params:r.headers,add:s=>u.serviceHeaders.push(s)}];for(let s of d)for(let o of s.params){if(n&&FEn({typeDeclarations:i,typeReference:o.valueType}))continue;let c=uC({fieldName:o.name.name.originalName,currentDepth:0,maxDepth:1,typeDeclarations:i,typeReference:o.valueType,skipOptionalProperties:n});if(c.type==="failure")return c;let{example:b}=c;s.add({name:o.name,value:b})}if(t.requestBody!=null)switch(t.requestBody.type){case"bytes":return{type:"failure",message:"Bytes request unsupported"};case"fileUpload":return{type:"failure",message:"File upload unsupported"};case"inlinedRequestBody":{let s={},o=[];if(t.requestBody.extends!=null)for(let c of t.requestBody.extends){let b=i[c.typeId];if(b==null)throw new Error(`Failed to find extended type declaration with id ${c.typeId}`);let g=NEn({typeDeclaration:b,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});g!=null&&g.type==="success"&&Object.assign(s,g.jsonExample)}for(let c of[...t.requestBody.properties??[],...t.requestBody.extendedProperties??[]]){let b=uC({fieldName:c.name.wireValue,typeReference:c.valueType,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});if(b.type==="failure"&&!FEn({typeDeclarations:i,typeReference:c.valueType}))return{type:"failure",message:`Failed to generate required property ${c.name.wireValue} b/c ${b.message}`};if(b.type==="failure")continue;let{example:g,jsonExample:O}=b;o.push({name:c.name,originalTypeDeclaration:void 0,value:g}),s[c.name.wireValue]=O}u.request=tG.inlinedRequestBody({jsonExample:s,properties:o});break}case"reference":{let s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.requestBody.requestBodyType,skipOptionalProperties:n});if(s.type==="failure")return s;let{example:o}=s;u.request=tG.reference(o);break}default:Fo(t.requestBody)}if(a.type==="success"&&t.response?.body!=null)switch(t.response.body.type){case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":{let s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.responseBodyType,skipOptionalProperties:!1});if(s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Wq.ok(nC.body({...o,jsonExample:c}));break}case"streamParameter":{let s;switch(t.response.body.nonStreamResponse.type){case"bytes":return{type:"failure",message:"Bytes unsupported"};case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.nonStreamResponse.value.responseBodyType,skipOptionalProperties:!1});break;case"text":s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:PXs,skipOptionalProperties:!1});break;default:Fo(t.response.body.nonStreamResponse)}if(s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Wq.ok(nC.body({...o,jsonExample:c}));break}case"streaming":{let s;switch(t.response.body.value.type){case"sse":{if(s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Wq.ok(nC.sse([{data:{...o,jsonExample:c},event:""}]));break}case"json":{if(s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Wq.ok(nC.stream([{...o,jsonExample:c}]));break}case"text":{if(s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:PXs,skipOptionalProperties:!1}),s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Wq.ok(nC.stream([{...o,jsonExample:c}]));break}default:Fo(t.response.body.value)}break}case"text":{let s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:PXs,skipOptionalProperties:!1});if(s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Wq.ok(nC.body({...o,jsonExample:c}));break}case"bytes":return{type:"failure",message:"Bytes unsupported"};default:Fo(t.response.body)}else if(a.type==="error")if(a.declaration.type==null)u.response=Wq.error({body:void 0,error:a.declaration.name});else{let s=uC({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:a.declaration.type,skipOptionalProperties:n});if(s.type==="failure")return s;let{example:o}=s;u.response=Wq.error({body:o,error:a.declaration.name})}try{return{type:"success",example:{id:eba(u),url:qiE(t,u),...u},jsonExample:void 0}}catch(s){return{type:"failure",message:`Parse failure with exceptions ${s}`}}}function qiE(e,t){let r={};[...t.rootPathParameters,...t.servicePathParameters,...t.endpointPathParameters].forEach(n=>{let a=n.value.jsonExample,u=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=u});let i=e.fullPath.head+e.fullPath.parts.map(n=>r[n.pathParameter]+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function vFi({ir:e,exampleGeneration:t}){for(let[r,i]of Object.entries(e.services))for(let n of i.endpoints){if(n.userSpecifiedExamples.length>0&&t?.skipAutogenerationIfManualExamplesExist===!0)continue;let a=tba({ir:e,service:i,endpoint:n,typeDeclarations:e.types,skipOptionalRequestProperties:!t?.includeOptionalRequestPropertyExamples,generationResponse:{type:"success"}});if(a.type==="failure")continue;let{example:u}=a;n.autogeneratedExamples=[{example:u}]}return e}function jXs(e,t,r){let{environments:i,changedBaseUrlIds1:n,changedBaseUrlIds2:a}=TiE(e.environments,t.environments,r),{services:u,websocketChannels:l}=CiE(e,t,n,a);return{apiName:e.apiName,basePath:e.basePath,apiDisplayName:e.apiDisplayName??t.apiDisplayName,apiDocs:e.apiDocs??t.apiDocs,auth:e.auth??t.auth,headers:[...e.headers??[],...t.headers??[]],environments:i,types:{...e.types??{},...t.types??{}},constants:{...e.constants??{},...t.constants??{}},errors:{...e.errors??{},...t.errors??{}},services:u,webhookGroups:{...e.webhookGroups??{},...t.webhookGroups??{}},subpackages:{...e.subpackages??{},...t.subpackages??{}},websocketChannels:l,rootPackage:{service:e.rootPackage.service??t.rootPackage.service,types:[...e.rootPackage.types??[],...t.rootPackage.types??[]],errors:[...e.rootPackage.errors??[],...t.rootPackage.errors??[]],subpackages:[...e.rootPackage.subpackages??[],...t.rootPackage.subpackages??[]],fernFilepath:e.rootPackage.fernFilepath??t.rootPackage.fernFilepath,webhooks:e.rootPackage.webhooks??t.rootPackage.webhooks,websocket:e.rootPackage.websocket??t.rootPackage.websocket,hasEndpointsInTree:e.rootPackage.hasEndpointsInTree||t.rootPackage.hasEndpointsInTree,navigationConfig:e.rootPackage.navigationConfig??t.rootPackage.navigationConfig,docs:e.rootPackage.docs??t.rootPackage.docs},fdrApiDefinitionId:e.fdrApiDefinitionId??t.fdrApiDefinitionId,apiVersion:e.apiVersion??t.apiVersion,idempotencyHeaders:[...e.idempotencyHeaders??[],...t.idempotencyHeaders??[]],pathParameters:[...e.pathParameters??[],...t.pathParameters??[]],errorDiscriminationStrategy:e.errorDiscriminationStrategy??t.errorDiscriminationStrategy,variables:[...e.variables??[],...t.variables??[]],serviceTypeReferenceInfo:e.serviceTypeReferenceInfo??t.serviceTypeReferenceInfo,readmeConfig:e.readmeConfig??t.readmeConfig,sourceConfig:e.sourceConfig??t.sourceConfig,publishConfig:e.publishConfig??t.publishConfig,dynamic:e.dynamic??t.dynamic,sdkConfig:e.sdkConfig??t.sdkConfig}}function TiE(e,t,r){if(e==null&&t==null)return{environments:void 0,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(t==null)return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(e==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(JSON.stringify(e)===JSON.stringify(t))return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let i=ve_(e),n=ve_(t);if(i&&n&&e.environments.type==="singleBaseUrl"&&t.environments.type==="singleBaseUrl")return{environments:{defaultEnvironment:e.defaultEnvironment??t.defaultEnvironment,environments:NC.singleBaseUrl({environments:[...e.environments.environments,...t.environments.environments]})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let a=i?t.defaultEnvironment:e.defaultEnvironment,u=e.environments,l=t.environments;if(u.type==="singleBaseUrl"&&l.type==="singleBaseUrl"){let d=i?l:u,s=i?u:l,o={},{deconflictedEnvironments2:c,changedBaseUrlIds2:b}=BiE(d,s,r);if(d.environments[0]==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let g="Base",O=r.generateName("Base");return d.environments.forEach(m=>{o[m.id]=g}),{environments:{defaultEnvironment:a,environments:NC.multipleBaseUrls({baseUrls:[{id:g,name:O},...c.environments.map(m=>({id:m.id,name:m.name}))],environments:d.environments.map(m=>({id:m.id,name:m.name,urls:{[g]:m.url,...Object.fromEntries(c.environments.map(P=>[P.id,P.url]))},docs:void 0}))})},changedBaseUrlIds1:o,changedBaseUrlIds2:b}}if(u.type==="multipleBaseUrls"&&l.type==="singleBaseUrl"||u.type==="singleBaseUrl"&&l.type==="multipleBaseUrls"){let d=u.type==="singleBaseUrl"?u:l,s=u.type==="multipleBaseUrls"?u:l,{deconflictedEnvironments1:o,changedBaseUrlIds1:c}=xiE(d,s,r);return{environments:{defaultEnvironment:a,environments:NC.multipleBaseUrls({baseUrls:[...s.baseUrls,...o.environments.map(b=>({id:b.id,name:b.name}))],environments:s.environments.map(b=>({...b,urls:{...b.urls,...Object.fromEntries(o.environments.map(g=>[g.id,g.url]))}}))})},changedBaseUrlIds1:u.type==="singleBaseUrl"?c:void 0,changedBaseUrlIds2:u.type==="singleBaseUrl"?void 0:c}}if(u.type==="multipleBaseUrls"&&l.type==="multipleBaseUrls"){let{deconflictedEnvironments:d,changedBaseUrlIds:s}=IiE(u,l,r);return{environments:{defaultEnvironment:a,environments:NC.multipleBaseUrls({baseUrls:[...u.baseUrls,...d.baseUrls],environments:u.environments.flatMap(o=>d.environments.map(c=>({...o,urls:{...o.urls,...c.urls}})))})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:s}}return{environments:e??t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0}}function CiE(e,t,r,i){if(r!=null)for(let[u,l]of Object.entries(r)){for(let d of Object.values(e.services))for(let s of Object.values(d.endpoints))s.baseUrl==u&&(s.baseUrl=l);for(let d of Object.values(e.websocketChannels??{}))d.baseUrl==u&&(d.baseUrl=l)}if(i!=null)for(let[u,l]of Object.entries(i)){for(let d of Object.values(t.services))for(let s of Object.values(d.endpoints))s.baseUrl==u&&(s.baseUrl=l);for(let d of Object.values(t.websocketChannels??{}))d.baseUrl==u&&(d.baseUrl=l)}let n={...e.services??{},...t.services??{}},a={...e.websocketChannels??{},...t.websocketChannels??{}};return{services:n,websocketChannels:a}}function BiE(e,t,r){let i={},n=new Set(e.environments.map(s=>s.id)),a=new Set(e.environments.map(s=>s.name)),u=new Map(e.environments.map(s=>[s.url,s.id])),l=t.environments.filter(s=>{let o=u.get(s.url);return o!=null?(i[s.id]=o,!1):!0}).map(s=>{if(n.has(s.id)||a.has(s.name)){let o=wXs(s.id,n);return i[s.id]=o,{...s,id:o,name:r.generateName(o)}}return s});return{deconflictedEnvironments2:NC.singleBaseUrl({environments:l}),changedBaseUrlIds2:i}}function xiE(e,t,r){let i={},n=new Set(t.baseUrls.map(d=>d.id)),a=new Set(t.baseUrls.map(d=>d.name)),u=e.environments.map(d=>{if(n.has(d.id)||a.has(d.name)){let s=wXs(d.id,n);return i[d.id]=s,{...d,id:s,name:r.generateName(s)}}return d});return{deconflictedEnvironments1:NC.singleBaseUrl({environments:u}),changedBaseUrlIds1:i}}function IiE(e,t,r){let i={},n=new Set(e.baseUrls.map(s=>s.id)),a=new Set(e.baseUrls.map(s=>s.name)),u=t.baseUrls.map(s=>{if(n.has(s.id)||a.has(s.name)){let o=wXs(s.id,n);return i[s.id]=o,{...s,id:o,name:r.generateName(o)}}return s}),l=t.environments.map(s=>({...s,urls:Object.fromEntries(Object.entries(s.urls).map(([o,c])=>[i[o]??o,c]))}));return{deconflictedEnvironments:NC.multipleBaseUrls({baseUrls:u,environments:l}),changedBaseUrlIds:i}}function ve_(e){return e.environments.type==="singleBaseUrl"?e.environments.environments.some(t=>t.url&&(t.url.startsWith("ws://")||t.url.startsWith("wss://"))):e.environments.type==="multipleBaseUrls"?e.environments.environments.some(t=>Object.values(t.urls).some(r=>r&&(r.startsWith("ws://")||r.startsWith("wss://")))):!1}function wXs(e,t){let r=e,i=1;for(;t.has(r);)r=`${e}-${i}`,i++;return r}var og=class{breadcrumbs=[];constructor({breadcrumbs:t=[]}={}){this.breadcrumbs=t}};var be_={[My.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,lx(e)])),[My.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[My.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[My.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all"]),[My.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[My.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime"]),[My.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[My.GenerationLanguage.SWIFT]:new Set([])};var ziE=["go","ruby"];function vDe({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let u=c=>({unsafeName:c,safeName:RiE({name:c,keywords:NiE({generationLanguage:e,keywords:t})})}),l=L0(n),d=lx(l),s=qCi(n),o=DCi(l);return r&&(!UiE(o)&&(e==null||ziE.includes(e))&&(l=o.map((c,b)=>{if(b>0){let g=UNo(c);if(g!=null)return g;if(VNo(c))return c.toUpperCase()}return c}).join(""),d=o.map((c,b)=>{let g=UNo(c);return g??(VNo(c)?c.toUpperCase():b===0?lx(c):c)}).join("")),s=n.split(" ").map(c=>c.split(/(\d+)/).map(qCi).join("")).join("_")),{originalName:n,camelCase:u(a?.casingOverrides?.camel??l),snakeCase:u(a?.casingOverrides?.snake??s),screamingSnakeCase:u(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:u(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:n,wireValue:a,opts:u})=>({name:i.generateName(n,u),wireValue:a})};return i}function RiE({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":LiE(e)?"_"+e:e}function NiE({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return be_[e]}var FiE=/^[0-9]/;function LiE(e){return FiE.test(e)}function UiE(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=UNo(i)!=null||VNo(i),a=UNo(t)!=null||VNo(t);return n&&a})}function UNo(e){return WiE.get(e.toUpperCase())}function VNo(e){return ViE.has(e.toUpperCase())}var ViE=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),WiE=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var bFi=class e{args;spec;settings;logger;generationLanguage;smartCasing;casingsGenerator;namespace;constructor(t){this.args=t,this.spec=t.spec,this.settings=t.settings,this.logger=t.logger,this.generationLanguage=t.generationLanguage,this.smartCasing=t.smartCasing,this.namespace=t.namespace,this.casingsGenerator=vDe({generationLanguage:t.generationLanguage,keywords:void 0,smartCasing:t.smartCasing})}static BREADCRUMBS_TO_IGNORE=["properties","allOf","anyOf"];convertBreadcrumbsToName(t){let r=t.filter((n,a)=>!(/^\d+$/.test(n)||e.BREADCRUMBS_TO_IGNORE.includes(n)||a===0&&n==="components"||a===1&&n==="schemas"||t[0]==="paths"&&(a===0||a===1&&["get","post","put","delete","patch"].includes(n)||a===2&&t[1]!=null&&["get","post","put","delete","patch"].includes(t[1])&&n==="parameters"))),i=L0(r.join("_"));return i.charAt(0).toUpperCase()+i.slice(1)}createPackage(t={}){return{fernFilepath:this.createFernFilepath(t),service:void 0,types:[],errors:[],subpackages:[],docs:void 0,webhooks:void 0,websocket:void 0,hasEndpointsInTree:!1,navigationConfig:void 0}}createFernFilepath(t={}){let r=this.namespace!=null?[this.casingsGenerator.generateName(this.namespace)]:[],i=t.name!=null?this.casingsGenerator.generateName(t.name):void 0;return{allParts:i?[...r,i]:r,packagePath:r,file:i}}async resolveReference(t){let r=this.spec,i;if(t.$ref.startsWith("http://")||t.$ref.startsWith("https://")){let a=t.$ref.split("#"),u=a[0];if(i=a[1],!u)return{resolved:!1};let l=await fetch(u);if(!l.ok)return{resolved:!1};try{let d=await l.text();try{r=JSON.parse(d)}catch{r=Kd.load(d)}if(r==null)return{resolved:!1}}catch{return{resolved:!1}}if(!i)return{resolved:!0,value:r}}let n=(i??t.$ref).replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(a=>a.replace(/~1/g,"/"));for(let a of n){if(typeof r!="object"||r==null)return{resolved:!1};r=r[a]}return r==null?{resolved:!1}:{resolved:!0,value:r}}async getPropertyAccess(t){let r=t;for(;this.isReferenceObject(r);){let i=await this.resolveReference(r);if(!i.resolved)return;r=i.value}if(!(r.readOnly&&r.writeOnly)){if(r.readOnly)return cJt.ReadOnly;if(r.writeOnly)return cJt.WriteOnly}}async getAvailability({node:t,breadcrumbs:r,errorCollector:i}){for(;this.isReferenceObject(t);){let u=await this.resolveReference(t);if(!u.resolved)return;t=u.value}let a=await new HG.FernAvailabilityExtension({node:t,breadcrumbs:r}).convert({context:this,errorCollector:i});if(a!=null)return{status:a,message:void 0};if(t.deprecated===!0)return{status:d5.Deprecated,message:void 0}}getTypeIdFromSchemaReference(t){let r=t.$ref.match(/\/schemas\/(.+)$/);if(!(!r||!r[1]))return r[1]}createNamedTypeReference(t){return a_.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(t??"defaultName"),typeId:t,default:void 0,inline:!1})}typeReferenceToDeclaredTypeName(t){if(t.type!=="named")return;let r=t.typeId;return{typeId:r,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r)}}removeSchemaFromInlinedTypes({id:t,inlinedTypes:r}){return Object.fromEntries(Object.entries(r).filter(([i])=>i!==t))}maybeTrimPrefix(t,r){return t.startsWith(r)?t.slice(r.length):t}isReferenceObject(t){return typeof t=="object"&&t!==null&&"$ref"in t}isOptional(t){return t.type==="container"&&t.container.type==="optional"}isList(t){return t.type==="container"&&t.container.type==="list"}isFile(t){return t.type==="primitive"&&t.primitive.v2?.type==="string"&&t.primitive.v2.validation?.format==="binary"}getAsString(t){if(typeof t=="string")return t}getAsInteger(t){if(typeof t=="number"&&Number.isInteger(t))return t}getAsNumber(t){if(typeof t=="number")return t}getAsBoolean(t){if(typeof t=="boolean")return t}getAsArray(t){if(Array.isArray(t))return t}getAsObject(t){if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}};var mz=class extends og{getExtensionValue(t){if(!(typeof t!="object"||t==null))return t[this.key]}};var H2={};Eo(H2,{SchemaConverters:()=>SXs});var SXs={};Eo(SXs,{ArraySchemaConverter:()=>HEn,EnumSchemaConverter:()=>LEn,ObjectSchemaConverter:()=>UEn,OneOfSchemaConverter:()=>VEn,PrimitiveSchemaConverter:()=>WEn,SchemaConverter:()=>__i,SchemaOrReferenceConverter:()=>_9t});var LEn=class extends og{schema;maybeFernEnum;constructor({breadcrumbs:t,schema:r,maybeFernEnum:i}){super({breadcrumbs:t}),this.schema=r,this.maybeFernEnum=i}convert({context:t,errorCollector:r}){if(!this.schema.enum)return;let n=this.schema.enum.filter(u=>typeof u=="string").map(u=>{let l=this.maybeFernEnum?.[u],d=l?.name??u.toString();return{name:t.casingsGenerator.generateNameAndWireValue({name:d,wireValue:u.toString()}),docs:l?.description,availability:void 0,casing:l?.casing}});if(n.length===0)return;let a=t.getAsString(this.schema.default);return{enum:aw.enum({default:a!=null?n.find(u=>u.name.wireValue===a):void 0,values:n})}}};var UEn=class extends og{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){if(!this.schema.properties&&!this.schema.allOf)return{object:aw.object({properties:[],extends:[],extendedProperties:[],extraProperties:this.schema.additionalProperties!=null})};let i=[],n={};for(let[u,l]of Object.entries(this.schema.properties??{})){let d=[...this.breadcrumbs,"properties",u],s="nullable"in l?l.nullable:!1,o=t.convertBreadcrumbsToName(d),b=await new _9t({breadcrumbs:d,schemaOrReference:l,schemaIdOverride:o,wrapAsOptional:!this.schema.required?.includes(u),wrapAsNullable:s}).convert({context:t,errorCollector:r});b!=null&&(i.push({name:t.casingsGenerator.generateNameAndWireValue({name:u,wireValue:u}),valueType:b.type,docs:l.description,availability:b.availability,propertyAccess:await t.getPropertyAccess(l)}),n={...n,...b.inlinedTypes})}let a=[];for(let[u,l]of(this.schema.allOf??[]).entries()){let d=[...this.breadcrumbs,"allOf",u.toString()];if(t.isReferenceObject(l)){let s=await t.convertReferenceToTypeReference(l);s.ok&&a.push(s.reference);continue}for(let[s,o]of Object.entries(l.properties??{})){let c=[...d,s],b=t.convertBreadcrumbsToName(c),O=await new _9t({breadcrumbs:c,schemaOrReference:o,schemaIdOverride:b,wrapAsOptional:!l.required?.includes(s),wrapAsNullable:"nullable"in o?o.nullable:!1}).convert({context:t,errorCollector:r});O!=null&&(i.push({name:t.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),valueType:O.type,docs:o.description,availability:O.availability,propertyAccess:await t.getPropertyAccess(o)}),n={...n,...O.inlinedTypes})}}return{object:aw.object({properties:i,extends:a.map(u=>t.typeReferenceToDeclaredTypeName(u)).filter(y0),extendedProperties:[],extraProperties:this.schema.additionalProperties!=null}),inlinedTypes:n}}};var VEn=class extends og{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){return this.schema.discriminator!=null?await this.convertAsDiscriminatedUnion({context:t,errorCollector:r}):this.convertAsUndiscriminatedUnion({context:t,errorCollector:r})}async convertAsDiscriminatedUnion({context:t,errorCollector:r}){let i=[],n={};if(this.schema.discriminator!=null){for(let[a,u]of Object.entries(this.schema.discriminator.mapping??{})){let l=new _9t({schemaOrReference:{$ref:u},breadcrumbs:[...this.breadcrumbs,"discriminator","mapping",a]}),d=t.getTypeIdFromSchemaReference({$ref:u}),s=await l.convert({context:t,errorCollector:r});if(s?.type!=null&&d!=null){let o=t.casingsGenerator.generateNameAndWireValue({name:a,wireValue:a});i.push({docs:void 0,discriminantValue:o,availability:s.availability,displayName:void 0,shape:rG.samePropertiesAsObject({typeId:d,name:t.casingsGenerator.generateName(d),fernFilepath:{allParts:[],packagePath:[],file:void 0}})}),n={...n,...s.inlinedTypes}}}return{union:aw.union({baseProperties:[],discriminant:t.casingsGenerator.generateNameAndWireValue({name:this.schema.discriminator.propertyName,wireValue:this.schema.discriminator.propertyName}),extends:[],types:i}),inlinedTypes:n}}}async convertAsUndiscriminatedUnion({context:t,errorCollector:r}){if(!this.schema.oneOf&&!this.schema.anyOf||this.schema.anyOf?.length===0&&this.schema.oneOf?.length===0)return;let i=[],n={};for(let[a,u]of[...(this.schema.oneOf??[]).entries(),...(this.schema.anyOf??[]).entries()]){let l=[...this.breadcrumbs,"oneOf",rba(a)??""];if(t.isReferenceObject(u)){let c=await t.convertReferenceToTypeReference(u);c.ok&&i.push({type:c.reference,docs:u.description});continue}let d=t.convertBreadcrumbsToName(l),o=await new __i({id:d,breadcrumbs:l,schema:u}).convert({context:t,errorCollector:r});o!=null&&(i.push({type:t.createNamedTypeReference(d),docs:u.description}),n={...n,...o.inlinedTypes,[d]:o.typeDeclaration})}return{union:aw.undiscriminatedUnion({members:i}),inlinedTypes:n}}};var WEn=class extends og{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}convert({context:t,errorCollector:r}){switch(this.schema.type){case"string":{let i=t.getAsString(this.schema.const);return i!=null?a_.container(eg.literal(LY.string(i))):a_.primitive({v1:"STRING",v2:Dv.string({default:t.getAsString(this.schema.default),validation:this.getStringValidation(this.schema)})})}case"number":case"integer":switch(this.schema.format){case"double":case void 0:return a_.primitive({v1:"DOUBLE",v2:Dv.double({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return a_.primitive({v1:"FLOAT",v2:Dv.float({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return a_.primitive({v1:"INTEGER",v2:Dv.integer({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return a_.primitive({v1:"LONG",v2:Dv.long({default:t.getAsNumber(this.schema.default)})});case"uint32":return a_.primitive({v1:"UINT",v2:Dv.uint({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return a_.primitive({v1:"UINT_64",v2:Dv.uint64({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return a_.primitive({v1:"INTEGER",v2:Dv.integer({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"boolean":{let i=t.getAsBoolean(this.schema.const);return i!=null?a_.container(eg.literal(LY.boolean(i))):a_.primitive({v1:"BOOLEAN",v2:Dv.boolean({default:this.schema.default})})}default:return}}getNumberValidation(t){return{max:t.maximum,min:t.minimum,exclusiveMax:typeof t.exclusiveMaximum=="boolean"?t.exclusiveMaximum:void 0,exclusiveMin:typeof t.exclusiveMinimum=="boolean"?t.exclusiveMinimum:void 0,multipleOf:t.multipleOf}}getStringValidation(t){return{minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,format:t.format}}};var __i=class extends og{schema;id;inlined;constructor({breadcrumbs:t,schema:r,id:i,inlined:n=!1}){super({breadcrumbs:t}),this.schema=r,this.id=i,this.inlined=n}async convert({context:t,errorCollector:r}){if(this.schema.enum?.length){let u=new HG.FernEnumExtension({breadcrumbs:this.breadcrumbs,schema:this.schema}).convert({context:t,errorCollector:r}),d=new LEn({breadcrumbs:this.breadcrumbs,schema:this.schema,maybeFernEnum:u}).convert({context:t,errorCollector:r});if(d!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:d.enum,context:t,errorCollector:r}),inlinedTypes:{}}}let n=new WEn({schema:this.schema}).convert({context:t,errorCollector:r});if(n!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:aw.alias({aliasOf:n,resolvedType:n}),context:t,errorCollector:r}),inlinedTypes:{}};if(this.schema.type==="array"){let u=await new HEn({breadcrumbs:this.breadcrumbs,schema:this.schema}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:aw.alias({aliasOf:u.typeReference,resolvedType:u.typeReference}),context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}if(this.schema.oneOf!=null||this.schema.anyOf!=null){let u=await new VEn({breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:u.union,context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}if(this.schema.type==="object"||this.schema.properties!=null||this.schema.allOf!=null){let u=await new UEn({breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:u.object,context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}}async createTypeDeclaration({shape:t,context:r,errorCollector:i}){return{name:this.convertDeclaredTypeName({context:r}),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:await r.getAvailability({node:this.schema,breadcrumbs:this.breadcrumbs,errorCollector:i}),docs:this.schema.description,referencedTypes:new Set,source:void 0,inline:this.inlined}}convertDeclaredTypeName({context:t}){return{typeId:this.id,fernFilepath:t.createFernFilepath(),name:t.casingsGenerator.generateName(this.id)}}};var _9t=class extends og{schemaOrReference;schemaIdOverride;wrapAsOptional;wrapAsNullable;constructor({breadcrumbs:t,schemaOrReference:r,schemaIdOverride:i,wrapAsOptional:n=!1,wrapAsNullable:a=!1}){super({breadcrumbs:t}),this.schemaOrReference=r,this.schemaIdOverride=i,this.wrapAsOptional=n,this.wrapAsNullable=a}async convert({context:t,errorCollector:r}){if(t.isReferenceObject(this.schemaOrReference)){let l=await t.convertReferenceToTypeReference(this.schemaOrReference);return l.ok?{type:l.reference,inlinedTypes:{}}:void 0}let i=this.schemaIdOverride??t.convertBreadcrumbsToName(this.breadcrumbs),n=new __i({breadcrumbs:this.breadcrumbs,schema:this.schemaOrReference,id:i}),a=await t.getAvailability({node:this.schemaOrReference,breadcrumbs:this.breadcrumbs,errorCollector:r}),u=await n.convert({context:t,errorCollector:r});if(u!=null){if(u.typeDeclaration.shape.type==="alias"){let d=u.typeDeclaration.shape.aliasOf;return{type:this.wrapTypeReference(d),inlinedTypes:u.inlinedTypes,availability:a}}let l=t.createNamedTypeReference(i);return{type:this.wrapTypeReference(l),schema:u.typeDeclaration,inlinedTypes:{...u.inlinedTypes,[i]:u.typeDeclaration},availability:a}}}wrapTypeReference(t){return this.wrapAsOptional&&this.wrapAsNullable?this.wrapInOptional(this.wrapInNullable(t)):this.wrapAsOptional?this.wrapInOptional(t):this.wrapAsNullable?this.wrapInNullable(t):t}wrapInOptional(t){return a_.container(eg.optional(t))}wrapInNullable(t){return a_.container(eg.nullable(t))}};var HEn=class e extends og{static LIST_UNKNOWN=a_.container(eg.list(a_.unknown()));schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){if(this.schema.items==null)return{typeReference:e.LIST_UNKNOWN};let n=await new _9t({breadcrumbs:[...this.breadcrumbs,"items"],schemaOrReference:this.schema.items}).convert({context:t,errorCollector:r});return n!=null?{typeReference:a_.container(eg.list(n.type)),inlinedTypes:n.inlinedTypes}:{typeReference:e.LIST_UNKNOWN}}};var iba=class{errors=[];logger;constructor({logger:t}){this.logger=t}collect(t){this.errors.push(t)}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}logErrors(){for(let t of this.errors)this.logger.log(V0.Info,Wie({title:t.message,breadcrumbs:t.path,subtitle:t.path!=null?k_.dim(t.path.join(" -> ")):void 0}))}};var HG={};Eo(HG,{FernAvailabilityExtension:()=>WNo,FernEnumExtension:()=>HNo,FernIgnoreExtension:()=>$No,SdkGroupNameExtension:()=>GNo,SdkMethodNameExtension:()=>QNo});var WNo=class extends mz{node;key="x-fern-availability";constructor({breadcrumbs:t,node:r}){super({breadcrumbs:t}),this.node=r}async convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.node);if(i==null||typeof i!="string")return;switch(i.toUpperCase().replace(/[-_\s]/g,"_")){case"IN_DEVELOPMENT":return d5.InDevelopment;case"PRE_RELEASE":return d5.PreRelease;case"GENERAL_AVAILABILITY":return d5.GeneralAvailability;case"DEPRECATED":return d5.Deprecated;default:return}}};var HiE=Yu.object({snake:Yu.string().optional(),camel:Yu.string().optional(),screamingSnake:Yu.string().optional(),pascal:Yu.string().optional()}),$iE=Yu.object({description:Yu.string().optional(),name:Yu.string().optional(),casing:HiE.optional()}),ge_=Yu.record($iE);var HNo=class extends mz{schema;key="x-fern-enum";constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.schema);if(i==null)return;let n=ge_.safeParse(i);if(!n.success){r.collect({message:`Invalid x-fern-enum extension: ${n.error.message}`,path:this.breadcrumbs});return}return n.data}};var $No=class extends mz{operation;key="x-fern-ignore";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null){if(typeof i!="boolean"){r.collect({message:"Received unexpected non-boolean value for x-fern-ignore",path:this.breadcrumbs});return}return i}}};var GNo=class extends mz{operation;key="x-fern-sdk-group-name";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i==null)return;let n=Array.isArray(i)?i.filter(a=>typeof a=="string"):typeof i=="string"?[i]:[];if(n.length!==0)return{groups:n}}};var QNo=class extends mz{operation;key="x-fern-sdk-method-name";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null&&typeof i=="string")return{methodName:i}}};function rba(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),l=e%10;return l===0?i[u]:`${i[u]}_${t[l]}`}if(e<1e3){let u=Math.floor(e/100),l=e%100;return l===0?`${t[u]}_hundred`:`${t[u]}_hundred_${rba(l)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${rba(a)}`}var h_i=class e extends og{static STRING=a_.primitive({v1:"STRING",v2:Dv.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=a_.container(eg.optional(e.STRING));parameter;constructor({breadcrumbs:t,parameter:r}){super({breadcrumbs:t}),this.parameter=r}async convert({context:t,errorCollector:r}){let i,n={};if(this.parameter.schema!=null){let l=await new H2.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert({context:t,errorCollector:r});l!=null&&(i=l.type,n=l.inlinedTypes??{})}let a=await t.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs,errorCollector:r});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??(this.parameter.required?e.STRING:e.OPTIONAL_STRING),allowMultiple:this.parameter.explode??!1,availability:a},inlinedTypes:n};case"header":return{type:"header",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??(this.parameter.required?e.STRING:e.OPTIONAL_STRING),env:void 0,availability:a},inlinedTypes:n};case"path":return{type:"path",parameter:{name:t.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:i??(this.parameter.required?e.STRING:e.OPTIONAL_STRING),location:"ENDPOINT",variable:void 0},inlinedTypes:n};default:r.collect({message:`Unsupported parameter location: ${this.parameter.in}`,path:this.breadcrumbs});return}}};var JNo=class extends og{channel;channelPath;group;inlinedTypes={};constructor({breadcrumbs:t,channel:r,channelPath:i,group:n}){super({breadcrumbs:t}),this.channel=r,this.channelPath=i,this.group=n}async convert({context:t,errorCollector:r}){let i=[],n=[],a=[],u=this.group?this.group.join("."):this.channelPath;this.channel.parameters&&await this.convertQueryParameters({context:t,errorCollector:r,queryParameters:n}),this.channel.bindings?.ws!=null&&(await this.convertHeaders({context:t,errorCollector:r,headers:a}),await this.convertBindingQueryParameters({context:t,errorCollector:r,queryParameters:n}));let l;this.channel.subscribe!=null&&(l=await this.convertMessage({context:t,errorCollector:r,origin:"server",operation:this.channel.subscribe,defaultId:"subscribeEvent",breadcrumbName:"subscribeEvent"}));let d;this.channel.publish!=null&&(d=await this.convertMessage({context:t,errorCollector:r,origin:"client",operation:this.channel.publish,defaultId:"publishEvent",breadcrumbName:"publishEvent"}));let s=[];l!=null&&s.push(l),d!=null&&s.push(d);let o=this.channel.servers?.[0]??Object.keys(t.spec.servers??{})[0];return{channel:{name:t.casingsGenerator.generateName(u),displayName:u,baseUrl:o,path:{head:this.transformToValidPath(this.channel.address??this.channelPath),parts:[]},auth:!1,headers:a,queryParameters:n,pathParameters:i,messages:s,examples:[],availability:await t.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.channel.description},inlinedTypes:this.inlinedTypes}}async convertMessage({context:t,errorCollector:r,origin:i,operation:n,defaultId:a,breadcrumbName:u}){let l;if(t.isReferenceObject(n.message)){let d=await t.resolveReference(n.message);d.resolved&&(n.message=d.value)}if("oneOf"in n.message){let s=await new H2.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[...this.breadcrumbs,u],schemaOrReference:n.message,schemaIdOverride:n.operationId??a}).convert({context:t,errorCollector:r});s!=null&&s.schema!=null&&(l=s.schema,this.inlinedTypes={...this.inlinedTypes,...s.inlinedTypes})}else if(t.isMessageWithPayload(n.message)){let d;if(t.isReferenceObject(n.message.payload)){let s=await t.resolveReference(n.message.payload);s.resolved&&(d=s.value)}else d=n.message.payload;if(d!=null){let o=await new H2.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[...this.breadcrumbs,u],schemaOrReference:d,schemaIdOverride:n.operationId??a}).convert({context:t,errorCollector:r});o!=null&&o.schema!=null&&(l=o.schema,this.inlinedTypes={...this.inlinedTypes,...o.inlinedTypes})}}if(l!=null){let d=l,s=sc.TypeReference.named({fernFilepath:t.createFernFilepath(),name:d.name.name,typeId:d.name.typeId,default:void 0,inline:!1}),o=sc.WebSocketMessageBody.reference({bodyType:s,docs:n.description});return{type:d.name.typeId,displayName:d.name.name.originalName,origin:i,body:o,availability:await t.getAvailability({node:n,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:n.description}}}async convertQueryParameters({context:t,errorCollector:r,queryParameters:i}){for(let[n,a]of Object.entries(this.channel.parameters??{})){let u=a;if(t.isReferenceObject(a)){let s=await t.resolveReference(a);if(s.resolved)u=s.value;else continue}let d=await new h_i({breadcrumbs:this.breadcrumbs,parameter:{...u,name:n,in:"query",description:a.description,required:a.required??!1}}).convert({context:t,errorCollector:r});d!=null&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},d.type==="query"&&i.push(d.parameter))}}async convertHeaders({context:t,errorCollector:r,headers:i}){if(this.channel.bindings?.ws?.headers!=null){let n=this.channel.bindings.ws.headers.required??[];for(let[a,u]of Object.entries(this.channel.bindings.ws.headers.properties??{})){let l=u;if(t.isReferenceObject(u)){let o=await t.resolveReference(u);if(!o.resolved)continue;l=o.value}let s=await new h_i({breadcrumbs:[...this.breadcrumbs,a],parameter:{name:a,in:"header",required:n.includes(a),schema:l,description:"description"in l?l.description:void 0}}).convert({context:t,errorCollector:r});s!=null&&s.type==="header"&&(this.inlinedTypes={...this.inlinedTypes,...s.inlinedTypes},i.push(s.parameter))}}}async convertBindingQueryParameters({context:t,errorCollector:r,queryParameters:i}){if(this.channel.bindings?.ws?.query!=null){let n=this.channel.bindings.ws.query.required??[];for(let[a,u]of Object.entries(this.channel.bindings.ws.query.properties??{})){let l=u;if(t.isReferenceObject(u)){let o=await t.resolveReference(u);if(!o.resolved)continue;l=o.value}let s=await new h_i({breadcrumbs:[...this.breadcrumbs,a],parameter:{name:a,in:"query",required:n.includes(a),schema:l,description:"description"in l?l.description:void 0}}).convert({context:t,errorCollector:r});s!=null&&s.type==="query"&&(this.inlinedTypes={...this.inlinedTypes,...s.inlinedTypes},i.push(s.parameter))}}}transformToValidPath(t){return t.startsWith("/")?t:"/"+t}};var KNo=class extends og{servers;constructor({breadcrumbs:t,servers:r}){super({breadcrumbs:t}),this.servers=r}convert({context:t,errorCollector:r}){if(this.servers==null||Object.keys(this.servers).length===0)return;let i=[],n;for(let[a,u]of Object.entries(this.servers)){let l={id:a,name:t.casingsGenerator.generateName(a),url:this.constructServerUrl(u.protocol,u.url),docs:void 0};i.push(l),n==null&&(n=l.id)}return{defaultEnvironment:n,environments:NC.singleBaseUrl({environments:i})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var DXs="$message.",Oe_="#/channels/",me_="#/servers/",YNo=class extends og{channel;channelPath;operations;group;inlinedTypes={};constructor({breadcrumbs:t,channel:r,channelPath:i,operations:n,group:a}){super({breadcrumbs:t}),this.channel=r,this.channelPath=i,this.operations=n,this.group=a}async convert({context:t,errorCollector:r}){let i=[],n=[],a=[],u=this.group?this.group.join("."):this.channelPath;this.channel.parameters&&await this.convertChannelParameters({context:t,errorCollector:r,pathParameters:i,queryParameters:n,headers:a});let l=Object.entries(this.operations).reduce((o,[c,b])=>{try{this.getChannelPathFromOperation(b)===this.channelPath&&(o[c]=b)}catch{}return o},{}),d=[];for(let[o,c]of Object.entries(l))for(let b of c.messages){let g=await t.convertReferenceToTypeReference(b);if(g.ok){let O=sc.WebSocketMessageBody.reference({bodyType:g.reference,docs:c.description});d.push({type:o,displayName:o,origin:c.action==="send"?"client":"server",body:O,availability:await t.getAvailability({node:c,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:c.description})}}let s=this.resolveChannelServersFromReference(this.channel.servers??[],r)??Object.keys(t.spec.servers??{})[0];return{channel:{name:t.casingsGenerator.generateName(u),displayName:u,baseUrl:s,path:{head:this.transformToValidPath(this.channel.address??this.channelPath),parts:[]},auth:!1,headers:a,queryParameters:n,pathParameters:i,messages:d,examples:[],availability:await t.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.channel.description},inlinedTypes:this.inlinedTypes}}async convertChannelParameters({context:t,errorCollector:r,pathParameters:i,queryParameters:n,headers:a}){for(let u of Object.values(this.channel.parameters??{})){let l=u;if(t.isReferenceObject(u)){let g=await t.resolveReference(u);if(g.resolved)l=g.value;else continue}let d=this.convertChannelParameterLocation(u.location,r);if(d==null)continue;let{type:s,parameterKey:o}=d,b=await new h_i({breadcrumbs:this.breadcrumbs,parameter:{...l,name:o,in:s,required:!0}}).convert({context:t,errorCollector:r});if(b!=null)switch(this.inlinedTypes={...this.inlinedTypes,...b.inlinedTypes},b.type){case"path":i.push(b.parameter);break;case"query":n.push(b.parameter);break;case"header":a.push(b.parameter);break}}}convertChannelParameterLocation(t,r){try{let[i,n]=t.split("#/");if(i==null||n==null){r.collect({message:`Invalid location format: ${t}; unable to parse message type and parameter key`,path:this.breadcrumbs});return}if(!i.startsWith(DXs)){r.collect({message:`Invalid location format: ${t}; expected ${DXs} prefix`,path:this.breadcrumbs});return}let a=i.substring(DXs.length);if(a!=="header"&&a!=="path"&&a!=="payload"){r.collect({message:`Invalid message type: ${a}. Must be one of: header, path, payload`,path:this.breadcrumbs});return}return a==="payload"?{type:"query",parameterKey:n}:{type:a,parameterKey:n}}catch{r.collect({message:`Invalid location format: ${t}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`,path:this.breadcrumbs});return}}resolveChannelServersFromReference(t,r){if(t==null||t.length===0||t[0]==null)return;let i=t[0];if(!i.$ref.startsWith(me_)){r.collect({message:`Failed to resolve server name from server ref ${i.$ref}`,path:this.breadcrumbs});return}let n=i.$ref.substring(me_.length);if(n==null){r.collect({message:`Failed to find server with name ${n}`,path:this.breadcrumbs});return}return n}getChannelPathFromOperation(t){if(!t.channel.$ref.startsWith(Oe_))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring(Oe_.length)}transformToValidPath(t){return t.startsWith("/")?t:"/"+t}};var XNo=class extends og{servers;constructor({breadcrumbs:t,servers:r}){super({breadcrumbs:t}),this.servers=r}convert({context:t,errorCollector:r}){if(this.servers==null||Object.keys(this.servers).length===0)return;let i=[],n;for(let[a,u]of Object.entries(this.servers)){let l={id:a,name:t.casingsGenerator.generateName(a),url:this.constructServerUrl(u.protocol,u.host),docs:void 0};i.push(l),n==null&&(n=l.id)}return{defaultEnvironment:n,environments:NC.singleBaseUrl({environments:i})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var nba=class extends og{ir;constructor({breadcrumbs:t,context:r}){super({breadcrumbs:t}),this.ir={auth:{docs:void 0,requirement:sc.AuthSchemesRequirement.All,schemes:[]},types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:sc.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:r.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}}}}async convert({context:t,errorCollector:r}){t.spec=this.removeXFernIgnores({document:t.spec,context:t,errorCollector:r}),this.isAsyncAPIV3(t)?await this.convertChannelMessages({context:t,errorCollector:r}):await this.convertComponentMessages({context:t,errorCollector:r}),await this.convertSchemas({context:t,errorCollector:r}),await this.convertServers({context:t,errorCollector:r}),await this.convertChannels({context:t,errorCollector:r});let i={...this.ir,apiName:t.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:t.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}};return i={...i,...vFi({ir:i,exampleGeneration:{disabled:!1}})},i}isAsyncAPIV3(t){return parseFloat(t.spec.asyncapi)>=3}removeXFernIgnores({document:t,context:r,errorCollector:i,breadcrumbs:n=[]}){return Array.isArray(t)?t.filter((a,u)=>!new HG.FernIgnoreExtension({breadcrumbs:[...n,String(u)],operation:a}).convert({context:r,errorCollector:i})).map((a,u)=>this.removeXFernIgnores({document:a,context:r,errorCollector:i,breadcrumbs:[...n,String(u)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([a,u])=>!new HG.FernIgnoreExtension({breadcrumbs:[...n,a],operation:u}).convert({context:r,errorCollector:i})).map(([a,u])=>[a,this.removeXFernIgnores({document:u,context:r,errorCollector:i,breadcrumbs:[...n,a]})])):t}async convertChannelMessages({context:t,errorCollector:r}){let i=t.spec;for(let[n,a]of Object.entries(i.channels??{}))for(let[u,l]of Object.entries(a.messages??{})){if(!t.isMessageWithPayload(l)&&!t.isReferenceObject(l))continue;let d;if(t.isMessageWithPayload(l))if(t.isReferenceObject(l.payload)){let b=await t.resolveReference(l.payload);b.resolved&&(d=b.value)}else d=l.payload;else if(t.isReferenceObject(l)){let b=await t.resolveReference(l);if(b.resolved){let g=b.value.payload;if(t.isReferenceObject(g)){let O=await t.resolveReference(g);O.resolved&&(d=O.value)}else d=g}}if(d==null)continue;let s=`${n}_${u}`,c=await new H2.SchemaConverters.SchemaConverter({id:s,breadcrumbs:["channels",n,"messages",u],schema:d}).convert({context:t,errorCollector:r});c!=null&&(this.ir.rootPackage.types.push(s),this.ir.types={...this.ir.types,...c.inlinedTypes,[s]:c.typeDeclaration})}}async convertComponentMessages({context:t,errorCollector:r}){for(let[i,n]of Object.entries(t.spec.components?.messages??{})){if(n.payload==null)continue;let a;if(t.isReferenceObject(n.payload)){let d=await t.resolveReference(n.payload);d.resolved&&(a=d.value)}else a=n.payload;if(a==null)continue;let l=await new H2.SchemaConverters.SchemaConverter({id:i,breadcrumbs:["components","messages",i],schema:a}).convert({context:t,errorCollector:r});l!=null&&(this.ir.rootPackage.types.push(i),this.ir.types={...this.ir.types,...l.inlinedTypes,[i]:l.typeDeclaration})}}async convertSchemas({context:t,errorCollector:r}){for(let[i,n]of Object.entries(t.spec.components?.schemas??{})){let u=await new H2.SchemaConverters.SchemaConverter({id:i,breadcrumbs:["components","schemas",i],schema:n}).convert({context:t,errorCollector:r});u!=null&&(this.ir.rootPackage.types.push(i),this.ir.types={...this.ir.types,...u.inlinedTypes,[i]:u.typeDeclaration})}}async convertServers({context:t,errorCollector:r}){if(this.isAsyncAPIV3(t)){let i=t.spec.servers,a=new XNo({breadcrumbs:["servers"],servers:i}).convert({context:t,errorCollector:r});a!=null&&(this.ir.environments=a)}else{let i=t.spec.servers,a=new KNo({breadcrumbs:["servers"],servers:i}).convert({context:t,errorCollector:r});a!=null&&(this.ir.environments=a)}}async convertChannels({context:t,errorCollector:r}){for(let[i,n]of Object.entries(t.spec.channels??{})){let u=new HG.SdkGroupNameExtension({breadcrumbs:["channels",i],operation:n}).convert({context:t,errorCollector:r})?.groups;if(this.isAsyncAPIV3(t)){let d=t.spec.operations??{},o=await new YNo({breadcrumbs:["channels",i],channel:n,channelPath:i,operations:d,group:u}).convert({context:t,errorCollector:r});o!=null&&(this.ir.websocketChannels={...this.ir.websocketChannels,[u?u.join("."):i]:o.channel},this.ir.types={...this.ir.types,...o.inlinedTypes})}else{let d=await new JNo({breadcrumbs:["channels",i],channel:n,channelPath:i,group:u}).convert({context:t,errorCollector:r});d!=null&&(this.ir.websocketChannels={...this.ir.websocketChannels,[u?u.join("."):i]:d.channel},this.ir.types={...this.ir.types,...d.inlinedTypes})}}this.addWebsocketsToIr({websocketChannels:this.ir.websocketChannels,context:t})}addWebsocketsToIr({websocketChannels:t,context:r}){if(t!=null)for(let[i,n]of Object.entries(t))i!==""?(this.ir.subpackages[i]==null&&(this.ir.subpackages[i]={name:r.casingsGenerator.generateName(i),...r.createPackage({name:i})}),this.ir.subpackages[i].websocket=i,this.ir.rootPackage.subpackages.push(i)):this.ir.rootPackage.websocket=i}};var aba=class extends bFi{isReferenceObject(t){return t!=null&&"$ref"in t}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}getTypeIdFromMessageReference(t){let r=t.$ref.match(/\/messages\/(.+)$/);if(!(!r||!r[1]))return r[1]}async convertReferenceToTypeReference(t){let r,i=t.$ref.match(/^.*\/schemas\/(.+)$/),n=t.$ref.match(/^.*\/messages\/(.+)$/);return i&&i[1]?r=i[1]:n&&n[1]&&(r=n[1]),r==null?{ok:!1}:(await this.resolveReference(t)).resolved?{ok:!0,reference:a_.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(r),typeId:r,default:void 0,inline:!1})}:{ok:!1}}};var we_=di(EXs(),1);var TXs=di(EXs(),1);var Pe_=["get","post","put","delete","patch"];var ZNo=class extends mz{operation;key="x-fern-idempotent";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null){if(typeof i!="boolean"){r.collect({message:"Received unexpected non-boolean value for x-fern-idempotent",path:this.breadcrumbs});return}return i}}};var JiE=Yu.object({cursor:Yu.string(),next_cursor:Yu.string(),results:Yu.string()}),KiE=Yu.object({offset:Yu.string(),results:Yu.string(),step:Yu.string().optional(),"has-next-page":Yu.string().optional()}),MXs=Yu.union([Yu.boolean(),JiE,KiE]);var AXs="$request.",kNo="$response.",eFo=class extends mz{operation;document;key="x-fern-pagination";constructor({breadcrumbs:t,operation:r,document:i}){super({breadcrumbs:t}),this.operation=r,this.document=i}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i==null)return;let n=MXs.safeParse(i);if(!n.success){r.collect({message:`Invalid x-fern-pagination extension: ${n.error.message}`,path:this.breadcrumbs});return}if(typeof n.data=="boolean"){let a=this.getExtensionValue(this.document);if(a==null)return;if(typeof a=="boolean"){r.collect({message:"Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.",path:this.breadcrumbs});return}let u=MXs.safeParse(a);if(!u.success){r.collect({message:`Invalid x-fern-pagination extension: ${u.error.message}`,path:this.breadcrumbs});return}if(typeof u.data=="boolean"){r.collect({message:"Global pagination extension is a boolean, expected an object.",path:this.breadcrumbs});return}return this.convertPaginationConfig(u.data,t)}if(typeof n.data=="boolean"){r.collect({message:"Pagination extension is a boolean with no global configuration.",path:this.breadcrumbs});return}return this.convertPaginationConfig(n.data,t)}convertPaginationConfig(t,r){let i=t;if("cursor"in i)return{type:"cursor",cursor:r.maybeTrimPrefix(i.cursor,AXs),nextCursor:r.maybeTrimPrefix(i.next_cursor,kNo),results:r.maybeTrimPrefix(i.results,kNo)};let n=t;return{type:"offset",offset:r.maybeTrimPrefix(n.offset,AXs),results:r.maybeTrimPrefix(n.results,kNo),step:n.step!=null?r.maybeTrimPrefix(n.step,AXs):void 0,hasNextPage:n["has-next-page"]!=null?r.maybeTrimPrefix(n["has-next-page"],kNo):void 0}}};var YiE="$request.",XiE=Yu.object({"stream-condition":Yu.string().optional(),format:Yu.enum(["sse","json"]).optional(),"stream-description":Yu.string().optional(),"response-stream":Yu.any(),response:Yu.any()}),ZiE=Yu.union([Yu.boolean(),XiE]),$En=class extends mz{operation;key="x-fern-streaming";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i==null)return;let n=ZiE.safeParse(i);if(!n.success){r.collect({message:`Invalid x-fern-streaming extension: ${n.error.message}`,path:this.breadcrumbs});return}if(typeof n.data=="boolean")return n.data?{type:"stream",format:"json"}:void 0;if(n.data["stream-condition"]==null&&n.data.format!=null)return{type:"stream",format:n.data.format};if(n.data["stream-condition"]==null){r.collect({message:"Missing required stream-condition property",path:this.breadcrumbs});return}return{type:"streamCondition",format:n.data.format??"json",streamDescription:n.data["stream-description"],streamConditionProperty:t.maybeTrimPrefix(n.data["stream-condition"],YiE),responseStream:n.data["response-stream"],response:n.data.response}}};var tFo=class extends mz{operation;key="x-fern-webhook";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null){if(typeof i!="boolean"){r.collect({message:"Received unexpected non-boolean value for x-fern-webhook",path:this.breadcrumbs});return}return i}}};var rFo=class extends mz{server;key="x-fern-server-name";constructor({breadcrumbs:t,server:r}){super({breadcrumbs:t}),this.server=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.server);if(!(i==null||typeof i!="string"))return i}};var qXs="Base",GEn=class e extends og{servers;endpointLevelServers;constructor({breadcrumbs:t,servers:r,endpointLevelServers:i}){super({breadcrumbs:t}),this.servers=r,this.endpointLevelServers=i}convert({context:t,errorCollector:r}){if(this.servers==null||this.servers.length===0||this.servers[0]==null)return;if(this.endpointLevelServers!=null&&this.endpointLevelServers.length>0){let n={id:qXs,name:t.casingsGenerator.generateName(qXs)},a=this.endpointLevelServers.map(d=>{let s=e.getServerName({server:d,errorCollector:r,context:t});return{id:s,name:t.casingsGenerator.generateName(s)}}).filter((d,s,o)=>o.findIndex(c=>c.id===d.id)===s),u=[n,...a],l=this.servers.map(d=>{let s=e.getServerName({server:d,errorCollector:r,context:t}),o=this.endpointLevelServers?.map(c=>[e.getServerName({server:c,errorCollector:r,context:t}),this.getServerUrl(c)]);return{id:s,name:t.casingsGenerator.generateName(s),urls:{[qXs]:this.getServerUrl(d),...Object.fromEntries(o??[])},docs:d.description}});return{value:{defaultEnvironment:l[0]?.id,environments:NC.multipleBaseUrls({baseUrls:u,environments:l})},defaultUrl:e.getServerName({server:this.servers[0],errorCollector:r,context:t})}}let i=this.servers.map(n=>{let a=e.getServerName({server:n,context:t,errorCollector:r});return{id:a,name:t.casingsGenerator.generateName(a),url:this.getServerUrl(n),docs:n.description}}).filter(y0);return{value:{defaultEnvironment:i[0]?.id,environments:NC.singleBaseUrl({environments:i})}}}static getServerName({server:t,context:r,errorCollector:i}){return new rFo({breadcrumbs:[],server:t}).convert({context:r,errorCollector:i})??t.description??t.url}getServerUrl(t){if(t.variables==null)return t.url;let r=t.url;for(let[i,n]of Object.entries(t.variables))n.default!=null&&(r=r.replace(`{${i}}`,n.default));return r}};var oba=class e extends og{static STRING=a_.primitive({v1:"STRING",v2:Dv.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=a_.container(eg.optional(e.STRING));parameter;constructor({breadcrumbs:t,parameter:r}){super({breadcrumbs:t}),this.parameter=r}async convert({context:t,errorCollector:r}){let i,n={};if(this.parameter.schema!=null){let l=await new H2.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert({context:t,errorCollector:r});l!=null&&(i=l.type,n=l.inlinedTypes??{})}let a=await t.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs,errorCollector:r});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??e.OPTIONAL_STRING,allowMultiple:this.parameter.explode??!1,availability:a},inlinedTypes:n};case"header":return{type:"header",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??e.OPTIONAL_STRING,env:void 0,availability:a},inlinedTypes:n};case"path":return{type:"path",parameter:{name:t.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:i??e.STRING,location:"ENDPOINT",variable:void 0},inlinedTypes:n};default:return}}};var iFo=class extends og{requestBody;group;method;constructor({breadcrumbs:t,requestBody:r,group:i,method:n}){super({breadcrumbs:t}),this.requestBody=r,this.group=i,this.method=n}async convert({context:t,errorCollector:r}){if(!this.requestBody.content)return;let i=Object.keys(this.requestBody.content).filter(u=>u.includes("json"));for(let u of i){let l=this.handleJsonOrFormContent({contentType:u,context:t,errorCollector:r});if(l!=null)return l}let n=Object.keys(this.requestBody.content).filter(u=>u.includes("multipart"));for(let u of n){let l=[...this.group,this.method,"Request"].join("_"),d=await this.convertRequestSchemaForMediaType({schemaId:l,contentType:u,context:t,errorCollector:r});if(d!=null&&d.schema?.shape.type==="object")return{requestBody:pI.fileUpload({docs:this.requestBody.description,name:t.casingsGenerator.generateName(l),properties:d.schema?.shape.properties.map(o=>this.convertRequestBodyProperty({context:t,property:o,contentType:u}))}),inlinedTypes:t.removeSchemaFromInlinedTypes({id:l,inlinedTypes:d.inlinedTypes}),examples:d.examples}}let a=Object.keys(this.requestBody.content).filter(u=>u.includes("urlencoded"));for(let u of a){let l=this.handleJsonOrFormContent({contentType:u,context:t,errorCollector:r});if(l!=null)return l}}async convertRequestSchemaForMediaType({schemaId:t,contentType:r,context:i,errorCollector:n}){let a=this.requestBody.content[r];if(a==null||a.schema==null)return;let l=await new H2.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:a.schema,schemaIdOverride:t}).convert({context:i,errorCollector:n});if(l==null)return;let d=a.examples!=null?Object.fromEntries(await Promise.all(Object.entries(a.examples).map(async([s,o])=>[s,i.isReferenceObject(o)?await i.resolveReference(o):o]))):void 0;return{...l,examples:d}}async handleJsonOrFormContent({contentType:t,context:r,errorCollector:i}){let n=[...this.group,this.method,"Request"].join("_"),a=await this.convertRequestSchemaForMediaType({schemaId:n,contentType:t,context:r,errorCollector:i});if(a!=null)return a.schema?.shape.type==="object"?{requestBody:pI.inlinedRequestBody({contentType:t,docs:this.requestBody.description,name:r.casingsGenerator.generateName(n),extendedProperties:a.schema?.shape.extendedProperties,extends:a.schema?.shape.extends,properties:a.schema?.shape.properties,extraProperties:a.schema?.shape.extraProperties}),inlinedTypes:r.removeSchemaFromInlinedTypes({id:n,inlinedTypes:a.inlinedTypes})}:{requestBody:pI.reference({contentType:t,docs:this.requestBody.description,requestBodyType:a.type}),inlinedTypes:r.removeSchemaFromInlinedTypes({id:n,inlinedTypes:a.inlinedTypes})}}convertRequestBodyProperty({context:t,property:r,contentType:i}){return t.isFile(r.valueType)?aF.file(QU.file({key:r.name,isOptional:!1,contentType:i,docs:r.docs})):t.isOptional(r.valueType)&&t.isFile(r.valueType.container.optional)?aF.file(QU.file({key:r.name,isOptional:!0,contentType:i,docs:r.docs})):t.isList(r.valueType)&&t.isFile(r.valueType.container.list)?aF.file(QU.fileArray({key:r.name,isOptional:!1,contentType:i,docs:r.docs})):t.isList(r.valueType)&&t.isOptional(r.valueType.container.list)&&t.isFile(r.valueType.container.list.container.optional)?aF.file(QU.fileArray({key:r.name,isOptional:!1,contentType:i,docs:r.docs})):t.isOptional(r.valueType)&&t.isList(r.valueType.container.optional)&&t.isFile(r.valueType.container.optional.container.list)?aF.file(QU.fileArray({key:r.name,isOptional:!0,contentType:i,docs:r.docs})):aF.bodyProperty({...r,contentType:i,style:void 0,name:r.name})}};var nFo=class extends og{responseBody;group;method;statusCode;streamingExtension;constructor({breadcrumbs:t,responseBody:r,group:i,method:n,statusCode:a,streamingExtension:u}){super({breadcrumbs:t}),this.responseBody=r,this.group=i,this.method=n,this.statusCode=a,this.streamingExtension=u}async convert({context:t,errorCollector:r}){if(!this.responseBody.content)return;let i=Object.keys(this.responseBody.content).filter(a=>a.includes("json"));for(let a of[...i]){let u=await this.parseMediaTypeObject({context:t,errorCollector:r,contentType:a});if(u!=null&&a.includes("json"))return{responseBody:JA.json(MSe.response({responseBodyType:u.convertedSchema.type,docs:this.responseBody.description})),inlinedTypes:u.convertedSchema.inlinedTypes,examples:u.examples}}let n=Object.keys(this.responseBody.content).filter(a=>!a.includes("json"));for(let a of n){let u=await this.parseMediaTypeObject({context:t,errorCollector:r,contentType:a});if(u!=null&&this.isBinarySchema(u.convertedSchema))return t.settings?.useBytesForBinaryResponse&&this.streamingExtension==null?{responseBody:JA.bytes({docs:this.responseBody.description}),inlinedTypes:{}}:{responseBody:JA.fileDownload({docs:this.responseBody.description}),inlinedTypes:{}}}}async parseMediaTypeObject({context:t,errorCollector:r,contentType:i}){let n=this.responseBody.content?.[i];if(n==null||n.schema==null)return;let a=[...this.group,this.method,"Response",this.statusCode].join("_"),l=await new H2.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:n.schema,schemaIdOverride:a}).convert({context:t,errorCollector:r});if(l==null)return;let d=n.examples!=null?Object.fromEntries(await Promise.all(Object.entries(n.examples).map(async([s,o])=>[s,t.isReferenceObject(o)?await t.resolveReference(o):o]))):void 0;return{convertedSchema:l,examples:d}}isBinarySchema(t){let r=t.type;switch(r.type){case"container":case"named":case"unknown":return!1;case"primitive":return r.primitive.v2==null?!1:r.primitive.v2.type==="string"&&r.primitive.v2.validation?.format==="binary";default:return!1}}};var kiE=/{([^}]+)}/g,QEn=class extends og{operation;method;path;inlinedTypes={};constructor({breadcrumbs:t,operation:r,method:i,path:n}){super({breadcrumbs:t}),this.operation=r,this.method=i,this.path=n}convertHttpMethod(){switch(this.method){case"get":return b7.Get;case"post":return b7.Post;case"put":return b7.Put;case"delete":return b7.Delete;case"patch":return b7.Patch;default:return}}async convertParameters({context:t,errorCollector:r,breadcrumbs:i}){let n=[],a=[],u=[];if(!this.operation.parameters)return{pathParameters:n,queryParameters:a,headers:u};for(let s of this.operation.parameters){if(t.isReferenceObject(s)){let b=await t.resolveReference(s);if(b.resolved)s=b.value;else continue}let c=await new oba({breadcrumbs:i,parameter:s}).convert({context:t,errorCollector:r});if(c!=null)switch(this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},c.type){case"path":n.push(c.parameter);break;case"query":a.push(c.parameter);break;case"header":u.push(c.parameter);break}}let d=[...this.path.matchAll(kiE)].map(s=>s[1]).filter(s=>!n.some(o=>o.name.originalName===s));for(let s of d)s!=null&&n.push({name:t.casingsGenerator.generateName(s),valueType:oba.STRING,docs:void 0,location:"ENDPOINT",variable:void 0});return{pathParameters:n,queryParameters:a,headers:u}}async convertRequestBody({context:t,errorCollector:r,breadcrumbs:i,group:n,method:a}){if(this.operation.requestBody==null)return;let u;if(t.isReferenceObject(this.operation.requestBody)){let s=await t.resolveReference(this.operation.requestBody);s.resolved&&(u=s.value)}else u=this.operation.requestBody;if(u==null)return null;let d=await new iFo({breadcrumbs:i,requestBody:u,group:n??[],method:a}).convert({context:t,errorCollector:r});if(d!=null)return this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},{value:d.requestBody,examples:d.examples}}async convertResponseBody({context:t,errorCollector:r,breadcrumbs:i,group:n,method:a,streamingExtension:u}){if(this.operation.responses!=null)for(let[l,d]of Object.entries(this.operation.responses)){let s=parseInt(l);if(isNaN(s)||s<200||s>=300)continue;let o;if(t.isReferenceObject(d)){let g=await t.resolveReference(d);g.resolved&&(o=g.value)}else o=d;if(o==null)continue;let b=await new nFo({breadcrumbs:[...i,l],responseBody:o,group:n??[],method:a,statusCode:l,streamingExtension:u}).convert({context:t,errorCollector:r});if(b!=null)return this.inlinedTypes={...this.inlinedTypes,...b.inlinedTypes},{value:{statusCode:s,body:b.responseBody},examples:b.examples}}}computeGroupNameAndLocationFromExtensions({context:t,errorCollector:r}){let n=new HG.SdkMethodNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation}).convert({context:t,errorCollector:r})?.methodName,u=new HG.SdkGroupNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation}).convert({context:t,errorCollector:r})?.groups??[];if(n!=null)return{group:u,method:n}}computeGroupNameFromTagAndOperationId({context:t,errorCollector:r}){let i=this.operation.tags?.[0],n=this.operation.operationId;if(n==null){let l=this.operation.summary!=null?L0(this.operation.summary):L0(`${this.method}_${this.path.split("/").join("_")}`);return i!=null?{group:[i],method:l}:{method:l}}if(i==null)return{method:n};let a=je_(i),u=je_(n);return oSe(a,u)?{method:i}:this.computeGroupAndMethodFromTokens({tag:i,tagTokens:a,operationId:n,operationIdTokens:u})}computeGroupAndMethodFromTokens({tag:t,tagTokens:r,operationId:i,operationIdTokens:n}){if(r.some((l,d)=>l!==n[d]))return{group:[t],method:i};let u=n.slice(r.length);return{group:[t],method:L0(u.join("_"))}}};function je_(e){let t=enE(e)?tnE(e):rnE(e);return t=t.map(r=>r.toLowerCase()),t=NBe(t),t}function enE(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function tnE(e){return e.split(/(?=[A-Z])/)}function rnE(e){return e.split(/[^a-zA-Z0-9]+/)}var aFo=class extends QEn{idempotent;servers;streamingExtensionConverter;constructor({breadcrumbs:t,operation:r,method:i,path:n,idempotent:a,servers:u}){super({breadcrumbs:t,operation:r,method:i,path:n}),this.idempotent=a,this.servers=u,this.streamingExtensionConverter=new $En({breadcrumbs:this.breadcrumbs,operation:this.operation})}async convert({context:t,errorCollector:r}){let i=this.convertHttpMethod();if(i==null)return;let{group:n,method:a}=this.computeGroupNameAndLocationFromExtensions({context:t,errorCollector:r})??this.computeGroupNameFromTagAndOperationId({context:t,errorCollector:r}),u=this.streamingExtensionConverter.convert({context:t,errorCollector:r}),{headers:l,pathParameters:d,queryParameters:s}=await this.convertParameters({context:t,errorCollector:r,breadcrumbs:[...this.breadcrumbs,"parameters"]}),o=await this.convertRequestBody({context:t,errorCollector:r,breadcrumbs:[...this.breadcrumbs,"requestBody"],group:n,method:a}),c=o?.value,b=await this.convertResponseBody({context:t,errorCollector:r,breadcrumbs:[...this.breadcrumbs,"responses"],group:n,method:a,streamingExtension:u}),g=this.operation.servers?.[0]??this.servers?.[0]??t.spec.servers?.[0],O=[];return t.namespace!=null&&O.push(t.namespace),O.push(...n??[]),O.push(a),{group:n,endpoint:{id:O.join("."),displayName:this.operation.summary,method:i,name:t.casingsGenerator.generateName(a),baseUrl:g!=null?GEn.getServerName({server:g,context:t,errorCollector:r}):void 0,path:LV(this.path),pathParameters:d,queryParameters:s,headers:l,requestBody:c,sdkRequest:void 0,response:b?.value,errors:[],auth:this.operation.security!=null||t.spec.security!=null,availability:await t.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.operation.description,userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:this.idempotent??!1,basePath:void 0,fullPath:LV(this.path),allPathParameters:d,pagination:void 0,transport:void 0},inlinedTypes:this.inlinedTypes,servers:this.operation.servers}}convertExamples({requestExamples:t,responseExamples:r,context:i}){return[]}};var JEn=class extends QEn{constructor({breadcrumbs:t,operation:r,method:i,path:n}){super({breadcrumbs:t,operation:r,method:i,path:n})}async convert({context:t,errorCollector:r}){if(this.operation.operationId==null){r.collect({message:"Skipping webhook because no operation id present",path:this.breadcrumbs});return}if(this.operation.requestBody==null){r.collect({message:"Skipping webhook because no request body present",path:this.breadcrumbs});return}let i=this.convertHttpMethod();if(i==null)return;if(i!=="POST"&&i!=="GET"){r.collect({message:"Skipping webhook because non-POST or GET method",path:this.breadcrumbs});return}let{group:n,method:a}=this.computeGroupNameAndLocationFromExtensions({context:t,errorCollector:r})??this.computeGroupNameFromTagAndOperationId({context:t,errorCollector:r}),u=[...this.breadcrumbs,"Payload"],{headers:l,pathParameters:d,queryParameters:s}=await this.convertParameters({context:t,errorCollector:r,breadcrumbs:u}),o=await this.convertRequestBody({context:t,errorCollector:r,breadcrumbs:u,group:n,method:a}),c;if(o?.value.type==="inlinedRequestBody")c=YU.inlinedPayload({name:o.value.name,extends:o.value.extends,properties:o.value.properties});else if(o?.value.type==="reference")c=YU.reference({payloadType:o.value.requestBodyType,docs:o.value.docs});else return;return{group:n,webhook:{id:`${n?.join(".")??""}.${a}`,name:t.casingsGenerator.generateName(a),displayName:this.operation.summary,method:i,headers:l,payload:c,examples:[],availability:await t.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.operation.description},inlinedTypes:this.inlinedTypes}}};var oFo=class extends og{pathItem;path;servers;constructor({breadcrumbs:t,pathItem:r,path:i,servers:n}){super({breadcrumbs:t}),this.pathItem=r,this.path=i,this.servers=n}async convert({context:t,errorCollector:r}){let i=[],n=[],a={};for(let u of Pe_){let l=this.pathItem[u];if(l==null)continue;let d=[...this.breadcrumbs,u],s=await this.tryParseAsWebhook({operationBreadcrumbs:d,operation:l,method:u,context:t,errorCollector:r});if(s!=null){n.push(s),Object.assign(a,s.inlinedTypes);continue}new $En({breadcrumbs:d,operation:l}).convert({context:t,errorCollector:r})!=null;let b=await this.tryParseAsHttpEndpoint({operationBreadcrumbs:d,operation:l,method:u,context:t,errorCollector:r});b!=null&&(i.push(b),Object.assign(a,b.inlinedTypes))}return{endpoints:i,webhooks:n,inlinedTypes:a}}async tryParseAsWebhook({operation:t,method:r,operationBreadcrumbs:i,context:n,errorCollector:a}){return new tFo({breadcrumbs:i,operation:t}).convert({context:n,errorCollector:a})?await new JEn({breadcrumbs:i,operation:t,method:TXs.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert({context:n,errorCollector:a}):void 0}async tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:i,context:n,errorCollector:a}){new eFo({breadcrumbs:i,operation:t,document:n.spec}).convert({context:n,errorCollector:a})!=null;let s=new ZNo({breadcrumbs:i,operation:t}).convert({context:n,errorCollector:a});return await new aFo({breadcrumbs:i,operation:t,method:TXs.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:s}).convert({context:n,errorCollector:a})}};var uFo=class extends og{securityScheme;constructor({breadcrumbs:t,securityScheme:r}){super({breadcrumbs:t}),this.securityScheme=r}convert({context:t,errorCollector:r}){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme==="bearer")return FR.bearer({token:t.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description});if(this.securityScheme.scheme==="basic")return FR.basic({username:t.casingsGenerator.generateName("username"),password:t.casingsGenerator.generateName("password"),usernameEnvVar:void 0,passwordEnvVar:void 0,docs:this.securityScheme.description});break}case"apiKey":{if(this.securityScheme.in==="header")return FR.header({name:{name:t.casingsGenerator.generateName(this.securityScheme.name),wireValue:this.securityScheme.name},valueType:a_.container(eg.optional(a_.primitive({v1:"STRING",v2:Dv.string({default:void 0,validation:void 0})}))),prefix:void 0,headerEnvVar:void 0,docs:this.securityScheme.description});break}case"oauth2":return FR.bearer({token:t.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var uba=class extends og{ir;constructor({breadcrumbs:t,context:r}){super({breadcrumbs:t}),this.ir={auth:{docs:void 0,requirement:sc.AuthSchemesRequirement.All,schemes:[]},types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:sc.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:r.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}}}}async convert({context:t,errorCollector:r}){t.spec=this.removeXFernIgnores({document:t.spec,context:t,errorCollector:r}),await this.convertSecuritySchemes({context:t,errorCollector:r}),await this.convertSchemas({context:t,errorCollector:r}),await this.convertWebhooks({context:t,errorCollector:r});let{endpointLevelServers:i}=await this.convertPaths({context:t,errorCollector:r});this.convertServers({context:t,errorCollector:r,endpointLevelServers:i});let n={...this.ir,apiName:t.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:t.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}};return n={...n,...vFi({ir:n,exampleGeneration:{disabled:!1}})},n}removeXFernIgnores({document:t,context:r,errorCollector:i,breadcrumbs:n=[]}){return Array.isArray(t)?t.filter((a,u)=>!new HG.FernIgnoreExtension({breadcrumbs:[...n,String(u)],operation:a}).convert({context:r,errorCollector:i})).map((a,u)=>this.removeXFernIgnores({document:a,context:r,errorCollector:i,breadcrumbs:[...n,String(u)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([a,u])=>!new HG.FernIgnoreExtension({breadcrumbs:[...n,a],operation:u}).convert({context:r,errorCollector:i})).map(([a,u])=>[a,this.removeXFernIgnores({document:u,context:r,errorCollector:i,breadcrumbs:[...n,a]})])):t}async convertSecuritySchemes({context:t,errorCollector:r}){let i=[];for(let[n,a]of Object.entries(t.spec.components?.securitySchemes??{})){let u;if(t.isReferenceObject(a)){let s=await t.resolveReference(a);if(!s.resolved)continue;u=s.value}else u=a;let d=new uFo({breadcrumbs:["components","securitySchemes",n],securityScheme:u}).convert({context:t,errorCollector:r});d!=null&&i.push(d)}i.length>0&&(this.ir.auth={requirement:"ANY",schemes:i,docs:void 0})}convertServers({context:t,errorCollector:r,endpointLevelServers:i}){let a=new GEn({breadcrumbs:["servers"],servers:t.spec.servers,endpointLevelServers:i}).convert({context:t,errorCollector:r});a!=null&&(this.ir.environments=a.value)}async convertSchemas({context:t,errorCollector:r}){let i=this.getGroup({groupParts:[],namespace:t.namespace}),n=this.getOrCreatePackage({context:t,group:i});for(let[a,u]of Object.entries(t.spec.components?.schemas??{})){let d=await new H2.SchemaConverters.SchemaConverter({id:a,breadcrumbs:["components","schemas",a],schema:u}).convert({context:t,errorCollector:r});d!=null&&(n.types.push(a),this.ir.types={...this.ir.types,...d.inlinedTypes,[a]:d.typeDeclaration})}}async convertWebhooks({context:t,errorCollector:r}){let i={};for(let[,n]of Object.entries(t.spec.webhooks??{})){if(n==null||!("post"in n)||!n.post?.operationId)continue;let a=n.post.operationId,l=await new JEn({breadcrumbs:["webhooks",a],operation:n.post,method:we_.OpenAPIV3.HttpMethods.POST,path:a}).convert({context:t,errorCollector:r});if(l!=null){let d=l.group?.join(".")??a;i[d]==null&&(i[d]=[]),i[d].push(a),this.ir.webhookGroups[d]==null&&(this.ir.webhookGroups[d]=[]),this.ir.webhookGroups[d].push(l.webhook),this.ir.types={...this.ir.types,...l.inlinedTypes}}}}async convertPaths({context:t,errorCollector:r}){let i=[];for(let[n,a]of Object.entries(t.spec.paths??{})){if(a==null)continue;let l=await new oFo({breadcrumbs:["paths",n],pathItem:a,path:n,servers:t.spec.servers}).convert({context:t,errorCollector:r});if(l!=null){for(let d of l.endpoints){let s=this.getGroup({groupParts:d.group,namespace:t.namespace}),o=s.join("."),c=this.getOrCreatePackage({context:t,group:d.group}),b=[...s].map(O=>t.casingsGenerator.generateName(O)),g=b[b.length-1];c.service==null&&(c.service=`service_${o}`),this.ir.services[c.service]==null&&(this.ir.services[c.service]={name:{fernFilepath:{allParts:b,packagePath:b.slice(0,-1),file:g}},displayName:void 0,basePath:LV(""),headers:[],pathParameters:[],availability:void 0,endpoints:[],transport:void 0,encoding:void 0}),this.ir.services[c.service]?.endpoints.push(d.endpoint),d.servers&&d.servers[0]!=null&&i.push(d.servers[0])}for(let d of l.webhooks){let o=this.getGroup({groupParts:d.group,namespace:t.namespace}).join("."),c=this.getOrCreatePackage({context:t,group:d.group});this.ir.webhookGroups[o]??=[],this.ir.webhookGroups[o].push(d.webhook),c.webhooks=o}this.ir.types={...this.ir.types,...l.inlinedTypes}}}return{endpointLevelServers:i}}getOrCreatePackage({context:t,group:r}){let i=[];if(t.namespace!=null&&i.push(t.namespace),i.push(...r??[]),i.length==0)return this.ir.rootPackage;let n=this.ir.rootPackage;for(let a=0;a<i.length;a++){let u=i[a],l=i.slice(0,a+1).join(".");this.ir.subpackages[l]==null&&(this.ir.subpackages[l]={name:t.casingsGenerator.generateName(u),...t.createPackage({name:u})});let d=this.ir.subpackages[l];n.subpackages.includes(l)||n.subpackages.push(l),n=d}return n}getGroup({groupParts:t,namespace:r}){let i=[];return r!=null&&i.push(r),i.push(...t??[]),i}};var sba=class extends bFi{isReferenceObject(t){return t!=null&&"$ref"in t}async convertReferenceToTypeReference(t){let r=this.getTypeIdFromSchemaReference(t);return r==null?{ok:!1}:(await this.resolveReference(t)).resolved?{ok:!0,reference:a_.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r),typeId:r,default:void 0,inline:!1})}:{ok:!1}}};var Se_={[My.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,lx(e)])),[My.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[My.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[My.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all"]),[My.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[My.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime"]),[My.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[My.GenerationLanguage.SWIFT]:new Set([])};var inE=["go","ruby"];function De_({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let u=c=>({unsafeName:c,safeName:nnE({name:c,keywords:anE({generationLanguage:e,keywords:t})})}),l=L0(n),d=lx(l),s=qCi(n),o=DCi(l);return r&&(!snE(o)&&(e==null||inE.includes(e))&&(l=o.map((c,b)=>{if(b>0){let g=sFo(c);if(g!=null)return g;if(cFo(c))return c.toUpperCase()}return c}).join(""),d=o.map((c,b)=>{let g=sFo(c);return g??(cFo(c)?c.toUpperCase():b===0?lx(c):c)}).join("")),s=n.split(" ").map(c=>c.split(/(\d+)/).map(qCi).join("")).join("_")),{originalName:n,camelCase:u(a?.casingOverrides?.camel??l),snakeCase:u(a?.casingOverrides?.snake??s),screamingSnakeCase:u(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:u(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:n,wireValue:a,opts:u})=>({name:i.generateName(n,u),wireValue:a})};return i}function nnE({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":unE(e)?"_"+e:e}function anE({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return Se_[e]}var onE=/^[0-9]/;function unE(e){return onE.test(e)}function snE(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=sFo(i)!=null||cFo(i),a=sFo(t)!=null||cFo(t);return n&&a})}function sFo(e){return lnE.get(e.toUpperCase())}function cFo(e){return cnE.has(e.toUpperCase())}var cnE=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),lnE=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var $7=class extends jha{specs;sources;loader;constructor({specs:t,...r}){super({...r,respectReadonlySchemas:t.every(i=>i.settings?.respectReadonlySchemas),respectNullableSchemas:t.every(i=>i.settings?.respectNullableSchemas),onlyIncludeReferencedSchemas:t.every(i=>i.settings?.onlyIncludeReferencedSchemas),inlinePathParameters:t.every(i=>i.settings?.inlinePathParameters),objectQueryParameters:t.every(i=>i.settings?.objectQueryParameters),useBytesForBinaryResponse:t.filter(i=>i.type==="openapi"&&i.source.type==="openapi").some(i=>i.settings?.useBytesForBinaryResponse),exampleGeneration:t[0]?.settings?.exampleGeneration}),this.specs=t,this.sources=this.convertSpecsToIdentifiableSources(t),this.loader=new f9t(this.absoluteFilePath)}async getOpenAPIIr({context:t,relativePathToDependency:r},i){let n=await Jze({context:t,specs:this.specs,relativePathToDependency:r});return GNi({context:t,documents:await this.loader.loadDocuments({context:t,specs:n}),options:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.objectQueryParameters,exampleGeneration:i?.exampleGeneration??this.exampleGeneration,useBytesForBinaryResponse:i?.useBytesForBinaryResponse??this.useBytesForBinaryResponse}})}async getIntermediateRepresentation({context:t}){let r=await Jze({context:t,specs:this.specs}),i=await this.loader.loadDocuments({context:t,specs:r}),n;for(let a of i){let u=new iba({logger:t.logger}),l;if(a.type==="openapi"){let s=new sba({namespace:a.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:a.value});l=await new uba({context:s}).convert({context:s,errorCollector:u})}else if(a.type==="asyncapi"){let s=new aba({namespace:a.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:a.value});l=await new nba({context:s}).convert({context:s,errorCollector:u})}else u.collect({message:`Unsupported document type: ${a}`,path:[]});u.hasErrors()&&(t.logger.info(`${a.type==="openapi"?"OpenAPI":"AsyncAPI"} Importer encountered errors:`),u.logErrors());let d=De_({generationLanguage:"typescript",keywords:void 0,smartCasing:!1});l!=null&&(n=n===void 0?l:jXs(n,l,d))}if(n===void 0)throw new Error("Failed to generate intermediate representation");return n}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new oDe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(y0)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,i=[];return t.reduce((n,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),n.push({type:a.type,id:Tie(),absoluteFilePath:u})),n},i)}};var Ee_={None:"none",Header:"header"};var CFo={};Eo(CFo,{ConjureAliasDeclaration:()=>yFo,ConjureArgument:()=>AFo,ConjureArgumentWithParamType:()=>MFo,ConjureAuthDefinition:()=>ZEn,ConjureAuthDefinitionType:()=>DFo,ConjureDefinitions:()=>wFo,ConjureEndpointDefinition:()=>qFo,ConjureEnumDeclaration:()=>PFo,ConjureEnumVariant:()=>mFo,ConjureEnumWithDocs:()=>OFo,ConjureObjectDeclaration:()=>gFo,ConjureParamType:()=>EFo,ConjurePrimitive:()=>hFo,ConjureService:()=>TFo,ConjureServiceName:()=>_Fo,ConjureType:()=>g_i,ConjureTypeDeclaration:()=>jFo,ConjureTypeReference:()=>O_i,ConjureTypeWithDocs:()=>vFo,ConjureTypes:()=>SFo,ConjureUnionDeclaration:()=>bFo,DefinitionFile:()=>tt_,WithDocs:()=>lZt,commons:()=>zXs,conjure:()=>RXs,services:()=>NXs,types:()=>FXs});var zXs={};Eo(zXs,{WithDocs:()=>lZt});var kd={};Eo(kd,{JsonError:()=>KEn,ParseError:()=>YEn,any:()=>Ve_,bigint:()=>Ae_,boolean:()=>We_,booleanLiteral:()=>Ue_,date:()=>qe_,discriminant:()=>Ze_,enum_:()=>fFo,getObjectLikeUtils:()=>h9t,getObjectUtils:()=>gFi,getSchemaUtils:()=>tq,isProperty:()=>b_i,lazy:()=>Te_,lazyObject:()=>Ne_,list:()=>pFo,number:()=>He_,object:()=>dFo,objectWithoutOptionalProperties:()=>Re_,optional:()=>CXs,property:()=>Be_,record:()=>Je_,set:()=>Ke_,string:()=>$e_,stringLiteral:()=>Le_,transform:()=>BXs,undiscriminatedUnion:()=>Xe_,union:()=>et_,unknown:()=>Ge_,withParsedProperties:()=>IXs});var ej={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 BM(e,t){return`Expected ${t}. Received ${fnE(e)}.`}function fnE(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 V5(e){return{...e,json:Me_(e.json),parse:Me_(e.parse)}}function Me_(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(`
1957
1957
  `)),{ok:!0,value:t}):i}}function lFo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var KEn=class e extends Error{errors;constructor(t){super(t.map(lFo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var YEn=class e extends Error{errors;constructor(t){super(t.map(lFo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function tq(e){return{optional:()=>CXs(e),transform:t=>BXs(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new YEn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new KEn(i.errors)}}}function CXs(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>ej.OPTIONAL};return{...t,...tq(t)}}function BXs(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...tq(r)}}function Ae_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:BM(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:BM(t,"bigint")}]},getType:()=>ej.BIGINT};return{...V5(e),...tq(e)}}var dnE=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function qe_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:BM(t,"string")}]}:dnE.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:BM(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:BM(t,"Date object")}]},getType:()=>ej.DATE};return{...V5(e),...tq(e)}}function $G(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...V5(r),...tq(r)}}}function fFo(e){let t=new Set(e);return $G(ej.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:BM(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:BM(i,"enum")}]}:{ok:!0,value:i})()}function Te_(e){let t=xXs(e);return{...t,...tq(t)}}function xXs(e){return{parse:(t,r)=>XEn(e).parse(t,r),json:(t,r)=>XEn(e).json(t,r),getType:()=>XEn(e).getType()}}function XEn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function cba(e){return Object.entries(e)}function lba(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function v_i(e){if(typeof e!="object"||e===null)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function fba(e){return Object.keys(e)}function Ce_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function h9t(e){return{withParsedProperties:t=>IXs(e,t)}}function IXs(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((l,[d,s])=>({...l,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!v_i(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:BM(i,"object")}]};let a=new Set(Object.keys(t)),u=lba(i,Object.keys(i).filter(l=>!a.has(l)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...tq(r),...h9t(r)}}function Be_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function b_i(e){return e.isProperty}function dFo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>b_i(i)?i.rawKey:r),_getParsedProperties:()=>fba(e),parse:(r,i)=>{let n={},a=[];for(let[u,l]of cba(e)){let d=b_i(l)?l.rawKey:u,s=b_i(l)?l.valueSchema:l,o={rawKey:d,parsedKey:u,valueSchema:s};n[d]=o,ze_(s)&&a.push(d)}return xe_({value:r,requiredKeys:a,getProperty:u=>{let l=n[u];if(l!=null)return{transformedKey:l.parsedKey,transform:d=>l.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of cba(e)){let l=b_i(u)?u.valueSchema:u;ze_(l)&&n.push(a)}return xe_({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return b_i(u)?{transformedKey:u.rawKey,transform:l=>u.valueSchema.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:l=>u.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>ej.OBJECT};return{...V5(t),...tq(t),...h9t(t),...gFi(t)}}function xe_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!v_i(e))return{ok:!1,errors:[{path:a,message:BM(e,"object")}]};let u=new Set(t),l=[],d={};for(let[s,o]of Object.entries(e)){let c=r(s);if(c!=null){u.delete(s);let b=c.transform(o);b.ok?d[c.transformedKey]=b.value:(d[s]=o,l.push(...b.errors))}else switch(i){case"fail":l.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=o;break}}return l.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),l.length===0||n?{ok:!0,value:d}:{ok:!1,errors:l}}function gFi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>Ie_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>Ie_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>ej.OBJECT};return{...r,...tq(r),...h9t(r),...gFi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>ej.OBJECT};return{...t,...tq(t),...h9t(t),...gFi(t)}}}}function Ie_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=Ce_(fba(t),s=>n.has(s)),l=r(lba(t,u)),d=i(lba(t,a));return l.ok&&d.ok?{ok:!0,value:{...l.value,...d.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...d.ok?[]:d.errors]}}function ze_(e){return!pnE(e)}function pnE(e){switch(e.getType()){case ej.ANY:case ej.UNKNOWN:case ej.OPTIONAL:return!0;default:return!1}}function Re_(e){return dFo(e)}function Ne_(e){let t={...xXs(e),_getRawProperties:()=>XEn(e)._getRawProperties(),_getParsedProperties:()=>XEn(e)._getParsedProperties()};return{...t,...tq(t),...h9t(t),...gFi(t)}}function pFo(e){let t={parse:(r,i)=>Fe_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Fe_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>ej.LIST};return{...V5(t),...tq(t)}}function Fe_(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:BM(e,"list"),path:[]}]}}function Le_(e){return $G(ej.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:BM(r,`"${e}"`)}]})()}function Ue_(e){return $G(ej.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:BM(r,`${e.toString()}`)}]})()}var Ve_=$G(ej.ANY,e=>({ok:!0,value:e}));var We_=$G(ej.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:BM(e,"boolean")}]});var He_=$G(ej.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:BM(e,"number")}]});var $e_=$G(ej.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:BM(e,"string")}]});var Ge_=$G(ej.UNKNOWN,e=>({ok:!0,value:e}));function Je_(e,t){let r={parse:(i,n)=>Qe_({value:i,isKeyNumeric:e.getType()===ej.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>Qe_({value:i,isKeyNumeric:e.getType()===ej.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>ej.RECORD};return{...V5(r),...tq(r)}}function Qe_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return v_i(e)?cba(e).reduce((a,[u,l])=>{if(l==null)return a;let d=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),c=i(l,s);if(d.ok&&o.ok&&c.ok)return{ok:!0,value:{...d.value,[o.value]:c.value}};let b=[];return d.ok||b.push(...d.errors),o.ok||b.push(...o.errors),c.ok||b.push(...c.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:BM(e,"object")}]}}function Ke_(e){let t=pFo(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:BM(i,"Set")}]},getType:()=>ej.SET};return{...V5(r),...tq(r)}}function Xe_(e){let t={parse:(r,i)=>Ye_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>Ye_((n,a)=>n.json(r,a),e,i),getType:()=>ej.UNDISCRIMINATED_UNION};return{...V5(t),...tq(t)}}function Ye_(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let l of u.errors)i.push({path:l.path,message:`[Variant ${n}] ${l.message}`})}return{ok:!1,errors:i}}function Ze_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function et_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=fFo(fba(t)),a={parse:(u,l)=>ke_({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),json:(u,l)=>ke_({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),getType:()=>ej.UNION};return{...V5(a),...tq(a),...h9t(a)}}function ke_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:l=[]}){if(!v_i(e))return{ok:!1,errors:[{path:l,message:BM(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:l,message:`Missing discriminant ("${t}")`}]};let o=i(d);if(!o.ok)return{ok:!1,errors:o.errors};let c=n(o.value);if(c==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...l,t],message:"Unexpected discriminant value"}]};let b=u(s,c);return b.ok?{ok:!0,value:{[r]:d,...b.value}}:b}var lZt=kd.objectWithoutOptionalProperties({docs:kd.string().optional()});var RXs={};Eo(RXs,{ConjureServiceName:()=>_Fo,DefinitionFile:()=>tt_});var _Fo=kd.string();var hFo=kd.enum_(["rid","string","safelong","integer","double","boolean"]);var g_i=kd.undiscriminatedUnion([hFo,kd.string()]);var yFo=kd.objectWithoutOptionalProperties({alias:g_i,docs:kd.string().optional()});var vFo=kd.objectWithoutOptionalProperties({type:g_i,docs:kd.string().optional()});var O_i=kd.undiscriminatedUnion([g_i,vFo]);var bFo=kd.objectWithoutOptionalProperties({union:kd.record(kd.string(),O_i)});var gFo=kd.objectWithoutOptionalProperties({fields:kd.record(kd.string(),O_i)});var OFo=kd.objectWithoutOptionalProperties({value:kd.string()}).extend(lZt);var mFo=kd.undiscriminatedUnion([kd.string(),OFo]);var PFo=kd.objectWithoutOptionalProperties({values:kd.list(mFo)});var jFo=kd.undiscriminatedUnion([yFo,bFo,gFo,PFo]);var wFo=kd.objectWithoutOptionalProperties({objects:kd.record(kd.string(),jFo).optional()});var SFo=kd.objectWithoutOptionalProperties({conjureImports:kd.property("conjure-imports",kd.record(kd.string(),kd.string()).optional()),definitions:wFo.optional()});var DFo=kd.enum_(["none","header"]);var ZEn=kd.undiscriminatedUnion([DFo,kd.string()]);var EFo=kd.enum_(["path","query","body"]);var MFo=kd.objectWithoutOptionalProperties({paramType:kd.property("param-type",EFo),type:kd.string()}).extend(lZt);var AFo=kd.undiscriminatedUnion([kd.string(),MFo]);var qFo=kd.objectWithoutOptionalProperties({http:kd.string(),auth:ZEn.optional(),args:kd.record(kd.string(),AFo).optional(),returns:O_i.optional()}).extend(lZt);var TFo=kd.objectWithoutOptionalProperties({name:kd.string().optional(),package:kd.string().optional(),basePath:kd.property("base-path",kd.string().optional()),defaultAuth:kd.property("default-auth",ZEn.optional()),endpoints:kd.record(kd.string(),qFo).optional()}).extend(lZt);var tt_=kd.objectWithoutOptionalProperties({types:SFo.optional(),services:kd.record(_Fo,TFo).optional()});var NXs={};Eo(NXs,{ConjureArgument:()=>AFo,ConjureArgumentWithParamType:()=>MFo,ConjureAuthDefinition:()=>ZEn,ConjureAuthDefinitionType:()=>DFo,ConjureEndpointDefinition:()=>qFo,ConjureParamType:()=>EFo,ConjureService:()=>TFo});var FXs={};Eo(FXs,{ConjureAliasDeclaration:()=>yFo,ConjureDefinitions:()=>wFo,ConjureEnumDeclaration:()=>PFo,ConjureEnumVariant:()=>mFo,ConjureEnumWithDocs:()=>OFo,ConjureObjectDeclaration:()=>gFo,ConjurePrimitive:()=>hFo,ConjureType:()=>g_i,ConjureTypeDeclaration:()=>jFo,ConjureTypeReference:()=>O_i,ConjureTypeWithDocs:()=>vFo,ConjureTypes:()=>SFo,ConjureUnionDeclaration:()=>bFo});var rt_=require("fs/promises");async function it_(e,t){let r=[];for(let i of await XBe(e,t))r.push(await _nE({relativeFilepath:HA(e,i),absoluteFilepath:i}));return r}async function _nE({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,rt_.readFile)(t)).toString().replaceAll(/: rid(?:$|\s)/g,`: string
1958
1958
  `).replaceAll("<rid>","<string>").replaceAll("rid>","string>").replaceAll(": safelong",": long").replaceAll("<safelong>","<long>").replaceAll("safelong>","long>").replaceAll(": any",": unknown").replaceAll("<any>","<unknown>").replaceAll("any>","unknown>");return{relativeFilepath:e,absoluteFilepath:t,fileContents:CFo.DefinitionFile.parseOrThrow(Kd.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}function nt_(e,t){if(hnE(e))return t.alias(e);if(ynE(e))return t.enum(e);if(vnE(e))return t.object(e);if(bnE(e))return t.union(e);Fo(e)}function hnE(e){return e?.alias!=null}function ynE(e){return e?.values!=null}function vnE(e){return e?.fields!=null}function bnE(e){return e?.union!=null}var dba=class extends pha{fernDefinitionBuilder=new dNi(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:i,globalHeaderOverrides:n}){if(r!=null){for(let[a,u]of Object.entries(r["auth-schemes"]??{}))this.fernDefinitionBuilder.addAuthScheme({name:a,schema:u});r.auth!=null&&this.fernDefinitionBuilder.setAuth(r.auth)}if(i!=null){for(let[a,u]of Object.entries(i.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:u});i["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(i["default-environment"]),i["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(i["default-url"])}return await at_(t,(a,u,l)=>{for(let[o,c]of Object.entries(l.services??{})){let b=YXa({value:o,suffix:"Service"});this.conjureFilepathToFernFilepath[u]=uo.of(`${b}/__package__.yml`);return}let s=Tbs(u)?.split(".")[0];s!=null&&(this.conjureFilepathToFernFilepath[u]=uo.of(`${s}/__package__.yml`))}),await at_(t,(a,u,l)=>{if(l.services==null||Object.keys(l.services??{}).length===0){let d=this.conjureFilepathToFernFilepath[u];if(d==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${u}`);for(let[s,o]of Object.entries(l.types?.conjureImports??{})){let c=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:uo.of(o)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:uo.of(c),alias:s})}this.importAllTypes({conjureFile:l,fernFilePath:d});return}for(let[d,s]of Object.entries(l.services)){let o=YXa({value:d,suffix:"Service"}),c=uo.of(`${o}/__package__.yml`),b={};s.basePath!=null&&(b["base-path"]=s.basePath),s.docs!=null&&(b.docs=s.docs),this.fernDefinitionBuilder.setServiceInfo(c,b),this.importAllTypes({conjureFile:l,fernFilePath:c});for(let[g,O]of Object.entries(l.types?.conjureImports??{})){let m=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:uo.of(O)});this.fernDefinitionBuilder.addImport({file:c,fileToImport:uo.of(m),alias:g})}for(let[g,O]of Object.entries(s.endpoints??{})){let m=L_s(O.http);if(m.type==="failure"){this.context?.logger.error(`Failed to parse ${O.http}. Skipping.`);continue}let E={auth:(O.auth??s.defaultAuth)!==Ee_.None,path:m.path,method:m.method,response:O.returns==="binary"?"file":O.returns};O.docs!=null&&(E.docs=O.docs);let A={};if(O.args!=null)for(let q of m.pathParameters){let D=O.args[q];if(D==null)throw new Error(`Failed to find path parameter ${q} in ${O.http}`);A[q]=typeof D=="string"?D:{type:D.type}}Object.entries(A).length>0&&(E["path-parameters"]=A);for(let[q,D]of Object.entries(O.args??{}))if(A[q]==null)if(typeof D=="string")E.request?typeof E.request=="string"&&(E.request={body:E.request}):E.request={},E.request.body=D==="binary"?"bytes":D;else switch(D.paramType){case"body":E.request={body:D.type==="binary"?"bytes":D.type};break;case"query":E.request==null?E.request={"query-parameters":{[q]:D.type}}:typeof E.request!="string"&&E.request?.["query-parameters"]==null?E.request["query-parameters"]={[q]:D.type}:typeof E.request!="string"&&E.request?.["query-parameters"]!=null&&(E.request["query-parameters"][q]=D.type)}E.request!=null&&typeof E.request!="string"&&E.request?.["query-parameters"]!=null&&(E.request.name=`${g}Request`),this.fernDefinitionBuilder.addEndpoint(c,{name:g,schema:E,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[i,n]of Object.entries(t.types?.definitions?.objects??{}))nt_(n,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{union:Object.fromEntries(Object.entries(a.union).map(([u,l])=>[u,{type:typeof l=="string"?l:l.type,docs:typeof l=="string"?void 0:l.docs,key:u}]))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:i}){let n=es(_p(t),uo.of(r)),a=usi(i,n),u=this.conjureFilepathToFernFilepath[a];if(u==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return u}};async function at_(e,t){for(let r of await it_(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}function ot_(e,t){return rd(e,t)}var BFo=class extends Y5t{absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=es(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new oDe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let n=await new dba(t).import({absolutePathToConjureFolder:this.absolutePathToConjureFolder,authOverrides:this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0,environmentOverrides:this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:Wl.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:n.rootApiFile["default-url"],contents:n.rootApiFile,rawContents:Kd.dump(n.rootApiFile)},namedDefinitionFiles:{...ot_(n.definitionFiles,a=>({absoluteFilepath:Wl.of("/DUMMY_PATH"),rawContents:Kd.dump(a),contents:a})),[uo.of(iS)]:{absoluteFilepath:Wl.of("/DUMMY_PATH"),rawContents:Kd.dump(n.packageMarkerFile),contents:n.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};function LXs(e,t){for(let[r,i]of $N(e.failures))gnE({relativeFilepath:r,failure:i,logger:t})}function gnE({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case uP.MISCONFIGURED_DIRECTORY:r.error("Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder");break;case uP.FILE_READ:r.error("Failed to open file: "+e);break;case uP.FILE_MISSING:r.error("Missing file: "+e);break;case uP.FILE_PARSE:t.error instanceof Vaa?r.error(Wie({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case uP.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of OnE(i))r.error(Wie({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case uP.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case uP.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${zZa}: `+t.dependencyName);break;case uP.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case uP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case uP.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(Wie({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));break;default:Fo(t)}}function OnE(e){switch(e.code){case Hl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Js.underline(e.expected)} but received ${Js.underline(e.received)}`}];case Hl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Js.underline(t)}`}));case Hl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Js.underline(t)).join(", ")}`}];case Hl.invalid_union:case Hl.invalid_arguments:case Hl.invalid_return_type:case Hl.invalid_date:case Hl.invalid_string:case Hl.too_small:case Hl.too_big:case Hl.invalid_intersection_types:case Hl.not_multiple_of:case Hl.custom:default:return[{title:e.message}]}}var ut_=require("fs/promises");async function st_(e,t){let r=[];for(let i of await XBe(e,t))r.push(await mnE({relativeFilepath:HA(e,i),absoluteFilepath:i}));return r}async function mnE({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,ut_.readFile)(t)).toString()}}async function ct_({absolutePathToWorkspace:e}){let t=es(e,uo.of(THf));if(!await Cf(t))return;let i=await st_(t,"{md,mdx}");return{files:await Promise.all(i.map(n=>({absoluteFilepath:n.absoluteFilepath,contents:n.fileContents})))}}async function UXs({absolutePathToWorkspace:e,namespace:t,definitions:r}){let i=[];for(let n of r){let a=n.overrides!=null?es(e,uo.of(n.overrides)):void 0;if(n.schema.type==="protobuf"){let l=uo.of(n.schema.root),d=es(e,l);if(!await Cf(d))return{didSucceed:!1,failures:{[uo.of(n.schema.root)]:{type:uP.FILE_MISSING}}};let s=es(e,uo.of(n.schema.target));if(!await Cf(s))return{didSucceed:!1,failures:{[uo.of(n.schema.target)]:{type:uP.FILE_MISSING}}};i.push({type:"protobuf",absoluteFilepathToProtobufRoot:d,absoluteFilepathToProtobufTarget:s,absoluteFilepathToOverrides:a,relativeFilepathToProtobufRoot:l,generateLocally:n.schema.localGeneration,settings:{audiences:n.audiences??[],useTitlesAsName:n.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,shouldUseIdiomaticRequestNames:n.settings?.shouldUseIdiomaticRequestNames??!1,optionalAdditionalProperties:n.settings?.shouldUseOptionalAdditionalProperties??!0,coerceEnumsToLiterals:n.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:n.settings?.objectQueryParameters??!1,respectReadonlySchemas:n.settings?.respectReadonlySchemas??!1,respectNullableSchemas:n.settings?.respectNullableSchemas??!1,onlyIncludeReferencedSchemas:n.settings?.onlyIncludeReferencedSchemas??!1,inlinePathParameters:n.settings?.inlinePathParameters??!1,disableExamples:!1,discriminatedUnionV2:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,preserveSchemaIds:!1,asyncApiNaming:n.settings?.asyncApiMessageNaming??"v1",filter:n.settings?.filter,exampleGeneration:void 0,defaultFormParameterEncoding:n.settings?.defaultFormParameterEncoding,useBytesForBinaryResponse:n.settings?.useBytesForBinaryResponse??!1}});continue}let u=es(e,uo.of(n.schema.path));if(!await Cf(u))return{didSucceed:!1,failures:{[uo.of(n.schema.path)]:{type:uP.FILE_MISSING}}};if(n.overrides!=null&&a!=null&&!await Cf(a))return{didSucceed:!1,failures:{[uo.of(n.overrides)]:{type:uP.FILE_MISSING}}};i.push({type:"openapi",absoluteFilepath:u,absoluteFilepathToOverrides:a,settings:{audiences:n.audiences??[],useTitlesAsName:n.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,shouldUseIdiomaticRequestNames:n.settings?.shouldUseIdiomaticRequestNames??!1,optionalAdditionalProperties:n.settings?.shouldUseOptionalAdditionalProperties??!0,coerceEnumsToLiterals:n.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:n.settings?.objectQueryParameters??!1,respectReadonlySchemas:n.settings?.respectReadonlySchemas??!1,respectNullableSchemas:n.settings?.respectNullableSchemas??!1,onlyIncludeReferencedSchemas:n.settings?.onlyIncludeReferencedSchemas??!1,inlinePathParameters:n.settings?.inlinePathParameters??!1,disableExamples:!1,discriminatedUnionV2:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,preserveSchemaIds:!1,asyncApiNaming:n.settings?.asyncApiMessageNaming??"v1",filter:n.settings?.filter,exampleGeneration:n.settings?.exampleGeneration,defaultFormParameterEncoding:n.settings?.defaultFormParameterEncoding,useBytesForBinaryResponse:n.settings?.useBytesForBinaryResponse??!1},source:{type:"openapi",file:u},namespace:t})}return i}async function pba({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:i}){let n=await L8t({absolutePathToWorkspace:e,context:t}),a;try{a=await ct_({absolutePathToWorkspace:e})}catch{}if(n?.api!=null&&n?.api.type==="conjure")return{didSucceed:!0,workspace:new BFo({workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r,context:t,relativePathToConjureDirectory:uo.of(n.api.pathToConjureDefinition)})};if(n?.api!=null&&(n.api.type==="singleNamespace"&&n.api.definitions.length>0||n.api.type==="multiNamespace")){let u=[];if(n.api.type==="singleNamespace"){let l=await UXs({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.definitions});if(!Array.isArray(l))return l;u.push(...l)}else{for(let[l,d]of Object.entries(n.api.definitions)){let s=await UXs({absolutePathToWorkspace:e,namespace:l,definitions:d});if(!Array.isArray(s))return s;u.push(...s)}if(n.api.rootDefinitions!=null){let l=await UXs({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.rootDefinitions});if(!Array.isArray(l))return l;u.push(...l)}}return{didSucceed:!0,workspace:new $7({specs:u,workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r})}}return await Cf(es(e,uo.of(X8)))?{didSucceed:!0,workspace:new p_i({absoluteFilePath:e,generatorsConfiguration:n,workspaceName:i,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:pba})}:{didSucceed:!1,failures:{[uo.of(IZa)]:{type:uP.MISCONFIGURED_DIRECTORY}}}}var lt_=require("fs/promises");var VXs={};Eo(VXs,{additionalProperties:()=>SnE,default:()=>EnE,definitions:()=>DnE,properties:()=>jnE,required:()=>wnE,type:()=>PnE});var PnE="object",jnE={instances:{type:"array",items:{$ref:"#/definitions/docs.DocsInstance"}},title:{oneOf:[{type:"string"},{type:"null"}]},analytics:{oneOf:[{$ref:"#/definitions/docs.AnalyticsConfig"},{type:"null"}]},announcement:{oneOf:[{$ref:"#/definitions/docs.AnnouncementConfig"},{type:"null"}]},roles:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.RoleId"}},{type:"null"}]},tabs:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/docs.TabConfig"}},{type:"null"}]},versions:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.VersionConfig"}},{type:"null"}]},"landing-page":{oneOf:[{$ref:"#/definitions/docs.PageConfiguration"},{type:"null"}]},navigation:{oneOf:[{$ref:"#/definitions/docs.NavigationConfig"},{type:"null"}]},"navbar-links":{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.NavbarLink"}},{type:"null"}]},"footer-links":{oneOf:[{$ref:"#/definitions/docs.FooterLinksConfig"},{type:"null"}]},experimental:{oneOf:[{$ref:"#/definitions/docs.ExperimentalConfig"},{type:"null"}]},"default-language":{oneOf:[{$ref:"#/definitions/docs.ProgrammingLanguage"},{type:"null"}]},"ai-chat":{oneOf:[{$ref:"#/definitions/docs.AIChatConfig"},{type:"null"}]},metadata:{oneOf:[{$ref:"#/definitions/docs.MetadataConfig"},{type:"null"}]},redirects:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.RedirectConfig"}},{type:"null"}]},logo:{oneOf:[{$ref:"#/definitions/docs.LogoConfiguration"},{type:"null"}]},favicon:{oneOf:[{type:"string"},{type:"null"}]},"background-image":{oneOf:[{$ref:"#/definitions/docs.BackgroundImageConfiguration"},{type:"null"}]},colors:{oneOf:[{$ref:"#/definitions/docs.ColorsConfiguration"},{type:"null"}]},typography:{oneOf:[{$ref:"#/definitions/docs.DocsTypographyConfig"},{type:"null"}]},layout:{oneOf:[{$ref:"#/definitions/docs.LayoutConfig"},{type:"null"}]},integrations:{oneOf:[{$ref:"#/definitions/docs.IntegrationsConfig"},{type:"null"}]},css:{oneOf:[{$ref:"#/definitions/docs.CssConfig"},{type:"null"}]},js:{oneOf:[{$ref:"#/definitions/docs.JsConfig"},{type:"null"}]}},wnE=["instances"],SnE=!1,DnE={"docs.CustomDomain":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"docs.GithubEditThisPageConfig":{type:"object",properties:{host:{oneOf:[{type:"string"},{type:"null"}]},owner:{type:"string"},repo:{type:"string"},branch:{oneOf:[{type:"string"},{type:"null"}]}},required:["owner","repo"],additionalProperties:!1},"docs.EditThisPageConfig":{type:"object",properties:{github:{oneOf:[{$ref:"#/definitions/docs.GithubEditThisPageConfig"},{type:"null"}]}},additionalProperties:!1},"docs.DocsInstance":{type:"object",properties:{url:{type:"string"},"custom-domain":{oneOf:[{$ref:"#/definitions/docs.CustomDomain"},{type:"null"}]},private:{oneOf:[{type:"boolean"},{type:"null"}]},"edit-this-page":{oneOf:[{$ref:"#/definitions/docs.EditThisPageConfig"},{type:"null"}]}},required:["url"],additionalProperties:!1},"docs.SegmentConfig":{type:"object",properties:{"write-key":{type:"string"}},required:["write-key"],additionalProperties:!1},"docs.FullStoryAnalyticsConfig":{type:"object",properties:{"org-id":{type:"string"}},required:["org-id"],additionalProperties:!1},"docs.IntercomConfig":{type:"object",properties:{"app-id":{type:"string"},"api-base":{oneOf:[{type:"string"},{type:"null"}]}},required:["app-id"],additionalProperties:!1},"docs.PostHogConfig":{type:"object",properties:{"api-key":{type:"string"},endpoint:{oneOf:[{type:"string"},{type:"null"}]}},required:["api-key"],additionalProperties:!1},"docs.GTMConfig":{type:"object",properties:{"container-id":{type:"string"}},required:["container-id"],additionalProperties:!1},"docs.GoogleAnalytics4Config":{type:"object",properties:{"measurement-id":{type:"string"}},required:["measurement-id"],additionalProperties:!1},"docs.AnalyticsConfig":{type:"object",properties:{segment:{oneOf:[{$ref:"#/definitions/docs.SegmentConfig"},{type:"null"}]},fullstory:{oneOf:[{$ref:"#/definitions/docs.FullStoryAnalyticsConfig"},{type:"null"}]},intercom:{oneOf:[{$ref:"#/definitions/docs.IntercomConfig"},{type:"null"}]},posthog:{oneOf:[{$ref:"#/definitions/docs.PostHogConfig"},{type:"null"}]},gtm:{oneOf:[{$ref:"#/definitions/docs.GTMConfig"},{type:"null"}]},ga4:{oneOf:[{$ref:"#/definitions/docs.GoogleAnalytics4Config"},{type:"null"}]}},additionalProperties:!1},"docs.AnnouncementConfig":{type:"object",properties:{message:{type:"string"}},required:["message"],additionalProperties:!1},"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.VersionAvailability":{type:"string",enum:["deprecated","ga","stable","beta"]},"docs.VersionConfig":{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"},path:{type:"string"},slug:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.VersionAvailability"},{type:"null"}]}},required:["display-name","path"],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"}]},"docs.NavbarGithubConfig":{type:"string"},"docs.NavbarLink":{type:"object",properties:{type:{type:"string",enum:["filled","outlined","minimal","github","primary","secondary"]}},required:["type"],oneOf:[{properties:{type:{const:"filled"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]},{properties:{type:{const:"outlined"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]},{properties:{type:{const:"minimal"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]},{properties:{type:{const:"github"},value:{$ref:"#/definitions/docs.NavbarGithubConfig"}},required:["type"]},{properties:{type:{const:"primary"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]},{properties:{type:{const:"secondary"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]}]},"docs.FooterLinksConfig":{type:"object",properties:{github:{oneOf:[{type:"string"},{type:"null"}]},twitter:{oneOf:[{type:"string"},{type:"null"}]},x:{oneOf:[{type:"string"},{type:"null"}]},linkedin:{oneOf:[{type:"string"},{type:"null"}]},youtube:{oneOf:[{type:"string"},{type:"null"}]},instagram:{oneOf:[{type:"string"},{type:"null"}]},facebook:{oneOf:[{type:"string"},{type:"null"}]},discord:{oneOf:[{type:"string"},{type:"null"}]},slack:{oneOf:[{type:"string"},{type:"null"}]},hackernews:{oneOf:[{type:"string"},{type:"null"}]},medium:{oneOf:[{type:"string"},{type:"null"}]},website:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.ExperimentalConfig":{type:"object",properties:{"mdx-components":{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"disable-stream-toggle":{oneOf:[{type:"boolean"},{type:"null"}]},"openapi-parser-v2":{oneOf:[{type:"boolean"},{type:"null"}]},"openapi-parser-v3":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"docs.ProgrammingLanguage":{type:"string",enum:["typescript","javascript","python","java","go","ruby","csharp","nodets","nodejs","dotnet","curl","jvm","ts","js"]},"docs.AIChatModel":{type:"string",enum:["claude-3.5","claude-3.7","command-r-plus"]},"docs.AIChatConfig":{type:"object",properties:{model:{oneOf:[{$ref:"#/definitions/docs.AIChatModel"},{type:"null"}]},"system-prompt":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.TwitterCardSetting":{type:"string",enum:["summary","summary_large_image","app","player"]},"docs.MetadataConfig":{type:"object",properties:{"og:site_name":{oneOf:[{type:"string"},{type:"null"}]},"og:title":{oneOf:[{type:"string"},{type:"null"}]},"og:description":{oneOf:[{type:"string"},{type:"null"}]},"og:url":{oneOf:[{type:"string"},{type:"null"}]},"og:image":{oneOf:[{type:"string"},{type:"null"}]},"og:image:width":{oneOf:[{type:"number"},{type:"null"}]},"og:image:height":{oneOf:[{type:"number"},{type:"null"}]},"og:locale":{oneOf:[{type:"string"},{type:"null"}]},"og:logo":{oneOf:[{type:"string"},{type:"null"}]},"twitter:title":{oneOf:[{type:"string"},{type:"null"}]},"twitter:description":{oneOf:[{type:"string"},{type:"null"}]},"twitter:handle":{oneOf:[{type:"string"},{type:"null"}]},"twitter:image":{oneOf:[{type:"string"},{type:"null"}]},"twitter:site":{oneOf:[{type:"string"},{type:"null"}]},"twitter:url":{oneOf:[{type:"string"},{type:"null"}]},"twitter:card":{oneOf:[{$ref:"#/definitions/docs.TwitterCardSetting"},{type:"null"}]}},additionalProperties:!1},"docs.RedirectConfig":{type:"object",properties:{source:{type:"string"},destination:{type:"string"},permanent:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["source","destination"],additionalProperties:!1},"docs.LogoConfiguration":{type:"object",properties:{dark:{oneOf:[{type:"string"},{type:"null"}]},light:{oneOf:[{type:"string"},{type:"null"}]},height:{oneOf:[{type:"number"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.BackgroundImageThemedConfig":{type:"object",properties:{dark:{oneOf:[{type:"string"},{type:"null"}]},light:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.BackgroundImageConfiguration":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.BackgroundImageThemedConfig"}]},"docs.ColorThemedConfig":{type:"object",properties:{dark:{oneOf:[{type:"string"},{type:"null"}]},light:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.ColorConfig":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.ColorThemedConfig"}]},"docs.ColorsConfiguration":{type:"object",properties:{"accent-primary":{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},accentPrimary:{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},background:{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},border:{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},"sidebar-background":{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},"header-background":{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},"card-background":{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]}},additionalProperties:!1},"docs.FontWeight":{anyOf:[{type:"string"},{type:"integer"}]},"docs.FontStyle":{type:"string",enum:["normal","italic"]},"docs.FontConfigVariant":{type:"object",properties:{path:{type:"string"},weight:{oneOf:[{$ref:"#/definitions/docs.FontWeight"},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/docs.FontStyle"},{type:"null"}]}},required:["path"],additionalProperties:!1},"docs.FontConfigPath":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.FontConfigVariant"}]},"docs.FontDisplay":{type:"string",enum:["auto","block","swap","fallback","optional"]},"docs.FontConfig":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},path:{oneOf:[{type:"string"},{type:"null"}]},weight:{oneOf:[{$ref:"#/definitions/docs.FontWeight"},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/docs.FontStyle"},{type:"null"}]},paths:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.FontConfigPath"}},{type:"null"}]},display:{oneOf:[{$ref:"#/definitions/docs.FontDisplay"},{type:"null"}]},fallback:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"font-variation-settings":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.DocsTypographyConfig":{type:"object",properties:{headingsFont:{oneOf:[{$ref:"#/definitions/docs.FontConfig"},{type:"null"}]},bodyFont:{oneOf:[{$ref:"#/definitions/docs.FontConfig"},{type:"null"}]},codeFont:{oneOf:[{$ref:"#/definitions/docs.FontConfig"},{type:"null"}]}},additionalProperties:!1},"docs.SearchbarPlacement":{type:"string",enum:["header","header-tabs","sidebar"]},"docs.TabsPlacement":{type:"string",enum:["header","sidebar"]},"docs.ContentAlignment":{type:"string",enum:["center","left"]},"docs.HeaderPosition":{type:"string",enum:["fixed","static"]},"docs.LayoutConfig":{type:"object",properties:{"page-width":{oneOf:[{type:"string"},{type:"null"}]},"content-width":{oneOf:[{type:"string"},{type:"null"}]},"sidebar-width":{oneOf:[{type:"string"},{type:"null"}]},"header-height":{oneOf:[{type:"string"},{type:"null"}]},"searchbar-placement":{oneOf:[{$ref:"#/definitions/docs.SearchbarPlacement"},{type:"null"}]},"tabs-placement":{oneOf:[{$ref:"#/definitions/docs.TabsPlacement"},{type:"null"}]},"content-alignment":{oneOf:[{$ref:"#/definitions/docs.ContentAlignment"},{type:"null"}]},"header-position":{oneOf:[{$ref:"#/definitions/docs.HeaderPosition"},{type:"null"}]},"disable-header":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"docs.IntegrationsConfig":{type:"object",properties:{intercom:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.CssConfig":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"docs.JsScriptStrategy":{type:"string",enum:["beforeInteractive","afterInteractive","lazyOnload"]},"docs.JsRemoteConfig":{type:"object",properties:{url:{type:"string"},strategy:{oneOf:[{$ref:"#/definitions/docs.JsScriptStrategy"},{type:"null"}]}},required:["url"],additionalProperties:!1},"docs.JsFileConfigSettings":{type:"object",properties:{path:{type:"string"},strategy:{oneOf:[{$ref:"#/definitions/docs.JsScriptStrategy"},{type:"null"}]}},required:["path"],additionalProperties:!1},"docs.JsFileConfig":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.JsFileConfigSettings"}]},"docs.JsConfigOptions":{anyOf:[{$ref:"#/definitions/docs.JsRemoteConfig"},{$ref:"#/definitions/docs.JsFileConfig"}]},"docs.JsConfig":{anyOf:[{$ref:"#/definitions/docs.JsConfigOptions"},{type:"array",items:{$ref:"#/definitions/docs.JsConfigOptions"}}]}},EnE={type:PnE,properties:jnE,required:wnE,additionalProperties:SnE,definitions:DnE};async function WXs({fernDirectory:e,context:t}){let r=es(e,uo.of(Y4t));if(!await Cf(r))return;let i=await MnE({absolutePathToDocsDefinition:e,context:t});if(i!=null)return{type:"docs",absoluteFilePath:e,config:i,workspaceName:void 0,absoluteFilepathToDocsConfig:es(e,uo.of(Y4t))}}async function MnE({absolutePathToDocsDefinition:e,context:t}){if(!await Cf(e))return;let r=es(e,uo.of(Y4t));return await AnE({absolutePathOfConfiguration:r,context:t})}async function AnE({absolutePathOfConfiguration:e,context:t}){let r=await(0,lt_.readFile)(e),i=Kd.load(r.toString()),n=nQr(i,VXs);if(n.success)return k4t.RawSchemas.Serializer.DocsConfiguration.parseOrThrow(i);throw new Error(`Failed to parse docs.yml because of ${n.error?.message??"Unknown error"}`)}async function HXs({context:e,nameOverride:t,...r}){let i=await u8t(t);return i==null?e.failAndThrow(`Directory "${t??qU}" not found.`):await dt_({absolutePathToFernDirectory:i,context:e,nameOverride:t,...r})}async function dt_({absolutePathToFernDirectory:e,cliName:t,cliVersion:r,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:n,context:a}){let u=[];return(await Cf(es(e,uo.of(Fui)))||await Cf(es(e,uo.of(X8)))||await Cf(es(e,uo.of(JN)))||await Cf(es(e,uo.of(IZa)))||await Cf(es(e,uo.of(CHf))))&&(u=await pt_({cliName:t,fernDirectory:e,cliVersion:r,context:a,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:n})),{config:await qQr({directory:e,context:a}),apiWorkspaces:u,docsWorkspaces:await WXs({fernDirectory:e,context:a}),loadAPIWorkspace:l=>l==null?u[0]:u.find(d=>d.workspaceName===l)}}async function pt_({cliName:e,fernDirectory:t,context:r,cliVersion:i,commandLineApiWorkspace:n,defaultToAllApiWorkspaces:a}){let u=es(t,uo.of(Fui));if(await Cf(u)){let o=(await(0,ft_.readdir)(u,{withFileTypes:!0})).reduce((g,O)=>(O.isDirectory()&&g.push(O.name),g),[]);if(n!=null){if(!o.includes(n))return r.failAndThrow("API does not exist: "+n)}else{if(o.length===0)return r.failAndThrow("No APIs found.");if(o.length>1&&!a){let g=`There are multiple workspaces. You must specify one with --api:
1959
1959
  `,O=Math.max(...o.map(m=>m.length));return g+=o.map(m=>{let P=`${e} ${process.argv.slice(2).join(" ")} --api ${m}`;return` \u203A ${Js.bold(m.padEnd(O))} ${Js.dim(P)}`}).join(`