fern-api 0.42.5 → 0.42.6
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.
- package/bundle.cjs +3 -3
- package/package.json +1 -1
package/bundle.cjs
CHANGED
|
@@ -1784,7 +1784,7 @@ ${l.indent}`:""}${i4c(o)}:${f.indent?" ":""}`;return u=!1,c=!0,f.objectItem=void
|
|
|
1784
1784
|
`}),r.replaceAll(/\n$/g,"")}function UZP(e){return e?cl.green(n8r.radioOn):n8r.radioOff}var Opa=yu(Bje(),1);function rQl(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var Hdi=class extends dR{_run(t){this.done=t;let r=cW(this.rl),n=r.line.pipe((0,Opa.map)(this.filterInput.bind(this))),i=this.handleSubmitEvents(n);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,Opa.takeUntil)(i.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),n="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(n=`
|
|
1785
1785
|
`+cl.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?cl.cyan(rQl(t,this.opt.mask)):cl.italic.dim("[hidden]"):this.opt.mask?rQl(t,this.opt.mask):cl.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(){var t;(t=this.opt).default&&(t.default=void 0),this.render()}};var MZl=yu(EZl(),1),xZl=yu(Bje(),1);var epi=class extends dR{_run(t){this.done=t,this.editorResult=new xZl.Subject;let r=cW(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let n=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,i=this.handleSubmitEvents(this.editorResult);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,n?this.render():this.startExternalEditor(),this}render(t){let r="",n=this.getQuestion();n+=this.status==="answered"?cl.dim("Received"):cl.dim("Press <enter> to launch your preferred editor."),t&&(r=cl.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),(0,MZl.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 IZl=yu(CZl(),1);var zZl=yu(require("readline"),1),BZl=yu(NZl(),1),Hkr=class{constructor(t){this.rl||(this.rl=zZl.default.createInterface(qkP(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 qkP(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let i=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw i.isTtyError=!0,i}let r=new BZl.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var tpi=class extends Hkr{constructor(t={}){super(t),this.log=(0,IZl.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return Bdi(this.rl,this.bottomBar.split(`
|
|
1786
1786
|
`).length),this}updateBottomBar(t){return Bdi(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+`
|
|
1787
|
-
`}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&&vpa(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var GZl=yu(LZl(),1),KZl=yu(anu(),1),YZl=yu($Zl(),1),iq=yu(Bje(),1),XZl=yu(Hfi(),1);var Wpa=yu(Bje(),1),JZl=yu(Hfi(),1),Hpa=function(e,t,r){return typeof e[t]!="function"?(0,Wpa.of)(e):(0,Wpa.from)((0,JZl.default)(e[t])(r).then(n=>(e[t]=n,e)))};var rpi={isPlainObject:GZl.default,set:YZl.default,get:KZl.default},KAn=class extends Hkr{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=rpi.isPlainObject(r)?{...r}:{},rpi.isPlainObject(t)&&(t=Object.values(t).every(i=>rpi.isPlainObject(i)&&i.name===void 0)?Object.entries(t).map(([i,a])=>({name:i,...a})):[t]);let n=Array.isArray(t)?(0,iq.from)(t):t;return this.process=n.pipe((0,iq.concatMap)(this.processQuestion.bind(this)),(0,iq.publish)()),this.process.connect(),this.process.pipe((0,iq.reduce)((i,a)=>(rpi.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,iq.defer)(()=>(0,iq.of)(t).pipe((0,iq.concatMap)(this.setDefaultType.bind(this)),(0,iq.concatMap)(this.filterIfRunnable.bind(this)),(0,iq.concatMap)(()=>Hpa(t,"message",this.answers)),(0,iq.concatMap)(()=>Hpa(t,"default",this.answers)),(0,iq.concatMap)(()=>Hpa(t,"choices",this.answers)),(0,iq.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,iq.defer)(()=>(0,iq.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,iq.defer)(()=>(0,iq.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&rpi.get(this.answers,t.name)!==void 0)return(0,iq.empty)();if(t.when===!1)return(0,iq.empty)();if(typeof t.when!="function")return(0,iq.of)(t);let{answers:r}=this;return(0,iq.defer)(()=>(0,iq.from)((0,XZl.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,iq.filter)(n=>n!=null)))}};function QZl(e){let t=function(r,n){let i;try{i=new KAn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",Rdi),this.registerPrompt("input",Ikr),this.registerPrompt("number",Fdi),this.registerPrompt("confirm",Ldi),this.registerPrompt("rawlist",Udi),this.registerPrompt("expand",Vdi),this.registerPrompt("checkbox",Wdi),this.registerPrompt("password",Hdi),this.registerPrompt("editor",epi)},t.restoreDefaultPrompts(),t}var Ziu=QZl();function YkP(e,t){Ziu.registerPrompt(e,t)}function XkP(){Ziu.restoreDefaultPrompts()}var QkP={prompt:Ziu,ui:{BottomBar:tpi,Prompt:KAn},createPromptModule:QZl,registerPrompt:YkP,restoreDefaultPrompts:XkP,Separator:gne},$pa=QkP;var pkl=yu(iau(),1),Gpa=class{posthog;constructor({posthogApiKey:t}){this.posthog=new pkl.PostHog(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.42.
|
|
1787
|
+
`}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&&vpa(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var GZl=yu(LZl(),1),KZl=yu(anu(),1),YZl=yu($Zl(),1),iq=yu(Bje(),1),XZl=yu(Hfi(),1);var Wpa=yu(Bje(),1),JZl=yu(Hfi(),1),Hpa=function(e,t,r){return typeof e[t]!="function"?(0,Wpa.of)(e):(0,Wpa.from)((0,JZl.default)(e[t])(r).then(n=>(e[t]=n,e)))};var rpi={isPlainObject:GZl.default,set:YZl.default,get:KZl.default},KAn=class extends Hkr{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=rpi.isPlainObject(r)?{...r}:{},rpi.isPlainObject(t)&&(t=Object.values(t).every(i=>rpi.isPlainObject(i)&&i.name===void 0)?Object.entries(t).map(([i,a])=>({name:i,...a})):[t]);let n=Array.isArray(t)?(0,iq.from)(t):t;return this.process=n.pipe((0,iq.concatMap)(this.processQuestion.bind(this)),(0,iq.publish)()),this.process.connect(),this.process.pipe((0,iq.reduce)((i,a)=>(rpi.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,iq.defer)(()=>(0,iq.of)(t).pipe((0,iq.concatMap)(this.setDefaultType.bind(this)),(0,iq.concatMap)(this.filterIfRunnable.bind(this)),(0,iq.concatMap)(()=>Hpa(t,"message",this.answers)),(0,iq.concatMap)(()=>Hpa(t,"default",this.answers)),(0,iq.concatMap)(()=>Hpa(t,"choices",this.answers)),(0,iq.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,iq.defer)(()=>(0,iq.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,iq.defer)(()=>(0,iq.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&rpi.get(this.answers,t.name)!==void 0)return(0,iq.empty)();if(t.when===!1)return(0,iq.empty)();if(typeof t.when!="function")return(0,iq.of)(t);let{answers:r}=this;return(0,iq.defer)(()=>(0,iq.from)((0,XZl.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,iq.filter)(n=>n!=null)))}};function QZl(e){let t=function(r,n){let i;try{i=new KAn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",Rdi),this.registerPrompt("input",Ikr),this.registerPrompt("number",Fdi),this.registerPrompt("confirm",Ldi),this.registerPrompt("rawlist",Udi),this.registerPrompt("expand",Vdi),this.registerPrompt("checkbox",Wdi),this.registerPrompt("password",Hdi),this.registerPrompt("editor",epi)},t.restoreDefaultPrompts(),t}var Ziu=QZl();function YkP(e,t){Ziu.registerPrompt(e,t)}function XkP(){Ziu.restoreDefaultPrompts()}var QkP={prompt:Ziu,ui:{BottomBar:tpi,Prompt:KAn},createPromptModule:QZl,registerPrompt:YkP,restoreDefaultPrompts:XkP,Separator:gne},$pa=QkP;var pkl=yu(iau(),1),Gpa=class{posthog;constructor({posthogApiKey:t}){this.posthog=new pkl.PostHog(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.42.6",usingAccessToken:!0}})}flush(){this.posthog.flush()}};var opi=class{async sendEvent(){}async identify(){}async flush(){}};var XAn=require("fs/promises"),Akl=require("os"),Nkl=require("path"),zkl=yu(iau(),1);var hRt=yu(Ckl(),1),mU7=hRt.default.v1,OU7=hRt.default.v3,Jkr=hRt.default.v4,PU7=hRt.default.v5,jU7=hRt.default.NIL,wU7=hRt.default.version,DU7=hRt.default.validate,SU7=hRt.default.stringify,EU7=hRt.default.parse;var St1="id",Et1=".fern",lpi=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new zkl.PostHog(r),this.userId=t==null?void 0:yZo(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.42.6",...t,...t.properties}})}flush(){this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=pf(I_.of((0,Akl.homedir)()),zs.of(Et1),zs.of(St1));await Vh(t)||(await(0,XAn.mkdir)((0,Nkl.dirname)(t),{recursive:!0}),await(0,XAn.writeFile)(t,Jkr())),this.persistedDistinctId=(await(0,XAn.readFile)(t)).toString()}return this.persistedDistinctId}};var dau;async function QAn(){return dau==null&&(dau=await Mt1()),dau}async function Mt1(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new opi;let r=await Oua();return r!=null?new lpi({token:r,posthogApiKey:e}):await mua()!=null?new Gpa({posthogApiKey:e}):new lpi({token:void 0,posthogApiKey:e})}catch{return new opi}}var uou=yu(vRt(),1);var ppi=yu(require("process"),1);var xtf=yu(Iau(),1),Ttf=yu(Mtf(),1);function N9(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Kqt(e),e.length===0))return 0;e=e.replace((0,Ttf.default)()," ");let r=t.ambiguousIsNarrow?1:2,n=0;for(let i of e){let a=i.codePointAt(0);if(a<=31||a>=127&&a<=159||a>=768&&a<=879)continue;switch(xtf.default.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=r;break;default:n+=1}}return n}function m_a(e){let t=0;for(let r of e.split(`
|
|
1788
1788
|
`))t=Math.max(t,N9(r));return t}var Xtf=yu(Fau(),1);var wn1=/[\p{Lu}]/u,Dn1=/[\p{Ll}]/u,Atf=/^[\p{Lu}](?![\p{Lu}])/gu,Btf=/([\p{Alpha}\p{N}_]|$)/u,Lau=/[_.\- ]+/,Sn1=new RegExp("^"+Lau.source),Ntf=new RegExp(Lau.source+Btf.source,"gu"),ztf=new RegExp("\\d+"+Btf.source,"gu"),En1=(e,t,r,n)=>{let i=!1,a=!1,u=!1,f=!1;for(let d=0;d<e.length;d++){let c=e[d];f=d>2?e[d-3]==="-":!0,i&&wn1.test(c)?(e=e.slice(0,d)+"-"+e.slice(d),i=!1,u=a,a=!0,d++):a&&u&&Dn1.test(c)&&(!f||n)?(e=e.slice(0,d-1)+"-"+e.slice(d-1),u=a,a=!1,i=!0):(i=t(c)===c&&r(c)!==c,u=a,a=r(c)===c&&t(c)!==c)}return e},Mn1=(e,t)=>(Atf.lastIndex=0,e.replace(Atf,r=>t(r))),xn1=(e,t)=>(Ntf.lastIndex=0,ztf.lastIndex=0,e.replace(Ntf,(r,n)=>t(n)).replace(ztf,r=>t(r)));function Uau(e,t){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(e)?e=e.map(a=>a.trim()).filter(a=>a.length).join("-"):e=e.trim(),e.length===0)return"";let r=t.locale===!1?a=>a.toLowerCase():a=>a.toLocaleLowerCase(t.locale),n=t.locale===!1?a=>a.toUpperCase():a=>a.toLocaleUpperCase(t.locale);return e.length===1?Lau.test(e)?"":t.pascalCase?n(e):r(e):(e!==r(e)&&(e=En1(e,r,n,t.preserveConsecutiveUppercase)),e=e.replace(Sn1,""),e=t.preserveConsecutiveUppercase?Mn1(e,r):r(e),t.pascalCase&&(e=n(e.charAt(0))+e.slice(1)),xn1(e,n))}var $au=yu(Rtf(),1);var Ftf=(e=0)=>t=>`\x1B[${t+e}m`,Ltf=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Utf=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function An1(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[r,n]of Object.entries(t)){for(let[i,a]of Object.entries(n))t[i]={open:`\x1B[${a[0]}m`,close:`\x1B[${a[1]}m`},n[i]=t[i],e.set(a[0],a[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=Ftf(),t.color.ansi256=Ltf(),t.color.ansi16m=Utf(),t.bgColor.ansi=Ftf(10),t.bgColor.ansi256=Ltf(10),t.bgColor.ansi16m=Utf(10),Object.defineProperties(t,{rgbToAnsi256:{value:(r,n,i)=>r===n&&n===i?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5),enumerable:!1},hexToRgb:{value:r=>{let n=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!n)return[0,0,0];let{colorString:i}=n.groups;i.length===3&&(i=i.split("").map(u=>u+u).join(""));let a=Number.parseInt(i,16);return[a>>16&255,a>>8&255,a&255]},enumerable:!1},hexToAnsi256:{value:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let n,i,a;if(r>=232)n=((r-232)*10+8)/255,i=n,a=n;else{r-=16;let d=r%36;n=Math.floor(r/36)/5,i=Math.floor(d/6)/5,a=d%6/5}let u=Math.max(n,i,a)*2;if(u===0)return 30;let f=30+(Math.round(a)<<2|Math.round(i)<<1|Math.round(n));return u===2&&(f+=60),f},enumerable:!1},rgbToAnsi:{value:(r,n,i)=>t.ansi256ToAnsi(t.rgbToAnsi256(r,n,i)),enumerable:!1},hexToAnsi:{value:r=>t.ansi256ToAnsi(t.hexToAnsi256(r)),enumerable:!1}}),t}var Nn1=An1(),Vtf=Nn1;var O_a=new Set(["\x1B","\x9B"]),zn1=39,Wau="\x07",$tf="[",Bn1="]",Jtf="m",Hau=`${Bn1}8;;`,Wtf=e=>`${O_a.values().next().value}${$tf}${e}${Jtf}`,Htf=e=>`${O_a.values().next().value}${Hau}${e}${Wau}`,In1=e=>e.split(" ").map(t=>N9(t)),Vau=(e,t,r)=>{let n=[...t],i=!1,a=!1,u=N9(Kqt(e[e.length-1]));for(let[f,d]of n.entries()){let c=N9(d);if(u+c<=r?e[e.length-1]+=d:(e.push(d),u=0),O_a.has(d)&&(i=!0,a=n.slice(f+1).join("").startsWith(Hau)),i){a?d===Wau&&(i=!1,a=!1):d===Jtf&&(i=!1);continue}u+=c,u===r&&f<n.length-1&&(e.push(""),u=0)}!u&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Rn1=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(N9(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Fn1=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",i,a,u=In1(e),f=[""];for(let[c,o]of e.split(" ").entries()){r.trim!==!1&&(f[f.length-1]=f[f.length-1].trimStart());let l=N9(f[f.length-1]);if(c!==0&&(l>=t&&(r.wordWrap===!1||r.trim===!1)&&(f.push(""),l=0),(l>0||r.trim===!1)&&(f[f.length-1]+=" ",l++)),r.hard&&u[c]>t){let g=t-l,O=1+Math.floor((u[c]-g-1)/t);Math.floor((u[c]-1)/t)<O&&f.push(""),Vau(f,o,t);continue}if(l+u[c]>t&&l>0&&u[c]>0){if(r.wordWrap===!1&&l<t){Vau(f,o,t);continue}f.push("")}if(l+u[c]>t&&r.wordWrap===!1){Vau(f,o,t);continue}f[f.length-1]+=o}r.trim!==!1&&(f=f.map(c=>Rn1(c)));let d=[...f.join(`
|
|
1789
1789
|
`)];for(let[c,o]of d.entries()){if(n+=o,O_a.has(o)){let{groups:g}=new RegExp(`(?:\\${$tf}(?<code>\\d+)m|\\${Hau}(?<uri>.*)${Wau})`).exec(d.slice(c).join(""))||{groups:{}};if(g.code!==void 0){let O=Number.parseFloat(g.code);i=O===zn1?void 0:O}else g.uri!==void 0&&(a=g.uri.length===0?void 0:g.uri)}let l=Vtf.codes.get(Number(i));d[c+1]===`
|
|
1790
1790
|
`?(a&&(n+=Htf("")),i&&l&&(n+=Wtf(l))):o===`
|
|
@@ -1901,10 +1901,10 @@ errors:
|
|
|
1901
1901
|
Run ${cl.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1902
1902
|
Run ${cl.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),u6n(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function Tsu({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!luf(e))return;let i=t??"",a=e.filter(f=>f.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((f,d)=>f.generatorName.localeCompare(d.generatorName)||f.currentVersion.localeCompare(d.currentVersion));for(let f of u)i+=`
|
|
1903
1903
|
${await Rp1(f.generatorName)} (${f.apiName!=null?"API: "+f.apiName+", ":""}Group: ${f.generatorGroup}) `+cl.dim(f.currentVersion)+cl.reset(" \u2192 ")+cl.green(f.latestVersion);return i+=`
|
|
1904
|
-
`,n?u6n(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function Rp1(e){let r=await new cuf.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 Fp1({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await duf({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,c,o,l)=>{f.versions[c]==null&&(f.versions[c]={});let g=pg.getGeneratorNameOrThrow(o.name,l),O=await pg.getLatestGeneratorVersion({generatorName:g,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});O!=null&&(f.versions[c][o.name]={previousVersion:o.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),f}let u={type:"multiApi",versions:{}};return await duf({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,d,c,o)=>{if(f==null)return;u.versions[f]==null&&(u.versions[f]={}),u.versions[f][d]==null&&(u.versions[f][d]={});let l=pg.getGeneratorNameOrThrow(c.name,o),g=await pg.getLatestGeneratorVersion({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:a,context:o});g!=null&&(u.versions[f][d][c.name]={previousVersion:c.version,latestVersion:g})},generatorFilter:r,groupFilter:n}),u}async function duf({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let f=await pg.loadGeneratorsConfiguration({absolutePathToWorkspace:a.absoluteFilepath,context:u});if(!(f==null||f.groups==null)){for(let d of f.groups)if(!(i!=null&&d.groupName!==i))for(let c of d.generators)n!=null&&c.name!==n||await r(a.workspaceName,d.groupName,c,u)}})}))}function puf(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,f]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let d=Pne(f.latestVersion,f.previousVersion);r.debug(`Latest version: ${f.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:f.previousVersion,latestVersion:f.latestVersion})}return n}async function Eha({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await Fp1({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(f.type==="multiApi")for(let[d,c]of Object.entries(f.versions))u.push(...puf(c,d,t.logger));else u.push(...puf(f.versions,void 0,t.logger))}return u}var e_i=class extends Error{constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${i} ${a}`.trim(),f=u?`status code ${u}`:"an unknown error";super(`Request failed with ${f}`),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var F6n=class extends Error{constructor(t){super("Request timed out"),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="TimeoutError",this.request=t}};var t_i=e=>e!==null&&typeof e=="object";var r_i=(...e)=>{for(let t of e)if((!t_i(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Mha({},...e)},qsu=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,u]of i.entries())n&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r},Mha=(...e)=>{let t={},r={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(t_i(n)){for(let[i,a]of Object.entries(n))t_i(a)&&i in t&&(a=Mha(t[i],a)),t={...t,[i]:a};t_i(n.headers)&&(r=qsu(r,n.headers),t.headers=r)}return t};var _uf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";return r&&n&&(t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")),e&&!t})(),huf=typeof globalThis.AbortController=="function",yuf=typeof globalThis.ReadableStream=="function",vuf=typeof globalThis.FormData=="function",xha=["get","post","put","patch","head","delete"],Lp1=()=>{};Lp1();var buf={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},Tha=2147483647,qha=Symbol("stop"),guf={json:!0,parseJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},muf={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};var Puf=e=>xha.includes(e)?e.toUpperCase():e,Up1=["get","put","head","delete","options","trace"],Vp1=[408,413,429,500,502,503,504],juf=[413,429,503],Ouf={limit:2,methods:Up1,statusCodes:Vp1,afterStatusCodes:juf,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},wuf=(e={})=>{if(typeof e=="number")return{...Ouf,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{...Ouf,...e,afterStatusCodes:juf}};async function Csu(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new F6n(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function Asu(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t==null||t.removeEventListener("abort",i),r()},e)})}var Duf=(e,t)=>{let r={};for(let n in t)!(n in muf)&&!(n in guf)&&!(n in e)&&(r[n]=t[n]);return r};var pen=class{static create(t,r){let n=new pen(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>Tha)throw new RangeError(`The \`timeout\` option cannot be greater than ${Tha}`);await Promise.resolve();let f=await n._fetch();for(let d of n._options.hooks.afterResponse){let c=await d(n.request,n._options,n._decorateResponse(f.clone()));c instanceof globalThis.Response&&(f=c)}if(n._decorateResponse(f),!f.ok&&n._options.throwHttpErrors){let d=new e_i(f,n.request,n._options);for(let c of n._options.hooks.beforeError)d=await c(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!yuf)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(f.clone(),n._options.onDownloadProgress)}return f},u=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[f,d]of Object.entries(buf))u[f]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let o=(await u).clone();if(f==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[f]()};return u}constructor(t,r={}){Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"abortController",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_retryCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._input=t;let n="credentials"in Request.prototype;if(this._options={credentials:n?this._input.credentials:void 0,...r,headers:qsu(this._input.headers,r.headers),hooks:Mha({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Puf(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:wuf(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(huf){if(this.abortController=new globalThis.AbortController,this._options.signal){let i=this._options.signal;this._options.signal.addEventListener("abort",()=>{this.abortController.abort(i.reason)})}this._options.signal=this.abortController.signal}if(_uf&&(this._options.duplex="half"),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let i=typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString(),a="?"+i,u=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,a);(vuf&&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(u,{...this.request}),this._options)}this._options.json!==void 0&&(this._options.body=JSON.stringify(this._options.json),this.request.headers.set("content-type",this._options.headers.get("content-type")??"application/json"),this.request=new globalThis.Request(this.request,{body:this._options.body}))}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount<=this._options.retry.limit&&!(t instanceof F6n)){if(t instanceof e_i){if(!this._options.retry.statusCodes.includes(t.response.status))return 0;let n=t.response.headers.get("Retry-After");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n);return Number.isNaN(i)?i=Date.parse(n)-Date.now():i*=1e3,this._options.retry.maxRetryAfter!==void 0&&i>this._options.retry.maxRetryAfter?0:i}if(t.response.status===413)return 0}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}return 0}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),Tha);if(n!==0&&this._retryCount>0){await Asu(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===qha)return;return this._retry(t)}throw r}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=Duf(this.request,this._options);return this._options.timeout===!1?this._options.fetch(this.request.clone(),t):Csu(this.request.clone(),t,this.abortController,this._options)}_stream(t,r){let n=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function f(){let{done:d,value:c}=await u.read();if(d){a.close();return}if(r){i+=c.byteLength;let o=n===0?0:i/n;r({percent:o,transferredBytes:i,totalBytes:n},c)}a.enqueue(c),await f()}await f()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var Nsu=e=>{let t=(r,n)=>pen.create(r,r_i(e,n));for(let r of xha)t[r]=(n,i)=>pen.create(n,r_i(e,i,{method:r}));return t.create=r=>Nsu(r_i(r)),t.extend=r=>Nsu(r_i(e,r)),t.stop=qha,t},Wp1=Nsu(),Suf=Wp1;var Yuf=yu(Kuf(),1);function Fsu(e){let t=(0,Yuf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var $sf=yu(Hsf(),1),Jsf=yu(ZQr(),1),Qsu=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Zsu=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function ksu(e,t={}){var l;let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??Fsu(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,$sf.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,f&&(d.authorization=`${f.type} ${f.token}`);let c;try{c=await Suf(u,{headers:d,keepalive:!0}).json()}catch(g){throw((l=g==null?void 0:g.response)==null?void 0:l.status)===404?new Qsu(e):g}if(t.allVersions)return c;let o=new Zsu(e,r);if(c["dist-tags"][r]){let{time:g}=c;c=c.versions[c["dist-tags"][r]],c.time=g}else if(r){let g=Boolean(c.versions[r]);if(n&&!g)for(let[j,S]of Object.entries(c.versions))S.deprecated&&delete c.versions[j];if(!g){let j=Object.keys(c.versions);if(r=Jsf.default.maxSatisfying(j,r),!r)throw o}let{time:O}=c;if(c=c.versions[r],c.time=O,!c)throw o}return c}async function u_i(e,t){let{version:r}=await ksu(e.toLowerCase(),t);return r}async function J6n({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:u_i(e.packageName,{version:t?"prerelease":"latest"})}var Gsf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Hha=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=hM.Info;constructor(t){this.ttyAwareLogger=new Sha(t);let r=this.getPackageName(),n=this.getPackageVersion(),i=this.getCliName();(r==null||n==null||i==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:n,cliName:i}}getPackageName(){return"fern-api"==null&&this.logger.error("CLI_PACKAGE_NAME is not defined"),"fern-api"}getPackageVersion(){return"0.42.5"==null&&this.logger.error("CLI_VERSION is not defined"),"0.42.5"}getCliName(){return"fern"==null&&this.logger.error("CLI_NAME is not defined"),"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${cl.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Gte}failWithoutThrowing(t,r){this.didSucceed=!1,Pha({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),(await QAn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await fuf({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1904
|
+
`,n?u6n(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function Rp1(e){let r=await new cuf.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 Fp1({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await duf({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,c,o,l)=>{f.versions[c]==null&&(f.versions[c]={});let g=pg.getGeneratorNameOrThrow(o.name,l),O=await pg.getLatestGeneratorVersion({generatorName:g,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});O!=null&&(f.versions[c][o.name]={previousVersion:o.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),f}let u={type:"multiApi",versions:{}};return await duf({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,d,c,o)=>{if(f==null)return;u.versions[f]==null&&(u.versions[f]={}),u.versions[f][d]==null&&(u.versions[f][d]={});let l=pg.getGeneratorNameOrThrow(c.name,o),g=await pg.getLatestGeneratorVersion({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:a,context:o});g!=null&&(u.versions[f][d][c.name]={previousVersion:c.version,latestVersion:g})},generatorFilter:r,groupFilter:n}),u}async function duf({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let f=await pg.loadGeneratorsConfiguration({absolutePathToWorkspace:a.absoluteFilepath,context:u});if(!(f==null||f.groups==null)){for(let d of f.groups)if(!(i!=null&&d.groupName!==i))for(let c of d.generators)n!=null&&c.name!==n||await r(a.workspaceName,d.groupName,c,u)}})}))}function puf(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,f]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let d=Pne(f.latestVersion,f.previousVersion);r.debug(`Latest version: ${f.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:f.previousVersion,latestVersion:f.latestVersion})}return n}async function Eha({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await Fp1({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(f.type==="multiApi")for(let[d,c]of Object.entries(f.versions))u.push(...puf(c,d,t.logger));else u.push(...puf(f.versions,void 0,t.logger))}return u}var e_i=class extends Error{constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${i} ${a}`.trim(),f=u?`status code ${u}`:"an unknown error";super(`Request failed with ${f}`),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var F6n=class extends Error{constructor(t){super("Request timed out"),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="TimeoutError",this.request=t}};var t_i=e=>e!==null&&typeof e=="object";var r_i=(...e)=>{for(let t of e)if((!t_i(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Mha({},...e)},qsu=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,u]of i.entries())n&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r},Mha=(...e)=>{let t={},r={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(t_i(n)){for(let[i,a]of Object.entries(n))t_i(a)&&i in t&&(a=Mha(t[i],a)),t={...t,[i]:a};t_i(n.headers)&&(r=qsu(r,n.headers),t.headers=r)}return t};var _uf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";return r&&n&&(t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")),e&&!t})(),huf=typeof globalThis.AbortController=="function",yuf=typeof globalThis.ReadableStream=="function",vuf=typeof globalThis.FormData=="function",xha=["get","post","put","patch","head","delete"],Lp1=()=>{};Lp1();var buf={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},Tha=2147483647,qha=Symbol("stop"),guf={json:!0,parseJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},muf={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};var Puf=e=>xha.includes(e)?e.toUpperCase():e,Up1=["get","put","head","delete","options","trace"],Vp1=[408,413,429,500,502,503,504],juf=[413,429,503],Ouf={limit:2,methods:Up1,statusCodes:Vp1,afterStatusCodes:juf,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},wuf=(e={})=>{if(typeof e=="number")return{...Ouf,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{...Ouf,...e,afterStatusCodes:juf}};async function Csu(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new F6n(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function Asu(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t==null||t.removeEventListener("abort",i),r()},e)})}var Duf=(e,t)=>{let r={};for(let n in t)!(n in muf)&&!(n in guf)&&!(n in e)&&(r[n]=t[n]);return r};var pen=class{static create(t,r){let n=new pen(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>Tha)throw new RangeError(`The \`timeout\` option cannot be greater than ${Tha}`);await Promise.resolve();let f=await n._fetch();for(let d of n._options.hooks.afterResponse){let c=await d(n.request,n._options,n._decorateResponse(f.clone()));c instanceof globalThis.Response&&(f=c)}if(n._decorateResponse(f),!f.ok&&n._options.throwHttpErrors){let d=new e_i(f,n.request,n._options);for(let c of n._options.hooks.beforeError)d=await c(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!yuf)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(f.clone(),n._options.onDownloadProgress)}return f},u=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[f,d]of Object.entries(buf))u[f]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let o=(await u).clone();if(f==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[f]()};return u}constructor(t,r={}){Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"abortController",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_retryCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._input=t;let n="credentials"in Request.prototype;if(this._options={credentials:n?this._input.credentials:void 0,...r,headers:qsu(this._input.headers,r.headers),hooks:Mha({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Puf(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:wuf(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(huf){if(this.abortController=new globalThis.AbortController,this._options.signal){let i=this._options.signal;this._options.signal.addEventListener("abort",()=>{this.abortController.abort(i.reason)})}this._options.signal=this.abortController.signal}if(_uf&&(this._options.duplex="half"),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let i=typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString(),a="?"+i,u=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,a);(vuf&&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(u,{...this.request}),this._options)}this._options.json!==void 0&&(this._options.body=JSON.stringify(this._options.json),this.request.headers.set("content-type",this._options.headers.get("content-type")??"application/json"),this.request=new globalThis.Request(this.request,{body:this._options.body}))}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount<=this._options.retry.limit&&!(t instanceof F6n)){if(t instanceof e_i){if(!this._options.retry.statusCodes.includes(t.response.status))return 0;let n=t.response.headers.get("Retry-After");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n);return Number.isNaN(i)?i=Date.parse(n)-Date.now():i*=1e3,this._options.retry.maxRetryAfter!==void 0&&i>this._options.retry.maxRetryAfter?0:i}if(t.response.status===413)return 0}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}return 0}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),Tha);if(n!==0&&this._retryCount>0){await Asu(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===qha)return;return this._retry(t)}throw r}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=Duf(this.request,this._options);return this._options.timeout===!1?this._options.fetch(this.request.clone(),t):Csu(this.request.clone(),t,this.abortController,this._options)}_stream(t,r){let n=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function f(){let{done:d,value:c}=await u.read();if(d){a.close();return}if(r){i+=c.byteLength;let o=n===0?0:i/n;r({percent:o,transferredBytes:i,totalBytes:n},c)}a.enqueue(c),await f()}await f()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var Nsu=e=>{let t=(r,n)=>pen.create(r,r_i(e,n));for(let r of xha)t[r]=(n,i)=>pen.create(n,r_i(e,i,{method:r}));return t.create=r=>Nsu(r_i(r)),t.extend=r=>Nsu(r_i(e,r)),t.stop=qha,t},Wp1=Nsu(),Suf=Wp1;var Yuf=yu(Kuf(),1);function Fsu(e){let t=(0,Yuf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var $sf=yu(Hsf(),1),Jsf=yu(ZQr(),1),Qsu=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Zsu=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function ksu(e,t={}){var l;let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??Fsu(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,$sf.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,f&&(d.authorization=`${f.type} ${f.token}`);let c;try{c=await Suf(u,{headers:d,keepalive:!0}).json()}catch(g){throw((l=g==null?void 0:g.response)==null?void 0:l.status)===404?new Qsu(e):g}if(t.allVersions)return c;let o=new Zsu(e,r);if(c["dist-tags"][r]){let{time:g}=c;c=c.versions[c["dist-tags"][r]],c.time=g}else if(r){let g=Boolean(c.versions[r]);if(n&&!g)for(let[j,S]of Object.entries(c.versions))S.deprecated&&delete c.versions[j];if(!g){let j=Object.keys(c.versions);if(r=Jsf.default.maxSatisfying(j,r),!r)throw o}let{time:O}=c;if(c=c.versions[r],c.time=O,!c)throw o}return c}async function u_i(e,t){let{version:r}=await ksu(e.toLowerCase(),t);return r}async function J6n({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:u_i(e.packageName,{version:t?"prerelease":"latest"})}var Gsf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Hha=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=hM.Info;constructor(t){this.ttyAwareLogger=new Sha(t);let r=this.getPackageName(),n=this.getPackageVersion(),i=this.getCliName();(r==null||n==null||i==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:n,cliName:i}}getPackageName(){return"fern-api"==null&&this.logger.error("CLI_PACKAGE_NAME is not defined"),"fern-api"}getPackageVersion(){return"0.42.6"==null&&this.logger.error("CLI_VERSION is not defined"),"0.42.6"}getCliName(){return"fern"==null&&this.logger.error("CLI_NAME is not defined"),"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${cl.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Gte}failWithoutThrowing(t,r){this.didSucceed=!1,Pha({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),(await QAn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await fuf({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1905
1905
|
`)||(r+=`
|
|
1906
1906
|
`),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=PWo(t.map(n=>n.type==="docs"?"docs":n.workspaceName??"api"),n=>n.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new Wpi(t);return this.ttyAwareLogger.registerTask(r),r}async runTaskWithInit(t,r){let n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(a){throw n.failWithoutThrowing(void 0,a),new Gte}finally{n.finish()}return i}async instrumentPostHogEvent(t){(await QAn()).sendEvent(t)}logger=Zui(this.log.bind(this));constructTaskInitForWorkspace(t){let r=Ksf(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?Ksf(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=Gsf[this.numTasks++%Gsf.length],u=cl.hex(a)(i);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===D4.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logImmediately(t){let r=t.filter(n=>_4r.indexOf(n.level)>=_4r.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===hM.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 J6n({cliEnvironment:this.environment,includePreReleases:t}),n=Pne(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await Eha({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}};function Ksf(e){return`[${e}]:`}var tC;(function(e){e.FILE_READ="FILE_READ",e.FILE_PARSE="FILE_PARSE",e.FILE_MISSING="FILE_MISSING",e.STRUCTURE_VALIDATION="STRUCTURE_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"})(tC||(tC={}));function ecu(e,t){for(let[r,n]of v3(e.failures))Ysf({relativeFilepath:r,failure:n,logger:t})}function $ha(e,t){for(let[r,n]of v3(e))Ysf({relativeFilepath:r,failure:n,logger:t})}function Ysf({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case tC.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 tC.FILE_READ:r.error("Failed to open file: "+e);break;case tC.FILE_MISSING:r.error("Missing file: "+e);break;case tC.FILE_PARSE:t.error instanceof jLo?r.error(wMn({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case tC.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of J_1(n))r.error(wMn({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case tC.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case tC.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${t7c}: `+t.dependencyName);break;case tC.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case tC.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;default:Ol(t)}}function J_1(e){switch(e.code){case L_.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${cl.underline(e.expected)} but received ${cl.underline(e.received)}`}];case L_.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${cl.underline(t)}`}));case L_.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>cl.underline(t)).join(", ")}`}];case L_.invalid_union:case L_.invalid_arguments:case L_.invalid_return_type:case L_.invalid_date:case L_.invalid_string:case L_.too_small:case L_.too_big:case L_.invalid_intersection_types:case L_.not_multiple_of:case L_.custom:default:return[{title:e.message}]}}var Xsf=require("fs/promises");async function Jha(e,t){let r=[];for(let n of await u4r(e,t))r.push(await G_1({relativeFilepath:YN(e,n),absoluteFilepath:n}));return r}async function G_1({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,Xsf.readFile)(t)).toString()}}async function Qsf({absolutePathToWorkspace:e}){let t=pf(e,zs.of(k6c));if(!await Vh(t))return;let n=await Jha(t,"{md,mdx}");return{files:await Promise.all(n.map(i=>({absoluteFilepath:i.absoluteFilepath,contents:i.fileContents})))}}var pdf=yu(ncu(),1);async function ncf(e){let t={},r={};function n(i){try{t[i.relativeFilepath]={defaultUrl:void 0,contents:av.load(i.fileContents,{schema:av.CORE_SCHEMA}),rawContents:i.fileContents}}catch(a){r[i.relativeFilepath]={type:tC.FILE_PARSE,error:a}}}return await Promise.all(e.map(n)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}var Hlu=yu(gZr(),1),tdf=yu(vRt(),1),rdf=require("fs"),v7n=require("fs/promises");var ndf=require("os"),idf=yu(require("path"),1),adf=require("stream/promises"),odf=yu(kya(),1),udf=yu(Jte(),1);var w01=QDr();async function sdf({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:n,cliVersion:i,settings:a}){let u,f={type:tC.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},d=t.dependencies[e];return d==null?f={type:tC.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${q01(d)}`},async c=>{switch(d.type){case"version":u=await x01({context:c,dependency:d,cliVersion:i,settings:a});return;case"local":u=await M01({context:c,dependency:d,cliVersion:i,settings:a});return;default:Ol(d)}}),u!=null?{didSucceed:!0,definition:u}:{didSucceed:!1,failure:f}}var cdf="dependencies";var D01="metadata.json",S01=".fern";function E01(e){return pf(I_.of((0,ndf.homedir)()),zs.of(S01),zs.of(cdf),zs.of(e.organization),zs.of(e.apiName),zs.of(e.version))}async function M01({dependency:e,context:t,cliVersion:r,settings:n}){t.logger.info("Parsing...");let i=await Nen({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!i.didSucceed){t.failWithoutThrowing("Failed to load api definition",i.failures);return}t.logger.info("Modifying source filepath ...");let a=await i.workspace.getDefinition({context:t,relativePathToDependency:zs.of(e.path)},n);return t.logger.info("Loaded..."),a}async function x01({dependency:e,context:t,cliVersion:r,settings:n}){let i=E01(e),a=pf(i,zs.of(cdf)),u=pf(i,zs.of(D01)),f;if(!await Vh(a)||!await Vh(u)){t.logger.info("Downloading manifest...");let o=await w01.definitionRegistry.get(Hlu.FernFiddle.OrganizationId(e.organization),Hlu.FernFiddle.ApiId(e.apiName),e.version);if(!o.ok){o.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:j=>{t.failWithoutThrowing("Failed to download API manifest",j)}});return}let l=o.body.yamlSchemaVersion!=null?parseInt(o.body.yamlSchemaVersion):void 0,g=cen(r),O=cen(o.body.cliVersion);if(l!=null){if(l>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${o.body.cliVersion}`);return}else if(l<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 ${o.body.cliVersion}. Expected ${g.major}.${g.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+o.body.definitionS3DownloadUrl),await(0,v7n.mkdir)(a,{recursive:!0});try{await T01({s3PreSignedReadUrl:o.body.definitionS3DownloadUrl,absolutePathToLocalOutput:a})}catch(j){t.failWithoutThrowing("Failed to download API",j);return}f=o.body,await(0,v7n.writeFile)(u,JSON.stringify(f))}else f=JSON.parse((await(0,v7n.readFile)(u)).toString());t.logger.info("Parsing...");let d=await Nen({absolutePathToWorkspace:a,context:t,cliVersion:f.cliVersion,workspaceName:void 0});if(!d.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",d.failures);return}if(d.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await d.workspace.getDefinition({context:t},n)}async function T01({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await tdf.default.get(e,{responseType:"stream"}),n=await udf.default.dir(),i=idf.default.join(n.path,"api.tgz");await(0,adf.pipeline)(r.data,(0,rdf.createWriteStream)(i)),await odf.default.extract({file:i,cwd:t})}function q01(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:Ol(e)}}async function ldf({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:n,settings:i}){let a={},u={},f={};return await Promise.all(v3(t.packageMarkers).map(async([d,c])=>{if(c.contents.export==null)a[d]=c;else{let{export:o,...l}=c.contents;if(Q8t(l)>0)f[d]={type:tC.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:d};else{let g=Cg(d);if(E8t(t.namedDefinitionFiles).some(j=>j!==d&&j.startsWith(g)))f[d]={type:tC.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:g};else{let j=await sdf({dependencyName:typeof c.contents.export=="string"?c.contents.export:c.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:n,settings:i});j.didSucceed?u[Cg(d)]={definition:j.definition,url:typeof c.contents.export=="object"?c.contents.export.url:void 0}:f[d]=j.failure}}}})),Q8t(f)>0?{didSucceed:!1,failures:f}:{didSucceed:!0,packageMarkers:a,importedDefinitions:u}}var fdf=yu(require("path"),1);function ddf({files:e,absolutePathToDefinition:t}){let r,n={},i={},a={};for(let[u,f]of v3(e)){let d=f.contents,c=o=>{a[u]={type:tC.STRUCTURE_VALIDATION,error:o}};if(u===nB){let o=tta.safeParse(d);o.success?r={defaultUrl:o.data["default-url"],contents:o.data,rawContents:f.rawContents}:c(o.error)}else if(fdf.default.basename(u)===HT){let o=Xea.safeParse(d);o.success?i[u]={defaultUrl:typeof o.data.export=="object"?o.data.export.url:void 0,contents:o.data,rawContents:f.rawContents}:c(o.error)}else{let o=s2n.safeParse(d);o.success?n[u]={defaultUrl:void 0,contents:o.data,rawContents:f.rawContents,absoluteFilepath:pf(t,u)}:c(o.error)}}return r==null?{didSucceed:!1,failures:{[zs.of(nB)]:{type:tC.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:n,rootApiFile:r,packageMarkers:i}}var zen=class{};var y5r=class extends zen{type="fern";workspaceName;absoluteFilepath;generatorsConfiguration;dependenciesConfiguration;definition;changelog;sources;cliVersion;constructor({absoluteFilepath:t,workspaceName:r,generatorsConfiguration:n,dependenciesConfiguration:i,definition:a,changelog:u,sources:f,cliVersion:d}){super(),this.absoluteFilepath=t,this.workspaceName=r,this.changelog=u,this.generatorsConfiguration=n,this.dependenciesConfiguration=i,this.definition=a,this.sources=f??[],this.cliVersion=d}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getAbsoluteFilepaths(){return[this.absoluteFilepath]}getSources(){return this.sources}},Ben=class extends zen{type="fern";workspaceName;absoluteFilepath;generatorsConfiguration;changelog;context;cliVersion;fernWorkspaces={};constructor({absoluteFilepath:t,workspaceName:r,generatorsConfiguration:n,changelog:i,cliVersion:a,context:u}){super(),this.absoluteFilepath=t,this.workspaceName=r,this.changelog=i,this.generatorsConfiguration=n,this.cliVersion=a,this.context=u}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let n=(0,pdf.default)(r??{}),i=this.fernWorkspaces[n];if(i==null){let a=t||this.context,u=pf(this.absoluteFilepath,zs.of(p9)),f=await FGi.loadDependenciesConfiguration({absolutePathToWorkspace:this.absoluteFilepath,context:a}),d=await Jha(u,"{yml,yaml}"),c=await ncf(d);if(!c.didSucceed)return $ha(c.failures,a.logger),a.failAndThrow();let o=ddf({files:c.files,absolutePathToDefinition:u});if(!o.didSucceed)return $ha(o.failures,a.logger),a.failAndThrow();let l=await ldf({dependenciesConfiguration:f,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r});if(!l.didSucceed)return $ha(l.failures,a.logger),a.failAndThrow();i=new y5r({absoluteFilepath:this.absoluteFilepath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:f,workspaceName:this.workspaceName,definition:{absoluteFilepath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:l.packageMarkers,importedDefinitions:l.importedDefinitions},changelog:this.changelog,sources:void 0,cliVersion:this.cliVersion}),this.fernWorkspaces[n]=i}return i}getAbsoluteFilepaths(){return[this.absoluteFilepath]}};var HSr={openapi:e=>({...e,type:"openapi",_visit:function(t){return HSr._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return HSr._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 b7n={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return b7n._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var F9={basic:e=>({...e,type:"basic",_visit:function(t){return F9._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return F9._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return F9._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return F9._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return F9._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 RP={primitive:e=>({value:e,type:"primitive",_visit:function(t){return RP._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return RP._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return RP._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return RP._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return RP._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return RP._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return RP._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return RP._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 t0={int:e=>({value:e,type:"int",_visit:function(t){return t0._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return t0._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return t0._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return t0._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return t0._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return t0._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return t0._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return t0._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return t0._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return t0._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return t0._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 g7n={boolean:e=>({value:e,type:"boolean",_visit:function(t){return g7n._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return g7n._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 v5r={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return v5r._visit(this,t)}}),undisciminated:e=>({value:e,type:"undisciminated",_visit:function(t){return v5r._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undisciminated":return t.undisciminated(e.value);default:return t._other(e)}}};var vW={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case vW.GenerallyAvailable:return t.generallyAvailable();case vW.Beta:return t.beta();case vW.Deprecated:return t.deprecated();default:return t._other()}}};var $Sr={cursor:e=>({...e,type:"cursor",_visit:function(t){return $Sr._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return $Sr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);default:return t._other(e)}}};var JSr={language:e=>({...e,type:"language",_visit:function(t){return JSr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return JSr._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 bW={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 bW.Curl:return t.curl();case bW.Python:return t.python();case bW.Javascript:return t.javascript();case bW.Typescript:return t.typescript();case bW.Go:return t.go();case bW.Ruby:return t.ruby();case bW.Csharp:return t.csharp();case bW.Java:return t.java();case bW.Js:return t.js();case bW.Node:return t.node();case bW.Ts:return t.ts();case bW.Nodets:return t.nodets();case bW.Golang:return t.golang();case bW.Dotnet:return t.dotnet();case bW.Jvm:return t.jvm();default:return t._other()}}};var pAt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return pAt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return pAt._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 KJ={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case KJ.Get:return t.get();case KJ.Post:return t.post();case KJ.Put:return t.put();case KJ.Patch:return t.patch();case KJ.Delete:return t.delete();case KJ.Head:return t.head();case KJ.Options:return t.options();case KJ.Trace:return t.trace();default:return t._other()}}};var b5r={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return b5r._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return b5r._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return b5r._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 D2e={file:e=>({...e,type:"file",_visit:function(t){return D2e._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return D2e._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 Sne={file:e=>({...e,type:"file",_visit:function(t){return Sne._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Sne._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Sne._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Sne._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Sne._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Sne._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var ib={primitive:e=>({...e,type:"primitive",_visit:function(t){return ib._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ib._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return ib._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return ib._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return ib._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ib._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return ib._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return ib._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ib._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return ib._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return ib._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 Xw={int:e=>({...e,type:"int",_visit:function(t){return Xw._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Xw._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Xw._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Xw._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Xw._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Xw._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Xw._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Xw._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Xw._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Xw._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Xw._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 E7={boolean:e=>({value:e,type:"boolean",_visit:function(t){return E7._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return E7._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 GSr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return GSr._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return GSr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undisciminated":return t.undisciminated(e);default:return t._other(e)}}};var S2e={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return S2e._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return S2e._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return S2e._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 T3={file:e=>({...e,type:"file",_visit:function(t){return T3._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return T3._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return T3._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return T3._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return T3._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return T3._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Lp={primitive:e=>({...e,type:"primitive",_visit:function(t){return Lp._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Lp._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Lp._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Lp._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Lp._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Lp._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Lp._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Lp._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Lp._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Lp._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Lp._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 jQ={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return jQ._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return jQ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undisciminated":return t.undisciminated(e);default:return t._other(e)}}};var by={int:e=>({...e,type:"int",_visit:function(t){return by._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return by._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return by._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return by._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return by._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return by._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return by._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return by._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return by._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return by._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return by._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 Ng={};Wb(Ng,{AllOfPropertyConflict:()=>I7n,ArraySchema:()=>fva,ArraySchemaWithExample:()=>Lva,Availability:()=>c0a,Base64WithExample:()=>zva,BasicSecurityScheme:()=>d0a,BearerSecurityScheme:()=>p0a,BooleanSchema:()=>ava,BooleanWithExample:()=>Bva,CasingOverrides:()=>y0a,CommonProperty:()=>gva,CommonPropertyWithExample:()=>Yva,CursorPagination:()=>H0a,CustomCodeSample:()=>V0a,CustomCodeSampleLanguage:()=>F0a,CustomCodeSampleSdk:()=>U0a,DateWithExample:()=>Nva,DatetimeWithExample:()=>Ava,DiscriminatedOneOfSchema:()=>vva,DiscriminatedOneOfSchemaWithExample:()=>Gva,DoubleSchema:()=>nva,DoubleWithExample:()=>qva,Encoding:()=>s0a,Endpoint:()=>J0a,EndpointExample:()=>N7n,EndpointSdkName:()=>M5r,EndpointWithExample:()=>Vdf,EnumSchema:()=>P7n,EnumSchemaWithExample:()=>Rva,EnumValue:()=>j5r,ErrorExample:()=>z0a,FernExample:()=>I0a,FileResponse:()=>T7n,FileSchema:()=>x0a,FloatWithExample:()=>Tva,FullEndpointExample:()=>W0a,FullExample:()=>yA,FullObjectExample:()=>w0a,FullOneOfExample:()=>S0a,GlobalHeader:()=>uva,Header:()=>E5r,HeaderExample:()=>A7n,HeaderSecurityScheme:()=>_0a,HeaderWithExample:()=>L7n,HttpEndpointServer:()=>q7n,HttpError:()=>B0a,HttpErrorWithExample:()=>Dva,HttpMethod:()=>D7n,IdempotencyHeader:()=>sva,Int64WithExample:()=>Eva,IntSchema:()=>tva,IntWithExample:()=>Sva,JsonRequest:()=>C0a,JsonRequestWithExample:()=>Ova,JsonResponse:()=>KSr,JsonResponseWithExample:()=>jva,KeyValuePair:()=>D0a,LiteralExample:()=>j0a,LiteralSchema:()=>B7n,LiteralSchemaValue:()=>cva,LongSchema:()=>rva,MapSchema:()=>dva,MapSchemaWithExample:()=>Uva,MultipartRequest:()=>x7n,MultipartRequestProperty:()=>q0a,MultipartSchema:()=>T0a,NamedFullExample:()=>BRt,Namespace:()=>v0a,NamespaceId:()=>P0a,NullableSchema:()=>_va,NullableSchemaWithExample:()=>Wva,OauthSecurityScheme:()=>g0a,ObjectProperty:()=>yva,ObjectPropertyConflictInfo:()=>R7n,ObjectPropertyWithExample:()=>Jva,ObjectSchema:()=>lva,ObjectSchemaWithExample:()=>Hva,OctetStreamRequest:()=>M7n,OffsetPagination:()=>$0a,OneOfSchema:()=>hva,OneOfSchemaWithExample:()=>$va,OpenApiIntermediateRepresentation:()=>Ldf,OpenApiSource:()=>i0a,OptionalSchema:()=>pva,OptionalSchemaWithExample:()=>Vva,Pagination:()=>z7n,PathParameter:()=>S7n,PathParameterExample:()=>R0a,PathParameterWithExample:()=>mva,PrimitiveExample:()=>w7n,PrimitiveSchema:()=>T5r,PrimitiveSchemaValue:()=>ova,PrimitiveSchemaValueWithExample:()=>Iva,PrimitiveSchemaWithExample:()=>U7n,PropertyKey:()=>j7n,ProtobufEncoding:()=>u0a,ProtobufSource:()=>a0a,QueryParameter:()=>E7n,QueryParameterExample:()=>C7n,QueryParameterWithExample:()=>F7n,QuerySecurityScheme:()=>h0a,ReferencedSchema:()=>zRt,Request:()=>A0a,RequestWithExample:()=>Pva,Response:()=>N0a,ResponseWithExample:()=>wva,Schema:()=>D1,SchemaId:()=>wQ,SchemaWithExample:()=>aq,Schemas:()=>eva,SdkGroup:()=>b0a,SdkGroupInfo:()=>E0a,SdkGroupName:()=>w5r,SecurityScheme:()=>m0a,SecuritySchemeId:()=>f0a,Server:()=>O0a,Source:()=>o0a,StatusCode:()=>D5r,StringSchema:()=>iva,StringSchemaWithExample:()=>Cva,SupportedSdkLanguage:()=>L0a,Tag:()=>l0a,TagId:()=>Kje,Tags:()=>M0a,TextResponse:()=>x5r,Uint64WithExample:()=>xva,UintWithExample:()=>Mva,UnDiscriminatedOneOfSchema:()=>bva,UnDiscriminatedOneOfSchemaWithExample:()=>Kva,UnknownSchemaWithExample:()=>Fva,Webhook:()=>Y0a,WebhookExampleCall:()=>K0a,WebhookHttpMethod:()=>G0a,WebsocketChannel:()=>k0a,WebsocketHandshake:()=>X0a,WebsocketHandshakeWithExample:()=>Udf,WebsocketMessageExample:()=>Q0a,WebsocketSessionExample:()=>Z0a,WithAvailability:()=>Z0,WithDescription:()=>O_,WithEncoding:()=>Ene,WithName:()=>Ym,WithNamespace:()=>S5r,WithSdkGroupName:()=>w1,WithSource:()=>hb,WithTitle:()=>j1,commons:()=>Ylu,example:()=>Xlu,finalIr:()=>Qlu,parseIr:()=>Zlu});var Ylu={};Wb(Ylu,{BasicSecurityScheme:()=>d0a,BearerSecurityScheme:()=>p0a,Encoding:()=>s0a,HeaderSecurityScheme:()=>_0a,Namespace:()=>v0a,NamespaceId:()=>P0a,OauthSecurityScheme:()=>g0a,OpenApiSource:()=>i0a,ProtobufEncoding:()=>u0a,ProtobufSource:()=>a0a,QuerySecurityScheme:()=>h0a,SchemaId:()=>wQ,SdkGroup:()=>b0a,SdkGroupName:()=>w5r,SecurityScheme:()=>m0a,SecuritySchemeId:()=>f0a,Server:()=>O0a,Source:()=>o0a,StatusCode:()=>D5r,Tag:()=>l0a,TagId:()=>Kje,WithAvailability:()=>Z0,WithDescription:()=>O_,WithEncoding:()=>Ene,WithName:()=>Ym,WithNamespace:()=>S5r,WithSdkGroupName:()=>w1,WithSource:()=>hb,WithTitle:()=>j1});var Wn={};Wb(Wn,{JsonError:()=>g5r,ParseError:()=>m5r,any:()=>Edf,boolean:()=>Mdf,booleanLiteral:()=>Sdf,date:()=>hdf,discriminant:()=>Idf,enum_:()=>t0a,getObjectLikeUtils:()=>NRt,getObjectUtils:()=>O7n,getSchemaUtils:()=>hA,isProperty:()=>P5r,lazy:()=>ydf,lazyObject:()=>jdf,list:()=>n0a,number:()=>xdf,object:()=>r0a,objectWithoutOptionalProperties:()=>Pdf,optional:()=>$lu,property:()=>bdf,record:()=>Adf,set:()=>Ndf,string:()=>Tdf,stringLiteral:()=>Ddf,transform:()=>Jlu,undiscriminatedUnion:()=>Bdf,union:()=>Fdf,unknown:()=>qdf,withParsedProperties:()=>Klu});var VS={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 rC(e,t){return`Expected ${t}. Received ${C01(e)}.`}function C01(e){if(Array.isArray(e))return"list";if(e===null)return"null";switch(typeof e){case"string":return`"${e}"`;case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function YJ(e){return{...e,json:_df(e.json),parse:_df(e.parse)}}function _df(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1907
|
-
`)),{ok:!0,value:t}):n}}function e0a(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var g5r=class extends Error{errors;constructor(t){super(t.map(e0a).join("; ")),this.errors=t,Object.setPrototypeOf(this,g5r.prototype)}};var m5r=class extends Error{errors;constructor(t){super(t.map(e0a).join("; ")),this.errors=t,Object.setPrototypeOf(this,m5r.prototype)}};function hA(e){return{optional:()=>$lu(e),transform:t=>Jlu(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new m5r(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new g5r(n.errors)}}}function $lu(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>(n==null?void 0:n.omitUndefined)&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>VS.OPTIONAL};return{...t,...hA(t)}}function Jlu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...hA(r)}}var A01=/^([+-]?\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 hdf(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:rC(t,"string")}]}:A01.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:rC(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:rC(t,"Date object")}]},getType:()=>VS.DATE};return{...YJ(e),...hA(e)}}function XJ(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...YJ(r),...hA(r)}}}function t0a(e){let t=new Set(e);return XJ(VS.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:rC(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:rC(n,"enum")}]}:{ok:!0,value:n})()}function ydf(e){let t=Glu(e);return{...t,...hA(t)}}function Glu(e){return{parse:(t,r)=>m7n(e).parse(t,r),json:(t,r)=>m7n(e).json(t,r),getType:()=>m7n(e).getType()}}function m7n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function T_i(e){return Object.entries(e)}function q_i(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function O5r(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 C_i(e){return Object.keys(e)}function vdf(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function NRt(e){return{withParsedProperties:t=>Klu(e,t)}}function Klu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((f,[d,c])=>({...f,[d]:typeof c=="function"?c(a.value):c}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!O5r(n))return{ok:!1,errors:[{path:(i==null?void 0:i.breadcrumbsPrefix)??[],message:rC(n,"object")}]};let a=new Set(Object.keys(t)),u=q_i(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...hA(r),...NRt(r)}}function bdf(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function P5r(e){return e.isProperty}function r0a(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>P5r(n)?n.rawKey:r),_getParsedProperties:()=>C_i(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of T_i(e)){let d=P5r(f)?f.rawKey:u,c=P5r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,Odf(c)&&a.push(d)}return gdf({value:r,requiredKeys:a,getProperty:u=>{let f=i[u];if(f!=null)return{transformedKey:f.parsedKey,transform:d=>f.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],u]})}},unrecognizedObjectKeys:n==null?void 0:n.unrecognizedObjectKeys,skipValidation:n==null?void 0:n.skipValidation,breadcrumbsPrefix:n==null?void 0:n.breadcrumbsPrefix,omitUndefined:n==null?void 0:n.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,u]of T_i(e)){let f=P5r(u)?u.valueSchema:u;Odf(f)&&i.push(a)}return gdf({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return P5r(u)?{transformedKey:u.rawKey,transform:f=>u.valueSchema.json(f,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],a]})}:{transformedKey:a,transform:f=>u.json(f,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],a]})}},unrecognizedObjectKeys:n==null?void 0:n.unrecognizedObjectKeys,skipValidation:n==null?void 0:n.skipValidation,breadcrumbsPrefix:n==null?void 0:n.breadcrumbsPrefix,omitUndefined:n==null?void 0:n.omitUndefined})},getType:()=>VS.OBJECT};return{...YJ(t),...hA(t),...NRt(t),...O7n(t)}}function gdf({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!O5r(e))return{ok:!1,errors:[{path:a,message:rC(e,"object")}]};let u=new Set(t),f=[],d={};for(let[c,o]of Object.entries(e)){let l=r(c);if(l!=null){u.delete(c);let g=l.transform(o);g.ok?d[l.transformedKey]=g.value:(d[c]=o,f.push(...g.errors))}else switch(n){case"fail":f.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":d[c]=o;break}}return f.push(...t.filter(c=>u.has(c)).map(c=>({path:a,message:`Missing required key "${c}"`}))),f.length===0||i?{ok:!0,value:d}:{ok:!1,errors:f}}function O7n(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>mdf({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>mdf({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>VS.OBJECT};return{...r,...hA(r),...NRt(r),...O7n(r)}}}}function mdf({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=vdf(C_i(t),c=>i.has(c)),f=r(q_i(t,u)),d=n(q_i(t,a));return f.ok&&d.ok?{ok:!0,value:{...f.value,...d.value}}:{ok:!1,errors:[...f.ok?[]:f.errors,...d.ok?[]:d.errors]}}function Odf(e){return!N01(e)}function N01(e){switch(e.getType()){case VS.ANY:case VS.UNKNOWN:case VS.OPTIONAL:return!0;default:return!1}}function Pdf(e){return r0a(e)}function jdf(e){let t={...Glu(e),_getRawProperties:()=>m7n(e)._getRawProperties(),_getParsedProperties:()=>m7n(e)._getParsedProperties()};return{...t,...hA(t),...NRt(t),...O7n(t)}}function n0a(e){let t={parse:(r,n)=>wdf(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],`[${a}]`]})),json:(r,n)=>wdf(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],`[${a}]`]})),getType:()=>VS.LIST};return{...YJ(t),...hA(t)}}function wdf(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:rC(e,"list"),path:[]}]}}function Ddf(e){return XJ(VS.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:rC(r,`"${e}"`)}]})()}function Sdf(e){return XJ(VS.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:rC(r,`${e.toString()}`)}]})()}var Edf=XJ(VS.ANY,e=>({ok:!0,value:e}));var Mdf=XJ(VS.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"boolean")}]});var xdf=XJ(VS.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"number")}]});var Tdf=XJ(VS.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"string")}]});var qdf=XJ(VS.UNKNOWN,e=>({ok:!0,value:e}));function Adf(e,t){let r={parse:(n,i)=>Cdf({value:n,isKeyNumeric:e.getType()===VS.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...(i==null?void 0:i.breadcrumbsPrefix)??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...i,breadcrumbsPrefix:[...(i==null?void 0:i.breadcrumbsPrefix)??[],`${u}`]}),breadcrumbsPrefix:i==null?void 0:i.breadcrumbsPrefix}),json:(n,i)=>Cdf({value:n,isKeyNumeric:e.getType()===VS.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...(i==null?void 0:i.breadcrumbsPrefix)??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...i,breadcrumbsPrefix:[...(i==null?void 0:i.breadcrumbsPrefix)??[],`${u}`]}),breadcrumbsPrefix:i==null?void 0:i.breadcrumbsPrefix}),getType:()=>VS.RECORD};return{...YJ(r),...hA(r)}}function Cdf({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return O5r(e)?T_i(e).reduce((a,[u,f])=>{if(f==null)return a;let d=a,c=u;if(t){let O=u.length>0?Number(u):NaN;isNaN(O)||(c=O)}let o=r(c),l=n(f,c);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let g=[];return d.ok||g.push(...d.errors),o.ok||g.push(...o.errors),l.ok||g.push(...l.errors),{ok:!1,errors:g}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:rC(e,"object")}]}}function Ndf(e){let t=n0a(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:(i==null?void 0:i.breadcrumbsPrefix)??[],message:rC(n,"Set")}]},getType:()=>VS.SET};return{...YJ(r),...hA(r)}}function Bdf(e){let t={parse:(r,n)=>zdf((i,a)=>i.parse(r,a),e,n),json:(r,n)=>zdf((i,a)=>i.json(r,a),e,n),getType:()=>VS.UNDISCRIMINATED_UNION};return{...YJ(t),...hA(t)}}function zdf(e,t,r){let n=[];for(let[i,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let f of u.errors)n.push({path:f.path,message:`[Variant ${i}] ${f.message}`})}return{ok:!1,errors:n}}function Idf(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Fdf(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=t0a(C_i(t)),a={parse:(u,f)=>Rdf({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:f==null?void 0:f.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(f==null?void 0:f.breadcrumbsPrefix)??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f==null?void 0:f.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.parse(d,f),breadcrumbsPrefix:f==null?void 0:f.breadcrumbsPrefix}),json:(u,f)=>Rdf({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:f==null?void 0:f.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(f==null?void 0:f.breadcrumbsPrefix)??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f==null?void 0:f.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.json(d,f),breadcrumbsPrefix:f==null?void 0:f.breadcrumbsPrefix}),getType:()=>VS.UNION};return{...YJ(a),...hA(a),...NRt(a)}}function Rdf({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!O5r(e))return{ok:!1,errors:[{path:f,message:rC(e,"object")}]};let{[t]:d,...c}=e;if(d==null)return{ok:!1,errors:[{path:f,message:`Missing discriminant ("${t}")`}]};let o=n(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=i(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...c}}:{ok:!1,errors:[{path:[...f,t],message:"Unexpected discriminant value"}]};let g=u(c,l);return g.ok?{ok:!0,value:{[r]:d,...g.value}}:g}var j1=Wn.objectWithoutOptionalProperties({title:Wn.string().optional()});var i0a=Wn.objectWithoutOptionalProperties({file:Wn.string()});var a0a=Wn.objectWithoutOptionalProperties({file:Wn.string()});var o0a=Wn.union("type",{openapi:i0a,protobuf:a0a}).transform({transform:e=>{switch(e.type){case"openapi":return HSr.openapi(e);case"protobuf":return HSr.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var hb=Wn.objectWithoutOptionalProperties({source:o0a.optional()});var u0a=Wn.objectWithoutOptionalProperties({typeName:Wn.string()});var s0a=Wn.union("type",{protobuf:u0a}).transform({transform:e=>{switch(e.type){case"protobuf":return b7n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ene=Wn.objectWithoutOptionalProperties({encoding:s0a.optional()});var O_=Wn.objectWithoutOptionalProperties({description:Wn.string().optional()});var c0a=Wn.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Z0=Wn.objectWithoutOptionalProperties({availability:c0a.optional()});var Ym=Wn.objectWithoutOptionalProperties({nameOverride:Wn.string().optional(),generatedName:Wn.string()});var wQ=Wn.string();var Kje=Wn.string();var l0a=Wn.objectWithoutOptionalProperties({id:Kje}).extend(O_);var f0a=Wn.string();var d0a=Wn.objectWithoutOptionalProperties({usernameVariableName:Wn.string().optional(),usernameEnvVar:Wn.string().optional(),passwordVariableName:Wn.string().optional(),passwordEnvVar:Wn.string().optional()});var p0a=Wn.objectWithoutOptionalProperties({tokenVariableName:Wn.string().optional(),tokenEnvVar:Wn.string().optional()});var _0a=Wn.objectWithoutOptionalProperties({headerName:Wn.string(),prefix:Wn.string().optional(),headerVariableName:Wn.string().optional(),headerEnvVar:Wn.string().optional()});var h0a=Wn.objectWithoutOptionalProperties({queryParameterName:Wn.string()});var y0a=Wn.objectWithoutOptionalProperties({snake:Wn.string().optional(),camel:Wn.string().optional(),screamingSnake:Wn.string().optional(),pascal:Wn.string().optional()});var j5r=Wn.objectWithoutOptionalProperties({nameOverride:Wn.string().optional(),generatedName:Wn.string(),value:Wn.string(),casing:y0a.optional()}).extend(O_).extend(Z0);var v0a=Wn.objectWithoutOptionalProperties({type:Wn.stringLiteral("namespace"),name:Wn.string()});var b0a=Wn.undiscriminatedUnion([Wn.string(),v0a]);var w5r=Wn.list(b0a);var w1=Wn.objectWithoutOptionalProperties({groupName:w5r.optional()});var P7n=Wn.objectWithoutOptionalProperties({default:j5r.optional(),values:Wn.list(j5r)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var g0a=Wn.objectWithoutOptionalProperties({scopesEnum:P7n.optional()});var m0a=Wn.union("type",{basic:d0a,bearer:p0a,header:_0a,query:h0a,oauth:g0a}).transform({transform:e=>{switch(e.type){case"basic":return F9.basic(e);case"bearer":return F9.bearer(e);case"header":return F9.header(e);case"query":return F9.query(e);case"oauth":return F9.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var D5r=Wn.number();var O0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),url:Wn.string(),audiences:Wn.list(Wn.string()).optional()}).extend(O_);var P0a=Wn.string();var S5r=Wn.objectWithoutOptionalProperties({namespace:Wn.string().optional()});var Xlu={};Wb(Xlu,{FullExample:()=>yA,FullObjectExample:()=>w0a,FullOneOfExample:()=>S0a,KeyValuePair:()=>D0a,LiteralExample:()=>j0a,PrimitiveExample:()=>w7n,PropertyKey:()=>j7n});var j7n=Wn.string();var w7n=Wn.union("type",{int:Wn.object({value:Wn.number()}),int64:Wn.object({value:Wn.number()}),uint:Wn.object({value:Wn.number()}),uint64:Wn.object({value:Wn.number()}),float:Wn.object({value:Wn.number()}),double:Wn.object({value:Wn.number()}),string:Wn.object({value:Wn.string()}),datetime:Wn.object({value:Wn.string()}),date:Wn.object({value:Wn.string()}),base64:Wn.object({value:Wn.string()}),boolean:Wn.object({value:Wn.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return t0.int(e.value);case"int64":return t0.int64(e.value);case"uint":return t0.uint(e.value);case"uint64":return t0.uint64(e.value);case"float":return t0.float(e.value);case"double":return t0.double(e.value);case"string":return t0.string(e.value);case"datetime":return t0.datetime(e.value);case"date":return t0.date(e.value);case"base64":return t0.base64(e.value);case"boolean":return t0.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var j0a=Wn.union("type",{boolean:Wn.object({value:Wn.boolean()}),string:Wn.object({value:Wn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return g7n.boolean(e.value);case"string":return g7n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var yA=Wn.union("type",{primitive:Wn.object({value:w7n}),object:Wn.lazyObject(()=>w0a),array:Wn.object({value:Wn.list(Wn.lazy(()=>yA))}),map:Wn.object({value:Wn.list(Wn.lazyObject(()=>D0a))}),enum:Wn.object({value:Wn.string()}),literal:Wn.object({value:j0a}),oneOf:Wn.object({value:Wn.lazy(()=>S0a)}),unknown:Wn.object({value:Wn.lazy(()=>yA)})}).transform({transform:e=>{switch(e.type){case"primitive":return RP.primitive(e.value);case"object":return RP.object(e);case"array":return RP.array(e.value);case"map":return RP.map(e.value);case"enum":return RP.enum(e.value);case"literal":return RP.literal(e.value);case"oneOf":return RP.oneOf(e.value);case"unknown":return RP.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var w0a=Wn.objectWithoutOptionalProperties({properties:Wn.record(j7n,Wn.lazy(()=>yA))});var D0a=Wn.objectWithoutOptionalProperties({key:w7n,value:Wn.lazy(()=>yA)});var S0a=Wn.union("type",{discriminated:Wn.object({value:Wn.record(j7n,Wn.lazy(()=>yA))}),undisciminated:Wn.object({value:Wn.lazy(()=>yA)})}).transform({transform:e=>{switch(e.type){case"discriminated":return v5r.discriminated(e.value);case"undisciminated":return v5r.undisciminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Qlu={};Wb(Qlu,{AllOfPropertyConflict:()=>I7n,ArraySchema:()=>fva,Availability:()=>c0a,BooleanSchema:()=>ava,CasingOverrides:()=>y0a,CommonProperty:()=>gva,CursorPagination:()=>H0a,CustomCodeSample:()=>V0a,CustomCodeSampleLanguage:()=>F0a,CustomCodeSampleSdk:()=>U0a,DiscriminatedOneOfSchema:()=>vva,DoubleSchema:()=>nva,Endpoint:()=>J0a,EndpointExample:()=>N7n,EndpointSdkName:()=>M5r,EnumSchema:()=>P7n,EnumValue:()=>j5r,ErrorExample:()=>z0a,FernExample:()=>I0a,FileResponse:()=>T7n,FileSchema:()=>x0a,FullEndpointExample:()=>W0a,GlobalHeader:()=>uva,Header:()=>E5r,HeaderExample:()=>A7n,HttpEndpointServer:()=>q7n,HttpError:()=>B0a,HttpMethod:()=>D7n,IdempotencyHeader:()=>sva,IntSchema:()=>tva,JsonRequest:()=>C0a,JsonResponse:()=>KSr,LiteralSchema:()=>B7n,LiteralSchemaValue:()=>cva,LongSchema:()=>rva,MapSchema:()=>dva,MultipartRequest:()=>x7n,MultipartRequestProperty:()=>q0a,MultipartSchema:()=>T0a,NullableSchema:()=>_va,ObjectProperty:()=>yva,ObjectPropertyConflictInfo:()=>R7n,ObjectSchema:()=>lva,OctetStreamRequest:()=>M7n,OffsetPagination:()=>$0a,OneOfSchema:()=>hva,OpenApiIntermediateRepresentation:()=>Ldf,OptionalSchema:()=>pva,Pagination:()=>z7n,PathParameter:()=>S7n,PathParameterExample:()=>R0a,PrimitiveSchema:()=>T5r,PrimitiveSchemaValue:()=>ova,QueryParameter:()=>E7n,QueryParameterExample:()=>C7n,ReferencedSchema:()=>zRt,Request:()=>A0a,Response:()=>N0a,Schema:()=>D1,Schemas:()=>eva,SdkGroupInfo:()=>E0a,StringSchema:()=>iva,SupportedSdkLanguage:()=>L0a,Tags:()=>M0a,TextResponse:()=>x5r,UnDiscriminatedOneOfSchema:()=>bva,Webhook:()=>Y0a,WebhookExampleCall:()=>K0a,WebhookHttpMethod:()=>G0a,WebsocketChannel:()=>k0a,WebsocketHandshake:()=>X0a,WebsocketMessageExample:()=>Q0a,WebsocketSessionExample:()=>Z0a});var E0a=Wn.objectWithoutOptionalProperties({summary:Wn.string().optional(),description:Wn.string().optional()});var M0a=Wn.objectWithoutOptionalProperties({tagsById:Wn.record(Kje,l0a),orderedTagIds:Wn.list(Kje).optional()});var D7n=Wn.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var S7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),variableReference:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var E7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var E5r=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),env:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var M5r=Wn.objectWithoutOptionalProperties({groupName:w5r,methodName:Wn.string()});var M7n=Wn.objectWithoutOptionalProperties({}).extend(O_).extend(hb);var x0a=Wn.objectWithoutOptionalProperties({isOptional:Wn.boolean(),isArray:Wn.boolean()});var T0a=Wn.union("type",{file:x0a,json:Wn.object({value:Wn.lazy(()=>D1)})}).transform({transform:e=>{switch(e.type){case"file":return D2e.file(e);case"json":return D2e.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var q0a=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:T0a,contentType:Wn.string().optional()}).extend(O_);var x7n=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),properties:Wn.list(q0a)}).extend(O_).extend(hb);var C0a=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1),contentType:Wn.string().optional(),additionalProperties:Wn.boolean()}).extend(O_).extend(hb);var A0a=Wn.union("type",{octetStream:M7n,multipart:x7n,json:C0a}).transform({transform:e=>{switch(e.type){case"octetStream":return b5r.octetStream(e);case"multipart":return b5r.multipart(e);case"json":return b5r.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var T7n=Wn.objectWithoutOptionalProperties({}).extend(O_).extend(hb);var KSr=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1),responseProperty:Wn.string().optional()}).extend(O_).extend(hb);var x5r=Wn.objectWithoutOptionalProperties({}).extend(O_).extend(hb);var N0a=Wn.union("type",{file:T7n,json:KSr,text:x5r,streamingSse:KSr,streamingText:x5r,streamingJson:KSr}).transform({transform:e=>{switch(e.type){case"file":return Sne.file(e);case"json":return Sne.json(e);case"text":return Sne.text(e);case"streamingSse":return Sne.streamingSse(e);case"streamingText":return Sne.streamingText(e);case"streamingJson":return Sne.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var z0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),description:Wn.string().optional(),example:Wn.lazy(()=>yA)});var B0a=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1).optional(),examples:Wn.list(z0a).optional()}).extend(O_).extend(Ym).extend(hb);var q7n=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),url:Wn.string().optional(),audiences:Wn.list(Wn.string()).optional()});var I0a=Wn.unknown();var R0a=Wn.objectWithoutOptionalProperties({name:Wn.string(),parameterNameOverride:Wn.string().optional(),value:Wn.lazy(()=>yA)});var C7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),value:Wn.lazy(()=>yA)});var A7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),value:Wn.lazy(()=>yA)});var F0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),language:Wn.string(),code:Wn.string(),install:Wn.string().optional()}).extend(O_);var L0a=Wn.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var U0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),sdk:L0a,code:Wn.string()}).extend(O_);var V0a=Wn.union("type",{language:F0a,sdk:U0a}).transform({transform:e=>{switch(e.type){case"language":return JSr.language(e);case"sdk":return JSr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var W0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),pathParameters:Wn.list(R0a).optional(),queryParameters:Wn.list(C7n).optional(),headers:Wn.list(A7n).optional(),request:Wn.lazy(()=>yA).optional(),response:Wn.lazy(()=>yA).optional(),codeSamples:Wn.list(V0a)}).extend(O_);var N7n=Wn.union("type",{unknown:Wn.object({value:I0a}),full:W0a}).transform({transform:e=>{switch(e.type){case"unknown":return pAt.unknown(e.value);case"full":return pAt.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var H0a=Wn.objectWithoutOptionalProperties({cursor:Wn.string(),nextCursor:Wn.property("next_cursor",Wn.string()),results:Wn.string()});var $0a=Wn.objectWithoutOptionalProperties({offset:Wn.string(),results:Wn.string(),step:Wn.string().optional(),hasNextPage:Wn.string().optional()});var z7n=Wn.union("type",{cursor:H0a,offset:$0a}).transform({transform:e=>{switch(e.type){case"cursor":return $Sr.cursor(e);case"offset":return $Sr.offset(e);default:return e}},untransform:({_visit:e,...t})=>t});var J0a=Wn.objectWithoutOptionalProperties({authed:Wn.boolean(),internal:Wn.boolean().optional(),idempotent:Wn.boolean().optional(),method:D7n,audiences:Wn.list(Wn.string()),path:Wn.string(),summary:Wn.string().optional(),operationId:Wn.string().optional(),tags:Wn.list(Kje),pathParameters:Wn.list(S7n),queryParameters:Wn.list(E7n),headers:Wn.list(E5r),sdkName:M5r.optional(),generatedRequestName:Wn.string(),requestNameOverride:Wn.string().optional(),request:A0a.optional(),response:N0a.optional(),errors:Wn.record(D5r,B0a),server:Wn.list(q7n),examples:Wn.list(N7n),pagination:z7n.optional()}).extend(O_).extend(Z0).extend(hb).extend(S5r);var G0a=Wn.enum_(["GET","POST"]);var K0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),payload:Wn.lazy(()=>yA)}).extend(O_);var Y0a=Wn.objectWithoutOptionalProperties({sdkName:M5r.optional(),method:G0a,summary:Wn.string().optional(),operationId:Wn.string(),tags:Wn.list(Kje),headers:Wn.list(E5r),generatedPayloadName:Wn.string(),payload:Wn.lazy(()=>D1),examples:Wn.list(K0a)}).extend(O_).extend(hb).extend(S5r);var X0a=Wn.objectWithoutOptionalProperties({queryParameters:Wn.list(E7n),headers:Wn.list(E5r),pathParameters:Wn.list(S7n)});var Q0a=Wn.objectWithoutOptionalProperties({messageType:Wn.string(),payload:Wn.lazy(()=>yA)}).extend(O_);var Z0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),queryParameters:Wn.list(C7n).optional(),headers:Wn.list(A7n).optional(),messages:Wn.list(Q0a)}).extend(O_);var k0a=Wn.objectWithoutOptionalProperties({path:Wn.string(),groupName:w5r,summary:Wn.string().optional(),handshake:X0a,publish:Wn.lazy(()=>D1).optional(),subscribe:Wn.lazy(()=>D1).optional(),examples:Wn.list(Z0a)}).extend(O_).extend(hb);var eva=Wn.objectWithoutOptionalProperties({rootSchemas:Wn.record(wQ,Wn.lazy(()=>D1)),namespacedSchemas:Wn.record(P0a,Wn.record(wQ,Wn.lazy(()=>D1)))});var tva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),minimum:Wn.number().optional(),maximum:Wn.number().optional(),exclusiveMinimum:Wn.boolean().optional(),exclusiveMaximum:Wn.boolean().optional(),multipleOf:Wn.number().optional()});var rva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional()});var nva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),minimum:Wn.number().optional(),maximum:Wn.number().optional(),exclusiveMinimum:Wn.boolean().optional(),exclusiveMaximum:Wn.boolean().optional(),multipleOf:Wn.number().optional()});var iva=Wn.objectWithoutOptionalProperties({default:Wn.string().optional(),pattern:Wn.string().optional(),format:Wn.string().optional(),minLength:Wn.number().optional(),maxLength:Wn.number().optional()});var ava=Wn.objectWithoutOptionalProperties({default:Wn.boolean().optional()});var ova=Wn.union("type",{int:tva,int64:rva,uint:Wn.object({}),uint64:Wn.object({}),float:Wn.object({}),double:nva,string:iva,datetime:Wn.object({}),date:Wn.object({}),base64:Wn.object({}),boolean:ava}).transform({transform:e=>{switch(e.type){case"int":return Xw.int(e);case"int64":return Xw.int64(e);case"uint":return Xw.uint();case"uint64":return Xw.uint64();case"float":return Xw.float();case"double":return Xw.double(e);case"string":return Xw.string(e);case"datetime":return Xw.datetime();case"date":return Xw.date();case"base64":return Xw.base64();case"boolean":return Xw.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var T5r=Wn.objectWithoutOptionalProperties({schema:ova}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var uva=Wn.objectWithoutOptionalProperties({header:Wn.string(),name:Wn.string().optional(),optional:Wn.boolean().optional(),env:Wn.string().optional(),schema:Wn.lazy(()=>D1).optional()});var sva=Wn.objectWithoutOptionalProperties({header:Wn.string(),name:Wn.string().optional(),env:Wn.string().optional(),schema:Wn.lazy(()=>D1).optional()});var Ldf=Wn.objectWithoutOptionalProperties({apiVersion:Wn.unknown().optional(),title:Wn.string().optional(),description:Wn.string().optional(),basePath:Wn.string().optional(),servers:Wn.list(O0a),groups:Wn.record(Wn.string(),E0a),tags:M0a,hasEndpointsMarkedInternal:Wn.boolean(),endpoints:Wn.list(J0a),webhooks:Wn.list(Y0a),channel:Wn.list(k0a),groupedSchemas:eva,variables:Wn.record(Wn.string(),T5r),nonRequestReferencedSchemas:Wn.set(wQ),securitySchemes:Wn.record(f0a,m0a),globalHeaders:Wn.list(uva).optional(),idempotencyHeaders:Wn.list(sva).optional()});var zRt=Wn.objectWithoutOptionalProperties({schema:wQ}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var cva=Wn.union("type",{boolean:Wn.object({value:Wn.boolean()}),string:Wn.object({value:Wn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return E7.boolean(e.value);case"string":return E7.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var B7n=Wn.objectWithoutOptionalProperties({value:cva}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var D1=Wn.union("type",{primitive:T5r,object:Wn.lazyObject(()=>lva),array:Wn.lazyObject(()=>fva),map:Wn.lazyObject(()=>dva),optional:Wn.lazyObject(()=>pva),enum:P7n,reference:zRt,literal:B7n,oneOf:Wn.object({value:Wn.lazy(()=>hva)}),nullable:Wn.lazyObject(()=>_va),unknown:Ym}).transform({transform:e=>{switch(e.type){case"primitive":return ib.primitive(e);case"object":return ib.object(e);case"array":return ib.array(e);case"map":return ib.map(e);case"optional":return ib.optional(e);case"enum":return ib.enum(e);case"reference":return ib.reference(e);case"literal":return ib.literal(e);case"oneOf":return ib.oneOf(e.value);case"nullable":return ib.nullable(e);case"unknown":return ib.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var I7n=Wn.objectWithoutOptionalProperties({propertyKey:Wn.string(),allOfSchemaIds:Wn.list(wQ),conflictingTypeSignatures:Wn.boolean()});var lva=Wn.objectWithoutOptionalProperties({allOf:Wn.list(zRt),properties:Wn.list(Wn.lazyObject(()=>yva)),allOfPropertyConflicts:Wn.list(I7n),additionalProperties:Wn.boolean()}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var R7n=Wn.objectWithoutOptionalProperties({differentSchema:Wn.boolean()});var yva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>D1),conflict:Wn.record(wQ,R7n),generatedName:Wn.string(),nameOverride:Wn.string().optional(),audiences:Wn.list(Wn.string())}).extend(Z0);var fva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var dva=Wn.objectWithoutOptionalProperties({key:T5r,value:Wn.lazy(()=>D1)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(j1);var pva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var _va=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var hva=Wn.union("type",{discriminated:Wn.lazyObject(()=>vva),undisciminated:Wn.lazyObject(()=>bva)}).transform({transform:e=>{switch(e.type){case"discriminated":return GSr.discriminated(e);case"undisciminated":return GSr.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var vva=Wn.objectWithoutOptionalProperties({discriminantProperty:Wn.string(),commonProperties:Wn.list(Wn.lazyObject(()=>gva)),schemas:Wn.record(Wn.string(),Wn.lazy(()=>D1))}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var gva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>D1)});var bva=Wn.objectWithoutOptionalProperties({schemas:Wn.list(Wn.lazy(()=>D1))}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var Zlu={};Wb(Zlu,{ArraySchemaWithExample:()=>Lva,Base64WithExample:()=>zva,BooleanWithExample:()=>Bva,CommonPropertyWithExample:()=>Yva,DateWithExample:()=>Nva,DatetimeWithExample:()=>Ava,DiscriminatedOneOfSchemaWithExample:()=>Gva,DoubleWithExample:()=>qva,EndpointWithExample:()=>Vdf,EnumSchemaWithExample:()=>Rva,FloatWithExample:()=>Tva,HeaderWithExample:()=>L7n,HttpErrorWithExample:()=>Dva,Int64WithExample:()=>Eva,IntWithExample:()=>Sva,JsonRequestWithExample:()=>Ova,JsonResponseWithExample:()=>jva,MapSchemaWithExample:()=>Uva,NamedFullExample:()=>BRt,NullableSchemaWithExample:()=>Wva,ObjectPropertyWithExample:()=>Jva,ObjectSchemaWithExample:()=>Hva,OneOfSchemaWithExample:()=>$va,OptionalSchemaWithExample:()=>Vva,PathParameterWithExample:()=>mva,PrimitiveSchemaValueWithExample:()=>Iva,PrimitiveSchemaWithExample:()=>U7n,QueryParameterWithExample:()=>F7n,RequestWithExample:()=>Pva,ResponseWithExample:()=>wva,SchemaWithExample:()=>aq,StringSchemaWithExample:()=>Cva,Uint64WithExample:()=>xva,UintWithExample:()=>Mva,UnDiscriminatedOneOfSchemaWithExample:()=>Kva,UnknownSchemaWithExample:()=>Fva,WebsocketHandshakeWithExample:()=>Udf});var BRt=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),value:Wn.unknown()}).extend(O_);var F7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>aq),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var L7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>aq),env:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var Udf=Wn.objectWithoutOptionalProperties({queryParameters:Wn.list(F7n),headers:Wn.list(L7n)});var mva=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>aq),variableReference:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var Ova=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>aq),contentType:Wn.string().optional(),fullExamples:Wn.list(BRt).optional(),additionalProperties:Wn.boolean()}).extend(O_).extend(hb);var Pva=Wn.union("type",{octetStream:M7n,multipart:x7n,json:Ova}).transform({transform:e=>{switch(e.type){case"octetStream":return S2e.octetStream(e);case"multipart":return S2e.multipart(e);case"json":return S2e.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var jva=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>aq),responseProperty:Wn.string().optional(),fullExamples:Wn.list(BRt).optional()}).extend(O_).extend(hb);var wva=Wn.union("type",{file:T7n,json:jva,text:x5r,streamingSse:KSr,streamingText:x5r,streamingJson:KSr}).transform({transform:e=>{switch(e.type){case"file":return T3.file(e);case"json":return T3.json(e);case"text":return T3.text(e);case"streamingSse":return T3.streamingSse(e);case"streamingText":return T3.streamingText(e);case"streamingJson":return T3.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Dva=Wn.objectWithoutOptionalProperties({statusCode:D5r,schema:Wn.lazy(()=>aq),fullExamples:Wn.list(BRt).optional()}).extend(O_).extend(Ym).extend(hb);var Vdf=Wn.objectWithoutOptionalProperties({authed:Wn.boolean(),internal:Wn.boolean().optional(),idempotent:Wn.boolean().optional(),method:D7n,audiences:Wn.list(Wn.string()),path:Wn.string(),summary:Wn.string().optional(),operationId:Wn.string().optional(),tags:Wn.list(Kje),pathParameters:Wn.list(mva),queryParameters:Wn.list(F7n),headers:Wn.list(L7n),sdkName:M5r.optional(),generatedRequestName:Wn.string(),requestNameOverride:Wn.string().optional(),request:Pva.optional(),response:wva.optional(),errors:Wn.record(D5r,Dva),server:Wn.list(q7n),examples:Wn.list(N7n),pagination:z7n.optional()}).extend(O_).extend(Z0).extend(hb).extend(S5r);var Sva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),minimum:Wn.number().optional(),maximum:Wn.number().optional(),exclusiveMinimum:Wn.boolean().optional(),exclusiveMaximum:Wn.boolean().optional(),multipleOf:Wn.number().optional(),example:Wn.number().optional()});var Eva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var Mva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var xva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var Tva=Wn.objectWithoutOptionalProperties({example:Wn.number().optional()});var qva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),minimum:Wn.number().optional(),maximum:Wn.number().optional(),exclusiveMinimum:Wn.boolean().optional(),exclusiveMaximum:Wn.boolean().optional(),multipleOf:Wn.number().optional(),example:Wn.number().optional()});var Cva=Wn.objectWithoutOptionalProperties({default:Wn.string().optional(),pattern:Wn.string().optional(),format:Wn.string().optional(),minLength:Wn.number().optional(),maxLength:Wn.number().optional(),example:Wn.string().optional()});var Ava=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var Nva=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var zva=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var Bva=Wn.objectWithoutOptionalProperties({default:Wn.boolean().optional(),example:Wn.boolean().optional()});var Iva=Wn.union("type",{int:Sva,int64:Eva,uint:Mva,uint64:xva,float:Tva,double:qva,string:Cva,datetime:Ava,date:Nva,base64:zva,boolean:Bva}).transform({transform:e=>{switch(e.type){case"int":return by.int(e);case"int64":return by.int64(e);case"uint":return by.uint(e);case"uint64":return by.uint64(e);case"float":return by.float(e);case"double":return by.double(e);case"string":return by.string(e);case"datetime":return by.datetime(e);case"date":return by.date(e);case"base64":return by.base64(e);case"boolean":return by.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var U7n=Wn.objectWithoutOptionalProperties({schema:Iva}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var Rva=Wn.objectWithoutOptionalProperties({default:j5r.optional(),values:Wn.list(j5r),example:Wn.string().optional()}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var Fva=Wn.objectWithoutOptionalProperties({example:Wn.unknown()}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(j1);var aq=Wn.union("type",{primitive:U7n,object:Wn.lazyObject(()=>Hva),array:Wn.lazyObject(()=>Lva),map:Wn.lazyObject(()=>Uva),optional:Wn.lazyObject(()=>Vva),enum:Rva,reference:zRt,literal:B7n,oneOf:Wn.object({value:Wn.lazy(()=>$va)}),nullable:Wn.lazyObject(()=>Wva),unknown:Fva}).transform({transform:e=>{switch(e.type){case"primitive":return Lp.primitive(e);case"object":return Lp.object(e);case"array":return Lp.array(e);case"map":return Lp.map(e);case"optional":return Lp.optional(e);case"enum":return Lp.enum(e);case"reference":return Lp.reference(e);case"literal":return Lp.literal(e);case"oneOf":return Lp.oneOf(e.value);case"nullable":return Lp.nullable(e);case"unknown":return Lp.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var Lva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>aq),example:Wn.list(Wn.unknown()).optional()}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(j1);var Uva=Wn.objectWithoutOptionalProperties({key:U7n,value:Wn.lazy(()=>aq),example:Wn.unknown().optional()}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(Ene).extend(j1);var Vva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>aq)}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(j1);var Wva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>aq)}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(j1);var Hva=Wn.objectWithoutOptionalProperties({allOf:Wn.list(zRt),properties:Wn.list(Wn.lazyObject(()=>Jva)),allOfPropertyConflicts:Wn.list(I7n),fullExamples:Wn.list(BRt).optional(),additionalProperties:Wn.boolean()}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var Jva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>aq),audiences:Wn.list(Wn.string()),conflict:Wn.record(wQ,R7n),nameOverride:Wn.string().optional(),generatedName:Wn.string()}).extend(Z0);var $va=Wn.union("type",{discriminated:Wn.lazyObject(()=>Gva),undisciminated:Wn.lazyObject(()=>Kva)}).transform({transform:e=>{switch(e.type){case"discriminated":return jQ.discriminated(e);case"undisciminated":return jQ.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Gva=Wn.objectWithoutOptionalProperties({discriminantProperty:Wn.string(),commonProperties:Wn.list(Wn.lazyObject(()=>Yva)),schemas:Wn.record(Wn.string(),Wn.lazy(()=>aq))}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var Yva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>aq)});var Kva=Wn.objectWithoutOptionalProperties({schemas:Wn.list(Wn.lazy(()=>aq))}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);function Xva(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Ol(e.type)}}function V7n(e){switch(e.type){case"object":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":case"primitive":return e.groupName??void 0;case"oneOf":return e.value.groupName??void 0;case"unknown":return;default:Ol(e)}}function A2(e){return typeof e=="string"?e:e.type}function A_i(e){if(typeof e!="string")return e.docs}function Wdf(e){if(typeof e!="string")return e.default}function Hdf(e){if(typeof e!="string")return e.validation}function z01(e){let t=e.find(n=>typeof n=="object"&&n.type==="namespace"),r=e.filter(n=>typeof n=="string"||n.type!=="namespace");return t?[t,...r]:r}function $df(e){var n;let t=e?z01(e):void 0;if(t==null||t.length===0)return zui;let r=[];for(let[i,a]of t.entries())if(typeof a=="string")r.push(FE(a));else if(typeof a=="object")switch(a.type){case"namespace":{i<t.length-1?r.push(FE(a.name)):r.push(a.name,zui);break}default:Ol(a.type)}else Ol(a);if(((n=r[-1])==null?void 0:n.toLowerCase())==="v1")throw new Error(`[TESTING HERE] ${JSON.stringify(e)}, ${JSON.stringify(r)}`);return r.join("/")}function W7n(e){return zs.of(`${$df(e)}.yml`)}function klu({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?zui:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,$df(r))}function Jdf({sdkName:e,namespaceOverride:t}){return zs.of(`${klu({sdkName:e,namespaceOverride:t})}.yml`)}function Gdf({location:e,namespaceOverride:t}){return t!=null?pf(zs.of(t),e):e}function q3(e){switch(e){case vW.Deprecated:return"deprecated";case vW.Beta:return"pre-release";case vW.GenerallyAvailable:return"generally-available";default:return}}var B01=-2147483648,I01=2147483647,R01=-17976931348623157e292,F01=17976931348623157e292;function S1({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i}){switch(e.type){case"primitive":return Qva(e);case"array":return rfu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"map":return nfu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"reference":return tfu({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return afu();case"optional":case"nullable":return ifu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"enum":return K01({schema:e,fileContainingReference:t,context:n,declarationFile:r});case"literal":return e.value,ofu(e);case"object":return Y01({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"oneOf":return X01({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i});default:Ol(e)}}function Qva(e){switch(e.schema.type){case"string":return V01({description:e.description,schema:e.schema});case"int":return W01({description:e.description,schema:e.schema});case"float":return H01({description:e.description,schema:e.schema});case"double":return $01({description:e.description,schema:e.schema});case"boolean":return L01({description:e.description,schema:e.schema});case"int64":return U01({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{...e.title!=null?{"display-name":e.title}:{},type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function L01({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function U01({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function V01({description:e,schema:t}){let r="string",n=J01(t);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function W01({description:e,schema:t}){let r="integer",n=Kdf(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function H01({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function $01({description:e,schema:t}){let r="double",n=Kdf(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function J01(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=G01(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function G01(e){switch(e){case"date":case"date-time":case"password":case"byte":case"bytes":case"binary":case"email":case"uuid":case"uri":case"hostname":case"ipv4":case"ipv6":return e;default:return}}function Kdf(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=efu(r,t),n=efu(n,t),i=efu(i,t),!(r==null&&n==null&&a==null&&u==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:u,multipleOf:i}}function efu(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[B01,I01]:[R01,F01];return e<r||e>n?void 0:e}function tfu({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=Q01(i)??e.schema,u=V7n(i),f=Z01(i),d=Zva({context:r,fileContainingReference:t,declarationFile:W7n(u),type:a}),c=i.type==="nullable"?`optional<${d}>`:d;return e.description==null&&f==null?c:{...f!=null?{"display-name":f}:{},type:i.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function rfu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=S1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=`list<${A2(a)}>`;return e.description==null&&e.title==null?u:{...e.title!=null?{"display-name":e.title}:{},...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{},type:u}}function nfu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Qva(e.key),u=S1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),f=e.encoding!=null?Xva(e.encoding):void 0,d=`map<${A2(a)}, ${A2(u)}>`;if(e.description==null&&f==null&&e.title==null)return d;let c={type:d};return e.description!=null&&(c.docs=e.description),e.encoding!=null&&(c.encoding=f),e.title!=null&&(c["display-name"]=e.title),e.availability!=null&&(c.availability=q3(e.availability)),c}function ifu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=S1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=A2(a),f=A_i(a),d=Wdf(a),c=Hdf(a),o=u.startsWith("optional<")?u:`optional<${u}>`;if(e.availability==null&&e.description==null&&f==null&&d==null&&c==null&&e.title==null)return o;let l={type:o};return(e.description!=null||f!=null)&&(l.docs=e.description??f),d!=null&&(l.default=d),c!=null&&(l.validation=c),e.title!=null&&(l["display-name"]=e.title),e.availability!=null&&(l.availability=q3(e.availability)),l}function afu(){return"unknown"}function ofu(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Ol(e.value)}return e.description==null&&e.title==null?t:{...e.title!=null?{"display-name":e.title}:{},type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function K01({schema:e,fileContainingReference:t,declarationFile:r,context:n}){let i=N_i(e),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:i.schema});let u=Zva({type:a,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return u;let f={type:u};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.title!=null&&(f["display-name"]=e.title),e.availability!=null&&(f.availability=q3(e.availability)),f}function Y01({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=ufu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=Zva({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{...e.title!=null?{"display-name":e.title}:{},type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function X01({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=sfu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=Zva({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{...e.title!=null?{"display-name":e.title}:{},type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function Zva({type:e,fileContainingReference:t,declarationFile:r,context:n}){if(r===t)return e;let i=n.builder.addImport({file:t,fileToImport:r});return i!=null?`${i}.${e}`:e}function Q01(e){return ib._visit(e,{primitive:t=>t.nameOverride??t.generatedName,object:t=>t.nameOverride??t.generatedName,array:t=>t.nameOverride??t.generatedName,map:t=>t.nameOverride??t.generatedName,enum:t=>t.nameOverride??t.generatedName,reference:t=>t.nameOverride??t.generatedName,literal:t=>t.nameOverride??t.generatedName,oneOf:t=>t.nameOverride??t.generatedName,optional:t=>t.nameOverride??t.generatedName,nullable:t=>t.nameOverride??t.generatedName,unknown:t=>t.nameOverride??t.generatedName,_other:()=>{}})}function Z01(e){return ib._visit(e,{primitive:t=>t.title,object:t=>t.title,array:t=>t.title,map:t=>t.title,enum:t=>t.title,reference:t=>t.title,literal:t=>t.title,oneOf:t=>t.title,optional:t=>t.title,nullable:t=>t.title,unknown:t=>{},_other:()=>{}})}function Ien(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Ol(e)}}function Xdf({schema:e,context:t,declarationFile:r,namespace:n}){switch(e.type){case"primitive":return tv1(e);case"array":return k01({schema:e,context:t,declarationFile:r,namespace:n});case"map":return ev1({schema:e,context:t,declarationFile:r,namespace:n});case"reference":return rv1({schema:e,context:t,declarationFile:r,namespace:n});case"unknown":return iv1(e.nameOverride,e.generatedName);case"optional":case"nullable":return nv1({schema:e,context:t,declarationFile:r,namespace:n});case"enum":return N_i(e);case"literal":return av1(e,e.nameOverride,e.generatedName);case"object":return ufu({schema:e,context:t,declarationFile:r,namespace:n});case"oneOf":return sfu({schema:e.value,context:t,declarationFile:r,namespace:n});default:Ol(e)}}function ufu({schema:e,context:t,declarationFile:r,namespace:n}){let i={},a=new Set;for(let c of e.properties){if(Object.keys(c.conflict).length>0){if(Object.entries(c.conflict).every(([S,x])=>!x.differentSchema))continue;Object.entries(c.conflict).forEach(([S])=>{cfu({property:c.key,schemaId:S,context:t,namespace:n}).forEach(A=>{a.add(A)})})}let o=S1({schema:c.schema,context:t,fileContainingReference:r,namespace:n}),l=c.audiences,g=c.nameOverride,O=q3(c.availability);i[c.key]=sv1(o,l,g,O)}let u=new Set;for(let c of e.allOfPropertyConflicts)c.allOfSchemaIds.forEach(o=>a.add(o)),c.conflictingTypeSignatures&&u.add(c.propertyKey);let f=[];for(let c of e.allOf){let o=Qdf({schema:c.schema,context:t,namespace:n});if(o==null||a.has(c.schema)||a.has(o))continue;let l=S1({schema:ib.reference(c),context:t,fileContainingReference:r,namespace:n});f.push(A2(l))}for(let c of a){let o=lfu(t,c,n);for(let l of o.properties)i[l.key]==null&&(u.has(l.key)&&(i[l.key]="unknown"),i[l.key]=S1({schema:l.schema,context:t,fileContainingReference:r,namespace:n}));for(let l of o.allOf){if(a.has(l.schema))continue;let g=S1({schema:ib.reference(l),context:t,fileContainingReference:r,namespace:n});f.push(A2(g))}}let d={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(i).map(([c,o])=>uv1(c)?[c,typeof o=="string"?{type:o,name:`_${c}`}:{...o,name:`_${c}`}]:[c,o]))};return f.length>0&&(d.extends=f),e.additionalProperties&&(d["extra-properties"]=!0),e.availability!=null&&(d.availability=q3(e.availability)),e.source!=null&&(d.source=Ien(e.source)),{name:e.nameOverride??e.generatedName,schema:d}}function cfu({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return cfu({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:u}=lfu(r,t,n),f=a.some(c=>c.key===e),d=[...u.flatMap(c=>cfu({property:e,context:r,schemaId:c.schema,namespace:n}))];if(f||d.length>0)return[t,...d]}return[]}function lfu(e,t,r){let n=e.getSchema(t,r);if(n==null)return{properties:[],allOf:[]};if(n.type==="object")return{properties:n.properties,allOf:n.allOf};if(n.type==="reference")return lfu(e,n.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${n.type}`)}function k01({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:rfu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function ev1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:nfu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function tv1(e){let t=Qva(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...n}=t;return{name:e.nameOverride??e.generatedName,schema:{...n}}}function Ydf(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function N_i(e){let t={enum:e.values.map(i=>{let a=i.nameOverride??i.generatedName,u=i.value;if(a===u&&i.description==null&&(i.casing==null||Ydf(i.casing)))return a;let f={value:i.value};if(a!==u&&(f.name=a),i.description!=null&&(f.docs=i.description),i.casing!=null&&!Ydf(i.casing)){let d={},c=!1;i.casing.camel!=null&&(d.camel=i.casing.camel,c=!0),i.casing.screamingSnake!=null&&(d["screaming-snake"]=i.casing.screamingSnake,c=!0),i.casing.snake!=null&&(d.snake=i.casing.snake,c=!0),i.casing.pascal!=null&&(d.pascal=i.casing.pascal,c=!0),c&&(f.casing=d)}return f})};e.description!=null&&(t.docs=e.description),e.default!=null&&(t.default=e.default.value);let r=new Set,n={...t,enum:[],source:e.source!=null?Ien(e.source):void 0};for(let i of t.enum){let a=typeof i=="string"?i:i.name??i.value;r.has(a.toLowerCase())||(n.enum.push(i),r.add(a.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function rv1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:tfu({schema:e,context:t,fileContainingReference:r,namespace:n})}}function nv1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:ifu({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n})}}function iv1(e,t){return{name:e??t,schema:afu()}}function av1(e,t,r){return{name:t??r,schema:ofu(e)}}function sfu({schema:e,context:t,declarationFile:r,namespace:n}){let i=e.encoding!=null?Xva(e.encoding):void 0;if(e.type==="discriminated"){let u={};for(let d of e.commonProperties)u[d.key]=S1({schema:d.schema,fileContainingReference:r,context:t,namespace:n});let f={};for(let[d,c]of Object.entries(e.schemas))f[d]=S1({schema:c,context:t,fileContainingReference:r,namespace:n});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":u,docs:e.description??void 0,availability:e.availability!=null?q3(e.availability):void 0,union:f,encoding:i,source:e.source!=null?Ien(e.source):void 0}}}let a=[];for(let u of e.schemas)a.push(S1({schema:u,fileContainingReference:r,context:t,namespace:n}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:a,encoding:i,source:e.source!=null?Ien(e.source):void 0}}}var ov1=/^[0-9]/;function uv1(e){return ov1.test(e)}function Qdf({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?Qdf({context:t,schema:n.schema,namespace:r}):e}function sv1(e,t,r,n){return t.length===0&&r==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{}}}function Zdf(e){let t=e.replace(/^x-|^X-/,"");return FE(t)}var kdf="BasicAuthScheme",kva="BearerAuthScheme";function epf(e){if(e.authOverrides!=null){for(let[r,n]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:n});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,n]of Object.entries(e.ir.securitySchemes))if(n.type==="basic"){let i={scheme:"basic"};n.usernameVariableName!=null&&(i.username===void 0?i.username={name:n.usernameVariableName}:i.username.name=n.usernameVariableName),n.usernameEnvVar!=null&&(i.username===void 0?i.username={env:n.usernameEnvVar}:i.username.env=n.usernameEnvVar),n.passwordVariableName!=null&&(i.password===void 0?i.password={name:n.passwordVariableName}:i.password.name=n.passwordVariableName),n.passwordEnvVar!=null&&(i.password===void 0?i.password={env:n.passwordEnvVar}:i.password.env=n.passwordEnvVar),e.builder.addAuthScheme({name:kdf,schema:i}),t||(e.builder.setAuth(kdf),t=!0)}else if(n.type==="bearer"){let i={scheme:"bearer"};n.tokenVariableName!=null&&(i.token===void 0?i.token={name:n.tokenVariableName}:i.token.name=n.tokenVariableName),n.tokenEnvVar!=null&&(i.token===void 0?i.token={env:n.tokenEnvVar}:i.token.env=n.tokenEnvVar),e.builder.addAuthScheme({name:kva,schema:i}),t||(e.builder.setAuth(kva),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??Zdf(n.headerName),env:n.headerEnvVar}});else{let i={header:n.headerName,name:n.headerVariableName??"apiKey",type:"string"};n.headerEnvVar!=null&&(i.env=n.headerEnvVar),n.prefix!=null&&(i.prefix=n.prefix),e.builder.addAuthScheme({name:r,schema:i}),e.builder.setAuth(r),t=!0}else if(n.type==="oauth"){let i={scheme:"bearer"};e.builder.addAuthScheme({name:kva,schema:i}),t||(e.builder.setAuth(kva),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(zs.of("__package__.yml"),{name:"OauthScope",schema:N_i(n.scopesEnum).schema})}}function IRt({header:e,context:t,fileContainingReference:r,namespace:n}){let i=S1({schema:e.schema,context:t,fileContainingReference:r,namespace:n}),a=A2(i),u=e.name.replace(/^x-|^X-/,""),f=e.parameterNameOverride!=null?e.parameterNameOverride:FE(u);if(e.description==null&&e.name===f&&e.env==null&&e.availability==null)return a;let d={type:a};return f!==e.name&&(d.name=f),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=q3(e.availability)),d}function eba({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=S1({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(e.variableReference==null&&e.description==null&&e.availability==null)return A2(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:A2(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=q3(e.availability)),a}var Zmu=require("fs/promises");var tpf={naming:"v1"};function Lh(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function RRt(e,t,r,n,i=[]){try{let a=Lh(e,t);if(a!=null)return r.parse(a)}catch{let u=X8t(i).join(" -> ");n.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}var tba={of(e){return e}};var kh={SDK_METHOD_NAME:tba.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:tba.of("x-fern-sdk-group-name"),REQUEST_NAME_V1:"x-request-name",REQUEST_NAME_V2:"x-fern-request-name",TYPE_NAME:"x-fern-type-name",BOOLEAN_LITERAL:"x-fern-boolean-literal",SERVER_NAME_V1:"x-name",SERVER_NAME_V2:"x-fern-server-name",BASE_PATH:"x-fern-base-path",GROUPS:tba.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport"};function gy(e){return e.$ref!=null}function E2e(e){switch(Lh(e,kh.AVAILABILITY)){case"deprecated":return vW.Deprecated;case"beta":return vW.Beta;case"generally-available":return vW.GenerallyAvailable;default:break}if(!gy(e)&&e.deprecated)return vW.Deprecated}var Yje={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};function rpf({schema:e,logger:t}){return RRt(e,kh.ENCODING,h5.EncodingSchema,t)??void 0}function npf(e){return Lh(e,kh.FERN_ENUM)}function ipf({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:a}){let u=Lh(n,kh.SDK_GROUP_NAME),f=Lh(n,kh.TYPE_DEFINITION);if(f!=null)return z_i({fernType:f,nameOverride:e,generatedName:t,title:r,description:i,availability:a,groupName:typeof u=="string"?[u]:u})}function z_i({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u}){return IJ({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.base64({example:void 0})});case"BOOLEAN":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.boolean({default:void 0,example:void 0})});case"DATE":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.date({example:void 0})});case"DATE_TIME":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.datetime({example:void 0})});case"FLOAT":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.float({example:void 0})});case"DOUBLE":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.double({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.uint({default:void 0,example:void 0})});case"INTEGER":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.int({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT_64":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.uint64({default:void 0,example:void 0})});case"LONG":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Ol(f.v1)}},unknown:()=>Lp.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:a,groupName:u}),map:({keyType:f,valueType:d})=>(f==null?void 0:f.type)==="primitive"&&d!=null?Lp.map({nameOverride:t,generatedName:r,title:n,key:f,value:d,description:i,availability:a,groupName:u,encoding:void 0,example:void 0}):void 0,list:f=>f!=null?Lp.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,optional:f=>f!=null?Lp.optional({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u}):void 0,set:f=>f!=null?Lp.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,literal:f=>Lp.literal({nameOverride:t,generatedName:r,title:n,value:f._visit({string:d=>E7.string(d),boolean:d=>E7.boolean(d),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:a,groupName:u}),named:()=>{}}})}function Ren(e){if(e!=null&&typeof e=="boolean")return e}function apf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,encoding:l,source:g,namespace:O}){return typeof i=="boolean"||H7n(i)?rba({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:by.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Lp.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:void 0}),groupName:c,example:o,encoding:l}):rba({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:by.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:L1(i,d.options.optionalAdditionalProperties?f:!1,d,[...n,"Value"],g,O),groupName:c,example:o,encoding:l})}function rba({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsNullable:a,description:u,availability:f,groupName:d,example:c,encoding:o}){return a?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.map({nameOverride:e,generatedName:t,title:r,description:u,availability:n.availability,key:n,value:i,groupName:d,encoding:o,example:c}),description:u,availability:f,groupName:d}):Lp.map({nameOverride:e,generatedName:t,title:r,description:u,availability:f,key:n,value:i,groupName:d,encoding:o,example:c})}function H7n(e){return e==null?!1:typeof e=="boolean"?e:!gy(e)&&Object.keys(e).length===0}function opf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,source:l,namespace:g}){let O=i==null?Lp.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,groupName:c}):L1(i,!1,d,[...n,"Item"],l,g);return cv1({nameOverride:e,generatedName:t,title:r,groupName:c,itemSchema:O,wrapAsNullable:f,description:a,availability:u,example:o})}function cv1({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsNullable:i,description:a,availability:u,groupName:f,example:d}){return i?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d}),description:a,availability:u,groupName:f}):Lp.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d})}function ffu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminator:c,context:o,groupName:l,encoding:g,source:O,namespace:j}){let S=c.propertyName,x=Object.fromEntries(Object.entries(c.mapping??{}).map(([z,N])=>{let C=$7n({$ref:N},!1,o,[N],g,O,j);return o.markReferencedByDiscriminatedUnion({$ref:N},S,1),[z,C]})),A=Object.entries(i).filter(([z])=>z!==S).map(([z,N])=>{let C=f!=null&&f.includes(z),U=L1(N,!C,o,[...n,z],O,j);return{key:z,schema:U}});return upf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:A,description:a,availability:u,discriminant:S,subtypes:x,groupName:l,source:O})}function dfu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminant:c,variants:o,context:l,groupName:g,encoding:O,source:j,namespace:S}){let x=Object.fromEntries(Object.entries(o).map(([z,N])=>{if(gy(N)){let C=$7n(N,!1,l,[N.$ref],O,j,S);return l.markReferencedByDiscriminatedUnion(N,c,1),[z,C]}else{let C=q5r(N,!1,l,[...n,z],O,j,S,new Set([c]));return[z,C]}})),A=Object.entries(i).filter(([z])=>z!==c).map(([z,N])=>{let C=f!=null&&f.includes(z),U=L1(N,!C,l,[...n,z],j,S);return{key:z,schema:U}});return upf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:A,description:a,availability:u,discriminant:c,subtypes:x,groupName:g,source:j})}function upf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,availability:u,discriminant:f,subtypes:d,groupName:c,source:o}){return n?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.oneOf(jQ.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o})),groupName:c,description:a,availability:u}):Lp.oneOf(jQ.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o}))}function spf(e){if(e.proto!=null)return b7n.protobuf({typeName:e.proto.type})}var lv1=/^(\d+)/;function nba(e){let t=e.match(lv1);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=J7n(i);return n.length>0?`${a}_${n}`:a}}}function J7n(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","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),f=e%10;return f===0?n[u]:`${n[u]}_${t[f]}`}if(e<1e3){let u=Math.floor(e/100),f=e%100;return f===0?`${t[u]}_hundred`:`${t[u]}_hundred_${J7n(f)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${J7n(a)}`}var G7n=/^[a-zA-Z][a-zA-Z0-9_]*$/;function C5r({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:a,_default:u,description:f,availability:d,wrapAsNullable:c,groupName:o,context:l,source:g}){let O=pv1(i??[]),j=new Set(a),S=Array.from(j).map((A,z)=>{var G,$,ee,Ve;let N=n==null?void 0:n[A],C=O[z],U=G7n.test(A),Y=(N==null?void 0:N.name)??C,te=U?A:B_i(A);return Y!=null&&!G7n.test(Y)&&(l==null||l.logger.warn(`Enum name override ${Y} is not a valid name. Falling back on ${te}.`),Y=void 0),{nameOverride:Y,generatedName:te,value:A,description:N==null?void 0:N.description,availability:d,casing:{snake:((G=N==null?void 0:N.casing)==null?void 0:G.snake)??void 0,pascal:(($=N==null?void 0:N.casing)==null?void 0:$.pascal)??void 0,screamingSnake:((ee=N==null?void 0:N.casing)==null?void 0:ee.screamingSnake)??void 0,camel:((Ve=N==null?void 0:N.casing)==null?void 0:Ve.camel)??void 0}}}),x=u!=null?S.find(A=>A.value===u):void 0;return fv1({wrapAsNullable:c,nameOverride:e,generatedName:t,title:r,values:S,_default:x,description:f,availability:d,groupName:o,source:g})}function fv1({wrapAsNullable:e,nameOverride:t,generatedName:r,title:n,values:i,_default:a,description:u,availability:f,groupName:d,source:c}){return e?Lp.nullable({nameOverride:t,generatedName:r,title:n,value:Lp.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,default:a,availability:f,example:void 0,groupName:d,source:c}),description:u,availability:f,groupName:d}):Lp.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,availability:f,default:a,example:void 0,groupName:d,source:c})}var dv1={"<":"LESS_THAN",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL_TO","<=":"LESS_THAN_OR_EQUAL_TO","!=":"NOT_EQUALS","=":"EQUAL_TO","==":"EQUAL_TO","*":"ALL","":"EMPTY",'""':"EMPTY_STRING","-":"HYPHEN","|":"PIPE",".":"DOT","/":"SLASH"};function B_i(e){let t=nba(e),r=dv1[e];return t!=null?qV(FE(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":qV(FE(e)))}function pv1(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(n=>n[r]===t[r]);)r++;return e.map(n=>n.substring(r))}function cpf({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:g,example:O,groupName:j}){return n==="int64"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.int64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="uint32"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.uint({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="uint64"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.uint64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):L9({nameOverride:e,generatedName:t,title:r,primitive:by.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j})}function lpf(e){return typeof e=="string"?E7.string(e):typeof e=="boolean"?E7.boolean(e):E7.string(`${e}`)}function fpf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,value:i,description:a,availability:u,groupName:f}){return n?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.literal({nameOverride:e,generatedName:t,title:r,value:lpf(i),description:a,availability:u,groupName:f}),description:a,availability:u,groupName:f}):Lp.literal({nameOverride:e,generatedName:t,title:r,value:lpf(i),description:a,availability:u,groupName:f})}function pfu({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:g,example:O,groupName:j}){return n==null||n==="double"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.double({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="float"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.float({example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="int32"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="int64"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.int64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="uint32"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.uint({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="uint64"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.uint64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="time-delta"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.float({example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):L9({nameOverride:e,generatedName:t,title:r,primitive:by.float({example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j})}var _v1={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},hv1={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="responses",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},yv1={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="parameters",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),e[0]==="schema"&&(e=e.slice(1)),{refUnderProcessing:e,newBreadcrumbs:t}}},vv1={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},bv1={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},gv1={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},mv1={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},Ov1={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function iba(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[_v1,hv1,yv1,vv1,bv1,gv1,mv1,Ov1],i;do{i=t;for(let a of n)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:f}=a.applyStrategy(t);t=u,r=[...r,...f]}}while(t.join("")!==i.join(""));return r}function yR(e){let t=e.join("_"),r=qV(FE(t));return/^\d/.test(r)?nba(r)??r:r}function _fu(e){let t=e.join("_");return FE(t)}function oq(e){switch(e.type){case"object":return ib.object({allOf:e.allOf,properties:e.properties.map(t=>jv1(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return ib.array({description:e.description,availability:e.availability,value:oq(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"enum":return ib.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,groupName:e.groupName,source:e.source});case"literal":return ib.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"nullable":return ib.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:oq(e.value),groupName:e.groupName});case"optional":return ib.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:oq(e.value),groupName:e.groupName});case"primitive":return ib.primitive({description:e.description,availability:e.availability,schema:dpf(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return ib.map({description:e.description,availability:e.availability,key:ib.primitive({description:e.key.description,availability:e.key.availability,schema:dpf(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:oq(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,encoding:e.encoding});case"reference":return ib.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,groupName:e.groupName,source:e.source});case"oneOf":return ib.oneOf(Pv1(e.value));case"unknown":return ib.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Ol(e)}}function Pv1(e){switch(e.type){case"discriminated":return GSr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:oq(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,oq(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return GSr.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>oq(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:Ol(e)}}function dpf(e){switch(e.type){case"string":return Xw.string(e);case"base64":return Xw.base64();case"boolean":return Xw.boolean(e);case"date":return Xw.date();case"datetime":return Xw.datetime();case"double":return Xw.double(e);case"float":return Xw.float();case"int":return Xw.int(e);case"int64":return Xw.int64(e);case"uint":return Xw.uint();case"uint64":return Xw.uint64();default:Ol(e)}}function jv1(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:oq(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability}}function aba(e,t){return FRt(oq(e),oq(t))}function FRt(e,t){return e.type==="primitive"&&t.type==="primitive"?ppf(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?wv1(e.values,t.values):e.type==="array"&&t.type==="array"?FRt(e.value,t.value):e.type==="unknown"&&t.type==="unknown"?!0:e.type==="reference"&&t.type==="reference"?e.schema===t.schema:e.type==="optional"&&t.type==="optional"?FRt(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?Dv1(e.value,t.value):e.type==="object"&&t.type==="object"?Sv1(e,t):e.type==="map"&&t.type==="map"?ppf(e.key.schema,t.key.schema)&&FRt(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function ppf(e,t){return e.type===t.type}function wv1(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return iDr(r,n)}function Dv1(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,n])=>{let i=t.schemas[r];return i==null?!1:FRt(n,i)}):e.type==="undisciminated"&&t.type==="undisciminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:FRt(r,i)}):!1}function Sv1(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(n=>[n.key,n.schema]));return Object.entries(t.properties).every(([n,i])=>{let a=r[n];return a==null?!1:FRt(a,i.schema)})}function _pf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,required:u,wrapAsNullable:f,allOf:d,context:c,propertiesToExclude:o,groupName:l,fullExamples:g,additionalProperties:O,availability:j,encoding:S,source:x,namespace:A}){let z=[...u??[]],N={...i},C=[],U=[];for(let $ of d)if(gy($)){let ee=c.resolveSchemaReference($);if(ee.discriminator!=null&&ee.discriminator.mapping!=null)continue;if(ee.oneOf!=null){for(let $e of ee.oneOf){let Dt=gy($e)?c.resolveSchemaReference($e):$e,Tt=L1(Dt,!1,c.DUMMY,n,x,A);Tt.type==="object"&&C.push(...Tt.properties.map(Wt=>Wt.schema.type!=="optional"&&Wt.schema.type!=="nullable"?{...Wt,schema:Lp.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Wt.schema,description:void 0,availability:Wt.availability,groupName:void 0})}:Wt))}continue}let Ve=A5r($);if(Ve==null)continue;U.push({schemaId:Ve,convertedSchema:hfu($,[Ve],x),properties:hpf({schema:$,context:c,breadcrumbs:n,source:x,namespace:A})}),c.markSchemaAsReferencedByNonRequest(Ve)}else{let ee=L1($,!1,c,n,x,A);ee.type==="object"&&C.push(...ee.properties)}let Y={};for(let $ of U)for(let[ee,Ve]of Object.entries($.properties)){let $e=Y[ee];$e!=null?($e.schemaIds.push($.schemaId),$e.schemas.some(Tt=>aba(Tt,Ve))||$e.schemas.push(Ve)):Y[ee]={schemaIds:[$.schemaId],schemas:[Ve]}}let te=[];for(let[$,ee]of Object.entries(Y))ee.schemaIds.length>1&&te.push({propertyKey:$,allOfSchemaIds:ee.schemaIds,conflictingTypeSignatures:ee.schemas.length>1});let G=Object.entries(N).map(([$,ee])=>{let Ve=z.includes($),$e=Lh(ee,kh.AUDIENCES)??[],Dt=E2e(ee),Tt=Lh(ee,kh.FERN_PROPERTY_NAME),Wt=[...n,$],Nt=_fu(Wt),ur=Ve?L1(ee,!1,c,Wt,x,A):Lp.optional({nameOverride:e,generatedName:Nt,title:r,description:void 0,availability:Dt,value:L1(ee,!1,c,Wt,x,A),groupName:l}),Ar={};for(let Gr of U){let zt=Gr.properties[$];zt!=null&&!aba(ur,zt)?Ar[Gr.schemaId]={differentSchema:!0}:zt!=null&&(Ar[Gr.schemaId]={differentSchema:!1})}return{key:$,schema:ur,nameOverride:Tt,audiences:$e,conflict:Ar,generatedName:_fu([...n,$]),availability:Dt}});return G.push(...C.map($=>{let ee=$.conflict;for(let Ve of U){let $e=Ve.properties[$.key];$e!=null&&!aba($.schema,$e)?ee[Ve.schemaId]={differentSchema:!0}:$e!=null&&(ee[Ve.schemaId]={differentSchema:!1})}return{...$,conflict:ee}})),Ev1({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,properties:G.filter($=>!o.has($.key)),description:a,allOf:U.map($=>$.convertedSchema),allOfPropertyConflicts:te,groupName:l,fullExamples:g,additionalProperties:O,availability:j,source:x})}function Ev1({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:o,availability:l,source:g}){return n?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:H7n(o),availability:void 0,source:g}),description:a,availability:l,groupName:d}):Lp.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:H7n(o),availability:l,source:g})}function hpf({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[u,f]=gy(e)?[t.resolveSchemaReference(e),iba(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...hpf({schema:d,context:t,breadcrumbs:f,source:n,namespace:i})};for(let[d,c]of Object.entries(u.properties??{})){let o=L1(c,!1,t,[...f,d],n,i);a[d]=o}return a}function K7n({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:a,wrapAsNullable:u,context:f,subtypes:d,groupName:c,encoding:o,source:l,subtypePrefixOverrides:g,namespace:O}){let j=Mv1({schemas:d}),S=d.flatMap((z,N)=>{if(!gy(z)&&z.enum!=null)return z.enum.map(U=>Lp.literal({nameOverride:void 0,generatedName:yR([t,U]),title:void 0,value:E7.string(U),groupName:void 0,description:void 0,availability:U.availability}));let C=j[N];if(g!=null){let U=g[N];U!=null&&"name"in U&&(C=U.name)}return[L1(z,!1,f,[...n,C??`${N}`],l,O)]}),x=[];for(let z=0;z<S.length;++z){let N=S[z],C=!1;for(let U=z+1;U<S.length;++U){let Y=S[U];if(N!=null&&Y!=null&&FRt(N,Y)){C=!0;break}}N!=null&&!C&&x.push(N)}if(Object.entries(x).every(([z,N])=>N.type==="literal")){let z={},N=[];return Object.entries(x).forEach(([C,U])=>{U.type==="literal"&&U.value.type==="string"&&(N.push(U.value.value),U.description!=null&&(z[U.value.value]={description:U.description}))}),C5r({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,fernEnum:z,enumVarNames:void 0,enumValues:N,_default:void 0,groupName:c,context:f,source:l})}return x.length===1&&x[0]!=null?x[0]:ypf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,subtypes:x,groupName:c,encoding:o,source:l})}function yfu({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsNullable:a,context:u,groupName:f,discriminator:d,encoding:c,source:o,namespace:l}){let g=Object.entries(d.mapping??{}).map(([S,x],A)=>{let z={$ref:x},N=$7n(z,!1,u,[x],c,o,l);return u.markSchemaWithDiscriminantValue(z,d.propertyName,S),N.type==="object"&&(N.properties={[d.propertyName]:Lp.literal({nameOverride:void 0,generatedName:yR([t,S]),title:void 0,value:E7.string(S),groupName:void 0,description:void 0,availability:void 0}),...N.properties.filter(C=>C.key!==d.propertyName)}),N}),O=[];for(let S=0;S<g.length;++S){let x=g[S],A=!1;for(let z=S+1;z<g.length;++z){let N=g[z];if(x!=null&&N!=null&&FRt(x,N)){A=!0;break}}x!=null&&!A&&O.push(x)}if(Object.entries(O).every(([S,x])=>x.type==="literal")){let S={},x=[];return Object.entries(O).forEach(([A,z])=>{z.type==="literal"&&z.value.type==="string"&&(x.push(z.value.value),z.description!=null&&(S[z.value.value]={description:z.description}))}),C5r({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,fernEnum:S,enumVarNames:void 0,enumValues:x,_default:void 0,groupName:f,context:u,source:o})}return O.length===1&&O[0]!=null?O[0]:ypf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,subtypes:O,groupName:f,encoding:c,source:o})}function Mv1({schemas:e}){let t={},r=0;for(let a of e){if(!gy(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),f={},d=u;for(let[c,o]of Object.entries(t)){let l=CXi(o,u);d=CXi(d,o),f[c]=l}f[r]=d,t=f}}r++}let n=[],i=0;for(let a of e){let u=t[i];if(u!=null&&u.length>0){let f=u.sort();if(f[0]!=null){n.push(f[0]),++i;continue}}gy(a)?n.push(J7n(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(J7n(i)??`${i}`),++i}return n}function ypf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,description:i,availability:a,subtypes:u,groupName:f,encoding:d,source:c}){return n?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.oneOf(jQ.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c})),description:i,availability:a,groupName:f}):Lp.oneOf(jQ.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c}))}function Y7n(e){if(e.default!=null&&typeof e.default=="string")return e.default}function oba({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;if(r&&typeof r=="number")return r;r&&t.warn(`Expected fallback to be a number, but got ${typeof r}`)}function vpf({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;if(r&&typeof r=="boolean")return r;r&&t.warn(`Expected fallback to be a boolean, but got ${typeof r}`)}function LRt({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;if(r&&typeof r=="string")return r;r&&t.warn(`Expected fallback to be a string, but got ${typeof r}`)}function bpf({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;if(r&&Array.isArray(r))return r;r&&t.warn(`Expected fallback to be a array, but got ${typeof r}`)}var Fen="#/components/schemas/";function L1(e,t,r,n,i,a,u=!1,f=new Set,d){let c=zv1({schema:e,logger:r.logger});if(gy(e)){let o=A5r(e);return o!=null?(u?r.markSchemaAsReferencedByRequest(o):r.markSchemaAsReferencedByNonRequest(o),$7n(e,t,r,n,c,i,a)):q5r(r.resolveSchemaReference(e),t,r,iba(e.$ref),c,i,a,f,u,d)}return q5r(e,t,r,n,c,i,a,f,u,d)}function $7n(e,t,r,n,i,a,u){let f=e.$ref.includes("properties")?q5r(r.resolveSchemaReference(e),t,r,n,i,a,u,new Set):Lp.reference(hfu(e,n,a));return t?Lp.nullable({title:void 0,nameOverride:void 0,generatedName:yR(n),value:f,description:void 0,availability:void 0,groupName:void 0}):f}function xv1(e){if(e!=null&&!e.includes(" ")&&!!/^[a-zA-Z]+$/.test(e))return e}function q5r(e,t,r,n,i,a,u,f=new Set,d=!1,c){var C;let o=Lh(e,kh.TYPE_NAME)??(r.options.useTitlesAsName?xv1(e.title):void 0),l=Lh(e,kh.SDK_GROUP_NAME)??((C=Lh(e,Yje.TAGS))==null?void 0:C[0]),g=(typeof l=="string"?[l]:l)??[];g=r.resolveGroupName(g);let O=yR(n),j=e.title,S=e.description,x=E2e(e),A=Lh(e,Yje.EXAMPLES),z=[];e.example!=null&&z.push({name:void 0,value:e.example,description:void 0}),A!=null&&Object.keys(A).length>0&&z.push(...Object.entries(A).map(([U,Y])=>({name:Y.summary??U,value:Y.value,description:Y.description})));let N=ipf({schema:e,description:S,title:j,nameOverride:o,generatedName:O,availability:x});if(N!=null)return N;if(!t&&e.nullable===!0)return q5r(e,!0,r,n,i,a,u,f,d,c);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!I_i(e.enum))return L9({nameOverride:o,generatedName:O,title:j,primitive:by.string({default:Y7n(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:LRt({schema:e,logger:r.logger,fallback:c})}),groupName:g,wrapAsNullable:t,description:S,availability:x});let U=npf(e);return e.enum.length===1&&e.enum[0]!=null&&U==null?fpf({nameOverride:o,generatedName:O,title:j,wrapAsNullable:t,value:e.enum[0],description:S,availability:x,groupName:g}):C5r({nameOverride:o,generatedName:O,title:j,fernEnum:U,enumVarNames:Lh(e,[Yje.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:S,availability:x,wrapAsNullable:t,groupName:g,context:r,source:a})}if(I_i(e.type)&&e.type[1]!=null&&e.type[0]!=null){let U=e.type[0],Y=e.type[1];if(U==="null")return Lp.nullable({nameOverride:o,generatedName:O,title:j,value:q5r({...e,type:Y},t,r,n,i,a,u,f,d,c),groupName:g,description:e.description,availability:x});if(Y==="null")return Lp.nullable({nameOverride:o,generatedName:O,title:j,value:q5r({...e,type:U},t,r,n,i,a,u,f,d,c),groupName:g,description:e.description,availability:x})}if(I_i(e.type)&&e.type.length>1){let U=e.type.includes("null"),Y=e.type.filter(te=>te!=="null").map(te=>({type:te,nullable:U}));return K7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,wrapAsNullable:t,context:r,subtypes:Y,groupName:g,encoding:i,source:a,namespace:u})}if(e==="boolean"||e.type==="boolean"){let U=Lh(e,kh.BOOLEAN_LITERAL);return U!=null?mpf({nameOverride:o,generatedName:O,title:j,literal:E7.boolean(U),wrapAsNullable:t,description:S,availability:x,groupName:g}):L9({nameOverride:o,generatedName:O,title:j,primitive:by.boolean({default:e.default,example:vpf({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:S,availability:x,groupName:g})}if(e==="number"||e.type==="number")return pfu({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Ren(e.exclusiveMinimum),exclusiveMaximum:Ren(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:oba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="integer"||e.type==="integer")return cpf({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Ren(e.exclusiveMinimum),exclusiveMaximum:Ren(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:oba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="float")return pfu({nameOverride:o,generatedName:O,title:j,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Ren(e.exclusiveMinimum),exclusiveMaximum:Ren(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:oba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="string"||e.type==="string"){if(e.format==="date-time")return L9({nameOverride:o,generatedName:O,title:j,primitive:by.datetime({example:LRt({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:S,availability:x,groupName:g});if(e.format==="json-string")return Lp.unknown({nameOverride:o,generatedName:O,title:j,description:S,availability:x,groupName:g,example:void 0});let U=jpf(e,"const");return U!=null?mpf({nameOverride:o,generatedName:O,title:j,literal:E7.string(U),wrapAsNullable:t,description:S,availability:x,groupName:g}):L9({nameOverride:o,generatedName:O,title:j,primitive:by.string({default:Y7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:LRt({schema:e,logger:r.logger,fallback:c})}),groupName:g,wrapAsNullable:t,description:S,availability:x})}if(e.type==="array")return opf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,item:e.items,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,example:bpf({schema:e,logger:r.logger,fallback:c}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&gpf(e))return apf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,additionalProperties:e.additionalProperties,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,encoding:i,example:e.example,source:a,namespace:u});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?yfu({nameOverride:o,generatedName:O,title:j,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):ffu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:g,encoding:i,source:a,namespace:u});if(Array.isArray(e.type)&&(e.oneOf==null?e.oneOf=e.type:e.oneOf.push(...e.type)),e.oneOf!=null&&e.oneOf.length>0){let U=Lh(e,kh.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||U?yfu({nameOverride:o,generatedName:O,title:j,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):ffu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:g,encoding:i,source:a,namespace:u});if(e.oneOf.length===1&&e.oneOf[0]!=null){let Y=L1(e.oneOf[0],t,r,n,a,u,d);return X7n(Y,S,g)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let $=e.oneOf[0],ee=e.oneOf[1];if(!gy($)&&$.type==="null")return L1(ee,!0,r,n,a,u);if(!gy(ee)&&ee.type==="null")return L1($,!0,r,n,a,u)}let Y=Cv1({schemas:e.oneOf});if(Y!=null)return C5r({nameOverride:o,generatedName:O,title:j,fernEnum:void 0,enumVarNames:void 0,enumValues:Y,_default:e.default,description:S,availability:x,wrapAsNullable:t,groupName:g,context:r,source:a});let te=Opf({schemas:e.oneOf,context:r});if(te!=null&&!r.options.discriminatedUnionV2&&!U)return dfu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},required:e.required,description:S,availability:x,wrapAsNullable:t,discriminant:te.discriminant,variants:te.schemas,context:r,groupName:g,encoding:i,source:a,namespace:u});let G=e.oneOf.filter($=>!gy($)&&$.type==="null").length>0;return K7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,wrapAsNullable:t||G,context:r,subtypes:e.oneOf.filter($=>gy($)||$.type!=="null"),encoding:i,groupName:g,source:a,namespace:u})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let te=L1(e.anyOf[0],t,r,n,a,u,d);return X7n(te,S,g)}if(e.anyOf.length===2){let[te,G]=e.anyOf;if(te!=null&&G!=null){if(!gy(te)&&te.type==="null"){let $=L1(G,!0,r,n,a,u);return X7n($,S,g)}else if(!gy(G)&&G.type==="null"){let $=L1(te,!0,r,n,a,u);return X7n($,S,g)}}}let U=Opf({schemas:e.anyOf,context:r});if(U!=null&&!r.options.discriminatedUnionV2)return dfu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},required:e.required,description:S,availability:x,wrapAsNullable:t,discriminant:U.discriminant,variants:U.schemas,context:r,groupName:g,encoding:i,source:a,namespace:u});let Y=e.anyOf.filter(te=>!gy(te)&&te.type==="null").length>0;return K7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,wrapAsNullable:t||Y,context:r,subtypes:e.anyOf.filter(te=>gy(te)||te.type!=="null"),encoding:i,groupName:g,source:a,namespace:u})}if(e.allOf!=null||e.properties!=null){let U=[];for(let te of e.allOf??[])(gy(te)||Object.keys(te).length>0)&&U.push(te);if((e.properties==null||e.properties.length===0)&&U.length===1&&U[0]!=null){let te=L1(U[0],t,r,n,a,u,d);return X7n(te,S,g)}let Y=U.filter(te=>{let G=uba(te);return G||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify(te)}`),G});if((e.properties==null||e.properties.length===0)&&Y.length===1&&Y[0]!=null){let te=L1(Y[0],t,r,n,a,u,d);return X7n(te,S,g)}return _pf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},description:S,required:e.required,wrapAsNullable:t,allOf:Y,context:r,propertiesToExclude:f,groupName:g,fullExamples:z,additionalProperties:e.additionalProperties,availability:x,encoding:i,source:a,namespace:u})}if(e.type==="object"&&Tv1(e)&&qv1(e)&&gpf(e))return rba({nameOverride:o,generatedName:O,title:j,description:S,availability:x,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${O}Key`,title:void 0,description:void 0,availability:void 0,schema:by.string({default:Y7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:LRt({schema:e,logger:r.logger,fallback:c})}),groupName:g},valueSchema:Lp.unknown({nameOverride:void 0,generatedName:`${O}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:g}),groupName:g,encoding:i,example:e.example});if(e.type==null){let U=e.example??e.default;return Lp.unknown({nameOverride:o,generatedName:O,title:j,description:S,availability:x,groupName:g,example:U})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(n)} value=${JSON.stringify(e)}`)}function A5r(e){if(!!e.$ref.startsWith(Fen))return e.$ref.replace(Fen,"")}function hfu(e,t,r){let n=Lh(e,kh.TYPE_NAME),i=yR(t),a=e.description,u=E2e(e),f=A5r(e);if(f==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return ib.reference({generatedName:i,nameOverride:n,title:void 0,schema:f,description:a??void 0,availability:u,groupName:void 0,source:r})}function Tv1(e){return e.oneOf==null||e.oneOf.length===0}function qv1(e){return e.allOf==null||e.allOf.length===0}function gpf(e){return e.properties==null||Object.keys(e.properties).length===0}function I_i(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function X7n(e,t,r){return e.type==="reference"?Lp.reference({...e,description:t,availability:e.availability,groupName:r}):e.type==="optional"?Lp.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e.type==="nullable"?Lp.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e}function uba(e){return gy(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>uba(t)):e.oneOf!=null?e.oneOf.every(t=>uba(t)):e.anyOf!=null?e.anyOf.every(t=>uba(t)):!1}function mpf({literal:e,wrapAsNullable:t,groupName:r,description:n,availability:i,nameOverride:a,generatedName:u,title:f}){return t?Lp.nullable({nameOverride:a,generatedName:u,title:f,value:Lp.literal({nameOverride:a,generatedName:u,title:f,value:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Lp.literal({nameOverride:a,generatedName:u,title:f,value:e,groupName:r,description:n,availability:i})}function L9({primitive:e,wrapAsNullable:t,groupName:r,description:n,availability:i,generatedName:a,nameOverride:u,title:f}){return r=typeof r=="string"?[r]:r,t?Lp.nullable({nameOverride:u,generatedName:a,title:f,value:Lp.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Lp.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r})}function Cv1({schemas:e}){let t=new Set;for(let r of e){if(gy(r))return;if(r.enum!=null&&I_i(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function Opf({schemas:e,context:t}){let r={};for(let n of e){let i=Ppf({schema:n,context:t});for(let[a,u]of Object.entries(i)){let f=r[a];f!=null?f[u]=n:r[a]={[u]:n}}}for(let[n,i]of Object.entries(r))if(Object.keys(i).length===e.length)return{discriminant:n,schemas:i}}function Ppf({schema:e,context:t}){let r=gy(e)?t.resolveSchemaReference(e):e;return Av1({schema:r,context:t})}function Av1({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=Ppf({schema:n,context:t});for(let[a,u]of Object.entries(i??{}))r[a]=u}return r}for(let[n,i]of Object.entries(e.properties??{})){let a=gy(i)?t.resolveSchemaReference(i):i;a.type==="string"&&a.enum!=null&&I_i(a.enum)&&Nv1(a.enum).length===1&&a.enum[0]!=null&&(r[n]=a.enum[0]);let u=jpf(a,"const");a.type==="string"&&u!=null&&(r[n]=u),n==="type"&&a.example!=null&&(r[n]=a.example)}return r}function Nv1(e){if(!e)return[];let t=new Set;return e.forEach(r=>{typeof r=="string"?t.add(r.toLowerCase()):t.add(r)}),Array.from(t)}function jpf(e,t){let r=e[t];if(r!=null)return r}function zv1({schema:e,logger:t}){let r=rpf({schema:e,logger:t});if(r!=null)return spf(r)}function sba(e,t){let r={},n={};return e==null?r=t:n={[e]:t},{rootSchemas:r,namespacedSchemas:n}}var wpf="#/components/messages/",vfu=class{logger;document;taskContext;DUMMY;options;namespace;constructor({document:t,taskContext:r,options:n,namespace:i}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=n,this.namespace=i}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let n=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};n.push(i)}return n.concat(t??[])}resolveSchemaReference(t){var a;if(this.document.components==null||this.document.components.schemas==null||!t.$ref.startsWith(Fen))throw new Error(`Failed to resolve ${t.$ref}`);let n=t.$ref.substring(Fen.length).split("/");if(n[0]==null)throw new Error(`${t.$ref} is undefined`);let i=this.document.components.schemas[n[0]];if(i==null)throw new Error(`${n[0]} is undefined`);if(gy(i)&&(i=this.resolveSchemaReference(i)),n[1]==="properties"&&n[2]!=null){let u=(a=i.properties)==null?void 0:a[n[2]];if(u==null)throw new Error(`${t.$ref} is undefiened. Property does not exist on object.`);gy(u)?i=this.resolveSchemaReference(u):i=u}return i}resolveMessageReference(t){if(this.document.components==null||this.document.components.messages==null||!t.$ref.startsWith(wpf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(wpf.length),n=this.document.components.messages[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}},cba=class extends vfu{constructor({document:t,taskContext:r,options:n,namespace:i}){super({document:t,taskContext:r,options:n,namespace:i})}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,n){}markSchemaWithDiscriminantValue(t,r,n){}};function N5r(e){if(typeof e=="string")return RP.primitive(t0.string(e));if(typeof e=="number")return Number.isInteger(e)?RP.primitive(t0.int(e)):RP.primitive(t0.double(e));if(typeof e=="boolean")return RP.primitive(t0.boolean(e));if(Array.isArray(e)){let t=e.map(r=>N5r(r));return t.length===0?void 0:RP.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,n]of Object.entries(e)){let i=N5r(n);i!=null&&t.push({key:t0.string(r),value:i})}return RP.map(t)}}function R_i(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function Dpf(e){if(e!=null&&Array.isArray(e))return e}var Q7n=class{schemas;constructor(t){this.schemas=t}buildExample({schema:t,exampleId:r,example:n,options:i}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:n,options:{...i,maxCheckerDepth:i.maxCheckerDepth??5},depth:0})}buildExampleHelper({exampleId:t,example:r,schema:n,depth:i,visitedSchemaIds:a,options:u}){var f,d,c,o;switch(n.type){case"enum":return typeof r=="string"&&Spf({schema:n,value:r})?RP.enum(r):n.values[0]!=null?RP.enum((f=n.values[0])==null?void 0:f.value):void 0;case"literal":return RP.literal(n.value);case"nullable":{if(r==null&&!this.hasExample(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let l=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u});return l!=null&&l.type==="array"&&l.value.length===0||l!=null&&l.type==="map"&&l.value.length===0||l!=null&&l.type==="object"&&Object.keys(l.properties).length===0?void 0:l}case"optional":{if(r==null&&!this.hasExample(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let l=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u});return l!=null&&l.type==="array"&&l.value.length===0||l!=null&&l.type==="map"&&l.value.length===0||l!=null&&l.type==="object"&&Object.keys(l.properties).length===0?void 0:l}case"primitive":{let l=this.buildExampleFromPrimitive({schema:n.schema,example:r,options:u});return RP.primitive(l)}case"reference":{let l=this.schemas[n.schema];if(l!=null&&!a.has(n.schema)){a.add(n.schema);let g=this.buildExampleHelper({example:r,schema:l,exampleId:t,visitedSchemaIds:a,depth:i,options:u});return a.delete(n.schema),g}return}case"oneOf":switch(n.value.type){case"discriminated":{let l={},g={},O={},j=R_i(r),S=j==null?void 0:j[n.value.discriminantProperty],x=n.value.schemas[S],A=[],z=this.getDiscriminatedUnionVariantSchema(n.value,j);z!=null&&A.push(z),A.push(...Object.entries(n.value.schemas));for(let N of A)if(S!=null&&x!=null&&x.type==="object"){g=this.getAllProperties(x),O=this.getAllRequiredProperties(x),l[n.value.discriminantProperty]=RP.primitive(t0.string(S));break}else{let C=this.getObjectSchema(N[1]);if(C==null)continue;g=this.getAllProperties(C),O=this.getAllRequiredProperties(C),l[n.value.discriminantProperty]=RP.primitive(t0.string(N[0]))}for(let N of n.value.commonProperties){g[N.key]=N.schema;let C=this.getResolvedSchema(N.schema);C.type!=="optional"&&C.type!=="nullable"&&(O[N.key]=N.schema)}for(let[N,C]of Object.entries(g)){let U=N in O;if(U&&(j==null?void 0:j[N])!=null){let Y=this.buildExampleHelper({schema:C,exampleId:t,example:j[N],visitedSchemaIds:a,depth:i+1,options:u});if(Y!=null)l[N]=Y;else return}else{let Y=this.buildExampleHelper({exampleId:t,schema:C,example:j==null?void 0:j[N],visitedSchemaIds:a,depth:i+1,options:u});if(Y!=null)l[N]=Y;else if(U)return}}return RP.oneOf(v5r.discriminated(l))}case"undisciminated":{let l=this.getUnDiscriminatedUnionVariantSchema(n.value,r);if(l!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:l,visitedSchemaIds:a,depth:i,options:u});break}}return;case"unknown":if(r!=null){let l=N5r(r);if(l!=null)return RP.unknown(l)}return u.ignoreOptionals||this.exceedsMaxDepth(i,u)?void 0:u.isParameter?RP.primitive(t0.string(u.name??"string")):RP.map([{key:t0.string("key"),value:RP.primitive(t0.string("value"))}]);case"array":{let l=Dpf(r),g=[];if(l!=null&&l.length>0)for(let O of l){let j=this.buildExampleHelper({exampleId:t,example:O,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u});j!=null&&g.push(j)}else if(n.example!=null&&n.example.length>0)for(let O of n.example){let j=this.buildExampleHelper({exampleId:t,example:O,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u});j!=null&&g.push(j)}else{let O=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u});O!=null&&g.push(O)}return RP.array(g)}case"map":{let l=R_i(r??n.example);if(l!=null&&Object.entries(l).length>0){let j=[];for(let[S,x]of Object.entries(l)){let A=this.buildExampleFromPrimitive({schema:n.key.schema,example:S,options:u}),z=this.buildExampleHelper({exampleId:t,example:x,schema:n.value,visitedSchemaIds:a,depth:i+1,options:u});z!=null&&j.push({key:A,value:z})}return RP.map(j)}if(n.key.schema.type==="string"&&n.value.type==="unknown")return RP.map([{key:t0.string("key"),value:RP.unknown(RP.primitive(t0.string("value")))}]);let g=this.buildExampleFromPrimitive({schema:n.key.schema,example:void 0,options:{...u,name:"key"}}),O=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,visitedSchemaIds:a,depth:i+1,options:{...u,name:"value"}});return O!=null?RP.map([{key:g,value:O}]):RP.map([])}case"object":{let l={},g=((d=n.fullExamples)==null?void 0:d.find(x=>x.name===t))??((c=n.fullExamples)==null?void 0:c.find(x=>x.name==null))??((o=n.fullExamples)==null?void 0:o[0]),O=R_i(r)??(g!=null?R_i(g.value):{})??{},j=this.getAllProperties(n),S=this.getAllRequiredProperties(n);for(let[x,A]of Object.entries(j)){let z=x in S,N=Object.keys(O).includes(x),C=this.buildExampleHelper({schema:A,exampleId:t,example:O[x],visitedSchemaIds:a,depth:i+1,options:{...u,name:x}});if(z&&C!=null)l[x]=C;else{if(z)return;(N&&C!=null||!u.ignoreOptionals&&C!=null)&&(l[x]=C)}}return RP.object({properties:l})}default:Ol(n)}}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let n=r==null?void 0:r[t.discriminantProperty];if(n==null||typeof n!="string")return Object.entries(t.schemas)[0];let i=t.schemas[n];return i==null?Object.entries(t.schemas)[0]:[n,i]}getUnDiscriminatedUnionVariantSchema(t,r){var a;return r==null?t.schemas[0]:(a=t.schemas.map(u=>({schema:u,heuristic:this.calcExampleHeuristic(u,r)})).sort((u,f)=>f.heuristic-u.heuristic)[0])==null?void 0:a.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return Spf({schema:t,value:r})?5:0;case"object":{if(!RO(r))return 0;let n=this.getAllProperties(t),i=0;for(let[a,u]of Object.entries(n))r[a]!=null?(i++,i+=this.calcExampleHeuristic(u,r[a])):i--;return i}case"array":{if(!Array.isArray(r))return 0;let n=0;for(let i of r)n+=this.calcExampleHeuristic(t.value,i);return n}case"map":{if(!RO(r))return 0;let n=0;for(let[,i]of Object.entries(r))n+=this.calcExampleHeuristic(t.value,i);return n}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let n=this.getResolvedSchema(t);return n==null?0:this.calcExampleHeuristic(n,r)}case"oneOf":return Object.values(t.value.schemas).map(i=>this.calcExampleHeuristic(i,r)).sort((i,a)=>a-i)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,n=new Set,i){if(this.exceedsMaxCheckerDepth(r,i))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,n,i);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,n,i);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let u of t.properties)if(this.hasExample(u.schema,r+1,n,i))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!n.has(t.schema)){n.add(t.schema);let u=this.hasExample(a,r,n,i);return n.delete(t.schema),u}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,n,i));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let n of t.properties)r[n.key]=n.schema;for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let n of t.properties){let i=this.getResolvedSchema(n.schema);i.type!=="optional"&&i.type!=="nullable"&&(r[n.key]=n.schema)}for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:n}){switch(r.type){case"string":return t!=null&&typeof t=="string"?t0.string(t):r.example!=null?t0.string(r.example):t0.string(n.name??DC.STRING);case"base64":return t!=null&&typeof t=="string"?t0.base64(t):r.example!=null?t0.base64(r.example):t0.base64(DC.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?t0.boolean(t):r.example!=null?t0.boolean(r.example):t0.boolean(DC.BOOLEAN);case"date":return t!=null&&typeof t=="string"?t0.date(t):r.example!=null?t0.date(r.example):t0.date(DC.DATE);case"datetime":return t!=null&&typeof t=="string"?t0.datetime(t):r.example!=null?t0.datetime(r.example):t0.datetime(DC.DATE_TIME);case"double":return t!=null&&typeof t=="number"?t0.double(t):r.example!=null?t0.double(r.example):t0.double(DC.DOUBLE);case"float":return t!=null&&typeof t=="number"?t0.float(t):r.example!=null?t0.float(r.example):t0.float(DC.FLOAT);case"int":return t!=null&&typeof t=="number"?t0.int(t):r.example!=null?t0.int(r.example):t0.int(DC.INT);case"int64":return t!=null&&typeof t=="number"?t0.int64(t):r.example!=null?t0.int64(r.example):t0.int64(DC.INT64);case"uint":return t!=null&&typeof t=="number"?t0.uint(t):r.example!=null?t0.uint(r.example):t0.uint(DC.UINT);case"uint64":return t!=null&&typeof t=="number"?t0.uint64(t):r.example!=null?t0.uint64(r.example):t0.uint64(DC.UINT64);default:Ol(r)}}};function Spf({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function URt(e){switch(e.type){case"object":return Lp.object({allOf:e.allOf,properties:e.properties.map(t=>Iv1(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return Lp.array({description:e.description,availability:e.availability,value:URt(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0});case"enum":return Lp.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,groupName:e.groupName,example:void 0,source:e.source});case"literal":return Lp.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName});case"nullable":return Lp.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:URt(e.value),groupName:e.groupName});case"optional":return Lp.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:URt(e.value),groupName:e.groupName});case"primitive":return Lp.primitive({description:e.description,availability:e.availability,schema:Epf(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return Lp.map({description:e.description,availability:e.availability,key:Lp.primitive({description:e.key.description,availability:e.key.availability,schema:Epf(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:URt(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,encoding:e.encoding,example:void 0});case"reference":return Lp.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,groupName:e.groupName,source:e.source});case"oneOf":return Lp.oneOf(Bv1(e.value));case"unknown":return Lp.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,groupName:void 0,description:void 0,availability:void 0});default:Ol(e)}}function Bv1(e){switch(e.type){case"discriminated":return jQ.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:URt(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,URt(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return jQ.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>URt(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:Ol(e)}}function Epf(e){switch(e.type){case"string":return by.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return by.base64({example:void 0});case"boolean":return by.boolean({default:e.default,example:void 0});case"date":return by.date({example:void 0});case"datetime":return by.datetime({example:void 0});case"double":return by.double({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"float":return by.float({example:void 0});case"int":return by.int({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"int64":return by.int64({default:e.default,example:void 0});case"uint":return by.uint({default:void 0,example:void 0});case"uint64":return by.uint64({default:void 0,example:void 0});default:Ol(e)}}function Iv1(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:URt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability}}function lba(e){return e.type!=="optional"&&e.type!=="nullable"}function F_i(e){if(e.type==="full")return e.request==null&&e.response==null&&e.queryParameters==null&&e.pathParameters==null&&e.headers==null;{let t=e.value;return t.request==null&&t.response==null&&t["query-parameters"]==null&&t["path-parameters"]==null&&t.headers==null}}var fba=class{exampleTypeFactory;logger;schemas;constructor(t,r){this.schemas=t,this.exampleTypeFactory=new Q7n(t),this.logger=r}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=Fv1(t.request),n=Lv1(t.response);if((r==null?void 0:r.type)==="unsupported"||(n==null?void 0:n.type)==="unsupported")return[];let i=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let g=this.exampleTypeFactory.buildExample({schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});g!=null&&i.push([void 0,g])}else for(let{name:g,value:O}of r.examples){let j=this.exampleTypeFactory.buildExample({schema:r.schema,exampleId:g,example:O,options:{isParameter:!1,ignoreOptionals:!0}});j!=null&&i.push([g,j])}if(l&&i.length===0)return this.logger.warn(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(n!=null&&n.type==="present"){let l=this.isSchemaRequired(n.schema);if(n.examples.length===0){let g=this.exampleTypeFactory.buildExample({schema:n.schema,exampleId:void 0,example:void 0,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});g!=null&&a.push([void 0,g])}else for(let{name:g,value:O}of n.examples){let j=this.exampleTypeFactory.buildExample({schema:n.schema,exampleId:g,example:O,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});j!=null&&a.push([g,j])}if(l&&a.length===0)return this.logger.warn(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let l of t.pathParameters){let g=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!VRt(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),g&&O==null)return[];O!=null&&u.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:O})}let f=[];for(let l of t.queryParameters){let g=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!VRt(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),g&&O==null)return[];O!=null&&f.push({name:l.name,value:O})}let d=[];for(let l of t.headers){let g=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!VRt(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),g&&O==null)return[];O!=null&&d.push({name:l.name,value:O})}let c=[];t.request!=null&&t.response!=null?c=Rv1(i,a):t.request!=null?c=i.map(([l,g])=>({id:l,request:g,response:void 0})):t.response!=null&&(c=a.map(([l,g])=>({id:l,request:void 0,response:g})));let o=t.examples.filter(l=>F_i(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let g=l.value["code-samples"];if(g!=null)return this.convertCodeSamples(g)}return}else return l.codeSamples}).filter(l=>RS(l));return c.length===0?[pAt.full({name:void 0,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:void 0,response:void 0,codeSamples:o})]:c.map(({id:l,request:g,response:O})=>pAt.full({name:l,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:g,response:O,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?JSr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):JSr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?bW.Csharp:r.sdk,code:r.code})).filter(RS)}isSchemaRequired(t){return lba(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function Rv1(e,t){var i,a,u,f;let r=[];if(e.length<=1){let[d,c]=e[0]??[];if(t.length===0)return r.push({id:d,request:c,response:void 0}),r;for(let[o,l]of t)r.push({id:o??d,request:c,response:l});return r}if(t.length<=1){let[d,c]=t[0]??[];if(t.length===0)return r.push({id:d,request:void 0,response:c}),r;for(let[o,l]of e)r.push({id:o??d,request:l,response:c});return r}let n=new Set;for(let[d,c]of e){let o=((i=t.find(([g])=>g==null))==null?void 0:i[1])??((a=t[0])==null?void 0:a[1]);if(d==null){if(o==null)continue;r.push({id:void 0,request:c,response:o});continue}let l=!1;for(let g=0;g<t.length;g++){let[O,j]=t[g];O!=null||n.has(g)||d===O&&(r.push({id:d,request:c,response:j}),O!=null&&n.add(g),l=!0)}!l&&o!=null&&r.push({id:d,request:c,response:o})}for(let d=0;d<t.length;d++){if(n.has(d))continue;let[c,o]=t[d],l=((u=e.find(([g])=>g==null))==null?void 0:u[1])??((f=e[0])==null?void 0:f[1]);l!=null&&r.push({id:c,request:l,response:o})}return r}function Fv1(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:Uv1(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function Lv1(e){if(e!=null)return e.type!=="json"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function VRt(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return VRt(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undisciminated":return VRt(e.value.value);default:return!1}default:Ol(e)}}function Uv1(e){return Lp.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:URt(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0}).filter(RS),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source})}var dba=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new Q7n(t),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,publish:n,subscribe:i,handshake:a,source:u,namespace:f}){var c,o;let d=[];for(let l of r){let g=[];for(let S of a.queryParameters){let x=this.isSchemaRequired(S.schema),A=this.exampleTypeFactory.buildExample({schema:S.schema,exampleId:void 0,example:(c=l.queryParameters)==null?void 0:c[S.name],options:{name:S.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!VRt(A)&&(A=void 0),!(x&&A==null)&&A!=null&&g.push({name:S.name,value:A})}let O=[];for(let S of a.headers){let x=this.isSchemaRequired(S.schema),A=this.exampleTypeFactory.buildExample({schema:S.schema,exampleId:void 0,example:(o=l.headers)==null?void 0:o[S.name],options:{name:S.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!VRt(A)&&(A=void 0),!(x&&A==null)&&A!=null&&O.push({name:S.name,value:A})}let j=[];for(let S of l.messages){let x=t.resolveMessageReference({$ref:`#/components/messages/${S.messageId}`}),A=gy(x.payload)?t.resolveSchemaReference(x.payload):x.payload,z=this.exampleTypeFactory.buildExample({schema:L1(A,!1,t,[S.messageId],u,f),exampleId:void 0,example:S.value,options:{isParameter:!1,ignoreOptionals:!0}});z!=null&&j.push({messageType:S.type,payload:z,description:void 0})}d.push({name:l.summary,queryParameters:g,headers:O,description:l.description,messages:j})}return d}buildWebsocketSessionExample({publish:t,subscribe:r,handshake:n}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},a=[];for(let f of n.queryParameters){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!VRt(c)&&(c=void 0),d&&c==null)return;c!=null&&a.push({name:f.name,value:c})}let u=[];for(let f of n.headers){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!VRt(c)&&(c=void 0),d&&c==null)return;c!=null&&u.push({name:f.name,value:c})}if(t!=null){let f=this.exampleTypeFactory.buildExample({schema:t,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"publish",payload:f,description:void 0})}if(r!=null){let f=this.exampleTypeFactory.buildExample({schema:r,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"subscribe",payload:f,description:void 0})}return i}isSchemaRequired(t){return lba(this.getResolvedSchema(t))}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}};var L_i={FERN_DISPLAY_NAME:"x-fern-display-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path"};function Mpf(e){return Lh(e,L_i.FERN_EXAMPLES)??[]}function Tpf({document:e,taskContext:t,options:r,source:n,asyncApiOptions:i,namespace:a}){var l,g,O,j,S,x;let u=[];a!=null&&u.push(a),((l=e.tags)==null?void 0:l[0])!=null?u.push(e.tags[0].name):i.naming!=="v2"&&u.push("websocket");let f=new cba({document:e,taskContext:t,options:r,namespace:a}),d={},c;for(let[A,z]of Object.entries(((g=e.components)==null?void 0:g.schemas)??{})){let N=L1(z,!1,f,[A],n,a);d[A]=N}let o=new dba(d,t.logger);for(let[A,z]of Object.entries(e.channels??{})){if(((O=z.bindings)==null?void 0:O.ws)==null){f.logger.error(`Channel ${A} does not have websocket bindings. Skipping.`);continue}let N=[];if(z.parameters!=null)for(let[G,$]of Object.entries(z.parameters??{}))N.push({name:G,description:$.description,parameterNameOverride:void 0,schema:$.schema!=null?L1($.schema,!1,f,u,n,a):Lp.primitive({schema:by.string({default:void 0,pattern:void 0,format:void 0,maxLength:void 0,minLength:void 0,example:void 0}),description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:E2e($),source:n});let C=[];if(z.bindings.ws.headers!=null){let G=z.bindings.ws.headers.required??[];for(let[$,ee]of Object.entries(z.bindings.ws.headers.properties??{})){let Ve=gy(ee)?f.resolveSchemaReference(ee):ee;C.push({name:$,schema:L1(Ve,!G.includes($),f,u,n,a),description:Ve.description,parameterNameOverride:void 0,env:void 0,availability:E2e(Ve),source:n})}}let U=[];if(z.bindings.ws.query!=null){let G=z.bindings.ws.query.required??[];for(let[$,ee]of Object.entries(z.bindings.ws.query.properties??{})){let Ve=gy(ee)?f.resolveSchemaReference(ee):ee;U.push({name:$,schema:L1(Ve,!G.includes($),f,u,n,a),description:Ve.description,parameterNameOverride:void 0,availability:E2e(Ve),source:n})}}let Y;z.publish!=null&&(Y=xpf({generatedName:z.publish.operationId??"PublishEvent",event:z.publish,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i}));let te;if(z.subscribe!=null&&(te=xpf({generatedName:z.subscribe.operationId??"SubscribeEvent",event:z.subscribe,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i})),C.length>0||U.length>0||Y!=null||te!=null){let G=Mpf(z),$=[];if(G.length>0)$=o.buildWebsocketSessionExamplesForExtension({context:f,extensionExamples:G,handshake:{headers:C,queryParameters:U},publish:Y,subscribe:te,source:n,namespace:a});else{let Ve=o.buildWebsocketSessionExample({handshake:{headers:C,queryParameters:U},publish:Y,subscribe:te});Ve!=null&&$.push(Ve)}let ee=((S=(j=e.tags)==null?void 0:j[0])==null?void 0:S.name)!=null?[(x=e.tags)==null?void 0:x[0].name]:void 0;c={handshake:{headers:C.map(Ve=>({...Ve,schema:oq(Ve.schema),env:Ve.env})),queryParameters:U.map(Ve=>({...Ve,schema:oq(Ve.schema)})),pathParameters:N.map(Ve=>({...Ve,parameterNameOverride:void 0,schema:oq(Ve.schema)}))},groupName:f.resolveTags(ee,"Websocket"),publish:Y!=null?oq(Y):Y,subscribe:te!=null?oq(te):te,summary:Lh(z,L_i.FERN_DISPLAY_NAME),path:A,description:void 0,examples:$,source:n};break}}return{groupedSchemas:sba(a,d),channel:c,basePath:Lh(e,L_i.BASE_PATH)}}function xpf({generatedName:e,event:t,context:r,breadcrumbs:n,source:i,options:a,asyncApiOptions:u}){if(t.message.oneOf!=null){let f=[],d=[];for(let c of t.message.oneOf){let o,l={type:"notFound"};if(gy(c)){let g=r.resolveMessageReference(c);!gy(g.payload)&&u.naming==="v2"?(l=g.name?{type:"name",name:g.name}:l,o={...g.payload,title:g.name??g.payload.title,description:g.name??g.payload.description}):o=g.payload}else o=c;d.push(l),f.push(o)}return K7n({description:t.description??t.message.description,availability:E2e(t.message),subtypes:f,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:n,context:r,encoding:void 0,source:i,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}var IEf=yu(Vbf(),1);var Rtn=yu(NEf(),1);var zEf=require("fs/promises");async function jPa({absoluteFilepathToOverrides:e,data:t,context:r}){let n=null;try{let u=(await(0,zEf.readFile)(e,"utf8")).toString();try{n=JSON.parse(u)}catch{n=av.load(u,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}let i=qXi(t,qXi,n,(u,f)=>Array.isArray(u)&&Array.isArray(f)?f.every(d=>typeof d=="object")&&u.every(d=>typeof d=="object")?void 0:[...f]:void 0);return Wbu(i,mWo)}var Wbu=(e,t)=>{function r(n){if(!Array.isArray(n)&&!Lsi(n))return n;if(Array.isArray(n))return n.map(a=>Wbu(a,t));let i={};for(let[a,u]of Object.entries(n))i[a]=Wbu(u,t);return jWo(i,t)}return r(e)};var wH1={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},DH1={id:"",typeExtension:{oas3:e=>{var t;return{...e,XFernStreaming:wH1,Operation:{...e.Operation,properties:{...(t=e.Operation)==null?void 0:t.properties,"x-fern-streaming":"XFernStreaming"}}}}}};async function REf({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,context:r}){let n=await BEf({absolutePathToOpenAPI:e}),i;if(t!=null?i=t:typeof n=="object"&&n[kh.OPENAPI_OVERIDES_FILEPATH]!=null&&(i=pf(Cg(e),zs.of(n[kh.OPENAPI_OVERIDES_FILEPATH]))),i!=null){let a=await jPa({absoluteFilepathToOverrides:i,context:r,data:n});return await BEf({absolutePathToOpenAPI:e,parsed:a})}return n}async function BEf({absolutePathToOpenAPI:e,parsed:t}){let r={config:new Rtn.Config({apis:{},styleguide:{plugins:[DH1],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0},n=t!=null?await(0,Rtn.bundle)({...r,doc:{source:new Rtn.Source(e,"<openapi>"),parsed:t}}):await(0,Rtn.bundle)({...r,ref:e});return await IEf.default.parse(n.bundle.parsed)}var Cqf=yu(L2f(),1);function U2f(e){return Lh(e,kh.ASYNC_CONFIG)}var V2f="$request.";function W2f(e){let t=Lh(e,kh.STREAMING);if(t!=null)return typeof t=="boolean"?t?{type:"stream",format:"json"}:void 0:t["stream-condition"]==null&&t.format!=null?{type:"stream",format:t.format}:{type:"streamCondition",format:t.format??"json",streamConditionProperty:IX1(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function IX1(e){return e.startsWith(V2f)?e.slice(V2f.length):e}function H2f(e){let t=e;if(t.cursor!=null)return $Sr.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});let r=e;return $Sr.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}function $2f(e,t){let r=Lh(t,kh.PAGINATION);if(r!=null){if(typeof r=="boolean"){let n=Lh(e,kh.PAGINATION);if(typeof n=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return n==null?void 0:H2f(n)}return H2f(r)}}function J2f(e){let t=RX1(e),r={};return Hmu({obj:t,occurrences:r,breadcrumbs:[]}),r}function Hmu({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let n of e)Hmu({obj:n,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let n=e.$ref;t[n]==null?t[n]=1:t[n]+=1;return}for(let n in e)Hmu({obj:e[n],occurrences:t,breadcrumbs:[...r,n]})}}}function RX1(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:(r==null?void 0:r.get)!=null?C0i(r.get):void 0,put:(r==null?void 0:r.put)!=null?C0i(r.put):void 0,post:(r==null?void 0:r.post)!=null?C0i(r.post):void 0,patch:(r==null?void 0:r.patch)!=null?C0i(r.patch):void 0,delete:(r==null?void 0:r.delete)!=null?C0i(r.delete):void 0}]))}}function C0i(e){return{...e,requestBody:e.requestBody!=null?gy(e.requestBody)?e.requestBody:FX1(e.requestBody):void 0}}function FX1(e){let t,r;for(let n in e.content){let i=sA.parse(n);i!=null&&(i.isJSON()?t=e.content[n]:i.isMultipart()&&(r=e.content[n]))}return r!=null&&t!=null?{...e,content:{[sA.MULTIPART_FORM_DATA]:r}}:e}var G2f="#/components/parameters/",K2f="#/components/responses/",Y2f="#/components/examples/",X2f="#/components/requestBodies/",V3n=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;namespace;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=n,this.refOccurrences=J2f(t),this.options=i,this.source=a,this.DUMMY=this.getDummy(),this.namespace=u}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};r.push(n)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return{"x-fern-type":"unknown",additionalProperties:!0};n=n[i]}return n==null?{"x-fern-type":"unknown",additionalProperties:!0}:(gy(n)&&(n=this.resolveSchemaReference(n)),n)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(G2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(G2f.length),n=this.document.components.parameters[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return gy(n)?this.resolveParameterReference(n):n}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(X2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(X2f.length),n=this.document.components.requestBodies[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return gy(n)?this.resolveRequestBodyReference(n):n}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(K2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(K2f.length),n=this.document.components.responses[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return gy(n)?this.resolveResponseReference(n):n}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(Y2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(Y2f.length),n=this.document.components.examples[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return gy(n)?this.resolveExampleReference(n):n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}};var W3n=class extends V3n{constructor({document:t,taskContext:r,options:n,source:i,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:n,source:i,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,n){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,n){}getDiscriminatedUnionMetadata(t){}};var LX1=ir.object({lang:ir.string(),label:ir.optional(ir.string()),source:ir.string()}),$mu=ir.array(LX1);var Q2f={README_EXT:"x-readme"};function UX1(e){if(!Array.isArray(e))return!1;for(let t of e)if(!RO(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function Z2f(e){let t=Lh(e,Q2f.README_EXT);if(!RO(t))return[];let r=t["code-samples"];if(!UX1(r))return[];let n=[];for(let i of r)n.push({name:i.name,language:i.language,code:i.code,install:i.install,docs:void 0});return n}function k2f(e,t,r){let n=RRt(t,kh.EXAMPLES,h5.ExampleEndpointCallArraySchema,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],i=RRt(t,Yje.REDOCLY_CODE_SAMPLES_KEBAB,$mu,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],u=[...RRt(t,Yje.REDOCLY_CODE_SAMPLES_CAMEL,$mu,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...i];u.length>0&&n.push({"code-samples":u.map(d=>({name:d.label??d.lang,language:d.lang,code:d.source,install:void 0,docs:void 0}))});let f=Z2f(t);return f.length>0&&n.push({"code-samples":f}),n.map(pAt.unknown)}function eqf(e){let t=Lh(e,kh.AVAILABILITY);if(t==="ga"||t==="generally-available")return vW.GenerallyAvailable;if(t==="beta"||t==="pre-release")return vW.Beta;if(t==="deprecated")return vW.Deprecated;if(e.deprecated)return vW.Deprecated}function x1a(e){return{url:VX1({url:e.url,variables:e.variables??{}}),description:e.description,name:WX1(e),audiences:Lh(e,kh.AUDIENCES)}}function VX1({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([n,i])=>[n,i.default]));for(let[n,i]of Object.entries(r))e=e.replace(`{${n}}`,i);return e}function WX1(e){var r,n;let t=Lh(e,[kh.SERVER_NAME_V1,kh.SERVER_NAME_V2]);if(t!=null)return t;if(((r=e.description)==null?void 0:r.toLowerCase())==="production")return"Production";if(((n=e.description)==null?void 0:n.toLowerCase())==="sandbox")return"Sandbox"}function tqf(e){return Lh(e,kh.PARAMETER_NAME)}function rqf(e){return Lh(e,kh.SDK_VARIABLE)}function T1a({path:e,httpMethod:t,parameters:r,context:n,requestBreadcrumbs:i,source:a}){var f;let u={pathParameters:[],queryParameters:[],headers:[]};for(let d of r){let c=gy(d)?n.resolveParameterReference(d):d,o=c.required??!1,l=E2e(c),g=[...i,c.name],O=yR(g);(f=LRt({schema:c,logger:n.logger}))!=null&&f.includes(" ")&&n.logger.warn("Parameter example contains a space, which is ambiguous. Consider using enums for multiple examples, or use an encoding if a space is part of the parameter.");let j=c.schema!=null?L1(c.schema,!o,n,g,a,n.namespace,!1,new Set,LRt({schema:c,logger:n.logger})):o?Lp.primitive({nameOverride:void 0,generatedName:O,title:void 0,schema:by.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:LRt({schema:c,logger:n.logger})}),description:void 0,availability:l,groupName:void 0}):Lp.optional({nameOverride:void 0,generatedName:O,title:void 0,value:Lp.primitive({nameOverride:void 0,generatedName:O,title:void 0,schema:by.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:LRt({schema:c,logger:n.logger})}),description:void 0,availability:void 0,groupName:void 0}),description:void 0,availability:l,groupName:void 0});if(c.in==="header"&&c.schema!=null&&!gy(c.schema)&&c.schema.default!=null){let x=c.schema.default;typeof x=="string"&&x.length>0&&(j=Lp.literal({nameOverride:void 0,generatedName:O,title:void 0,value:E7.string(x),description:void 0,availability:l,groupName:void 0}))}let S={name:c.name,schema:j,description:c.description,parameterNameOverride:tqf(c),availability:l,source:a};c.in==="query"?u.queryParameters.push(S):c.in==="path"?u.pathParameters.push({...S,variableReference:rqf(c)}):c.in==="header"?!HX1.has(c.name)&&!n.authHeaders.has(c.name)?u.headers.push({...S,env:void 0}):n.logger.debug(`Ignoring ${c.name} header, in ${t.toUpperCase()} ${e}`):n.logger.warn(`Skipping ${c.in} parameter, ${c.name}, in ${t.toUpperCase()} ${e}`)}return u}var HX1=new Set(["User-Agent","Content-Length","Content-Type","X-Forwarded-For","Cookie","Origin","Content-Disposition","X-Ping-Custom-Domain"]);function H3n(e,t){for(let r of Object.keys(e))if(r.includes("json")){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:iqf(n,t)}}}function nqf(e,t){for(let r of Object.keys(e)){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:iqf(n,t)}}}function iqf(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let n=Lh(e,Yje.EXAMPLES);return n!=null&&Object.keys(n).length>0&&r.push(...Object.entries(n).map(([i,a])=>({name:a.summary??i,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([i,a])=>{let u=gy(a)?t.resolveExampleReference(a):a;return{name:u.summary??i,value:u.value,description:u.description}})),r}function $X1(e){var t;for(let[r,n]of Object.entries(e.content))if((t=sA.parse(r))!=null&&t.isMultipart())return{schema:n.schema,encoding:n.encoding}}function JX1(e){var t;for(let r in e.content)if((t=sA.parse(r))!=null&&t.isOctetStream())return!0;return!1}function GX1(e,t){let r=gy(e)?Jmu(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([n,i])=>!gy(i)&&i.type==="string"&&i.format==="binary")!=null}function $3n({requestBody:e,document:t,context:r,requestBreadcrumbs:n,source:i,namespace:a}){var g,O,j,S,x;let u=gy(e)?r.resolveRequestBodyReference(e):e,f=$X1(u),d=f==null?void 0:f.schema,c=f==null?void 0:f.encoding,o=H3n(u.content,r);if(JX1(u))return S2e.octetStream({description:void 0,source:i});if(d!=null&&o==null||d!=null&&GX1(d,t)){let A=gy(d)?Jmu(d,t):{id:void 0,schema:d},z=L1(A.schema,!1,r,n,i,a),N=[];if(z.type==="object")for(let C of z.properties){if(C.schema.type==="primitive"&&C.schema.schema.type==="string"&&C.schema.schema.format==="binary"){N.push({key:C.key,schema:D2e.file({isOptional:!1,isArray:!1}),description:C.schema.description,contentType:c!=null?(g=c[C.key])==null?void 0:g.contentType:void 0});continue}if(C.schema.type==="optional"&&C.schema.value.type==="primitive"&&C.schema.value.schema.type==="string"&&C.schema.value.schema.format==="binary"){N.push({key:C.key,schema:D2e.file({isOptional:!0,isArray:!1}),description:C.schema.description,contentType:c!=null?(O=c[C.key])==null?void 0:O.contentType:void 0});continue}if(C.schema.type==="array"&&C.schema.value.type==="primitive"&&C.schema.value.schema.type==="string"&&C.schema.value.schema.format==="binary"){N.push({key:C.key,schema:D2e.file({isOptional:!1,isArray:!0}),description:C.schema.description,contentType:c!=null?(j=c[C.key])==null?void 0:j.contentType:void 0});continue}if(C.schema.type==="optional"&&C.schema.value.type==="array"&&C.schema.value.value.type==="primitive"&&C.schema.value.value.schema.type==="string"&&C.schema.value.value.schema.format==="binary"){N.push({key:C.key,schema:D2e.file({isOptional:!0,isArray:!0}),description:C.schema.description,contentType:c!=null?(S=c[C.key])==null?void 0:S.contentType:void 0});continue}N.push({key:C.key,schema:D2e.json(C.schema),description:void 0,contentType:c!=null?(x=c[C.key])==null?void 0:x.contentType:void 0})}return S2e.multipart({name:gy(d)&&r.getNumberOfOccurrencesForRef(d)===1?A.id:void 0,description:void 0,properties:N,source:i})}if(o==null)return;let l=L1(o.schema,!1,r,n,i,a,!0);return S2e.json({description:void 0,schema:l,contentType:void 0,fullExamples:o.examples,additionalProperties:!gy(o.schema)&&H7n(o.schema.additionalProperties),source:i})}function Jmu(e,t){var i,a;if(!e.$ref.startsWith(Fen))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=A5r(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let n=(a=(i=t.components)==null?void 0:i.schemas)==null?void 0:a[r];if(n==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return gy(n)?Jmu(n,t):{id:r,schema:n}}var Gmu={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},aqf=new Set(Object.values(Gmu));var KX1=["200","201","202","204"];function uqf({operationContext:e,responses:t,context:r,responseBreadcrumbs:n,responseStatusCode:i,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let f=YX1({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,c;for(let o of i!=null?[i]:KX1){let l=t[o];l!=null&&(d=!0,c==null&&(c=oqf({operationContext:e,response:l,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})))}if(c==null&&!d&&t.default!=null&&(c=oqf({operationContext:e,response:t.default,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})),c!=null)switch(c.type){case"json":return{value:c,errors:f};case"streamingJson":case"streamingSse":return{value:c,errors:f};case"file":case"text":case"streamingText":return{value:c,errors:f};default:Ol(c)}return{value:void 0,errors:f}}function oqf({operationContext:e,streamFormat:t,response:r,context:n,responseBreadcrumbs:i,source:a,namespace:u}){let f=gy(r)?n.resolveResponseReference(r):r;if(f.content!=null&&Object.entries(f.content).find(([o,l])=>{if(l.schema==null)return!1;let g=gy(l.schema)?n.resolveSchemaReference(l.schema):l.schema;return g.type==="string"&&g.format==="binary"}))return T3.file({description:f.description,source:a});let d=H3n(f.content??{},n);if(d!=null){if(t!=null)switch(t){case"json":return T3.streamingJson({description:f.description,responseProperty:void 0,schema:oq(L1(d.schema,!1,n,i,a,u)),source:a});case"sse":return T3.streamingSse({description:f.description,responseProperty:void 0,schema:oq(L1(d.schema,!1,n,i,a,u)),source:a})}return T3.json({description:f.description,schema:L1(d.schema,!1,n,i,a,u),responseProperty:Lh(e.operation,kh.RESPONSE_PROPERTY),fullExamples:d.examples,source:a})}for(let[c,o]of Object.entries(f.content??{})){let l=sA.parse(c);if(l!=null){if(l.isOctetStream()||l.isPDF()||l.isAudio()||l.isImage()||l.isVideo())return T3.file({description:f.description,source:a});if(l.isPlainText()){let g=o.schema;if(g==null)return T3.text({description:f.description,source:a});let O=gy(g)?n.resolveSchemaReference(g):g;return O.type==="string"&&O.format==="byte"?T3.file({description:f.description,source:a}):T3.text({description:f.description,source:a})}}}}function YX1({responses:e,context:t,source:r,namespace:n}){let i={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let f=parseInt(a);if(f<400||f>600)continue;let d=gy(u)?t.resolveResponseReference(u):u,c=nqf(d.content??{},t),o=Gmu[f];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}i[f]={statusCode:f,nameOverride:void 0,generatedName:o,description:d.description,schema:L1((c==null?void 0:c.schema)??{},!1,t,[o,"Body"],r,n),fullExamples:c==null?void 0:c.examples,source:r}}return i}function vEr({operationContext:e,context:t,responseStatusCode:r,suffix:n,streamFormat:i,source:a}){let{document:u,operation:f,path:d,method:c,baseBreadcrumbs:o,sdkMethodName:l}=e,g=Lh(f,kh.IDEMPOTENT),O=Lh(f,[kh.REQUEST_NAME_V1,kh.REQUEST_NAME_V2]),j=[...o,"Request"],S=T1a({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:j,path:d,httpMethod:c,source:a}),x=f.requestBody!=null?$3n({requestBody:f.requestBody,document:u,context:new W3n({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:j,source:a,namespace:t.namespace}):void 0;(S.queryParameters.length>0||S.headers.length>0)&&x!=null&&x.type==="json"&&x.schema.type!=="object"&&f.requestBody!=null?x=$3n({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j,"Body"],source:a,namespace:t.namespace}):f.requestBody!=null&&(x=$3n({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j],source:a,namespace:t.namespace}));let A=[...o,"Response"],z=uqf({operationContext:e,streamFormat:i,responses:f.responses,context:t,responseBreadcrumbs:A,responseStatusCode:r,source:a}),N=eqf(f),C=k2f(e,f,t),U=Lh(f,kh.SERVER_NAME_V2);return{summary:f.summary,internal:Lh(f,Yje.INTERNAL),idempotent:g,audiences:Lh(f,kh.AUDIENCES)??[],operationId:f.operationId!=null&&n!=null?f.operationId+"_"+n:f.operationId,tags:t.resolveTagsToTagIds(f.tags),namespace:t.namespace,sdkName:l,pathParameters:S.pathParameters,queryParameters:S.queryParameters,headers:S.headers,requestNameOverride:O??void 0,generatedRequestName:yR(j),request:x,response:z.value,errors:z.errors,server:U!=null?[{name:U,url:void 0,audiences:void 0}]:(f.servers??[]).map(Y=>x1a(Y)),description:f.description,authed:XX1(f,u),availability:N,method:c,path:d,examples:C,pagination:e.pagination,source:a}}function XX1(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function cqf({operationContext:e,context:t,asyncExtension:r,source:n}){let{operation:i,pathItemParameters:a,operationParameters:u}=e,f=r.discriminant.name,d=r.discriminant.value,c=r["response-status-code"],o=sqf({context:t,headerToIgnore:f,parameters:a}),l=sqf({context:t,headerToIgnore:f,parameters:u}),g=vEr({operationContext:{...e,pathItemParameters:o,operationParameters:l,operation:{...i,responses:Object.fromEntries(Object.entries(i.responses).filter(([j])=>parseInt(j)!==c))}},context:t,streamFormat:void 0,source:n}),O=vEr({operationContext:{...e,pathItemParameters:o,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:c,streamFormat:void 0,source:n});return O.headers.push({name:f,schema:Lp.literal({nameOverride:void 0,generatedName:yR([f]),title:void 0,description:void 0,availability:void 0,value:E7.string(d),groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:n}),{sync:g,async:O}}function sqf({context:e,headerToIgnore:t,parameters:r}){return r.filter(n=>{let i=gy(n)?e.resolveParameterReference(n):n;return!(i.in==="header"&&i.name===t)})}var Kmu="stream";function pqf({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:vEr({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let n=lqf({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if((n==null?void 0:n.schemaReference)!=null){let c=A5r(n.schemaReference);c!=null&&t.excludeSchema(c)}let i=fqf({operation:e.operation,response:r.responseStream}),a=vEr({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+Kmu}:void 0,operation:{...e.operation,requestBody:n==null?void 0:n.requestBody,responses:i},baseBreadcrumbs:[...e.baseBreadcrumbs,Kmu]},context:t,streamFormat:r.format,suffix:Kmu,source:t.source});a.examples=a.examples.filter(c=>dqf(c,t)!==!1);let u=lqf({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),f=fqf({operation:e.operation,response:r.response}),d=vEr({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u==null?void 0:u.requestBody,responses:f}},context:t,source:t.source});return d.examples=d.examples.filter(c=>dqf(c,t)!==!0),{streaming:a,nonStreaming:d}}default:Ol(r)}}function lqf({context:e,operation:t,streamingExtension:r,isStreaming:n}){var c;if(t.requestBody==null)return;let i=gy(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=H3n(i.content,e);if(a==null)return;let u=gy(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let f=(c=u.properties)==null?void 0:c[r.streamConditionProperty];f!=null&&gy(f)&&(f=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":n,...f??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[sA.APPLICATION_JSON]:{schema:d}}},schemaReference:gy(a.schema)?a.schema:void 0}}function fqf({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[sA.APPLICATION_JSON]:{schema:t}}}}}function dqf(e,t){return e._visit({unknown:r=>{let n=h5.ExampleEndpointCallSchema.safeParse(r);if(!n.success){t.logger.error("Failed to parse example",n.error.toString());return}if(n.data.response!=null)return n.data.response.stream!=null},full:()=>{},_other:()=>{}})}function _qf({context:e,operationContext:t,source:r}){let{document:n,operation:i,path:a,method:u,baseBreadcrumbs:f,sdkMethodName:d}=t,c=[...f,"Payload"],o=T1a({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:c,path:a,httpMethod:u,source:r});if(i.requestBody==null){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Missing a request body`);return}if(u!=="POST"&&u!=="GET"){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Not POST or GET`);return}let l=$3n({requestBody:i.requestBody,document:n,context:e,requestBreadcrumbs:[...f,"Payload"],source:r,namespace:e.namespace});if(l==null||l.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(i.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:i.summary,sdkName:d,namespace:e.namespace,method:u,operationId:i.operationId,tags:e.resolveTagsToTagIds(i.tags),headers:o.headers,generatedPayloadName:yR(c),payload:l.schema,description:i.description,examples:QX1(l.fullExamples),source:r}}function QX1(e){if(e==null)return[];let t=[];for(let r of e){let n=N5r(r.value);n!=null&&t.push({description:r.description,name:r.name,payload:n})}return t}function Ymu({context:e,pathItemContext:t,operation:r,convertToWebhook:n}){let i=Lh(r,kh.IGNORE);if(i!=null&&i){e.logger.info(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=ZX1(r,e),u=$2f(e.document,r),f={...t,sdkMethodName:a,baseBreadcrumbs:kX1({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path}),operation:r,operationParameters:r.parameters??[],pagination:u};if(n){let l=_qf({context:e,operationContext:f,source:e.source});return l!=null?{type:"webhook",value:l}:void 0}let d=W2f(r);if(d!=null){let l=pqf({context:e,operationContext:f,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let c=U2f(r);if(c!=null){let l=cqf({context:e,operationContext:f,asyncExtension:c,source:e.source});return{type:"async",async:l.async,sync:l.sync}}let o=vEr({context:e,operationContext:f,streamFormat:void 0,source:e.source});return{type:"http",value:o}}function ZX1(e,t){let r=Lh(e,kh.SDK_METHOD_NAME),n=Lh(e,kh.SDK_GROUP_NAME)??[];if(r!=null){let i=typeof n=="string"?[n]:n;return i=t.resolveGroupName(i),{groupName:i,methodName:r}}}function kX1({sdkMethodName:e,operation:t,httpMethod:r,path:n}){let i=[];if(e!=null){if(e.groupName.length>0){let a=e.groupName[e.groupName.length-1];a!=null&&i.push(typeof a=="string"?a:a.name)}i.push(e.methodName)}else t.operationId!=null?i.push(t.operationId):i.push(FE(`${r}_${n.split("/").join("_")}`));return i}function hqf(e,t,r,n){let i=[],a=vqf(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=eQ1({operation:f.operation}),c=Ymu({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:d});c!=null&&i.push(c)}return i}function yqf(e,t,r,n){let i=[],a=vqf(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=Ymu({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:!0});d!=null&&i.push(d)}return i}function vqf(e){let t=[];return e.get!=null&&t.push({method:KJ.Get,operation:e.get}),e.post!=null&&t.push({method:KJ.Post,operation:e.post}),e.put!=null&&t.push({method:KJ.Put,operation:e.put}),e.delete!=null&&t.push({method:KJ.Delete,operation:e.delete}),e.patch!=null&&t.push({method:KJ.Patch,operation:e.patch}),t}function eQ1({operation:e}){return Lh(e,[kh.WEBHOOK])??!1}function bqf(e){let t=Lh(e,kh.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=Lh(e,kh.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function gqf(e){return Lh(e,kh.FERN_BASIC_AUTH)}function Xmu(e,t){if(gy(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return tQ1(e,t)}function tQ1(e,t){var r,n,i,a;if(e.type==="apiKey"&&e.in==="header"){let u=Lh(e,Yje.BEARER_FORMAT),f=Lh(e,kh.FERN_HEADER_AUTH);return F9.header({headerName:e.name,prefix:u!=null?"Bearer":f==null?void 0:f.prefix,headerVariableName:(f==null?void 0:f.name)??Lh(e,kh.HEADER_VARIABLE_NAME),headerEnvVar:f==null?void 0:f.env})}else if(e.type==="http"&&e.scheme==="bearer"){let u=Lh(e,kh.FERN_BEARER_TOKEN);return F9.bearer({tokenVariableName:(u==null?void 0:u.name)??Lh(e,kh.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:u==null?void 0:u.env})}else if(e.type==="http"&&e.scheme==="basic"){let u=gqf(e),f=bqf(e);return F9.basic({usernameVariableName:((r=u==null?void 0:u.username)==null?void 0:r.name)??f.usernameVariable,usernameEnvVar:(n=u==null?void 0:u.username)==null?void 0:n.env,passwordVariableName:((i=u==null?void 0:u.password)==null?void 0:i.name)??f.passwordVariable,passwordEnvVar:(a=u==null?void 0:u.password)==null?void 0:a.env})}else{if(e.type==="openIdConnect")return F9.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return F9.oauth({scopesEnum:rQ1(e,t)})}throw new Error(`Failed to convert security scheme ${JSON.stringify(e)}`)}function rQ1(e,t){var n,i,a,u;let r=((n=e.flows.authorizationCode)==null?void 0:n.scopes)??((i=e.flows.clientCredentials)==null?void 0:i.scopes)??((a=e.flows.implicit)==null?void 0:a.scopes)??((u=e.flows.password)==null?void 0:u.scopes);if(r!=null){let f=C5r({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([c,o])=>[c,{description:o}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsNullable:!1,groupName:void 0,context:void 0,source:t}),d=oq(f);if(d.type==="enum")return d}}function mqf(e){return Lh(e,kh.BASE_PATH)}var nQ1=ir.record(ir.string(),ir.object({summary:ir.string().optional(),description:ir.string().optional()}));function Oqf({document:e,context:t}){return RRt(e,kh.GROUPS,nQ1,t.logger)}function Pqf({context:e,document:t}){return RRt(t,kh.FERN_VERSION,h5.VersionDeclarationSchema,e.logger)??void 0}function jqf(e){let t=Lh(e,kh.FERN_GLOBAL_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?z_i({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function wqf(e){let t=Lh(e,kh.FERN_IDEMPOTENCY_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?z_i({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function Dqf(e){let t=Lh(e,kh.SDK_VARIABLES);return t==null?{}:Object.fromEntries(Object.entries(t).map(([r,n])=>{if(n.type==="string")return[r,{nameOverride:void 0,generatedName:yR([r]),title:n.title,schema:Xw.string({default:Y7n(n),pattern:n.pattern,format:n.format,minLength:n.minLength,maxLength:n.maxLength}),description:n.description,availability:void 0,groupName:void 0}];throw new Error(`Variable ${r} has unsupported schema ${JSON.stringify(n)}`)}))}var iQ1="webhooks";function Sqf(e){return Lh(e,iQ1)??{}}var q1a=class extends V3n{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discrminatedUnionReferences={};discrminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u})}getDummy(){return new W3n({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,n){let i=this.discrminatedUnionReferences[t.$ref];i!=null?(i.discriminants.add(r),i.numReferences+=n):this.discrminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:n}}getReferencesFromDiscriminatedUnion(t){return this.discrminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,n){let i=this.discrminatedUnionMetadata[t.$ref];i!=null?i.discriminants.set(r,n):this.discrminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,n]])}}getDiscriminatedUnionMetadata(t){return this.discrminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function Eqf(e){return Lh(e,kh.RESOLUTIONS)}function Mqf({openapi:e}){let t=Eqf(e);if(t==null)return e;let r={};for(let n of t){let i=`#/components/schemas/${n.name}`;for(let a of n.resolutions)e=aQ1({openapi:e,schemaReference:a,schemaName:n.name}),e=xqf({openapi:e,replaceReference:a,schemaReference:i,replacedReferences:r}),r={...r,...Object.fromEntries(n.resolutions.map(u=>[i,u]))}}return e}function aQ1({openapi:e,schemaReference:t,schemaName:r}){let n=t.replace("#/","").split("/").map(a=>a.replace("~1","/")),i=e;for(let a of n){let u=i[a];if(u==null)return e;i=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=i,e}function xqf({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:n}){let i=Object.keys(n).filter(d=>t.startsWith(d)).sort((d,c)=>c.length-d.length)[0];if(i!=null){let d=n[i];if(d!=null){let c=r.replace(i,d);return xqf({openapi:e,replaceReference:t,schemaReference:c,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replace("~1","/")),u=e;for(let d of a.slice(0,-1)){let c=u[d];if(c==null)return e;u=c}let f=a[a.length-1];return f==null||(u[f]={$ref:r}),e}function C1a({openApi:e,taskContext:t,options:r,source:n,namespace:i}){var Y,te,G;e=Mqf({openapi:e});let a=Object.fromEntries(Object.entries(((Y=e.components)==null?void 0:Y.securitySchemes)??{}).map(([$,ee])=>Xmu(ee,n)==null?[]:[$,Xmu(ee,n)])),u=new Set(...Object.entries(a).map(([$,ee])=>ee.type==="basic"||ee.type==="bearer"?"Authorization":ee.type==="header"?ee.headerName:null)),f=new q1a({document:e,taskContext:t,authHeaders:u,options:r,source:n,namespace:i}),d=Dqf(e),c=jqf(e),o=wqf(e),l=r.audiences??[],g=[],O=[];Object.entries(e.paths??{}).forEach(([$,ee])=>{if(ee==null)return;t.logger.debug(`Converting path ${$}`);let Ve=hqf($,ee,e,f);for(let $e of Ve){let Dt=Tqf({operation:$e});if(!(l.length>0&&!l.some(Tt=>Dt.includes(Tt))))switch($e.type){case"async":g.push($e.sync),g.push($e.async);break;case"http":g.push($e.value);break;case"streaming":g.push($e.streaming),$e.nonStreaming&&g.push($e.nonStreaming);break;case"webhook":O.push($e.value);break;default:Ol($e)}}}),Object.entries(Sqf(e)).forEach(([$,ee])=>{if(ee==null)return;t.logger.debug(`Converting path ${$}`);let Ve=yqf($,ee,e,f);for(let $e of Ve){let Dt=Tqf({operation:$e});l.length>0&&!l.some(Tt=>Dt.includes(Tt))||O.push($e.value)}});let j=Object.fromEntries(Object.entries(((te=e.components)==null?void 0:te.schemas)??{}).map(([$,ee])=>{if(!gy(ee)){let Ve=Lh(ee,kh.IGNORE);if(Ve!=null&&Ve)return[];if(aqf.has($))return[$,L1({...ee,"x-fern-type-name":`${$}Body`},!1,f,[$],n,i)]}return[$,L1(ee,!1,f,[$],n,i)]}).filter($=>$.length>0)),S=oQ1(j,f,n),x=uQ1(S,f),A={};for(let[$,ee]of Object.entries(x)){let Ve=oq(ee);f.isSchemaExcluded($)||(A[$]=Ve,t.logger.debug(`Converted schema ${$}`))}let z=new fba(x,f.logger),N=g.map($=>{let ee=$.examples,Ve=ee;if(!r.disableExamples&&(ee.length===0||ee.every(F_i))){let Tt=z.buildEndpointExample($);Tt.length>0&&(Ve=[...Tt,...ee.filter(Wt=>!F_i(Wt))])}let $e=$.request,Dt=$.response;return{...$,request:($e==null?void 0:$e.type)==="json"?{...$e,schema:oq($e.schema)}:$e,response:(Dt==null?void 0:Dt.type)==="json"?{...Dt,schema:oq(Dt.schema)}:Dt,queryParameters:$.queryParameters.map(Tt=>({description:Tt.description,name:Tt.name,schema:oq(Tt.schema),parameterNameOverride:Tt.parameterNameOverride,availability:Tt.availability,source:Tt.source})),pathParameters:$.pathParameters.map(Tt=>({description:Tt.description,name:Tt.name,schema:oq(Tt.schema),parameterNameOverride:Tt.parameterNameOverride,variableReference:Tt.variableReference,availability:Tt.availability,source:Tt.source})),headers:$.headers.map(Tt=>({description:Tt.description,name:Tt.name,schema:oq(Tt.schema),parameterNameOverride:Tt.parameterNameOverride,env:Tt.env,availability:Tt.availability,source:Tt.source})),examples:Ve,errors:sy($.errors,Tt=>{var Wt;return{generatedName:Tt.generatedName,nameOverride:Tt.nameOverride,schema:oq(Tt.schema),description:Tt.description,source:Tt.source,examples:(Wt=Tt.fullExamples)==null?void 0:Wt.map(Nt=>{let ur=N5r(Nt.value);if(ur!=null)return{name:Nt.name,description:Nt.description,example:ur}}).filter(RS)}})}}),C=Oqf({document:e,context:f});return{apiVersion:Pqf({context:f,document:e}),basePath:mqf(e),title:e.info.title,description:e.info.description,groups:Object.fromEntries(Object.entries(C??{}).map(([$,ee])=>[$,{summary:ee.summary??void 0,description:ee.description??void 0}])),servers:(e.servers??[]).map($=>x1a($)),tags:{tagsById:Object.fromEntries((e.tags??[]).map($=>[$.name,{id:$.name,description:$.description}])),orderedTagIds:(G=e.tags)==null?void 0:G.map($=>$.name)},endpoints:N,webhooks:O,channel:[],groupedSchemas:sba(i,A),securitySchemes:a,hasEndpointsMarkedInternal:N.some($=>$.internal),nonRequestReferencedSchemas:f.getReferencedSchemas(),variables:d,globalHeaders:c,idempotencyHeaders:o}}function oQ1(e,t,r){let n={};for(let[i,a]of Object.entries(e)){if(a.type!=="object"){n[i]=a;continue}let u={$ref:`#/components/schemas/${i}`},f=t.getReferencesFromDiscriminatedUnion(u);if(f==null){n[i]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!f.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!f.discriminants.has(o.propertyKey)),source:r};n[i]=d;let c=qqf({schema:a,schemas:e});for(let o of[...new Set(c)]){let l=n[o]??e[o];l==null||l.type!=="object"||(n[o]={...l,type:"object",properties:l.properties.filter(g=>!f.discriminants.has(g.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(g=>!f.discriminants.has(g.propertyKey))})}}return n}function uQ1(e,t){let r={};for(let[n,i]of Object.entries(e)){if(i.type!=="object"){r[n]=i;continue}let a={$ref:`#/components/schemas/${n}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[n]=i;continue}let f=[];for(let c of i.properties)if(u.discriminants.has(c.key)){let o=u.discriminants.get(c.key);o!=null&&f.push({...c,schema:Lp.literal({nameOverride:void 0,generatedName:yR([i.generatedName,o]),title:void 0,value:E7.string(o),groupName:void 0,description:void 0,availability:i.availability})})}else f.push(c);let d={...i,type:"object",properties:f};r[n]=d}return r}function qqf({schema:e,schemas:t}){let r=[];for(let n of e.allOf){r.push(n.schema);let i=t[n.schema];i!=null&&i.type==="object"&&r.push(...qqf({schema:i,schemas:t}))}return r}function Tqf({operation:e}){let t=[];switch(e.type){case"async":t=e.async.audiences;break;case"http":t=e.value.audiences;break;case"streaming":t=e.streaming.audiences;break;case"webhook":break;default:Ol(e)}return t}async function Aqf({openApi:e,taskContext:t,options:r,source:n,namespace:i}){let a=await(0,Cqf.convertObj)(e,{});return C1a({openApi:a.openapi,taskContext:t,options:r,source:n,namespace:i})}var J3n={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0};async function Ktn({absoluteFilePathToWorkspace:e,specs:t,taskContext:r,optionOverrides:n}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channel:[],groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let a of t){let u=(await(0,Zmu.readFile)(a.absoluteFilepath)).toString(),f=YN(e,a.source.file);a.source.relativePathToDependency!=null&&(f=pf(a.source.relativePathToDependency,f));let d=a.source.type==="protobuf"?HSr.protobuf({file:f}):HSr.openapi({file:f});if(u.includes("openapi")||u.includes("swagger")){let c=await REf({absolutePathToOpenAPI:a.absoluteFilepath,context:r,absolutePathToOpenAPIOverrides:a.absoluteFilepathToOverrides});if(lQ1(c)){let o=C1a({openApi:c,taskContext:r,options:Qmu({specSettings:a.settings,overrides:n}),source:d,namespace:a.namespace});i=Nqf(i,o)}else if(fQ1(c)){let o=await Aqf({openApi:c,taskContext:r,options:Qmu({specSettings:a.settings}),source:d,namespace:a.namespace});i=Nqf(i,o)}}else if(u.includes("asyncapi")){let c=await cQ1({absoluteFilePathToAsyncAPI:a.absoluteFilepath,context:r,absoluteFilePathToAsyncAPIOverrides:a.absoluteFilepathToOverrides}),o=Tpf({document:c,taskContext:r,options:Qmu({specSettings:a.settings}),source:d,asyncApiOptions:sQ1({specSettings:a.settings}),namespace:a.namespace});o.channel!=null&&i.channel.push(o.channel),o.groupedSchemas!=null&&(i.groupedSchemas=zqf(i.groupedSchemas,o.groupedSchemas)),o.basePath!=null&&(i.basePath=o.basePath)}else r.failAndThrow(`${a.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}function Qmu({specSettings:e,overrides:t}){return{disableExamples:(t==null?void 0:t.disableExamples)??J3n.disableExamples,discriminatedUnionV2:(t==null?void 0:t.discriminatedUnionV2)??(e==null?void 0:e.shouldUseUndiscriminatedUnionsWithLiterals)??J3n.discriminatedUnionV2,useTitlesAsName:(t==null?void 0:t.useTitlesAsName)??(e==null?void 0:e.shouldUseTitleAsName)??J3n.useTitlesAsName,audiences:(t==null?void 0:t.audiences)??(e==null?void 0:e.audiences)??J3n.audiences,optionalAdditionalProperties:(t==null?void 0:t.optionalAdditionalProperties)??(e==null?void 0:e.optionalAdditionalProperties)??J3n.optionalAdditionalProperties}}function sQ1({specSettings:e,overrides:t}){return{naming:(t==null?void 0:t.naming)??(e==null?void 0:e.asyncApiNaming)??tpf.naming}}function Nqf(e,t){return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channel:[...e.channel,...t.channel],groupedSchemas:zqf(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}}}function zqf(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,n]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...n}:e.namespacedSchemas[r]=n;return e}async function cQ1({absoluteFilePathToAsyncAPI:e,absoluteFilePathToAsyncAPIOverrides:t,context:r}){let n=(await(0,Zmu.readFile)(e)).toString(),i=await av.load(n);return t!=null?await jPa({absoluteFilepathToOverrides:t,context:r,data:i}):i}function lQ1(e){return e.openapi!=null}function fQ1(e){return e.swagger!=null}function N1a({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=kmu({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=A2(i.value);if(a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>"),e.description==null&&!i.allowMultiple&&e.parameterNameOverride==null&&e.availability==null)return a;let u={type:a};return i.allowMultiple&&(u["allow-multiple"]=!0),e.description!=null&&(u.docs=e.description),e.parameterNameOverride!=null&&(u.name=e.parameterNameOverride),e.availability!=null&&(u.availability=q3(e.availability)),u}function kmu({schema:e,context:t,fileContainingReference:r,namespace:n}){if(e.type==="reference"){let i=t.getSchema(e.schema,n);if(i==null)return;if(i.type==="array")return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,declarationFile:zs.of(HT),fileContainingReference:r,namespace:n}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undisciminated"){let a=[];for(let[u,f]of Object.entries(i.value.schemas))f.type==="literal"&&f.value.type==="string"&&(G7n.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:B_i(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[u,f]=i.value.schemas;if(u!=null&&f!=null&&A1a({array:u,primitive:f}))return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(u!=null&&f!=null&&A1a({array:u,primitive:f}))return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[u,f]of Object.entries(i.value.schemas))return kmu({schema:f,context:t,fileContainingReference:r,namespace:n})}else if(i.type==="object")return}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let i=t.getSchema(e.value.schema,n);if(i==null)return;if(i.type==="array")return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,declarationFile:zs.of(HT),namespace:n}),allowMultiple:!0}}if(e.value.type==="array")return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undisciminated"){let i=[];for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="literal"&&u.value.type==="string"&&(G7n.test(u.value.value)?i.push(u.value.value):i.push({value:u.value.value,name:B_i(u.value.value)}));if(i.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:i}}),{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[a,u]=e.value.value.schemas;if(a!=null&&u!=null&&A1a({array:a,primitive:u}))return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(a!=null&&u!=null&&A1a({array:u,primitive:a}))return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[a,u]of Object.entries(e.value.value.schemas))return kmu({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return;return{value:S1({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}return e.type==="array"?{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}:{value:S1({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}function A1a({array:e,primitive:t}){return(e==null?void 0:e.type)==="array"&&e.value.type==="primitive"&&(t==null?void 0:t.type)==="primitive"&&e.value.schema.type===t.schema.type}function Bqf({websocketExample:e,context:t}){let r={messages:[]};e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=dQ1(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=pQ1({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=Rzr(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function dQ1(e){let t={};return e.forEach(r=>{let n=Rzr(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function pQ1({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=Rzr(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function Rzr(e){switch(e.type){case"primitive":return Iqf(e.value);case"object":return Rqf(e.properties);case"array":return _Q1(e.value);case"map":return hQ1(e.value);case"oneOf":return yQ1(e.value);case"enum":return e.value;case"literal":return vQ1(e.value);case"unknown":return Rzr(e.value);default:Ol(e)}}function Iqf(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:Ol(e)}}function Rqf(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Rzr(r)]))}function _Q1(e){return e.map(t=>Rzr(t))}function hQ1(e){return Object.fromEntries(e.map(t=>[Iqf(t.key),Rzr(t.value)]))}function yQ1(e){return e.type==="discriminated"?Rqf(e.value):Rzr(e.value)}function vQ1(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ol(e)}}function bEr(e){var t;return(t=e.find(r=>typeof r!="string"&&r.type==="namespace"))==null?void 0:t.name}function z1a(e,t){return t??((e==null?void 0:e.groupName)!=null?bEr(e.groupName):void 0)}function Fqf({channel:e,context:t,declarationFile:r}){let n={path:e.path,auth:!1};e.summary!=null&&(n["display-name"]=e.summary);let i=bEr(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=eba({pathParameter:d,context:t,fileContainingReference:r,namespace:i});Object.keys(a).length>0&&(n["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let c=N1a({queryParameter:d,context:t,fileContainingReference:r,namespace:i});c!=null&&(u[d.name]=c)}Object.keys(u).length>0&&(n["query-parameters"]=u);let f={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let c=IRt({header:d,context:t,fileContainingReference:r,namespace:i});f[d.name]=c}Object.keys(f).length>0&&(n.headers=f),t.builder.addChannel(r,{channel:n}),e.subscribe!=null&&t.builder.addChannelMessage(r,{messageId:"subscribe",message:{origin:"server",body:S1({schema:e.subscribe,context:t,fileContainingReference:r,namespace:i})}}),e.publish!=null&&t.builder.addChannelMessage(r,{messageId:"publish",message:{origin:"client",body:S1({schema:e.publish,context:t,fileContainingReference:r,namespace:i})}});for(let d of e.examples){let c=Bqf({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:c})}}var Lqf="Production",Uqf="Default";function Vqf(e){return Object.entries(e).reduce((t,[r,n])=>(U2n(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function Wqf(e){var f,d;if(e.environmentOverrides!=null){for(let[c,o]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:c,schema:o});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[];for(let c of e.ir.servers){let o=c.audiences?{url:c.url,audiences:c.audiences}:c.url;if(c.name==null){r.push(o);continue}t[c.name]=o}let n={},i=[];for(let c of e.ir.endpoints)for(let o of c.server){if(o.url==null)continue;let l=o.audiences?{url:o.url,audiences:o.audiences}:o.url;if(o.name==null){i.push(l);continue}n[o.name]=l}let a=Object.keys(t).length,u=Object.keys(n).length;if(a===0&&u===0){let c=(f=e.ir.servers[0])==null?void 0:f.url,o=(d=e.ir.servers[0])==null?void 0:d.audiences;c!=null&&(e.builder.addEnvironment({name:Uqf,schema:o?{url:c,audiences:o}:c}),e.builder.setDefaultEnvironment(Uqf))}else if(a>0&&u===0){let c=0;r.length>0&&e.logger.error(`Skipping servers ${r.map(o=>typeof o=="string"?o:o.url).join(", ")} because x-fern-server-name was not provided.`);for(let[o,l]of Object.entries(t))c===0&&e.builder.setDefaultEnvironment(o),e.builder.addEnvironment({name:o,schema:l}),c+=1}else if(u>0){(r.length>0||i.length>0)&&e.logger.error(`Skipping servers ${[...r,...i].map(o=>typeof o=="string"?o:o.url).join(", ")} because x-fern-server-name was not provided.`);let c=Object.entries(t)[0];if(c!=null){let[o,l]=c;e.setDefaultServerName(o)}e.builder.addEnvironment({name:Lqf,schema:{urls:{...Vqf(t),...Vqf(n)}}}),e.builder.setDefaultEnvironment(Lqf)}}function B1a(e){return A2(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var eOu=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},bQ1=.75,gQ1=new Set("authorization");function Hqf(e){let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,n]of Object.entries(t)){let i="optional<string>";if(n.name==null&&n.env==null&&typeof n.schema=="string")i=n.schema;else if(n!=null){let a=n.schema?V7n(n.schema):void 0,u=a!=null?bEr(a):void 0,f=zs.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?A2(S1({schema:n.schema,context:e,fileContainingReference:u?pf(zs.of(FE(u)),f):f,namespace:u}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:i})}if(e.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let a of i.headers){if(gQ1.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let f=t[a.name],d=IRt({header:{...a,schema:(f==null?void 0:f.schema)??a.schema,name:(f==null?void 0:f.name)??a.name},fileContainingReference:zs.of(nB),context:e,namespace:void 0});u=new eOu(d),r[a.name]=u}u.increment()}let n=e.ir.endpoints.length*bQ1;for(let[i,a]of Object.entries(r)){let u=t[i],f=a.count===e.ir.endpoints.length,d=a.count>=n;u==null&&(f?e.builder.addGlobalHeader({name:i,schema:a.schema}):d&&e.builder.addGlobalHeader({name:i,schema:B1a(a.schema)}))}}}function $qf(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?V7n(t.schema):void 0,n=r!=null?bEr(r):void 0,i=IRt({header:{...t,schema:t.schema??ib.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:Xw.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0})}),name:t.name??t.header,parameterNameOverride:void 0,description:void 0,availability:void 0,source:void 0},fileContainingReference:zs.of(nB),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:B1a(i)})}}function lG(e){switch(e.type){case"primitive":return Jqf(e.value);case"object":return Gqf(e.properties);case"array":return mQ1(e.value);case"map":return OQ1(e.value);case"oneOf":return PQ1(e.value);case"enum":return e.value;case"literal":return jQ1(e.value);case"unknown":return lG(e.value);default:Ol(e)}}function Jqf(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:Ol(e)}}function Gqf(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,lG(r)]))}function mQ1(e){return e.map(t=>lG(t))}function OQ1(e){return Object.fromEntries(e.map(t=>[Jqf(t.key),lG(t.value)]))}function PQ1(e){return e.type==="discriminated"?Gqf(e.value):lG(e.value)}function jQ1(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ol(e)}}function Kqf({endpointExample:e,context:t}){let r={};return e.type!=="full"?e.value:(e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=wQ1(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=DQ1(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=SQ1({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=lG(e.request)),e.response!=null&&(r.response={body:lG(e.response)}),e.response!=null&&(r.response={body:lG(e.response)}),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(n=>n.type==="language"?{name:n.name??void 0,docs:n.description??void 0,language:n.language,code:n.code,install:n.install??void 0}:{name:n.name??void 0,docs:n.description??void 0,sdk:n.sdk,code:n.code}).filter(RS)),r)}function wQ1(e){let t={};return e.forEach(r=>{let n=lG(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function DQ1(e){let t={};return e.forEach(r=>{let n=lG(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function SQ1({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=lG(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function Yqf(e){return KJ._visit(e,{get:()=>h5.HttpMethodSchema.Enum.GET,post:()=>h5.HttpMethodSchema.Enum.POST,put:()=>h5.HttpMethodSchema.Enum.PUT,patch:()=>h5.HttpMethodSchema.Enum.PATCH,delete:()=>h5.HttpMethodSchema.Enum.DELETE,head:()=>{throw new Error("HEAD is unsupported")},options:()=>{throw new Error("HEAD is unsupported")},trace:()=>{throw new Error("HEAD is unsupported")},_other:()=>{throw new Error("Unkown http method is unsupported")}})}function Xqf({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,u=e.path,f=z1a(e.sdkName,e.namespace),d={};for(let S of e.pathParameters)S.parameterNameOverride&&(u=u.replace(S.name,S.parameterNameOverride)),d[S.parameterNameOverride??S.name]=eba({pathParameter:S,context:r,fileContainingReference:t,namespace:f}),a.add(S.name);let c={};for(let S of e.queryParameters){let x=N1a({queryParameter:S,context:r,fileContainingReference:t,namespace:f});x!=null&&(c[S.name]=x,a.add(S.name))}let o;e.pagination!=null&&(e.pagination.type==="cursor"?o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results}:o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage});let l={path:u,method:Yqf(e.method),auth:e.authed,docs:e.description??void 0,pagination:o};Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let g={},O=r.builder.getGlobalHeaderNames(),j=e.headers.filter(S=>!O.has(S.name));for(let S of j){let x=IRt({header:S,context:r,fileContainingReference:t,namespace:f});g[S.name]=x,a.add(typeof x=="string"?S.name:x.name??S.name)}if(e.request!=null){let S=MQ1({context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,queryParameters:Object.keys(c).length>0?c:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(g).length>0?g:void 0,usedNames:a,namespace:f});l.request=S.value,i=[...i,...S.schemaIdsToExclude??[]]}else{let S=Object.keys(c).length>0,x=Object.keys(g).length>0,A={};(S||x)&&(A.name=e.requestNameOverride??e.generatedRequestName),S&&(A["query-parameters"]=c),x&&(A.headers=g),Object.keys(A).length>0&&(l.request=A)}if(e.response!=null&&e.response._visit({json:S=>{let x=S1({schema:S.schema,context:r,fileContainingReference:t,namespace:f});l.response={docs:S.description??void 0,type:A2(x)},S.responseProperty!=null&&(l.response.property=S.responseProperty)},streamingJson:S=>{let x=S1({schema:S.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:S.description??void 0,type:A2(x),format:"json"}},streamingSse:S=>{let x=S1({schema:S.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:S.description??void 0,type:A2(x),format:"sse"}},file:S=>{l.response={docs:S.description??void 0,type:"file"}},streamingText:S=>{l["response-stream"]={docs:S.description??void 0,type:"text"}},text:S=>{l.response={docs:S.description??void 0,type:"text"}},_other:()=>{var S;throw new Error("Unrecognized Response type: "+((S=e.response)==null?void 0:S.type))}}),r.builder.getEnvironmentType()==="multi"){let S=r.getDefaultServerName(),x=e.server[0];x==null?S!=null&&(l.url=S):l.url=x.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=q3(e.availability)),Object.entries(e.errors).forEach(([S,x])=>{var te;let A=x.generatedName,z=zs.of(HT);r.builder.enableUniqueErrorsPerEndpoint&&(A=`${e.generatedRequestName}${x.generatedName}`,x.schema!=null&&(x.schema.type!=="reference"&&x.schema.type!=="oneOf"?x.schema.generatedName=`${e.generatedRequestName}${x.schema.generatedName}`:x.schema.type==="oneOf"&&(x.schema.value.generatedName=`${e.generatedRequestName}${x.schema.value.generatedName}`)));let N={"status-code":parseInt(S)},C=Gdf({location:Qqf,namespaceOverride:f});if(x.schema!=null){let G=S1({schema:x.schema,context:r,fileContainingReference:C,declarationFile:C,namespace:f});N.type=A2(G),N.docs=x.description}r.builder.addError(C,{name:A,schema:N}),l.errors==null&&(l.errors=[]);let U=r.builder.addImport({file:t,fileToImport:C});l.errors.push(U!=null?`${U}.${A}`:A),N.type!=null&&((te=x.examples)==null||te.forEach(G=>{let $={value:lG(G.example),name:G.name,docs:G.description};r.builder.addErrorExample(C,{name:A,example:$})}))}),e.examples.length>0&&(l.examples=EQ1({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[tOu,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function EQ1({endpointExamples:e,context:t}){return e.map(r=>{try{return Kqf({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function MQ1({declarationFile:e,context:t,request:r,requestNameOverride:n,generatedRequestName:i,queryParameters:a,nonRequestReferencedSchemas:u,headers:f,usedNames:d,namespace:c}){if(r.type==="json"){let o=r.schema.type==="reference"?r.schema.schema:void 0,l=r.schema.type==="reference"?t.getSchema(r.schema.schema,c):r.schema;if((l==null?void 0:l.type)!=="object"||o!=null&&u.includes(o)){let x=S1({schema:r.schema,fileContainingReference:e,context:t,namespace:c}),A={schemaIdsToExclude:[],value:{body:x}},z=Object.keys(a??{}).length>0,N=Object.keys(f??{}).length>0;return z&&(A.value["query-parameters"]=a),N&&(A.value.headers=f),(z||N)&&(A.value.name=n??i),r.contentType!=null&&(A.value["content-type"]=r.contentType),A}let g=Object.fromEntries(l.properties.map(x=>{let A=S1({schema:x.schema,fileContainingReference:e,context:t,namespace:c}),z=x.nameOverride??x.key,N=q3(x.availability);if(!d.has(z)&&x.audiences.length<=0)return d.add(z),x.nameOverride!=null?[x.key,{type:A2(A),docs:A_i(A),name:x.nameOverride,availability:N}]:[x.key,N?{...typeof A=="string"?{type:A}:A,availability:N}:A];let C={type:A2(A),docs:A_i(A)};return d.has(z)&&(C.name=x.generatedName),x.audiences.length>0&&(C.audiences=x.audiences),N!=null&&(C.availability=N),d.add(z),[x.key,C]})),O=l.allOf.map(x=>{let A=S1({schema:ib.reference(x),fileContainingReference:e,context:t,namespace:c});return A2(A)}),j={properties:g};O.length>0&&(j.extends=O),r.additionalProperties&&(j["extra-properties"]=!0);let S={name:n??l.nameOverride??l.generatedName,"query-parameters":a,headers:f,body:j};return r.contentType!=null&&(S["content-type"]=r.contentType),{schemaIdsToExclude:o!=null?[o]:[],value:S}}else{if(r.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":sA.APPLICATION_OCTET_STREAM}};if(r.type==="multipart"){let o=Object.fromEntries(r.properties.map(l=>{if(l.schema.type==="file"){let g=l.schema.isArray?"list<file>":"file";if(g=l.schema.isOptional?`optional<${g}>`:g,l.description!=null||l.contentType!=null){let O={type:g};return l.description!=null&&(O.docs=l.description),l.contentType!=null&&(O["content-type"]=l.contentType),[l.key,O]}return[l.key,g]}else{let g=S1({schema:l.schema.value,fileContainingReference:e,context:t,namespace:c});return l.contentType!=null&&(typeof g=="string"?g={type:g,"content-type":l.contentType}:g["content-type"]=l.contentType),[l.key,g]}}));return{schemaIdsToExclude:r.name==null?[]:[r.name],value:{name:n??r.name??i,"query-parameters":a,headers:f,body:{properties:o},"content-type":sA.MULTIPART_FORM_DATA}}}else Ol(r)}}function xQ1({location:e,namespaceOverride:t}){return t!=null?{...e,file:pf(zs.of(t),e.file)}:e}function TQ1(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:zs.of(`${FE(r)}.yml`),endpointId:e.summary!=null?FE(e.summary):FE(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:zs.of(HT),endpointId:FE(e.summary)}:{file:zs.of(HT),endpointId:FE(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:zs.of(HT),endpointId:n};let i=A0i(r),a=A0i(n);if(iDr(i,a))return{file:zs.of("__package__.yml"),endpointId:r};let u=AQ1({operationId:n,tag:r,path:e.path,method:e.method});if(u!=null)return u;let f=[];for(let d=0;d<i.length;++d){let c=i[d];if(c!=null&&c===a[d])f.push(c);else{let o=FE(r);return{file:zs.of(`${o}.yml`),endpointId:n,tag:r}}}if(f.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:zs.of(FE(f.join("_"))+".yml"),endpointId:FE(a.slice(f.length).join("_")),tag:r}}function N0i(e){let t=e.tags[0];if(e.sdkName!=null){let r=klu({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===(t==null?void 0:t.toLowerCase().replaceAll(" ",""));return{file:zs.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return xQ1({namespaceOverride:e.namespace,location:TQ1(e)})}function A0i(e){let t;return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)?t=e.split(/(?=[A-Z])/):t=e.split(/[^a-zA-Z0-9]+/),t=t.map(r=>r.toLowerCase()),t=X8t(t),t}var qQ1=new RegExp("[^a-zA-Z0-9{}]+"),CQ1=new RegExp("[{}]","g");function AQ1({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(qQ1).join("_").replaceAll(CQ1,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:zs.of(FE(t)+".yml"),endpointId:FE(e.slice(0,-1*a.length)),tag:t}}function Zqf(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:u,file:f,tag:d}=N0i(a),c=f.split(".")[0];c!=null&&t.add(c);let o;if(a.sdkName!=null){let O=e.ir.groups;for(let j of a.sdkName.groupName){let S=typeof j=="string"?j:j.name,x=O[S];if(x==null)break;if(x.summary!=null||x.description!=null){o=O[S];break}}}let l=d==null?void 0:n.tagsById[d],g=Xqf({context:e,endpoint:a,declarationFile:f});i=[...i,...g.schemaIdsToExclude],e.builder.addEndpoint(f,{name:u,schema:g.value,source:a.source}),((l==null?void 0:l.id)!=null||(l==null?void 0:l.description)!=null)&&e.builder.setServiceInfo(f,{displayName:(o==null?void 0:o.summary)??(l==null?void 0:l.id),docs:(o==null?void 0:o.description)??(l==null?void 0:l.description)??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}function kqf(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?bEr(r.groupName):void 0,i=S1({schema:ib.primitive(r),context:e,fileContainingReference:zs.of(HT),namespace:n});e.builder.addVariable({name:t,schema:{type:A2(i),docs:r.description??void 0}})}}function eCf(e){for(let t of e.ir.webhooks){let r=BQ1({webhook:t,context:e});if(r==null)continue;let n=z1a(t.sdkName,t.namespace),i={};for(let u of t.headers)i[u.name]=IRt({header:u,context:e,fileContainingReference:r.file,namespace:n});let a={method:t.method,"display-name":t.summary??void 0,headers:i,payload:S1({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:lG(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function NQ1({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:pf(zs.of(t),e.file)}:e}function zQ1({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:zs.of(HT),endpointId:n};let i=A0i(r),a=A0i(n);if(iDr(i,a))return{file:zs.of("__package__.yml"),endpointId:r};let u=[];for(let f=0;f<i.length;++f){let d=i[f];if(d!=null&&d===a[f])u.push(d);else{let c=FE(r);return{file:zs.of(`${c}.yml`),endpointId:n,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:zs.of(FE(u.join("_"))+".yml"),endpointId:FE(a.slice(u.length).join("_")),tag:r}}function BQ1({webhook:e,context:t}){return e.sdkName!=null?{file:Jdf({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:NQ1({namespaceOverride:e.namespace,location:zQ1({webhook:e,context:t})})}var IQ1=zs.of(HT);function tCf(e){switch(e.type){case"object":return bFt(e.groupName);case"enum":return bFt(e.groupName);case"oneOf":return bFt(e.value.groupName);case"array":return bFt(e.groupName);case"map":return bFt(e.groupName);case"reference":return bFt(e.groupName);case"literal":return bFt(e.groupName);case"optional":return bFt(e.groupName);case"nullable":return bFt(e.groupName);case"primitive":return bFt(e.groupName);case"unknown":return IQ1;default:Ol(e)}}function bFt(e){return W7n(e)}var tOu="external",Qqf=zs.of(HT);function rCf({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let u=tCf(a),f=Xdf({schema:a,context:n,declarationFile:u,namespace:r});if(W2n(f.schema)){let d=A2(f.schema);if(d===(f.name??i)||d===`optional<${f.name??i}>`)continue}n.builder.addType(u,{name:f.name??i,schema:f.schema})}}function nCf(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),Wqf(e),Hqf(e),$qf(e),epf(e),kqf(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(tOu);let{schemaIdsToExclude:t,sdkGroups:r}=Zqf(e);eCf(e);for(let n of e.ir.channel){let i=W7n(n.groupName);Fqf({channel:n,context:e,declarationFile:i})}rCf({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:t,namespace:void 0,context:e});for(let[n,i]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))rCf({schemas:i,schemaIdsToExclude:t,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(i=>r.has(i))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}var Fzr=yu(require("path"),1);var I1a=yu(require("path"),1),G3n=class{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[u,f]of Object.entries(n.files)){let d=i!=null?zs.of(`${i}${I1a.default.sep}${u}`):zs.of(u);t[d]=f}let a=Object.keys(n.directories).sort();for(let u of a){let f=i!=null?`${i}${I1a.default.sep}${u}`:u,d=n.directories[u];r(d,f)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(I1a.default.sep))}getOrCreateFileRecursive(t){var i,a;if(t.length===1)return(i=this.files)[a=zs.of(t[0])]??(i[a]={});let[r,...n]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new G3n),this.directories[r].getOrCreateFileRecursive(n)}};var R1a=class{modifyBasePaths;enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t,r,n){this.modifyBasePaths=r,this.enableUniqueErrorsPerEndpoint=n,this.root=new G3n,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}},t.title!=null&&(this.rootApiFile["display-name"]=t.title)}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{displayName:r,docs:n}){let i=this.getOrCreateFile(t);i.service==null&&(i.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(i.service["display-name"]=r),n!=null&&(i.docs=n)}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 ADr(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??{}),r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}addGlobalHeader({name:t,schema:r}){let n=this.getVersionHeader();n!=null&&n===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}){if(t===r)return;let n=FE((Cg(r)+"/"+(0,Fzr.basename)(r,(0,Fzr.extname)(r))).replaceAll("__package__","root"));if(t===zs.of(nB))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=YN(Cg(I_.of(`/${t}`)),I_.of(`/${r}`)),n;let i=this.getOrCreateFile(t);return i.imports==null&&(i.imports={}),i.imports[n]=YN(Cg(I_.of(`/${t}`)),I_.of(`/${r}`)),n}addType(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.types==null&&(i.types={}),i.types[r]=n}addTypeExample(t,r,n){let i=this.getOrCreateFile(t);i.types==null&&(i.types={});let a=i.types[r];a!=null&&(typeof a=="string"?i.types[r]={type:a,examples:[n]}:(a.examples==null&&(a.examples=[]),a.examples.push(n)))}addError(t,{name:r,schema:n}){var a;let i=this.getOrCreateFile(t);i.errors==null&&(i.errors={}),i.errors[r]==null?i.errors[r]=n:((a=i.errors[r])==null?void 0:a.type)!==n.type&&(i.errors[r]={"status-code":n["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:n}){var f;let i=this.getOrCreateFile(t);if(i.errors==null)return;let a=i.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(d=>iDr(d,n))??!1)||(f=a.examples)==null||f.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(a.service.source=Ien(i)),a.service.endpoints[r]=n}addWebhook(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.webhooks==null&&(i.webhooks={}),i.webhooks[r]=n}addChannel(t,{channel:r}){let n=this.getOrCreateFile(t);n.channel=r;let i=this.basePath;i!=null&&(n.channel.path=Fzr.default.join(i,r.path))}addChannelExample(t,{example:r}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.examples==null&&(n.channel.examples=[]),n.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:n}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.messages[r]=n}build(){let t=this.root.getAllFiles();if(this.modifyBasePaths){let i=RQ1(this.rootApiFile);this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([a,u])=>[a,{...u,path:`${i}${u.path}`}]))});for(let a of Object.values(t))a.service!=null&&(a.service={...a.service,endpoints:Object.fromEntries(Object.entries(a.service.endpoints).map(([u,f])=>[u,{...f,path:`${i}${f.path}`}]))});this.rootApiFile.environments!=null&&(this.rootApiFile.environments={...Object.fromEntries(Object.entries(this.rootApiFile.environments).map(([a,u])=>typeof u=="string"?[a,u.substring(0,u.length-i.length)]:iCf(u)?[a,{url:u.url.substring(0,u.url.length-i.length)}]:[a,{urls:Object.fromEntries(Object.entries(u.urls).map(([f,d])=>[f,d.substring(0,d.length-i.length)]))}]))})}let 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(([i,a])=>[i,{...a,path:Fzr.default.join(r,a.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([a,u])=>[a,{...u,path:Fzr.default.join(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===HT?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 RQ1(e){if(e.environments==null)return"";let t=Object.entries(e.environments).flatMap(([r,n])=>typeof n=="string"?[n]:iCf(n)?[n.url]:Object.values(n.urls));return LQ1(t.map(FQ1))}function FQ1(e){try{let r=new URL(e).pathname;return r.endsWith("/")?r.slice(0,-1):r}catch{return""}}function LQ1(e){let t="";for(;;){let r=e.map(i=>i[i.length-t.length-1]),n=r[0];if(n==null||r.some(i=>i!==n))break;t=n+t}return t}function iCf(e){return e.url!=null}var F1a=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;detectGlobalHeaders;defaultServerName=void 0;constructor({taskContext:t,ir:r,enableUniqueErrorsPerEndpoint:n,detectGlobalHeaders:i,environmentOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.builder=new R1a(r,!1,n),this.detectGlobalHeaders=i,this.environmentOverrides=a,this.authOverrides=u}getSchema(t,r){var n;return r==null?this.ir.groupedSchemas.rootSchemas[t]:(n=this.ir.groupedSchemas.namespacedSchemas[r])==null?void 0:n[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}};function rOu(e){let t=new F1a(e);return nCf(t)}var CAf=yu(qAf(),1);async function iwe(e,t,r=[],{doNotPipeOutput:n=!1,secrets:i=[],substitutions:a={},...u}={}){var o,l;let f=i.reduce((g,O)=>({...g,[O]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[g,O]of Object.entries(f))d=d.replaceAll(g,O);e==null||e.debug(`+ ${d}`);let c=(0,CAf.default)(t,r,u);return n||((o=c.stdout)==null||o.pipe(process.stdout),(l=c.stderr)==null||l.pipe(process.stderr)),c}function G1a(e,{logger:t,...r}={}){return(n,i)=>iwe(t,e,n,{...r,...i})}var Y1a=require("fs/promises"),AAf=yu(Jte(),1),Ak1="buf.gen.yaml",NAf="output",Nk1=`${NAf}/openapi.yaml`,zk1=`
|
|
1907
|
+
`)),{ok:!0,value:t}):n}}function e0a(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var g5r=class extends Error{errors;constructor(t){super(t.map(e0a).join("; ")),this.errors=t,Object.setPrototypeOf(this,g5r.prototype)}};var m5r=class extends Error{errors;constructor(t){super(t.map(e0a).join("; ")),this.errors=t,Object.setPrototypeOf(this,m5r.prototype)}};function hA(e){return{optional:()=>$lu(e),transform:t=>Jlu(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new m5r(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new g5r(n.errors)}}}function $lu(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>(n==null?void 0:n.omitUndefined)&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>VS.OPTIONAL};return{...t,...hA(t)}}function Jlu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...hA(r)}}var A01=/^([+-]?\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 hdf(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:rC(t,"string")}]}:A01.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:rC(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:rC(t,"Date object")}]},getType:()=>VS.DATE};return{...YJ(e),...hA(e)}}function XJ(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...YJ(r),...hA(r)}}}function t0a(e){let t=new Set(e);return XJ(VS.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:rC(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:rC(n,"enum")}]}:{ok:!0,value:n})()}function ydf(e){let t=Glu(e);return{...t,...hA(t)}}function Glu(e){return{parse:(t,r)=>m7n(e).parse(t,r),json:(t,r)=>m7n(e).json(t,r),getType:()=>m7n(e).getType()}}function m7n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function T_i(e){return Object.entries(e)}function q_i(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function O5r(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 C_i(e){return Object.keys(e)}function vdf(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function NRt(e){return{withParsedProperties:t=>Klu(e,t)}}function Klu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((f,[d,c])=>({...f,[d]:typeof c=="function"?c(a.value):c}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!O5r(n))return{ok:!1,errors:[{path:(i==null?void 0:i.breadcrumbsPrefix)??[],message:rC(n,"object")}]};let a=new Set(Object.keys(t)),u=q_i(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...hA(r),...NRt(r)}}function bdf(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function P5r(e){return e.isProperty}function r0a(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>P5r(n)?n.rawKey:r),_getParsedProperties:()=>C_i(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of T_i(e)){let d=P5r(f)?f.rawKey:u,c=P5r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,Odf(c)&&a.push(d)}return gdf({value:r,requiredKeys:a,getProperty:u=>{let f=i[u];if(f!=null)return{transformedKey:f.parsedKey,transform:d=>f.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],u]})}},unrecognizedObjectKeys:n==null?void 0:n.unrecognizedObjectKeys,skipValidation:n==null?void 0:n.skipValidation,breadcrumbsPrefix:n==null?void 0:n.breadcrumbsPrefix,omitUndefined:n==null?void 0:n.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,u]of T_i(e)){let f=P5r(u)?u.valueSchema:u;Odf(f)&&i.push(a)}return gdf({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return P5r(u)?{transformedKey:u.rawKey,transform:f=>u.valueSchema.json(f,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],a]})}:{transformedKey:a,transform:f=>u.json(f,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],a]})}},unrecognizedObjectKeys:n==null?void 0:n.unrecognizedObjectKeys,skipValidation:n==null?void 0:n.skipValidation,breadcrumbsPrefix:n==null?void 0:n.breadcrumbsPrefix,omitUndefined:n==null?void 0:n.omitUndefined})},getType:()=>VS.OBJECT};return{...YJ(t),...hA(t),...NRt(t),...O7n(t)}}function gdf({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!O5r(e))return{ok:!1,errors:[{path:a,message:rC(e,"object")}]};let u=new Set(t),f=[],d={};for(let[c,o]of Object.entries(e)){let l=r(c);if(l!=null){u.delete(c);let g=l.transform(o);g.ok?d[l.transformedKey]=g.value:(d[c]=o,f.push(...g.errors))}else switch(n){case"fail":f.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":d[c]=o;break}}return f.push(...t.filter(c=>u.has(c)).map(c=>({path:a,message:`Missing required key "${c}"`}))),f.length===0||i?{ok:!0,value:d}:{ok:!1,errors:f}}function O7n(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>mdf({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>mdf({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>VS.OBJECT};return{...r,...hA(r),...NRt(r),...O7n(r)}}}}function mdf({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=vdf(C_i(t),c=>i.has(c)),f=r(q_i(t,u)),d=n(q_i(t,a));return f.ok&&d.ok?{ok:!0,value:{...f.value,...d.value}}:{ok:!1,errors:[...f.ok?[]:f.errors,...d.ok?[]:d.errors]}}function Odf(e){return!N01(e)}function N01(e){switch(e.getType()){case VS.ANY:case VS.UNKNOWN:case VS.OPTIONAL:return!0;default:return!1}}function Pdf(e){return r0a(e)}function jdf(e){let t={...Glu(e),_getRawProperties:()=>m7n(e)._getRawProperties(),_getParsedProperties:()=>m7n(e)._getParsedProperties()};return{...t,...hA(t),...NRt(t),...O7n(t)}}function n0a(e){let t={parse:(r,n)=>wdf(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],`[${a}]`]})),json:(r,n)=>wdf(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],`[${a}]`]})),getType:()=>VS.LIST};return{...YJ(t),...hA(t)}}function wdf(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:rC(e,"list"),path:[]}]}}function Ddf(e){return XJ(VS.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:rC(r,`"${e}"`)}]})()}function Sdf(e){return XJ(VS.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:rC(r,`${e.toString()}`)}]})()}var Edf=XJ(VS.ANY,e=>({ok:!0,value:e}));var Mdf=XJ(VS.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"boolean")}]});var xdf=XJ(VS.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"number")}]});var Tdf=XJ(VS.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"string")}]});var qdf=XJ(VS.UNKNOWN,e=>({ok:!0,value:e}));function Adf(e,t){let r={parse:(n,i)=>Cdf({value:n,isKeyNumeric:e.getType()===VS.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...(i==null?void 0:i.breadcrumbsPrefix)??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...i,breadcrumbsPrefix:[...(i==null?void 0:i.breadcrumbsPrefix)??[],`${u}`]}),breadcrumbsPrefix:i==null?void 0:i.breadcrumbsPrefix}),json:(n,i)=>Cdf({value:n,isKeyNumeric:e.getType()===VS.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...(i==null?void 0:i.breadcrumbsPrefix)??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...i,breadcrumbsPrefix:[...(i==null?void 0:i.breadcrumbsPrefix)??[],`${u}`]}),breadcrumbsPrefix:i==null?void 0:i.breadcrumbsPrefix}),getType:()=>VS.RECORD};return{...YJ(r),...hA(r)}}function Cdf({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return O5r(e)?T_i(e).reduce((a,[u,f])=>{if(f==null)return a;let d=a,c=u;if(t){let O=u.length>0?Number(u):NaN;isNaN(O)||(c=O)}let o=r(c),l=n(f,c);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let g=[];return d.ok||g.push(...d.errors),o.ok||g.push(...o.errors),l.ok||g.push(...l.errors),{ok:!1,errors:g}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:rC(e,"object")}]}}function Ndf(e){let t=n0a(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:(i==null?void 0:i.breadcrumbsPrefix)??[],message:rC(n,"Set")}]},getType:()=>VS.SET};return{...YJ(r),...hA(r)}}function Bdf(e){let t={parse:(r,n)=>zdf((i,a)=>i.parse(r,a),e,n),json:(r,n)=>zdf((i,a)=>i.json(r,a),e,n),getType:()=>VS.UNDISCRIMINATED_UNION};return{...YJ(t),...hA(t)}}function zdf(e,t,r){let n=[];for(let[i,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let f of u.errors)n.push({path:f.path,message:`[Variant ${i}] ${f.message}`})}return{ok:!1,errors:n}}function Idf(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Fdf(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=t0a(C_i(t)),a={parse:(u,f)=>Rdf({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:f==null?void 0:f.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(f==null?void 0:f.breadcrumbsPrefix)??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f==null?void 0:f.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.parse(d,f),breadcrumbsPrefix:f==null?void 0:f.breadcrumbsPrefix}),json:(u,f)=>Rdf({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:f==null?void 0:f.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(f==null?void 0:f.breadcrumbsPrefix)??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f==null?void 0:f.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.json(d,f),breadcrumbsPrefix:f==null?void 0:f.breadcrumbsPrefix}),getType:()=>VS.UNION};return{...YJ(a),...hA(a),...NRt(a)}}function Rdf({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!O5r(e))return{ok:!1,errors:[{path:f,message:rC(e,"object")}]};let{[t]:d,...c}=e;if(d==null)return{ok:!1,errors:[{path:f,message:`Missing discriminant ("${t}")`}]};let o=n(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=i(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...c}}:{ok:!1,errors:[{path:[...f,t],message:"Unexpected discriminant value"}]};let g=u(c,l);return g.ok?{ok:!0,value:{[r]:d,...g.value}}:g}var j1=Wn.objectWithoutOptionalProperties({title:Wn.string().optional()});var i0a=Wn.objectWithoutOptionalProperties({file:Wn.string()});var a0a=Wn.objectWithoutOptionalProperties({file:Wn.string()});var o0a=Wn.union("type",{openapi:i0a,protobuf:a0a}).transform({transform:e=>{switch(e.type){case"openapi":return HSr.openapi(e);case"protobuf":return HSr.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var hb=Wn.objectWithoutOptionalProperties({source:o0a.optional()});var u0a=Wn.objectWithoutOptionalProperties({typeName:Wn.string()});var s0a=Wn.union("type",{protobuf:u0a}).transform({transform:e=>{switch(e.type){case"protobuf":return b7n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ene=Wn.objectWithoutOptionalProperties({encoding:s0a.optional()});var O_=Wn.objectWithoutOptionalProperties({description:Wn.string().optional()});var c0a=Wn.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Z0=Wn.objectWithoutOptionalProperties({availability:c0a.optional()});var Ym=Wn.objectWithoutOptionalProperties({nameOverride:Wn.string().optional(),generatedName:Wn.string()});var wQ=Wn.string();var Kje=Wn.string();var l0a=Wn.objectWithoutOptionalProperties({id:Kje}).extend(O_);var f0a=Wn.string();var d0a=Wn.objectWithoutOptionalProperties({usernameVariableName:Wn.string().optional(),usernameEnvVar:Wn.string().optional(),passwordVariableName:Wn.string().optional(),passwordEnvVar:Wn.string().optional()});var p0a=Wn.objectWithoutOptionalProperties({tokenVariableName:Wn.string().optional(),tokenEnvVar:Wn.string().optional()});var _0a=Wn.objectWithoutOptionalProperties({headerName:Wn.string(),prefix:Wn.string().optional(),headerVariableName:Wn.string().optional(),headerEnvVar:Wn.string().optional()});var h0a=Wn.objectWithoutOptionalProperties({queryParameterName:Wn.string()});var y0a=Wn.objectWithoutOptionalProperties({snake:Wn.string().optional(),camel:Wn.string().optional(),screamingSnake:Wn.string().optional(),pascal:Wn.string().optional()});var j5r=Wn.objectWithoutOptionalProperties({nameOverride:Wn.string().optional(),generatedName:Wn.string(),value:Wn.string(),casing:y0a.optional()}).extend(O_).extend(Z0);var v0a=Wn.objectWithoutOptionalProperties({type:Wn.stringLiteral("namespace"),name:Wn.string()});var b0a=Wn.undiscriminatedUnion([Wn.string(),v0a]);var w5r=Wn.list(b0a);var w1=Wn.objectWithoutOptionalProperties({groupName:w5r.optional()});var P7n=Wn.objectWithoutOptionalProperties({default:j5r.optional(),values:Wn.list(j5r)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var g0a=Wn.objectWithoutOptionalProperties({scopesEnum:P7n.optional()});var m0a=Wn.union("type",{basic:d0a,bearer:p0a,header:_0a,query:h0a,oauth:g0a}).transform({transform:e=>{switch(e.type){case"basic":return F9.basic(e);case"bearer":return F9.bearer(e);case"header":return F9.header(e);case"query":return F9.query(e);case"oauth":return F9.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var D5r=Wn.number();var O0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),url:Wn.string(),audiences:Wn.list(Wn.string()).optional()}).extend(O_);var P0a=Wn.string();var S5r=Wn.objectWithoutOptionalProperties({namespace:Wn.string().optional()});var Xlu={};Wb(Xlu,{FullExample:()=>yA,FullObjectExample:()=>w0a,FullOneOfExample:()=>S0a,KeyValuePair:()=>D0a,LiteralExample:()=>j0a,PrimitiveExample:()=>w7n,PropertyKey:()=>j7n});var j7n=Wn.string();var w7n=Wn.union("type",{int:Wn.object({value:Wn.number()}),int64:Wn.object({value:Wn.number()}),uint:Wn.object({value:Wn.number()}),uint64:Wn.object({value:Wn.number()}),float:Wn.object({value:Wn.number()}),double:Wn.object({value:Wn.number()}),string:Wn.object({value:Wn.string()}),datetime:Wn.object({value:Wn.string()}),date:Wn.object({value:Wn.string()}),base64:Wn.object({value:Wn.string()}),boolean:Wn.object({value:Wn.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return t0.int(e.value);case"int64":return t0.int64(e.value);case"uint":return t0.uint(e.value);case"uint64":return t0.uint64(e.value);case"float":return t0.float(e.value);case"double":return t0.double(e.value);case"string":return t0.string(e.value);case"datetime":return t0.datetime(e.value);case"date":return t0.date(e.value);case"base64":return t0.base64(e.value);case"boolean":return t0.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var j0a=Wn.union("type",{boolean:Wn.object({value:Wn.boolean()}),string:Wn.object({value:Wn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return g7n.boolean(e.value);case"string":return g7n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var yA=Wn.union("type",{primitive:Wn.object({value:w7n}),object:Wn.lazyObject(()=>w0a),array:Wn.object({value:Wn.list(Wn.lazy(()=>yA))}),map:Wn.object({value:Wn.list(Wn.lazyObject(()=>D0a))}),enum:Wn.object({value:Wn.string()}),literal:Wn.object({value:j0a}),oneOf:Wn.object({value:Wn.lazy(()=>S0a)}),unknown:Wn.object({value:Wn.lazy(()=>yA)})}).transform({transform:e=>{switch(e.type){case"primitive":return RP.primitive(e.value);case"object":return RP.object(e);case"array":return RP.array(e.value);case"map":return RP.map(e.value);case"enum":return RP.enum(e.value);case"literal":return RP.literal(e.value);case"oneOf":return RP.oneOf(e.value);case"unknown":return RP.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var w0a=Wn.objectWithoutOptionalProperties({properties:Wn.record(j7n,Wn.lazy(()=>yA))});var D0a=Wn.objectWithoutOptionalProperties({key:w7n,value:Wn.lazy(()=>yA)});var S0a=Wn.union("type",{discriminated:Wn.object({value:Wn.record(j7n,Wn.lazy(()=>yA))}),undisciminated:Wn.object({value:Wn.lazy(()=>yA)})}).transform({transform:e=>{switch(e.type){case"discriminated":return v5r.discriminated(e.value);case"undisciminated":return v5r.undisciminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Qlu={};Wb(Qlu,{AllOfPropertyConflict:()=>I7n,ArraySchema:()=>fva,Availability:()=>c0a,BooleanSchema:()=>ava,CasingOverrides:()=>y0a,CommonProperty:()=>gva,CursorPagination:()=>H0a,CustomCodeSample:()=>V0a,CustomCodeSampleLanguage:()=>F0a,CustomCodeSampleSdk:()=>U0a,DiscriminatedOneOfSchema:()=>vva,DoubleSchema:()=>nva,Endpoint:()=>J0a,EndpointExample:()=>N7n,EndpointSdkName:()=>M5r,EnumSchema:()=>P7n,EnumValue:()=>j5r,ErrorExample:()=>z0a,FernExample:()=>I0a,FileResponse:()=>T7n,FileSchema:()=>x0a,FullEndpointExample:()=>W0a,GlobalHeader:()=>uva,Header:()=>E5r,HeaderExample:()=>A7n,HttpEndpointServer:()=>q7n,HttpError:()=>B0a,HttpMethod:()=>D7n,IdempotencyHeader:()=>sva,IntSchema:()=>tva,JsonRequest:()=>C0a,JsonResponse:()=>KSr,LiteralSchema:()=>B7n,LiteralSchemaValue:()=>cva,LongSchema:()=>rva,MapSchema:()=>dva,MultipartRequest:()=>x7n,MultipartRequestProperty:()=>q0a,MultipartSchema:()=>T0a,NullableSchema:()=>_va,ObjectProperty:()=>yva,ObjectPropertyConflictInfo:()=>R7n,ObjectSchema:()=>lva,OctetStreamRequest:()=>M7n,OffsetPagination:()=>$0a,OneOfSchema:()=>hva,OpenApiIntermediateRepresentation:()=>Ldf,OptionalSchema:()=>pva,Pagination:()=>z7n,PathParameter:()=>S7n,PathParameterExample:()=>R0a,PrimitiveSchema:()=>T5r,PrimitiveSchemaValue:()=>ova,QueryParameter:()=>E7n,QueryParameterExample:()=>C7n,ReferencedSchema:()=>zRt,Request:()=>A0a,Response:()=>N0a,Schema:()=>D1,Schemas:()=>eva,SdkGroupInfo:()=>E0a,StringSchema:()=>iva,SupportedSdkLanguage:()=>L0a,Tags:()=>M0a,TextResponse:()=>x5r,UnDiscriminatedOneOfSchema:()=>bva,Webhook:()=>Y0a,WebhookExampleCall:()=>K0a,WebhookHttpMethod:()=>G0a,WebsocketChannel:()=>k0a,WebsocketHandshake:()=>X0a,WebsocketMessageExample:()=>Q0a,WebsocketSessionExample:()=>Z0a});var E0a=Wn.objectWithoutOptionalProperties({summary:Wn.string().optional(),description:Wn.string().optional()});var M0a=Wn.objectWithoutOptionalProperties({tagsById:Wn.record(Kje,l0a),orderedTagIds:Wn.list(Kje).optional()});var D7n=Wn.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var S7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),variableReference:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var E7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var E5r=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),env:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var M5r=Wn.objectWithoutOptionalProperties({groupName:w5r,methodName:Wn.string()});var M7n=Wn.objectWithoutOptionalProperties({}).extend(O_).extend(hb);var x0a=Wn.objectWithoutOptionalProperties({isOptional:Wn.boolean(),isArray:Wn.boolean()});var T0a=Wn.union("type",{file:x0a,json:Wn.object({value:Wn.lazy(()=>D1)})}).transform({transform:e=>{switch(e.type){case"file":return D2e.file(e);case"json":return D2e.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var q0a=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:T0a,contentType:Wn.string().optional()}).extend(O_);var x7n=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),properties:Wn.list(q0a)}).extend(O_).extend(hb);var C0a=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1),contentType:Wn.string().optional(),additionalProperties:Wn.boolean()}).extend(O_).extend(hb);var A0a=Wn.union("type",{octetStream:M7n,multipart:x7n,json:C0a}).transform({transform:e=>{switch(e.type){case"octetStream":return b5r.octetStream(e);case"multipart":return b5r.multipart(e);case"json":return b5r.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var T7n=Wn.objectWithoutOptionalProperties({}).extend(O_).extend(hb);var KSr=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1),responseProperty:Wn.string().optional()}).extend(O_).extend(hb);var x5r=Wn.objectWithoutOptionalProperties({}).extend(O_).extend(hb);var N0a=Wn.union("type",{file:T7n,json:KSr,text:x5r,streamingSse:KSr,streamingText:x5r,streamingJson:KSr}).transform({transform:e=>{switch(e.type){case"file":return Sne.file(e);case"json":return Sne.json(e);case"text":return Sne.text(e);case"streamingSse":return Sne.streamingSse(e);case"streamingText":return Sne.streamingText(e);case"streamingJson":return Sne.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var z0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),description:Wn.string().optional(),example:Wn.lazy(()=>yA)});var B0a=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1).optional(),examples:Wn.list(z0a).optional()}).extend(O_).extend(Ym).extend(hb);var q7n=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),url:Wn.string().optional(),audiences:Wn.list(Wn.string()).optional()});var I0a=Wn.unknown();var R0a=Wn.objectWithoutOptionalProperties({name:Wn.string(),parameterNameOverride:Wn.string().optional(),value:Wn.lazy(()=>yA)});var C7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),value:Wn.lazy(()=>yA)});var A7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),value:Wn.lazy(()=>yA)});var F0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),language:Wn.string(),code:Wn.string(),install:Wn.string().optional()}).extend(O_);var L0a=Wn.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var U0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),sdk:L0a,code:Wn.string()}).extend(O_);var V0a=Wn.union("type",{language:F0a,sdk:U0a}).transform({transform:e=>{switch(e.type){case"language":return JSr.language(e);case"sdk":return JSr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var W0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),pathParameters:Wn.list(R0a).optional(),queryParameters:Wn.list(C7n).optional(),headers:Wn.list(A7n).optional(),request:Wn.lazy(()=>yA).optional(),response:Wn.lazy(()=>yA).optional(),codeSamples:Wn.list(V0a)}).extend(O_);var N7n=Wn.union("type",{unknown:Wn.object({value:I0a}),full:W0a}).transform({transform:e=>{switch(e.type){case"unknown":return pAt.unknown(e.value);case"full":return pAt.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var H0a=Wn.objectWithoutOptionalProperties({cursor:Wn.string(),nextCursor:Wn.property("next_cursor",Wn.string()),results:Wn.string()});var $0a=Wn.objectWithoutOptionalProperties({offset:Wn.string(),results:Wn.string(),step:Wn.string().optional(),hasNextPage:Wn.string().optional()});var z7n=Wn.union("type",{cursor:H0a,offset:$0a}).transform({transform:e=>{switch(e.type){case"cursor":return $Sr.cursor(e);case"offset":return $Sr.offset(e);default:return e}},untransform:({_visit:e,...t})=>t});var J0a=Wn.objectWithoutOptionalProperties({authed:Wn.boolean(),internal:Wn.boolean().optional(),idempotent:Wn.boolean().optional(),method:D7n,audiences:Wn.list(Wn.string()),path:Wn.string(),summary:Wn.string().optional(),operationId:Wn.string().optional(),tags:Wn.list(Kje),pathParameters:Wn.list(S7n),queryParameters:Wn.list(E7n),headers:Wn.list(E5r),sdkName:M5r.optional(),generatedRequestName:Wn.string(),requestNameOverride:Wn.string().optional(),request:A0a.optional(),response:N0a.optional(),errors:Wn.record(D5r,B0a),server:Wn.list(q7n),examples:Wn.list(N7n),pagination:z7n.optional()}).extend(O_).extend(Z0).extend(hb).extend(S5r);var G0a=Wn.enum_(["GET","POST"]);var K0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),payload:Wn.lazy(()=>yA)}).extend(O_);var Y0a=Wn.objectWithoutOptionalProperties({sdkName:M5r.optional(),method:G0a,summary:Wn.string().optional(),operationId:Wn.string(),tags:Wn.list(Kje),headers:Wn.list(E5r),generatedPayloadName:Wn.string(),payload:Wn.lazy(()=>D1),examples:Wn.list(K0a)}).extend(O_).extend(hb).extend(S5r);var X0a=Wn.objectWithoutOptionalProperties({queryParameters:Wn.list(E7n),headers:Wn.list(E5r),pathParameters:Wn.list(S7n)});var Q0a=Wn.objectWithoutOptionalProperties({messageType:Wn.string(),payload:Wn.lazy(()=>yA)}).extend(O_);var Z0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),queryParameters:Wn.list(C7n).optional(),headers:Wn.list(A7n).optional(),messages:Wn.list(Q0a)}).extend(O_);var k0a=Wn.objectWithoutOptionalProperties({path:Wn.string(),groupName:w5r,summary:Wn.string().optional(),handshake:X0a,publish:Wn.lazy(()=>D1).optional(),subscribe:Wn.lazy(()=>D1).optional(),examples:Wn.list(Z0a)}).extend(O_).extend(hb);var eva=Wn.objectWithoutOptionalProperties({rootSchemas:Wn.record(wQ,Wn.lazy(()=>D1)),namespacedSchemas:Wn.record(P0a,Wn.record(wQ,Wn.lazy(()=>D1)))});var tva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),minimum:Wn.number().optional(),maximum:Wn.number().optional(),exclusiveMinimum:Wn.boolean().optional(),exclusiveMaximum:Wn.boolean().optional(),multipleOf:Wn.number().optional()});var rva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional()});var nva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),minimum:Wn.number().optional(),maximum:Wn.number().optional(),exclusiveMinimum:Wn.boolean().optional(),exclusiveMaximum:Wn.boolean().optional(),multipleOf:Wn.number().optional()});var iva=Wn.objectWithoutOptionalProperties({default:Wn.string().optional(),pattern:Wn.string().optional(),format:Wn.string().optional(),minLength:Wn.number().optional(),maxLength:Wn.number().optional()});var ava=Wn.objectWithoutOptionalProperties({default:Wn.boolean().optional()});var ova=Wn.union("type",{int:tva,int64:rva,uint:Wn.object({}),uint64:Wn.object({}),float:Wn.object({}),double:nva,string:iva,datetime:Wn.object({}),date:Wn.object({}),base64:Wn.object({}),boolean:ava}).transform({transform:e=>{switch(e.type){case"int":return Xw.int(e);case"int64":return Xw.int64(e);case"uint":return Xw.uint();case"uint64":return Xw.uint64();case"float":return Xw.float();case"double":return Xw.double(e);case"string":return Xw.string(e);case"datetime":return Xw.datetime();case"date":return Xw.date();case"base64":return Xw.base64();case"boolean":return Xw.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var T5r=Wn.objectWithoutOptionalProperties({schema:ova}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var uva=Wn.objectWithoutOptionalProperties({header:Wn.string(),name:Wn.string().optional(),optional:Wn.boolean().optional(),env:Wn.string().optional(),schema:Wn.lazy(()=>D1).optional()});var sva=Wn.objectWithoutOptionalProperties({header:Wn.string(),name:Wn.string().optional(),env:Wn.string().optional(),schema:Wn.lazy(()=>D1).optional()});var Ldf=Wn.objectWithoutOptionalProperties({apiVersion:Wn.unknown().optional(),title:Wn.string().optional(),description:Wn.string().optional(),basePath:Wn.string().optional(),servers:Wn.list(O0a),groups:Wn.record(Wn.string(),E0a),tags:M0a,hasEndpointsMarkedInternal:Wn.boolean(),endpoints:Wn.list(J0a),webhooks:Wn.list(Y0a),channel:Wn.list(k0a),groupedSchemas:eva,variables:Wn.record(Wn.string(),T5r),nonRequestReferencedSchemas:Wn.set(wQ),securitySchemes:Wn.record(f0a,m0a),globalHeaders:Wn.list(uva).optional(),idempotencyHeaders:Wn.list(sva).optional()});var zRt=Wn.objectWithoutOptionalProperties({schema:wQ}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var cva=Wn.union("type",{boolean:Wn.object({value:Wn.boolean()}),string:Wn.object({value:Wn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return E7.boolean(e.value);case"string":return E7.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var B7n=Wn.objectWithoutOptionalProperties({value:cva}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var D1=Wn.union("type",{primitive:T5r,object:Wn.lazyObject(()=>lva),array:Wn.lazyObject(()=>fva),map:Wn.lazyObject(()=>dva),optional:Wn.lazyObject(()=>pva),enum:P7n,reference:zRt,literal:B7n,oneOf:Wn.object({value:Wn.lazy(()=>hva)}),nullable:Wn.lazyObject(()=>_va),unknown:Ym}).transform({transform:e=>{switch(e.type){case"primitive":return ib.primitive(e);case"object":return ib.object(e);case"array":return ib.array(e);case"map":return ib.map(e);case"optional":return ib.optional(e);case"enum":return ib.enum(e);case"reference":return ib.reference(e);case"literal":return ib.literal(e);case"oneOf":return ib.oneOf(e.value);case"nullable":return ib.nullable(e);case"unknown":return ib.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var I7n=Wn.objectWithoutOptionalProperties({propertyKey:Wn.string(),allOfSchemaIds:Wn.list(wQ),conflictingTypeSignatures:Wn.boolean()});var lva=Wn.objectWithoutOptionalProperties({allOf:Wn.list(zRt),properties:Wn.list(Wn.lazyObject(()=>yva)),allOfPropertyConflicts:Wn.list(I7n),additionalProperties:Wn.boolean()}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var R7n=Wn.objectWithoutOptionalProperties({differentSchema:Wn.boolean()});var yva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>D1),conflict:Wn.record(wQ,R7n),generatedName:Wn.string(),nameOverride:Wn.string().optional(),audiences:Wn.list(Wn.string())}).extend(Z0);var fva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var dva=Wn.objectWithoutOptionalProperties({key:T5r,value:Wn.lazy(()=>D1)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(j1);var pva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var _va=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var hva=Wn.union("type",{discriminated:Wn.lazyObject(()=>vva),undisciminated:Wn.lazyObject(()=>bva)}).transform({transform:e=>{switch(e.type){case"discriminated":return GSr.discriminated(e);case"undisciminated":return GSr.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var vva=Wn.objectWithoutOptionalProperties({discriminantProperty:Wn.string(),commonProperties:Wn.list(Wn.lazyObject(()=>gva)),schemas:Wn.record(Wn.string(),Wn.lazy(()=>D1))}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var gva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>D1)});var bva=Wn.objectWithoutOptionalProperties({schemas:Wn.list(Wn.lazy(()=>D1))}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var Zlu={};Wb(Zlu,{ArraySchemaWithExample:()=>Lva,Base64WithExample:()=>zva,BooleanWithExample:()=>Bva,CommonPropertyWithExample:()=>Yva,DateWithExample:()=>Nva,DatetimeWithExample:()=>Ava,DiscriminatedOneOfSchemaWithExample:()=>Gva,DoubleWithExample:()=>qva,EndpointWithExample:()=>Vdf,EnumSchemaWithExample:()=>Rva,FloatWithExample:()=>Tva,HeaderWithExample:()=>L7n,HttpErrorWithExample:()=>Dva,Int64WithExample:()=>Eva,IntWithExample:()=>Sva,JsonRequestWithExample:()=>Ova,JsonResponseWithExample:()=>jva,MapSchemaWithExample:()=>Uva,NamedFullExample:()=>BRt,NullableSchemaWithExample:()=>Wva,ObjectPropertyWithExample:()=>Jva,ObjectSchemaWithExample:()=>Hva,OneOfSchemaWithExample:()=>$va,OptionalSchemaWithExample:()=>Vva,PathParameterWithExample:()=>mva,PrimitiveSchemaValueWithExample:()=>Iva,PrimitiveSchemaWithExample:()=>U7n,QueryParameterWithExample:()=>F7n,RequestWithExample:()=>Pva,ResponseWithExample:()=>wva,SchemaWithExample:()=>aq,StringSchemaWithExample:()=>Cva,Uint64WithExample:()=>xva,UintWithExample:()=>Mva,UnDiscriminatedOneOfSchemaWithExample:()=>Kva,UnknownSchemaWithExample:()=>Fva,WebsocketHandshakeWithExample:()=>Udf});var BRt=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),value:Wn.unknown()}).extend(O_);var F7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>aq),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var L7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>aq),env:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var Udf=Wn.objectWithoutOptionalProperties({queryParameters:Wn.list(F7n),headers:Wn.list(L7n)});var mva=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>aq),variableReference:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var Ova=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>aq),contentType:Wn.string().optional(),fullExamples:Wn.list(BRt).optional(),additionalProperties:Wn.boolean()}).extend(O_).extend(hb);var Pva=Wn.union("type",{octetStream:M7n,multipart:x7n,json:Ova}).transform({transform:e=>{switch(e.type){case"octetStream":return S2e.octetStream(e);case"multipart":return S2e.multipart(e);case"json":return S2e.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var jva=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>aq),responseProperty:Wn.string().optional(),fullExamples:Wn.list(BRt).optional()}).extend(O_).extend(hb);var wva=Wn.union("type",{file:T7n,json:jva,text:x5r,streamingSse:KSr,streamingText:x5r,streamingJson:KSr}).transform({transform:e=>{switch(e.type){case"file":return T3.file(e);case"json":return T3.json(e);case"text":return T3.text(e);case"streamingSse":return T3.streamingSse(e);case"streamingText":return T3.streamingText(e);case"streamingJson":return T3.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Dva=Wn.objectWithoutOptionalProperties({statusCode:D5r,schema:Wn.lazy(()=>aq),fullExamples:Wn.list(BRt).optional()}).extend(O_).extend(Ym).extend(hb);var Vdf=Wn.objectWithoutOptionalProperties({authed:Wn.boolean(),internal:Wn.boolean().optional(),idempotent:Wn.boolean().optional(),method:D7n,audiences:Wn.list(Wn.string()),path:Wn.string(),summary:Wn.string().optional(),operationId:Wn.string().optional(),tags:Wn.list(Kje),pathParameters:Wn.list(mva),queryParameters:Wn.list(F7n),headers:Wn.list(L7n),sdkName:M5r.optional(),generatedRequestName:Wn.string(),requestNameOverride:Wn.string().optional(),request:Pva.optional(),response:wva.optional(),errors:Wn.record(D5r,Dva),server:Wn.list(q7n),examples:Wn.list(N7n),pagination:z7n.optional()}).extend(O_).extend(Z0).extend(hb).extend(S5r);var Sva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),minimum:Wn.number().optional(),maximum:Wn.number().optional(),exclusiveMinimum:Wn.boolean().optional(),exclusiveMaximum:Wn.boolean().optional(),multipleOf:Wn.number().optional(),example:Wn.number().optional()});var Eva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var Mva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var xva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var Tva=Wn.objectWithoutOptionalProperties({example:Wn.number().optional()});var qva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),minimum:Wn.number().optional(),maximum:Wn.number().optional(),exclusiveMinimum:Wn.boolean().optional(),exclusiveMaximum:Wn.boolean().optional(),multipleOf:Wn.number().optional(),example:Wn.number().optional()});var Cva=Wn.objectWithoutOptionalProperties({default:Wn.string().optional(),pattern:Wn.string().optional(),format:Wn.string().optional(),minLength:Wn.number().optional(),maxLength:Wn.number().optional(),example:Wn.string().optional()});var Ava=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var Nva=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var zva=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var Bva=Wn.objectWithoutOptionalProperties({default:Wn.boolean().optional(),example:Wn.boolean().optional()});var Iva=Wn.union("type",{int:Sva,int64:Eva,uint:Mva,uint64:xva,float:Tva,double:qva,string:Cva,datetime:Ava,date:Nva,base64:zva,boolean:Bva}).transform({transform:e=>{switch(e.type){case"int":return by.int(e);case"int64":return by.int64(e);case"uint":return by.uint(e);case"uint64":return by.uint64(e);case"float":return by.float(e);case"double":return by.double(e);case"string":return by.string(e);case"datetime":return by.datetime(e);case"date":return by.date(e);case"base64":return by.base64(e);case"boolean":return by.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var U7n=Wn.objectWithoutOptionalProperties({schema:Iva}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var Rva=Wn.objectWithoutOptionalProperties({default:j5r.optional(),values:Wn.list(j5r),example:Wn.string().optional()}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var Fva=Wn.objectWithoutOptionalProperties({example:Wn.unknown()}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(j1);var aq=Wn.union("type",{primitive:U7n,object:Wn.lazyObject(()=>Hva),array:Wn.lazyObject(()=>Lva),map:Wn.lazyObject(()=>Uva),optional:Wn.lazyObject(()=>Vva),enum:Rva,reference:zRt,literal:B7n,oneOf:Wn.object({value:Wn.lazy(()=>$va)}),nullable:Wn.lazyObject(()=>Wva),unknown:Fva}).transform({transform:e=>{switch(e.type){case"primitive":return Lp.primitive(e);case"object":return Lp.object(e);case"array":return Lp.array(e);case"map":return Lp.map(e);case"optional":return Lp.optional(e);case"enum":return Lp.enum(e);case"reference":return Lp.reference(e);case"literal":return Lp.literal(e);case"oneOf":return Lp.oneOf(e.value);case"nullable":return Lp.nullable(e);case"unknown":return Lp.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var Lva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>aq),example:Wn.list(Wn.unknown()).optional()}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(j1);var Uva=Wn.objectWithoutOptionalProperties({key:U7n,value:Wn.lazy(()=>aq),example:Wn.unknown().optional()}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(Ene).extend(j1);var Vva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>aq)}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(j1);var Wva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>aq)}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(j1);var Hva=Wn.objectWithoutOptionalProperties({allOf:Wn.list(zRt),properties:Wn.list(Wn.lazyObject(()=>Jva)),allOfPropertyConflicts:Wn.list(I7n),fullExamples:Wn.list(BRt).optional(),additionalProperties:Wn.boolean()}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var Jva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>aq),audiences:Wn.list(Wn.string()),conflict:Wn.record(wQ,R7n),nameOverride:Wn.string().optional(),generatedName:Wn.string()}).extend(Z0);var $va=Wn.union("type",{discriminated:Wn.lazyObject(()=>Gva),undisciminated:Wn.lazyObject(()=>Kva)}).transform({transform:e=>{switch(e.type){case"discriminated":return jQ.discriminated(e);case"undisciminated":return jQ.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Gva=Wn.objectWithoutOptionalProperties({discriminantProperty:Wn.string(),commonProperties:Wn.list(Wn.lazyObject(()=>Yva)),schemas:Wn.record(Wn.string(),Wn.lazy(()=>aq))}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var Yva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>aq)});var Kva=Wn.objectWithoutOptionalProperties({schemas:Wn.list(Wn.lazy(()=>aq))}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);function Xva(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Ol(e.type)}}function V7n(e){switch(e.type){case"object":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":case"primitive":return e.groupName??void 0;case"oneOf":return e.value.groupName??void 0;case"unknown":return;default:Ol(e)}}function A2(e){return typeof e=="string"?e:e.type}function A_i(e){if(typeof e!="string")return e.docs}function Wdf(e){if(typeof e!="string")return e.default}function Hdf(e){if(typeof e!="string")return e.validation}function z01(e){let t=e.find(n=>typeof n=="object"&&n.type==="namespace"),r=e.filter(n=>typeof n=="string"||n.type!=="namespace");return t?[t,...r]:r}function $df(e){let t=e?z01(e):void 0;if(t==null||t.length===0)return zui;let r=[];for(let[n,i]of t.entries())if(typeof i=="string")r.push(FE(i));else if(typeof i=="object")switch(i.type){case"namespace":{n<t.length-1?r.push(FE(i.name)):r.push(i.name,zui);break}default:Ol(i.type)}else Ol(i);return r.join("/")}function W7n(e){return zs.of(`${$df(e)}.yml`)}function klu({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?zui:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,$df(r))}function Jdf({sdkName:e,namespaceOverride:t}){return zs.of(`${klu({sdkName:e,namespaceOverride:t})}.yml`)}function Gdf({location:e,namespaceOverride:t}){return t!=null?pf(zs.of(t),e):e}function q3(e){switch(e){case vW.Deprecated:return"deprecated";case vW.Beta:return"pre-release";case vW.GenerallyAvailable:return"generally-available";default:return}}var B01=-2147483648,I01=2147483647,R01=-17976931348623157e292,F01=17976931348623157e292;function S1({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i}){switch(e.type){case"primitive":return Qva(e);case"array":return rfu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"map":return nfu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"reference":return tfu({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return afu();case"optional":case"nullable":return ifu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"enum":return K01({schema:e,fileContainingReference:t,context:n,declarationFile:r});case"literal":return e.value,ofu(e);case"object":return Y01({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"oneOf":return X01({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i});default:Ol(e)}}function Qva(e){switch(e.schema.type){case"string":return V01({description:e.description,schema:e.schema});case"int":return W01({description:e.description,schema:e.schema});case"float":return H01({description:e.description,schema:e.schema});case"double":return $01({description:e.description,schema:e.schema});case"boolean":return L01({description:e.description,schema:e.schema});case"int64":return U01({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{...e.title!=null?{"display-name":e.title}:{},type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function L01({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function U01({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function V01({description:e,schema:t}){let r="string",n=J01(t);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function W01({description:e,schema:t}){let r="integer",n=Kdf(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function H01({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function $01({description:e,schema:t}){let r="double",n=Kdf(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function J01(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=G01(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function G01(e){switch(e){case"date":case"date-time":case"password":case"byte":case"bytes":case"binary":case"email":case"uuid":case"uri":case"hostname":case"ipv4":case"ipv6":return e;default:return}}function Kdf(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=efu(r,t),n=efu(n,t),i=efu(i,t),!(r==null&&n==null&&a==null&&u==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:u,multipleOf:i}}function efu(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[B01,I01]:[R01,F01];return e<r||e>n?void 0:e}function tfu({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=Q01(i)??e.schema,u=V7n(i),f=Z01(i),d=Zva({context:r,fileContainingReference:t,declarationFile:W7n(u),type:a}),c=i.type==="nullable"?`optional<${d}>`:d;return e.description==null&&f==null?c:{...f!=null?{"display-name":f}:{},type:i.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function rfu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=S1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=`list<${A2(a)}>`;return e.description==null&&e.title==null?u:{...e.title!=null?{"display-name":e.title}:{},...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{},type:u}}function nfu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Qva(e.key),u=S1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),f=e.encoding!=null?Xva(e.encoding):void 0,d=`map<${A2(a)}, ${A2(u)}>`;if(e.description==null&&f==null&&e.title==null)return d;let c={type:d};return e.description!=null&&(c.docs=e.description),e.encoding!=null&&(c.encoding=f),e.title!=null&&(c["display-name"]=e.title),e.availability!=null&&(c.availability=q3(e.availability)),c}function ifu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=S1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=A2(a),f=A_i(a),d=Wdf(a),c=Hdf(a),o=u.startsWith("optional<")?u:`optional<${u}>`;if(e.availability==null&&e.description==null&&f==null&&d==null&&c==null&&e.title==null)return o;let l={type:o};return(e.description!=null||f!=null)&&(l.docs=e.description??f),d!=null&&(l.default=d),c!=null&&(l.validation=c),e.title!=null&&(l["display-name"]=e.title),e.availability!=null&&(l.availability=q3(e.availability)),l}function afu(){return"unknown"}function ofu(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Ol(e.value)}return e.description==null&&e.title==null?t:{...e.title!=null?{"display-name":e.title}:{},type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function K01({schema:e,fileContainingReference:t,declarationFile:r,context:n}){let i=N_i(e),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:i.schema});let u=Zva({type:a,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return u;let f={type:u};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.title!=null&&(f["display-name"]=e.title),e.availability!=null&&(f.availability=q3(e.availability)),f}function Y01({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=ufu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=Zva({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{...e.title!=null?{"display-name":e.title}:{},type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function X01({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=sfu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=Zva({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{...e.title!=null?{"display-name":e.title}:{},type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function Zva({type:e,fileContainingReference:t,declarationFile:r,context:n}){if(r===t)return e;let i=n.builder.addImport({file:t,fileToImport:r});return i!=null?`${i}.${e}`:e}function Q01(e){return ib._visit(e,{primitive:t=>t.nameOverride??t.generatedName,object:t=>t.nameOverride??t.generatedName,array:t=>t.nameOverride??t.generatedName,map:t=>t.nameOverride??t.generatedName,enum:t=>t.nameOverride??t.generatedName,reference:t=>t.nameOverride??t.generatedName,literal:t=>t.nameOverride??t.generatedName,oneOf:t=>t.nameOverride??t.generatedName,optional:t=>t.nameOverride??t.generatedName,nullable:t=>t.nameOverride??t.generatedName,unknown:t=>t.nameOverride??t.generatedName,_other:()=>{}})}function Z01(e){return ib._visit(e,{primitive:t=>t.title,object:t=>t.title,array:t=>t.title,map:t=>t.title,enum:t=>t.title,reference:t=>t.title,literal:t=>t.title,oneOf:t=>t.title,optional:t=>t.title,nullable:t=>t.title,unknown:t=>{},_other:()=>{}})}function Ien(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Ol(e)}}function Xdf({schema:e,context:t,declarationFile:r,namespace:n}){switch(e.type){case"primitive":return tv1(e);case"array":return k01({schema:e,context:t,declarationFile:r,namespace:n});case"map":return ev1({schema:e,context:t,declarationFile:r,namespace:n});case"reference":return rv1({schema:e,context:t,declarationFile:r,namespace:n});case"unknown":return iv1(e.nameOverride,e.generatedName);case"optional":case"nullable":return nv1({schema:e,context:t,declarationFile:r,namespace:n});case"enum":return N_i(e);case"literal":return av1(e,e.nameOverride,e.generatedName);case"object":return ufu({schema:e,context:t,declarationFile:r,namespace:n});case"oneOf":return sfu({schema:e.value,context:t,declarationFile:r,namespace:n});default:Ol(e)}}function ufu({schema:e,context:t,declarationFile:r,namespace:n}){let i={},a=new Set;for(let c of e.properties){if(Object.keys(c.conflict).length>0){if(Object.entries(c.conflict).every(([S,x])=>!x.differentSchema))continue;Object.entries(c.conflict).forEach(([S])=>{cfu({property:c.key,schemaId:S,context:t,namespace:n}).forEach(A=>{a.add(A)})})}let o=S1({schema:c.schema,context:t,fileContainingReference:r,namespace:n}),l=c.audiences,g=c.nameOverride,O=q3(c.availability);i[c.key]=sv1(o,l,g,O)}let u=new Set;for(let c of e.allOfPropertyConflicts)c.allOfSchemaIds.forEach(o=>a.add(o)),c.conflictingTypeSignatures&&u.add(c.propertyKey);let f=[];for(let c of e.allOf){let o=Qdf({schema:c.schema,context:t,namespace:n});if(o==null||a.has(c.schema)||a.has(o))continue;let l=S1({schema:ib.reference(c),context:t,fileContainingReference:r,namespace:n});f.push(A2(l))}for(let c of a){let o=lfu(t,c,n);for(let l of o.properties)i[l.key]==null&&(u.has(l.key)&&(i[l.key]="unknown"),i[l.key]=S1({schema:l.schema,context:t,fileContainingReference:r,namespace:n}));for(let l of o.allOf){if(a.has(l.schema))continue;let g=S1({schema:ib.reference(l),context:t,fileContainingReference:r,namespace:n});f.push(A2(g))}}let d={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(i).map(([c,o])=>uv1(c)?[c,typeof o=="string"?{type:o,name:`_${c}`}:{...o,name:`_${c}`}]:[c,o]))};return f.length>0&&(d.extends=f),e.additionalProperties&&(d["extra-properties"]=!0),e.availability!=null&&(d.availability=q3(e.availability)),e.source!=null&&(d.source=Ien(e.source)),{name:e.nameOverride??e.generatedName,schema:d}}function cfu({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return cfu({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:u}=lfu(r,t,n),f=a.some(c=>c.key===e),d=[...u.flatMap(c=>cfu({property:e,context:r,schemaId:c.schema,namespace:n}))];if(f||d.length>0)return[t,...d]}return[]}function lfu(e,t,r){let n=e.getSchema(t,r);if(n==null)return{properties:[],allOf:[]};if(n.type==="object")return{properties:n.properties,allOf:n.allOf};if(n.type==="reference")return lfu(e,n.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${n.type}`)}function k01({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:rfu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function ev1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:nfu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function tv1(e){let t=Qva(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...n}=t;return{name:e.nameOverride??e.generatedName,schema:{...n}}}function Ydf(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function N_i(e){let t={enum:e.values.map(i=>{let a=i.nameOverride??i.generatedName,u=i.value;if(a===u&&i.description==null&&(i.casing==null||Ydf(i.casing)))return a;let f={value:i.value};if(a!==u&&(f.name=a),i.description!=null&&(f.docs=i.description),i.casing!=null&&!Ydf(i.casing)){let d={},c=!1;i.casing.camel!=null&&(d.camel=i.casing.camel,c=!0),i.casing.screamingSnake!=null&&(d["screaming-snake"]=i.casing.screamingSnake,c=!0),i.casing.snake!=null&&(d.snake=i.casing.snake,c=!0),i.casing.pascal!=null&&(d.pascal=i.casing.pascal,c=!0),c&&(f.casing=d)}return f})};e.description!=null&&(t.docs=e.description),e.default!=null&&(t.default=e.default.value);let r=new Set,n={...t,enum:[],source:e.source!=null?Ien(e.source):void 0};for(let i of t.enum){let a=typeof i=="string"?i:i.name??i.value;r.has(a.toLowerCase())||(n.enum.push(i),r.add(a.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function rv1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:tfu({schema:e,context:t,fileContainingReference:r,namespace:n})}}function nv1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:ifu({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n})}}function iv1(e,t){return{name:e??t,schema:afu()}}function av1(e,t,r){return{name:t??r,schema:ofu(e)}}function sfu({schema:e,context:t,declarationFile:r,namespace:n}){let i=e.encoding!=null?Xva(e.encoding):void 0;if(e.type==="discriminated"){let u={};for(let d of e.commonProperties)u[d.key]=S1({schema:d.schema,fileContainingReference:r,context:t,namespace:n});let f={};for(let[d,c]of Object.entries(e.schemas))f[d]=S1({schema:c,context:t,fileContainingReference:r,namespace:n});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":u,docs:e.description??void 0,availability:e.availability!=null?q3(e.availability):void 0,union:f,encoding:i,source:e.source!=null?Ien(e.source):void 0}}}let a=[];for(let u of e.schemas)a.push(S1({schema:u,fileContainingReference:r,context:t,namespace:n}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:a,encoding:i,source:e.source!=null?Ien(e.source):void 0}}}var ov1=/^[0-9]/;function uv1(e){return ov1.test(e)}function Qdf({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?Qdf({context:t,schema:n.schema,namespace:r}):e}function sv1(e,t,r,n){return t.length===0&&r==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{}}}function Zdf(e){let t=e.replace(/^x-|^X-/,"");return FE(t)}var kdf="BasicAuthScheme",kva="BearerAuthScheme";function epf(e){if(e.authOverrides!=null){for(let[r,n]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:n});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,n]of Object.entries(e.ir.securitySchemes))if(n.type==="basic"){let i={scheme:"basic"};n.usernameVariableName!=null&&(i.username===void 0?i.username={name:n.usernameVariableName}:i.username.name=n.usernameVariableName),n.usernameEnvVar!=null&&(i.username===void 0?i.username={env:n.usernameEnvVar}:i.username.env=n.usernameEnvVar),n.passwordVariableName!=null&&(i.password===void 0?i.password={name:n.passwordVariableName}:i.password.name=n.passwordVariableName),n.passwordEnvVar!=null&&(i.password===void 0?i.password={env:n.passwordEnvVar}:i.password.env=n.passwordEnvVar),e.builder.addAuthScheme({name:kdf,schema:i}),t||(e.builder.setAuth(kdf),t=!0)}else if(n.type==="bearer"){let i={scheme:"bearer"};n.tokenVariableName!=null&&(i.token===void 0?i.token={name:n.tokenVariableName}:i.token.name=n.tokenVariableName),n.tokenEnvVar!=null&&(i.token===void 0?i.token={env:n.tokenEnvVar}:i.token.env=n.tokenEnvVar),e.builder.addAuthScheme({name:kva,schema:i}),t||(e.builder.setAuth(kva),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??Zdf(n.headerName),env:n.headerEnvVar}});else{let i={header:n.headerName,name:n.headerVariableName??"apiKey",type:"string"};n.headerEnvVar!=null&&(i.env=n.headerEnvVar),n.prefix!=null&&(i.prefix=n.prefix),e.builder.addAuthScheme({name:r,schema:i}),e.builder.setAuth(r),t=!0}else if(n.type==="oauth"){let i={scheme:"bearer"};e.builder.addAuthScheme({name:kva,schema:i}),t||(e.builder.setAuth(kva),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(zs.of("__package__.yml"),{name:"OauthScope",schema:N_i(n.scopesEnum).schema})}}function IRt({header:e,context:t,fileContainingReference:r,namespace:n}){let i=S1({schema:e.schema,context:t,fileContainingReference:r,namespace:n}),a=A2(i),u=e.name.replace(/^x-|^X-/,""),f=e.parameterNameOverride!=null?e.parameterNameOverride:FE(u);if(e.description==null&&e.name===f&&e.env==null&&e.availability==null)return a;let d={type:a};return f!==e.name&&(d.name=f),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=q3(e.availability)),d}function eba({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=S1({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(e.variableReference==null&&e.description==null&&e.availability==null)return A2(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:A2(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=q3(e.availability)),a}var Zmu=require("fs/promises");var tpf={naming:"v1"};function Lh(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function RRt(e,t,r,n,i=[]){try{let a=Lh(e,t);if(a!=null)return r.parse(a)}catch{let u=X8t(i).join(" -> ");n.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}var tba={of(e){return e}};var kh={SDK_METHOD_NAME:tba.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:tba.of("x-fern-sdk-group-name"),REQUEST_NAME_V1:"x-request-name",REQUEST_NAME_V2:"x-fern-request-name",TYPE_NAME:"x-fern-type-name",BOOLEAN_LITERAL:"x-fern-boolean-literal",SERVER_NAME_V1:"x-name",SERVER_NAME_V2:"x-fern-server-name",BASE_PATH:"x-fern-base-path",GROUPS:tba.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport"};function gy(e){return e.$ref!=null}function E2e(e){switch(Lh(e,kh.AVAILABILITY)){case"deprecated":return vW.Deprecated;case"beta":return vW.Beta;case"generally-available":return vW.GenerallyAvailable;default:break}if(!gy(e)&&e.deprecated)return vW.Deprecated}var Yje={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};function rpf({schema:e,logger:t}){return RRt(e,kh.ENCODING,h5.EncodingSchema,t)??void 0}function npf(e){return Lh(e,kh.FERN_ENUM)}function ipf({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:a}){let u=Lh(n,kh.SDK_GROUP_NAME),f=Lh(n,kh.TYPE_DEFINITION);if(f!=null)return z_i({fernType:f,nameOverride:e,generatedName:t,title:r,description:i,availability:a,groupName:typeof u=="string"?[u]:u})}function z_i({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u}){return IJ({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.base64({example:void 0})});case"BOOLEAN":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.boolean({default:void 0,example:void 0})});case"DATE":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.date({example:void 0})});case"DATE_TIME":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.datetime({example:void 0})});case"FLOAT":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.float({example:void 0})});case"DOUBLE":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.double({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.uint({default:void 0,example:void 0})});case"INTEGER":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.int({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT_64":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.uint64({default:void 0,example:void 0})});case"LONG":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Ol(f.v1)}},unknown:()=>Lp.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:a,groupName:u}),map:({keyType:f,valueType:d})=>(f==null?void 0:f.type)==="primitive"&&d!=null?Lp.map({nameOverride:t,generatedName:r,title:n,key:f,value:d,description:i,availability:a,groupName:u,encoding:void 0,example:void 0}):void 0,list:f=>f!=null?Lp.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,optional:f=>f!=null?Lp.optional({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u}):void 0,set:f=>f!=null?Lp.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,literal:f=>Lp.literal({nameOverride:t,generatedName:r,title:n,value:f._visit({string:d=>E7.string(d),boolean:d=>E7.boolean(d),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:a,groupName:u}),named:()=>{}}})}function Ren(e){if(e!=null&&typeof e=="boolean")return e}function apf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,encoding:l,source:g,namespace:O}){return typeof i=="boolean"||H7n(i)?rba({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:by.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Lp.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:void 0}),groupName:c,example:o,encoding:l}):rba({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:by.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:L1(i,d.options.optionalAdditionalProperties?f:!1,d,[...n,"Value"],g,O),groupName:c,example:o,encoding:l})}function rba({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsNullable:a,description:u,availability:f,groupName:d,example:c,encoding:o}){return a?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.map({nameOverride:e,generatedName:t,title:r,description:u,availability:n.availability,key:n,value:i,groupName:d,encoding:o,example:c}),description:u,availability:f,groupName:d}):Lp.map({nameOverride:e,generatedName:t,title:r,description:u,availability:f,key:n,value:i,groupName:d,encoding:o,example:c})}function H7n(e){return e==null?!1:typeof e=="boolean"?e:!gy(e)&&Object.keys(e).length===0}function opf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,source:l,namespace:g}){let O=i==null?Lp.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,groupName:c}):L1(i,!1,d,[...n,"Item"],l,g);return cv1({nameOverride:e,generatedName:t,title:r,groupName:c,itemSchema:O,wrapAsNullable:f,description:a,availability:u,example:o})}function cv1({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsNullable:i,description:a,availability:u,groupName:f,example:d}){return i?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d}),description:a,availability:u,groupName:f}):Lp.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d})}function ffu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminator:c,context:o,groupName:l,encoding:g,source:O,namespace:j}){let S=c.propertyName,x=Object.fromEntries(Object.entries(c.mapping??{}).map(([z,N])=>{let C=$7n({$ref:N},!1,o,[N],g,O,j);return o.markReferencedByDiscriminatedUnion({$ref:N},S,1),[z,C]})),A=Object.entries(i).filter(([z])=>z!==S).map(([z,N])=>{let C=f!=null&&f.includes(z),U=L1(N,!C,o,[...n,z],O,j);return{key:z,schema:U}});return upf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:A,description:a,availability:u,discriminant:S,subtypes:x,groupName:l,source:O})}function dfu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminant:c,variants:o,context:l,groupName:g,encoding:O,source:j,namespace:S}){let x=Object.fromEntries(Object.entries(o).map(([z,N])=>{if(gy(N)){let C=$7n(N,!1,l,[N.$ref],O,j,S);return l.markReferencedByDiscriminatedUnion(N,c,1),[z,C]}else{let C=q5r(N,!1,l,[...n,z],O,j,S,new Set([c]));return[z,C]}})),A=Object.entries(i).filter(([z])=>z!==c).map(([z,N])=>{let C=f!=null&&f.includes(z),U=L1(N,!C,l,[...n,z],j,S);return{key:z,schema:U}});return upf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:A,description:a,availability:u,discriminant:c,subtypes:x,groupName:g,source:j})}function upf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,availability:u,discriminant:f,subtypes:d,groupName:c,source:o}){return n?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.oneOf(jQ.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o})),groupName:c,description:a,availability:u}):Lp.oneOf(jQ.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o}))}function spf(e){if(e.proto!=null)return b7n.protobuf({typeName:e.proto.type})}var lv1=/^(\d+)/;function nba(e){let t=e.match(lv1);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=J7n(i);return n.length>0?`${a}_${n}`:a}}}function J7n(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","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),f=e%10;return f===0?n[u]:`${n[u]}_${t[f]}`}if(e<1e3){let u=Math.floor(e/100),f=e%100;return f===0?`${t[u]}_hundred`:`${t[u]}_hundred_${J7n(f)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${J7n(a)}`}var G7n=/^[a-zA-Z][a-zA-Z0-9_]*$/;function C5r({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:a,_default:u,description:f,availability:d,wrapAsNullable:c,groupName:o,context:l,source:g}){let O=pv1(i??[]),j=new Set(a),S=Array.from(j).map((A,z)=>{var G,$,ee,Ve;let N=n==null?void 0:n[A],C=O[z],U=G7n.test(A),Y=(N==null?void 0:N.name)??C,te=U?A:B_i(A);return Y!=null&&!G7n.test(Y)&&(l==null||l.logger.warn(`Enum name override ${Y} is not a valid name. Falling back on ${te}.`),Y=void 0),{nameOverride:Y,generatedName:te,value:A,description:N==null?void 0:N.description,availability:d,casing:{snake:((G=N==null?void 0:N.casing)==null?void 0:G.snake)??void 0,pascal:(($=N==null?void 0:N.casing)==null?void 0:$.pascal)??void 0,screamingSnake:((ee=N==null?void 0:N.casing)==null?void 0:ee.screamingSnake)??void 0,camel:((Ve=N==null?void 0:N.casing)==null?void 0:Ve.camel)??void 0}}}),x=u!=null?S.find(A=>A.value===u):void 0;return fv1({wrapAsNullable:c,nameOverride:e,generatedName:t,title:r,values:S,_default:x,description:f,availability:d,groupName:o,source:g})}function fv1({wrapAsNullable:e,nameOverride:t,generatedName:r,title:n,values:i,_default:a,description:u,availability:f,groupName:d,source:c}){return e?Lp.nullable({nameOverride:t,generatedName:r,title:n,value:Lp.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,default:a,availability:f,example:void 0,groupName:d,source:c}),description:u,availability:f,groupName:d}):Lp.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,availability:f,default:a,example:void 0,groupName:d,source:c})}var dv1={"<":"LESS_THAN",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL_TO","<=":"LESS_THAN_OR_EQUAL_TO","!=":"NOT_EQUALS","=":"EQUAL_TO","==":"EQUAL_TO","*":"ALL","":"EMPTY",'""':"EMPTY_STRING","-":"HYPHEN","|":"PIPE",".":"DOT","/":"SLASH"};function B_i(e){let t=nba(e),r=dv1[e];return t!=null?qV(FE(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":qV(FE(e)))}function pv1(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(n=>n[r]===t[r]);)r++;return e.map(n=>n.substring(r))}function cpf({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:g,example:O,groupName:j}){return n==="int64"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.int64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="uint32"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.uint({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="uint64"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.uint64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):L9({nameOverride:e,generatedName:t,title:r,primitive:by.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j})}function lpf(e){return typeof e=="string"?E7.string(e):typeof e=="boolean"?E7.boolean(e):E7.string(`${e}`)}function fpf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,value:i,description:a,availability:u,groupName:f}){return n?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.literal({nameOverride:e,generatedName:t,title:r,value:lpf(i),description:a,availability:u,groupName:f}),description:a,availability:u,groupName:f}):Lp.literal({nameOverride:e,generatedName:t,title:r,value:lpf(i),description:a,availability:u,groupName:f})}function pfu({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:g,example:O,groupName:j}){return n==null||n==="double"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.double({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="float"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.float({example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="int32"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="int64"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.int64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="uint32"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.uint({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="uint64"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.uint64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="time-delta"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.float({example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):L9({nameOverride:e,generatedName:t,title:r,primitive:by.float({example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j})}var _v1={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},hv1={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="responses",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},yv1={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="parameters",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),e[0]==="schema"&&(e=e.slice(1)),{refUnderProcessing:e,newBreadcrumbs:t}}},vv1={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},bv1={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},gv1={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},mv1={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},Ov1={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function iba(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[_v1,hv1,yv1,vv1,bv1,gv1,mv1,Ov1],i;do{i=t;for(let a of n)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:f}=a.applyStrategy(t);t=u,r=[...r,...f]}}while(t.join("")!==i.join(""));return r}function yR(e){let t=e.join("_"),r=qV(FE(t));return/^\d/.test(r)?nba(r)??r:r}function _fu(e){let t=e.join("_");return FE(t)}function oq(e){switch(e.type){case"object":return ib.object({allOf:e.allOf,properties:e.properties.map(t=>jv1(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return ib.array({description:e.description,availability:e.availability,value:oq(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"enum":return ib.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,groupName:e.groupName,source:e.source});case"literal":return ib.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"nullable":return ib.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:oq(e.value),groupName:e.groupName});case"optional":return ib.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:oq(e.value),groupName:e.groupName});case"primitive":return ib.primitive({description:e.description,availability:e.availability,schema:dpf(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return ib.map({description:e.description,availability:e.availability,key:ib.primitive({description:e.key.description,availability:e.key.availability,schema:dpf(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:oq(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,encoding:e.encoding});case"reference":return ib.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,groupName:e.groupName,source:e.source});case"oneOf":return ib.oneOf(Pv1(e.value));case"unknown":return ib.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Ol(e)}}function Pv1(e){switch(e.type){case"discriminated":return GSr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:oq(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,oq(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return GSr.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>oq(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:Ol(e)}}function dpf(e){switch(e.type){case"string":return Xw.string(e);case"base64":return Xw.base64();case"boolean":return Xw.boolean(e);case"date":return Xw.date();case"datetime":return Xw.datetime();case"double":return Xw.double(e);case"float":return Xw.float();case"int":return Xw.int(e);case"int64":return Xw.int64(e);case"uint":return Xw.uint();case"uint64":return Xw.uint64();default:Ol(e)}}function jv1(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:oq(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability}}function aba(e,t){return FRt(oq(e),oq(t))}function FRt(e,t){return e.type==="primitive"&&t.type==="primitive"?ppf(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?wv1(e.values,t.values):e.type==="array"&&t.type==="array"?FRt(e.value,t.value):e.type==="unknown"&&t.type==="unknown"?!0:e.type==="reference"&&t.type==="reference"?e.schema===t.schema:e.type==="optional"&&t.type==="optional"?FRt(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?Dv1(e.value,t.value):e.type==="object"&&t.type==="object"?Sv1(e,t):e.type==="map"&&t.type==="map"?ppf(e.key.schema,t.key.schema)&&FRt(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function ppf(e,t){return e.type===t.type}function wv1(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return iDr(r,n)}function Dv1(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,n])=>{let i=t.schemas[r];return i==null?!1:FRt(n,i)}):e.type==="undisciminated"&&t.type==="undisciminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:FRt(r,i)}):!1}function Sv1(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(n=>[n.key,n.schema]));return Object.entries(t.properties).every(([n,i])=>{let a=r[n];return a==null?!1:FRt(a,i.schema)})}function _pf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,required:u,wrapAsNullable:f,allOf:d,context:c,propertiesToExclude:o,groupName:l,fullExamples:g,additionalProperties:O,availability:j,encoding:S,source:x,namespace:A}){let z=[...u??[]],N={...i},C=[],U=[];for(let $ of d)if(gy($)){let ee=c.resolveSchemaReference($);if(ee.discriminator!=null&&ee.discriminator.mapping!=null)continue;if(ee.oneOf!=null){for(let $e of ee.oneOf){let Dt=gy($e)?c.resolveSchemaReference($e):$e,Tt=L1(Dt,!1,c.DUMMY,n,x,A);Tt.type==="object"&&C.push(...Tt.properties.map(Wt=>Wt.schema.type!=="optional"&&Wt.schema.type!=="nullable"?{...Wt,schema:Lp.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Wt.schema,description:void 0,availability:Wt.availability,groupName:void 0})}:Wt))}continue}let Ve=A5r($);if(Ve==null)continue;U.push({schemaId:Ve,convertedSchema:hfu($,[Ve],x),properties:hpf({schema:$,context:c,breadcrumbs:n,source:x,namespace:A})}),c.markSchemaAsReferencedByNonRequest(Ve)}else{let ee=L1($,!1,c,n,x,A);ee.type==="object"&&C.push(...ee.properties)}let Y={};for(let $ of U)for(let[ee,Ve]of Object.entries($.properties)){let $e=Y[ee];$e!=null?($e.schemaIds.push($.schemaId),$e.schemas.some(Tt=>aba(Tt,Ve))||$e.schemas.push(Ve)):Y[ee]={schemaIds:[$.schemaId],schemas:[Ve]}}let te=[];for(let[$,ee]of Object.entries(Y))ee.schemaIds.length>1&&te.push({propertyKey:$,allOfSchemaIds:ee.schemaIds,conflictingTypeSignatures:ee.schemas.length>1});let G=Object.entries(N).map(([$,ee])=>{let Ve=z.includes($),$e=Lh(ee,kh.AUDIENCES)??[],Dt=E2e(ee),Tt=Lh(ee,kh.FERN_PROPERTY_NAME),Wt=[...n,$],Nt=_fu(Wt),ur=Ve?L1(ee,!1,c,Wt,x,A):Lp.optional({nameOverride:e,generatedName:Nt,title:r,description:void 0,availability:Dt,value:L1(ee,!1,c,Wt,x,A),groupName:l}),Ar={};for(let Gr of U){let zt=Gr.properties[$];zt!=null&&!aba(ur,zt)?Ar[Gr.schemaId]={differentSchema:!0}:zt!=null&&(Ar[Gr.schemaId]={differentSchema:!1})}return{key:$,schema:ur,nameOverride:Tt,audiences:$e,conflict:Ar,generatedName:_fu([...n,$]),availability:Dt}});return G.push(...C.map($=>{let ee=$.conflict;for(let Ve of U){let $e=Ve.properties[$.key];$e!=null&&!aba($.schema,$e)?ee[Ve.schemaId]={differentSchema:!0}:$e!=null&&(ee[Ve.schemaId]={differentSchema:!1})}return{...$,conflict:ee}})),Ev1({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,properties:G.filter($=>!o.has($.key)),description:a,allOf:U.map($=>$.convertedSchema),allOfPropertyConflicts:te,groupName:l,fullExamples:g,additionalProperties:O,availability:j,source:x})}function Ev1({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:o,availability:l,source:g}){return n?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:H7n(o),availability:void 0,source:g}),description:a,availability:l,groupName:d}):Lp.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:H7n(o),availability:l,source:g})}function hpf({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[u,f]=gy(e)?[t.resolveSchemaReference(e),iba(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...hpf({schema:d,context:t,breadcrumbs:f,source:n,namespace:i})};for(let[d,c]of Object.entries(u.properties??{})){let o=L1(c,!1,t,[...f,d],n,i);a[d]=o}return a}function K7n({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:a,wrapAsNullable:u,context:f,subtypes:d,groupName:c,encoding:o,source:l,subtypePrefixOverrides:g,namespace:O}){let j=Mv1({schemas:d}),S=d.flatMap((z,N)=>{if(!gy(z)&&z.enum!=null)return z.enum.map(U=>Lp.literal({nameOverride:void 0,generatedName:yR([t,U]),title:void 0,value:E7.string(U),groupName:void 0,description:void 0,availability:U.availability}));let C=j[N];if(g!=null){let U=g[N];U!=null&&"name"in U&&(C=U.name)}return[L1(z,!1,f,[...n,C??`${N}`],l,O)]}),x=[];for(let z=0;z<S.length;++z){let N=S[z],C=!1;for(let U=z+1;U<S.length;++U){let Y=S[U];if(N!=null&&Y!=null&&FRt(N,Y)){C=!0;break}}N!=null&&!C&&x.push(N)}if(Object.entries(x).every(([z,N])=>N.type==="literal")){let z={},N=[];return Object.entries(x).forEach(([C,U])=>{U.type==="literal"&&U.value.type==="string"&&(N.push(U.value.value),U.description!=null&&(z[U.value.value]={description:U.description}))}),C5r({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,fernEnum:z,enumVarNames:void 0,enumValues:N,_default:void 0,groupName:c,context:f,source:l})}return x.length===1&&x[0]!=null?x[0]:ypf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,subtypes:x,groupName:c,encoding:o,source:l})}function yfu({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsNullable:a,context:u,groupName:f,discriminator:d,encoding:c,source:o,namespace:l}){let g=Object.entries(d.mapping??{}).map(([S,x],A)=>{let z={$ref:x},N=$7n(z,!1,u,[x],c,o,l);return u.markSchemaWithDiscriminantValue(z,d.propertyName,S),N.type==="object"&&(N.properties={[d.propertyName]:Lp.literal({nameOverride:void 0,generatedName:yR([t,S]),title:void 0,value:E7.string(S),groupName:void 0,description:void 0,availability:void 0}),...N.properties.filter(C=>C.key!==d.propertyName)}),N}),O=[];for(let S=0;S<g.length;++S){let x=g[S],A=!1;for(let z=S+1;z<g.length;++z){let N=g[z];if(x!=null&&N!=null&&FRt(x,N)){A=!0;break}}x!=null&&!A&&O.push(x)}if(Object.entries(O).every(([S,x])=>x.type==="literal")){let S={},x=[];return Object.entries(O).forEach(([A,z])=>{z.type==="literal"&&z.value.type==="string"&&(x.push(z.value.value),z.description!=null&&(S[z.value.value]={description:z.description}))}),C5r({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,fernEnum:S,enumVarNames:void 0,enumValues:x,_default:void 0,groupName:f,context:u,source:o})}return O.length===1&&O[0]!=null?O[0]:ypf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,subtypes:O,groupName:f,encoding:c,source:o})}function Mv1({schemas:e}){let t={},r=0;for(let a of e){if(!gy(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),f={},d=u;for(let[c,o]of Object.entries(t)){let l=CXi(o,u);d=CXi(d,o),f[c]=l}f[r]=d,t=f}}r++}let n=[],i=0;for(let a of e){let u=t[i];if(u!=null&&u.length>0){let f=u.sort();if(f[0]!=null){n.push(f[0]),++i;continue}}gy(a)?n.push(J7n(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(J7n(i)??`${i}`),++i}return n}function ypf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,description:i,availability:a,subtypes:u,groupName:f,encoding:d,source:c}){return n?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.oneOf(jQ.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c})),description:i,availability:a,groupName:f}):Lp.oneOf(jQ.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c}))}function Y7n(e){if(e.default!=null&&typeof e.default=="string")return e.default}function oba({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;if(r&&typeof r=="number")return r;r&&t.warn(`Expected fallback to be a number, but got ${typeof r}`)}function vpf({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;if(r&&typeof r=="boolean")return r;r&&t.warn(`Expected fallback to be a boolean, but got ${typeof r}`)}function LRt({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;if(r&&typeof r=="string")return r;r&&t.warn(`Expected fallback to be a string, but got ${typeof r}`)}function bpf({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;if(r&&Array.isArray(r))return r;r&&t.warn(`Expected fallback to be a array, but got ${typeof r}`)}var Fen="#/components/schemas/";function L1(e,t,r,n,i,a,u=!1,f=new Set,d){let c=zv1({schema:e,logger:r.logger});if(gy(e)){let o=A5r(e);return o!=null?(u?r.markSchemaAsReferencedByRequest(o):r.markSchemaAsReferencedByNonRequest(o),$7n(e,t,r,n,c,i,a)):q5r(r.resolveSchemaReference(e),t,r,iba(e.$ref),c,i,a,f,u,d)}return q5r(e,t,r,n,c,i,a,f,u,d)}function $7n(e,t,r,n,i,a,u){let f=e.$ref.includes("properties")?q5r(r.resolveSchemaReference(e),t,r,n,i,a,u,new Set):Lp.reference(hfu(e,n,a));return t?Lp.nullable({title:void 0,nameOverride:void 0,generatedName:yR(n),value:f,description:void 0,availability:void 0,groupName:void 0}):f}function xv1(e){if(e!=null&&!e.includes(" ")&&!!/^[a-zA-Z]+$/.test(e))return e}function q5r(e,t,r,n,i,a,u,f=new Set,d=!1,c){var C;let o=Lh(e,kh.TYPE_NAME)??(r.options.useTitlesAsName?xv1(e.title):void 0),l=Lh(e,kh.SDK_GROUP_NAME)??((C=Lh(e,Yje.TAGS))==null?void 0:C[0]),g=(typeof l=="string"?[l]:l)??[];g=r.resolveGroupName(g);let O=yR(n),j=e.title,S=e.description,x=E2e(e),A=Lh(e,Yje.EXAMPLES),z=[];e.example!=null&&z.push({name:void 0,value:e.example,description:void 0}),A!=null&&Object.keys(A).length>0&&z.push(...Object.entries(A).map(([U,Y])=>({name:Y.summary??U,value:Y.value,description:Y.description})));let N=ipf({schema:e,description:S,title:j,nameOverride:o,generatedName:O,availability:x});if(N!=null)return N;if(!t&&e.nullable===!0)return q5r(e,!0,r,n,i,a,u,f,d,c);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!I_i(e.enum))return L9({nameOverride:o,generatedName:O,title:j,primitive:by.string({default:Y7n(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:LRt({schema:e,logger:r.logger,fallback:c})}),groupName:g,wrapAsNullable:t,description:S,availability:x});let U=npf(e);return e.enum.length===1&&e.enum[0]!=null&&U==null?fpf({nameOverride:o,generatedName:O,title:j,wrapAsNullable:t,value:e.enum[0],description:S,availability:x,groupName:g}):C5r({nameOverride:o,generatedName:O,title:j,fernEnum:U,enumVarNames:Lh(e,[Yje.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:S,availability:x,wrapAsNullable:t,groupName:g,context:r,source:a})}if(I_i(e.type)&&e.type[1]!=null&&e.type[0]!=null){let U=e.type[0],Y=e.type[1];if(U==="null")return Lp.nullable({nameOverride:o,generatedName:O,title:j,value:q5r({...e,type:Y},t,r,n,i,a,u,f,d,c),groupName:g,description:e.description,availability:x});if(Y==="null")return Lp.nullable({nameOverride:o,generatedName:O,title:j,value:q5r({...e,type:U},t,r,n,i,a,u,f,d,c),groupName:g,description:e.description,availability:x})}if(I_i(e.type)&&e.type.length>1){let U=e.type.includes("null"),Y=e.type.filter(te=>te!=="null").map(te=>({type:te,nullable:U}));return K7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,wrapAsNullable:t,context:r,subtypes:Y,groupName:g,encoding:i,source:a,namespace:u})}if(e==="boolean"||e.type==="boolean"){let U=Lh(e,kh.BOOLEAN_LITERAL);return U!=null?mpf({nameOverride:o,generatedName:O,title:j,literal:E7.boolean(U),wrapAsNullable:t,description:S,availability:x,groupName:g}):L9({nameOverride:o,generatedName:O,title:j,primitive:by.boolean({default:e.default,example:vpf({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:S,availability:x,groupName:g})}if(e==="number"||e.type==="number")return pfu({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Ren(e.exclusiveMinimum),exclusiveMaximum:Ren(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:oba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="integer"||e.type==="integer")return cpf({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Ren(e.exclusiveMinimum),exclusiveMaximum:Ren(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:oba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="float")return pfu({nameOverride:o,generatedName:O,title:j,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Ren(e.exclusiveMinimum),exclusiveMaximum:Ren(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:oba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="string"||e.type==="string"){if(e.format==="date-time")return L9({nameOverride:o,generatedName:O,title:j,primitive:by.datetime({example:LRt({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:S,availability:x,groupName:g});if(e.format==="json-string")return Lp.unknown({nameOverride:o,generatedName:O,title:j,description:S,availability:x,groupName:g,example:void 0});let U=jpf(e,"const");return U!=null?mpf({nameOverride:o,generatedName:O,title:j,literal:E7.string(U),wrapAsNullable:t,description:S,availability:x,groupName:g}):L9({nameOverride:o,generatedName:O,title:j,primitive:by.string({default:Y7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:LRt({schema:e,logger:r.logger,fallback:c})}),groupName:g,wrapAsNullable:t,description:S,availability:x})}if(e.type==="array")return opf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,item:e.items,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,example:bpf({schema:e,logger:r.logger,fallback:c}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&gpf(e))return apf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,additionalProperties:e.additionalProperties,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,encoding:i,example:e.example,source:a,namespace:u});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?yfu({nameOverride:o,generatedName:O,title:j,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):ffu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:g,encoding:i,source:a,namespace:u});if(Array.isArray(e.type)&&(e.oneOf==null?e.oneOf=e.type:e.oneOf.push(...e.type)),e.oneOf!=null&&e.oneOf.length>0){let U=Lh(e,kh.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||U?yfu({nameOverride:o,generatedName:O,title:j,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):ffu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:g,encoding:i,source:a,namespace:u});if(e.oneOf.length===1&&e.oneOf[0]!=null){let Y=L1(e.oneOf[0],t,r,n,a,u,d);return X7n(Y,S,g)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let $=e.oneOf[0],ee=e.oneOf[1];if(!gy($)&&$.type==="null")return L1(ee,!0,r,n,a,u);if(!gy(ee)&&ee.type==="null")return L1($,!0,r,n,a,u)}let Y=Cv1({schemas:e.oneOf});if(Y!=null)return C5r({nameOverride:o,generatedName:O,title:j,fernEnum:void 0,enumVarNames:void 0,enumValues:Y,_default:e.default,description:S,availability:x,wrapAsNullable:t,groupName:g,context:r,source:a});let te=Opf({schemas:e.oneOf,context:r});if(te!=null&&!r.options.discriminatedUnionV2&&!U)return dfu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},required:e.required,description:S,availability:x,wrapAsNullable:t,discriminant:te.discriminant,variants:te.schemas,context:r,groupName:g,encoding:i,source:a,namespace:u});let G=e.oneOf.filter($=>!gy($)&&$.type==="null").length>0;return K7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,wrapAsNullable:t||G,context:r,subtypes:e.oneOf.filter($=>gy($)||$.type!=="null"),encoding:i,groupName:g,source:a,namespace:u})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let te=L1(e.anyOf[0],t,r,n,a,u,d);return X7n(te,S,g)}if(e.anyOf.length===2){let[te,G]=e.anyOf;if(te!=null&&G!=null){if(!gy(te)&&te.type==="null"){let $=L1(G,!0,r,n,a,u);return X7n($,S,g)}else if(!gy(G)&&G.type==="null"){let $=L1(te,!0,r,n,a,u);return X7n($,S,g)}}}let U=Opf({schemas:e.anyOf,context:r});if(U!=null&&!r.options.discriminatedUnionV2)return dfu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},required:e.required,description:S,availability:x,wrapAsNullable:t,discriminant:U.discriminant,variants:U.schemas,context:r,groupName:g,encoding:i,source:a,namespace:u});let Y=e.anyOf.filter(te=>!gy(te)&&te.type==="null").length>0;return K7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,wrapAsNullable:t||Y,context:r,subtypes:e.anyOf.filter(te=>gy(te)||te.type!=="null"),encoding:i,groupName:g,source:a,namespace:u})}if(e.allOf!=null||e.properties!=null){let U=[];for(let te of e.allOf??[])(gy(te)||Object.keys(te).length>0)&&U.push(te);if((e.properties==null||e.properties.length===0)&&U.length===1&&U[0]!=null){let te=L1(U[0],t,r,n,a,u,d);return X7n(te,S,g)}let Y=U.filter(te=>{let G=uba(te);return G||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify(te)}`),G});if((e.properties==null||e.properties.length===0)&&Y.length===1&&Y[0]!=null){let te=L1(Y[0],t,r,n,a,u,d);return X7n(te,S,g)}return _pf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},description:S,required:e.required,wrapAsNullable:t,allOf:Y,context:r,propertiesToExclude:f,groupName:g,fullExamples:z,additionalProperties:e.additionalProperties,availability:x,encoding:i,source:a,namespace:u})}if(e.type==="object"&&Tv1(e)&&qv1(e)&&gpf(e))return rba({nameOverride:o,generatedName:O,title:j,description:S,availability:x,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${O}Key`,title:void 0,description:void 0,availability:void 0,schema:by.string({default:Y7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:LRt({schema:e,logger:r.logger,fallback:c})}),groupName:g},valueSchema:Lp.unknown({nameOverride:void 0,generatedName:`${O}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:g}),groupName:g,encoding:i,example:e.example});if(e.type==null){let U=e.example??e.default;return Lp.unknown({nameOverride:o,generatedName:O,title:j,description:S,availability:x,groupName:g,example:U})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(n)} value=${JSON.stringify(e)}`)}function A5r(e){if(!!e.$ref.startsWith(Fen))return e.$ref.replace(Fen,"")}function hfu(e,t,r){let n=Lh(e,kh.TYPE_NAME),i=yR(t),a=e.description,u=E2e(e),f=A5r(e);if(f==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return ib.reference({generatedName:i,nameOverride:n,title:void 0,schema:f,description:a??void 0,availability:u,groupName:void 0,source:r})}function Tv1(e){return e.oneOf==null||e.oneOf.length===0}function qv1(e){return e.allOf==null||e.allOf.length===0}function gpf(e){return e.properties==null||Object.keys(e.properties).length===0}function I_i(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function X7n(e,t,r){return e.type==="reference"?Lp.reference({...e,description:t,availability:e.availability,groupName:r}):e.type==="optional"?Lp.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e.type==="nullable"?Lp.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e}function uba(e){return gy(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>uba(t)):e.oneOf!=null?e.oneOf.every(t=>uba(t)):e.anyOf!=null?e.anyOf.every(t=>uba(t)):!1}function mpf({literal:e,wrapAsNullable:t,groupName:r,description:n,availability:i,nameOverride:a,generatedName:u,title:f}){return t?Lp.nullable({nameOverride:a,generatedName:u,title:f,value:Lp.literal({nameOverride:a,generatedName:u,title:f,value:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Lp.literal({nameOverride:a,generatedName:u,title:f,value:e,groupName:r,description:n,availability:i})}function L9({primitive:e,wrapAsNullable:t,groupName:r,description:n,availability:i,generatedName:a,nameOverride:u,title:f}){return r=typeof r=="string"?[r]:r,t?Lp.nullable({nameOverride:u,generatedName:a,title:f,value:Lp.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Lp.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r})}function Cv1({schemas:e}){let t=new Set;for(let r of e){if(gy(r))return;if(r.enum!=null&&I_i(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function Opf({schemas:e,context:t}){let r={};for(let n of e){let i=Ppf({schema:n,context:t});for(let[a,u]of Object.entries(i)){let f=r[a];f!=null?f[u]=n:r[a]={[u]:n}}}for(let[n,i]of Object.entries(r))if(Object.keys(i).length===e.length)return{discriminant:n,schemas:i}}function Ppf({schema:e,context:t}){let r=gy(e)?t.resolveSchemaReference(e):e;return Av1({schema:r,context:t})}function Av1({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=Ppf({schema:n,context:t});for(let[a,u]of Object.entries(i??{}))r[a]=u}return r}for(let[n,i]of Object.entries(e.properties??{})){let a=gy(i)?t.resolveSchemaReference(i):i;a.type==="string"&&a.enum!=null&&I_i(a.enum)&&Nv1(a.enum).length===1&&a.enum[0]!=null&&(r[n]=a.enum[0]);let u=jpf(a,"const");a.type==="string"&&u!=null&&(r[n]=u),n==="type"&&a.example!=null&&(r[n]=a.example)}return r}function Nv1(e){if(!e)return[];let t=new Set;return e.forEach(r=>{typeof r=="string"?t.add(r.toLowerCase()):t.add(r)}),Array.from(t)}function jpf(e,t){let r=e[t];if(r!=null)return r}function zv1({schema:e,logger:t}){let r=rpf({schema:e,logger:t});if(r!=null)return spf(r)}function sba(e,t){let r={},n={};return e==null?r=t:n={[e]:t},{rootSchemas:r,namespacedSchemas:n}}var wpf="#/components/messages/",vfu=class{logger;document;taskContext;DUMMY;options;namespace;constructor({document:t,taskContext:r,options:n,namespace:i}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=n,this.namespace=i}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let n=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};n.push(i)}return n.concat(t??[])}resolveSchemaReference(t){var a;if(this.document.components==null||this.document.components.schemas==null||!t.$ref.startsWith(Fen))throw new Error(`Failed to resolve ${t.$ref}`);let n=t.$ref.substring(Fen.length).split("/");if(n[0]==null)throw new Error(`${t.$ref} is undefined`);let i=this.document.components.schemas[n[0]];if(i==null)throw new Error(`${n[0]} is undefined`);if(gy(i)&&(i=this.resolveSchemaReference(i)),n[1]==="properties"&&n[2]!=null){let u=(a=i.properties)==null?void 0:a[n[2]];if(u==null)throw new Error(`${t.$ref} is undefiened. Property does not exist on object.`);gy(u)?i=this.resolveSchemaReference(u):i=u}return i}resolveMessageReference(t){if(this.document.components==null||this.document.components.messages==null||!t.$ref.startsWith(wpf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(wpf.length),n=this.document.components.messages[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}},cba=class extends vfu{constructor({document:t,taskContext:r,options:n,namespace:i}){super({document:t,taskContext:r,options:n,namespace:i})}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,n){}markSchemaWithDiscriminantValue(t,r,n){}};function N5r(e){if(typeof e=="string")return RP.primitive(t0.string(e));if(typeof e=="number")return Number.isInteger(e)?RP.primitive(t0.int(e)):RP.primitive(t0.double(e));if(typeof e=="boolean")return RP.primitive(t0.boolean(e));if(Array.isArray(e)){let t=e.map(r=>N5r(r));return t.length===0?void 0:RP.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,n]of Object.entries(e)){let i=N5r(n);i!=null&&t.push({key:t0.string(r),value:i})}return RP.map(t)}}function R_i(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function Dpf(e){if(e!=null&&Array.isArray(e))return e}var Q7n=class{schemas;constructor(t){this.schemas=t}buildExample({schema:t,exampleId:r,example:n,options:i}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:n,options:{...i,maxCheckerDepth:i.maxCheckerDepth??5},depth:0})}buildExampleHelper({exampleId:t,example:r,schema:n,depth:i,visitedSchemaIds:a,options:u}){var f,d,c,o;switch(n.type){case"enum":return typeof r=="string"&&Spf({schema:n,value:r})?RP.enum(r):n.values[0]!=null?RP.enum((f=n.values[0])==null?void 0:f.value):void 0;case"literal":return RP.literal(n.value);case"nullable":{if(r==null&&!this.hasExample(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let l=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u});return l!=null&&l.type==="array"&&l.value.length===0||l!=null&&l.type==="map"&&l.value.length===0||l!=null&&l.type==="object"&&Object.keys(l.properties).length===0?void 0:l}case"optional":{if(r==null&&!this.hasExample(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let l=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u});return l!=null&&l.type==="array"&&l.value.length===0||l!=null&&l.type==="map"&&l.value.length===0||l!=null&&l.type==="object"&&Object.keys(l.properties).length===0?void 0:l}case"primitive":{let l=this.buildExampleFromPrimitive({schema:n.schema,example:r,options:u});return RP.primitive(l)}case"reference":{let l=this.schemas[n.schema];if(l!=null&&!a.has(n.schema)){a.add(n.schema);let g=this.buildExampleHelper({example:r,schema:l,exampleId:t,visitedSchemaIds:a,depth:i,options:u});return a.delete(n.schema),g}return}case"oneOf":switch(n.value.type){case"discriminated":{let l={},g={},O={},j=R_i(r),S=j==null?void 0:j[n.value.discriminantProperty],x=n.value.schemas[S],A=[],z=this.getDiscriminatedUnionVariantSchema(n.value,j);z!=null&&A.push(z),A.push(...Object.entries(n.value.schemas));for(let N of A)if(S!=null&&x!=null&&x.type==="object"){g=this.getAllProperties(x),O=this.getAllRequiredProperties(x),l[n.value.discriminantProperty]=RP.primitive(t0.string(S));break}else{let C=this.getObjectSchema(N[1]);if(C==null)continue;g=this.getAllProperties(C),O=this.getAllRequiredProperties(C),l[n.value.discriminantProperty]=RP.primitive(t0.string(N[0]))}for(let N of n.value.commonProperties){g[N.key]=N.schema;let C=this.getResolvedSchema(N.schema);C.type!=="optional"&&C.type!=="nullable"&&(O[N.key]=N.schema)}for(let[N,C]of Object.entries(g)){let U=N in O;if(U&&(j==null?void 0:j[N])!=null){let Y=this.buildExampleHelper({schema:C,exampleId:t,example:j[N],visitedSchemaIds:a,depth:i+1,options:u});if(Y!=null)l[N]=Y;else return}else{let Y=this.buildExampleHelper({exampleId:t,schema:C,example:j==null?void 0:j[N],visitedSchemaIds:a,depth:i+1,options:u});if(Y!=null)l[N]=Y;else if(U)return}}return RP.oneOf(v5r.discriminated(l))}case"undisciminated":{let l=this.getUnDiscriminatedUnionVariantSchema(n.value,r);if(l!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:l,visitedSchemaIds:a,depth:i,options:u});break}}return;case"unknown":if(r!=null){let l=N5r(r);if(l!=null)return RP.unknown(l)}return u.ignoreOptionals||this.exceedsMaxDepth(i,u)?void 0:u.isParameter?RP.primitive(t0.string(u.name??"string")):RP.map([{key:t0.string("key"),value:RP.primitive(t0.string("value"))}]);case"array":{let l=Dpf(r),g=[];if(l!=null&&l.length>0)for(let O of l){let j=this.buildExampleHelper({exampleId:t,example:O,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u});j!=null&&g.push(j)}else if(n.example!=null&&n.example.length>0)for(let O of n.example){let j=this.buildExampleHelper({exampleId:t,example:O,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u});j!=null&&g.push(j)}else{let O=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u});O!=null&&g.push(O)}return RP.array(g)}case"map":{let l=R_i(r??n.example);if(l!=null&&Object.entries(l).length>0){let j=[];for(let[S,x]of Object.entries(l)){let A=this.buildExampleFromPrimitive({schema:n.key.schema,example:S,options:u}),z=this.buildExampleHelper({exampleId:t,example:x,schema:n.value,visitedSchemaIds:a,depth:i+1,options:u});z!=null&&j.push({key:A,value:z})}return RP.map(j)}if(n.key.schema.type==="string"&&n.value.type==="unknown")return RP.map([{key:t0.string("key"),value:RP.unknown(RP.primitive(t0.string("value")))}]);let g=this.buildExampleFromPrimitive({schema:n.key.schema,example:void 0,options:{...u,name:"key"}}),O=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,visitedSchemaIds:a,depth:i+1,options:{...u,name:"value"}});return O!=null?RP.map([{key:g,value:O}]):RP.map([])}case"object":{let l={},g=((d=n.fullExamples)==null?void 0:d.find(x=>x.name===t))??((c=n.fullExamples)==null?void 0:c.find(x=>x.name==null))??((o=n.fullExamples)==null?void 0:o[0]),O=R_i(r)??(g!=null?R_i(g.value):{})??{},j=this.getAllProperties(n),S=this.getAllRequiredProperties(n);for(let[x,A]of Object.entries(j)){let z=x in S,N=Object.keys(O).includes(x),C=this.buildExampleHelper({schema:A,exampleId:t,example:O[x],visitedSchemaIds:a,depth:i+1,options:{...u,name:x}});if(z&&C!=null)l[x]=C;else{if(z)return;(N&&C!=null||!u.ignoreOptionals&&C!=null)&&(l[x]=C)}}return RP.object({properties:l})}default:Ol(n)}}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let n=r==null?void 0:r[t.discriminantProperty];if(n==null||typeof n!="string")return Object.entries(t.schemas)[0];let i=t.schemas[n];return i==null?Object.entries(t.schemas)[0]:[n,i]}getUnDiscriminatedUnionVariantSchema(t,r){var a;return r==null?t.schemas[0]:(a=t.schemas.map(u=>({schema:u,heuristic:this.calcExampleHeuristic(u,r)})).sort((u,f)=>f.heuristic-u.heuristic)[0])==null?void 0:a.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return Spf({schema:t,value:r})?5:0;case"object":{if(!RO(r))return 0;let n=this.getAllProperties(t),i=0;for(let[a,u]of Object.entries(n))r[a]!=null?(i++,i+=this.calcExampleHeuristic(u,r[a])):i--;return i}case"array":{if(!Array.isArray(r))return 0;let n=0;for(let i of r)n+=this.calcExampleHeuristic(t.value,i);return n}case"map":{if(!RO(r))return 0;let n=0;for(let[,i]of Object.entries(r))n+=this.calcExampleHeuristic(t.value,i);return n}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let n=this.getResolvedSchema(t);return n==null?0:this.calcExampleHeuristic(n,r)}case"oneOf":return Object.values(t.value.schemas).map(i=>this.calcExampleHeuristic(i,r)).sort((i,a)=>a-i)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,n=new Set,i){if(this.exceedsMaxCheckerDepth(r,i))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,n,i);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,n,i);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let u of t.properties)if(this.hasExample(u.schema,r+1,n,i))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!n.has(t.schema)){n.add(t.schema);let u=this.hasExample(a,r,n,i);return n.delete(t.schema),u}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,n,i));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let n of t.properties)r[n.key]=n.schema;for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let n of t.properties){let i=this.getResolvedSchema(n.schema);i.type!=="optional"&&i.type!=="nullable"&&(r[n.key]=n.schema)}for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:n}){switch(r.type){case"string":return t!=null&&typeof t=="string"?t0.string(t):r.example!=null?t0.string(r.example):t0.string(n.name??DC.STRING);case"base64":return t!=null&&typeof t=="string"?t0.base64(t):r.example!=null?t0.base64(r.example):t0.base64(DC.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?t0.boolean(t):r.example!=null?t0.boolean(r.example):t0.boolean(DC.BOOLEAN);case"date":return t!=null&&typeof t=="string"?t0.date(t):r.example!=null?t0.date(r.example):t0.date(DC.DATE);case"datetime":return t!=null&&typeof t=="string"?t0.datetime(t):r.example!=null?t0.datetime(r.example):t0.datetime(DC.DATE_TIME);case"double":return t!=null&&typeof t=="number"?t0.double(t):r.example!=null?t0.double(r.example):t0.double(DC.DOUBLE);case"float":return t!=null&&typeof t=="number"?t0.float(t):r.example!=null?t0.float(r.example):t0.float(DC.FLOAT);case"int":return t!=null&&typeof t=="number"?t0.int(t):r.example!=null?t0.int(r.example):t0.int(DC.INT);case"int64":return t!=null&&typeof t=="number"?t0.int64(t):r.example!=null?t0.int64(r.example):t0.int64(DC.INT64);case"uint":return t!=null&&typeof t=="number"?t0.uint(t):r.example!=null?t0.uint(r.example):t0.uint(DC.UINT);case"uint64":return t!=null&&typeof t=="number"?t0.uint64(t):r.example!=null?t0.uint64(r.example):t0.uint64(DC.UINT64);default:Ol(r)}}};function Spf({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function URt(e){switch(e.type){case"object":return Lp.object({allOf:e.allOf,properties:e.properties.map(t=>Iv1(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return Lp.array({description:e.description,availability:e.availability,value:URt(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0});case"enum":return Lp.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,groupName:e.groupName,example:void 0,source:e.source});case"literal":return Lp.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName});case"nullable":return Lp.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:URt(e.value),groupName:e.groupName});case"optional":return Lp.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:URt(e.value),groupName:e.groupName});case"primitive":return Lp.primitive({description:e.description,availability:e.availability,schema:Epf(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return Lp.map({description:e.description,availability:e.availability,key:Lp.primitive({description:e.key.description,availability:e.key.availability,schema:Epf(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:URt(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,encoding:e.encoding,example:void 0});case"reference":return Lp.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,groupName:e.groupName,source:e.source});case"oneOf":return Lp.oneOf(Bv1(e.value));case"unknown":return Lp.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,groupName:void 0,description:void 0,availability:void 0});default:Ol(e)}}function Bv1(e){switch(e.type){case"discriminated":return jQ.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:URt(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,URt(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return jQ.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>URt(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:Ol(e)}}function Epf(e){switch(e.type){case"string":return by.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return by.base64({example:void 0});case"boolean":return by.boolean({default:e.default,example:void 0});case"date":return by.date({example:void 0});case"datetime":return by.datetime({example:void 0});case"double":return by.double({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"float":return by.float({example:void 0});case"int":return by.int({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"int64":return by.int64({default:e.default,example:void 0});case"uint":return by.uint({default:void 0,example:void 0});case"uint64":return by.uint64({default:void 0,example:void 0});default:Ol(e)}}function Iv1(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:URt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability}}function lba(e){return e.type!=="optional"&&e.type!=="nullable"}function F_i(e){if(e.type==="full")return e.request==null&&e.response==null&&e.queryParameters==null&&e.pathParameters==null&&e.headers==null;{let t=e.value;return t.request==null&&t.response==null&&t["query-parameters"]==null&&t["path-parameters"]==null&&t.headers==null}}var fba=class{exampleTypeFactory;logger;schemas;constructor(t,r){this.schemas=t,this.exampleTypeFactory=new Q7n(t),this.logger=r}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=Fv1(t.request),n=Lv1(t.response);if((r==null?void 0:r.type)==="unsupported"||(n==null?void 0:n.type)==="unsupported")return[];let i=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let g=this.exampleTypeFactory.buildExample({schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});g!=null&&i.push([void 0,g])}else for(let{name:g,value:O}of r.examples){let j=this.exampleTypeFactory.buildExample({schema:r.schema,exampleId:g,example:O,options:{isParameter:!1,ignoreOptionals:!0}});j!=null&&i.push([g,j])}if(l&&i.length===0)return this.logger.warn(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(n!=null&&n.type==="present"){let l=this.isSchemaRequired(n.schema);if(n.examples.length===0){let g=this.exampleTypeFactory.buildExample({schema:n.schema,exampleId:void 0,example:void 0,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});g!=null&&a.push([void 0,g])}else for(let{name:g,value:O}of n.examples){let j=this.exampleTypeFactory.buildExample({schema:n.schema,exampleId:g,example:O,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});j!=null&&a.push([g,j])}if(l&&a.length===0)return this.logger.warn(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let l of t.pathParameters){let g=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!VRt(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),g&&O==null)return[];O!=null&&u.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:O})}let f=[];for(let l of t.queryParameters){let g=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!VRt(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),g&&O==null)return[];O!=null&&f.push({name:l.name,value:O})}let d=[];for(let l of t.headers){let g=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!VRt(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),g&&O==null)return[];O!=null&&d.push({name:l.name,value:O})}let c=[];t.request!=null&&t.response!=null?c=Rv1(i,a):t.request!=null?c=i.map(([l,g])=>({id:l,request:g,response:void 0})):t.response!=null&&(c=a.map(([l,g])=>({id:l,request:void 0,response:g})));let o=t.examples.filter(l=>F_i(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let g=l.value["code-samples"];if(g!=null)return this.convertCodeSamples(g)}return}else return l.codeSamples}).filter(l=>RS(l));return c.length===0?[pAt.full({name:void 0,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:void 0,response:void 0,codeSamples:o})]:c.map(({id:l,request:g,response:O})=>pAt.full({name:l,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:g,response:O,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?JSr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):JSr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?bW.Csharp:r.sdk,code:r.code})).filter(RS)}isSchemaRequired(t){return lba(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function Rv1(e,t){var i,a,u,f;let r=[];if(e.length<=1){let[d,c]=e[0]??[];if(t.length===0)return r.push({id:d,request:c,response:void 0}),r;for(let[o,l]of t)r.push({id:o??d,request:c,response:l});return r}if(t.length<=1){let[d,c]=t[0]??[];if(t.length===0)return r.push({id:d,request:void 0,response:c}),r;for(let[o,l]of e)r.push({id:o??d,request:l,response:c});return r}let n=new Set;for(let[d,c]of e){let o=((i=t.find(([g])=>g==null))==null?void 0:i[1])??((a=t[0])==null?void 0:a[1]);if(d==null){if(o==null)continue;r.push({id:void 0,request:c,response:o});continue}let l=!1;for(let g=0;g<t.length;g++){let[O,j]=t[g];O!=null||n.has(g)||d===O&&(r.push({id:d,request:c,response:j}),O!=null&&n.add(g),l=!0)}!l&&o!=null&&r.push({id:d,request:c,response:o})}for(let d=0;d<t.length;d++){if(n.has(d))continue;let[c,o]=t[d],l=((u=e.find(([g])=>g==null))==null?void 0:u[1])??((f=e[0])==null?void 0:f[1]);l!=null&&r.push({id:c,request:l,response:o})}return r}function Fv1(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:Uv1(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function Lv1(e){if(e!=null)return e.type!=="json"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function VRt(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return VRt(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undisciminated":return VRt(e.value.value);default:return!1}default:Ol(e)}}function Uv1(e){return Lp.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:URt(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0}).filter(RS),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source})}var dba=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new Q7n(t),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,publish:n,subscribe:i,handshake:a,source:u,namespace:f}){var c,o;let d=[];for(let l of r){let g=[];for(let S of a.queryParameters){let x=this.isSchemaRequired(S.schema),A=this.exampleTypeFactory.buildExample({schema:S.schema,exampleId:void 0,example:(c=l.queryParameters)==null?void 0:c[S.name],options:{name:S.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!VRt(A)&&(A=void 0),!(x&&A==null)&&A!=null&&g.push({name:S.name,value:A})}let O=[];for(let S of a.headers){let x=this.isSchemaRequired(S.schema),A=this.exampleTypeFactory.buildExample({schema:S.schema,exampleId:void 0,example:(o=l.headers)==null?void 0:o[S.name],options:{name:S.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!VRt(A)&&(A=void 0),!(x&&A==null)&&A!=null&&O.push({name:S.name,value:A})}let j=[];for(let S of l.messages){let x=t.resolveMessageReference({$ref:`#/components/messages/${S.messageId}`}),A=gy(x.payload)?t.resolveSchemaReference(x.payload):x.payload,z=this.exampleTypeFactory.buildExample({schema:L1(A,!1,t,[S.messageId],u,f),exampleId:void 0,example:S.value,options:{isParameter:!1,ignoreOptionals:!0}});z!=null&&j.push({messageType:S.type,payload:z,description:void 0})}d.push({name:l.summary,queryParameters:g,headers:O,description:l.description,messages:j})}return d}buildWebsocketSessionExample({publish:t,subscribe:r,handshake:n}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},a=[];for(let f of n.queryParameters){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!VRt(c)&&(c=void 0),d&&c==null)return;c!=null&&a.push({name:f.name,value:c})}let u=[];for(let f of n.headers){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!VRt(c)&&(c=void 0),d&&c==null)return;c!=null&&u.push({name:f.name,value:c})}if(t!=null){let f=this.exampleTypeFactory.buildExample({schema:t,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"publish",payload:f,description:void 0})}if(r!=null){let f=this.exampleTypeFactory.buildExample({schema:r,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"subscribe",payload:f,description:void 0})}return i}isSchemaRequired(t){return lba(this.getResolvedSchema(t))}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}};var L_i={FERN_DISPLAY_NAME:"x-fern-display-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path"};function Mpf(e){return Lh(e,L_i.FERN_EXAMPLES)??[]}function Tpf({document:e,taskContext:t,options:r,source:n,asyncApiOptions:i,namespace:a}){var l,g,O,j,S,x;let u=[];a!=null&&u.push(a),((l=e.tags)==null?void 0:l[0])!=null?u.push(e.tags[0].name):i.naming!=="v2"&&u.push("websocket");let f=new cba({document:e,taskContext:t,options:r,namespace:a}),d={},c;for(let[A,z]of Object.entries(((g=e.components)==null?void 0:g.schemas)??{})){let N=L1(z,!1,f,[A],n,a);d[A]=N}let o=new dba(d,t.logger);for(let[A,z]of Object.entries(e.channels??{})){if(((O=z.bindings)==null?void 0:O.ws)==null){f.logger.error(`Channel ${A} does not have websocket bindings. Skipping.`);continue}let N=[];if(z.parameters!=null)for(let[G,$]of Object.entries(z.parameters??{}))N.push({name:G,description:$.description,parameterNameOverride:void 0,schema:$.schema!=null?L1($.schema,!1,f,u,n,a):Lp.primitive({schema:by.string({default:void 0,pattern:void 0,format:void 0,maxLength:void 0,minLength:void 0,example:void 0}),description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:E2e($),source:n});let C=[];if(z.bindings.ws.headers!=null){let G=z.bindings.ws.headers.required??[];for(let[$,ee]of Object.entries(z.bindings.ws.headers.properties??{})){let Ve=gy(ee)?f.resolveSchemaReference(ee):ee;C.push({name:$,schema:L1(Ve,!G.includes($),f,u,n,a),description:Ve.description,parameterNameOverride:void 0,env:void 0,availability:E2e(Ve),source:n})}}let U=[];if(z.bindings.ws.query!=null){let G=z.bindings.ws.query.required??[];for(let[$,ee]of Object.entries(z.bindings.ws.query.properties??{})){let Ve=gy(ee)?f.resolveSchemaReference(ee):ee;U.push({name:$,schema:L1(Ve,!G.includes($),f,u,n,a),description:Ve.description,parameterNameOverride:void 0,availability:E2e(Ve),source:n})}}let Y;z.publish!=null&&(Y=xpf({generatedName:z.publish.operationId??"PublishEvent",event:z.publish,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i}));let te;if(z.subscribe!=null&&(te=xpf({generatedName:z.subscribe.operationId??"SubscribeEvent",event:z.subscribe,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i})),C.length>0||U.length>0||Y!=null||te!=null){let G=Mpf(z),$=[];if(G.length>0)$=o.buildWebsocketSessionExamplesForExtension({context:f,extensionExamples:G,handshake:{headers:C,queryParameters:U},publish:Y,subscribe:te,source:n,namespace:a});else{let Ve=o.buildWebsocketSessionExample({handshake:{headers:C,queryParameters:U},publish:Y,subscribe:te});Ve!=null&&$.push(Ve)}let ee=((S=(j=e.tags)==null?void 0:j[0])==null?void 0:S.name)!=null?[(x=e.tags)==null?void 0:x[0].name]:void 0;c={handshake:{headers:C.map(Ve=>({...Ve,schema:oq(Ve.schema),env:Ve.env})),queryParameters:U.map(Ve=>({...Ve,schema:oq(Ve.schema)})),pathParameters:N.map(Ve=>({...Ve,parameterNameOverride:void 0,schema:oq(Ve.schema)}))},groupName:f.resolveTags(ee,"Websocket"),publish:Y!=null?oq(Y):Y,subscribe:te!=null?oq(te):te,summary:Lh(z,L_i.FERN_DISPLAY_NAME),path:A,description:void 0,examples:$,source:n};break}}return{groupedSchemas:sba(a,d),channel:c,basePath:Lh(e,L_i.BASE_PATH)}}function xpf({generatedName:e,event:t,context:r,breadcrumbs:n,source:i,options:a,asyncApiOptions:u}){if(t.message.oneOf!=null){let f=[],d=[];for(let c of t.message.oneOf){let o,l={type:"notFound"};if(gy(c)){let g=r.resolveMessageReference(c);!gy(g.payload)&&u.naming==="v2"?(l=g.name?{type:"name",name:g.name}:l,o={...g.payload,title:g.name??g.payload.title,description:g.name??g.payload.description}):o=g.payload}else o=c;d.push(l),f.push(o)}return K7n({description:t.description??t.message.description,availability:E2e(t.message),subtypes:f,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:n,context:r,encoding:void 0,source:i,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}var IEf=yu(Vbf(),1);var Rtn=yu(NEf(),1);var zEf=require("fs/promises");async function jPa({absoluteFilepathToOverrides:e,data:t,context:r}){let n=null;try{let u=(await(0,zEf.readFile)(e,"utf8")).toString();try{n=JSON.parse(u)}catch{n=av.load(u,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}let i=qXi(t,qXi,n,(u,f)=>Array.isArray(u)&&Array.isArray(f)?f.every(d=>typeof d=="object")&&u.every(d=>typeof d=="object")?void 0:[...f]:void 0);return Wbu(i,mWo)}var Wbu=(e,t)=>{function r(n){if(!Array.isArray(n)&&!Lsi(n))return n;if(Array.isArray(n))return n.map(a=>Wbu(a,t));let i={};for(let[a,u]of Object.entries(n))i[a]=Wbu(u,t);return jWo(i,t)}return r(e)};var wH1={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},DH1={id:"",typeExtension:{oas3:e=>{var t;return{...e,XFernStreaming:wH1,Operation:{...e.Operation,properties:{...(t=e.Operation)==null?void 0:t.properties,"x-fern-streaming":"XFernStreaming"}}}}}};async function REf({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,context:r}){let n=await BEf({absolutePathToOpenAPI:e}),i;if(t!=null?i=t:typeof n=="object"&&n[kh.OPENAPI_OVERIDES_FILEPATH]!=null&&(i=pf(Cg(e),zs.of(n[kh.OPENAPI_OVERIDES_FILEPATH]))),i!=null){let a=await jPa({absoluteFilepathToOverrides:i,context:r,data:n});return await BEf({absolutePathToOpenAPI:e,parsed:a})}return n}async function BEf({absolutePathToOpenAPI:e,parsed:t}){let r={config:new Rtn.Config({apis:{},styleguide:{plugins:[DH1],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0},n=t!=null?await(0,Rtn.bundle)({...r,doc:{source:new Rtn.Source(e,"<openapi>"),parsed:t}}):await(0,Rtn.bundle)({...r,ref:e});return await IEf.default.parse(n.bundle.parsed)}var Cqf=yu(L2f(),1);function U2f(e){return Lh(e,kh.ASYNC_CONFIG)}var V2f="$request.";function W2f(e){let t=Lh(e,kh.STREAMING);if(t!=null)return typeof t=="boolean"?t?{type:"stream",format:"json"}:void 0:t["stream-condition"]==null&&t.format!=null?{type:"stream",format:t.format}:{type:"streamCondition",format:t.format??"json",streamConditionProperty:IX1(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function IX1(e){return e.startsWith(V2f)?e.slice(V2f.length):e}function H2f(e){let t=e;if(t.cursor!=null)return $Sr.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});let r=e;return $Sr.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}function $2f(e,t){let r=Lh(t,kh.PAGINATION);if(r!=null){if(typeof r=="boolean"){let n=Lh(e,kh.PAGINATION);if(typeof n=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return n==null?void 0:H2f(n)}return H2f(r)}}function J2f(e){let t=RX1(e),r={};return Hmu({obj:t,occurrences:r,breadcrumbs:[]}),r}function Hmu({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let n of e)Hmu({obj:n,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let n=e.$ref;t[n]==null?t[n]=1:t[n]+=1;return}for(let n in e)Hmu({obj:e[n],occurrences:t,breadcrumbs:[...r,n]})}}}function RX1(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:(r==null?void 0:r.get)!=null?C0i(r.get):void 0,put:(r==null?void 0:r.put)!=null?C0i(r.put):void 0,post:(r==null?void 0:r.post)!=null?C0i(r.post):void 0,patch:(r==null?void 0:r.patch)!=null?C0i(r.patch):void 0,delete:(r==null?void 0:r.delete)!=null?C0i(r.delete):void 0}]))}}function C0i(e){return{...e,requestBody:e.requestBody!=null?gy(e.requestBody)?e.requestBody:FX1(e.requestBody):void 0}}function FX1(e){let t,r;for(let n in e.content){let i=sA.parse(n);i!=null&&(i.isJSON()?t=e.content[n]:i.isMultipart()&&(r=e.content[n]))}return r!=null&&t!=null?{...e,content:{[sA.MULTIPART_FORM_DATA]:r}}:e}var G2f="#/components/parameters/",K2f="#/components/responses/",Y2f="#/components/examples/",X2f="#/components/requestBodies/",V3n=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;namespace;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=n,this.refOccurrences=J2f(t),this.options=i,this.source=a,this.DUMMY=this.getDummy(),this.namespace=u}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};r.push(n)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return{"x-fern-type":"unknown",additionalProperties:!0};n=n[i]}return n==null?{"x-fern-type":"unknown",additionalProperties:!0}:(gy(n)&&(n=this.resolveSchemaReference(n)),n)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(G2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(G2f.length),n=this.document.components.parameters[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return gy(n)?this.resolveParameterReference(n):n}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(X2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(X2f.length),n=this.document.components.requestBodies[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return gy(n)?this.resolveRequestBodyReference(n):n}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(K2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(K2f.length),n=this.document.components.responses[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return gy(n)?this.resolveResponseReference(n):n}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(Y2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(Y2f.length),n=this.document.components.examples[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return gy(n)?this.resolveExampleReference(n):n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}};var W3n=class extends V3n{constructor({document:t,taskContext:r,options:n,source:i,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:n,source:i,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,n){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,n){}getDiscriminatedUnionMetadata(t){}};var LX1=ir.object({lang:ir.string(),label:ir.optional(ir.string()),source:ir.string()}),$mu=ir.array(LX1);var Q2f={README_EXT:"x-readme"};function UX1(e){if(!Array.isArray(e))return!1;for(let t of e)if(!RO(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function Z2f(e){let t=Lh(e,Q2f.README_EXT);if(!RO(t))return[];let r=t["code-samples"];if(!UX1(r))return[];let n=[];for(let i of r)n.push({name:i.name,language:i.language,code:i.code,install:i.install,docs:void 0});return n}function k2f(e,t,r){let n=RRt(t,kh.EXAMPLES,h5.ExampleEndpointCallArraySchema,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],i=RRt(t,Yje.REDOCLY_CODE_SAMPLES_KEBAB,$mu,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],u=[...RRt(t,Yje.REDOCLY_CODE_SAMPLES_CAMEL,$mu,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...i];u.length>0&&n.push({"code-samples":u.map(d=>({name:d.label??d.lang,language:d.lang,code:d.source,install:void 0,docs:void 0}))});let f=Z2f(t);return f.length>0&&n.push({"code-samples":f}),n.map(pAt.unknown)}function eqf(e){let t=Lh(e,kh.AVAILABILITY);if(t==="ga"||t==="generally-available")return vW.GenerallyAvailable;if(t==="beta"||t==="pre-release")return vW.Beta;if(t==="deprecated")return vW.Deprecated;if(e.deprecated)return vW.Deprecated}function x1a(e){return{url:VX1({url:e.url,variables:e.variables??{}}),description:e.description,name:WX1(e),audiences:Lh(e,kh.AUDIENCES)}}function VX1({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([n,i])=>[n,i.default]));for(let[n,i]of Object.entries(r))e=e.replace(`{${n}}`,i);return e}function WX1(e){var r,n;let t=Lh(e,[kh.SERVER_NAME_V1,kh.SERVER_NAME_V2]);if(t!=null)return t;if(((r=e.description)==null?void 0:r.toLowerCase())==="production")return"Production";if(((n=e.description)==null?void 0:n.toLowerCase())==="sandbox")return"Sandbox"}function tqf(e){return Lh(e,kh.PARAMETER_NAME)}function rqf(e){return Lh(e,kh.SDK_VARIABLE)}function T1a({path:e,httpMethod:t,parameters:r,context:n,requestBreadcrumbs:i,source:a}){var f;let u={pathParameters:[],queryParameters:[],headers:[]};for(let d of r){let c=gy(d)?n.resolveParameterReference(d):d,o=c.required??!1,l=E2e(c),g=[...i,c.name],O=yR(g);(f=LRt({schema:c,logger:n.logger}))!=null&&f.includes(" ")&&n.logger.warn("Parameter example contains a space, which is ambiguous. Consider using enums for multiple examples, or use an encoding if a space is part of the parameter.");let j=c.schema!=null?L1(c.schema,!o,n,g,a,n.namespace,!1,new Set,LRt({schema:c,logger:n.logger})):o?Lp.primitive({nameOverride:void 0,generatedName:O,title:void 0,schema:by.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:LRt({schema:c,logger:n.logger})}),description:void 0,availability:l,groupName:void 0}):Lp.optional({nameOverride:void 0,generatedName:O,title:void 0,value:Lp.primitive({nameOverride:void 0,generatedName:O,title:void 0,schema:by.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:LRt({schema:c,logger:n.logger})}),description:void 0,availability:void 0,groupName:void 0}),description:void 0,availability:l,groupName:void 0});if(c.in==="header"&&c.schema!=null&&!gy(c.schema)&&c.schema.default!=null){let x=c.schema.default;typeof x=="string"&&x.length>0&&(j=Lp.literal({nameOverride:void 0,generatedName:O,title:void 0,value:E7.string(x),description:void 0,availability:l,groupName:void 0}))}let S={name:c.name,schema:j,description:c.description,parameterNameOverride:tqf(c),availability:l,source:a};c.in==="query"?u.queryParameters.push(S):c.in==="path"?u.pathParameters.push({...S,variableReference:rqf(c)}):c.in==="header"?!HX1.has(c.name)&&!n.authHeaders.has(c.name)?u.headers.push({...S,env:void 0}):n.logger.debug(`Ignoring ${c.name} header, in ${t.toUpperCase()} ${e}`):n.logger.warn(`Skipping ${c.in} parameter, ${c.name}, in ${t.toUpperCase()} ${e}`)}return u}var HX1=new Set(["User-Agent","Content-Length","Content-Type","X-Forwarded-For","Cookie","Origin","Content-Disposition","X-Ping-Custom-Domain"]);function H3n(e,t){for(let r of Object.keys(e))if(r.includes("json")){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:iqf(n,t)}}}function nqf(e,t){for(let r of Object.keys(e)){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:iqf(n,t)}}}function iqf(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let n=Lh(e,Yje.EXAMPLES);return n!=null&&Object.keys(n).length>0&&r.push(...Object.entries(n).map(([i,a])=>({name:a.summary??i,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([i,a])=>{let u=gy(a)?t.resolveExampleReference(a):a;return{name:u.summary??i,value:u.value,description:u.description}})),r}function $X1(e){var t;for(let[r,n]of Object.entries(e.content))if((t=sA.parse(r))!=null&&t.isMultipart())return{schema:n.schema,encoding:n.encoding}}function JX1(e){var t;for(let r in e.content)if((t=sA.parse(r))!=null&&t.isOctetStream())return!0;return!1}function GX1(e,t){let r=gy(e)?Jmu(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([n,i])=>!gy(i)&&i.type==="string"&&i.format==="binary")!=null}function $3n({requestBody:e,document:t,context:r,requestBreadcrumbs:n,source:i,namespace:a}){var g,O,j,S,x;let u=gy(e)?r.resolveRequestBodyReference(e):e,f=$X1(u),d=f==null?void 0:f.schema,c=f==null?void 0:f.encoding,o=H3n(u.content,r);if(JX1(u))return S2e.octetStream({description:void 0,source:i});if(d!=null&&o==null||d!=null&&GX1(d,t)){let A=gy(d)?Jmu(d,t):{id:void 0,schema:d},z=L1(A.schema,!1,r,n,i,a),N=[];if(z.type==="object")for(let C of z.properties){if(C.schema.type==="primitive"&&C.schema.schema.type==="string"&&C.schema.schema.format==="binary"){N.push({key:C.key,schema:D2e.file({isOptional:!1,isArray:!1}),description:C.schema.description,contentType:c!=null?(g=c[C.key])==null?void 0:g.contentType:void 0});continue}if(C.schema.type==="optional"&&C.schema.value.type==="primitive"&&C.schema.value.schema.type==="string"&&C.schema.value.schema.format==="binary"){N.push({key:C.key,schema:D2e.file({isOptional:!0,isArray:!1}),description:C.schema.description,contentType:c!=null?(O=c[C.key])==null?void 0:O.contentType:void 0});continue}if(C.schema.type==="array"&&C.schema.value.type==="primitive"&&C.schema.value.schema.type==="string"&&C.schema.value.schema.format==="binary"){N.push({key:C.key,schema:D2e.file({isOptional:!1,isArray:!0}),description:C.schema.description,contentType:c!=null?(j=c[C.key])==null?void 0:j.contentType:void 0});continue}if(C.schema.type==="optional"&&C.schema.value.type==="array"&&C.schema.value.value.type==="primitive"&&C.schema.value.value.schema.type==="string"&&C.schema.value.value.schema.format==="binary"){N.push({key:C.key,schema:D2e.file({isOptional:!0,isArray:!0}),description:C.schema.description,contentType:c!=null?(S=c[C.key])==null?void 0:S.contentType:void 0});continue}N.push({key:C.key,schema:D2e.json(C.schema),description:void 0,contentType:c!=null?(x=c[C.key])==null?void 0:x.contentType:void 0})}return S2e.multipart({name:gy(d)&&r.getNumberOfOccurrencesForRef(d)===1?A.id:void 0,description:void 0,properties:N,source:i})}if(o==null)return;let l=L1(o.schema,!1,r,n,i,a,!0);return S2e.json({description:void 0,schema:l,contentType:void 0,fullExamples:o.examples,additionalProperties:!gy(o.schema)&&H7n(o.schema.additionalProperties),source:i})}function Jmu(e,t){var i,a;if(!e.$ref.startsWith(Fen))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=A5r(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let n=(a=(i=t.components)==null?void 0:i.schemas)==null?void 0:a[r];if(n==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return gy(n)?Jmu(n,t):{id:r,schema:n}}var Gmu={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},aqf=new Set(Object.values(Gmu));var KX1=["200","201","202","204"];function uqf({operationContext:e,responses:t,context:r,responseBreadcrumbs:n,responseStatusCode:i,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let f=YX1({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,c;for(let o of i!=null?[i]:KX1){let l=t[o];l!=null&&(d=!0,c==null&&(c=oqf({operationContext:e,response:l,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})))}if(c==null&&!d&&t.default!=null&&(c=oqf({operationContext:e,response:t.default,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})),c!=null)switch(c.type){case"json":return{value:c,errors:f};case"streamingJson":case"streamingSse":return{value:c,errors:f};case"file":case"text":case"streamingText":return{value:c,errors:f};default:Ol(c)}return{value:void 0,errors:f}}function oqf({operationContext:e,streamFormat:t,response:r,context:n,responseBreadcrumbs:i,source:a,namespace:u}){let f=gy(r)?n.resolveResponseReference(r):r;if(f.content!=null&&Object.entries(f.content).find(([o,l])=>{if(l.schema==null)return!1;let g=gy(l.schema)?n.resolveSchemaReference(l.schema):l.schema;return g.type==="string"&&g.format==="binary"}))return T3.file({description:f.description,source:a});let d=H3n(f.content??{},n);if(d!=null){if(t!=null)switch(t){case"json":return T3.streamingJson({description:f.description,responseProperty:void 0,schema:oq(L1(d.schema,!1,n,i,a,u)),source:a});case"sse":return T3.streamingSse({description:f.description,responseProperty:void 0,schema:oq(L1(d.schema,!1,n,i,a,u)),source:a})}return T3.json({description:f.description,schema:L1(d.schema,!1,n,i,a,u),responseProperty:Lh(e.operation,kh.RESPONSE_PROPERTY),fullExamples:d.examples,source:a})}for(let[c,o]of Object.entries(f.content??{})){let l=sA.parse(c);if(l!=null){if(l.isOctetStream()||l.isPDF()||l.isAudio()||l.isImage()||l.isVideo())return T3.file({description:f.description,source:a});if(l.isPlainText()){let g=o.schema;if(g==null)return T3.text({description:f.description,source:a});let O=gy(g)?n.resolveSchemaReference(g):g;return O.type==="string"&&O.format==="byte"?T3.file({description:f.description,source:a}):T3.text({description:f.description,source:a})}}}}function YX1({responses:e,context:t,source:r,namespace:n}){let i={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let f=parseInt(a);if(f<400||f>600)continue;let d=gy(u)?t.resolveResponseReference(u):u,c=nqf(d.content??{},t),o=Gmu[f];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}i[f]={statusCode:f,nameOverride:void 0,generatedName:o,description:d.description,schema:L1((c==null?void 0:c.schema)??{},!1,t,[o,"Body"],r,n),fullExamples:c==null?void 0:c.examples,source:r}}return i}function vEr({operationContext:e,context:t,responseStatusCode:r,suffix:n,streamFormat:i,source:a}){let{document:u,operation:f,path:d,method:c,baseBreadcrumbs:o,sdkMethodName:l}=e,g=Lh(f,kh.IDEMPOTENT),O=Lh(f,[kh.REQUEST_NAME_V1,kh.REQUEST_NAME_V2]),j=[...o,"Request"],S=T1a({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:j,path:d,httpMethod:c,source:a}),x=f.requestBody!=null?$3n({requestBody:f.requestBody,document:u,context:new W3n({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:j,source:a,namespace:t.namespace}):void 0;(S.queryParameters.length>0||S.headers.length>0)&&x!=null&&x.type==="json"&&x.schema.type!=="object"&&f.requestBody!=null?x=$3n({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j,"Body"],source:a,namespace:t.namespace}):f.requestBody!=null&&(x=$3n({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j],source:a,namespace:t.namespace}));let A=[...o,"Response"],z=uqf({operationContext:e,streamFormat:i,responses:f.responses,context:t,responseBreadcrumbs:A,responseStatusCode:r,source:a}),N=eqf(f),C=k2f(e,f,t),U=Lh(f,kh.SERVER_NAME_V2);return{summary:f.summary,internal:Lh(f,Yje.INTERNAL),idempotent:g,audiences:Lh(f,kh.AUDIENCES)??[],operationId:f.operationId!=null&&n!=null?f.operationId+"_"+n:f.operationId,tags:t.resolveTagsToTagIds(f.tags),namespace:t.namespace,sdkName:l,pathParameters:S.pathParameters,queryParameters:S.queryParameters,headers:S.headers,requestNameOverride:O??void 0,generatedRequestName:yR(j),request:x,response:z.value,errors:z.errors,server:U!=null?[{name:U,url:void 0,audiences:void 0}]:(f.servers??[]).map(Y=>x1a(Y)),description:f.description,authed:XX1(f,u),availability:N,method:c,path:d,examples:C,pagination:e.pagination,source:a}}function XX1(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function cqf({operationContext:e,context:t,asyncExtension:r,source:n}){let{operation:i,pathItemParameters:a,operationParameters:u}=e,f=r.discriminant.name,d=r.discriminant.value,c=r["response-status-code"],o=sqf({context:t,headerToIgnore:f,parameters:a}),l=sqf({context:t,headerToIgnore:f,parameters:u}),g=vEr({operationContext:{...e,pathItemParameters:o,operationParameters:l,operation:{...i,responses:Object.fromEntries(Object.entries(i.responses).filter(([j])=>parseInt(j)!==c))}},context:t,streamFormat:void 0,source:n}),O=vEr({operationContext:{...e,pathItemParameters:o,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:c,streamFormat:void 0,source:n});return O.headers.push({name:f,schema:Lp.literal({nameOverride:void 0,generatedName:yR([f]),title:void 0,description:void 0,availability:void 0,value:E7.string(d),groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:n}),{sync:g,async:O}}function sqf({context:e,headerToIgnore:t,parameters:r}){return r.filter(n=>{let i=gy(n)?e.resolveParameterReference(n):n;return!(i.in==="header"&&i.name===t)})}var Kmu="stream";function pqf({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:vEr({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let n=lqf({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if((n==null?void 0:n.schemaReference)!=null){let c=A5r(n.schemaReference);c!=null&&t.excludeSchema(c)}let i=fqf({operation:e.operation,response:r.responseStream}),a=vEr({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+Kmu}:void 0,operation:{...e.operation,requestBody:n==null?void 0:n.requestBody,responses:i},baseBreadcrumbs:[...e.baseBreadcrumbs,Kmu]},context:t,streamFormat:r.format,suffix:Kmu,source:t.source});a.examples=a.examples.filter(c=>dqf(c,t)!==!1);let u=lqf({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),f=fqf({operation:e.operation,response:r.response}),d=vEr({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u==null?void 0:u.requestBody,responses:f}},context:t,source:t.source});return d.examples=d.examples.filter(c=>dqf(c,t)!==!0),{streaming:a,nonStreaming:d}}default:Ol(r)}}function lqf({context:e,operation:t,streamingExtension:r,isStreaming:n}){var c;if(t.requestBody==null)return;let i=gy(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=H3n(i.content,e);if(a==null)return;let u=gy(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let f=(c=u.properties)==null?void 0:c[r.streamConditionProperty];f!=null&&gy(f)&&(f=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":n,...f??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[sA.APPLICATION_JSON]:{schema:d}}},schemaReference:gy(a.schema)?a.schema:void 0}}function fqf({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[sA.APPLICATION_JSON]:{schema:t}}}}}function dqf(e,t){return e._visit({unknown:r=>{let n=h5.ExampleEndpointCallSchema.safeParse(r);if(!n.success){t.logger.error("Failed to parse example",n.error.toString());return}if(n.data.response!=null)return n.data.response.stream!=null},full:()=>{},_other:()=>{}})}function _qf({context:e,operationContext:t,source:r}){let{document:n,operation:i,path:a,method:u,baseBreadcrumbs:f,sdkMethodName:d}=t,c=[...f,"Payload"],o=T1a({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:c,path:a,httpMethod:u,source:r});if(i.requestBody==null){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Missing a request body`);return}if(u!=="POST"&&u!=="GET"){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Not POST or GET`);return}let l=$3n({requestBody:i.requestBody,document:n,context:e,requestBreadcrumbs:[...f,"Payload"],source:r,namespace:e.namespace});if(l==null||l.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(i.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:i.summary,sdkName:d,namespace:e.namespace,method:u,operationId:i.operationId,tags:e.resolveTagsToTagIds(i.tags),headers:o.headers,generatedPayloadName:yR(c),payload:l.schema,description:i.description,examples:QX1(l.fullExamples),source:r}}function QX1(e){if(e==null)return[];let t=[];for(let r of e){let n=N5r(r.value);n!=null&&t.push({description:r.description,name:r.name,payload:n})}return t}function Ymu({context:e,pathItemContext:t,operation:r,convertToWebhook:n}){let i=Lh(r,kh.IGNORE);if(i!=null&&i){e.logger.info(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=ZX1(r,e),u=$2f(e.document,r),f={...t,sdkMethodName:a,baseBreadcrumbs:kX1({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path}),operation:r,operationParameters:r.parameters??[],pagination:u};if(n){let l=_qf({context:e,operationContext:f,source:e.source});return l!=null?{type:"webhook",value:l}:void 0}let d=W2f(r);if(d!=null){let l=pqf({context:e,operationContext:f,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let c=U2f(r);if(c!=null){let l=cqf({context:e,operationContext:f,asyncExtension:c,source:e.source});return{type:"async",async:l.async,sync:l.sync}}let o=vEr({context:e,operationContext:f,streamFormat:void 0,source:e.source});return{type:"http",value:o}}function ZX1(e,t){let r=Lh(e,kh.SDK_METHOD_NAME),n=Lh(e,kh.SDK_GROUP_NAME)??[];if(r!=null){let i=typeof n=="string"?[n]:n;return i=t.resolveGroupName(i),{groupName:i,methodName:r}}}function kX1({sdkMethodName:e,operation:t,httpMethod:r,path:n}){let i=[];if(e!=null){if(e.groupName.length>0){let a=e.groupName[e.groupName.length-1];a!=null&&i.push(typeof a=="string"?a:a.name)}i.push(e.methodName)}else t.operationId!=null?i.push(t.operationId):i.push(FE(`${r}_${n.split("/").join("_")}`));return i}function hqf(e,t,r,n){let i=[],a=vqf(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=eQ1({operation:f.operation}),c=Ymu({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:d});c!=null&&i.push(c)}return i}function yqf(e,t,r,n){let i=[],a=vqf(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=Ymu({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:!0});d!=null&&i.push(d)}return i}function vqf(e){let t=[];return e.get!=null&&t.push({method:KJ.Get,operation:e.get}),e.post!=null&&t.push({method:KJ.Post,operation:e.post}),e.put!=null&&t.push({method:KJ.Put,operation:e.put}),e.delete!=null&&t.push({method:KJ.Delete,operation:e.delete}),e.patch!=null&&t.push({method:KJ.Patch,operation:e.patch}),t}function eQ1({operation:e}){return Lh(e,[kh.WEBHOOK])??!1}function bqf(e){let t=Lh(e,kh.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=Lh(e,kh.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function gqf(e){return Lh(e,kh.FERN_BASIC_AUTH)}function Xmu(e,t){if(gy(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return tQ1(e,t)}function tQ1(e,t){var r,n,i,a;if(e.type==="apiKey"&&e.in==="header"){let u=Lh(e,Yje.BEARER_FORMAT),f=Lh(e,kh.FERN_HEADER_AUTH);return F9.header({headerName:e.name,prefix:u!=null?"Bearer":f==null?void 0:f.prefix,headerVariableName:(f==null?void 0:f.name)??Lh(e,kh.HEADER_VARIABLE_NAME),headerEnvVar:f==null?void 0:f.env})}else if(e.type==="http"&&e.scheme==="bearer"){let u=Lh(e,kh.FERN_BEARER_TOKEN);return F9.bearer({tokenVariableName:(u==null?void 0:u.name)??Lh(e,kh.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:u==null?void 0:u.env})}else if(e.type==="http"&&e.scheme==="basic"){let u=gqf(e),f=bqf(e);return F9.basic({usernameVariableName:((r=u==null?void 0:u.username)==null?void 0:r.name)??f.usernameVariable,usernameEnvVar:(n=u==null?void 0:u.username)==null?void 0:n.env,passwordVariableName:((i=u==null?void 0:u.password)==null?void 0:i.name)??f.passwordVariable,passwordEnvVar:(a=u==null?void 0:u.password)==null?void 0:a.env})}else{if(e.type==="openIdConnect")return F9.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return F9.oauth({scopesEnum:rQ1(e,t)})}throw new Error(`Failed to convert security scheme ${JSON.stringify(e)}`)}function rQ1(e,t){var n,i,a,u;let r=((n=e.flows.authorizationCode)==null?void 0:n.scopes)??((i=e.flows.clientCredentials)==null?void 0:i.scopes)??((a=e.flows.implicit)==null?void 0:a.scopes)??((u=e.flows.password)==null?void 0:u.scopes);if(r!=null){let f=C5r({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([c,o])=>[c,{description:o}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsNullable:!1,groupName:void 0,context:void 0,source:t}),d=oq(f);if(d.type==="enum")return d}}function mqf(e){return Lh(e,kh.BASE_PATH)}var nQ1=ir.record(ir.string(),ir.object({summary:ir.string().optional(),description:ir.string().optional()}));function Oqf({document:e,context:t}){return RRt(e,kh.GROUPS,nQ1,t.logger)}function Pqf({context:e,document:t}){return RRt(t,kh.FERN_VERSION,h5.VersionDeclarationSchema,e.logger)??void 0}function jqf(e){let t=Lh(e,kh.FERN_GLOBAL_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?z_i({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function wqf(e){let t=Lh(e,kh.FERN_IDEMPOTENCY_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?z_i({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function Dqf(e){let t=Lh(e,kh.SDK_VARIABLES);return t==null?{}:Object.fromEntries(Object.entries(t).map(([r,n])=>{if(n.type==="string")return[r,{nameOverride:void 0,generatedName:yR([r]),title:n.title,schema:Xw.string({default:Y7n(n),pattern:n.pattern,format:n.format,minLength:n.minLength,maxLength:n.maxLength}),description:n.description,availability:void 0,groupName:void 0}];throw new Error(`Variable ${r} has unsupported schema ${JSON.stringify(n)}`)}))}var iQ1="webhooks";function Sqf(e){return Lh(e,iQ1)??{}}var q1a=class extends V3n{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discrminatedUnionReferences={};discrminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u})}getDummy(){return new W3n({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,n){let i=this.discrminatedUnionReferences[t.$ref];i!=null?(i.discriminants.add(r),i.numReferences+=n):this.discrminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:n}}getReferencesFromDiscriminatedUnion(t){return this.discrminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,n){let i=this.discrminatedUnionMetadata[t.$ref];i!=null?i.discriminants.set(r,n):this.discrminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,n]])}}getDiscriminatedUnionMetadata(t){return this.discrminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function Eqf(e){return Lh(e,kh.RESOLUTIONS)}function Mqf({openapi:e}){let t=Eqf(e);if(t==null)return e;let r={};for(let n of t){let i=`#/components/schemas/${n.name}`;for(let a of n.resolutions)e=aQ1({openapi:e,schemaReference:a,schemaName:n.name}),e=xqf({openapi:e,replaceReference:a,schemaReference:i,replacedReferences:r}),r={...r,...Object.fromEntries(n.resolutions.map(u=>[i,u]))}}return e}function aQ1({openapi:e,schemaReference:t,schemaName:r}){let n=t.replace("#/","").split("/").map(a=>a.replace("~1","/")),i=e;for(let a of n){let u=i[a];if(u==null)return e;i=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=i,e}function xqf({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:n}){let i=Object.keys(n).filter(d=>t.startsWith(d)).sort((d,c)=>c.length-d.length)[0];if(i!=null){let d=n[i];if(d!=null){let c=r.replace(i,d);return xqf({openapi:e,replaceReference:t,schemaReference:c,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replace("~1","/")),u=e;for(let d of a.slice(0,-1)){let c=u[d];if(c==null)return e;u=c}let f=a[a.length-1];return f==null||(u[f]={$ref:r}),e}function C1a({openApi:e,taskContext:t,options:r,source:n,namespace:i}){var Y,te,G;e=Mqf({openapi:e});let a=Object.fromEntries(Object.entries(((Y=e.components)==null?void 0:Y.securitySchemes)??{}).map(([$,ee])=>Xmu(ee,n)==null?[]:[$,Xmu(ee,n)])),u=new Set(...Object.entries(a).map(([$,ee])=>ee.type==="basic"||ee.type==="bearer"?"Authorization":ee.type==="header"?ee.headerName:null)),f=new q1a({document:e,taskContext:t,authHeaders:u,options:r,source:n,namespace:i}),d=Dqf(e),c=jqf(e),o=wqf(e),l=r.audiences??[],g=[],O=[];Object.entries(e.paths??{}).forEach(([$,ee])=>{if(ee==null)return;t.logger.debug(`Converting path ${$}`);let Ve=hqf($,ee,e,f);for(let $e of Ve){let Dt=Tqf({operation:$e});if(!(l.length>0&&!l.some(Tt=>Dt.includes(Tt))))switch($e.type){case"async":g.push($e.sync),g.push($e.async);break;case"http":g.push($e.value);break;case"streaming":g.push($e.streaming),$e.nonStreaming&&g.push($e.nonStreaming);break;case"webhook":O.push($e.value);break;default:Ol($e)}}}),Object.entries(Sqf(e)).forEach(([$,ee])=>{if(ee==null)return;t.logger.debug(`Converting path ${$}`);let Ve=yqf($,ee,e,f);for(let $e of Ve){let Dt=Tqf({operation:$e});l.length>0&&!l.some(Tt=>Dt.includes(Tt))||O.push($e.value)}});let j=Object.fromEntries(Object.entries(((te=e.components)==null?void 0:te.schemas)??{}).map(([$,ee])=>{if(!gy(ee)){let Ve=Lh(ee,kh.IGNORE);if(Ve!=null&&Ve)return[];if(aqf.has($))return[$,L1({...ee,"x-fern-type-name":`${$}Body`},!1,f,[$],n,i)]}return[$,L1(ee,!1,f,[$],n,i)]}).filter($=>$.length>0)),S=oQ1(j,f,n),x=uQ1(S,f),A={};for(let[$,ee]of Object.entries(x)){let Ve=oq(ee);f.isSchemaExcluded($)||(A[$]=Ve,t.logger.debug(`Converted schema ${$}`))}let z=new fba(x,f.logger),N=g.map($=>{let ee=$.examples,Ve=ee;if(!r.disableExamples&&(ee.length===0||ee.every(F_i))){let Tt=z.buildEndpointExample($);Tt.length>0&&(Ve=[...Tt,...ee.filter(Wt=>!F_i(Wt))])}let $e=$.request,Dt=$.response;return{...$,request:($e==null?void 0:$e.type)==="json"?{...$e,schema:oq($e.schema)}:$e,response:(Dt==null?void 0:Dt.type)==="json"?{...Dt,schema:oq(Dt.schema)}:Dt,queryParameters:$.queryParameters.map(Tt=>({description:Tt.description,name:Tt.name,schema:oq(Tt.schema),parameterNameOverride:Tt.parameterNameOverride,availability:Tt.availability,source:Tt.source})),pathParameters:$.pathParameters.map(Tt=>({description:Tt.description,name:Tt.name,schema:oq(Tt.schema),parameterNameOverride:Tt.parameterNameOverride,variableReference:Tt.variableReference,availability:Tt.availability,source:Tt.source})),headers:$.headers.map(Tt=>({description:Tt.description,name:Tt.name,schema:oq(Tt.schema),parameterNameOverride:Tt.parameterNameOverride,env:Tt.env,availability:Tt.availability,source:Tt.source})),examples:Ve,errors:sy($.errors,Tt=>{var Wt;return{generatedName:Tt.generatedName,nameOverride:Tt.nameOverride,schema:oq(Tt.schema),description:Tt.description,source:Tt.source,examples:(Wt=Tt.fullExamples)==null?void 0:Wt.map(Nt=>{let ur=N5r(Nt.value);if(ur!=null)return{name:Nt.name,description:Nt.description,example:ur}}).filter(RS)}})}}),C=Oqf({document:e,context:f});return{apiVersion:Pqf({context:f,document:e}),basePath:mqf(e),title:e.info.title,description:e.info.description,groups:Object.fromEntries(Object.entries(C??{}).map(([$,ee])=>[$,{summary:ee.summary??void 0,description:ee.description??void 0}])),servers:(e.servers??[]).map($=>x1a($)),tags:{tagsById:Object.fromEntries((e.tags??[]).map($=>[$.name,{id:$.name,description:$.description}])),orderedTagIds:(G=e.tags)==null?void 0:G.map($=>$.name)},endpoints:N,webhooks:O,channel:[],groupedSchemas:sba(i,A),securitySchemes:a,hasEndpointsMarkedInternal:N.some($=>$.internal),nonRequestReferencedSchemas:f.getReferencedSchemas(),variables:d,globalHeaders:c,idempotencyHeaders:o}}function oQ1(e,t,r){let n={};for(let[i,a]of Object.entries(e)){if(a.type!=="object"){n[i]=a;continue}let u={$ref:`#/components/schemas/${i}`},f=t.getReferencesFromDiscriminatedUnion(u);if(f==null){n[i]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!f.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!f.discriminants.has(o.propertyKey)),source:r};n[i]=d;let c=qqf({schema:a,schemas:e});for(let o of[...new Set(c)]){let l=n[o]??e[o];l==null||l.type!=="object"||(n[o]={...l,type:"object",properties:l.properties.filter(g=>!f.discriminants.has(g.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(g=>!f.discriminants.has(g.propertyKey))})}}return n}function uQ1(e,t){let r={};for(let[n,i]of Object.entries(e)){if(i.type!=="object"){r[n]=i;continue}let a={$ref:`#/components/schemas/${n}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[n]=i;continue}let f=[];for(let c of i.properties)if(u.discriminants.has(c.key)){let o=u.discriminants.get(c.key);o!=null&&f.push({...c,schema:Lp.literal({nameOverride:void 0,generatedName:yR([i.generatedName,o]),title:void 0,value:E7.string(o),groupName:void 0,description:void 0,availability:i.availability})})}else f.push(c);let d={...i,type:"object",properties:f};r[n]=d}return r}function qqf({schema:e,schemas:t}){let r=[];for(let n of e.allOf){r.push(n.schema);let i=t[n.schema];i!=null&&i.type==="object"&&r.push(...qqf({schema:i,schemas:t}))}return r}function Tqf({operation:e}){let t=[];switch(e.type){case"async":t=e.async.audiences;break;case"http":t=e.value.audiences;break;case"streaming":t=e.streaming.audiences;break;case"webhook":break;default:Ol(e)}return t}async function Aqf({openApi:e,taskContext:t,options:r,source:n,namespace:i}){let a=await(0,Cqf.convertObj)(e,{});return C1a({openApi:a.openapi,taskContext:t,options:r,source:n,namespace:i})}var J3n={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0};async function Ktn({absoluteFilePathToWorkspace:e,specs:t,taskContext:r,optionOverrides:n}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channel:[],groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let a of t){let u=(await(0,Zmu.readFile)(a.absoluteFilepath)).toString(),f=YN(e,a.source.file);a.source.relativePathToDependency!=null&&(f=pf(a.source.relativePathToDependency,f));let d=a.source.type==="protobuf"?HSr.protobuf({file:f}):HSr.openapi({file:f});if(u.includes("openapi")||u.includes("swagger")){let c=await REf({absolutePathToOpenAPI:a.absoluteFilepath,context:r,absolutePathToOpenAPIOverrides:a.absoluteFilepathToOverrides});if(lQ1(c)){let o=C1a({openApi:c,taskContext:r,options:Qmu({specSettings:a.settings,overrides:n}),source:d,namespace:a.namespace});i=Nqf(i,o)}else if(fQ1(c)){let o=await Aqf({openApi:c,taskContext:r,options:Qmu({specSettings:a.settings}),source:d,namespace:a.namespace});i=Nqf(i,o)}}else if(u.includes("asyncapi")){let c=await cQ1({absoluteFilePathToAsyncAPI:a.absoluteFilepath,context:r,absoluteFilePathToAsyncAPIOverrides:a.absoluteFilepathToOverrides}),o=Tpf({document:c,taskContext:r,options:Qmu({specSettings:a.settings}),source:d,asyncApiOptions:sQ1({specSettings:a.settings}),namespace:a.namespace});o.channel!=null&&i.channel.push(o.channel),o.groupedSchemas!=null&&(i.groupedSchemas=zqf(i.groupedSchemas,o.groupedSchemas)),o.basePath!=null&&(i.basePath=o.basePath)}else r.failAndThrow(`${a.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}function Qmu({specSettings:e,overrides:t}){return{disableExamples:(t==null?void 0:t.disableExamples)??J3n.disableExamples,discriminatedUnionV2:(t==null?void 0:t.discriminatedUnionV2)??(e==null?void 0:e.shouldUseUndiscriminatedUnionsWithLiterals)??J3n.discriminatedUnionV2,useTitlesAsName:(t==null?void 0:t.useTitlesAsName)??(e==null?void 0:e.shouldUseTitleAsName)??J3n.useTitlesAsName,audiences:(t==null?void 0:t.audiences)??(e==null?void 0:e.audiences)??J3n.audiences,optionalAdditionalProperties:(t==null?void 0:t.optionalAdditionalProperties)??(e==null?void 0:e.optionalAdditionalProperties)??J3n.optionalAdditionalProperties}}function sQ1({specSettings:e,overrides:t}){return{naming:(t==null?void 0:t.naming)??(e==null?void 0:e.asyncApiNaming)??tpf.naming}}function Nqf(e,t){return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channel:[...e.channel,...t.channel],groupedSchemas:zqf(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}}}function zqf(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,n]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...n}:e.namespacedSchemas[r]=n;return e}async function cQ1({absoluteFilePathToAsyncAPI:e,absoluteFilePathToAsyncAPIOverrides:t,context:r}){let n=(await(0,Zmu.readFile)(e)).toString(),i=await av.load(n);return t!=null?await jPa({absoluteFilepathToOverrides:t,context:r,data:i}):i}function lQ1(e){return e.openapi!=null}function fQ1(e){return e.swagger!=null}function N1a({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=kmu({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=A2(i.value);if(a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>"),e.description==null&&!i.allowMultiple&&e.parameterNameOverride==null&&e.availability==null)return a;let u={type:a};return i.allowMultiple&&(u["allow-multiple"]=!0),e.description!=null&&(u.docs=e.description),e.parameterNameOverride!=null&&(u.name=e.parameterNameOverride),e.availability!=null&&(u.availability=q3(e.availability)),u}function kmu({schema:e,context:t,fileContainingReference:r,namespace:n}){if(e.type==="reference"){let i=t.getSchema(e.schema,n);if(i==null)return;if(i.type==="array")return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,declarationFile:zs.of(HT),fileContainingReference:r,namespace:n}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undisciminated"){let a=[];for(let[u,f]of Object.entries(i.value.schemas))f.type==="literal"&&f.value.type==="string"&&(G7n.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:B_i(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[u,f]=i.value.schemas;if(u!=null&&f!=null&&A1a({array:u,primitive:f}))return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(u!=null&&f!=null&&A1a({array:u,primitive:f}))return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[u,f]of Object.entries(i.value.schemas))return kmu({schema:f,context:t,fileContainingReference:r,namespace:n})}else if(i.type==="object")return}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let i=t.getSchema(e.value.schema,n);if(i==null)return;if(i.type==="array")return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,declarationFile:zs.of(HT),namespace:n}),allowMultiple:!0}}if(e.value.type==="array")return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undisciminated"){let i=[];for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="literal"&&u.value.type==="string"&&(G7n.test(u.value.value)?i.push(u.value.value):i.push({value:u.value.value,name:B_i(u.value.value)}));if(i.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:i}}),{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[a,u]=e.value.value.schemas;if(a!=null&&u!=null&&A1a({array:a,primitive:u}))return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(a!=null&&u!=null&&A1a({array:u,primitive:a}))return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[a,u]of Object.entries(e.value.value.schemas))return kmu({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return;return{value:S1({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}return e.type==="array"?{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}:{value:S1({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}function A1a({array:e,primitive:t}){return(e==null?void 0:e.type)==="array"&&e.value.type==="primitive"&&(t==null?void 0:t.type)==="primitive"&&e.value.schema.type===t.schema.type}function Bqf({websocketExample:e,context:t}){let r={messages:[]};e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=dQ1(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=pQ1({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=Rzr(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function dQ1(e){let t={};return e.forEach(r=>{let n=Rzr(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function pQ1({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=Rzr(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function Rzr(e){switch(e.type){case"primitive":return Iqf(e.value);case"object":return Rqf(e.properties);case"array":return _Q1(e.value);case"map":return hQ1(e.value);case"oneOf":return yQ1(e.value);case"enum":return e.value;case"literal":return vQ1(e.value);case"unknown":return Rzr(e.value);default:Ol(e)}}function Iqf(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:Ol(e)}}function Rqf(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Rzr(r)]))}function _Q1(e){return e.map(t=>Rzr(t))}function hQ1(e){return Object.fromEntries(e.map(t=>[Iqf(t.key),Rzr(t.value)]))}function yQ1(e){return e.type==="discriminated"?Rqf(e.value):Rzr(e.value)}function vQ1(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ol(e)}}function bEr(e){var t;return(t=e.find(r=>typeof r!="string"&&r.type==="namespace"))==null?void 0:t.name}function z1a(e,t){return t??((e==null?void 0:e.groupName)!=null?bEr(e.groupName):void 0)}function Fqf({channel:e,context:t,declarationFile:r}){let n={path:e.path,auth:!1};e.summary!=null&&(n["display-name"]=e.summary);let i=bEr(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=eba({pathParameter:d,context:t,fileContainingReference:r,namespace:i});Object.keys(a).length>0&&(n["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let c=N1a({queryParameter:d,context:t,fileContainingReference:r,namespace:i});c!=null&&(u[d.name]=c)}Object.keys(u).length>0&&(n["query-parameters"]=u);let f={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let c=IRt({header:d,context:t,fileContainingReference:r,namespace:i});f[d.name]=c}Object.keys(f).length>0&&(n.headers=f),t.builder.addChannel(r,{channel:n}),e.subscribe!=null&&t.builder.addChannelMessage(r,{messageId:"subscribe",message:{origin:"server",body:S1({schema:e.subscribe,context:t,fileContainingReference:r,namespace:i})}}),e.publish!=null&&t.builder.addChannelMessage(r,{messageId:"publish",message:{origin:"client",body:S1({schema:e.publish,context:t,fileContainingReference:r,namespace:i})}});for(let d of e.examples){let c=Bqf({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:c})}}var Lqf="Production",Uqf="Default";function Vqf(e){return Object.entries(e).reduce((t,[r,n])=>(U2n(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function Wqf(e){var f,d;if(e.environmentOverrides!=null){for(let[c,o]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:c,schema:o});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[];for(let c of e.ir.servers){let o=c.audiences?{url:c.url,audiences:c.audiences}:c.url;if(c.name==null){r.push(o);continue}t[c.name]=o}let n={},i=[];for(let c of e.ir.endpoints)for(let o of c.server){if(o.url==null)continue;let l=o.audiences?{url:o.url,audiences:o.audiences}:o.url;if(o.name==null){i.push(l);continue}n[o.name]=l}let a=Object.keys(t).length,u=Object.keys(n).length;if(a===0&&u===0){let c=(f=e.ir.servers[0])==null?void 0:f.url,o=(d=e.ir.servers[0])==null?void 0:d.audiences;c!=null&&(e.builder.addEnvironment({name:Uqf,schema:o?{url:c,audiences:o}:c}),e.builder.setDefaultEnvironment(Uqf))}else if(a>0&&u===0){let c=0;r.length>0&&e.logger.error(`Skipping servers ${r.map(o=>typeof o=="string"?o:o.url).join(", ")} because x-fern-server-name was not provided.`);for(let[o,l]of Object.entries(t))c===0&&e.builder.setDefaultEnvironment(o),e.builder.addEnvironment({name:o,schema:l}),c+=1}else if(u>0){(r.length>0||i.length>0)&&e.logger.error(`Skipping servers ${[...r,...i].map(o=>typeof o=="string"?o:o.url).join(", ")} because x-fern-server-name was not provided.`);let c=Object.entries(t)[0];if(c!=null){let[o,l]=c;e.setDefaultServerName(o)}e.builder.addEnvironment({name:Lqf,schema:{urls:{...Vqf(t),...Vqf(n)}}}),e.builder.setDefaultEnvironment(Lqf)}}function B1a(e){return A2(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var eOu=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},bQ1=.75,gQ1=new Set("authorization");function Hqf(e){let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,n]of Object.entries(t)){let i="optional<string>";if(n.name==null&&n.env==null&&typeof n.schema=="string")i=n.schema;else if(n!=null){let a=n.schema?V7n(n.schema):void 0,u=a!=null?bEr(a):void 0,f=zs.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?A2(S1({schema:n.schema,context:e,fileContainingReference:u?pf(zs.of(FE(u)),f):f,namespace:u}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:i})}if(e.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let a of i.headers){if(gQ1.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let f=t[a.name],d=IRt({header:{...a,schema:(f==null?void 0:f.schema)??a.schema,name:(f==null?void 0:f.name)??a.name},fileContainingReference:zs.of(nB),context:e,namespace:void 0});u=new eOu(d),r[a.name]=u}u.increment()}let n=e.ir.endpoints.length*bQ1;for(let[i,a]of Object.entries(r)){let u=t[i],f=a.count===e.ir.endpoints.length,d=a.count>=n;u==null&&(f?e.builder.addGlobalHeader({name:i,schema:a.schema}):d&&e.builder.addGlobalHeader({name:i,schema:B1a(a.schema)}))}}}function $qf(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?V7n(t.schema):void 0,n=r!=null?bEr(r):void 0,i=IRt({header:{...t,schema:t.schema??ib.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:Xw.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0})}),name:t.name??t.header,parameterNameOverride:void 0,description:void 0,availability:void 0,source:void 0},fileContainingReference:zs.of(nB),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:B1a(i)})}}function lG(e){switch(e.type){case"primitive":return Jqf(e.value);case"object":return Gqf(e.properties);case"array":return mQ1(e.value);case"map":return OQ1(e.value);case"oneOf":return PQ1(e.value);case"enum":return e.value;case"literal":return jQ1(e.value);case"unknown":return lG(e.value);default:Ol(e)}}function Jqf(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:Ol(e)}}function Gqf(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,lG(r)]))}function mQ1(e){return e.map(t=>lG(t))}function OQ1(e){return Object.fromEntries(e.map(t=>[Jqf(t.key),lG(t.value)]))}function PQ1(e){return e.type==="discriminated"?Gqf(e.value):lG(e.value)}function jQ1(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ol(e)}}function Kqf({endpointExample:e,context:t}){let r={};return e.type!=="full"?e.value:(e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=wQ1(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=DQ1(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=SQ1({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=lG(e.request)),e.response!=null&&(r.response={body:lG(e.response)}),e.response!=null&&(r.response={body:lG(e.response)}),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(n=>n.type==="language"?{name:n.name??void 0,docs:n.description??void 0,language:n.language,code:n.code,install:n.install??void 0}:{name:n.name??void 0,docs:n.description??void 0,sdk:n.sdk,code:n.code}).filter(RS)),r)}function wQ1(e){let t={};return e.forEach(r=>{let n=lG(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function DQ1(e){let t={};return e.forEach(r=>{let n=lG(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function SQ1({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=lG(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function Yqf(e){return KJ._visit(e,{get:()=>h5.HttpMethodSchema.Enum.GET,post:()=>h5.HttpMethodSchema.Enum.POST,put:()=>h5.HttpMethodSchema.Enum.PUT,patch:()=>h5.HttpMethodSchema.Enum.PATCH,delete:()=>h5.HttpMethodSchema.Enum.DELETE,head:()=>{throw new Error("HEAD is unsupported")},options:()=>{throw new Error("HEAD is unsupported")},trace:()=>{throw new Error("HEAD is unsupported")},_other:()=>{throw new Error("Unkown http method is unsupported")}})}function Xqf({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,u=e.path,f=z1a(e.sdkName,e.namespace),d={};for(let S of e.pathParameters)S.parameterNameOverride&&(u=u.replace(S.name,S.parameterNameOverride)),d[S.parameterNameOverride??S.name]=eba({pathParameter:S,context:r,fileContainingReference:t,namespace:f}),a.add(S.name);let c={};for(let S of e.queryParameters){let x=N1a({queryParameter:S,context:r,fileContainingReference:t,namespace:f});x!=null&&(c[S.name]=x,a.add(S.name))}let o;e.pagination!=null&&(e.pagination.type==="cursor"?o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results}:o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage});let l={path:u,method:Yqf(e.method),auth:e.authed,docs:e.description??void 0,pagination:o};Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let g={},O=r.builder.getGlobalHeaderNames(),j=e.headers.filter(S=>!O.has(S.name));for(let S of j){let x=IRt({header:S,context:r,fileContainingReference:t,namespace:f});g[S.name]=x,a.add(typeof x=="string"?S.name:x.name??S.name)}if(e.request!=null){let S=MQ1({context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,queryParameters:Object.keys(c).length>0?c:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(g).length>0?g:void 0,usedNames:a,namespace:f});l.request=S.value,i=[...i,...S.schemaIdsToExclude??[]]}else{let S=Object.keys(c).length>0,x=Object.keys(g).length>0,A={};(S||x)&&(A.name=e.requestNameOverride??e.generatedRequestName),S&&(A["query-parameters"]=c),x&&(A.headers=g),Object.keys(A).length>0&&(l.request=A)}if(e.response!=null&&e.response._visit({json:S=>{let x=S1({schema:S.schema,context:r,fileContainingReference:t,namespace:f});l.response={docs:S.description??void 0,type:A2(x)},S.responseProperty!=null&&(l.response.property=S.responseProperty)},streamingJson:S=>{let x=S1({schema:S.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:S.description??void 0,type:A2(x),format:"json"}},streamingSse:S=>{let x=S1({schema:S.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:S.description??void 0,type:A2(x),format:"sse"}},file:S=>{l.response={docs:S.description??void 0,type:"file"}},streamingText:S=>{l["response-stream"]={docs:S.description??void 0,type:"text"}},text:S=>{l.response={docs:S.description??void 0,type:"text"}},_other:()=>{var S;throw new Error("Unrecognized Response type: "+((S=e.response)==null?void 0:S.type))}}),r.builder.getEnvironmentType()==="multi"){let S=r.getDefaultServerName(),x=e.server[0];x==null?S!=null&&(l.url=S):l.url=x.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=q3(e.availability)),Object.entries(e.errors).forEach(([S,x])=>{var te;let A=x.generatedName,z=zs.of(HT);r.builder.enableUniqueErrorsPerEndpoint&&(A=`${e.generatedRequestName}${x.generatedName}`,x.schema!=null&&(x.schema.type!=="reference"&&x.schema.type!=="oneOf"?x.schema.generatedName=`${e.generatedRequestName}${x.schema.generatedName}`:x.schema.type==="oneOf"&&(x.schema.value.generatedName=`${e.generatedRequestName}${x.schema.value.generatedName}`)));let N={"status-code":parseInt(S)},C=Gdf({location:Qqf,namespaceOverride:f});if(x.schema!=null){let G=S1({schema:x.schema,context:r,fileContainingReference:C,declarationFile:C,namespace:f});N.type=A2(G),N.docs=x.description}r.builder.addError(C,{name:A,schema:N}),l.errors==null&&(l.errors=[]);let U=r.builder.addImport({file:t,fileToImport:C});l.errors.push(U!=null?`${U}.${A}`:A),N.type!=null&&((te=x.examples)==null||te.forEach(G=>{let $={value:lG(G.example),name:G.name,docs:G.description};r.builder.addErrorExample(C,{name:A,example:$})}))}),e.examples.length>0&&(l.examples=EQ1({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[tOu,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function EQ1({endpointExamples:e,context:t}){return e.map(r=>{try{return Kqf({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function MQ1({declarationFile:e,context:t,request:r,requestNameOverride:n,generatedRequestName:i,queryParameters:a,nonRequestReferencedSchemas:u,headers:f,usedNames:d,namespace:c}){if(r.type==="json"){let o=r.schema.type==="reference"?r.schema.schema:void 0,l=r.schema.type==="reference"?t.getSchema(r.schema.schema,c):r.schema;if((l==null?void 0:l.type)!=="object"||o!=null&&u.includes(o)){let x=S1({schema:r.schema,fileContainingReference:e,context:t,namespace:c}),A={schemaIdsToExclude:[],value:{body:x}},z=Object.keys(a??{}).length>0,N=Object.keys(f??{}).length>0;return z&&(A.value["query-parameters"]=a),N&&(A.value.headers=f),(z||N)&&(A.value.name=n??i),r.contentType!=null&&(A.value["content-type"]=r.contentType),A}let g=Object.fromEntries(l.properties.map(x=>{let A=S1({schema:x.schema,fileContainingReference:e,context:t,namespace:c}),z=x.nameOverride??x.key,N=q3(x.availability);if(!d.has(z)&&x.audiences.length<=0)return d.add(z),x.nameOverride!=null?[x.key,{type:A2(A),docs:A_i(A),name:x.nameOverride,availability:N}]:[x.key,N?{...typeof A=="string"?{type:A}:A,availability:N}:A];let C={type:A2(A),docs:A_i(A)};return d.has(z)&&(C.name=x.generatedName),x.audiences.length>0&&(C.audiences=x.audiences),N!=null&&(C.availability=N),d.add(z),[x.key,C]})),O=l.allOf.map(x=>{let A=S1({schema:ib.reference(x),fileContainingReference:e,context:t,namespace:c});return A2(A)}),j={properties:g};O.length>0&&(j.extends=O),r.additionalProperties&&(j["extra-properties"]=!0);let S={name:n??l.nameOverride??l.generatedName,"query-parameters":a,headers:f,body:j};return r.contentType!=null&&(S["content-type"]=r.contentType),{schemaIdsToExclude:o!=null?[o]:[],value:S}}else{if(r.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":sA.APPLICATION_OCTET_STREAM}};if(r.type==="multipart"){let o=Object.fromEntries(r.properties.map(l=>{if(l.schema.type==="file"){let g=l.schema.isArray?"list<file>":"file";if(g=l.schema.isOptional?`optional<${g}>`:g,l.description!=null||l.contentType!=null){let O={type:g};return l.description!=null&&(O.docs=l.description),l.contentType!=null&&(O["content-type"]=l.contentType),[l.key,O]}return[l.key,g]}else{let g=S1({schema:l.schema.value,fileContainingReference:e,context:t,namespace:c});return l.contentType!=null&&(typeof g=="string"?g={type:g,"content-type":l.contentType}:g["content-type"]=l.contentType),[l.key,g]}}));return{schemaIdsToExclude:r.name==null?[]:[r.name],value:{name:n??r.name??i,"query-parameters":a,headers:f,body:{properties:o},"content-type":sA.MULTIPART_FORM_DATA}}}else Ol(r)}}function xQ1({location:e,namespaceOverride:t}){return t!=null?{...e,file:pf(zs.of(t),e.file)}:e}function TQ1(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:zs.of(`${FE(r)}.yml`),endpointId:e.summary!=null?FE(e.summary):FE(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:zs.of(HT),endpointId:FE(e.summary)}:{file:zs.of(HT),endpointId:FE(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:zs.of(HT),endpointId:n};let i=A0i(r),a=A0i(n);if(iDr(i,a))return{file:zs.of("__package__.yml"),endpointId:r};let u=AQ1({operationId:n,tag:r,path:e.path,method:e.method});if(u!=null)return u;let f=[];for(let d=0;d<i.length;++d){let c=i[d];if(c!=null&&c===a[d])f.push(c);else{let o=FE(r);return{file:zs.of(`${o}.yml`),endpointId:n,tag:r}}}if(f.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:zs.of(FE(f.join("_"))+".yml"),endpointId:FE(a.slice(f.length).join("_")),tag:r}}function N0i(e){let t=e.tags[0];if(e.sdkName!=null){let r=klu({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===(t==null?void 0:t.toLowerCase().replaceAll(" ",""));return{file:zs.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return xQ1({namespaceOverride:e.namespace,location:TQ1(e)})}function A0i(e){let t;return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)?t=e.split(/(?=[A-Z])/):t=e.split(/[^a-zA-Z0-9]+/),t=t.map(r=>r.toLowerCase()),t=X8t(t),t}var qQ1=new RegExp("[^a-zA-Z0-9{}]+"),CQ1=new RegExp("[{}]","g");function AQ1({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(qQ1).join("_").replaceAll(CQ1,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:zs.of(FE(t)+".yml"),endpointId:FE(e.slice(0,-1*a.length)),tag:t}}function Zqf(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:u,file:f,tag:d}=N0i(a),c=f.split(".")[0];c!=null&&t.add(c);let o;if(a.sdkName!=null){let O=e.ir.groups;for(let j of a.sdkName.groupName){let S=typeof j=="string"?j:j.name,x=O[S];if(x==null)break;if(x.summary!=null||x.description!=null){o=O[S];break}}}let l=d==null?void 0:n.tagsById[d],g=Xqf({context:e,endpoint:a,declarationFile:f});i=[...i,...g.schemaIdsToExclude],e.builder.addEndpoint(f,{name:u,schema:g.value,source:a.source}),((l==null?void 0:l.id)!=null||(l==null?void 0:l.description)!=null)&&e.builder.setServiceInfo(f,{displayName:(o==null?void 0:o.summary)??(l==null?void 0:l.id),docs:(o==null?void 0:o.description)??(l==null?void 0:l.description)??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}function kqf(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?bEr(r.groupName):void 0,i=S1({schema:ib.primitive(r),context:e,fileContainingReference:zs.of(HT),namespace:n});e.builder.addVariable({name:t,schema:{type:A2(i),docs:r.description??void 0}})}}function eCf(e){for(let t of e.ir.webhooks){let r=BQ1({webhook:t,context:e});if(r==null)continue;let n=z1a(t.sdkName,t.namespace),i={};for(let u of t.headers)i[u.name]=IRt({header:u,context:e,fileContainingReference:r.file,namespace:n});let a={method:t.method,"display-name":t.summary??void 0,headers:i,payload:S1({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:lG(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function NQ1({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:pf(zs.of(t),e.file)}:e}function zQ1({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:zs.of(HT),endpointId:n};let i=A0i(r),a=A0i(n);if(iDr(i,a))return{file:zs.of("__package__.yml"),endpointId:r};let u=[];for(let f=0;f<i.length;++f){let d=i[f];if(d!=null&&d===a[f])u.push(d);else{let c=FE(r);return{file:zs.of(`${c}.yml`),endpointId:n,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:zs.of(FE(u.join("_"))+".yml"),endpointId:FE(a.slice(u.length).join("_")),tag:r}}function BQ1({webhook:e,context:t}){return e.sdkName!=null?{file:Jdf({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:NQ1({namespaceOverride:e.namespace,location:zQ1({webhook:e,context:t})})}var IQ1=zs.of(HT);function tCf(e){switch(e.type){case"object":return bFt(e.groupName);case"enum":return bFt(e.groupName);case"oneOf":return bFt(e.value.groupName);case"array":return bFt(e.groupName);case"map":return bFt(e.groupName);case"reference":return bFt(e.groupName);case"literal":return bFt(e.groupName);case"optional":return bFt(e.groupName);case"nullable":return bFt(e.groupName);case"primitive":return bFt(e.groupName);case"unknown":return IQ1;default:Ol(e)}}function bFt(e){return W7n(e)}var tOu="external",Qqf=zs.of(HT);function rCf({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let u=tCf(a),f=Xdf({schema:a,context:n,declarationFile:u,namespace:r});if(W2n(f.schema)){let d=A2(f.schema);if(d===(f.name??i)||d===`optional<${f.name??i}>`)continue}n.builder.addType(u,{name:f.name??i,schema:f.schema})}}function nCf(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),Wqf(e),Hqf(e),$qf(e),epf(e),kqf(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(tOu);let{schemaIdsToExclude:t,sdkGroups:r}=Zqf(e);eCf(e);for(let n of e.ir.channel){let i=W7n(n.groupName);Fqf({channel:n,context:e,declarationFile:i})}rCf({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:t,namespace:void 0,context:e});for(let[n,i]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))rCf({schemas:i,schemaIdsToExclude:t,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(i=>r.has(i))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}var Fzr=yu(require("path"),1);var I1a=yu(require("path"),1),G3n=class{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[u,f]of Object.entries(n.files)){let d=i!=null?zs.of(`${i}${I1a.default.sep}${u}`):zs.of(u);t[d]=f}let a=Object.keys(n.directories).sort();for(let u of a){let f=i!=null?`${i}${I1a.default.sep}${u}`:u,d=n.directories[u];r(d,f)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(I1a.default.sep))}getOrCreateFileRecursive(t){var i,a;if(t.length===1)return(i=this.files)[a=zs.of(t[0])]??(i[a]={});let[r,...n]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new G3n),this.directories[r].getOrCreateFileRecursive(n)}};var R1a=class{modifyBasePaths;enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t,r,n){this.modifyBasePaths=r,this.enableUniqueErrorsPerEndpoint=n,this.root=new G3n,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}},t.title!=null&&(this.rootApiFile["display-name"]=t.title)}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{displayName:r,docs:n}){let i=this.getOrCreateFile(t);i.service==null&&(i.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(i.service["display-name"]=r),n!=null&&(i.docs=n)}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 ADr(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??{}),r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}addGlobalHeader({name:t,schema:r}){let n=this.getVersionHeader();n!=null&&n===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}){if(t===r)return;let n=FE((Cg(r)+"/"+(0,Fzr.basename)(r,(0,Fzr.extname)(r))).replaceAll("__package__","root"));if(t===zs.of(nB))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=YN(Cg(I_.of(`/${t}`)),I_.of(`/${r}`)),n;let i=this.getOrCreateFile(t);return i.imports==null&&(i.imports={}),i.imports[n]=YN(Cg(I_.of(`/${t}`)),I_.of(`/${r}`)),n}addType(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.types==null&&(i.types={}),i.types[r]=n}addTypeExample(t,r,n){let i=this.getOrCreateFile(t);i.types==null&&(i.types={});let a=i.types[r];a!=null&&(typeof a=="string"?i.types[r]={type:a,examples:[n]}:(a.examples==null&&(a.examples=[]),a.examples.push(n)))}addError(t,{name:r,schema:n}){var a;let i=this.getOrCreateFile(t);i.errors==null&&(i.errors={}),i.errors[r]==null?i.errors[r]=n:((a=i.errors[r])==null?void 0:a.type)!==n.type&&(i.errors[r]={"status-code":n["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:n}){var f;let i=this.getOrCreateFile(t);if(i.errors==null)return;let a=i.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(d=>iDr(d,n))??!1)||(f=a.examples)==null||f.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(a.service.source=Ien(i)),a.service.endpoints[r]=n}addWebhook(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.webhooks==null&&(i.webhooks={}),i.webhooks[r]=n}addChannel(t,{channel:r}){let n=this.getOrCreateFile(t);n.channel=r;let i=this.basePath;i!=null&&(n.channel.path=Fzr.default.join(i,r.path))}addChannelExample(t,{example:r}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.examples==null&&(n.channel.examples=[]),n.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:n}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.messages[r]=n}build(){let t=this.root.getAllFiles();if(this.modifyBasePaths){let i=RQ1(this.rootApiFile);this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([a,u])=>[a,{...u,path:`${i}${u.path}`}]))});for(let a of Object.values(t))a.service!=null&&(a.service={...a.service,endpoints:Object.fromEntries(Object.entries(a.service.endpoints).map(([u,f])=>[u,{...f,path:`${i}${f.path}`}]))});this.rootApiFile.environments!=null&&(this.rootApiFile.environments={...Object.fromEntries(Object.entries(this.rootApiFile.environments).map(([a,u])=>typeof u=="string"?[a,u.substring(0,u.length-i.length)]:iCf(u)?[a,{url:u.url.substring(0,u.url.length-i.length)}]:[a,{urls:Object.fromEntries(Object.entries(u.urls).map(([f,d])=>[f,d.substring(0,d.length-i.length)]))}]))})}let 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(([i,a])=>[i,{...a,path:Fzr.default.join(r,a.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([a,u])=>[a,{...u,path:Fzr.default.join(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===HT?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 RQ1(e){if(e.environments==null)return"";let t=Object.entries(e.environments).flatMap(([r,n])=>typeof n=="string"?[n]:iCf(n)?[n.url]:Object.values(n.urls));return LQ1(t.map(FQ1))}function FQ1(e){try{let r=new URL(e).pathname;return r.endsWith("/")?r.slice(0,-1):r}catch{return""}}function LQ1(e){let t="";for(;;){let r=e.map(i=>i[i.length-t.length-1]),n=r[0];if(n==null||r.some(i=>i!==n))break;t=n+t}return t}function iCf(e){return e.url!=null}var F1a=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;detectGlobalHeaders;defaultServerName=void 0;constructor({taskContext:t,ir:r,enableUniqueErrorsPerEndpoint:n,detectGlobalHeaders:i,environmentOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.builder=new R1a(r,!1,n),this.detectGlobalHeaders=i,this.environmentOverrides=a,this.authOverrides=u}getSchema(t,r){var n;return r==null?this.ir.groupedSchemas.rootSchemas[t]:(n=this.ir.groupedSchemas.namespacedSchemas[r])==null?void 0:n[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}};function rOu(e){let t=new F1a(e);return nCf(t)}var CAf=yu(qAf(),1);async function iwe(e,t,r=[],{doNotPipeOutput:n=!1,secrets:i=[],substitutions:a={},...u}={}){var o,l;let f=i.reduce((g,O)=>({...g,[O]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[g,O]of Object.entries(f))d=d.replaceAll(g,O);e==null||e.debug(`+ ${d}`);let c=(0,CAf.default)(t,r,u);return n||((o=c.stdout)==null||o.pipe(process.stdout),(l=c.stderr)==null||l.pipe(process.stderr)),c}function G1a(e,{logger:t,...r}={}){return(n,i)=>iwe(t,e,n,{...r,...i})}var Y1a=require("fs/promises"),AAf=yu(Jte(),1),Ak1="buf.gen.yaml",NAf="output",Nk1=`${NAf}/openapi.yaml`,zk1=`
|
|
1908
1908
|
version: v1
|
|
1909
1909
|
plugins:
|
|
1910
1910
|
- plugin: openapi
|