fern-api 0.43.2 → 0.43.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bundle.cjs +4 -4
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -1784,7 +1784,7 @@ ${l.indent}`:""}${D8c(o)}:${f.indent?" ":""}`;return u=!1,c=!0,f.objectItem=void
1784
1784
  `}),r.replaceAll(/\n$/g,"")}function HZP(e){return e?al.green(o8r.radioOn):o8r.radioOff}var Dpa=yu(Bje(),1);function nQl(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,Dpa.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,Dpa.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
  `+al.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?al.cyan(nQl(t,this.opt.mask)):al.italic.dim("[hidden]"):this.opt.mask?nQl(t,this.opt.mask):al.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 xZl=yu(MZl(),1),TZl=yu(Bje(),1);var epi=class extends dR{_run(t){this.done=t,this.editorResult=new TZl.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"?al.dim("Received"):al.dim("Press <enter> to launch your preferred editor."),t&&(r=al.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),(0,xZl.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 RZl=yu(AZl(),1);var BZl=yu(require("readline"),1),IZl=yu(zZl(),1),Jkr=class{constructor(t){this.rl||(this.rl=BZl.default.createInterface(NkP(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 NkP(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 IZl.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var tpi=class extends Jkr{constructor(t={}){super(t),this.log=(0,RZl.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&&Opa(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var KZl=yu(UZl(),1),YZl=yu(lnu(),1),XZl=yu(JZl(),1),aq=yu(Bje(),1),QZl=yu(Hfi(),1);var Gpa=yu(Bje(),1),GZl=yu(Hfi(),1),Kpa=function(e,t,r){return typeof e[t]!="function"?(0,Gpa.of)(e):(0,Gpa.from)((0,GZl.default)(e[t])(r).then(n=>(e[t]=n,e)))};var rpi={isPlainObject:KZl.default,set:XZl.default,get:YZl.default},GAn=class extends Jkr{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,aq.from)(t):t;return this.process=n.pipe((0,aq.concatMap)(this.processQuestion.bind(this)),(0,aq.publish)()),this.process.connect(),this.process.pipe((0,aq.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,aq.defer)(()=>(0,aq.of)(t).pipe((0,aq.concatMap)(this.setDefaultType.bind(this)),(0,aq.concatMap)(this.filterIfRunnable.bind(this)),(0,aq.concatMap)(()=>Kpa(t,"message",this.answers)),(0,aq.concatMap)(()=>Kpa(t,"default",this.answers)),(0,aq.concatMap)(()=>Kpa(t,"choices",this.answers)),(0,aq.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,aq.defer)(()=>(0,aq.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,aq.defer)(()=>(0,aq.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&rpi.get(this.answers,t.name)!==void 0)return(0,aq.empty)();if(t.when===!1)return(0,aq.empty)();if(typeof t.when!="function")return(0,aq.of)(t);let{answers:r}=this;return(0,aq.defer)(()=>(0,aq.from)((0,QZl.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,aq.filter)(n=>n!=null)))}};function ZZl(e){let t=function(r,n){let i;try{i=new GAn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",Rdi),this.registerPrompt("input",Fkr),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 nau=ZZl();function ZkP(e,t){nau.registerPrompt(e,t)}function kkP(){nau.restoreDefaultPrompts()}var ee1={prompt:nau,ui:{BottomBar:tpi,Prompt:GAn},createPromptModule:ZZl,registerPrompt:ZkP,restoreDefaultPrompts:kkP,Separator:bne},Ypa=ee1;var _kl=yu(cau(),1),Qpa=class{posthog;constructor({posthogApiKey:t}){this.posthog=new _kl.PostHog(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.43.2",usingAccessToken:!0}})}flush(){this.posthog.flush()}};var opi=class{async sendEvent(){}async identify(){}async flush(){}};var YAn=require("fs/promises"),Nkl=require("os"),zkl=require("path"),Bkl=yu(cau(),1);var hRt=yu(Akl(),1),CU7=hRt.default.v1,AU7=hRt.default.v3,Kkr=hRt.default.v4,NU7=hRt.default.v5,zU7=hRt.default.NIL,BU7=hRt.default.version,IU7=hRt.default.validate,RU7=hRt.default.stringify,FU7=hRt.default.parse;var xt1="id",Tt1=".fern",lpi=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new Bkl.PostHog(r),this.userId=t==null?void 0:OZo(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.43.2",...t,...t.properties}})}flush(){this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=pf(R_.of((0,Nkl.homedir)()),zs.of(Tt1),zs.of(xt1));await Vh(t)||(await(0,YAn.mkdir)((0,zkl.dirname)(t),{recursive:!0}),await(0,YAn.writeFile)(t,Kkr())),this.persistedDistinctId=(await(0,YAn.readFile)(t)).toString()}return this.persistedDistinctId}};var vau;async function XAn(){return vau==null&&(vau=await qt1()),vau}async function qt1(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new opi;let r=await Dua();return r!=null?new lpi({token:r,posthogApiKey:e}):await wua()!=null?new Qpa({posthogApiKey:e}):new lpi({token:void 0,posthogApiKey:e})}catch{return new opi}}var dou=yu(vRt(),1);var ppi=yu(require("process"),1);var Ttf=yu(Vau(),1),qtf=yu(xtf(),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,qtf.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(Ttf.default.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=r;break;default:n+=1}}return n}function w_a(e){let t=0;for(let r of e.split(`
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&&Opa(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var KZl=yu(UZl(),1),YZl=yu(lnu(),1),XZl=yu(JZl(),1),aq=yu(Bje(),1),QZl=yu(Hfi(),1);var Gpa=yu(Bje(),1),GZl=yu(Hfi(),1),Kpa=function(e,t,r){return typeof e[t]!="function"?(0,Gpa.of)(e):(0,Gpa.from)((0,GZl.default)(e[t])(r).then(n=>(e[t]=n,e)))};var rpi={isPlainObject:KZl.default,set:XZl.default,get:YZl.default},GAn=class extends Jkr{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,aq.from)(t):t;return this.process=n.pipe((0,aq.concatMap)(this.processQuestion.bind(this)),(0,aq.publish)()),this.process.connect(),this.process.pipe((0,aq.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,aq.defer)(()=>(0,aq.of)(t).pipe((0,aq.concatMap)(this.setDefaultType.bind(this)),(0,aq.concatMap)(this.filterIfRunnable.bind(this)),(0,aq.concatMap)(()=>Kpa(t,"message",this.answers)),(0,aq.concatMap)(()=>Kpa(t,"default",this.answers)),(0,aq.concatMap)(()=>Kpa(t,"choices",this.answers)),(0,aq.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,aq.defer)(()=>(0,aq.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,aq.defer)(()=>(0,aq.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&rpi.get(this.answers,t.name)!==void 0)return(0,aq.empty)();if(t.when===!1)return(0,aq.empty)();if(typeof t.when!="function")return(0,aq.of)(t);let{answers:r}=this;return(0,aq.defer)(()=>(0,aq.from)((0,QZl.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,aq.filter)(n=>n!=null)))}};function ZZl(e){let t=function(r,n){let i;try{i=new GAn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",Rdi),this.registerPrompt("input",Fkr),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 nau=ZZl();function ZkP(e,t){nau.registerPrompt(e,t)}function kkP(){nau.restoreDefaultPrompts()}var ee1={prompt:nau,ui:{BottomBar:tpi,Prompt:GAn},createPromptModule:ZZl,registerPrompt:ZkP,restoreDefaultPrompts:kkP,Separator:bne},Ypa=ee1;var _kl=yu(cau(),1),Qpa=class{posthog;constructor({posthogApiKey:t}){this.posthog=new _kl.PostHog(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.43.4",usingAccessToken:!0}})}flush(){this.posthog.flush()}};var opi=class{async sendEvent(){}async identify(){}async flush(){}};var YAn=require("fs/promises"),Nkl=require("os"),zkl=require("path"),Bkl=yu(cau(),1);var hRt=yu(Akl(),1),CU7=hRt.default.v1,AU7=hRt.default.v3,Kkr=hRt.default.v4,NU7=hRt.default.v5,zU7=hRt.default.NIL,BU7=hRt.default.version,IU7=hRt.default.validate,RU7=hRt.default.stringify,FU7=hRt.default.parse;var xt1="id",Tt1=".fern",lpi=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new Bkl.PostHog(r),this.userId=t==null?void 0:OZo(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.43.4",...t,...t.properties}})}flush(){this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=pf(R_.of((0,Nkl.homedir)()),zs.of(Tt1),zs.of(xt1));await Vh(t)||(await(0,YAn.mkdir)((0,zkl.dirname)(t),{recursive:!0}),await(0,YAn.writeFile)(t,Kkr())),this.persistedDistinctId=(await(0,YAn.readFile)(t)).toString()}return this.persistedDistinctId}};var vau;async function XAn(){return vau==null&&(vau=await qt1()),vau}async function qt1(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new opi;let r=await Dua();return r!=null?new lpi({token:r,posthogApiKey:e}):await wua()!=null?new Qpa({posthogApiKey:e}):new lpi({token:void 0,posthogApiKey:e})}catch{return new opi}}var dou=yu(vRt(),1);var ppi=yu(require("process"),1);var Ttf=yu(Vau(),1),qtf=yu(xtf(),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,qtf.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(Ttf.default.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=r;break;default:n+=1}}return n}function w_a(e){let t=0;for(let r of e.split(`
1788
1788
  `))t=Math.max(t,N9(r));return t}var Qtf=yu(Hau(),1);var En1=/[\p{Lu}]/u,Mn1=/[\p{Ll}]/u,Ntf=/^[\p{Lu}](?![\p{Lu}])/gu,Itf=/([\p{Alpha}\p{N}_]|$)/u,$au=/[_.\- ]+/,xn1=new RegExp("^"+$au.source),ztf=new RegExp($au.source+Itf.source,"gu"),Btf=new RegExp("\\d+"+Itf.source,"gu"),Tn1=(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&&En1.test(c)?(e=e.slice(0,d)+"-"+e.slice(d),i=!1,u=a,a=!0,d++):a&&u&&Mn1.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},qn1=(e,t)=>(Ntf.lastIndex=0,e.replace(Ntf,r=>t(r))),Cn1=(e,t)=>(ztf.lastIndex=0,Btf.lastIndex=0,e.replace(ztf,(r,n)=>t(n)).replace(Btf,r=>t(r)));function Jau(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?$au.test(e)?"":t.pascalCase?n(e):r(e):(e!==r(e)&&(e=Tn1(e,r,n,t.preserveConsecutiveUppercase)),e=e.replace(xn1,""),e=t.preserveConsecutiveUppercase?qn1(e,r):r(e),t.pascalCase&&(e=n(e.charAt(0))+e.slice(1)),Cn1(e,n))}var Xau=yu(Ftf(),1);var Ltf=(e=0)=>t=>`\x1B[${t+e}m`,Utf=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Vtf=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function Bn1(){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=Ltf(),t.color.ansi256=Utf(),t.color.ansi16m=Vtf(),t.bgColor.ansi=Ltf(10),t.bgColor.ansi256=Utf(10),t.bgColor.ansi16m=Vtf(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 In1=Bn1(),Wtf=In1;var D_a=new Set(["\x1B","\x9B"]),Rn1=39,Kau="\x07",Jtf="[",Fn1="]",Gtf="m",Yau=`${Fn1}8;;`,Htf=e=>`${D_a.values().next().value}${Jtf}${e}${Gtf}`,$tf=e=>`${D_a.values().next().value}${Yau}${e}${Kau}`,Ln1=e=>e.split(" ").map(t=>N9(t)),Gau=(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),D_a.has(d)&&(i=!0,a=n.slice(f+1).join("").startsWith(Yau)),i){a?d===Kau&&(i=!1,a=!1):d===Gtf&&(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())},Un1=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("")},Vn1=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",i,a,u=Ln1(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(""),Gau(f,o,t);continue}if(l+u[c]>t&&l>0&&u[c]>0){if(r.wordWrap===!1&&l<t){Gau(f,o,t);continue}f.push("")}if(l+u[c]>t&&r.wordWrap===!1){Gau(f,o,t);continue}f[f.length-1]+=o}r.trim!==!1&&(f=f.map(c=>Un1(c)));let d=[...f.join(`
1789
1789
  `)];for(let[c,o]of d.entries()){if(n+=o,D_a.has(o)){let{groups:g}=new RegExp(`(?:\\${Jtf}(?<code>\\d+)m|\\${Yau}(?<uri>.*)${Kau})`).exec(d.slice(c).join(""))||{groups:{}};if(g.code!==void 0){let O=Number.parseFloat(g.code);i=O===Rn1?void 0:O}else g.uri!==void 0&&(a=g.uri.length===0?void 0:g.uri)}let l=Wtf.codes.get(Number(i));d[c+1]===`
1790
1790
  `?(a&&(n+=$tf("")),i&&l&&(n+=Htf(l))):o===`
@@ -1901,7 +1901,7 @@ errors:
1901
1901
  Run ${al.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
1902
1902
  Run ${al.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),o6n(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function zsu({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!fuf(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 Up1(f.generatorName)} (${f.apiName!=null?"API: "+f.apiName+", ":""}Group: ${f.generatorGroup}) `+al.dim(f.currentVersion)+al.reset(" \u2192 ")+al.green(f.latestVersion);return i+=`
1904
- `,n?o6n(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function Up1(e){let r=await new luf.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 Vp1({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await puf({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 puf({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 puf({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 _uf(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=One(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 qha({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await Vp1({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(..._uf(c,d,t.logger));else u.push(..._uf(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 R6n=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 Cha({},...e)},Bsu=(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},Cha=(...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=Cha(t[i],a)),t={...t,[i]:a};t_i(n.headers)&&(r=Bsu(r,n.headers),t.headers=r)}return t};var huf=(()=>{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})(),yuf=typeof globalThis.AbortController=="function",vuf=typeof globalThis.ReadableStream=="function",buf=typeof globalThis.FormData=="function",Aha=["get","post","put","patch","head","delete"],Wp1=()=>{};Wp1();var guf={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},Nha=2147483647,zha=Symbol("stop"),muf={json:!0,parseJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},Ouf={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 juf=e=>Aha.includes(e)?e.toUpperCase():e,Hp1=["get","put","head","delete","options","trace"],$p1=[408,413,429,500,502,503,504],wuf=[413,429,503],Puf={limit:2,methods:Hp1,statusCodes:$p1,afterStatusCodes:wuf,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Duf=(e={})=>{if(typeof e=="number")return{...Puf,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{...Puf,...e,afterStatusCodes:wuf}};async function Isu(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new R6n(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function Rsu(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 Suf=(e,t)=>{let r={};for(let n in t)!(n in Ouf)&&!(n in muf)&&!(n in e)&&(r[n]=t[n]);return r};var hen=class{static create(t,r){let n=new hen(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>Nha)throw new RangeError(`The \`timeout\` option cannot be greater than ${Nha}`);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(!vuf)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(guf))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:Bsu(this._input.headers,r.headers),hooks:Cha({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:juf(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:Duf(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(yuf){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(huf&&(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);(buf&&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 R6n)){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),Nha);if(n!==0&&this._retryCount>0){await Rsu(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})===zha)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=Suf(this.request,this._options);return this._options.timeout===!1?this._options.fetch(this.request.clone(),t):Isu(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 Fsu=e=>{let t=(r,n)=>hen.create(r,r_i(e,n));for(let r of Aha)t[r]=(n,i)=>hen.create(n,r_i(e,i,{method:r}));return t.create=r=>Fsu(r_i(r)),t.extend=r=>Fsu(r_i(e,r)),t.stop=zha,t},Jp1=Fsu(),Euf=Jp1;var Xuf=yu(Yuf(),1);function Hsu(e){let t=(0,Xuf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Jsf=yu($sf(),1),Gsf=yu(tZr(),1),rcu=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},ncu=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function icu(e,t={}){var l;let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??Hsu(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,Jsf.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 Euf(u,{headers:d,keepalive:!0}).json()}catch(g){throw((l=g==null?void 0:g.response)==null?void 0:l.status)===404?new rcu(e):g}if(t.allVersions)return c;let o=new ncu(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=Gsf.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 icu(e.toLowerCase(),t);return r}async function $6n({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:u_i(e.packageName,{version:t?"prerelease":"latest"})}var Ksf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Kha=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=vM.Info;constructor(t){this.ttyAwareLogger=new Tha(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.43.2"==null&&this.logger.error("CLI_VERSION is not defined"),"0.43.2"}getCliName(){return"fern"==null&&this.logger.error("CLI_NAME is not defined"),"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${al.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Yte}failWithoutThrowing(t,r){this.didSucceed=!1,Sha({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),(await XAn()).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 duf({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1904
+ `,n?o6n(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function Up1(e){let r=await new luf.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 Vp1({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await puf({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 puf({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 puf({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 _uf(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=One(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 qha({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await Vp1({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(..._uf(c,d,t.logger));else u.push(..._uf(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 R6n=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 Cha({},...e)},Bsu=(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},Cha=(...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=Cha(t[i],a)),t={...t,[i]:a};t_i(n.headers)&&(r=Bsu(r,n.headers),t.headers=r)}return t};var huf=(()=>{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})(),yuf=typeof globalThis.AbortController=="function",vuf=typeof globalThis.ReadableStream=="function",buf=typeof globalThis.FormData=="function",Aha=["get","post","put","patch","head","delete"],Wp1=()=>{};Wp1();var guf={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},Nha=2147483647,zha=Symbol("stop"),muf={json:!0,parseJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},Ouf={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 juf=e=>Aha.includes(e)?e.toUpperCase():e,Hp1=["get","put","head","delete","options","trace"],$p1=[408,413,429,500,502,503,504],wuf=[413,429,503],Puf={limit:2,methods:Hp1,statusCodes:$p1,afterStatusCodes:wuf,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Duf=(e={})=>{if(typeof e=="number")return{...Puf,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{...Puf,...e,afterStatusCodes:wuf}};async function Isu(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new R6n(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function Rsu(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 Suf=(e,t)=>{let r={};for(let n in t)!(n in Ouf)&&!(n in muf)&&!(n in e)&&(r[n]=t[n]);return r};var hen=class{static create(t,r){let n=new hen(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>Nha)throw new RangeError(`The \`timeout\` option cannot be greater than ${Nha}`);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(!vuf)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(guf))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:Bsu(this._input.headers,r.headers),hooks:Cha({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:juf(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:Duf(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(yuf){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(huf&&(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);(buf&&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 R6n)){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),Nha);if(n!==0&&this._retryCount>0){await Rsu(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})===zha)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=Suf(this.request,this._options);return this._options.timeout===!1?this._options.fetch(this.request.clone(),t):Isu(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 Fsu=e=>{let t=(r,n)=>hen.create(r,r_i(e,n));for(let r of Aha)t[r]=(n,i)=>hen.create(n,r_i(e,i,{method:r}));return t.create=r=>Fsu(r_i(r)),t.extend=r=>Fsu(r_i(e,r)),t.stop=zha,t},Jp1=Fsu(),Euf=Jp1;var Xuf=yu(Yuf(),1);function Hsu(e){let t=(0,Xuf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Jsf=yu($sf(),1),Gsf=yu(tZr(),1),rcu=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},ncu=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function icu(e,t={}){var l;let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??Hsu(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,Jsf.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 Euf(u,{headers:d,keepalive:!0}).json()}catch(g){throw((l=g==null?void 0:g.response)==null?void 0:l.status)===404?new rcu(e):g}if(t.allVersions)return c;let o=new ncu(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=Gsf.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 icu(e.toLowerCase(),t);return r}async function $6n({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:u_i(e.packageName,{version:t?"prerelease":"latest"})}var Ksf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Kha=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=vM.Info;constructor(t){this.ttyAwareLogger=new Tha(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.43.4"==null&&this.logger.error("CLI_VERSION is not defined"),"0.43.4"}getCliName(){return"fern"==null&&this.logger.error("CLI_NAME is not defined"),"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${al.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Yte}failWithoutThrowing(t,r){this.didSucceed=!1,Sha({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),(await XAn()).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 duf({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=r9o(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 Yte}finally{n.finish()}return i}async instrumentPostHogEvent(t){(await XAn()).sendEvent(t)}logger=csi(this.log.bind(this));constructTaskInitForWorkspace(t){let r=Ysf(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?Ysf(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=Ksf[this.numTasks++%Ksf.length],u=al.hex(a)(i);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===E4.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=>E4r.indexOf(n.level)>=E4r.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===vM.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 $6n({cliEnvironment:this.environment,includePreReleases:t}),n=One(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await qha({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}};function Ysf(e){return`[${e}]:`}var jlf=yu(Plf(),1);async function $je(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,jlf.default)(t,r,u);return n||((o=c.stdout)==null||o.pipe(process.stdout),(l=c.stderr)==null||l.pipe(process.stderr)),c}function rya(e,{logger:t,...r}={}){return(n,i)=>$je(t,e,n,{...r,...i})}var iya=require("fs/promises"),wlf=yu(Kte(),1),Uy1="buf.gen.yaml",Dlf="output",Vy1=`${Dlf}/openapi.yaml`,Wy1=`
1907
1907
  version: v1
@@ -1913,7 +1913,7 @@ plugins:
1913
1913
  - enum_type=string
1914
1914
  - default_response=false
1915
1915
  `,nya=class{context;constructor({context:t}){this.context=t}async generate({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,local:n}){return n?this.generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r}):this.generateRemote()}async generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r}){let n=await this.setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t}),i=D4(t,r);return this.doGenerateLocal({cwd:n,target:i})}async setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t}){let r=R_.of((await wlf.default.dir()).path);return await(0,iya.cp)(t,r,{recursive:!0}),await(0,iya.writeFile)(pf(r,zs.of(Uy1)),Wy1),r}async doGenerateLocal({cwd:t,target:r}){let n=rya("which",{cwd:t,logger:this.context.logger});try{await n(["buf"])}catch{this.context.failAndThrow("Missing required dependency; please install 'buf' to continue (e.g. 'brew install buf').")}try{await n(["protoc-gen-openapi"])}catch{this.context.failAndThrow("Missing required dependency; please install 'protoc-gen-openapi' to continue (e.g. 'brew install go && go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest').")}let i=rya("buf",{cwd:t,logger:this.context.logger});return await i(["config","init"]),await i(["generate",r]),pf(t,zs.of(Vy1))}async generateRemote(){this.context.failAndThrow("Remote Protobuf generation is unimplemented.")}};async function wen({context:e,specs:t,relativePathToDependency:r}){let n=new nya({context:e}),i=t.filter(f=>f.type==="openapi").map(f=>({...f,relativePathToDependency:r})),a=t.filter(f=>f.type==="protobuf"),u=await Promise.all(a.map(async f=>Hy1({generator:n,protobufSpec:f,relativePathToDependency:r})));return[...i,...u]}async function Hy1({generator:e,protobufSpec:t,relativePathToDependency:r}){let n=await e.generate({absoluteFilepathToProtobufRoot:t.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:t.absoluteFilepathToProtobufTarget,local:t.generateLocally});return{type:"openapi",absoluteFilepath:n,absoluteFilepathToOverrides:t.absoluteFilepathToOverrides,settings:t.settings,source:{type:"protobuf",relativePathToDependency:r,root:t.absoluteFilepathToProtobufRoot,file:t.absoluteFilepathToProtobufTarget}}}var ufu=yu(PZr(),1),jpf=yu(vRt(),1),wpf=require("fs"),m7n=require("fs/promises");var Dpf=require("os"),Spf=yu(require("path"),1),Epf=require("stream/promises"),Mpf=yu(f0a(),1),xpf=yu(Kte(),1);var Xw;(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"})(Xw||(Xw={}));var mb1=ZDr();async function Tpf({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:n,cliVersion:i,settings:a,loadAPIWorkspace:u}){let f,d={type:Xw.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},c=t.dependencies[e];return c==null?d={type:Xw.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${Eb1(c)}`},async o=>{switch(c.type){case"version":f=await Db1({context:o,dependency:c,cliVersion:i,settings:a,loadAPIWorkspace:u});return;case"local":f=await wb1({context:o,dependency:c,cliVersion:i,settings:a,loadAPIWorkspace:u});return;default:fl(c)}}),f!=null?{didSucceed:!0,definition:f}:{didSucceed:!1,failure:d}}var qpf="dependencies";var Ob1="metadata.json",Pb1=".fern";function jb1(e){return pf(R_.of((0,Dpf.homedir)()),zs.of(Pb1),zs.of(qpf),zs.of(e.organization),zs.of(e.apiName),zs.of(e.version))}async function wb1({dependency:e,context:t,cliVersion:r,settings:n,loadAPIWorkspace:i}){if(i==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await i({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!a.didSucceed){t.failWithoutThrowing("Failed to load api definition",a.failures);return}t.logger.info("Modifying source filepath ...");let u=await a.workspace.getDefinition({context:t,relativePathToDependency:zs.of(e.path)},n);return t.logger.info("Loaded..."),u}async function Db1({dependency:e,context:t,cliVersion:r,settings:n,loadAPIWorkspace:i}){let a=jb1(e),u=pf(a,zs.of(qpf)),f=pf(a,zs.of(Ob1)),d;if(!await Vh(u)||!await Vh(f)){t.logger.info("Downloading manifest...");let l=await mb1.definitionRegistry.get(ufu.FernFiddle.OrganizationId(e.organization),ufu.FernFiddle.ApiId(e.apiName),e.version);if(!l.ok){l.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:S=>{t.failWithoutThrowing("Failed to download API manifest",S)}});return}let g=l.body.yamlSchemaVersion!=null?parseInt(l.body.yamlSchemaVersion):void 0,O=fen(r),j=fen(l.body.cliVersion);if(g!=null){if(g>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${l.body.cliVersion}`);return}else if(g<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(O.major!==j.major||O.minor!==j.minor){t.failWithoutThrowing(`CLI version is ${l.body.cliVersion}. Expected ${O.major}.${O.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+l.body.definitionS3DownloadUrl),await(0,m7n.mkdir)(u,{recursive:!0});try{await Sb1({s3PreSignedReadUrl:l.body.definitionS3DownloadUrl,absolutePathToLocalOutput:u})}catch(S){t.failWithoutThrowing("Failed to download API",S);return}d=l.body,await(0,m7n.writeFile)(f,JSON.stringify(d))}else d=JSON.parse((await(0,m7n.readFile)(f)).toString());if(t.logger.info("Parsing..."),i==null){t.failWithoutThrowing("Failed to load API");return}let c=await i({absolutePathToWorkspace:u,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!c.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",c.failures);return}if(c.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await c.workspace.getDefinition({context:t},n)}async function Sb1({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await jpf.default.get(e,{responseType:"stream"}),n=await xpf.default.dir(),i=Spf.default.join(n.path,"api.tgz");await(0,Epf.pipeline)(r.data,(0,wpf.createWriteStream)(i)),await Mpf.default.extract({file:i,cwd:t})}function Eb1(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:fl(e)}}var Hpf=yu(lfu(),1);function d0a(e,t){for(let[r,n]of w4(e))xb1({relativeFilepath:r,failure:n,logger:t})}function xb1({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Xw.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 Xw.FILE_READ:r.error("Failed to open file: "+e);break;case Xw.FILE_MISSING:r.error("Missing file: "+e);break;case Xw.FILE_PARSE:t.error instanceof vsi?r.error(Bwr({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Xw.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of Tb1(n))r.error(Bwr({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case Xw.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Xw.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${BGi}: `+t.dependencyName);break;case Xw.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Xw.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;default:fl(t)}}function Tb1(e){switch(e.code){case Yp.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${al.underline(e.expected)} but received ${al.underline(e.received)}`}];case Yp.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${al.underline(t)}`}));case Yp.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>al.underline(t)).join(", ")}`}];case Yp.invalid_union:case Yp.invalid_arguments:case Yp.invalid_return_type:case Yp.invalid_date:case Yp.invalid_string:case Yp.too_small:case Yp.too_big:case Yp.invalid_intersection_types:case Yp.not_multiple_of:case Yp.custom:default:return[{title:e.message}]}}var Ipf=require("fs/promises");async function Rpf(e,t){let r=[];for(let n of await z8t(e,t))r.push(await qb1({relativeFilepath:D4(e,n),absoluteFilepath:n}));return r}async function qb1({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,Ipf.readFile)(t)).toString()}}async function Fpf(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:Xw.FILE_PARSE,error:a}}}return await Promise.all(e.map(n)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}async function Lpf({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:n,settings:i,loadAPIWorkspace:a}){let u={},f={},d={};return await Promise.all(w4(t.packageMarkers).map(async([c,o])=>{if(o.contents.export==null)u[c]=o;else{let{export:l,...g}=o.contents;if(A8t(g)>0)d[c]={type:Xw.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:c};else{let O=Cg(c);if(E8t(t.namedDefinitionFiles).some(S=>S!==c&&S.startsWith(O)))d[c]={type:Xw.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:O};else{let S=await Tpf({dependencyName:typeof o.contents.export=="string"?o.contents.export:o.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:n,settings:i,loadAPIWorkspace:a});S.didSucceed?f[Cg(c)]={definition:S.definition,url:typeof o.contents.export=="object"?o.contents.export.url:void 0}:d[c]=S.failure}}}})),A8t(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:u,importedDefinitions:f}}var Upf=yu(require("path"),1);function Vpf({files:e,absolutePathToDefinition:t}){let r,n={},i={},a={};for(let[u,f]of w4(e)){let d=f.contents,c=o=>{a[u]={type:Xw.STRUCTURE_VALIDATION,error:o}};if(u===iB){let o=ata.safeParse(d);o.success?r={defaultUrl:o.data["default-url"],contents:o.data,rawContents:f.rawContents}:c(o.error)}else if(Upf.default.basename(u)===$T){let o=eta.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=u2n.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(iB)]:{type:Xw.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:n,rootApiFile:r,packageMarkers:i}}var $Sr=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;type="api";constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:n,absoluteFilePath:i,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=n,this.absoluteFilePath=i,this.changelog=a}};var JSr=class extends $Sr{definition;sources;constructor({definition:t,sources:r,...n}){super(n),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};function g5r(e,t={}){return{...Object.fromEntries(w4(e.namedDefinitionFiles).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...w4(e.importedDefinitions).reduce((r,[n,i])=>({...r,...Hui(g5r(i.definition,{defaultURL:i.url}),(a,u)=>pf(n,zs.of(u)))}),{})}}function N_i(e,t={}){return{...Object.fromEntries(w4(e.packageMarkers).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...w4(e.importedDefinitions).reduce((r,[n,i])=>({...r,...Hui(N_i(i.definition,{defaultURL:i.url}),(a,u)=>pf(n,zs.of(u)))}),{})}}function GSr(e){return{...N_i(e),...g5r(e)}}function Dne(e,t){var r;return(r=GSr(e.definition)[t])==null?void 0:r.contents}var Wpf=yu(require("path"),1);async function q5(e,t){for(let[r,n]of w4(GSr(e.definition)))await t(r,n.contents,{isPackageMarker:Wpf.default.basename(r)===$T,defaultUrl:n.defaultUrl})}async function Ien(e,t){for(let[r,n]of w4(N_i(e.definition)))await t(r,n.contents)}var P7n=class extends $Sr{context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...n}){super(n),this.context=t,this.loadAPIWorkspace=r}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let n=(0,Hpf.default)(r??{}),i=this.fernWorkspaces[n];if(i==null){let a=t||this.context,u=pf(this.absoluteFilePath,zs.of(p9)),f=await bKi.loadDependenciesConfiguration({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await Rpf(u,"{yml,yaml}"),c=await Fpf(d);if(!c.didSucceed)return d0a(c.failures,a.logger),a.failAndThrow();let o=Vpf({files:c.files,absolutePathToDefinition:u});if(!o.didSucceed)return d0a(o.failures,a.logger),a.failAndThrow();let l=await Lpf({dependenciesConfiguration:f,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!l.didSucceed)return d0a(l.failures,a.logger),a.failAndThrow();i=new JSr({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},cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[n]=i}return i}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var KSr={openapi:e=>({...e,type:"openapi",_visit:function(t){return KSr._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return KSr._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 j7n={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return j7n._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 w7n={boolean:e=>({value:e,type:"boolean",_visit:function(t){return w7n._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return w7n._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 m5r={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return m5r._visit(this,t)}}),undisciminated:e=>({value:e,type:"undisciminated",_visit:function(t){return m5r._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 YSr={cursor:e=>({...e,type:"cursor",_visit:function(t){return YSr._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return YSr._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 XSr={language:e=>({...e,type:"language",_visit:function(t){return XSr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return XSr._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 O5r={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return O5r._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return O5r._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return O5r._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 Qw={int:e=>({...e,type:"int",_visit:function(t){return Qw._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Qw._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Qw._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Qw._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Qw._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Qw._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Qw._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Qw._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Qw._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Qw._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Qw._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 QSr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return QSr._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return QSr._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 q3={file:e=>({...e,type:"file",_visit:function(t){return q3._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return q3._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return q3._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return q3._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return q3._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return q3._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:()=>V7n,ArraySchema:()=>wva,ArraySchemaWithExample:()=>kva,Availability:()=>P0a,Base64WithExample:()=>Kva,BasicSecurityScheme:()=>D0a,BearerSecurityScheme:()=>S0a,BooleanSchema:()=>bva,BooleanWithExample:()=>Yva,CasingOverrides:()=>x0a,CommonProperty:()=>Cva,CommonPropertyWithExample:()=>sba,CursorPagination:()=>nva,CustomCodeSample:()=>tva,CustomCodeSampleLanguage:()=>Z0a,CustomCodeSampleSdk:()=>eva,DateWithExample:()=>Gva,DatetimeWithExample:()=>Jva,DiscriminatedOneOfSchema:()=>Tva,DiscriminatedOneOfSchemaWithExample:()=>oba,DoubleSchema:()=>yva,DoubleWithExample:()=>Hva,Encoding:()=>O0a,Endpoint:()=>ava,EndpointExample:()=>F7n,EndpointSdkName:()=>q5r,EndpointWithExample:()=>g_f,EnumSchema:()=>E7n,EnumSchemaWithExample:()=>Qva,EnumValue:()=>S5r,ErrorExample:()=>K0a,FernExample:()=>X0a,FileResponse:()=>z7n,FileSchema:()=>V0a,FloatWithExample:()=>Wva,FullEndpointExample:()=>rva,FullExample:()=>yA,FullObjectExample:()=>I0a,FullOneOfExample:()=>F0a,GlobalHeader:()=>mva,Header:()=>T5r,HeaderExample:()=>R7n,HeaderSecurityScheme:()=>E0a,HeaderWithExample:()=>$7n,HttpEndpointServer:()=>B7n,HttpError:()=>Y0a,HttpErrorWithExample:()=>Rva,HttpMethod:()=>T7n,IdempotencyHeader:()=>Ova,Int64WithExample:()=>Lva,IntSchema:()=>_va,IntWithExample:()=>Fva,JsonRequest:()=>$0a,JsonRequestWithExample:()=>Nva,JsonResponse:()=>ZSr,JsonResponseWithExample:()=>Bva,KeyValuePair:()=>R0a,LiteralExample:()=>B0a,LiteralSchema:()=>U7n,LiteralSchemaValue:()=>Pva,LongSchema:()=>hva,MapSchema:()=>Dva,MapSchemaWithExample:()=>eba,MultipartRequest:()=>N7n,MultipartRequestProperty:()=>H0a,MultipartSchema:()=>W0a,NamedFullExample:()=>IRt,Namespace:()=>T0a,NamespaceId:()=>z0a,NullableSchema:()=>Eva,NullableSchemaWithExample:()=>rba,OauthSecurityScheme:()=>C0a,ObjectProperty:()=>xva,ObjectPropertyConflictInfo:()=>W7n,ObjectPropertyWithExample:()=>aba,ObjectSchema:()=>jva,ObjectSchemaWithExample:()=>nba,OctetStreamRequest:()=>A7n,OffsetPagination:()=>iva,OneOfSchema:()=>Mva,OneOfSchemaWithExample:()=>iba,OpenApiIntermediateRepresentation:()=>v_f,OpenApiSource:()=>v0a,OptionalSchema:()=>Sva,OptionalSchemaWithExample:()=>tba,Pagination:()=>L7n,PathParameter:()=>q7n,PathParameterExample:()=>Q0a,PathParameterWithExample:()=>Ava,PrimitiveExample:()=>x7n,PrimitiveSchema:()=>A5r,PrimitiveSchemaValue:()=>gva,PrimitiveSchemaValueWithExample:()=>Xva,PrimitiveSchemaWithExample:()=>J7n,PropertyKey:()=>M7n,ProtobufEncoding:()=>m0a,ProtobufSource:()=>b0a,QueryParameter:()=>C7n,QueryParameterExample:()=>I7n,QueryParameterWithExample:()=>H7n,QuerySecurityScheme:()=>M0a,ReferencedSchema:()=>BRt,Request:()=>J0a,RequestWithExample:()=>zva,Response:()=>G0a,ResponseWithExample:()=>Iva,Schema:()=>D1,SchemaId:()=>wQ,SchemaWithExample:()=>oq,Schemas:()=>pva,SdkGroup:()=>q0a,SdkGroupInfo:()=>L0a,SdkGroupName:()=>E5r,SecurityScheme:()=>A0a,SecuritySchemeId:()=>w0a,Server:()=>N0a,Source:()=>g0a,StatusCode:()=>M5r,StringSchema:()=>vva,StringSchemaWithExample:()=>$va,SupportedSdkLanguage:()=>k0a,Tag:()=>j0a,TagId:()=>Yje,Tags:()=>U0a,TextResponse:()=>C5r,Uint64WithExample:()=>Vva,UintWithExample:()=>Uva,UnDiscriminatedOneOfSchema:()=>qva,UnDiscriminatedOneOfSchemaWithExample:()=>uba,UnknownSchemaWithExample:()=>Zva,Webhook:()=>sva,WebhookExampleCall:()=>uva,WebhookHttpMethod:()=>ova,WebsocketChannel:()=>dva,WebsocketHandshake:()=>cva,WebsocketHandshakeWithExample:()=>b_f,WebsocketMessageExample:()=>lva,WebsocketSessionExample:()=>fva,WithAvailability:()=>Z0,WithDescription:()=>P_,WithEncoding:()=>Ene,WithName:()=>Ym,WithNamespace:()=>x5r,WithSdkGroupName:()=>w1,WithSource:()=>hb,WithTitle:()=>j1,commons:()=>hfu,example:()=>yfu,finalIr:()=>vfu,parseIr:()=>bfu});var hfu={};Wb(hfu,{BasicSecurityScheme:()=>D0a,BearerSecurityScheme:()=>S0a,Encoding:()=>O0a,HeaderSecurityScheme:()=>E0a,Namespace:()=>T0a,NamespaceId:()=>z0a,OauthSecurityScheme:()=>C0a,OpenApiSource:()=>v0a,ProtobufEncoding:()=>m0a,ProtobufSource:()=>b0a,QuerySecurityScheme:()=>M0a,SchemaId:()=>wQ,SdkGroup:()=>q0a,SdkGroupName:()=>E5r,SecurityScheme:()=>A0a,SecuritySchemeId:()=>w0a,Server:()=>N0a,Source:()=>g0a,StatusCode:()=>M5r,Tag:()=>j0a,TagId:()=>Yje,WithAvailability:()=>Z0,WithDescription:()=>P_,WithEncoding:()=>Ene,WithName:()=>Ym,WithNamespace:()=>x5r,WithSdkGroupName:()=>w1,WithSource:()=>hb,WithTitle:()=>j1});var Wn={};Wb(Wn,{JsonError:()=>P5r,ParseError:()=>j5r,any:()=>i_f,boolean:()=>a_f,booleanLiteral:()=>n_f,date:()=>Jpf,discriminant:()=>__f,enum_:()=>_0a,getObjectLikeUtils:()=>zRt,getObjectUtils:()=>S7n,getSchemaUtils:()=>hA,isProperty:()=>D5r,lazy:()=>Gpf,lazyObject:()=>e_f,list:()=>y0a,number:()=>o_f,object:()=>h0a,objectWithoutOptionalProperties:()=>kpf,optional:()=>ffu,property:()=>Ypf,record:()=>l_f,set:()=>f_f,string:()=>u_f,stringLiteral:()=>r_f,transform:()=>dfu,undiscriminatedUnion:()=>p_f,union:()=>y_f,unknown:()=>s_f,withParsedProperties:()=>_fu});var WS={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 ${Cb1(e)}.`}function Cb1(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:$pf(e.json),parse:$pf(e.parse)}}function $pf(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(`
1916
- `)),{ok:!0,value:t}):n}}function p0a(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var P5r=class extends Error{errors;constructor(t){super(t.map(p0a).join("; ")),this.errors=t,Object.setPrototypeOf(this,P5r.prototype)}};var j5r=class extends Error{errors;constructor(t){super(t.map(p0a).join("; ")),this.errors=t,Object.setPrototypeOf(this,j5r.prototype)}};function hA(e){return{optional:()=>ffu(e),transform:t=>dfu(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new j5r(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new P5r(n.errors)}}}function ffu(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:()=>WS.OPTIONAL};return{...t,...hA(t)}}function dfu(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 Ab1=/^([+-]?\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 Jpf(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:rC(t,"string")}]}:Ab1.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:()=>WS.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 _0a(e){let t=new Set(e);return XJ(WS.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 Gpf(e){let t=pfu(e);return{...t,...hA(t)}}function pfu(e){return{parse:(t,r)=>D7n(e).parse(t,r),json:(t,r)=>D7n(e).json(t,r),getType:()=>D7n(e).getType()}}function D7n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function z_i(e){return Object.entries(e)}function B_i(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function w5r(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 I_i(e){return Object.keys(e)}function Kpf(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function zRt(e){return{withParsedProperties:t=>_fu(e,t)}}function _fu(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(!w5r(n))return{ok:!1,errors:[{path:(i==null?void 0:i.breadcrumbsPrefix)??[],message:rC(n,"object")}]};let a=new Set(Object.keys(t)),u=B_i(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...hA(r),...zRt(r)}}function Ypf(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function D5r(e){return e.isProperty}function h0a(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>D5r(n)?n.rawKey:r),_getParsedProperties:()=>I_i(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of z_i(e)){let d=D5r(f)?f.rawKey:u,c=D5r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,Zpf(c)&&a.push(d)}return Xpf({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 z_i(e)){let f=D5r(u)?u.valueSchema:u;Zpf(f)&&i.push(a)}return Xpf({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return D5r(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:()=>WS.OBJECT};return{...YJ(t),...hA(t),...zRt(t),...S7n(t)}}function Xpf({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!w5r(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 S7n(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>Qpf({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>Qpf({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>WS.OBJECT};return{...r,...hA(r),...zRt(r),...S7n(r)}}}}function Qpf({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=Kpf(I_i(t),c=>i.has(c)),f=r(B_i(t,u)),d=n(B_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 Zpf(e){return!Nb1(e)}function Nb1(e){switch(e.getType()){case WS.ANY:case WS.UNKNOWN:case WS.OPTIONAL:return!0;default:return!1}}function kpf(e){return h0a(e)}function e_f(e){let t={...pfu(e),_getRawProperties:()=>D7n(e)._getRawProperties(),_getParsedProperties:()=>D7n(e)._getParsedProperties()};return{...t,...hA(t),...zRt(t),...S7n(t)}}function y0a(e){let t={parse:(r,n)=>t_f(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],`[${a}]`]})),json:(r,n)=>t_f(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],`[${a}]`]})),getType:()=>WS.LIST};return{...YJ(t),...hA(t)}}function t_f(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 r_f(e){return XJ(WS.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:rC(r,`"${e}"`)}]})()}function n_f(e){return XJ(WS.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:rC(r,`${e.toString()}`)}]})()}var i_f=XJ(WS.ANY,e=>({ok:!0,value:e}));var a_f=XJ(WS.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"boolean")}]});var o_f=XJ(WS.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"number")}]});var u_f=XJ(WS.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"string")}]});var s_f=XJ(WS.UNKNOWN,e=>({ok:!0,value:e}));function l_f(e,t){let r={parse:(n,i)=>c_f({value:n,isKeyNumeric:e.getType()===WS.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)=>c_f({value:n,isKeyNumeric:e.getType()===WS.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:()=>WS.RECORD};return{...YJ(r),...hA(r)}}function c_f({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return w5r(e)?z_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 f_f(e){let t=y0a(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:()=>WS.SET};return{...YJ(r),...hA(r)}}function p_f(e){let t={parse:(r,n)=>d_f((i,a)=>i.parse(r,a),e,n),json:(r,n)=>d_f((i,a)=>i.json(r,a),e,n),getType:()=>WS.UNDISCRIMINATED_UNION};return{...YJ(t),...hA(t)}}function d_f(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 __f(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function y_f(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=_0a(I_i(t)),a={parse:(u,f)=>h_f({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)=>h_f({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:()=>WS.UNION};return{...YJ(a),...hA(a),...zRt(a)}}function h_f({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!w5r(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 v0a=Wn.objectWithoutOptionalProperties({file:Wn.string()});var b0a=Wn.objectWithoutOptionalProperties({file:Wn.string()});var g0a=Wn.union("type",{openapi:v0a,protobuf:b0a}).transform({transform:e=>{switch(e.type){case"openapi":return KSr.openapi(e);case"protobuf":return KSr.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var hb=Wn.objectWithoutOptionalProperties({source:g0a.optional()});var m0a=Wn.objectWithoutOptionalProperties({typeName:Wn.string()});var O0a=Wn.union("type",{protobuf:m0a}).transform({transform:e=>{switch(e.type){case"protobuf":return j7n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ene=Wn.objectWithoutOptionalProperties({encoding:O0a.optional()});var P_=Wn.objectWithoutOptionalProperties({description:Wn.string().optional()});var P0a=Wn.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Z0=Wn.objectWithoutOptionalProperties({availability:P0a.optional()});var Ym=Wn.objectWithoutOptionalProperties({nameOverride:Wn.string().optional(),generatedName:Wn.string()});var wQ=Wn.string();var Yje=Wn.string();var j0a=Wn.objectWithoutOptionalProperties({id:Yje}).extend(P_);var w0a=Wn.string();var D0a=Wn.objectWithoutOptionalProperties({usernameVariableName:Wn.string().optional(),usernameEnvVar:Wn.string().optional(),passwordVariableName:Wn.string().optional(),passwordEnvVar:Wn.string().optional()});var S0a=Wn.objectWithoutOptionalProperties({tokenVariableName:Wn.string().optional(),tokenEnvVar:Wn.string().optional()});var E0a=Wn.objectWithoutOptionalProperties({headerName:Wn.string(),prefix:Wn.string().optional(),headerVariableName:Wn.string().optional(),headerEnvVar:Wn.string().optional()});var M0a=Wn.objectWithoutOptionalProperties({queryParameterName:Wn.string()});var x0a=Wn.objectWithoutOptionalProperties({snake:Wn.string().optional(),camel:Wn.string().optional(),screamingSnake:Wn.string().optional(),pascal:Wn.string().optional()});var S5r=Wn.objectWithoutOptionalProperties({nameOverride:Wn.string().optional(),generatedName:Wn.string(),value:Wn.string(),casing:x0a.optional()}).extend(P_).extend(Z0);var T0a=Wn.objectWithoutOptionalProperties({type:Wn.stringLiteral("namespace"),name:Wn.string()});var q0a=Wn.undiscriminatedUnion([Wn.string(),T0a]);var E5r=Wn.list(q0a);var w1=Wn.objectWithoutOptionalProperties({groupName:E5r.optional()});var E7n=Wn.objectWithoutOptionalProperties({default:S5r.optional(),values:Wn.list(S5r)}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var C0a=Wn.objectWithoutOptionalProperties({scopesEnum:E7n.optional()});var A0a=Wn.union("type",{basic:D0a,bearer:S0a,header:E0a,query:M0a,oauth:C0a}).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 M5r=Wn.number();var N0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),url:Wn.string(),audiences:Wn.list(Wn.string()).optional()}).extend(P_);var z0a=Wn.string();var x5r=Wn.objectWithoutOptionalProperties({namespace:Wn.string().optional()});var yfu={};Wb(yfu,{FullExample:()=>yA,FullObjectExample:()=>I0a,FullOneOfExample:()=>F0a,KeyValuePair:()=>R0a,LiteralExample:()=>B0a,PrimitiveExample:()=>x7n,PropertyKey:()=>M7n});var M7n=Wn.string();var x7n=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 B0a=Wn.union("type",{boolean:Wn.object({value:Wn.boolean()}),string:Wn.object({value:Wn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return w7n.boolean(e.value);case"string":return w7n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var yA=Wn.union("type",{primitive:Wn.object({value:x7n}),object:Wn.lazyObject(()=>I0a),array:Wn.object({value:Wn.list(Wn.lazy(()=>yA))}),map:Wn.object({value:Wn.list(Wn.lazyObject(()=>R0a))}),enum:Wn.object({value:Wn.string()}),literal:Wn.object({value:B0a}),oneOf:Wn.object({value:Wn.lazy(()=>F0a)}),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 I0a=Wn.objectWithoutOptionalProperties({properties:Wn.record(M7n,Wn.lazy(()=>yA))});var R0a=Wn.objectWithoutOptionalProperties({key:x7n,value:Wn.lazy(()=>yA)});var F0a=Wn.union("type",{discriminated:Wn.object({value:Wn.record(M7n,Wn.lazy(()=>yA))}),undisciminated:Wn.object({value:Wn.lazy(()=>yA)})}).transform({transform:e=>{switch(e.type){case"discriminated":return m5r.discriminated(e.value);case"undisciminated":return m5r.undisciminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var vfu={};Wb(vfu,{AllOfPropertyConflict:()=>V7n,ArraySchema:()=>wva,Availability:()=>P0a,BooleanSchema:()=>bva,CasingOverrides:()=>x0a,CommonProperty:()=>Cva,CursorPagination:()=>nva,CustomCodeSample:()=>tva,CustomCodeSampleLanguage:()=>Z0a,CustomCodeSampleSdk:()=>eva,DiscriminatedOneOfSchema:()=>Tva,DoubleSchema:()=>yva,Endpoint:()=>ava,EndpointExample:()=>F7n,EndpointSdkName:()=>q5r,EnumSchema:()=>E7n,EnumValue:()=>S5r,ErrorExample:()=>K0a,FernExample:()=>X0a,FileResponse:()=>z7n,FileSchema:()=>V0a,FullEndpointExample:()=>rva,GlobalHeader:()=>mva,Header:()=>T5r,HeaderExample:()=>R7n,HttpEndpointServer:()=>B7n,HttpError:()=>Y0a,HttpMethod:()=>T7n,IdempotencyHeader:()=>Ova,IntSchema:()=>_va,JsonRequest:()=>$0a,JsonResponse:()=>ZSr,LiteralSchema:()=>U7n,LiteralSchemaValue:()=>Pva,LongSchema:()=>hva,MapSchema:()=>Dva,MultipartRequest:()=>N7n,MultipartRequestProperty:()=>H0a,MultipartSchema:()=>W0a,NullableSchema:()=>Eva,ObjectProperty:()=>xva,ObjectPropertyConflictInfo:()=>W7n,ObjectSchema:()=>jva,OctetStreamRequest:()=>A7n,OffsetPagination:()=>iva,OneOfSchema:()=>Mva,OpenApiIntermediateRepresentation:()=>v_f,OptionalSchema:()=>Sva,Pagination:()=>L7n,PathParameter:()=>q7n,PathParameterExample:()=>Q0a,PrimitiveSchema:()=>A5r,PrimitiveSchemaValue:()=>gva,QueryParameter:()=>C7n,QueryParameterExample:()=>I7n,ReferencedSchema:()=>BRt,Request:()=>J0a,Response:()=>G0a,Schema:()=>D1,Schemas:()=>pva,SdkGroupInfo:()=>L0a,StringSchema:()=>vva,SupportedSdkLanguage:()=>k0a,Tags:()=>U0a,TextResponse:()=>C5r,UnDiscriminatedOneOfSchema:()=>qva,Webhook:()=>sva,WebhookExampleCall:()=>uva,WebhookHttpMethod:()=>ova,WebsocketChannel:()=>dva,WebsocketHandshake:()=>cva,WebsocketMessageExample:()=>lva,WebsocketSessionExample:()=>fva});var L0a=Wn.objectWithoutOptionalProperties({summary:Wn.string().optional(),description:Wn.string().optional()});var U0a=Wn.objectWithoutOptionalProperties({tagsById:Wn.record(Yje,j0a),orderedTagIds:Wn.list(Yje).optional()});var T7n=Wn.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var q7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),variableReference:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(P_).extend(Z0).extend(hb);var C7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),parameterNameOverride:Wn.string().optional()}).extend(P_).extend(Z0).extend(hb);var T5r=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),env:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(P_).extend(Z0).extend(hb);var q5r=Wn.objectWithoutOptionalProperties({groupName:E5r,methodName:Wn.string()});var A7n=Wn.objectWithoutOptionalProperties({}).extend(P_).extend(hb);var V0a=Wn.objectWithoutOptionalProperties({isOptional:Wn.boolean(),isArray:Wn.boolean()});var W0a=Wn.union("type",{file:V0a,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 H0a=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:W0a,contentType:Wn.string().optional()}).extend(P_);var N7n=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),properties:Wn.list(H0a)}).extend(P_).extend(hb);var $0a=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1),contentType:Wn.string().optional(),additionalProperties:Wn.boolean()}).extend(P_).extend(hb);var J0a=Wn.union("type",{octetStream:A7n,multipart:N7n,json:$0a}).transform({transform:e=>{switch(e.type){case"octetStream":return O5r.octetStream(e);case"multipart":return O5r.multipart(e);case"json":return O5r.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var z7n=Wn.objectWithoutOptionalProperties({}).extend(P_).extend(hb);var ZSr=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1),responseProperty:Wn.string().optional()}).extend(P_).extend(hb);var C5r=Wn.objectWithoutOptionalProperties({}).extend(P_).extend(hb);var G0a=Wn.union("type",{file:z7n,json:ZSr,text:C5r,streamingSse:ZSr,streamingText:C5r,streamingJson:ZSr}).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 K0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),description:Wn.string().optional(),example:Wn.lazy(()=>yA)});var Y0a=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1).optional(),examples:Wn.list(K0a).optional()}).extend(P_).extend(Ym).extend(hb);var B7n=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),url:Wn.string().optional(),audiences:Wn.list(Wn.string()).optional()});var X0a=Wn.unknown();var Q0a=Wn.objectWithoutOptionalProperties({name:Wn.string(),parameterNameOverride:Wn.string().optional(),value:Wn.lazy(()=>yA)});var I7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),value:Wn.lazy(()=>yA)});var R7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),value:Wn.lazy(()=>yA)});var Z0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),language:Wn.string(),code:Wn.string(),install:Wn.string().optional()}).extend(P_);var k0a=Wn.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var eva=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),sdk:k0a,code:Wn.string()}).extend(P_);var tva=Wn.union("type",{language:Z0a,sdk:eva}).transform({transform:e=>{switch(e.type){case"language":return XSr.language(e);case"sdk":return XSr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var rva=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),pathParameters:Wn.list(Q0a).optional(),queryParameters:Wn.list(I7n).optional(),headers:Wn.list(R7n).optional(),request:Wn.lazy(()=>yA).optional(),response:Wn.lazy(()=>yA).optional(),codeSamples:Wn.list(tva)}).extend(P_);var F7n=Wn.union("type",{unknown:Wn.object({value:X0a}),full:rva}).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 nva=Wn.objectWithoutOptionalProperties({cursor:Wn.string(),nextCursor:Wn.property("next_cursor",Wn.string()),results:Wn.string()});var iva=Wn.objectWithoutOptionalProperties({offset:Wn.string(),results:Wn.string(),step:Wn.string().optional(),hasNextPage:Wn.string().optional()});var L7n=Wn.union("type",{cursor:nva,offset:iva}).transform({transform:e=>{switch(e.type){case"cursor":return YSr.cursor(e);case"offset":return YSr.offset(e);default:return e}},untransform:({_visit:e,...t})=>t});var ava=Wn.objectWithoutOptionalProperties({authed:Wn.boolean(),internal:Wn.boolean().optional(),idempotent:Wn.boolean().optional(),method:T7n,audiences:Wn.list(Wn.string()),path:Wn.string(),summary:Wn.string().optional(),operationId:Wn.string().optional(),tags:Wn.list(Yje),pathParameters:Wn.list(q7n),queryParameters:Wn.list(C7n),headers:Wn.list(T5r),sdkName:q5r.optional(),generatedRequestName:Wn.string(),requestNameOverride:Wn.string().optional(),request:J0a.optional(),response:G0a.optional(),errors:Wn.record(M5r,Y0a),server:Wn.list(B7n),examples:Wn.list(F7n),pagination:L7n.optional()}).extend(P_).extend(Z0).extend(hb).extend(x5r);var ova=Wn.enum_(["GET","POST"]);var uva=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),payload:Wn.lazy(()=>yA)}).extend(P_);var sva=Wn.objectWithoutOptionalProperties({sdkName:q5r.optional(),method:ova,summary:Wn.string().optional(),operationId:Wn.string(),tags:Wn.list(Yje),headers:Wn.list(T5r),generatedPayloadName:Wn.string(),payload:Wn.lazy(()=>D1),examples:Wn.list(uva)}).extend(P_).extend(hb).extend(x5r);var cva=Wn.objectWithoutOptionalProperties({queryParameters:Wn.list(C7n),headers:Wn.list(T5r),pathParameters:Wn.list(q7n)});var lva=Wn.objectWithoutOptionalProperties({messageType:Wn.string(),payload:Wn.lazy(()=>yA)}).extend(P_);var fva=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),queryParameters:Wn.list(I7n).optional(),headers:Wn.list(R7n).optional(),messages:Wn.list(lva)}).extend(P_);var dva=Wn.objectWithoutOptionalProperties({path:Wn.string(),groupName:E5r,summary:Wn.string().optional(),handshake:cva,publish:Wn.lazy(()=>D1).optional(),subscribe:Wn.lazy(()=>D1).optional(),examples:Wn.list(fva)}).extend(P_).extend(hb);var pva=Wn.objectWithoutOptionalProperties({rootSchemas:Wn.record(wQ,Wn.lazy(()=>D1)),namespacedSchemas:Wn.record(z0a,Wn.record(wQ,Wn.lazy(()=>D1)))});var _va=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 hva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional()});var yva=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 vva=Wn.objectWithoutOptionalProperties({default:Wn.string().optional(),pattern:Wn.string().optional(),format:Wn.string().optional(),minLength:Wn.number().optional(),maxLength:Wn.number().optional()});var bva=Wn.objectWithoutOptionalProperties({default:Wn.boolean().optional()});var gva=Wn.union("type",{int:_va,int64:hva,uint:Wn.object({}),uint64:Wn.object({}),float:Wn.object({}),double:yva,string:vva,datetime:Wn.object({}),date:Wn.object({}),base64:Wn.object({}),boolean:bva}).transform({transform:e=>{switch(e.type){case"int":return Qw.int(e);case"int64":return Qw.int64(e);case"uint":return Qw.uint();case"uint64":return Qw.uint64();case"float":return Qw.float();case"double":return Qw.double(e);case"string":return Qw.string(e);case"datetime":return Qw.datetime();case"date":return Qw.date();case"base64":return Qw.base64();case"boolean":return Qw.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var A5r=Wn.objectWithoutOptionalProperties({schema:gva}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(j1);var mva=Wn.objectWithoutOptionalProperties({header:Wn.string(),name:Wn.string().optional(),optional:Wn.boolean().optional(),env:Wn.string().optional(),schema:Wn.lazy(()=>D1).optional()});var Ova=Wn.objectWithoutOptionalProperties({header:Wn.string(),name:Wn.string().optional(),env:Wn.string().optional(),schema:Wn.lazy(()=>D1).optional()});var v_f=Wn.objectWithoutOptionalProperties({apiVersion:Wn.unknown().optional(),title:Wn.string().optional(),description:Wn.string().optional(),basePath:Wn.string().optional(),servers:Wn.list(N0a),groups:Wn.record(Wn.string(),L0a),tags:U0a,hasEndpointsMarkedInternal:Wn.boolean(),endpoints:Wn.list(ava),webhooks:Wn.list(sva),channel:Wn.list(dva),groupedSchemas:pva,variables:Wn.record(Wn.string(),A5r),nonRequestReferencedSchemas:Wn.set(wQ),securitySchemes:Wn.record(w0a,A0a),globalHeaders:Wn.list(mva).optional(),idempotencyHeaders:Wn.list(Ova).optional()});var BRt=Wn.objectWithoutOptionalProperties({schema:wQ}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var Pva=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 U7n=Wn.objectWithoutOptionalProperties({value:Pva}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(j1);var D1=Wn.union("type",{primitive:A5r,object:Wn.lazyObject(()=>jva),array:Wn.lazyObject(()=>wva),map:Wn.lazyObject(()=>Dva),optional:Wn.lazyObject(()=>Sva),enum:E7n,reference:BRt,literal:U7n,oneOf:Wn.object({value:Wn.lazy(()=>Mva)}),nullable:Wn.lazyObject(()=>Eva),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 V7n=Wn.objectWithoutOptionalProperties({propertyKey:Wn.string(),allOfSchemaIds:Wn.list(wQ),conflictingTypeSignatures:Wn.boolean()});var jva=Wn.objectWithoutOptionalProperties({allOf:Wn.list(BRt),properties:Wn.list(Wn.lazyObject(()=>xva)),allOfPropertyConflicts:Wn.list(V7n),additionalProperties:Wn.boolean()}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var W7n=Wn.objectWithoutOptionalProperties({differentSchema:Wn.boolean()});var xva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>D1),conflict:Wn.record(wQ,W7n),generatedName:Wn.string(),nameOverride:Wn.string().optional(),audiences:Wn.list(Wn.string())}).extend(Z0);var wva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(j1);var Dva=Wn.objectWithoutOptionalProperties({key:A5r,value:Wn.lazy(()=>D1)}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(j1);var Sva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(j1);var Eva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(j1);var Mva=Wn.union("type",{discriminated:Wn.lazyObject(()=>Tva),undisciminated:Wn.lazyObject(()=>qva)}).transform({transform:e=>{switch(e.type){case"discriminated":return QSr.discriminated(e);case"undisciminated":return QSr.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Tva=Wn.objectWithoutOptionalProperties({discriminantProperty:Wn.string(),commonProperties:Wn.list(Wn.lazyObject(()=>Cva)),schemas:Wn.record(Wn.string(),Wn.lazy(()=>D1))}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var Cva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>D1)});var qva=Wn.objectWithoutOptionalProperties({schemas:Wn.list(Wn.lazy(()=>D1))}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var bfu={};Wb(bfu,{ArraySchemaWithExample:()=>kva,Base64WithExample:()=>Kva,BooleanWithExample:()=>Yva,CommonPropertyWithExample:()=>sba,DateWithExample:()=>Gva,DatetimeWithExample:()=>Jva,DiscriminatedOneOfSchemaWithExample:()=>oba,DoubleWithExample:()=>Hva,EndpointWithExample:()=>g_f,EnumSchemaWithExample:()=>Qva,FloatWithExample:()=>Wva,HeaderWithExample:()=>$7n,HttpErrorWithExample:()=>Rva,Int64WithExample:()=>Lva,IntWithExample:()=>Fva,JsonRequestWithExample:()=>Nva,JsonResponseWithExample:()=>Bva,MapSchemaWithExample:()=>eba,NamedFullExample:()=>IRt,NullableSchemaWithExample:()=>rba,ObjectPropertyWithExample:()=>aba,ObjectSchemaWithExample:()=>nba,OneOfSchemaWithExample:()=>iba,OptionalSchemaWithExample:()=>tba,PathParameterWithExample:()=>Ava,PrimitiveSchemaValueWithExample:()=>Xva,PrimitiveSchemaWithExample:()=>J7n,QueryParameterWithExample:()=>H7n,RequestWithExample:()=>zva,ResponseWithExample:()=>Iva,SchemaWithExample:()=>oq,StringSchemaWithExample:()=>$va,Uint64WithExample:()=>Vva,UintWithExample:()=>Uva,UnDiscriminatedOneOfSchemaWithExample:()=>uba,UnknownSchemaWithExample:()=>Zva,WebsocketHandshakeWithExample:()=>b_f});var IRt=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),value:Wn.unknown()}).extend(P_);var H7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>oq),parameterNameOverride:Wn.string().optional()}).extend(P_).extend(Z0).extend(hb);var $7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>oq),env:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(P_).extend(Z0).extend(hb);var b_f=Wn.objectWithoutOptionalProperties({queryParameters:Wn.list(H7n),headers:Wn.list($7n)});var Ava=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>oq),variableReference:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(P_).extend(Z0).extend(hb);var Nva=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>oq),contentType:Wn.string().optional(),fullExamples:Wn.list(IRt).optional(),additionalProperties:Wn.boolean()}).extend(P_).extend(hb);var zva=Wn.union("type",{octetStream:A7n,multipart:N7n,json:Nva}).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 Bva=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>oq),responseProperty:Wn.string().optional(),fullExamples:Wn.list(IRt).optional()}).extend(P_).extend(hb);var Iva=Wn.union("type",{file:z7n,json:Bva,text:C5r,streamingSse:ZSr,streamingText:C5r,streamingJson:ZSr}).transform({transform:e=>{switch(e.type){case"file":return q3.file(e);case"json":return q3.json(e);case"text":return q3.text(e);case"streamingSse":return q3.streamingSse(e);case"streamingText":return q3.streamingText(e);case"streamingJson":return q3.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Rva=Wn.objectWithoutOptionalProperties({statusCode:M5r,schema:Wn.lazy(()=>oq),fullExamples:Wn.list(IRt).optional()}).extend(P_).extend(Ym).extend(hb);var g_f=Wn.objectWithoutOptionalProperties({authed:Wn.boolean(),internal:Wn.boolean().optional(),idempotent:Wn.boolean().optional(),method:T7n,audiences:Wn.list(Wn.string()),path:Wn.string(),summary:Wn.string().optional(),operationId:Wn.string().optional(),tags:Wn.list(Yje),pathParameters:Wn.list(Ava),queryParameters:Wn.list(H7n),headers:Wn.list($7n),sdkName:q5r.optional(),generatedRequestName:Wn.string(),requestNameOverride:Wn.string().optional(),request:zva.optional(),response:Iva.optional(),errors:Wn.record(M5r,Rva),server:Wn.list(B7n),examples:Wn.list(F7n),pagination:L7n.optional()}).extend(P_).extend(Z0).extend(hb).extend(x5r);var Fva=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 Lva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var Uva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var Vva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var Wva=Wn.objectWithoutOptionalProperties({example:Wn.number().optional()});var Hva=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 $va=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 Jva=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var Gva=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var Kva=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var Yva=Wn.objectWithoutOptionalProperties({default:Wn.boolean().optional(),example:Wn.boolean().optional()});var Xva=Wn.union("type",{int:Fva,int64:Lva,uint:Uva,uint64:Vva,float:Wva,double:Hva,string:$va,datetime:Jva,date:Gva,base64:Kva,boolean:Yva}).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 J7n=Wn.objectWithoutOptionalProperties({schema:Xva}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(j1);var Qva=Wn.objectWithoutOptionalProperties({default:S5r.optional(),values:Wn.list(S5r),example:Wn.string().optional()}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var Zva=Wn.objectWithoutOptionalProperties({example:Wn.unknown()}).extend(w1).extend(Ym).extend(P_).extend(Z0).extend(j1);var oq=Wn.union("type",{primitive:J7n,object:Wn.lazyObject(()=>nba),array:Wn.lazyObject(()=>kva),map:Wn.lazyObject(()=>eba),optional:Wn.lazyObject(()=>tba),enum:Qva,reference:BRt,literal:U7n,oneOf:Wn.object({value:Wn.lazy(()=>iba)}),nullable:Wn.lazyObject(()=>rba),unknown:Zva}).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 kva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>oq),example:Wn.list(Wn.unknown()).optional()}).extend(w1).extend(Ym).extend(P_).extend(Z0).extend(j1);var eba=Wn.objectWithoutOptionalProperties({key:J7n,value:Wn.lazy(()=>oq),example:Wn.unknown().optional()}).extend(w1).extend(Ym).extend(P_).extend(Z0).extend(Ene).extend(j1);var tba=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>oq)}).extend(w1).extend(Ym).extend(P_).extend(Z0).extend(j1);var rba=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>oq)}).extend(w1).extend(Ym).extend(P_).extend(Z0).extend(j1);var nba=Wn.objectWithoutOptionalProperties({allOf:Wn.list(BRt),properties:Wn.list(Wn.lazyObject(()=>aba)),allOfPropertyConflicts:Wn.list(V7n),fullExamples:Wn.list(IRt).optional(),additionalProperties:Wn.boolean()}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var aba=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>oq),audiences:Wn.list(Wn.string()),conflict:Wn.record(wQ,W7n),nameOverride:Wn.string().optional(),generatedName:Wn.string()}).extend(Z0);var iba=Wn.union("type",{discriminated:Wn.lazyObject(()=>oba),undisciminated:Wn.lazyObject(()=>uba)}).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 oba=Wn.objectWithoutOptionalProperties({discriminantProperty:Wn.string(),commonProperties:Wn.list(Wn.lazyObject(()=>sba)),schemas:Wn.record(Wn.string(),Wn.lazy(()=>oq))}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var sba=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>oq)});var uba=Wn.objectWithoutOptionalProperties({schemas:Wn.list(Wn.lazy(()=>oq))}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);function cba(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:fl(e.type)}}function G7n(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:fl(e)}}function N2(e){return typeof e=="string"?e:e.type}function R_i(e){if(typeof e!="string")return e.docs}function m_f(e){if(typeof e!="string")return e.default}function O_f(e){if(typeof e!="string")return e.validation}function zb1(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 P_f(e){let t=e?zb1(e):void 0;if(t==null||t.length===0)return Jui;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,Jui);break}default:fl(i.type)}else fl(i);return r.join("/")}function K7n(e){return zs.of(`${P_f(e)}.yml`)}function gfu({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Jui:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,P_f(r))}function j_f({sdkName:e,namespaceOverride:t}){return zs.of(`${gfu({sdkName:e,namespaceOverride:t})}.yml`)}function w_f({location:e,namespaceOverride:t}){return t!=null?pf(zs.of(t),e):e}function C3(e){switch(e){case vW.Deprecated:return"deprecated";case vW.Beta:return"pre-release";case vW.GenerallyAvailable:return"generally-available";default:return}}var Bb1=-2147483648,Ib1=2147483647,Rb1=-17976931348623157e292,Fb1=17976931348623157e292;function S1({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i}){switch(e.type){case"primitive":return lba(e);case"array":return Pfu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"map":return jfu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"reference":return Ofu({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return Dfu();case"optional":case"nullable":return wfu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"enum":return Kb1({schema:e,fileContainingReference:t,context:n,declarationFile:r});case"literal":return e.value,Sfu(e);case"object":return Yb1({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"oneOf":return Xb1({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i});default:fl(e)}}function lba(e){switch(e.schema.type){case"string":return Vb1({description:e.description,schema:e.schema});case"int":return Wb1({description:e.description,schema:e.schema});case"float":return Hb1({description:e.description,schema:e.schema});case"double":return $b1({description:e.description,schema:e.schema});case"boolean":return Lb1({description:e.description,schema:e.schema});case"int64":return Ub1({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:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:C3(e.availability)}:{}}}function Lb1({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 Ub1({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 Vb1({description:e,schema:t}){let r="string",n=Jb1(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 Wb1({description:e,schema:t}){let r="integer",n=D_f(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 Hb1({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function $b1({description:e,schema:t}){let r="double",n=D_f(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 Jb1(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=Gb1(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function Gb1(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 D_f(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=mfu(r,t),n=mfu(n,t),i=mfu(i,t),!(r==null&&n==null&&a==null&&u==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:u,multipleOf:i}}function mfu(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[Bb1,Ib1]:[Rb1,Fb1];return e<r||e>n?void 0:e}function Ofu({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=Qb1(i)??e.schema,u=G7n(i),f=Zb1(i),d=fba({context:r,fileContainingReference:t,declarationFile:K7n(u),type:a}),c=i.type==="nullable"?`optional<${d}>`:d;return e.description==null&&f==null?c:{type:i.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:C3(e.availability)}:{}}}function Pfu({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<${N2(a)}>`;return e.description==null&&e.title==null?u:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:C3(e.availability)}:{},type:u}}function jfu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=lba(e.key),u=S1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),f=e.encoding!=null?cba(e.encoding):void 0,d=`map<${N2(a)}, ${N2(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.availability!=null&&(c.availability=C3(e.availability)),c}function wfu({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=N2(a),f=R_i(a),d=m_f(a),c=O_f(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.availability!=null&&(l.availability=C3(e.availability)),l}function Dfu(){return"unknown"}function Sfu(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:fl(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:C3(e.availability)}:{}}}function Kb1({schema:e,fileContainingReference:t,declarationFile:r,context:n}){let i=F_i(e),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:i.schema});let u=fba({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.availability!=null&&(f.availability=C3(e.availability)),f}function Yb1({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Efu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=fba({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:C3(e.availability)}:{}}}function Xb1({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Mfu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=fba({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:C3(e.availability)}:{}}}function fba({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 Qb1(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 Zb1(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 Ren(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:fl(e)}}function E_f({schema:e,context:t,declarationFile:r,namespace:n}){switch(e.type){case"primitive":return tg1(e);case"array":return kb1({schema:e,context:t,declarationFile:r,namespace:n});case"map":return eg1({schema:e,context:t,declarationFile:r,namespace:n});case"reference":return rg1({schema:e,context:t,declarationFile:r,namespace:n});case"unknown":return ig1(e.nameOverride,e.generatedName);case"optional":case"nullable":return ng1({schema:e,context:t,declarationFile:r,namespace:n});case"enum":return F_i(e);case"literal":return ag1(e,e.nameOverride,e.generatedName);case"object":return Efu({schema:e,context:t,declarationFile:r,namespace:n});case"oneOf":return Mfu({schema:e.value,context:t,declarationFile:r,namespace:n});default:fl(e)}}function Efu({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])=>{xfu({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=C3(c.availability);i[c.key]=sg1(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=M_f({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(N2(l))}for(let c of a){let o=Tfu(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(N2(g))}}let d={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(i).map(([c,o])=>ug1(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=C3(e.availability)),e.source!=null&&(d.source=Ren(e.source)),{name:e.nameOverride??e.generatedName,schema:d}}function xfu({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return xfu({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:u}=Tfu(r,t,n),f=a.some(c=>c.key===e),d=[...u.flatMap(c=>xfu({property:e,context:r,schemaId:c.schema,namespace:n}))];if(f||d.length>0)return[t,...d]}return[]}function Tfu(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 Tfu(e,n.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${n.type}`)}function kb1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Pfu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function eg1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:jfu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function tg1(e){let t=lba(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 S_f(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function F_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||S_f(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&&!S_f(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?Ren(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 rg1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Ofu({schema:e,context:t,fileContainingReference:r,namespace:n})}}function ng1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:wfu({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n})}}function ig1(e,t){return{name:e??t,schema:Dfu()}}function ag1(e,t,r){return{name:t??r,schema:Sfu(e)}}function Mfu({schema:e,context:t,declarationFile:r,namespace:n}){let i=e.encoding!=null?cba(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?C3(e.availability):void 0,union:f,encoding:i,source:e.source!=null?Ren(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?Ren(e.source):void 0}}}var og1=/^[0-9]/;function ug1(e){return og1.test(e)}function M_f({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?M_f({context:t,schema:n.schema,namespace:r}):e}function sg1(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 x_f(e){let t=e.replace(/^x-|^X-/,"");return FE(t)}var T_f="BasicAuthScheme",dba="BearerAuthScheme";function q_f(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:T_f,schema:i}),t||(e.builder.setAuth(T_f),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:dba,schema:i}),t||(e.builder.setAuth(dba),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??x_f(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:dba,schema:i}),t||(e.builder.setAuth(dba),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(zs.of("__package__.yml"),{name:"OauthScope",schema:F_i(n.scopesEnum).schema})}}function RRt({header:e,context:t,fileContainingReference:r,namespace:n}){let i=S1({schema:e.schema,context:t,fileContainingReference:r,namespace:n}),a=N2(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=C3(e.availability)),d}function pba({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 N2(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:N2(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=C3(e.availability)),a}var vOu=require("fs/promises");var C_f={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 FRt(e,t,r,n,i=[]){try{let a=Lh(e,t);if(a!=null)return r.parse(a)}catch{let u=C8t(i).join(" -> ");n.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}var _ba={of(e){return e}};var kh={SDK_METHOD_NAME:_ba.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:_ba.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:_ba.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 Xje={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 A_f({schema:e,logger:t}){return FRt(e,kh.ENCODING,t8.EncodingSchema,t)??void 0}function N_f(e){return Lh(e,kh.FERN_ENUM)}function z_f({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 L_i({fernType:f,nameOverride:e,generatedName:t,title:r,description:i,availability:a,groupName:typeof u=="string"?[u]:u})}function L_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:fl(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 Fen(e){if(e!=null&&typeof e=="boolean")return e}function B_f({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"||Y7n(i)?hba({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}):hba({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 hba({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 Y7n(e){return e==null?!1:typeof e=="boolean"?e:!gy(e)&&Object.keys(e).length===0}function I_f({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 cg1({nameOverride:e,generatedName:t,title:r,groupName:c,itemSchema:O,wrapAsNullable:f,description:a,availability:u,example:o})}function cg1({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 qfu({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=X7n({$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 R_f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:A,description:a,availability:u,discriminant:S,subtypes:x,groupName:l,source:O})}function Cfu({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=X7n(N,!1,l,[N.$ref],O,j,S);return l.markReferencedByDiscriminatedUnion(N,c,1),[z,C]}else{let C=N5r(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 R_f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:A,description:a,availability:u,discriminant:c,subtypes:x,groupName:g,source:j})}function R_f({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 F_f(e){if(e.proto!=null)return j7n.protobuf({typeName:e.proto.type})}var lg1=/^(\d+)/;function yba(e){let t=e.match(lg1);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=Q7n(i);return n.length>0?`${a}_${n}`:a}}}function Q7n(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_${Q7n(f)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${Q7n(a)}`}var Z7n=/^[a-zA-Z][a-zA-Z0-9_]*$/;function z5r({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=pg1(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=Z7n.test(A),Y=(N==null?void 0:N.name)??C,te=U?A:U_i(A);return Y!=null&&!Z7n.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 fg1({wrapAsNullable:c,nameOverride:e,generatedName:t,title:r,values:S,_default:x,description:f,availability:d,groupName:o,source:g})}function fg1({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 dg1={"<":"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 U_i(e){let t=yba(e),r=dg1[e];return t!=null?OV(FE(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":OV(FE(e)))}function pg1(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 L_f({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 U_f(e){return typeof e=="string"?E7.string(e):typeof e=="boolean"?E7.boolean(e):E7.string(`${e}`)}function V_f({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:U_f(i),description:a,availability:u,groupName:f}),description:a,availability:u,groupName:f}):Lp.literal({nameOverride:e,generatedName:t,title:r,value:U_f(i),description:a,availability:u,groupName:f})}function Afu({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 _g1={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},hg1={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}}},yg1={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}}},vg1={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},bg1={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},gg1={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},mg1={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},Og1={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function vba(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[_g1,hg1,yg1,vg1,bg1,gg1,mg1,Og1],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=OV(FE(t));return/^\d/.test(r)?yba(r)??r:r}function Nfu(e){let t=e.join("_");return FE(t)}function uq(e){switch(e.type){case"object":return ib.object({allOf:e.allOf,properties:e.properties.map(t=>jg1(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:uq(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:uq(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:uq(e.value),groupName:e.groupName});case"primitive":return ib.primitive({description:e.description,availability:e.availability,schema:W_f(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:W_f(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:uq(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(Pg1(e.value));case"unknown":return ib.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:fl(e)}}function Pg1(e){switch(e.type){case"discriminated":return QSr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:uq(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,uq(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return QSr.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>uq(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:fl(e)}}function W_f(e){switch(e.type){case"string":return Qw.string(e);case"base64":return Qw.base64();case"boolean":return Qw.boolean(e);case"date":return Qw.date();case"datetime":return Qw.datetime();case"double":return Qw.double(e);case"float":return Qw.float();case"int":return Qw.int(e);case"int64":return Qw.int64(e);case"uint":return Qw.uint();case"uint64":return Qw.uint64();default:fl(e)}}function jg1(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:uq(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability}}function bba(e,t){return LRt(uq(e),uq(t))}function LRt(e,t){return e.type==="primitive"&&t.type==="primitive"?H_f(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?wg1(e.values,t.values):e.type==="array"&&t.type==="array"?LRt(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"?LRt(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?Dg1(e.value,t.value):e.type==="object"&&t.type==="object"?Sg1(e,t):e.type==="map"&&t.type==="map"?H_f(e.key.schema,t.key.schema)&&LRt(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function H_f(e,t){return e.type===t.type}function wg1(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return Twr(r,n)}function Dg1(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:LRt(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:LRt(r,i)}):!1}function Sg1(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:LRt(a,i.schema)})}function $_f({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 Je of ee.oneOf){let Dt=gy(Je)?c.resolveSchemaReference(Je):Je,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=B5r($);if(Ve==null)continue;U.push({schemaId:Ve,convertedSchema:zfu($,[Ve],x),properties:J_f({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 Je=Y[ee];Je!=null?(Je.schemaIds.push($.schemaId),Je.schemas.some(Tt=>bba(Tt,Ve))||Je.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($),Je=Lh(ee,kh.AUDIENCES)??[],Dt=E2e(ee),Tt=Lh(ee,kh.FERN_PROPERTY_NAME),Wt=[...n,$],Nt=Nfu(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&&!bba(ur,zt)?Ar[Gr.schemaId]={differentSchema:!0}:zt!=null&&(Ar[Gr.schemaId]={differentSchema:!1})}return{key:$,schema:ur,nameOverride:Tt,audiences:Je,conflict:Ar,generatedName:Nfu([...n,$]),availability:Dt}});return G.push(...C.map($=>{let ee=$.conflict;for(let Ve of U){let Je=Ve.properties[$.key];Je!=null&&!bba($.schema,Je)?ee[Ve.schemaId]={differentSchema:!0}:Je!=null&&(ee[Ve.schemaId]={differentSchema:!1})}return{...$,conflict:ee}})),Eg1({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 Eg1({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:Y7n(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:Y7n(o),availability:l,source:g})}function J_f({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[u,f]=gy(e)?[t.resolveSchemaReference(e),vba(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...J_f({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=Mg1({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&&LRt(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}))}),z5r({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]:G_f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,subtypes:x,groupName:c,encoding:o,source:l})}function Bfu({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=X7n(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&&LRt(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}))}),z5r({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]:G_f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,subtypes:O,groupName:f,encoding:c,source:o})}function Mg1({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=NGi(o,u);d=NGi(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(Q7n(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(Q7n(i)??`${i}`),++i}return n}function G_f({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 e4n(e){if(e.default!=null&&typeof e.default=="string")return e.default}function gba({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 K_f({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 URt({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 Y_f({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 Len="#/components/schemas/";function L1(e,t,r,n,i,a,u=!1,f=new Set,d){let c=zg1({schema:e,logger:r.logger});if(gy(e)){let o=B5r(e);return o!=null?(u?r.markSchemaAsReferencedByRequest(o):r.markSchemaAsReferencedByNonRequest(o),X7n(e,t,r,n,c,i,a)):N5r(r.resolveSchemaReference(e),t,r,vba(e.$ref),c,i,a,f,u,d)}return N5r(e,t,r,n,c,i,a,f,u,d)}function X7n(e,t,r,n,i,a,u){let f=e.$ref.includes("properties")?N5r(r.resolveSchemaReference(e),t,r,n,i,a,u,new Set):Lp.reference(zfu(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 xg1(e){if(e!=null&&!e.includes(" ")&&!!/^[a-zA-Z]+$/.test(e))return e}function N5r(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?xg1(e.title):void 0),l=Lh(e,kh.SDK_GROUP_NAME)??((C=Lh(e,Xje.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,Xje.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=z_f({schema:e,description:S,title:j,nameOverride:o,generatedName:O,availability:x});if(N!=null)return N;if(!t&&e.nullable===!0)return N5r(e,!0,r,n,i,a,u,f,d,c);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!V_i(e.enum))return L9({nameOverride:o,generatedName:O,title:j,primitive:by.string({default:e4n(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:URt({schema:e,logger:r.logger,fallback:c})}),groupName:g,wrapAsNullable:t,description:S,availability:x});let U=N_f(e);return e.enum.length===1&&e.enum[0]!=null&&U==null?V_f({nameOverride:o,generatedName:O,title:j,wrapAsNullable:t,value:e.enum[0],description:S,availability:x,groupName:g}):z5r({nameOverride:o,generatedName:O,title:j,fernEnum:U,enumVarNames:Lh(e,[Xje.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:S,availability:x,wrapAsNullable:t,groupName:g,context:r,source:a})}if(V_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:N5r({...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:N5r({...e,type:U},t,r,n,i,a,u,f,d,c),groupName:g,description:e.description,availability:x})}if(V_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?Q_f({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:K_f({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:S,availability:x,groupName:g})}if(e==="number"||e.type==="number")return Afu({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Fen(e.exclusiveMinimum),exclusiveMaximum:Fen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:gba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="integer"||e.type==="integer")return L_f({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Fen(e.exclusiveMinimum),exclusiveMaximum:Fen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:gba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="float")return Afu({nameOverride:o,generatedName:O,title:j,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Fen(e.exclusiveMinimum),exclusiveMaximum:Fen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:gba({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:URt({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=ehf(e,"const");return U!=null?Q_f({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:e4n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:URt({schema:e,logger:r.logger,fallback:c})}),groupName:g,wrapAsNullable:t,description:S,availability:x})}if(e.type==="array")return I_f({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,item:e.items,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,example:Y_f({schema:e,logger:r.logger,fallback:c}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&X_f(e))return B_f({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?Bfu({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}):qfu({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?Bfu({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}):qfu({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 t4n(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=Cg1({schemas:e.oneOf});if(Y!=null)return z5r({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=Z_f({schemas:e.oneOf,context:r});if(te!=null&&!r.options.discriminatedUnionV2&&!U)return Cfu({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 t4n(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 t4n($,S,g)}else if(!gy(G)&&G.type==="null"){let $=L1(te,!0,r,n,a,u);return t4n($,S,g)}}}let U=Z_f({schemas:e.anyOf,context:r});if(U!=null&&!r.options.discriminatedUnionV2)return Cfu({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 t4n(te,S,g)}let Y=U.filter(te=>{let G=mba(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 t4n(te,S,g)}return $_f({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"&&Tg1(e)&&qg1(e)&&X_f(e))return hba({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:e4n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:URt({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 B5r(e){if(!!e.$ref.startsWith(Len))return e.$ref.replace(Len,"")}function zfu(e,t,r){let n=Lh(e,kh.TYPE_NAME),i=yR(t),a=e.description,u=E2e(e),f=B5r(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 Tg1(e){return e.oneOf==null||e.oneOf.length===0}function qg1(e){return e.allOf==null||e.allOf.length===0}function X_f(e){return e.properties==null||Object.keys(e.properties).length===0}function V_i(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function t4n(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 mba(e){return gy(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>mba(t)):e.oneOf!=null?e.oneOf.every(t=>mba(t)):e.anyOf!=null?e.anyOf.every(t=>mba(t)):!1}function Q_f({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 Cg1({schemas:e}){let t=new Set;for(let r of e){if(gy(r))return;if(r.enum!=null&&V_i(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function Z_f({schemas:e,context:t}){let r={};for(let n of e){let i=k_f({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 k_f({schema:e,context:t}){let r=gy(e)?t.resolveSchemaReference(e):e;return Ag1({schema:r,context:t})}function Ag1({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=k_f({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&&V_i(a.enum)&&Ng1(a.enum).length===1&&a.enum[0]!=null&&(r[n]=a.enum[0]);let u=ehf(a,"const");a.type==="string"&&u!=null&&(r[n]=u),n==="type"&&a.example!=null&&(r[n]=a.example)}return r}function Ng1(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 ehf(e,t){let r=e[t];if(r!=null)return r}function zg1({schema:e,logger:t}){let r=A_f({schema:e,logger:t});if(r!=null)return F_f(r)}function Oba(e,t){let r={},n={};return e==null?r=t:n={[e]:t},{rootSchemas:r,namespacedSchemas:n}}var thf="#/components/messages/",Ifu=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(Len))throw new Error(`Failed to resolve ${t.$ref}`);let n=t.$ref.substring(Len.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(thf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(thf.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}},Pba=class extends Ifu{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 I5r(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=>I5r(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=I5r(n);i!=null&&t.push({key:t0.string(r),value:i})}return RP.map(t)}}function W_i(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function rhf(e){if(e!=null&&Array.isArray(e))return e}var r4n=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"&&nhf({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=W_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(m5r.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=I5r(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=rhf(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=W_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=W_i(r)??(g!=null?W_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:fl(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 nhf({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:fl(r)}}};function nhf({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function VRt(e){switch(e.type){case"object":return Lp.object({allOf:e.allOf,properties:e.properties.map(t=>Ig1(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:VRt(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:VRt(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:VRt(e.value),groupName:e.groupName});case"primitive":return Lp.primitive({description:e.description,availability:e.availability,schema:ihf(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:ihf(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:VRt(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(Bg1(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:fl(e)}}function Bg1(e){switch(e.type){case"discriminated":return jQ.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:VRt(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,VRt(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=>VRt(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:fl(e)}}function ihf(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:fl(e)}}function Ig1(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:VRt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability}}function jba(e){return e.type!=="optional"&&e.type!=="nullable"}function H_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 wba=class{exampleTypeFactory;logger;schemas;constructor(t,r){this.schemas=t,this.exampleTypeFactory=new r4n(t),this.logger=r}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=Fg1(t.request),n=Lg1(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&&!WRt(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&&!WRt(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&&!WRt(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=Rg1(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=>H_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=>FS(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?XSr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):XSr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?bW.Csharp:r.sdk,code:r.code})).filter(FS)}isSchemaRequired(t){return jba(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function Rg1(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 Fg1(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:Ug1(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function Lg1(e){if(e!=null)return e.type!=="json"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function WRt(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return WRt(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undisciminated":return WRt(e.value.value);default:return!1}default:fl(e)}}function Ug1(e){return Lp.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:VRt(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0}).filter(FS),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 r4n(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&&!WRt(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&&!WRt(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&&!WRt(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&&!WRt(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 jba(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 $_i={FERN_DISPLAY_NAME:"x-fern-display-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path"};function ahf(e){return Lh(e,$_i.FERN_EXAMPLES)??[]}function uhf({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 Pba({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=ohf({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=ohf({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=ahf(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:uq(Ve.schema),env:Ve.env})),queryParameters:U.map(Ve=>({...Ve,schema:uq(Ve.schema)})),pathParameters:N.map(Ve=>({...Ve,parameterNameOverride:void 0,schema:uq(Ve.schema)}))},groupName:f.resolveTags(ee,"Websocket"),publish:Y!=null?uq(Y):Y,subscribe:te!=null?uq(te):te,summary:Lh(z,$_i.FERN_DISPLAY_NAME),path:A,description:void 0,examples:$,source:n};break}}return{groupedSchemas:Oba(a,d),channel:c,basePath:Lh(e,$_i.BASE_PATH)}}function ohf({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 _xf=yu(gmf(),1);var Ftn=yu(fxf(),1);var dxf=require("fs/promises");async function BPa({absoluteFilepathToOverrides:e,data:t,context:r}){let n=null;try{let i=(await(0,dxf.readFile)(e,"utf8")).toString();try{n=JSON.parse(i)}catch{n=av.load(i,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return u9o({data:t,overrides:n})}var wJ1={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},DJ1={id:"",typeExtension:{oas3:e=>{var t;return{...e,XFernStreaming:wJ1,Operation:{...e.Operation,properties:{...(t=e.Operation)==null?void 0:t.properties,"x-fern-streaming":"XFernStreaming"}}}}}};async function hxf({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,context:r}){let n=await pxf({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 BPa({absoluteFilepathToOverrides:i,context:r,data:n});return await pxf({absolutePathToOpenAPI:e,parsed:a})}return n}async function pxf({absolutePathToOpenAPI:e,parsed:t}){let r={config:new Ftn.Config({apis:{},styleguide:{plugins:[DJ1],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0},n=t!=null?await(0,Ftn.bundle)({...r,doc:{source:new Ftn.Source(e,"<openapi>"),parsed:t}}):await(0,Ftn.bundle)({...r,ref:e});return await _xf.default.parse(n.bundle.parsed)}var cAf=yu(vCf(),1);function bCf(e){return Lh(e,kh.ASYNC_CONFIG)}var gCf="$request.";function mCf(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:IZ1(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function IZ1(e){return e.startsWith(gCf)?e.slice(gCf.length):e}function OCf(e){let t=e;if(t.cursor!=null)return YSr.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});let r=e;return YSr.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}function PCf(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:OCf(n)}return OCf(r)}}function jCf(e){let t=RZ1(e),r={};return cOu({obj:t,occurrences:r,breadcrumbs:[]}),r}function cOu({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let n of e)cOu({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)cOu({obj:e[n],occurrences:t,breadcrumbs:[...r,n]})}}}function RZ1(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:(r==null?void 0:r.get)!=null?I0i(r.get):void 0,put:(r==null?void 0:r.put)!=null?I0i(r.put):void 0,post:(r==null?void 0:r.post)!=null?I0i(r.post):void 0,patch:(r==null?void 0:r.patch)!=null?I0i(r.patch):void 0,delete:(r==null?void 0:r.delete)!=null?I0i(r.delete):void 0}]))}}function I0i(e){return{...e,requestBody:e.requestBody!=null?gy(e.requestBody)?e.requestBody:FZ1(e.requestBody):void 0}}function FZ1(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 wCf="#/components/parameters/",DCf="#/components/responses/",SCf="#/components/examples/",ECf="#/components/requestBodies/",G3n=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=jCf(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(wCf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(wCf.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(ECf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(ECf.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(DCf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(DCf.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(SCf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(SCf.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 K3n=class extends G3n{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 LZ1=nr.object({lang:nr.string(),label:nr.optional(nr.string()),source:nr.string()}),lOu=nr.array(LZ1);var MCf={README_EXT:"x-readme"};function UZ1(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 xCf(e){let t=Lh(e,MCf.README_EXT);if(!RO(t))return[];let r=t["code-samples"];if(!UZ1(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 TCf(e,t,r){let n=FRt(t,kh.EXAMPLES,t8.ExampleEndpointCallArraySchema,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],i=FRt(t,Xje.REDOCLY_CODE_SAMPLES_KEBAB,lOu,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],u=[...FRt(t,Xje.REDOCLY_CODE_SAMPLES_CAMEL,lOu,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=xCf(t);return f.length>0&&n.push({"code-samples":f}),n.map(pAt.unknown)}function qCf(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 V1a(e){return{url:VZ1({url:e.url,variables:e.variables??{}}),description:e.description,name:WZ1(e),audiences:Lh(e,kh.AUDIENCES)}}function VZ1({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 WZ1(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 CCf(e){return Lh(e,kh.PARAMETER_NAME)}function ACf(e){return Lh(e,kh.SDK_VARIABLE)}function W1a({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=URt({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,URt({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:URt({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:URt({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:CCf(c),availability:l,source:a};c.in==="query"?u.queryParameters.push(S):c.in==="path"?u.pathParameters.push({...S,variableReference:ACf(c)}):c.in==="header"?!HZ1.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 HZ1=new Set(["User-Agent","Content-Length","Content-Type","X-Forwarded-For","Cookie","Origin","Content-Disposition","X-Ping-Custom-Domain"]);function Y3n(e,t){for(let r of Object.keys(e))if(r.includes("json")||r==="*/*"){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:zCf(n,t)}}}function NCf(e,t){for(let r of Object.keys(e)){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:zCf(n,t)}}}function zCf(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let n=Lh(e,Xje.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 $Z1(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 JZ1(e){var t;for(let r in e.content)if((t=sA.parse(r))!=null&&t.isOctetStream())return!0;return!1}function GZ1(e,t){let r=gy(e)?fOu(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 X3n({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=$Z1(u),d=f==null?void 0:f.schema,c=f==null?void 0:f.encoding,o=Y3n(u.content,r);if(JZ1(u))return S2e.octetStream({description:void 0,source:i});if(d!=null&&o==null||d!=null&&GZ1(d,t)){let A=gy(d)?fOu(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)&&Y7n(o.schema.additionalProperties),source:i})}function fOu(e,t){var i,a;if(!e.$ref.startsWith(Len))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=B5r(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)?fOu(n,t):{id:r,schema:n}}var dOu={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"},BCf=new Set(Object.values(dOu));var KZ1=["200","201","202","204"];function RCf({operationContext:e,responses:t,context:r,responseBreadcrumbs:n,responseStatusCode:i,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let f=YZ1({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,c;for(let o of i!=null?[i]:KZ1){let l=t[o];l!=null&&(d=!0,c==null&&(c=ICf({operationContext:e,response:l,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})))}if(c==null&&!d&&t.default!=null&&(c=ICf({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:fl(c)}return{value:void 0,errors:f}}function ICf({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 q3.file({description:f.description,source:a});let d=Y3n(f.content??{},n);if(d!=null){if(t!=null)switch(t){case"json":return q3.streamingJson({description:f.description,responseProperty:void 0,schema:uq(L1(d.schema,!1,n,i,a,u)),source:a});case"sse":return q3.streamingSse({description:f.description,responseProperty:void 0,schema:uq(L1(d.schema,!1,n,i,a,u)),source:a})}return q3.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 q3.file({description:f.description,source:a});if(l.isPlainText()){let g=o.schema;if(g==null)return q3.text({description:f.description,source:a});let O=gy(g)?n.resolveSchemaReference(g):g;return O.type==="string"&&O.format==="byte"?q3.file({description:f.description,source:a}):q3.text({description:f.description,source:a})}}}}function YZ1({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=NCf(d.content??{},t),o=dOu[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 OEr({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=W1a({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:j,path:d,httpMethod:c,source:a}),x=f.requestBody!=null?X3n({requestBody:f.requestBody,document:u,context:new K3n({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=X3n({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j,"Body"],source:a,namespace:t.namespace}):f.requestBody!=null&&(x=X3n({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j],source:a,namespace:t.namespace}));let A=[...o,"Response"],z=RCf({operationContext:e,streamFormat:i,responses:f.responses,context:t,responseBreadcrumbs:A,responseStatusCode:r,source:a}),N=qCf(f),C=TCf(e,f,t),U=Lh(f,kh.SERVER_NAME_V2);return{summary:f.summary,internal:Lh(f,Xje.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=>V1a(Y)),description:f.description,authed:XZ1(f,u),availability:N,method:c,path:d,examples:C,pagination:e.pagination,source:a}}function XZ1(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function LCf({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=FCf({context:t,headerToIgnore:f,parameters:a}),l=FCf({context:t,headerToIgnore:f,parameters:u}),g=OEr({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=OEr({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 FCf({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 pOu="stream";function HCf({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:OEr({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let n=UCf({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if((n==null?void 0:n.schemaReference)!=null){let c=B5r(n.schemaReference);c!=null&&t.excludeSchema(c)}let i=VCf({operation:e.operation,response:r.responseStream}),a=OEr({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+pOu}:void 0,operation:{...e.operation,requestBody:n==null?void 0:n.requestBody,responses:i},baseBreadcrumbs:[...e.baseBreadcrumbs,pOu]},context:t,streamFormat:r.format,suffix:pOu,source:t.source});a.examples=a.examples.filter(c=>WCf(c,t)!==!1);let u=UCf({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),f=VCf({operation:e.operation,response:r.response}),d=OEr({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=>WCf(c,t)!==!0),{streaming:a,nonStreaming:d}}default:fl(r)}}function UCf({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=Y3n(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 VCf({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[sA.APPLICATION_JSON]:{schema:t}}}}}function WCf(e,t){return e._visit({unknown:r=>{let n=t8.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 $Cf({context:e,operationContext:t,source:r}){let{document:n,operation:i,path:a,method:u,baseBreadcrumbs:f,sdkMethodName:d}=t,c=[...f,"Payload"],o=W1a({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=X3n({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:QZ1(l.fullExamples),source:r}}function QZ1(e){if(e==null)return[];let t=[];for(let r of e){let n=I5r(r.value);n!=null&&t.push({description:r.description,name:r.name,payload:n})}return t}function _Ou({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=ZZ1(r,e),u=PCf(e.document,r),f={...t,sdkMethodName:a,baseBreadcrumbs:kZ1({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path}),operation:r,operationParameters:r.parameters??[],pagination:u};if(n){let l=$Cf({context:e,operationContext:f,source:e.source});return l!=null?{type:"webhook",value:l}:void 0}let d=mCf(r);if(d!=null){let l=HCf({context:e,operationContext:f,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let c=bCf(r);if(c!=null){let l=LCf({context:e,operationContext:f,asyncExtension:c,source:e.source});return{type:"async",async:l.async,sync:l.sync}}let o=OEr({context:e,operationContext:f,streamFormat:void 0,source:e.source});return{type:"http",value:o}}function ZZ1(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 kZ1({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 JCf(e,t,r,n){let i=[],a=KCf(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=ek1({operation:f.operation}),c=_Ou({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:d});c!=null&&i.push(c)}return i}function GCf(e,t,r,n){let i=[],a=KCf(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=_Ou({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:!0});d!=null&&i.push(d)}return i}function KCf(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 ek1({operation:e}){return Lh(e,[kh.WEBHOOK])??!1}function YCf(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 XCf(e){return Lh(e,kh.FERN_BASIC_AUTH)}function hOu(e,t){if(gy(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return tk1(e,t)}function tk1(e,t){var r,n,i,a;if(e.type==="apiKey"&&e.in==="header"){let u=Lh(e,Xje.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=XCf(e),f=YCf(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:rk1(e,t)})}throw new Error(`Failed to convert security scheme ${JSON.stringify(e)}`)}function rk1(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=z5r({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=uq(f);if(d.type==="enum")return d}}function QCf(e){return Lh(e,kh.BASE_PATH)}var nk1=nr.record(nr.string(),nr.object({summary:nr.string().optional(),description:nr.string().optional()}));function ZCf({document:e,context:t}){return FRt(e,kh.GROUPS,nk1,t.logger)}function kCf({context:e,document:t}){return FRt(t,kh.FERN_VERSION,t8.VersionDeclarationSchema,e.logger)??void 0}function eAf(e){let t=Lh(e,kh.FERN_GLOBAL_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?L_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 tAf(e){let t=Lh(e,kh.FERN_IDEMPOTENCY_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?L_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 rAf(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:Qw.string({default:e4n(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 ik1="webhooks";function nAf(e){return Lh(e,ik1)??{}}var H1a=class extends G3n{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 K3n({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 iAf(e){return Lh(e,kh.RESOLUTIONS)}function aAf({openapi:e}){let t=iAf(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=ak1({openapi:e,schemaReference:a,schemaName:n.name}),e=oAf({openapi:e,replaceReference:a,schemaReference:i,replacedReferences:r}),r={...r,...Object.fromEntries(n.resolutions.map(u=>[i,u]))}}return e}function ak1({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 oAf({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 oAf({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 $1a({openApi:e,taskContext:t,options:r,source:n,namespace:i}){var Y,te,G;e=aAf({openapi:e});let a=Object.fromEntries(Object.entries(((Y=e.components)==null?void 0:Y.securitySchemes)??{}).map(([$,ee])=>hOu(ee,n)==null?[]:[$,hOu(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 H1a({document:e,taskContext:t,authHeaders:u,options:r,source:n,namespace:i}),d=rAf(e),c=eAf(e),o=tAf(e),l=r.audiences??[],g=[],O=[];Object.entries(e.paths??{}).forEach(([$,ee])=>{if(ee==null)return;t.logger.debug(`Converting path ${$}`);let Ve=JCf($,ee,e,f);for(let Je of Ve){let Dt=uAf({operation:Je});if(!(l.length>0&&!l.some(Tt=>Dt.includes(Tt))))switch(Je.type){case"async":g.push(Je.sync),g.push(Je.async);break;case"http":g.push(Je.value);break;case"streaming":g.push(Je.streaming),Je.nonStreaming&&g.push(Je.nonStreaming);break;case"webhook":O.push(Je.value);break;default:fl(Je)}}}),Object.entries(nAf(e)).forEach(([$,ee])=>{if(ee==null)return;t.logger.debug(`Converting path ${$}`);let Ve=GCf($,ee,e,f);for(let Je of Ve){let Dt=uAf({operation:Je});l.length>0&&!l.some(Tt=>Dt.includes(Tt))||O.push(Je.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(BCf.has($))return[$,L1({...ee,"x-fern-type-name":`${$}Body`},!1,f,[$],n,i)]}return[$,L1(ee,!1,f,[$],n,i)]}).filter($=>$.length>0)),S=ok1(j,f,n),x=uk1(S,f),A={};for(let[$,ee]of Object.entries(x)){let Ve=uq(ee);f.isSchemaExcluded($)||(A[$]=Ve,t.logger.debug(`Converted schema ${$}`))}let z=new wba(x,f.logger),N=g.map($=>{let ee=$.examples,Ve=ee;if(!r.disableExamples&&(ee.length===0||ee.every(H_i))){let Tt=z.buildEndpointExample($);Tt.length>0&&(Ve=[...Tt,...ee.filter(Wt=>!H_i(Wt))])}let Je=$.request,Dt=$.response;return{...$,request:(Je==null?void 0:Je.type)==="json"?{...Je,schema:uq(Je.schema)}:Je,response:(Dt==null?void 0:Dt.type)==="json"?{...Dt,schema:uq(Dt.schema)}:Dt,queryParameters:$.queryParameters.map(Tt=>({description:Tt.description,name:Tt.name,schema:uq(Tt.schema),parameterNameOverride:Tt.parameterNameOverride,availability:Tt.availability,source:Tt.source})),pathParameters:$.pathParameters.map(Tt=>({description:Tt.description,name:Tt.name,schema:uq(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:uq(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:uq(Tt.schema),description:Tt.description,source:Tt.source,examples:(Wt=Tt.fullExamples)==null?void 0:Wt.map(Nt=>{let ur=I5r(Nt.value);if(ur!=null)return{name:Nt.name,description:Nt.description,example:ur}}).filter(FS)}})}}),C=ZCf({document:e,context:f});return{apiVersion:kCf({context:f,document:e}),basePath:QCf(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($=>V1a($)),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:Oba(i,A),securitySchemes:a,hasEndpointsMarkedInternal:N.some($=>$.internal),nonRequestReferencedSchemas:f.getReferencedSchemas(),variables:d,globalHeaders:c,idempotencyHeaders:o}}function ok1(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=sAf({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 uk1(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 sAf({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(...sAf({schema:i,schemas:t}))}return r}function uAf({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:fl(e)}return t}async function lAf({openApi:e,taskContext:t,options:r,source:n,namespace:i}){let a=await(0,cAf.convertObj)(e,{});return $1a({openApi:a.openapi,taskContext:t,options:r,source:n,namespace:i})}var Q3n={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0};async function Ytn({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,vOu.readFile)(a.absoluteFilepath)).toString(),f=D4(e,a.source.file);a.source.relativePathToDependency!=null&&(f=pf(a.source.relativePathToDependency,f));let d=a.source.type==="protobuf"?KSr.protobuf({file:f}):KSr.openapi({file:f});if(u.includes("openapi")||u.includes("swagger")){let c=await hxf({absolutePathToOpenAPI:a.absoluteFilepath,context:r,absolutePathToOpenAPIOverrides:a.absoluteFilepathToOverrides});if(lk1(c)){let o=$1a({openApi:c,taskContext:r,options:yOu({specSettings:a.settings,overrides:n}),source:d,namespace:a.namespace});i=fAf(i,o)}else if(fk1(c)){let o=await lAf({openApi:c,taskContext:r,options:yOu({specSettings:a.settings}),source:d,namespace:a.namespace});i=fAf(i,o)}}else if(u.includes("asyncapi")){let c=await ck1({absoluteFilePathToAsyncAPI:a.absoluteFilepath,context:r,absoluteFilePathToAsyncAPIOverrides:a.absoluteFilepathToOverrides}),o=uhf({document:c,taskContext:r,options:yOu({specSettings:a.settings}),source:d,asyncApiOptions:sk1({specSettings:a.settings}),namespace:a.namespace});o.channel!=null&&i.channel.push(o.channel),o.groupedSchemas!=null&&(i.groupedSchemas=dAf(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 yOu({specSettings:e,overrides:t}){return{disableExamples:(t==null?void 0:t.disableExamples)??Q3n.disableExamples,discriminatedUnionV2:(t==null?void 0:t.discriminatedUnionV2)??(e==null?void 0:e.shouldUseUndiscriminatedUnionsWithLiterals)??Q3n.discriminatedUnionV2,useTitlesAsName:(t==null?void 0:t.useTitlesAsName)??(e==null?void 0:e.shouldUseTitleAsName)??Q3n.useTitlesAsName,audiences:(t==null?void 0:t.audiences)??(e==null?void 0:e.audiences)??Q3n.audiences,optionalAdditionalProperties:(t==null?void 0:t.optionalAdditionalProperties)??(e==null?void 0:e.optionalAdditionalProperties)??Q3n.optionalAdditionalProperties}}function sk1({specSettings:e,overrides:t}){return{naming:(t==null?void 0:t.naming)??(e==null?void 0:e.asyncApiNaming)??C_f.naming}}function fAf(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:dAf(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 dAf(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 ck1({absoluteFilePathToAsyncAPI:e,absoluteFilePathToAsyncAPIOverrides:t,context:r}){let n=(await(0,vOu.readFile)(e)).toString(),i=await av.load(n);return t!=null?await BPa({absoluteFilepathToOverrides:t,context:r,data:i}):i}function lk1(e){return e.openapi!=null}function fk1(e){return e.swagger!=null}function G1a({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=bOu({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=N2(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=C3(e.availability)),u}function bOu({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($T),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"&&(Z7n.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:U_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&&J1a({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&&J1a({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 bOu({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($T),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"&&(Z7n.test(u.value.value)?i.push(u.value.value):i.push({value:u.value.value,name:U_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&&J1a({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&&J1a({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 bOu({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 J1a({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 pAf({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"]=dk1(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=pk1({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=Uzr(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function dk1(e){let t={};return e.forEach(r=>{let n=Uzr(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function pk1({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=Uzr(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function Uzr(e){switch(e.type){case"primitive":return _Af(e.value);case"object":return hAf(e.properties);case"array":return _k1(e.value);case"map":return hk1(e.value);case"oneOf":return yk1(e.value);case"enum":return e.value;case"literal":return vk1(e.value);case"unknown":return Uzr(e.value);default:fl(e)}}function _Af(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:fl(e)}}function hAf(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Uzr(r)]))}function _k1(e){return e.map(t=>Uzr(t))}function hk1(e){return Object.fromEntries(e.map(t=>[_Af(t.key),Uzr(t.value)]))}function yk1(e){return e.type==="discriminated"?hAf(e.value):Uzr(e.value)}function vk1(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:fl(e)}}function PEr(e){var t;return(t=e.find(r=>typeof r!="string"&&r.type==="namespace"))==null?void 0:t.name}function K1a(e,t){return t??((e==null?void 0:e.groupName)!=null?PEr(e.groupName):void 0)}function yAf({channel:e,context:t,declarationFile:r}){let n={path:e.path,auth:!1};e.summary!=null&&(n["display-name"]=e.summary);let i=PEr(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=pba({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=G1a({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=RRt({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=pAf({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:c})}}var vAf="Production",bAf="Default";function gAf(e){return Object.entries(e).reduce((t,[r,n])=>(L2n(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function mAf(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:bAf,schema:o?{url:c,audiences:o}:c}),e.builder.setDefaultEnvironment(bAf))}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:vAf,schema:{urls:{...gAf(t),...gAf(n)}}}),e.builder.setDefaultEnvironment(vAf)}}function Y1a(e){return N2(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var gOu=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},bk1=.75,gk1=new Set("authorization");function OAf(e){if(e.globalHeaderOverrides!=null){for(let[r,n]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:n});return}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?G7n(n.schema):void 0,u=a!=null?PEr(a):void 0,f=zs.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?N2(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(gk1.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let f=t[a.name],d=RRt({header:{...a,schema:(f==null?void 0:f.schema)??a.schema,name:(f==null?void 0:f.name)??a.name},fileContainingReference:zs.of(iB),context:e,namespace:void 0});u=new gOu(d),r[a.name]=u}u.increment()}let n=e.ir.endpoints.length*bk1;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:Y1a(a.schema)}))}}}function PAf(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?G7n(t.schema):void 0,n=r!=null?PEr(r):void 0,i=RRt({header:{...t,schema:t.schema??ib.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:Qw.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(iB),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:Y1a(i)})}}function lG(e){switch(e.type){case"primitive":return jAf(e.value);case"object":return wAf(e.properties);case"array":return mk1(e.value);case"map":return Ok1(e.value);case"oneOf":return Pk1(e.value);case"enum":return e.value;case"literal":return jk1(e.value);case"unknown":return lG(e.value);default:fl(e)}}function jAf(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:fl(e)}}function wAf(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,lG(r)]))}function mk1(e){return e.map(t=>lG(t))}function Ok1(e){return Object.fromEntries(e.map(t=>[jAf(t.key),lG(t.value)]))}function Pk1(e){return e.type==="discriminated"?wAf(e.value):lG(e.value)}function jk1(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:fl(e)}}function DAf({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"]=wk1(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=Dk1(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=Sk1({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(FS)),r)}function wk1(e){let t={};return e.forEach(r=>{let n=lG(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function Dk1(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 Sk1({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 SAf(e){return KJ._visit(e,{get:()=>t8.HttpMethodSchema.Enum.GET,post:()=>t8.HttpMethodSchema.Enum.POST,put:()=>t8.HttpMethodSchema.Enum.PUT,patch:()=>t8.HttpMethodSchema.Enum.PATCH,delete:()=>t8.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 EAf({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,u=e.path,f=K1a(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]=pba({pathParameter:S,context:r,fileContainingReference:t,namespace:f}),a.add(S.name);let c={};for(let S of e.queryParameters){let x=G1a({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:SAf(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=RRt({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=Mk1({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:N2(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:N2(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:N2(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=C3(e.availability)),Object.entries(e.errors).forEach(([S,x])=>{var te;let A=x.generatedName,z=zs.of($T);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=w_f({location:MAf,namespaceOverride:f});if(x.schema!=null){let G=S1({schema:x.schema,context:r,fileContainingReference:C,declarationFile:C,namespace:f});N.type=N2(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=Ek1({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[mOu,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function Ek1({endpointExamples:e,context:t}){return e.map(r=>{try{return DAf({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function Mk1({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=C3(x.availability);if(!d.has(z)&&x.audiences.length<=0)return d.add(z),x.nameOverride!=null?[x.key,{type:N2(A),docs:R_i(A),name:x.nameOverride,availability:N}]:[x.key,N?{...typeof A=="string"?{type:A}:A,availability:N}:A];let C={type:N2(A),docs:R_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 N2(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 fl(r)}}function xk1({location:e,namespaceOverride:t}){return t!=null?{...e,file:pf(zs.of(t),e.file)}:e}function Tk1(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($T),endpointId:FE(e.summary)}:{file:zs.of($T),endpointId:FE(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:zs.of($T),endpointId:n};let i=R0i(r),a=R0i(n);if(Twr(i,a))return{file:zs.of("__package__.yml"),endpointId:r};let u=Ak1({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 F0i(e){let t=e.tags[0];if(e.sdkName!=null){let r=gfu({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 xk1({namespaceOverride:e.namespace,location:Tk1(e)})}function R0i(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=C8t(t),t}var qk1=new RegExp("[^a-zA-Z0-9{}]+"),Ck1=new RegExp("[{}]","g");function Ak1({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(qk1).join("_").replaceAll(Ck1,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:zs.of(FE(t)+".yml"),endpointId:FE(e.slice(0,-1*a.length)),tag:t}}function xAf(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:u,file:f,tag:d}=F0i(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=EAf({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 TAf(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?PEr(r.groupName):void 0,i=S1({schema:ib.primitive(r),context:e,fileContainingReference:zs.of($T),namespace:n});e.builder.addVariable({name:t,schema:{type:N2(i),docs:r.description??void 0}})}}function qAf(e){for(let t of e.ir.webhooks){let r=Bk1({webhook:t,context:e});if(r==null)continue;let n=K1a(t.sdkName,t.namespace),i={};for(let u of t.headers)i[u.name]=RRt({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 Nk1({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:pf(zs.of(t),e.file)}:e}function zk1({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:zs.of($T),endpointId:n};let i=R0i(r),a=R0i(n);if(Twr(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 Bk1({webhook:e,context:t}){return e.sdkName!=null?{file:j_f({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:Nk1({namespaceOverride:e.namespace,location:zk1({webhook:e,context:t})})}var Ik1=zs.of($T);function CAf(e){switch(e.type){case"object":return gFt(e.groupName);case"enum":return gFt(e.groupName);case"oneOf":return gFt(e.value.groupName);case"array":return gFt(e.groupName);case"map":return gFt(e.groupName);case"reference":return gFt(e.groupName);case"literal":return gFt(e.groupName);case"optional":return gFt(e.groupName);case"nullable":return gFt(e.groupName);case"primitive":return gFt(e.groupName);case"unknown":return Ik1;default:fl(e)}}function gFt(e){return K7n(e)}var mOu="external",MAf=zs.of($T);function AAf({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let u=CAf(a),f=E_f({schema:a,context:n,declarationFile:u,namespace:r});if(V2n(f.schema)){let d=N2(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 NAf(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),mAf(e),OAf(e),PAf(e),q_f(e),TAf(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(mOu);let{schemaIdsToExclude:t,sdkGroups:r}=xAf(e);qAf(e);for(let n of e.ir.channel){let i=K7n(n.groupName);yAf({channel:n,context:e,declarationFile:i})}AAf({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:t,namespace:void 0,context:e});for(let[n,i]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))AAf({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 Vzr=yu(require("path"),1);var X1a=yu(require("path"),1),Z3n=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}${X1a.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}${X1a.default.sep}${u}`:u,d=n.directories[u];r(d,f)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(X1a.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 Z3n),this.directories[r].getOrCreateFileRecursive(n)}};var Q1a=class{modifyBasePaths;enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t,r,n){this.modifyBasePaths=r,this.enableUniqueErrorsPerEndpoint=n,this.root=new Z3n,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 NDr(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,Vzr.basename)(r,(0,Vzr.extname)(r))).replaceAll("__package__","root"));if(t===zs.of(iB))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=D4(Cg(R_.of(`/${t}`)),R_.of(`/${r}`)),n;let i=this.getOrCreateFile(t);return i.imports==null&&(i.imports={}),i.imports[n]=D4(Cg(R_.of(`/${t}`)),R_.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=>Twr(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=Ren(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=Vzr.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=Rk1(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)]:zAf(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:Vzr.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:Vzr.default.join(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===$T?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 Rk1(e){if(e.environments==null)return"";let t=Object.entries(e.environments).flatMap(([r,n])=>typeof n=="string"?[n]:zAf(n)?[n.url]:Object.values(n.urls));return Lk1(t.map(Fk1))}function Fk1(e){try{let r=new URL(e).pathname;return r.endsWith("/")?r.slice(0,-1):r}catch{return""}}function Lk1(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 zAf(e){return e.url!=null}var Z1a=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;defaultServerName=void 0;constructor({taskContext:t,ir:r,enableUniqueErrorsPerEndpoint:n,detectGlobalHeaders:i,environmentOverrides:a,globalHeaderOverrides:u,authOverrides:f}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.builder=new Q1a(r,!1,n),this.detectGlobalHeaders=i,this.environmentOverrides=a,this.authOverrides=f,this.globalHeaderOverrides=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 OOu(e){let t=new Z1a(e);return NAf(t)}var Vne=class extends $Sr{specs;sources;constructor({specs:t,...r}){super(r),this.specs=t,this.sources=this.convertSpecsToIdentifiableSources(t)}async getDefinition({context:t,relativePathToDependency:r},n){var f,d,c,o,l,g,O,j,S;let i=await wen({context:t,specs:this.specs,relativePathToDependency:r}),a=await Ytn({absoluteFilePathToWorkspace:this.absoluteFilePath,specs:i,taskContext:t,optionOverrides:Uk1(n)}),u=OOu({authOverrides:((d=(f=this.generatorsConfiguration)==null?void 0:f.api)==null?void 0:d.auth)!=null?{...(c=this.generatorsConfiguration)==null?void 0:c.api}:void 0,environmentOverrides:((l=(o=this.generatorsConfiguration)==null?void 0:o.api)==null?void 0:l.environments)!=null?{...(g=this.generatorsConfiguration)==null?void 0:g.api}:void 0,globalHeaderOverrides:((j=(O=this.generatorsConfiguration)==null?void 0:O.api)==null?void 0:j.headers)!=null?{...(S=this.generatorsConfiguration)==null?void 0:S.api}:void 0,taskContext:t,ir:a,enableUniqueErrorsPerEndpoint:(n==null?void 0:n.enableUniqueErrorsPerEndpoint)??!1,detectGlobalHeaders:(n==null?void 0:n.detectGlobalHeaders)??!0});return{absoluteFilePath:R_.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:u.rootApiFile["default-url"],contents:u.rootApiFile,rawContents:av.dump(u.rootApiFile)},namedDefinitionFiles:{...Vk1(u.definitionFiles,x=>({absoluteFilepath:R_.of("/DUMMY_PATH"),rawContents:av.dump(x),contents:x})),[zs.of($T)]:{absoluteFilepath:R_.of("/DUMMY_PATH"),rawContents:av.dump(u.packageMarkerFile),contents:u.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new JSr({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(FS)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,n=[];return t.reduce((i,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),i.push({type:a.type,id:Kkr(),absoluteFilePath:u})),i},n)}};function L0i(e){if(e.settings==null)return;let t={detectGlobalHeaders:!0};return e.settings.unions==="v1"&&(t.enableDiscriminatedUnionV2=!0),t}function Uk1(e){if(e==null)return;let t={};return e.enableDiscriminatedUnionV2&&(t.discriminatedUnionV2=!0),e.optionalAdditionalProperties&&(t.optionalAdditionalProperties=!0),t}function Vk1(e,t){return sy(e,t)}function POu(e,t){for(let[r,n]of w4(e.failures))Wk1({relativeFilepath:r,failure:n,logger:t})}function Wk1({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Xw.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 Xw.FILE_READ:r.error("Failed to open file: "+e);break;case Xw.FILE_MISSING:r.error("Missing file: "+e);break;case Xw.FILE_PARSE:t.error instanceof vsi?r.error(Bwr({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Xw.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of Hk1(n))r.error(Bwr({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case Xw.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Xw.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${BGi}: `+t.dependencyName);break;case Xw.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Xw.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;default:fl(t)}}function Hk1(e){switch(e.code){case Yp.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${al.underline(e.expected)} but received ${al.underline(e.received)}`}];case Yp.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${al.underline(t)}`}));case Yp.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>al.underline(t)).join(", ")}`}];case Yp.invalid_union:case Yp.invalid_arguments:case Yp.invalid_return_type:case Yp.invalid_date:case Yp.invalid_string:case Yp.too_small:case Yp.too_big:case Yp.invalid_intersection_types:case Yp.not_multiple_of:case Yp.custom:default:return[{title:e.message}]}}var BAf=require("fs/promises");async function IAf(e,t){let r=[];for(let n of await z8t(e,t))r.push(await $k1({relativeFilepath:D4(e,n),absoluteFilepath:n}));return r}async function $k1({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,BAf.readFile)(t)).toString()}}async function RAf({absolutePathToWorkspace:e}){let t=pf(e,zs.of(mNc));if(!await Vh(t))return;let n=await IAf(t,"{md,mdx}");return{files:await Promise.all(n.map(i=>({absoluteFilepath:i.absoluteFilepath,contents:i.fileContents})))}}async function jOu({absolutePathToWorkspace:e,namespace:t,definitions:r}){var i,a,u,f,d,c,o;let n=[];for(let l of r){let g=l.overrides!=null?pf(e,zs.of(l.overrides)):void 0;if(l.schema.type==="protobuf"){let j=pf(e,zs.of(l.schema.root));if(!await Vh(j))return{didSucceed:!1,failures:{[zs.of(l.schema.root)]:{type:Xw.FILE_MISSING}}};let S=pf(e,zs.of(l.schema.target));if(!await Vh(S))return{didSucceed:!1,failures:{[zs.of(l.schema.target)]:{type:Xw.FILE_MISSING}}};n.push({type:"protobuf",absoluteFilepathToProtobufRoot:j,absoluteFilepathToProtobufTarget:S,absoluteFilepathToOverrides:g,generateLocally:l.schema.localGeneration,settings:{audiences:l.audiences??[],shouldUseTitleAsName:((i=l.settings)==null?void 0:i.shouldUseTitleAsName)??!0,shouldUseUndiscriminatedUnionsWithLiterals:((a=l.settings)==null?void 0:a.shouldUseUndiscriminatedUnionsWithLiterals)??!1,optionalAdditionalProperties:((u=l.settings)==null?void 0:u.shouldUseOptionalAdditionalProperties)??!0}});continue}let O=pf(e,zs.of(l.schema.path));if(!await Vh(O))return{didSucceed:!1,failures:{[zs.of(l.schema.path)]:{type:Xw.FILE_MISSING}}};if(l.overrides!=null&&g!=null&&!await Vh(g))return{didSucceed:!1,failures:{[zs.of(l.overrides)]:{type:Xw.FILE_MISSING}}};n.push({type:"openapi",absoluteFilepath:O,absoluteFilepathToOverrides:g,settings:{audiences:l.audiences??[],shouldUseTitleAsName:((f=l.settings)==null?void 0:f.shouldUseTitleAsName)??!0,shouldUseUndiscriminatedUnionsWithLiterals:((d=l.settings)==null?void 0:d.shouldUseUndiscriminatedUnionsWithLiterals)??!1,asyncApiNaming:(c=l.settings)==null?void 0:c.asyncApiMessageNaming,optionalAdditionalProperties:((o=l.settings)==null?void 0:o.shouldUseOptionalAdditionalProperties)??!0},source:{type:"openapi",file:O},namespace:t})}return n}async function U0i({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:n}){let i=await pg.loadGeneratorsConfiguration({absolutePathToWorkspace:e,context:t}),a;try{a=await RAf({absolutePathToWorkspace:e})}catch{}if((i==null?void 0:i.api)!=null&&(i.api.type==="singleNamespace"&&i.api.definitions.length>0||i.api.type==="multiNamespace")){let u=[];if(i.api.type==="singleNamespace"){let f=await jOu({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.definitions});if(!Array.isArray(f))return f;u.push(...f)}else{for(let[f,d]of Object.entries(i.api.definitions)){let c=await jOu({absolutePathToWorkspace:e,namespace:f,definitions:d});if(!Array.isArray(c))return c;u.push(...c)}if(i.api.rootDefinitions!=null){let f=await jOu({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.rootDefinitions});if(!Array.isArray(f))return f;u.push(...f)}}return{didSucceed:!0,workspace:new Vne({specs:u,workspaceName:n,absoluteFilePath:e,generatorsConfiguration:i,changelog:a,cliVersion:r})}}if(await Vh(pf(e,zs.of(p9)))){let u=new P7n({absoluteFilePath:e,generatorsConfiguration:i,workspaceName:n,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:U0i});return{didSucceed:!0,workspace:u}}return{didSucceed:!1,failures:{[zs.of(HXr)]:{type:Xw.MISCONFIGURED_DIRECTORY}}}}var FAf=require("fs/promises");var LAf=yu(require("path"),1);async function wOu({fernDirectory:e,context:t}){let r=pf(e,zs.of(qwr));if(!await Vh(r))return;let n=await Jk1({absolutePathToDocsDefinition:e,context:t});if(n!=null)return{type:"docs",absoluteFilePath:e,config:n,workspaceName:void 0,absoluteFilepathToDocsConfig:pf(e,zs.of(qwr))}}async function Jk1({absolutePathToDocsDefinition:e,context:t}){if(!await Vh(e))return;let r=pf(e,zs.of(qwr));return await Gk1({absolutePathOfConfiguration:r,context:t})}async function Gk1({absolutePathOfConfiguration:e,context:t}){let r=await(0,FAf.readFile)(e),n=av.load(r.toString());return await Kk1({value:n,context:t,filepathBeingParsed:e})}async function Kk1({value:e,context:t,filepathBeingParsed:r}){let n=await Pre.RawSchemas.Serializer.DocsConfiguration.parse(e);if(n.ok)return n.value;let i=n.errors.map(u=>{let f=u.path.length>0?`${u.message} at "${u.path.join(" -> ")}"`:u.message;return VX({content:f,prefix:" - "})}),a=[`Failed to parse file: ${LAf.default.relative(process.cwd(),r)}`,...i].join(`
1916
+ `)),{ok:!0,value:t}):n}}function p0a(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var P5r=class extends Error{errors;constructor(t){super(t.map(p0a).join("; ")),this.errors=t,Object.setPrototypeOf(this,P5r.prototype)}};var j5r=class extends Error{errors;constructor(t){super(t.map(p0a).join("; ")),this.errors=t,Object.setPrototypeOf(this,j5r.prototype)}};function hA(e){return{optional:()=>ffu(e),transform:t=>dfu(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new j5r(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new P5r(n.errors)}}}function ffu(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:()=>WS.OPTIONAL};return{...t,...hA(t)}}function dfu(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 Ab1=/^([+-]?\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 Jpf(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:rC(t,"string")}]}:Ab1.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:()=>WS.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 _0a(e){let t=new Set(e);return XJ(WS.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 Gpf(e){let t=pfu(e);return{...t,...hA(t)}}function pfu(e){return{parse:(t,r)=>D7n(e).parse(t,r),json:(t,r)=>D7n(e).json(t,r),getType:()=>D7n(e).getType()}}function D7n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function z_i(e){return Object.entries(e)}function B_i(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function w5r(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 I_i(e){return Object.keys(e)}function Kpf(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function zRt(e){return{withParsedProperties:t=>_fu(e,t)}}function _fu(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(!w5r(n))return{ok:!1,errors:[{path:(i==null?void 0:i.breadcrumbsPrefix)??[],message:rC(n,"object")}]};let a=new Set(Object.keys(t)),u=B_i(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...hA(r),...zRt(r)}}function Ypf(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function D5r(e){return e.isProperty}function h0a(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>D5r(n)?n.rawKey:r),_getParsedProperties:()=>I_i(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of z_i(e)){let d=D5r(f)?f.rawKey:u,c=D5r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,Zpf(c)&&a.push(d)}return Xpf({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 z_i(e)){let f=D5r(u)?u.valueSchema:u;Zpf(f)&&i.push(a)}return Xpf({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return D5r(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:()=>WS.OBJECT};return{...YJ(t),...hA(t),...zRt(t),...S7n(t)}}function Xpf({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!w5r(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 S7n(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>Qpf({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>Qpf({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>WS.OBJECT};return{...r,...hA(r),...zRt(r),...S7n(r)}}}}function Qpf({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=Kpf(I_i(t),c=>i.has(c)),f=r(B_i(t,u)),d=n(B_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 Zpf(e){return!Nb1(e)}function Nb1(e){switch(e.getType()){case WS.ANY:case WS.UNKNOWN:case WS.OPTIONAL:return!0;default:return!1}}function kpf(e){return h0a(e)}function e_f(e){let t={...pfu(e),_getRawProperties:()=>D7n(e)._getRawProperties(),_getParsedProperties:()=>D7n(e)._getParsedProperties()};return{...t,...hA(t),...zRt(t),...S7n(t)}}function y0a(e){let t={parse:(r,n)=>t_f(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],`[${a}]`]})),json:(r,n)=>t_f(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],`[${a}]`]})),getType:()=>WS.LIST};return{...YJ(t),...hA(t)}}function t_f(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 r_f(e){return XJ(WS.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:rC(r,`"${e}"`)}]})()}function n_f(e){return XJ(WS.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:rC(r,`${e.toString()}`)}]})()}var i_f=XJ(WS.ANY,e=>({ok:!0,value:e}));var a_f=XJ(WS.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"boolean")}]});var o_f=XJ(WS.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"number")}]});var u_f=XJ(WS.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"string")}]});var s_f=XJ(WS.UNKNOWN,e=>({ok:!0,value:e}));function l_f(e,t){let r={parse:(n,i)=>c_f({value:n,isKeyNumeric:e.getType()===WS.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)=>c_f({value:n,isKeyNumeric:e.getType()===WS.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:()=>WS.RECORD};return{...YJ(r),...hA(r)}}function c_f({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return w5r(e)?z_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 f_f(e){let t=y0a(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:()=>WS.SET};return{...YJ(r),...hA(r)}}function p_f(e){let t={parse:(r,n)=>d_f((i,a)=>i.parse(r,a),e,n),json:(r,n)=>d_f((i,a)=>i.json(r,a),e,n),getType:()=>WS.UNDISCRIMINATED_UNION};return{...YJ(t),...hA(t)}}function d_f(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 __f(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function y_f(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=_0a(I_i(t)),a={parse:(u,f)=>h_f({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)=>h_f({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:()=>WS.UNION};return{...YJ(a),...hA(a),...zRt(a)}}function h_f({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!w5r(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 v0a=Wn.objectWithoutOptionalProperties({file:Wn.string()});var b0a=Wn.objectWithoutOptionalProperties({file:Wn.string()});var g0a=Wn.union("type",{openapi:v0a,protobuf:b0a}).transform({transform:e=>{switch(e.type){case"openapi":return KSr.openapi(e);case"protobuf":return KSr.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var hb=Wn.objectWithoutOptionalProperties({source:g0a.optional()});var m0a=Wn.objectWithoutOptionalProperties({typeName:Wn.string()});var O0a=Wn.union("type",{protobuf:m0a}).transform({transform:e=>{switch(e.type){case"protobuf":return j7n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ene=Wn.objectWithoutOptionalProperties({encoding:O0a.optional()});var P_=Wn.objectWithoutOptionalProperties({description:Wn.string().optional()});var P0a=Wn.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Z0=Wn.objectWithoutOptionalProperties({availability:P0a.optional()});var Ym=Wn.objectWithoutOptionalProperties({nameOverride:Wn.string().optional(),generatedName:Wn.string()});var wQ=Wn.string();var Yje=Wn.string();var j0a=Wn.objectWithoutOptionalProperties({id:Yje}).extend(P_);var w0a=Wn.string();var D0a=Wn.objectWithoutOptionalProperties({usernameVariableName:Wn.string().optional(),usernameEnvVar:Wn.string().optional(),passwordVariableName:Wn.string().optional(),passwordEnvVar:Wn.string().optional()});var S0a=Wn.objectWithoutOptionalProperties({tokenVariableName:Wn.string().optional(),tokenEnvVar:Wn.string().optional()});var E0a=Wn.objectWithoutOptionalProperties({headerName:Wn.string(),prefix:Wn.string().optional(),headerVariableName:Wn.string().optional(),headerEnvVar:Wn.string().optional()});var M0a=Wn.objectWithoutOptionalProperties({queryParameterName:Wn.string()});var x0a=Wn.objectWithoutOptionalProperties({snake:Wn.string().optional(),camel:Wn.string().optional(),screamingSnake:Wn.string().optional(),pascal:Wn.string().optional()});var S5r=Wn.objectWithoutOptionalProperties({nameOverride:Wn.string().optional(),generatedName:Wn.string(),value:Wn.string(),casing:x0a.optional()}).extend(P_).extend(Z0);var T0a=Wn.objectWithoutOptionalProperties({type:Wn.stringLiteral("namespace"),name:Wn.string()});var q0a=Wn.undiscriminatedUnion([Wn.string(),T0a]);var E5r=Wn.list(q0a);var w1=Wn.objectWithoutOptionalProperties({groupName:E5r.optional()});var E7n=Wn.objectWithoutOptionalProperties({default:S5r.optional(),values:Wn.list(S5r)}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var C0a=Wn.objectWithoutOptionalProperties({scopesEnum:E7n.optional()});var A0a=Wn.union("type",{basic:D0a,bearer:S0a,header:E0a,query:M0a,oauth:C0a}).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 M5r=Wn.number();var N0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),url:Wn.string(),audiences:Wn.list(Wn.string()).optional()}).extend(P_);var z0a=Wn.string();var x5r=Wn.objectWithoutOptionalProperties({namespace:Wn.string().optional()});var yfu={};Wb(yfu,{FullExample:()=>yA,FullObjectExample:()=>I0a,FullOneOfExample:()=>F0a,KeyValuePair:()=>R0a,LiteralExample:()=>B0a,PrimitiveExample:()=>x7n,PropertyKey:()=>M7n});var M7n=Wn.string();var x7n=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 B0a=Wn.union("type",{boolean:Wn.object({value:Wn.boolean()}),string:Wn.object({value:Wn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return w7n.boolean(e.value);case"string":return w7n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var yA=Wn.union("type",{primitive:Wn.object({value:x7n}),object:Wn.lazyObject(()=>I0a),array:Wn.object({value:Wn.list(Wn.lazy(()=>yA))}),map:Wn.object({value:Wn.list(Wn.lazyObject(()=>R0a))}),enum:Wn.object({value:Wn.string()}),literal:Wn.object({value:B0a}),oneOf:Wn.object({value:Wn.lazy(()=>F0a)}),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 I0a=Wn.objectWithoutOptionalProperties({properties:Wn.record(M7n,Wn.lazy(()=>yA))});var R0a=Wn.objectWithoutOptionalProperties({key:x7n,value:Wn.lazy(()=>yA)});var F0a=Wn.union("type",{discriminated:Wn.object({value:Wn.record(M7n,Wn.lazy(()=>yA))}),undisciminated:Wn.object({value:Wn.lazy(()=>yA)})}).transform({transform:e=>{switch(e.type){case"discriminated":return m5r.discriminated(e.value);case"undisciminated":return m5r.undisciminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var vfu={};Wb(vfu,{AllOfPropertyConflict:()=>V7n,ArraySchema:()=>wva,Availability:()=>P0a,BooleanSchema:()=>bva,CasingOverrides:()=>x0a,CommonProperty:()=>Cva,CursorPagination:()=>nva,CustomCodeSample:()=>tva,CustomCodeSampleLanguage:()=>Z0a,CustomCodeSampleSdk:()=>eva,DiscriminatedOneOfSchema:()=>Tva,DoubleSchema:()=>yva,Endpoint:()=>ava,EndpointExample:()=>F7n,EndpointSdkName:()=>q5r,EnumSchema:()=>E7n,EnumValue:()=>S5r,ErrorExample:()=>K0a,FernExample:()=>X0a,FileResponse:()=>z7n,FileSchema:()=>V0a,FullEndpointExample:()=>rva,GlobalHeader:()=>mva,Header:()=>T5r,HeaderExample:()=>R7n,HttpEndpointServer:()=>B7n,HttpError:()=>Y0a,HttpMethod:()=>T7n,IdempotencyHeader:()=>Ova,IntSchema:()=>_va,JsonRequest:()=>$0a,JsonResponse:()=>ZSr,LiteralSchema:()=>U7n,LiteralSchemaValue:()=>Pva,LongSchema:()=>hva,MapSchema:()=>Dva,MultipartRequest:()=>N7n,MultipartRequestProperty:()=>H0a,MultipartSchema:()=>W0a,NullableSchema:()=>Eva,ObjectProperty:()=>xva,ObjectPropertyConflictInfo:()=>W7n,ObjectSchema:()=>jva,OctetStreamRequest:()=>A7n,OffsetPagination:()=>iva,OneOfSchema:()=>Mva,OpenApiIntermediateRepresentation:()=>v_f,OptionalSchema:()=>Sva,Pagination:()=>L7n,PathParameter:()=>q7n,PathParameterExample:()=>Q0a,PrimitiveSchema:()=>A5r,PrimitiveSchemaValue:()=>gva,QueryParameter:()=>C7n,QueryParameterExample:()=>I7n,ReferencedSchema:()=>BRt,Request:()=>J0a,Response:()=>G0a,Schema:()=>D1,Schemas:()=>pva,SdkGroupInfo:()=>L0a,StringSchema:()=>vva,SupportedSdkLanguage:()=>k0a,Tags:()=>U0a,TextResponse:()=>C5r,UnDiscriminatedOneOfSchema:()=>qva,Webhook:()=>sva,WebhookExampleCall:()=>uva,WebhookHttpMethod:()=>ova,WebsocketChannel:()=>dva,WebsocketHandshake:()=>cva,WebsocketMessageExample:()=>lva,WebsocketSessionExample:()=>fva});var L0a=Wn.objectWithoutOptionalProperties({summary:Wn.string().optional(),description:Wn.string().optional()});var U0a=Wn.objectWithoutOptionalProperties({tagsById:Wn.record(Yje,j0a),orderedTagIds:Wn.list(Yje).optional()});var T7n=Wn.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var q7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),variableReference:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(P_).extend(Z0).extend(hb);var C7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),parameterNameOverride:Wn.string().optional()}).extend(P_).extend(Z0).extend(hb);var T5r=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),env:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(P_).extend(Z0).extend(hb);var q5r=Wn.objectWithoutOptionalProperties({groupName:E5r,methodName:Wn.string()});var A7n=Wn.objectWithoutOptionalProperties({}).extend(P_).extend(hb);var V0a=Wn.objectWithoutOptionalProperties({isOptional:Wn.boolean(),isArray:Wn.boolean()});var W0a=Wn.union("type",{file:V0a,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 H0a=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:W0a,contentType:Wn.string().optional()}).extend(P_);var N7n=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),properties:Wn.list(H0a)}).extend(P_).extend(hb);var $0a=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1),contentType:Wn.string().optional(),additionalProperties:Wn.boolean()}).extend(P_).extend(hb);var J0a=Wn.union("type",{octetStream:A7n,multipart:N7n,json:$0a}).transform({transform:e=>{switch(e.type){case"octetStream":return O5r.octetStream(e);case"multipart":return O5r.multipart(e);case"json":return O5r.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var z7n=Wn.objectWithoutOptionalProperties({}).extend(P_).extend(hb);var ZSr=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1),responseProperty:Wn.string().optional()}).extend(P_).extend(hb);var C5r=Wn.objectWithoutOptionalProperties({}).extend(P_).extend(hb);var G0a=Wn.union("type",{file:z7n,json:ZSr,text:C5r,streamingSse:ZSr,streamingText:C5r,streamingJson:ZSr}).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 K0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),description:Wn.string().optional(),example:Wn.lazy(()=>yA)});var Y0a=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1).optional(),examples:Wn.list(K0a).optional()}).extend(P_).extend(Ym).extend(hb);var B7n=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),url:Wn.string().optional(),audiences:Wn.list(Wn.string()).optional()});var X0a=Wn.unknown();var Q0a=Wn.objectWithoutOptionalProperties({name:Wn.string(),parameterNameOverride:Wn.string().optional(),value:Wn.lazy(()=>yA)});var I7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),value:Wn.lazy(()=>yA)});var R7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),value:Wn.lazy(()=>yA)});var Z0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),language:Wn.string(),code:Wn.string(),install:Wn.string().optional()}).extend(P_);var k0a=Wn.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var eva=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),sdk:k0a,code:Wn.string()}).extend(P_);var tva=Wn.union("type",{language:Z0a,sdk:eva}).transform({transform:e=>{switch(e.type){case"language":return XSr.language(e);case"sdk":return XSr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var rva=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),pathParameters:Wn.list(Q0a).optional(),queryParameters:Wn.list(I7n).optional(),headers:Wn.list(R7n).optional(),request:Wn.lazy(()=>yA).optional(),response:Wn.lazy(()=>yA).optional(),codeSamples:Wn.list(tva)}).extend(P_);var F7n=Wn.union("type",{unknown:Wn.object({value:X0a}),full:rva}).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 nva=Wn.objectWithoutOptionalProperties({cursor:Wn.string(),nextCursor:Wn.property("next_cursor",Wn.string()),results:Wn.string()});var iva=Wn.objectWithoutOptionalProperties({offset:Wn.string(),results:Wn.string(),step:Wn.string().optional(),hasNextPage:Wn.string().optional()});var L7n=Wn.union("type",{cursor:nva,offset:iva}).transform({transform:e=>{switch(e.type){case"cursor":return YSr.cursor(e);case"offset":return YSr.offset(e);default:return e}},untransform:({_visit:e,...t})=>t});var ava=Wn.objectWithoutOptionalProperties({authed:Wn.boolean(),internal:Wn.boolean().optional(),idempotent:Wn.boolean().optional(),method:T7n,audiences:Wn.list(Wn.string()),path:Wn.string(),summary:Wn.string().optional(),operationId:Wn.string().optional(),tags:Wn.list(Yje),pathParameters:Wn.list(q7n),queryParameters:Wn.list(C7n),headers:Wn.list(T5r),sdkName:q5r.optional(),generatedRequestName:Wn.string(),requestNameOverride:Wn.string().optional(),request:J0a.optional(),response:G0a.optional(),errors:Wn.record(M5r,Y0a),server:Wn.list(B7n),examples:Wn.list(F7n),pagination:L7n.optional()}).extend(P_).extend(Z0).extend(hb).extend(x5r);var ova=Wn.enum_(["GET","POST"]);var uva=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),payload:Wn.lazy(()=>yA)}).extend(P_);var sva=Wn.objectWithoutOptionalProperties({sdkName:q5r.optional(),method:ova,summary:Wn.string().optional(),operationId:Wn.string(),tags:Wn.list(Yje),headers:Wn.list(T5r),generatedPayloadName:Wn.string(),payload:Wn.lazy(()=>D1),examples:Wn.list(uva)}).extend(P_).extend(hb).extend(x5r);var cva=Wn.objectWithoutOptionalProperties({queryParameters:Wn.list(C7n),headers:Wn.list(T5r),pathParameters:Wn.list(q7n)});var lva=Wn.objectWithoutOptionalProperties({messageType:Wn.string(),payload:Wn.lazy(()=>yA)}).extend(P_);var fva=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),queryParameters:Wn.list(I7n).optional(),headers:Wn.list(R7n).optional(),messages:Wn.list(lva)}).extend(P_);var dva=Wn.objectWithoutOptionalProperties({path:Wn.string(),groupName:E5r,summary:Wn.string().optional(),handshake:cva,publish:Wn.lazy(()=>D1).optional(),subscribe:Wn.lazy(()=>D1).optional(),examples:Wn.list(fva)}).extend(P_).extend(hb);var pva=Wn.objectWithoutOptionalProperties({rootSchemas:Wn.record(wQ,Wn.lazy(()=>D1)),namespacedSchemas:Wn.record(z0a,Wn.record(wQ,Wn.lazy(()=>D1)))});var _va=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 hva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional()});var yva=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 vva=Wn.objectWithoutOptionalProperties({default:Wn.string().optional(),pattern:Wn.string().optional(),format:Wn.string().optional(),minLength:Wn.number().optional(),maxLength:Wn.number().optional()});var bva=Wn.objectWithoutOptionalProperties({default:Wn.boolean().optional()});var gva=Wn.union("type",{int:_va,int64:hva,uint:Wn.object({}),uint64:Wn.object({}),float:Wn.object({}),double:yva,string:vva,datetime:Wn.object({}),date:Wn.object({}),base64:Wn.object({}),boolean:bva}).transform({transform:e=>{switch(e.type){case"int":return Qw.int(e);case"int64":return Qw.int64(e);case"uint":return Qw.uint();case"uint64":return Qw.uint64();case"float":return Qw.float();case"double":return Qw.double(e);case"string":return Qw.string(e);case"datetime":return Qw.datetime();case"date":return Qw.date();case"base64":return Qw.base64();case"boolean":return Qw.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var A5r=Wn.objectWithoutOptionalProperties({schema:gva}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(j1);var mva=Wn.objectWithoutOptionalProperties({header:Wn.string(),name:Wn.string().optional(),optional:Wn.boolean().optional(),env:Wn.string().optional(),schema:Wn.lazy(()=>D1).optional()});var Ova=Wn.objectWithoutOptionalProperties({header:Wn.string(),name:Wn.string().optional(),env:Wn.string().optional(),schema:Wn.lazy(()=>D1).optional()});var v_f=Wn.objectWithoutOptionalProperties({apiVersion:Wn.unknown().optional(),title:Wn.string().optional(),description:Wn.string().optional(),basePath:Wn.string().optional(),servers:Wn.list(N0a),groups:Wn.record(Wn.string(),L0a),tags:U0a,hasEndpointsMarkedInternal:Wn.boolean(),endpoints:Wn.list(ava),webhooks:Wn.list(sva),channel:Wn.list(dva),groupedSchemas:pva,variables:Wn.record(Wn.string(),A5r),nonRequestReferencedSchemas:Wn.set(wQ),securitySchemes:Wn.record(w0a,A0a),globalHeaders:Wn.list(mva).optional(),idempotencyHeaders:Wn.list(Ova).optional()});var BRt=Wn.objectWithoutOptionalProperties({schema:wQ}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var Pva=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 U7n=Wn.objectWithoutOptionalProperties({value:Pva}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(j1);var D1=Wn.union("type",{primitive:A5r,object:Wn.lazyObject(()=>jva),array:Wn.lazyObject(()=>wva),map:Wn.lazyObject(()=>Dva),optional:Wn.lazyObject(()=>Sva),enum:E7n,reference:BRt,literal:U7n,oneOf:Wn.object({value:Wn.lazy(()=>Mva)}),nullable:Wn.lazyObject(()=>Eva),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 V7n=Wn.objectWithoutOptionalProperties({propertyKey:Wn.string(),allOfSchemaIds:Wn.list(wQ),conflictingTypeSignatures:Wn.boolean()});var jva=Wn.objectWithoutOptionalProperties({allOf:Wn.list(BRt),properties:Wn.list(Wn.lazyObject(()=>xva)),allOfPropertyConflicts:Wn.list(V7n),additionalProperties:Wn.boolean()}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var W7n=Wn.objectWithoutOptionalProperties({differentSchema:Wn.boolean()});var xva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>D1),conflict:Wn.record(wQ,W7n),generatedName:Wn.string(),nameOverride:Wn.string().optional(),audiences:Wn.list(Wn.string())}).extend(Z0);var wva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(j1);var Dva=Wn.objectWithoutOptionalProperties({key:A5r,value:Wn.lazy(()=>D1)}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(j1);var Sva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(j1);var Eva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(j1);var Mva=Wn.union("type",{discriminated:Wn.lazyObject(()=>Tva),undisciminated:Wn.lazyObject(()=>qva)}).transform({transform:e=>{switch(e.type){case"discriminated":return QSr.discriminated(e);case"undisciminated":return QSr.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Tva=Wn.objectWithoutOptionalProperties({discriminantProperty:Wn.string(),commonProperties:Wn.list(Wn.lazyObject(()=>Cva)),schemas:Wn.record(Wn.string(),Wn.lazy(()=>D1))}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var Cva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>D1)});var qva=Wn.objectWithoutOptionalProperties({schemas:Wn.list(Wn.lazy(()=>D1))}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var bfu={};Wb(bfu,{ArraySchemaWithExample:()=>kva,Base64WithExample:()=>Kva,BooleanWithExample:()=>Yva,CommonPropertyWithExample:()=>sba,DateWithExample:()=>Gva,DatetimeWithExample:()=>Jva,DiscriminatedOneOfSchemaWithExample:()=>oba,DoubleWithExample:()=>Hva,EndpointWithExample:()=>g_f,EnumSchemaWithExample:()=>Qva,FloatWithExample:()=>Wva,HeaderWithExample:()=>$7n,HttpErrorWithExample:()=>Rva,Int64WithExample:()=>Lva,IntWithExample:()=>Fva,JsonRequestWithExample:()=>Nva,JsonResponseWithExample:()=>Bva,MapSchemaWithExample:()=>eba,NamedFullExample:()=>IRt,NullableSchemaWithExample:()=>rba,ObjectPropertyWithExample:()=>aba,ObjectSchemaWithExample:()=>nba,OneOfSchemaWithExample:()=>iba,OptionalSchemaWithExample:()=>tba,PathParameterWithExample:()=>Ava,PrimitiveSchemaValueWithExample:()=>Xva,PrimitiveSchemaWithExample:()=>J7n,QueryParameterWithExample:()=>H7n,RequestWithExample:()=>zva,ResponseWithExample:()=>Iva,SchemaWithExample:()=>oq,StringSchemaWithExample:()=>$va,Uint64WithExample:()=>Vva,UintWithExample:()=>Uva,UnDiscriminatedOneOfSchemaWithExample:()=>uba,UnknownSchemaWithExample:()=>Zva,WebsocketHandshakeWithExample:()=>b_f});var IRt=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),value:Wn.unknown()}).extend(P_);var H7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>oq),parameterNameOverride:Wn.string().optional()}).extend(P_).extend(Z0).extend(hb);var $7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>oq),env:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(P_).extend(Z0).extend(hb);var b_f=Wn.objectWithoutOptionalProperties({queryParameters:Wn.list(H7n),headers:Wn.list($7n)});var Ava=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>oq),variableReference:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(P_).extend(Z0).extend(hb);var Nva=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>oq),contentType:Wn.string().optional(),fullExamples:Wn.list(IRt).optional(),additionalProperties:Wn.boolean()}).extend(P_).extend(hb);var zva=Wn.union("type",{octetStream:A7n,multipart:N7n,json:Nva}).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 Bva=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>oq),responseProperty:Wn.string().optional(),fullExamples:Wn.list(IRt).optional()}).extend(P_).extend(hb);var Iva=Wn.union("type",{file:z7n,json:Bva,text:C5r,streamingSse:ZSr,streamingText:C5r,streamingJson:ZSr}).transform({transform:e=>{switch(e.type){case"file":return q3.file(e);case"json":return q3.json(e);case"text":return q3.text(e);case"streamingSse":return q3.streamingSse(e);case"streamingText":return q3.streamingText(e);case"streamingJson":return q3.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Rva=Wn.objectWithoutOptionalProperties({statusCode:M5r,schema:Wn.lazy(()=>oq),fullExamples:Wn.list(IRt).optional()}).extend(P_).extend(Ym).extend(hb);var g_f=Wn.objectWithoutOptionalProperties({authed:Wn.boolean(),internal:Wn.boolean().optional(),idempotent:Wn.boolean().optional(),method:T7n,audiences:Wn.list(Wn.string()),path:Wn.string(),summary:Wn.string().optional(),operationId:Wn.string().optional(),tags:Wn.list(Yje),pathParameters:Wn.list(Ava),queryParameters:Wn.list(H7n),headers:Wn.list($7n),sdkName:q5r.optional(),generatedRequestName:Wn.string(),requestNameOverride:Wn.string().optional(),request:zva.optional(),response:Iva.optional(),errors:Wn.record(M5r,Rva),server:Wn.list(B7n),examples:Wn.list(F7n),pagination:L7n.optional()}).extend(P_).extend(Z0).extend(hb).extend(x5r);var Fva=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 Lva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var Uva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var Vva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var Wva=Wn.objectWithoutOptionalProperties({example:Wn.number().optional()});var Hva=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 $va=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 Jva=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var Gva=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var Kva=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var Yva=Wn.objectWithoutOptionalProperties({default:Wn.boolean().optional(),example:Wn.boolean().optional()});var Xva=Wn.union("type",{int:Fva,int64:Lva,uint:Uva,uint64:Vva,float:Wva,double:Hva,string:$va,datetime:Jva,date:Gva,base64:Kva,boolean:Yva}).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 J7n=Wn.objectWithoutOptionalProperties({schema:Xva}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(j1);var Qva=Wn.objectWithoutOptionalProperties({default:S5r.optional(),values:Wn.list(S5r),example:Wn.string().optional()}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var Zva=Wn.objectWithoutOptionalProperties({example:Wn.unknown()}).extend(w1).extend(Ym).extend(P_).extend(Z0).extend(j1);var oq=Wn.union("type",{primitive:J7n,object:Wn.lazyObject(()=>nba),array:Wn.lazyObject(()=>kva),map:Wn.lazyObject(()=>eba),optional:Wn.lazyObject(()=>tba),enum:Qva,reference:BRt,literal:U7n,oneOf:Wn.object({value:Wn.lazy(()=>iba)}),nullable:Wn.lazyObject(()=>rba),unknown:Zva}).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 kva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>oq),example:Wn.list(Wn.unknown()).optional()}).extend(w1).extend(Ym).extend(P_).extend(Z0).extend(j1);var eba=Wn.objectWithoutOptionalProperties({key:J7n,value:Wn.lazy(()=>oq),example:Wn.unknown().optional()}).extend(w1).extend(Ym).extend(P_).extend(Z0).extend(Ene).extend(j1);var tba=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>oq)}).extend(w1).extend(Ym).extend(P_).extend(Z0).extend(j1);var rba=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>oq)}).extend(w1).extend(Ym).extend(P_).extend(Z0).extend(j1);var nba=Wn.objectWithoutOptionalProperties({allOf:Wn.list(BRt),properties:Wn.list(Wn.lazyObject(()=>aba)),allOfPropertyConflicts:Wn.list(V7n),fullExamples:Wn.list(IRt).optional(),additionalProperties:Wn.boolean()}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var aba=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>oq),audiences:Wn.list(Wn.string()),conflict:Wn.record(wQ,W7n),nameOverride:Wn.string().optional(),generatedName:Wn.string()}).extend(Z0);var iba=Wn.union("type",{discriminated:Wn.lazyObject(()=>oba),undisciminated:Wn.lazyObject(()=>uba)}).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 oba=Wn.objectWithoutOptionalProperties({discriminantProperty:Wn.string(),commonProperties:Wn.list(Wn.lazyObject(()=>sba)),schemas:Wn.record(Wn.string(),Wn.lazy(()=>oq))}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var sba=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>oq)});var uba=Wn.objectWithoutOptionalProperties({schemas:Wn.list(Wn.lazy(()=>oq))}).extend(P_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);function cba(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:fl(e.type)}}function G7n(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:fl(e)}}function N2(e){return typeof e=="string"?e:e.type}function R_i(e){if(typeof e!="string")return e.docs}function m_f(e){if(typeof e!="string")return e.default}function O_f(e){if(typeof e!="string")return e.validation}function zb1(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 P_f(e){let t=e?zb1(e):void 0;if(t==null||t.length===0)return Jui;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,Jui);break}default:fl(i.type)}else fl(i);return r.join("/")}function K7n(e){return zs.of(`${P_f(e)}.yml`)}function gfu({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Jui:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,P_f(r))}function j_f({sdkName:e,namespaceOverride:t}){return zs.of(`${gfu({sdkName:e,namespaceOverride:t})}.yml`)}function w_f({location:e,namespaceOverride:t}){return t!=null?pf(zs.of(t),e):e}function C3(e){switch(e){case vW.Deprecated:return"deprecated";case vW.Beta:return"pre-release";case vW.GenerallyAvailable:return"generally-available";default:return}}var Bb1=-2147483648,Ib1=2147483647,Rb1=-17976931348623157e292,Fb1=17976931348623157e292;function S1({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i}){switch(e.type){case"primitive":return lba(e);case"array":return Pfu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"map":return jfu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"reference":return Ofu({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return Dfu();case"optional":case"nullable":return wfu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"enum":return Kb1({schema:e,fileContainingReference:t,context:n,declarationFile:r});case"literal":return e.value,Sfu(e);case"object":return Yb1({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"oneOf":return Xb1({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i});default:fl(e)}}function lba(e){switch(e.schema.type){case"string":return Vb1({description:e.description,schema:e.schema});case"int":return Wb1({description:e.description,schema:e.schema});case"float":return Hb1({description:e.description,schema:e.schema});case"double":return $b1({description:e.description,schema:e.schema});case"boolean":return Lb1({description:e.description,schema:e.schema});case"int64":return Ub1({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:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:C3(e.availability)}:{}}}function Lb1({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 Ub1({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 Vb1({description:e,schema:t}){let r="string",n=Jb1(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 Wb1({description:e,schema:t}){let r="integer",n=D_f(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 Hb1({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function $b1({description:e,schema:t}){let r="double",n=D_f(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 Jb1(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=Gb1(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function Gb1(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 D_f(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=mfu(r,t),n=mfu(n,t),i=mfu(i,t),!(r==null&&n==null&&a==null&&u==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:u,multipleOf:i}}function mfu(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[Bb1,Ib1]:[Rb1,Fb1];return e<r||e>n?void 0:e}function Ofu({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=Qb1(i)??e.schema,u=G7n(i),f=Zb1(i),d=fba({context:r,fileContainingReference:t,declarationFile:K7n(u),type:a}),c=i.type==="nullable"?`optional<${d}>`:d;return e.description==null&&f==null?c:{type:i.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:C3(e.availability)}:{}}}function Pfu({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<${N2(a)}>`;return e.description==null&&e.title==null?u:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:C3(e.availability)}:{},type:u}}function jfu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=lba(e.key),u=S1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),f=e.encoding!=null?cba(e.encoding):void 0,d=`map<${N2(a)}, ${N2(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.availability!=null&&(c.availability=C3(e.availability)),c}function wfu({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=N2(a),f=R_i(a),d=m_f(a),c=O_f(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.availability!=null&&(l.availability=C3(e.availability)),l}function Dfu(){return"unknown"}function Sfu(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:fl(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:C3(e.availability)}:{}}}function Kb1({schema:e,fileContainingReference:t,declarationFile:r,context:n}){let i=F_i(e),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:i.schema});let u=fba({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.availability!=null&&(f.availability=C3(e.availability)),f}function Yb1({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Efu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=fba({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:C3(e.availability)}:{}}}function Xb1({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Mfu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=fba({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:C3(e.availability)}:{}}}function fba({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 Qb1(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 Zb1(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 Ren(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:fl(e)}}function E_f({schema:e,context:t,declarationFile:r,namespace:n}){switch(e.type){case"primitive":return tg1(e);case"array":return kb1({schema:e,context:t,declarationFile:r,namespace:n});case"map":return eg1({schema:e,context:t,declarationFile:r,namespace:n});case"reference":return rg1({schema:e,context:t,declarationFile:r,namespace:n});case"unknown":return ig1(e.nameOverride,e.generatedName);case"optional":case"nullable":return ng1({schema:e,context:t,declarationFile:r,namespace:n});case"enum":return F_i(e);case"literal":return ag1(e,e.nameOverride,e.generatedName);case"object":return Efu({schema:e,context:t,declarationFile:r,namespace:n});case"oneOf":return Mfu({schema:e.value,context:t,declarationFile:r,namespace:n});default:fl(e)}}function Efu({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])=>{xfu({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=C3(c.availability);i[c.key]=sg1(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=M_f({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(N2(l))}for(let c of a){let o=Tfu(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(N2(g))}}let d={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(i).map(([c,o])=>ug1(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=C3(e.availability)),e.source!=null&&(d.source=Ren(e.source)),{name:e.nameOverride??e.generatedName,schema:d}}function xfu({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return xfu({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:u}=Tfu(r,t,n),f=a.some(c=>c.key===e),d=[...u.flatMap(c=>xfu({property:e,context:r,schemaId:c.schema,namespace:n}))];if(f||d.length>0)return[t,...d]}return[]}function Tfu(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 Tfu(e,n.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${n.type}`)}function kb1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Pfu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function eg1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:jfu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function tg1(e){let t=lba(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 S_f(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function F_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||S_f(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&&!S_f(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?Ren(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 rg1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Ofu({schema:e,context:t,fileContainingReference:r,namespace:n})}}function ng1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:wfu({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n})}}function ig1(e,t){return{name:e??t,schema:Dfu()}}function ag1(e,t,r){return{name:t??r,schema:Sfu(e)}}function Mfu({schema:e,context:t,declarationFile:r,namespace:n}){let i=e.encoding!=null?cba(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?C3(e.availability):void 0,union:f,encoding:i,source:e.source!=null?Ren(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?Ren(e.source):void 0}}}var og1=/^[0-9]/;function ug1(e){return og1.test(e)}function M_f({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?M_f({context:t,schema:n.schema,namespace:r}):e}function sg1(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 x_f(e){let t=e.replace(/^x-|^X-/,"");return FE(t)}var T_f="BasicAuthScheme",dba="BearerAuthScheme";function q_f(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:T_f,schema:i}),t||(e.builder.setAuth(T_f),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:dba,schema:i}),t||(e.builder.setAuth(dba),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??x_f(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:dba,schema:i}),t||(e.builder.setAuth(dba),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(zs.of("__package__.yml"),{name:"OauthScope",schema:F_i(n.scopesEnum).schema})}}function RRt({header:e,context:t,fileContainingReference:r,namespace:n}){let i=S1({schema:e.schema,context:t,fileContainingReference:r,namespace:n}),a=N2(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=C3(e.availability)),d}function pba({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 N2(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:N2(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=C3(e.availability)),a}var vOu=require("fs/promises");var C_f={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 FRt(e,t,r,n,i=[]){try{let a=Lh(e,t);if(a!=null)return r.parse(a)}catch{let u=C8t(i).join(" -> ");n.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}var _ba={of(e){return e}};var kh={SDK_METHOD_NAME:_ba.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:_ba.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:_ba.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 Xje={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 A_f({schema:e,logger:t}){return FRt(e,kh.ENCODING,t8.EncodingSchema,t)??void 0}function N_f(e){return Lh(e,kh.FERN_ENUM)}function z_f({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 L_i({fernType:f,nameOverride:e,generatedName:t,title:r,description:i,availability:a,groupName:typeof u=="string"?[u]:u})}function L_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:fl(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 Fen(e){if(e!=null&&typeof e=="boolean")return e}function B_f({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"||Y7n(i)?hba({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}):hba({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 hba({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 Y7n(e){return e==null?!1:typeof e=="boolean"?e:!gy(e)&&Object.keys(e).length===0}function I_f({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 cg1({nameOverride:e,generatedName:t,title:r,groupName:c,itemSchema:O,wrapAsNullable:f,description:a,availability:u,example:o})}function cg1({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 qfu({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=X7n({$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 R_f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:A,description:a,availability:u,discriminant:S,subtypes:x,groupName:l,source:O})}function Cfu({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=X7n(N,!1,l,[N.$ref],O,j,S);return l.markReferencedByDiscriminatedUnion(N,c,1),[z,C]}else{let C=N5r(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 R_f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:A,description:a,availability:u,discriminant:c,subtypes:x,groupName:g,source:j})}function R_f({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 F_f(e){if(e.proto!=null)return j7n.protobuf({typeName:e.proto.type})}var lg1=/^(\d+)/;function yba(e){let t=e.match(lg1);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=Q7n(i);return n.length>0?`${a}_${n}`:a}}}function Q7n(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_${Q7n(f)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${Q7n(a)}`}var Z7n=/^[a-zA-Z][a-zA-Z0-9_]*$/;function z5r({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=pg1(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=Z7n.test(A),Y=(N==null?void 0:N.name)??C,te=U?A:U_i(A);return Y!=null&&!Z7n.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 fg1({wrapAsNullable:c,nameOverride:e,generatedName:t,title:r,values:S,_default:x,description:f,availability:d,groupName:o,source:g})}function fg1({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 dg1={"<":"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 U_i(e){let t=yba(e),r=dg1[e];return t!=null?OV(FE(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":OV(FE(e)))}function pg1(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 L_f({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 U_f(e){return typeof e=="string"?E7.string(e):typeof e=="boolean"?E7.boolean(e):E7.string(`${e}`)}function V_f({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:U_f(i),description:a,availability:u,groupName:f}),description:a,availability:u,groupName:f}):Lp.literal({nameOverride:e,generatedName:t,title:r,value:U_f(i),description:a,availability:u,groupName:f})}function Afu({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 _g1={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},hg1={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}}},yg1={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}}},vg1={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},bg1={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},gg1={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},mg1={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},Og1={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function vba(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[_g1,hg1,yg1,vg1,bg1,gg1,mg1,Og1],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=OV(FE(t));return/^\d/.test(r)?yba(r)??r:r}function Nfu(e){let t=e.join("_");return FE(t)}function uq(e){switch(e.type){case"object":return ib.object({allOf:e.allOf,properties:e.properties.map(t=>jg1(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:uq(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:uq(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:uq(e.value),groupName:e.groupName});case"primitive":return ib.primitive({description:e.description,availability:e.availability,schema:W_f(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:W_f(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:uq(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(Pg1(e.value));case"unknown":return ib.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:fl(e)}}function Pg1(e){switch(e.type){case"discriminated":return QSr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:uq(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,uq(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return QSr.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>uq(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:fl(e)}}function W_f(e){switch(e.type){case"string":return Qw.string(e);case"base64":return Qw.base64();case"boolean":return Qw.boolean(e);case"date":return Qw.date();case"datetime":return Qw.datetime();case"double":return Qw.double(e);case"float":return Qw.float();case"int":return Qw.int(e);case"int64":return Qw.int64(e);case"uint":return Qw.uint();case"uint64":return Qw.uint64();default:fl(e)}}function jg1(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:uq(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability}}function bba(e,t){return LRt(uq(e),uq(t))}function LRt(e,t){return e.type==="primitive"&&t.type==="primitive"?H_f(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?wg1(e.values,t.values):e.type==="array"&&t.type==="array"?LRt(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"?LRt(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?Dg1(e.value,t.value):e.type==="object"&&t.type==="object"?Sg1(e,t):e.type==="map"&&t.type==="map"?H_f(e.key.schema,t.key.schema)&&LRt(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function H_f(e,t){return e.type===t.type}function wg1(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return Twr(r,n)}function Dg1(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:LRt(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:LRt(r,i)}):!1}function Sg1(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:LRt(a,i.schema)})}function $_f({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 Je of ee.oneOf){let Dt=gy(Je)?c.resolveSchemaReference(Je):Je,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=B5r($);if(Ve==null)continue;U.push({schemaId:Ve,convertedSchema:zfu($,[Ve],x),properties:J_f({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 Je=Y[ee];Je!=null?(Je.schemaIds.push($.schemaId),Je.schemas.some(Tt=>bba(Tt,Ve))||Je.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($),Je=Lh(ee,kh.AUDIENCES)??[],Dt=E2e(ee),Tt=Lh(ee,kh.FERN_PROPERTY_NAME),Wt=[...n,$],Nt=Nfu(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&&!bba(ur,zt)?Ar[Gr.schemaId]={differentSchema:!0}:zt!=null&&(Ar[Gr.schemaId]={differentSchema:!1})}return{key:$,schema:ur,nameOverride:Tt,audiences:Je,conflict:Ar,generatedName:Nfu([...n,$]),availability:Dt}});return G.push(...C.map($=>{let ee=$.conflict;for(let Ve of U){let Je=Ve.properties[$.key];Je!=null&&!bba($.schema,Je)?ee[Ve.schemaId]={differentSchema:!0}:Je!=null&&(ee[Ve.schemaId]={differentSchema:!1})}return{...$,conflict:ee}})),Eg1({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 Eg1({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:Y7n(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:Y7n(o),availability:l,source:g})}function J_f({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[u,f]=gy(e)?[t.resolveSchemaReference(e),vba(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...J_f({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=Mg1({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&&LRt(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}))}),z5r({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]:G_f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,subtypes:x,groupName:c,encoding:o,source:l})}function Bfu({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=X7n(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&&LRt(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}))}),z5r({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]:G_f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,subtypes:O,groupName:f,encoding:c,source:o})}function Mg1({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=NGi(o,u);d=NGi(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(Q7n(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(Q7n(i)??`${i}`),++i}return n}function G_f({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 e4n(e){if(e.default!=null&&typeof e.default=="string")return e.default}function gba({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 K_f({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 URt({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 Y_f({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 Len="#/components/schemas/";function L1(e,t,r,n,i,a,u=!1,f=new Set,d){let c=zg1({schema:e,logger:r.logger});if(gy(e)){let o=B5r(e);return o!=null?(u?r.markSchemaAsReferencedByRequest(o):r.markSchemaAsReferencedByNonRequest(o),X7n(e,t,r,n,c,i,a)):N5r(r.resolveSchemaReference(e),t,r,vba(e.$ref),c,i,a,f,u,d)}return N5r(e,t,r,n,c,i,a,f,u,d)}function X7n(e,t,r,n,i,a,u){let f=e.$ref.includes("properties")?N5r(r.resolveSchemaReference(e),t,r,n,i,a,u,new Set):Lp.reference(zfu(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 xg1(e){if(e!=null&&!e.includes(" ")&&!!/^[a-zA-Z]+$/.test(e))return e}function N5r(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?xg1(e.title):void 0),l=Lh(e,kh.SDK_GROUP_NAME)??((C=Lh(e,Xje.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,Xje.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=z_f({schema:e,description:S,title:j,nameOverride:o,generatedName:O,availability:x});if(N!=null)return N;if(!t&&e.nullable===!0)return N5r(e,!0,r,n,i,a,u,f,d,c);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!V_i(e.enum))return L9({nameOverride:o,generatedName:O,title:j,primitive:by.string({default:e4n(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:URt({schema:e,logger:r.logger,fallback:c})}),groupName:g,wrapAsNullable:t,description:S,availability:x});let U=N_f(e);return e.enum.length===1&&e.enum[0]!=null&&U==null?V_f({nameOverride:o,generatedName:O,title:j,wrapAsNullable:t,value:e.enum[0],description:S,availability:x,groupName:g}):z5r({nameOverride:o,generatedName:O,title:j,fernEnum:U,enumVarNames:Lh(e,[Xje.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:S,availability:x,wrapAsNullable:t,groupName:g,context:r,source:a})}if(V_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:N5r({...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:N5r({...e,type:U},t,r,n,i,a,u,f,d,c),groupName:g,description:e.description,availability:x})}if(V_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?Q_f({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:K_f({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:S,availability:x,groupName:g})}if(e==="number"||e.type==="number")return Afu({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Fen(e.exclusiveMinimum),exclusiveMaximum:Fen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:gba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="integer"||e.type==="integer")return L_f({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Fen(e.exclusiveMinimum),exclusiveMaximum:Fen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:gba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="float")return Afu({nameOverride:o,generatedName:O,title:j,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Fen(e.exclusiveMinimum),exclusiveMaximum:Fen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:gba({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:URt({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=ehf(e,"const");return U!=null?Q_f({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:e4n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:URt({schema:e,logger:r.logger,fallback:c})}),groupName:g,wrapAsNullable:t,description:S,availability:x})}if(e.type==="array")return I_f({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,item:e.items,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,example:Y_f({schema:e,logger:r.logger,fallback:c}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&X_f(e))return B_f({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?Bfu({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}):qfu({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?Bfu({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}):qfu({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 t4n(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=Cg1({schemas:e.oneOf});if(Y!=null)return z5r({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=Z_f({schemas:e.oneOf,context:r});if(te!=null&&!r.options.discriminatedUnionV2&&!U)return Cfu({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 t4n(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 t4n($,S,g)}else if(!gy(G)&&G.type==="null"){let $=L1(te,!0,r,n,a,u);return t4n($,S,g)}}}let U=Z_f({schemas:e.anyOf,context:r});if(U!=null&&!r.options.discriminatedUnionV2)return Cfu({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 t4n(te,S,g)}let Y=U.filter(te=>{let G=mba(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 t4n(te,S,g)}return $_f({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"&&Tg1(e)&&qg1(e)&&X_f(e))return hba({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:e4n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:URt({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 B5r(e){if(!!e.$ref.startsWith(Len))return e.$ref.replace(Len,"")}function zfu(e,t,r){let n=Lh(e,kh.TYPE_NAME),i=yR(t),a=e.description,u=E2e(e),f=B5r(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 Tg1(e){return e.oneOf==null||e.oneOf.length===0}function qg1(e){return e.allOf==null||e.allOf.length===0}function X_f(e){return e.properties==null||Object.keys(e.properties).length===0}function V_i(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function t4n(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 mba(e){return gy(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>mba(t)):e.oneOf!=null?e.oneOf.every(t=>mba(t)):e.anyOf!=null?e.anyOf.every(t=>mba(t)):!1}function Q_f({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 Cg1({schemas:e}){let t=new Set;for(let r of e){if(gy(r))return;if(r.enum!=null&&V_i(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function Z_f({schemas:e,context:t}){let r={};for(let n of e){let i=k_f({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 k_f({schema:e,context:t}){let r=gy(e)?t.resolveSchemaReference(e):e;return Ag1({schema:r,context:t})}function Ag1({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=k_f({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&&V_i(a.enum)&&Ng1(a.enum).length===1&&a.enum[0]!=null&&(r[n]=a.enum[0]);let u=ehf(a,"const");a.type==="string"&&u!=null&&(r[n]=u),n==="type"&&a.example!=null&&(r[n]=a.example)}return r}function Ng1(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 ehf(e,t){let r=e[t];if(r!=null)return r}function zg1({schema:e,logger:t}){let r=A_f({schema:e,logger:t});if(r!=null)return F_f(r)}function Oba(e,t){let r={},n={};return e==null?r=t:n={[e]:t},{rootSchemas:r,namespacedSchemas:n}}var thf="#/components/messages/",Ifu=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(Len))throw new Error(`Failed to resolve ${t.$ref}`);let n=t.$ref.substring(Len.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(thf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(thf.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}},Pba=class extends Ifu{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 I5r(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=>I5r(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=I5r(n);i!=null&&t.push({key:t0.string(r),value:i})}return RP.map(t)}}function W_i(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function rhf(e){if(e!=null&&Array.isArray(e))return e}var r4n=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"&&nhf({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=W_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(m5r.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=I5r(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=rhf(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=W_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=W_i(r)??(g!=null?W_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:fl(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 nhf({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:fl(r)}}};function nhf({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function VRt(e){switch(e.type){case"object":return Lp.object({allOf:e.allOf,properties:e.properties.map(t=>Ig1(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:VRt(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:VRt(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:VRt(e.value),groupName:e.groupName});case"primitive":return Lp.primitive({description:e.description,availability:e.availability,schema:ihf(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:ihf(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:VRt(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(Bg1(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:fl(e)}}function Bg1(e){switch(e.type){case"discriminated":return jQ.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:VRt(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,VRt(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=>VRt(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:fl(e)}}function ihf(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:fl(e)}}function Ig1(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:VRt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability}}function jba(e){return e.type!=="optional"&&e.type!=="nullable"}function H_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 wba=class{exampleTypeFactory;logger;schemas;constructor(t,r){this.schemas=t,this.exampleTypeFactory=new r4n(t),this.logger=r}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=Fg1(t.request),n=Lg1(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&&!WRt(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&&!WRt(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&&!WRt(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=Rg1(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=>H_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=>FS(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?XSr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):XSr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?bW.Csharp:r.sdk,code:r.code})).filter(FS)}isSchemaRequired(t){return jba(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function Rg1(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 Fg1(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:Ug1(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function Lg1(e){if(e!=null)return e.type!=="json"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function WRt(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return WRt(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undisciminated":return WRt(e.value.value);default:return!1}default:fl(e)}}function Ug1(e){return Lp.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:VRt(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0}).filter(FS),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 r4n(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&&!WRt(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&&!WRt(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&&!WRt(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&&!WRt(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 jba(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 $_i={FERN_DISPLAY_NAME:"x-fern-display-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path"};function ahf(e){return Lh(e,$_i.FERN_EXAMPLES)??[]}function uhf({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 Pba({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=ohf({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=ohf({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=ahf(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:uq(Ve.schema),env:Ve.env})),queryParameters:U.map(Ve=>({...Ve,schema:uq(Ve.schema)})),pathParameters:N.map(Ve=>({...Ve,parameterNameOverride:void 0,schema:uq(Ve.schema)}))},groupName:f.resolveTags(ee,"Websocket"),publish:Y!=null?uq(Y):Y,subscribe:te!=null?uq(te):te,summary:Lh(z,$_i.FERN_DISPLAY_NAME),path:A,description:void 0,examples:$,source:n};break}}return{groupedSchemas:Oba(a,d),channel:c,basePath:Lh(e,$_i.BASE_PATH)}}function ohf({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 _xf=yu(gmf(),1);var Ftn=yu(fxf(),1);var dxf=require("fs/promises");async function BPa({absoluteFilepathToOverrides:e,data:t,context:r}){let n=null;try{let i=(await(0,dxf.readFile)(e,"utf8")).toString();try{n=JSON.parse(i)}catch{n=av.load(i,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return u9o({data:t,overrides:n})}var wJ1={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},DJ1={id:"",typeExtension:{oas3:e=>{var t;return{...e,XFernStreaming:wJ1,Operation:{...e.Operation,properties:{...(t=e.Operation)==null?void 0:t.properties,"x-fern-streaming":"XFernStreaming"}}}}}};async function hxf({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,context:r}){let n=await pxf({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 BPa({absoluteFilepathToOverrides:i,context:r,data:n});return await pxf({absolutePathToOpenAPI:e,parsed:a})}return n}async function pxf({absolutePathToOpenAPI:e,parsed:t}){let r={config:new Ftn.Config({apis:{},styleguide:{plugins:[DJ1],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0},n=t!=null?await(0,Ftn.bundle)({...r,doc:{source:new Ftn.Source(e,"<openapi>"),parsed:t}}):await(0,Ftn.bundle)({...r,ref:e});return await _xf.default.parse(n.bundle.parsed)}var cAf=yu(vCf(),1);function bCf(e){return Lh(e,kh.ASYNC_CONFIG)}var gCf="$request.";function mCf(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:IZ1(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function IZ1(e){return e.startsWith(gCf)?e.slice(gCf.length):e}function OCf(e){let t=e;if(t.cursor!=null)return YSr.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});let r=e;return YSr.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}function PCf(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:OCf(n)}return OCf(r)}}function jCf(e){let t=RZ1(e),r={};return cOu({obj:t,occurrences:r,breadcrumbs:[]}),r}function cOu({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let n of e)cOu({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)cOu({obj:e[n],occurrences:t,breadcrumbs:[...r,n]})}}}function RZ1(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:(r==null?void 0:r.get)!=null?I0i(r.get):void 0,put:(r==null?void 0:r.put)!=null?I0i(r.put):void 0,post:(r==null?void 0:r.post)!=null?I0i(r.post):void 0,patch:(r==null?void 0:r.patch)!=null?I0i(r.patch):void 0,delete:(r==null?void 0:r.delete)!=null?I0i(r.delete):void 0}]))}}function I0i(e){return{...e,requestBody:e.requestBody!=null?gy(e.requestBody)?e.requestBody:FZ1(e.requestBody):void 0}}function FZ1(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 wCf="#/components/parameters/",DCf="#/components/responses/",SCf="#/components/examples/",ECf="#/components/requestBodies/",G3n=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=jCf(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(wCf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(wCf.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(ECf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(ECf.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(DCf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(DCf.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(SCf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(SCf.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 K3n=class extends G3n{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 LZ1=nr.object({lang:nr.string(),label:nr.optional(nr.string()),source:nr.string()}),lOu=nr.array(LZ1);var MCf={README_EXT:"x-readme"};function UZ1(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 xCf(e){let t=Lh(e,MCf.README_EXT);if(!RO(t))return[];let r=t["code-samples"];if(!UZ1(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 TCf(e,t,r){let n=FRt(t,kh.EXAMPLES,t8.ExampleEndpointCallArraySchema,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],i=FRt(t,Xje.REDOCLY_CODE_SAMPLES_KEBAB,lOu,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],u=[...FRt(t,Xje.REDOCLY_CODE_SAMPLES_CAMEL,lOu,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=xCf(t);return f.length>0&&n.push({"code-samples":f}),n.map(pAt.unknown)}function qCf(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 V1a(e){return{url:VZ1({url:e.url,variables:e.variables??{}}),description:e.description,name:WZ1(e),audiences:Lh(e,kh.AUDIENCES)}}function VZ1({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 WZ1(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 CCf(e){return Lh(e,kh.PARAMETER_NAME)}function ACf(e){return Lh(e,kh.SDK_VARIABLE)}function W1a({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=URt({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,URt({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:URt({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:URt({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:CCf(c),availability:l,source:a};c.in==="query"?u.queryParameters.push(S):c.in==="path"?u.pathParameters.push({...S,variableReference:ACf(c)}):c.in==="header"?!HZ1.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 HZ1=new Set(["User-Agent","Content-Length","Content-Type","X-Forwarded-For","Cookie","Origin","Content-Disposition","X-Ping-Custom-Domain"]);function Y3n(e,t){for(let r of Object.keys(e))if(r.includes("json")||r==="*/*"){let n=e[r];if(n==null)continue;let i=n.schema;return{contentType:r.includes("*")?void 0:r,schema:i??{},examples:zCf(n,t)}}}function NCf(e,t){for(let r of Object.keys(e)){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:zCf(n,t)}}}function zCf(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let n=Lh(e,Xje.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 $Z1(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 JZ1(e){var t;for(let r in e.content)if((t=sA.parse(r))!=null&&t.isOctetStream())return!0;return!1}function GZ1(e,t){let r=gy(e)?fOu(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 X3n({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=$Z1(u),d=f==null?void 0:f.schema,c=f==null?void 0:f.encoding,o=Y3n(u.content,r);if(JZ1(u))return S2e.octetStream({description:void 0,source:i});if(d!=null&&o==null||d!=null&&GZ1(d,t)){let A=gy(d)?fOu(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:o.contentType,fullExamples:o.examples,additionalProperties:!gy(o.schema)&&Y7n(o.schema.additionalProperties),source:i})}function fOu(e,t){var i,a;if(!e.$ref.startsWith(Len))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=B5r(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)?fOu(n,t):{id:r,schema:n}}var dOu={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"},BCf=new Set(Object.values(dOu));var KZ1=["200","201","202","204"];function RCf({operationContext:e,responses:t,context:r,responseBreadcrumbs:n,responseStatusCode:i,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let f=YZ1({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,c;for(let o of i!=null?[i]:KZ1){let l=t[o];l!=null&&(d=!0,c==null&&(c=ICf({operationContext:e,response:l,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})))}if(c==null&&!d&&t.default!=null&&(c=ICf({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:fl(c)}return{value:void 0,errors:f}}function ICf({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 q3.file({description:f.description,source:a});let d=Y3n(f.content??{},n);if(d!=null){if(t!=null)switch(t){case"json":return q3.streamingJson({description:f.description,responseProperty:void 0,schema:uq(L1(d.schema,!1,n,i,a,u)),source:a});case"sse":return q3.streamingSse({description:f.description,responseProperty:void 0,schema:uq(L1(d.schema,!1,n,i,a,u)),source:a})}return q3.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 q3.file({description:f.description,source:a});if(l.isPlainText()){let g=o.schema;if(g==null)return q3.text({description:f.description,source:a});let O=gy(g)?n.resolveSchemaReference(g):g;return O.type==="string"&&O.format==="byte"?q3.file({description:f.description,source:a}):q3.text({description:f.description,source:a})}}}}function YZ1({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=NCf(d.content??{},t),o=dOu[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 OEr({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=W1a({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:j,path:d,httpMethod:c,source:a}),x=f.requestBody!=null?X3n({requestBody:f.requestBody,document:u,context:new K3n({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=X3n({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j,"Body"],source:a,namespace:t.namespace}):f.requestBody!=null&&(x=X3n({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j],source:a,namespace:t.namespace}));let A=[...o,"Response"],z=RCf({operationContext:e,streamFormat:i,responses:f.responses,context:t,responseBreadcrumbs:A,responseStatusCode:r,source:a}),N=qCf(f),C=TCf(e,f,t),U=Lh(f,kh.SERVER_NAME_V2);return{summary:f.summary,internal:Lh(f,Xje.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=>V1a(Y)),description:f.description,authed:XZ1(f,u),availability:N,method:c,path:d,examples:C,pagination:e.pagination,source:a}}function XZ1(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function LCf({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=FCf({context:t,headerToIgnore:f,parameters:a}),l=FCf({context:t,headerToIgnore:f,parameters:u}),g=OEr({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=OEr({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 FCf({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 pOu="stream";function HCf({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:OEr({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let n=UCf({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if((n==null?void 0:n.schemaReference)!=null){let c=B5r(n.schemaReference);c!=null&&t.excludeSchema(c)}let i=VCf({operation:e.operation,response:r.responseStream}),a=OEr({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+pOu}:void 0,operation:{...e.operation,requestBody:n==null?void 0:n.requestBody,responses:i},baseBreadcrumbs:[...e.baseBreadcrumbs,pOu]},context:t,streamFormat:r.format,suffix:pOu,source:t.source});a.examples=a.examples.filter(c=>WCf(c,t)!==!1);let u=UCf({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),f=VCf({operation:e.operation,response:r.response}),d=OEr({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=>WCf(c,t)!==!0),{streaming:a,nonStreaming:d}}default:fl(r)}}function UCf({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=Y3n(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 VCf({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[sA.APPLICATION_JSON]:{schema:t}}}}}function WCf(e,t){return e._visit({unknown:r=>{let n=t8.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 $Cf({context:e,operationContext:t,source:r}){let{document:n,operation:i,path:a,method:u,baseBreadcrumbs:f,sdkMethodName:d}=t,c=[...f,"Payload"],o=W1a({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=X3n({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:QZ1(l.fullExamples),source:r}}function QZ1(e){if(e==null)return[];let t=[];for(let r of e){let n=I5r(r.value);n!=null&&t.push({description:r.description,name:r.name,payload:n})}return t}function _Ou({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=ZZ1(r,e),u=PCf(e.document,r),f={...t,sdkMethodName:a,baseBreadcrumbs:kZ1({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path}),operation:r,operationParameters:r.parameters??[],pagination:u};if(n){let l=$Cf({context:e,operationContext:f,source:e.source});return l!=null?{type:"webhook",value:l}:void 0}let d=mCf(r);if(d!=null){let l=HCf({context:e,operationContext:f,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let c=bCf(r);if(c!=null){let l=LCf({context:e,operationContext:f,asyncExtension:c,source:e.source});return{type:"async",async:l.async,sync:l.sync}}let o=OEr({context:e,operationContext:f,streamFormat:void 0,source:e.source});return{type:"http",value:o}}function ZZ1(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 kZ1({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 JCf(e,t,r,n){let i=[],a=KCf(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=ek1({operation:f.operation}),c=_Ou({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:d});c!=null&&i.push(c)}return i}function GCf(e,t,r,n){let i=[],a=KCf(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=_Ou({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:!0});d!=null&&i.push(d)}return i}function KCf(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 ek1({operation:e}){return Lh(e,[kh.WEBHOOK])??!1}function YCf(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 XCf(e){return Lh(e,kh.FERN_BASIC_AUTH)}function hOu(e,t){if(gy(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return tk1(e,t)}function tk1(e,t){var r,n,i,a;if(e.type==="apiKey"&&e.in==="header"){let u=Lh(e,Xje.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=XCf(e),f=YCf(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:rk1(e,t)})}throw new Error(`Failed to convert security scheme ${JSON.stringify(e)}`)}function rk1(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=z5r({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=uq(f);if(d.type==="enum")return d}}function QCf(e){return Lh(e,kh.BASE_PATH)}var nk1=nr.record(nr.string(),nr.object({summary:nr.string().optional(),description:nr.string().optional()}));function ZCf({document:e,context:t}){return FRt(e,kh.GROUPS,nk1,t.logger)}function kCf({context:e,document:t}){return FRt(t,kh.FERN_VERSION,t8.VersionDeclarationSchema,e.logger)??void 0}function eAf(e){let t=Lh(e,kh.FERN_GLOBAL_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?L_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 tAf(e){let t=Lh(e,kh.FERN_IDEMPOTENCY_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?L_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 rAf(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:Qw.string({default:e4n(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 ik1="webhooks";function nAf(e){return Lh(e,ik1)??{}}var H1a=class extends G3n{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 K3n({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 iAf(e){return Lh(e,kh.RESOLUTIONS)}function aAf({openapi:e}){let t=iAf(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=ak1({openapi:e,schemaReference:a,schemaName:n.name}),e=oAf({openapi:e,replaceReference:a,schemaReference:i,replacedReferences:r}),r={...r,...Object.fromEntries(n.resolutions.map(u=>[i,u]))}}return e}function ak1({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 oAf({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 oAf({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 $1a({openApi:e,taskContext:t,options:r,source:n,namespace:i}){var Y,te,G;e=aAf({openapi:e});let a=Object.fromEntries(Object.entries(((Y=e.components)==null?void 0:Y.securitySchemes)??{}).map(([$,ee])=>hOu(ee,n)==null?[]:[$,hOu(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 H1a({document:e,taskContext:t,authHeaders:u,options:r,source:n,namespace:i}),d=rAf(e),c=eAf(e),o=tAf(e),l=r.audiences??[],g=[],O=[];Object.entries(e.paths??{}).forEach(([$,ee])=>{if(ee==null)return;t.logger.debug(`Converting path ${$}`);let Ve=JCf($,ee,e,f);for(let Je of Ve){let Dt=uAf({operation:Je});if(!(l.length>0&&!l.some(Tt=>Dt.includes(Tt))))switch(Je.type){case"async":g.push(Je.sync),g.push(Je.async);break;case"http":g.push(Je.value);break;case"streaming":g.push(Je.streaming),Je.nonStreaming&&g.push(Je.nonStreaming);break;case"webhook":O.push(Je.value);break;default:fl(Je)}}}),Object.entries(nAf(e)).forEach(([$,ee])=>{if(ee==null)return;t.logger.debug(`Converting path ${$}`);let Ve=GCf($,ee,e,f);for(let Je of Ve){let Dt=uAf({operation:Je});l.length>0&&!l.some(Tt=>Dt.includes(Tt))||O.push(Je.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(BCf.has($))return[$,L1({...ee,"x-fern-type-name":`${$}Body`},!1,f,[$],n,i)]}return[$,L1(ee,!1,f,[$],n,i)]}).filter($=>$.length>0)),S=ok1(j,f,n),x=uk1(S,f),A={};for(let[$,ee]of Object.entries(x)){let Ve=uq(ee);f.isSchemaExcluded($)||(A[$]=Ve,t.logger.debug(`Converted schema ${$}`))}let z=new wba(x,f.logger),N=g.map($=>{let ee=$.examples,Ve=ee;if(!r.disableExamples&&(ee.length===0||ee.every(H_i))){let Tt=z.buildEndpointExample($);Tt.length>0&&(Ve=[...Tt,...ee.filter(Wt=>!H_i(Wt))])}let Je=$.request,Dt=$.response;return{...$,request:(Je==null?void 0:Je.type)==="json"?{...Je,schema:uq(Je.schema)}:Je,response:(Dt==null?void 0:Dt.type)==="json"?{...Dt,schema:uq(Dt.schema)}:Dt,queryParameters:$.queryParameters.map(Tt=>({description:Tt.description,name:Tt.name,schema:uq(Tt.schema),parameterNameOverride:Tt.parameterNameOverride,availability:Tt.availability,source:Tt.source})),pathParameters:$.pathParameters.map(Tt=>({description:Tt.description,name:Tt.name,schema:uq(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:uq(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:uq(Tt.schema),description:Tt.description,source:Tt.source,examples:(Wt=Tt.fullExamples)==null?void 0:Wt.map(Nt=>{let ur=I5r(Nt.value);if(ur!=null)return{name:Nt.name,description:Nt.description,example:ur}}).filter(FS)}})}}),C=ZCf({document:e,context:f});return{apiVersion:kCf({context:f,document:e}),basePath:QCf(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($=>V1a($)),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:Oba(i,A),securitySchemes:a,hasEndpointsMarkedInternal:N.some($=>$.internal),nonRequestReferencedSchemas:f.getReferencedSchemas(),variables:d,globalHeaders:c,idempotencyHeaders:o}}function ok1(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=sAf({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 uk1(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 sAf({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(...sAf({schema:i,schemas:t}))}return r}function uAf({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:fl(e)}return t}async function lAf({openApi:e,taskContext:t,options:r,source:n,namespace:i}){let a=await(0,cAf.convertObj)(e,{});return $1a({openApi:a.openapi,taskContext:t,options:r,source:n,namespace:i})}var Q3n={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0};async function Ytn({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,vOu.readFile)(a.absoluteFilepath)).toString(),f=D4(e,a.source.file);a.source.relativePathToDependency!=null&&(f=pf(a.source.relativePathToDependency,f));let d=a.source.type==="protobuf"?KSr.protobuf({file:f}):KSr.openapi({file:f});if(u.includes("openapi")||u.includes("swagger")){let c=await hxf({absolutePathToOpenAPI:a.absoluteFilepath,context:r,absolutePathToOpenAPIOverrides:a.absoluteFilepathToOverrides});if(lk1(c)){let o=$1a({openApi:c,taskContext:r,options:yOu({specSettings:a.settings,overrides:n}),source:d,namespace:a.namespace});i=fAf(i,o)}else if(fk1(c)){let o=await lAf({openApi:c,taskContext:r,options:yOu({specSettings:a.settings}),source:d,namespace:a.namespace});i=fAf(i,o)}}else if(u.includes("asyncapi")){let c=await ck1({absoluteFilePathToAsyncAPI:a.absoluteFilepath,context:r,absoluteFilePathToAsyncAPIOverrides:a.absoluteFilepathToOverrides}),o=uhf({document:c,taskContext:r,options:yOu({specSettings:a.settings}),source:d,asyncApiOptions:sk1({specSettings:a.settings}),namespace:a.namespace});o.channel!=null&&i.channel.push(o.channel),o.groupedSchemas!=null&&(i.groupedSchemas=dAf(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 yOu({specSettings:e,overrides:t}){return{disableExamples:(t==null?void 0:t.disableExamples)??Q3n.disableExamples,discriminatedUnionV2:(t==null?void 0:t.discriminatedUnionV2)??(e==null?void 0:e.shouldUseUndiscriminatedUnionsWithLiterals)??Q3n.discriminatedUnionV2,useTitlesAsName:(t==null?void 0:t.useTitlesAsName)??(e==null?void 0:e.shouldUseTitleAsName)??Q3n.useTitlesAsName,audiences:(t==null?void 0:t.audiences)??(e==null?void 0:e.audiences)??Q3n.audiences,optionalAdditionalProperties:(t==null?void 0:t.optionalAdditionalProperties)??(e==null?void 0:e.optionalAdditionalProperties)??Q3n.optionalAdditionalProperties}}function sk1({specSettings:e,overrides:t}){return{naming:(t==null?void 0:t.naming)??(e==null?void 0:e.asyncApiNaming)??C_f.naming}}function fAf(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:dAf(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 dAf(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 ck1({absoluteFilePathToAsyncAPI:e,absoluteFilePathToAsyncAPIOverrides:t,context:r}){let n=(await(0,vOu.readFile)(e)).toString(),i=await av.load(n);return t!=null?await BPa({absoluteFilepathToOverrides:t,context:r,data:i}):i}function lk1(e){return e.openapi!=null}function fk1(e){return e.swagger!=null}function G1a({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=bOu({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=N2(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=C3(e.availability)),u}function bOu({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($T),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"&&(Z7n.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:U_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&&J1a({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&&J1a({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 bOu({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($T),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"&&(Z7n.test(u.value.value)?i.push(u.value.value):i.push({value:u.value.value,name:U_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&&J1a({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&&J1a({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 bOu({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 J1a({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 pAf({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"]=dk1(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=pk1({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=Uzr(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function dk1(e){let t={};return e.forEach(r=>{let n=Uzr(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function pk1({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=Uzr(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function Uzr(e){switch(e.type){case"primitive":return _Af(e.value);case"object":return hAf(e.properties);case"array":return _k1(e.value);case"map":return hk1(e.value);case"oneOf":return yk1(e.value);case"enum":return e.value;case"literal":return vk1(e.value);case"unknown":return Uzr(e.value);default:fl(e)}}function _Af(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:fl(e)}}function hAf(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Uzr(r)]))}function _k1(e){return e.map(t=>Uzr(t))}function hk1(e){return Object.fromEntries(e.map(t=>[_Af(t.key),Uzr(t.value)]))}function yk1(e){return e.type==="discriminated"?hAf(e.value):Uzr(e.value)}function vk1(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:fl(e)}}function PEr(e){var t;return(t=e.find(r=>typeof r!="string"&&r.type==="namespace"))==null?void 0:t.name}function K1a(e,t){return t??((e==null?void 0:e.groupName)!=null?PEr(e.groupName):void 0)}function yAf({channel:e,context:t,declarationFile:r}){let n={path:e.path,auth:!1};e.summary!=null&&(n["display-name"]=e.summary);let i=PEr(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=pba({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=G1a({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=RRt({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=pAf({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:c})}}var vAf="Production",bAf="Default";function gAf(e){return Object.entries(e).reduce((t,[r,n])=>(L2n(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function mAf(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:bAf,schema:o?{url:c,audiences:o}:c}),e.builder.setDefaultEnvironment(bAf))}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:vAf,schema:{urls:{...gAf(t),...gAf(n)}}}),e.builder.setDefaultEnvironment(vAf)}}function Y1a(e){return N2(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var gOu=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},bk1=.75,gk1=new Set("authorization");function OAf(e){if(e.globalHeaderOverrides!=null){for(let[r,n]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:n});return}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?G7n(n.schema):void 0,u=a!=null?PEr(a):void 0,f=zs.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?N2(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(gk1.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let f=t[a.name],d=RRt({header:{...a,schema:(f==null?void 0:f.schema)??a.schema,name:(f==null?void 0:f.name)??a.name},fileContainingReference:zs.of(iB),context:e,namespace:void 0});u=new gOu(d),r[a.name]=u}u.increment()}let n=e.ir.endpoints.length*bk1;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:Y1a(a.schema)}))}}}function PAf(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?G7n(t.schema):void 0,n=r!=null?PEr(r):void 0,i=RRt({header:{...t,schema:t.schema??ib.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:Qw.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(iB),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:Y1a(i)})}}function lG(e){switch(e.type){case"primitive":return jAf(e.value);case"object":return wAf(e.properties);case"array":return mk1(e.value);case"map":return Ok1(e.value);case"oneOf":return Pk1(e.value);case"enum":return e.value;case"literal":return jk1(e.value);case"unknown":return lG(e.value);default:fl(e)}}function jAf(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:fl(e)}}function wAf(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,lG(r)]))}function mk1(e){return e.map(t=>lG(t))}function Ok1(e){return Object.fromEntries(e.map(t=>[jAf(t.key),lG(t.value)]))}function Pk1(e){return e.type==="discriminated"?wAf(e.value):lG(e.value)}function jk1(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:fl(e)}}function DAf({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"]=wk1(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=Dk1(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=Sk1({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(FS)),r)}function wk1(e){let t={};return e.forEach(r=>{let n=lG(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function Dk1(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 Sk1({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 SAf(e){return KJ._visit(e,{get:()=>t8.HttpMethodSchema.Enum.GET,post:()=>t8.HttpMethodSchema.Enum.POST,put:()=>t8.HttpMethodSchema.Enum.PUT,patch:()=>t8.HttpMethodSchema.Enum.PATCH,delete:()=>t8.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 EAf({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,u=e.path,f=K1a(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]=pba({pathParameter:S,context:r,fileContainingReference:t,namespace:f}),a.add(S.name);let c={};for(let S of e.queryParameters){let x=G1a({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:SAf(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=RRt({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=Mk1({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:N2(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:N2(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:N2(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=C3(e.availability)),Object.entries(e.errors).forEach(([S,x])=>{var te;let A=x.generatedName,z=zs.of($T);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=w_f({location:MAf,namespaceOverride:f});if(x.schema!=null){let G=S1({schema:x.schema,context:r,fileContainingReference:C,declarationFile:C,namespace:f});N.type=N2(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=Ek1({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[mOu,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function Ek1({endpointExamples:e,context:t}){return e.map(r=>{try{return DAf({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function Mk1({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=C3(x.availability);if(!d.has(z)&&x.audiences.length<=0)return d.add(z),x.nameOverride!=null?[x.key,{type:N2(A),docs:R_i(A),name:x.nameOverride,availability:N}]:[x.key,N?{...typeof A=="string"?{type:A}:A,availability:N}:A];let C={type:N2(A),docs:R_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 N2(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 fl(r)}}function xk1({location:e,namespaceOverride:t}){return t!=null?{...e,file:pf(zs.of(t),e.file)}:e}function Tk1(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($T),endpointId:FE(e.summary)}:{file:zs.of($T),endpointId:FE(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:zs.of($T),endpointId:n};let i=R0i(r),a=R0i(n);if(Twr(i,a))return{file:zs.of("__package__.yml"),endpointId:r};let u=Ak1({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 F0i(e){let t=e.tags[0];if(e.sdkName!=null){let r=gfu({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 xk1({namespaceOverride:e.namespace,location:Tk1(e)})}function R0i(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=C8t(t),t}var qk1=new RegExp("[^a-zA-Z0-9{}]+"),Ck1=new RegExp("[{}]","g");function Ak1({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(qk1).join("_").replaceAll(Ck1,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:zs.of(FE(t)+".yml"),endpointId:FE(e.slice(0,-1*a.length)),tag:t}}function xAf(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:u,file:f,tag:d}=F0i(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=EAf({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 TAf(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?PEr(r.groupName):void 0,i=S1({schema:ib.primitive(r),context:e,fileContainingReference:zs.of($T),namespace:n});e.builder.addVariable({name:t,schema:{type:N2(i),docs:r.description??void 0}})}}function qAf(e){for(let t of e.ir.webhooks){let r=Bk1({webhook:t,context:e});if(r==null)continue;let n=K1a(t.sdkName,t.namespace),i={};for(let u of t.headers)i[u.name]=RRt({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 Nk1({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:pf(zs.of(t),e.file)}:e}function zk1({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:zs.of($T),endpointId:n};let i=R0i(r),a=R0i(n);if(Twr(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 Bk1({webhook:e,context:t}){return e.sdkName!=null?{file:j_f({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:Nk1({namespaceOverride:e.namespace,location:zk1({webhook:e,context:t})})}var Ik1=zs.of($T);function CAf(e){switch(e.type){case"object":return gFt(e.groupName);case"enum":return gFt(e.groupName);case"oneOf":return gFt(e.value.groupName);case"array":return gFt(e.groupName);case"map":return gFt(e.groupName);case"reference":return gFt(e.groupName);case"literal":return gFt(e.groupName);case"optional":return gFt(e.groupName);case"nullable":return gFt(e.groupName);case"primitive":return gFt(e.groupName);case"unknown":return Ik1;default:fl(e)}}function gFt(e){return K7n(e)}var mOu="external",MAf=zs.of($T);function AAf({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let u=CAf(a),f=E_f({schema:a,context:n,declarationFile:u,namespace:r});if(V2n(f.schema)){let d=N2(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 NAf(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),mAf(e),OAf(e),PAf(e),q_f(e),TAf(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(mOu);let{schemaIdsToExclude:t,sdkGroups:r}=xAf(e);qAf(e);for(let n of e.ir.channel){let i=K7n(n.groupName);yAf({channel:n,context:e,declarationFile:i})}AAf({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:t,namespace:void 0,context:e});for(let[n,i]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))AAf({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 Vzr=yu(require("path"),1);var X1a=yu(require("path"),1),Z3n=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}${X1a.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}${X1a.default.sep}${u}`:u,d=n.directories[u];r(d,f)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(X1a.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 Z3n),this.directories[r].getOrCreateFileRecursive(n)}};var Q1a=class{modifyBasePaths;enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t,r,n){this.modifyBasePaths=r,this.enableUniqueErrorsPerEndpoint=n,this.root=new Z3n,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 NDr(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,Vzr.basename)(r,(0,Vzr.extname)(r))).replaceAll("__package__","root"));if(t===zs.of(iB))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=D4(Cg(R_.of(`/${t}`)),R_.of(`/${r}`)),n;let i=this.getOrCreateFile(t);return i.imports==null&&(i.imports={}),i.imports[n]=D4(Cg(R_.of(`/${t}`)),R_.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=>Twr(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=Ren(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=Vzr.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=Rk1(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)]:zAf(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:Vzr.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:Vzr.default.join(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===$T?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 Rk1(e){if(e.environments==null)return"";let t=Object.entries(e.environments).flatMap(([r,n])=>typeof n=="string"?[n]:zAf(n)?[n.url]:Object.values(n.urls));return Lk1(t.map(Fk1))}function Fk1(e){try{let r=new URL(e).pathname;return r.endsWith("/")?r.slice(0,-1):r}catch{return""}}function Lk1(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 zAf(e){return e.url!=null}var Z1a=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;defaultServerName=void 0;constructor({taskContext:t,ir:r,enableUniqueErrorsPerEndpoint:n,detectGlobalHeaders:i,environmentOverrides:a,globalHeaderOverrides:u,authOverrides:f}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.builder=new Q1a(r,!1,n),this.detectGlobalHeaders=i,this.environmentOverrides=a,this.authOverrides=f,this.globalHeaderOverrides=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 OOu(e){let t=new Z1a(e);return NAf(t)}var Vne=class extends $Sr{specs;sources;constructor({specs:t,...r}){super(r),this.specs=t,this.sources=this.convertSpecsToIdentifiableSources(t)}async getDefinition({context:t,relativePathToDependency:r},n){var f,d,c,o,l,g,O,j,S;let i=await wen({context:t,specs:this.specs,relativePathToDependency:r}),a=await Ytn({absoluteFilePathToWorkspace:this.absoluteFilePath,specs:i,taskContext:t,optionOverrides:Uk1(n)}),u=OOu({authOverrides:((d=(f=this.generatorsConfiguration)==null?void 0:f.api)==null?void 0:d.auth)!=null?{...(c=this.generatorsConfiguration)==null?void 0:c.api}:void 0,environmentOverrides:((l=(o=this.generatorsConfiguration)==null?void 0:o.api)==null?void 0:l.environments)!=null?{...(g=this.generatorsConfiguration)==null?void 0:g.api}:void 0,globalHeaderOverrides:((j=(O=this.generatorsConfiguration)==null?void 0:O.api)==null?void 0:j.headers)!=null?{...(S=this.generatorsConfiguration)==null?void 0:S.api}:void 0,taskContext:t,ir:a,enableUniqueErrorsPerEndpoint:(n==null?void 0:n.enableUniqueErrorsPerEndpoint)??!1,detectGlobalHeaders:(n==null?void 0:n.detectGlobalHeaders)??!0});return{absoluteFilePath:R_.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:u.rootApiFile["default-url"],contents:u.rootApiFile,rawContents:av.dump(u.rootApiFile)},namedDefinitionFiles:{...Vk1(u.definitionFiles,x=>({absoluteFilepath:R_.of("/DUMMY_PATH"),rawContents:av.dump(x),contents:x})),[zs.of($T)]:{absoluteFilepath:R_.of("/DUMMY_PATH"),rawContents:av.dump(u.packageMarkerFile),contents:u.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new JSr({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(FS)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,n=[];return t.reduce((i,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),i.push({type:a.type,id:Kkr(),absoluteFilePath:u})),i},n)}};function L0i(e){if(e.settings==null)return;let t={detectGlobalHeaders:!0};return e.settings.unions==="v1"&&(t.enableDiscriminatedUnionV2=!0),t}function Uk1(e){if(e==null)return;let t={};return e.enableDiscriminatedUnionV2&&(t.discriminatedUnionV2=!0),e.optionalAdditionalProperties&&(t.optionalAdditionalProperties=!0),t}function Vk1(e,t){return sy(e,t)}function POu(e,t){for(let[r,n]of w4(e.failures))Wk1({relativeFilepath:r,failure:n,logger:t})}function Wk1({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Xw.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 Xw.FILE_READ:r.error("Failed to open file: "+e);break;case Xw.FILE_MISSING:r.error("Missing file: "+e);break;case Xw.FILE_PARSE:t.error instanceof vsi?r.error(Bwr({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Xw.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of Hk1(n))r.error(Bwr({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case Xw.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Xw.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${BGi}: `+t.dependencyName);break;case Xw.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Xw.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;default:fl(t)}}function Hk1(e){switch(e.code){case Yp.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${al.underline(e.expected)} but received ${al.underline(e.received)}`}];case Yp.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${al.underline(t)}`}));case Yp.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>al.underline(t)).join(", ")}`}];case Yp.invalid_union:case Yp.invalid_arguments:case Yp.invalid_return_type:case Yp.invalid_date:case Yp.invalid_string:case Yp.too_small:case Yp.too_big:case Yp.invalid_intersection_types:case Yp.not_multiple_of:case Yp.custom:default:return[{title:e.message}]}}var BAf=require("fs/promises");async function IAf(e,t){let r=[];for(let n of await z8t(e,t))r.push(await $k1({relativeFilepath:D4(e,n),absoluteFilepath:n}));return r}async function $k1({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,BAf.readFile)(t)).toString()}}async function RAf({absolutePathToWorkspace:e}){let t=pf(e,zs.of(mNc));if(!await Vh(t))return;let n=await IAf(t,"{md,mdx}");return{files:await Promise.all(n.map(i=>({absoluteFilepath:i.absoluteFilepath,contents:i.fileContents})))}}async function jOu({absolutePathToWorkspace:e,namespace:t,definitions:r}){var i,a,u,f,d,c,o;let n=[];for(let l of r){let g=l.overrides!=null?pf(e,zs.of(l.overrides)):void 0;if(l.schema.type==="protobuf"){let j=pf(e,zs.of(l.schema.root));if(!await Vh(j))return{didSucceed:!1,failures:{[zs.of(l.schema.root)]:{type:Xw.FILE_MISSING}}};let S=pf(e,zs.of(l.schema.target));if(!await Vh(S))return{didSucceed:!1,failures:{[zs.of(l.schema.target)]:{type:Xw.FILE_MISSING}}};n.push({type:"protobuf",absoluteFilepathToProtobufRoot:j,absoluteFilepathToProtobufTarget:S,absoluteFilepathToOverrides:g,generateLocally:l.schema.localGeneration,settings:{audiences:l.audiences??[],shouldUseTitleAsName:((i=l.settings)==null?void 0:i.shouldUseTitleAsName)??!0,shouldUseUndiscriminatedUnionsWithLiterals:((a=l.settings)==null?void 0:a.shouldUseUndiscriminatedUnionsWithLiterals)??!1,optionalAdditionalProperties:((u=l.settings)==null?void 0:u.shouldUseOptionalAdditionalProperties)??!0}});continue}let O=pf(e,zs.of(l.schema.path));if(!await Vh(O))return{didSucceed:!1,failures:{[zs.of(l.schema.path)]:{type:Xw.FILE_MISSING}}};if(l.overrides!=null&&g!=null&&!await Vh(g))return{didSucceed:!1,failures:{[zs.of(l.overrides)]:{type:Xw.FILE_MISSING}}};n.push({type:"openapi",absoluteFilepath:O,absoluteFilepathToOverrides:g,settings:{audiences:l.audiences??[],shouldUseTitleAsName:((f=l.settings)==null?void 0:f.shouldUseTitleAsName)??!0,shouldUseUndiscriminatedUnionsWithLiterals:((d=l.settings)==null?void 0:d.shouldUseUndiscriminatedUnionsWithLiterals)??!1,asyncApiNaming:(c=l.settings)==null?void 0:c.asyncApiMessageNaming,optionalAdditionalProperties:((o=l.settings)==null?void 0:o.shouldUseOptionalAdditionalProperties)??!0},source:{type:"openapi",file:O},namespace:t})}return n}async function U0i({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:n}){let i=await pg.loadGeneratorsConfiguration({absolutePathToWorkspace:e,context:t}),a;try{a=await RAf({absolutePathToWorkspace:e})}catch{}if((i==null?void 0:i.api)!=null&&(i.api.type==="singleNamespace"&&i.api.definitions.length>0||i.api.type==="multiNamespace")){let u=[];if(i.api.type==="singleNamespace"){let f=await jOu({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.definitions});if(!Array.isArray(f))return f;u.push(...f)}else{for(let[f,d]of Object.entries(i.api.definitions)){let c=await jOu({absolutePathToWorkspace:e,namespace:f,definitions:d});if(!Array.isArray(c))return c;u.push(...c)}if(i.api.rootDefinitions!=null){let f=await jOu({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.rootDefinitions});if(!Array.isArray(f))return f;u.push(...f)}}return{didSucceed:!0,workspace:new Vne({specs:u,workspaceName:n,absoluteFilePath:e,generatorsConfiguration:i,changelog:a,cliVersion:r})}}if(await Vh(pf(e,zs.of(p9)))){let u=new P7n({absoluteFilePath:e,generatorsConfiguration:i,workspaceName:n,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:U0i});return{didSucceed:!0,workspace:u}}return{didSucceed:!1,failures:{[zs.of(HXr)]:{type:Xw.MISCONFIGURED_DIRECTORY}}}}var FAf=require("fs/promises");var LAf=yu(require("path"),1);async function wOu({fernDirectory:e,context:t}){let r=pf(e,zs.of(qwr));if(!await Vh(r))return;let n=await Jk1({absolutePathToDocsDefinition:e,context:t});if(n!=null)return{type:"docs",absoluteFilePath:e,config:n,workspaceName:void 0,absoluteFilepathToDocsConfig:pf(e,zs.of(qwr))}}async function Jk1({absolutePathToDocsDefinition:e,context:t}){if(!await Vh(e))return;let r=pf(e,zs.of(qwr));return await Gk1({absolutePathOfConfiguration:r,context:t})}async function Gk1({absolutePathOfConfiguration:e,context:t}){let r=await(0,FAf.readFile)(e),n=av.load(r.toString());return await Kk1({value:n,context:t,filepathBeingParsed:e})}async function Kk1({value:e,context:t,filepathBeingParsed:r}){let n=await Pre.RawSchemas.Serializer.DocsConfiguration.parse(e);if(n.ok)return n.value;let i=n.errors.map(u=>{let f=u.path.length>0?`${u.message} at "${u.path.join(" -> ")}"`:u.message;return VX({content:f,prefix:" - "})}),a=[`Failed to parse file: ${LAf.default.relative(process.cwd(),r)}`,...i].join(`
1917
1917
  `);return t.failAndThrow(a)}var UAf=require("fs/promises");async function DOu({context:e,nameOverride:t,...r}){let n=await wBt(t);return n==null?e.failAndThrow(`Directory "${t??Qqt}" not found.`):await VAf({absolutePathToFernDirectory:n,context:e,nameOverride:t,...r})}async function VAf({absolutePathToFernDirectory:e,cliName:t,cliVersion:r,commandLineApiWorkspace:n,defaultToAllApiWorkspaces:i,context:a}){let u=[];return(await Vh(pf(e,zs.of(p4r)))||await Vh(pf(e,zs.of(p9)))||await Vh(pf(e,zs.of(a5)))||await Vh(pf(e,zs.of(HXr)))||await Vh(pf(e,zs.of(ONc))))&&(u=await WAf({cliName:t,fernDirectory:e,cliVersion:r,context:a,commandLineApiWorkspace:n,defaultToAllApiWorkspaces:i})),{config:await t5t.loadProjectConfig({directory:e,context:a}),apiWorkspaces:u,docsWorkspaces:await wOu({fernDirectory:e,context:a}),loadAPIWorkspace:f=>f==null?u[0]:u.find(d=>d.workspaceName===f)}}async function WAf({cliName:e,fernDirectory:t,context:r,cliVersion:n,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:a}){let u=pf(t,zs.of(p4r));if(await Vh(u)){let o=(await(0,UAf.readdir)(u,{withFileTypes:!0})).reduce((O,j)=>(j.isDirectory()&&O.push(j.name),O),[]);if(i!=null){if(!o.includes(i))return r.failAndThrow("API does not exist: "+i)}else{if(o.length===0)return r.failAndThrow("No APIs found.");if(o.length>1&&!a){let O=`There are multiple workspaces. You must specify one with --api:
1918
1918
  `,j=Math.max(...o.map(S=>S.length));return O+=o.map(S=>{let x=`${e} ${process.argv.slice(2).join(" ")} --api ${S}`;return` \u203A ${al.bold(S.padEnd(j))} ${al.dim(x)}`}).join(`
1919
1919
  `),r.failAndThrow(O)}}let l=[],g=i!=null?o.filter(O=>O===i):o;return await Promise.all(g.map(async O=>{let j=await U0i({absolutePathToWorkspace:pf(u,zs.of(O)),context:r,cliVersion:n,workspaceName:O});j.didSucceed?l.push(j.workspace):(POu(j,r.logger),r.failAndThrow())})),l}let d=await U0i({absolutePathToWorkspace:t,context:r,cliVersion:n,workspaceName:void 0});return d.didSucceed?[d.workspace]:(POu(d,r.logger),[])}async function q7(e,t,r=!1){let n=e.addTask().start(),i=await DOu({...t,cliName:e.environment.cliName,cliVersion:e.environment.packageVersion,context:n});return n.finish(),r&&i.docsWorkspaces!=null?e.registerWorkspaces([...i.apiWorkspaces,i.docsWorkspaces]):e.registerWorkspaces(i.apiWorkspaces),e.registerProject(i),i}var XAf=yu(uZi(),1);var HAf=require("fs/promises");async function $Af({cliContext:e,generatorFilter:t,groupFilter:r,apiFilter:n,apiKeyFallback:i="FERN_DEFAULT",project:{apiWorkspaces:a},outputLocation:u}){let f={};await Promise.all(a.map(async c=>{await e.runTaskForWorkspace(c,async o=>{if(n!=null&&(c.workspaceName==null||!n.has(c.workspaceName)))return;let l=await pg.loadGeneratorsConfiguration({absolutePathToWorkspace:c.absoluteFilePath,context:o});if(l==null||l.groups==null)return;let g=c.workspaceName??i;f[g]={};for(let O of l.groups)r!=null&&!r.has(O.groupName)||(f[g][O.groupName]=O.generators.filter(j=>t==null||t.has(j.name)).map(j=>j.name))})}));let d=av.dump(f);if(u==null){process.stdout.write(d);return}try{await(0,HAf.writeFile)(u,d)}catch(c){e.failAndThrow(`Could not write file to the specified location: ${u}`,c)}}async function JAf({cliContext:e,generatorFilter:t,groupFilter:r,apiFilter:n,project:{apiWorkspaces:i}}){let a;return await Promise.all(i.map(async u=>{await e.runTaskForWorkspace(u,async f=>{if(n!=null&&(u.workspaceName==null||n!==u.workspaceName))return;let d=await pg.loadGeneratorsConfiguration({absolutePathToWorkspace:u.absoluteFilePath,context:f});if(!(d==null||d.groups==null)){for(let c of d.groups)if(r===c.groupName)for(let o of c.generators)t===o.name&&(a=o)}})})),a}var GAf=require("fs/promises");async function KAf({project:e,outputLocation:t,context:r}){let n=e.config.organization;if(t==null){process.stdout.write(n);return}try{await(0,GAf.writeFile)(t,n)}catch(i){r.failAndThrow(`Could not write file to the specified location: ${t}`,i)}}var k1a=require("fs/promises"),V0i=yu(require("path"),1),k3n=yu(VQ(),1);async function Yk1({absolutePathToWorkspace:e,context:t,generatorFilter:r,groupFilter:n,includeMajor:i,channel:a,cliVersion:u}){let f=pg.getPathToGeneratorsConfiguration({absolutePathToWorkspace:e});if(!await Vh(f)){t.logger.debug("Generators configuration file was not found, no generators to upgrade.");return}let d=await(0,k1a.readFile)(f);t.logger.debug(`Found generators: ${d.toString()}`);let c=k3n.default.parseDocument(d.toString()),o=c.get("groups");if(o==null){t.logger.debug("No groups were found within the generators configuration, no generators to upgrade.");return}if(!k3n.default.isMap(o)){t.failAndThrow(`Expected 'groups' to be a map in ${V0i.default.relative(process.cwd(),f)}`);return}t.logger.debug(`Groups found: ${o.toString()}`);for(let l of o.items){let g=l.key.value,O=l.value;if(!k3n.default.isMap(O)){t.failAndThrow(`Expected group ${g} to be a map in ${V0i.default.relative(process.cwd(),f)}`);continue}if(n!=null&&n!==g){t.logger.debug(`Skipping group ${g} as it does not match the filter: ${n}`);continue}let j=O.get("generators");if(!k3n.default.isSeq(j)){t.failAndThrow(`Expected group ${g} to have a 'generators' key in ${V0i.default.relative(process.cwd(),f)}`);continue}t.logger.debug(`Generators found: ${j.toString()}`);for(let S of j.items){k3n.default.isMap(S)||t.failAndThrow(`Expected generator in group ${g} to be a map in ${V0i.default.relative(process.cwd(),f)}`);let x=S.get("name");if(r!=null&&x!==r){t.logger.debug(`Skipping generator ${x} as it does not match the filter: ${r}`);continue}let A=pg.getGeneratorNameOrThrow(x,t),z=S.get("version"),N=await pg.getLatestGeneratorVersion({generatorName:A,cliVersion:u,currentGeneratorVersion:z,channel:a,includeMajor:i,context:t});N!=null&&(t.logger.debug(al.green(`Upgrading ${x} from ${z} to ${N}`)),S.set("version",N))}}return c.toString()}async function YAf({cliContext:e,generator:t,group:r,project:{apiWorkspaces:n},includeMajor:i,channel:a}){await Promise.all(n.map(async u=>{await e.runTaskForWorkspace(u,async f=>{var o;let d=await pg.loadRawGeneratorsConfiguration({absolutePathToWorkspace:u.absoluteFilePath,context:f})??{};if(d==null||d.groups==null){f.logger.debug("No groups were found within the generators configuration, no generators to upgrade.");return}u.workspaceName==null?f.logger.info("Upgrading generators."):f.logger.info(`Upgrading generators in workspace: ${u.workspaceName}.`);let c=await Yk1({absolutePathToWorkspace:u.absoluteFilePath,context:f,generatorFilter:t,groupFilter:r,includeMajor:i,channel:a,cliVersion:e.environment.packageVersion});c!=null&&await(0,k1a.writeFile)(((o=u.generatorsConfiguration)==null?void 0:o.absolutePathToConfiguration)??pg.getPathToGeneratorsConfiguration({absolutePathToWorkspace:u.absoluteFilePath}),c)})}))}var QAf=require("fs/promises");function ZAf(e,t){e.command("organization",!1,r=>r.option("output",{string:!0,alias:"o",description:"The location to output the organization name as a text file, defaults to standard out."}),async r=>{await t.instrumentPostHogEvent({command:"fern organization",properties:{outputLocation:r.output}}),await KAf({project:await q7(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),context:t,outputLocation:r.output})})}function kAf(e,t){e.command("generator","Operate on the generators within your Fern configuration",r=>{r.command("list",!1,n=>n.option("output",{string:!0,alias:"o",description:"The location to output the list as a text file, defaults to standard out."}).option("generators",{string:!0,type:"array",description:"The type of generator to include in the list, ex: `fern-typescript-node-sdk`. If omitted, all generators will be listed."}).option("groups",{type:"array",string:!0,description:"The groups to include generators from, if group is not specified, the all generators of the specified type will be listed."}).option("apis",{type:"array",string:!0,description:"The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."}).option("api-fallback",{string:!0,description:"The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."}),async n=>{await t.instrumentPostHogEvent({command:"fern generator list",properties:{outputLocation:n.output}}),await $Af({project:await q7(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),generatorFilter:n.generators?new Set(n.generators):void 0,groupFilter:n.groups?new Set(n.groups):void 0,apiFilter:n.apis?new Set(n.apis):void 0,apiKeyFallback:n.apiFallback,cliContext:t,outputLocation:n.output})}).command("upgrade",`Upgrades the specified generator in ${a5} to the latest stable version.`,n=>n.option("generator",{string:!0,description:"The type of generator to upgrade, ex: `fern-typescript-node-sdk`."}).option("group",{string:!0,description:"The group in which the generator is located, if group is not specified, the all generators of the specified type will be upgraded."}).option("api",{string:!0,description:"The API to upgrade the generator for. If not specified, the generator will be upgraded for all APIs."}).option("include-major",{boolean:!0,default:!1,description:"Whether or not to include major versions within the upgrade. Defaults to false, meaning major versions will be skipped."}).option("channel",{demandOption:!1,choices:Object.values(XAf.FernRegistry.generators.ReleaseType)}).option("list",{demandOption:!1,boolean:!0,default:!1,description:"When specified, a list of available upgrades will be displayed, but no upgrade will be taken."}),async n=>{await t.instrumentPostHogEvent({command:"fern generator upgrade",properties:{generator:n.generator,version:n.version,api:n.api,group:n.group,includeMajor:n.includeMajor,rc:n.rc}});let i=await q7(t,{commandLineApiWorkspace:n.api,defaultToAllApiWorkspaces:!0});if(n.list){t.suppressUpgradeMessage();let a=await qha({cliContext:t,project:i,generatorFilter:n.generator,groupFilter:n.group,includeMajor:n.includeMajor,channel:n.channel}),u=await zsu({generatorUpgradeInfo:a,header:`Generator Upgrades
@@ -2266,7 +2266,7 @@ l0,-`+(r+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
2266
2266
  `.repeat(c)||" "),c=-1,d.push(o))}return d.join("")}function jkf(e,t,r){return e.type==="element"?nxj(e,t,r):e.type==="text"?r.whitespace==="normal"?wkf(e,r):ixj(e):[]}function nxj(e,t,r){let n=Dkf(e,r),i=e.children||[],a=-1,u=[];if(rxj(e))return u;let f,d;for(Lxu(e)||Okf(e)&&vMa(t,e,Okf)?d=`
2267
2267
  `:txj(e)?(f=2,d=2):Pkf(e)&&(f=1,d=1);++a<i.length;)u=u.concat(jkf(i[a],e,{whitespace:n,breakBefore:a?void 0:f,breakAfter:a<i.length-1?Lxu(i[a+1]):d}));return mkf(e)&&vMa(t,e,mkf)&&u.push(" "),f&&u.unshift(f),d&&u.push(d),u}function wkf(e,t){let r=String(e.value),n=[],i=[],a=0;for(;a<=r.length;){bkf.lastIndex=a;let d=bkf.exec(r),c=d&&"index"in d?d.index:r.length;n.push(axj(r.slice(a,c).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),a===0?t.breakBefore:!0,c===r.length?t.breakAfter:!0)),a=c+1}let u=-1,f;for(;++u<n.length;)n[u].charCodeAt(n[u].length-1)===8203||u<n.length-1&&n[u+1].charCodeAt(0)===8203?(i.push(n[u]),f=void 0):n[u]?(typeof f=="number"&&i.push(f),i.push(n[u]),f=0):(u===0||u===n.length-1)&&i.push(0);return i}function ixj(e){return[String(e.value)]}function axj(e,t,r){let n=[],i=0,a;for(;i<e.length;){gkf.lastIndex=i;let u=gkf.exec(e);a=u?u.index:e.length,!i&&!a&&u&&!t&&n.push(""),i!==a&&n.push(e.slice(i,a)),i=u?a+u[0].length:a}return i!==a&&!r&&n.push(""),n.join(" ")}function Dkf(e,t){if(e.type==="element"){let r=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return r.wrap?"pre-wrap":"pre";case"td":case"th":return r.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap";default:}}return t.whitespace}function oxj(e){return Boolean((e.properties||{}).hidden)}function uxj(e){return e.tagName==="td"||e.tagName==="th"}function sxj(e){return e.tagName==="dialog"&&!(e.properties||{}).open}var cxj={},lxj=[];function bMa(e){let t=e||cxj;return function(r,n){irn(r,"element",function(i,a){let u=Array.isArray(i.properties.className)?i.properties.className:lxj,f=u.includes("language-math"),d=u.includes("math-display"),c=u.includes("math-inline"),o=d;if(!f&&!d&&!c)return;let l=a[a.length-1],g=i;if(i.tagName==="code"&&f&&l&&l.type==="element"&&l.tagName==="pre"&&(g=l,l=a[a.length-2],o=!0),!l)return;let O=Uxu(g,{whitespace:"pre"}),j;try{j=lxu.renderToString(O,{...t,displayMode:o,throwOnError:!0})}catch(x){let A=x,z=A.name.toLowerCase();n.message("Could not render math with KaTeX",{ancestors:[...a,i],cause:A,place:i.position,ruleId:z,source:"rehype-katex"}),z==="parseerror"?j=lxu.renderToString(O,{...t,displayMode:o,strict:"ignore",throwOnError:!1}):j=[{type:"element",tagName:"span",properties:{className:["katex-error"],style:"color:"+(t.errorColor||"#cc0000"),title:String(x)},children:[{type:"text",value:O}]}]}typeof j=="string"&&(j=Rxu(j,{fragment:!0}).children);let S=l.children.indexOf(g);return l.children.splice(S,1,...j),cNn})}}var Vxu={name:"valid-markdown",create:()=>({markdownPage:async({content:e})=>{let t=await _xj({markdown:e});if(t.type==="failure"){let r=t.message!=null?`Markdown failed to parse: ${t.message}`:"Markdown failed to parse";return[{severity:"error",message:r}]}return[]}})},fxj=[DEa,QEa],dxj=[bMa],pxj=nr.object({title:nr.optional(nr.string(),{description:"Renders as the page title."}),"og:title":nr.optional(nr.string(),{description:"Renders as the og:title tag."}),"og:description":nr.optional(nr.string(),{description:"Renders as the og:description tag."}),subtitle:nr.optional(nr.string(),{description:"Renders as a subtitle on the page, and is also used in the meta description tag if description is not set."}),description:nr.optional(nr.string(),{description:"Renders as the meta description tag."}),image:nr.optional(nr.string(),{description:"Renders as the og:image tag."}),slug:nr.optional(nr.string(),{description:"The full slug path for the page, starting from root `/` (or basepath)."}),redirects:nr.optional(nr.array(nr.string()),{description:"A list of URLs to redirect to this page."}),editThisPageUrl:nr.optional(nr.string()),excerpt:nr.optional(nr.string(),{description:"Deprecated. Use `subtitle` instead."})});async function _xj({markdown:e}){try{let t=await BEu(e,{scope:{},mdxOptions:{remarkPlugins:fxj,rehypePlugins:dxj,format:"detect"},parseFrontmatter:!0}),r=pxj.safeParse(t.frontmatter);return r.success?{type:"success"}:{type:"failure",message:`Failed to parse frontmatter: ${r.error.errors.map(n=>n.message).join(`
2268
2268
  `)}`}}catch(t){return{type:"failure",message:t instanceof Error?t.message:void 0}}}function Skf({relativeFilepath:e,allRuleVisitors:t,addViolations:r}){function n(i){let a=async(u,f)=>{for(let d of t){let c=d[i];if(c!=null){let o=await c(u);r(o.map(l=>({severity:l.severity,relativeFilepath:e,nodePath:f,message:l.message})))}}};return{[i]:a}}return{...n("file"),...n("filepath"),...n("markdownPage"),...n("versionFile"),...n("apiSection")}}var Hxu=require("fs/promises");var xkf=yu(require("path"),1);async function Tkf(e,t,r,n,i,a){var f,d,c,o,l,g,O,j,S,x,A,z,N,C,U,Y;await((f=t.file)==null?void 0:f.call(t,{config:e},[]));let u={};try{let{pages:te}=await Pre.parseDocsConfiguration({rawDocsConfiguration:e,context:i,absoluteFilepathToDocsConfig:r,absolutePathToFernFolder:n});u=te}catch{}for(let[te,G]of Object.entries(u))u[zs.of(te)]=await evi({markdown:G,absolutePathToFernFolder:n,absolutePathToMdx:w2(n,te),context:i}),u[zs.of(te)]=await tvi({markdown:G,absolutePathToFernFolder:n,absolutePathToMdx:w2(n,te),context:i});for(let[te,G]of Object.entries(u)){let{filepaths:$}=k0i(G,{absolutePathToFernFolder:n,absolutePathToMdx:w2(n,te)});for(let ee of $)await((d=t.filepath)==null?void 0:d.call(t,{absoluteFilepath:ee,value:xkf.default.relative(n,ee),willBeUploaded:!0},[te]))}e.js!=null&&(Array.isArray(e.js)?await Promise.all(e.js.map((te,G)=>Mkf({absoluteFilepathToConfiguration:r,visitor:t,script:te,nodePath:["js",`${G}`]}))):await Mkf({absoluteFilepathToConfiguration:r,visitor:t,script:e.js,nodePath:["js"]})),e.css!=null&&(Array.isArray(e.css)?await Promise.all(e.css.map((te,G)=>FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:te,visitor:t,nodePath:["css",`${G}`],willBeUploaded:!1}))):await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.css,visitor:t,nodePath:["css"],willBeUploaded:!1})),e.backgroundImage!=null&&(typeof e.backgroundImage=="string"?await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.backgroundImage,visitor:t,nodePath:["background-image"]}):(e.backgroundImage.dark!=null&&await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.backgroundImage.dark,visitor:t,nodePath:["background-image","dark"]}),e.backgroundImage.light!=null&&await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.backgroundImage.light,visitor:t,nodePath:["background-image","light"]}))),e.favicon!=null&&await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.favicon,visitor:t,nodePath:["favicon"]}),((c=e.logo)==null?void 0:c.dark)!=null&&await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.logo.dark,visitor:t,nodePath:["logo","dark"]}),((o=e.logo)==null?void 0:o.light)!=null&&await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.logo.light,visitor:t,nodePath:["logo","light"]}),e.navigation!=null&&await Ekf({navigation:e.navigation,visitor:t,nodePath:["navigation"],absoluteFilepathToConfiguration:r,loadAPIWorkspace:a,context:i}),((g=(l=e.typography)==null?void 0:l.codeFont)==null?void 0:g.path)!=null&&await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.typography.codeFont.path,visitor:t,nodePath:["typography","codeFont"]});for(let te of((j=(O=e.typography)==null?void 0:O.codeFont)==null?void 0:j.paths)??[])await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:typeof te=="string"?te:te.path,visitor:t,nodePath:["typography","codeFont"]});((x=(S=e.typography)==null?void 0:S.bodyFont)==null?void 0:x.path)!=null&&await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.typography.bodyFont.path,visitor:t,nodePath:["typography","bodyFont"]});for(let te of((z=(A=e.typography)==null?void 0:A.bodyFont)==null?void 0:z.paths)??[])await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:typeof te=="string"?te:te.path,visitor:t,nodePath:["typography","bodyFont"]});((C=(N=e.typography)==null?void 0:N.headingsFont)==null?void 0:C.path)!=null&&await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.typography.headingsFont.path,visitor:t,nodePath:["typography","headingsFont"]});for(let te of((Y=(U=e.typography)==null?void 0:U.headingsFont)==null?void 0:Y.paths)??[])await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:typeof te=="string"?te:te.path,visitor:t,nodePath:["typography","headingsFont"]});e.versions!=null&&await Promise.all(e.versions.map(async(te,G)=>{var Je;await FW({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:te.path,visitor:t,nodePath:["versions",`${G}`],willBeUploaded:!1});let $=w2(Cg(r),te.path),ee=av.load((await(0,Hxu.readFile)($)).toString());await Vh($)&&await((Je=t.versionFile)==null?void 0:Je.call(t,{path:te.path,content:ee},[te.path]));let Ve=await SSa({value:ee});Ve.type==="success"&&await Ekf({navigation:Ve.contents.navigation,visitor:t,nodePath:["navigation"],absoluteFilepathToConfiguration:$,loadAPIWorkspace:a,context:i})}))}async function FW({absoluteFilepathToConfiguration:e,rawUnresolvedFilepath:t,visitor:r,nodePath:n,willBeUploaded:i=!0}){var u;let a=w2(Cg(e),t);await((u=r.filepath)==null?void 0:u.call(r,{absoluteFilepath:a,value:t,willBeUploaded:i},n))}async function Ekf({navigation:e,visitor:t,nodePath:r,absoluteFilepathToConfiguration:n,loadAPIWorkspace:i,context:a}){bxj(e)?await Promise.all(e.map(async(u,f)=>{u.layout!=null&&await Promise.all(u.layout.map(async(d,c)=>{await Wxu({navigationItem:d,visitor:t,nodePath:[...r,`${f}`,"layout",`${c}`],absoluteFilepathToConfiguration:n,loadAPIWorkspace:i,context:a})}))})):await Promise.all(e.map(async(u,f)=>{await Wxu({navigationItem:u,visitor:t,nodePath:[...r,`${f}`],absoluteFilepathToConfiguration:n,loadAPIWorkspace:i,context:a})}))}async function Wxu({navigationItem:e,visitor:t,nodePath:r,absoluteFilepathToConfiguration:n,loadAPIWorkspace:i,context:a}){var u,f;if(hxj(e)){await FW({absoluteFilepathToConfiguration:n,rawUnresolvedFilepath:e.path,visitor:t,nodePath:[...r,"page"],willBeUploaded:!1});let d=w2(Cg(n),e.path);if(await Vh(d)){let c=(await(0,Hxu.readFile)(d)).toString();await((u=t.markdownPage)==null?void 0:u.call(t,{title:e.page,content:c,absoluteFilepath:d},[...r,"page",e.path]))}}if(yxj(e)&&await Promise.all(e.contents.map(async(d,c)=>{await Wxu({navigationItem:d,visitor:t,nodePath:[...r,"section","contents",`${c}`],absoluteFilepathToConfiguration:n,loadAPIWorkspace:i,context:a})})),vxj(e)){let d=i(e.apiName!=null?e.apiName:void 0);d!=null&&await((f=t.apiSection)==null?void 0:f.call(t,{config:e,workspace:d,context:a},[...r,"api"]))}}async function Mkf({absoluteFilepathToConfiguration:e,visitor:t,script:r,nodePath:n}){let i=typeof r=="string"?r:"path"in r?r.path:null;i&&await FW({absoluteFilepathToConfiguration:e,rawUnresolvedFilepath:i,visitor:t,nodePath:n,willBeUploaded:!0})}function hxj(e){return e.page!=null}function yxj(e){return e.section!=null}function vxj(e){return e.api!=null}function bxj(e){var t;return((t=e[0])==null?void 0:t.tab)!=null}var qkf={name:"accent-color-contrast",create:()=>({file:async({config:e})=>{if(e.colors==null)return[];let t=Pre.getColorType(e.colors);return t==="dark"?gMa(e.colors,"dark"):t==="light"?gMa(e.colors,"light"):t==="darkAndLight"?[...gMa(e.colors,"dark"),...gMa(e.colors,"light")]:[]}})};function gMa(e,t){let r=Pre.getColorFromRawConfig(e.accentPrimary??e.accentPrimaryDeprecated,"accent-primary",t),n=Pre.getColorFromRawConfig(e.background,"background",t)??(t==="dark"?"#000":"#FFF"),i=[];if(!ky(n).isValid())i.push({severity:"error",message:`Invalid background color provided for colors.background.${t}: ${n}.`});else{let a=gxj(ky(n),t);ky(n).toHexString()!==a.toHexString()&&i.push({severity:"warning",message:`The provided background color for ${t} mode is not ${t} enough. It will be adjusted to ${a.toHexString()}.`}),n=a.toHexString()}if(r==null)i.push({severity:"warning",message:`No accent-color provided for ${t} mode. A random color will be used.`});else if(!ky(r).isValid())i.push({severity:"error",message:`Invalid accent-color provided for colors.accent-primary.${t}: ${r}.`});else{let a=ky.readability(r,n),u=`${a.toFixed(2)}:1`;a<3?i.push({severity:"warning",message:`The contrast ratio between the accent color and the background color for ${t} mode is ${u}. It should be at least 3:1.`}):a<4.5?i.push({severity:"warning",message:`The contrast ratio between the accent color and the background color for ${t} mode is ${u}. Fern will adjust the color to meet the minimum contrast ratio of 4.5:1 for WCAG AA and 7:1 for WCAG AAA.`}):a<7&&i.push({severity:"warning",message:`The contrast ratio between the accent color and the background color for ${t} mode is ${u}. Fern will adjust the color to meet the minimum contrast ratio of 7:1 for WCAG AAA.`})}return i}function gxj(e,t){return t==="dark"&&e.isDark()||t==="light"&&e.isLight()?e:mxj(e)}function mxj(e){if(e==null)return;let{h:t,s:r,v:n}=e.toHsv();return ky({h:t,s:r,v:1-n})}var $xu={name:"filepaths-exist",create:()=>({filepath:async({absoluteFilepath:e,value:t})=>await Vh(e)?[]:[{severity:"error",message:`Path ${t} does not exist`}]})};var Jxu={name:"only-versioned-navigation",create:()=>({file:async({config:e})=>e.navigation!=null&&e.versions!=null?[{severity:"error",message:"Cannot contain both navigation and versions. If you want versioned docs, use versions. Otherwise use navigation."}]:[]})};var Gxu={name:"playground-environments-exist",create:()=>({apiSection:async({workspace:e,context:t,config:r})=>{var f;let n=(await e.getDefinition({context:t})).rootApiFile.contents.environments,i=new Set(Object.keys(n??{})),a=(f=r.playground)==null?void 0:f.environments;if(a==null||a.length==null)return[];let u=a.filter(d=>!i.has(d));return u.length===0?[]:u.length===1?[{severity:"error",message:`The API does not contain the ${u[0]} environment. ${Ckf(Array.from(i))??""}`}]:[{severity:"error",message:`The API does not contain the following enviroments: ${u.join(", ")}. ${Ckf(Array.from(i))??""}`}]}})};function Ckf(e){if(e.length!==0)return e.length===1&&e[0]!=null?`The only configured environment is ${e[0]}`:`Existing enviroments include ${e.join(", ")}.`}var Kxu={name:"valid-docs-endpoints",create:()=>({file:async({config:e})=>{var n,i;return!e.analytics||!Object.keys(e.analytics).length?[]:[[(n=e.analytics.intercom)==null?void 0:n.apiBase,"Intercom API Base"],[(i=e.analytics.posthog)==null?void 0:i.endpoint,"Posthog Host Endpoint"]].filter(([a])=>a&&!Oxj(a)).map(([a,u])=>({severity:"warning",message:`${u} <${a}> is malformed. Make sure it includes a protocol (e.g. 'https://')!`}))}})};function Oxj(e){try{let t=new URL(e);return Boolean(t.protocol)}catch{return!1}}var ced=yu($kf(),1);var $xj="End-Of-Stream",F3=class extends Error{constructor(){super($xj)}};var SMa=class{constructor(){this.resolve=()=>null,this.reject=()=>null,this.promise=new Promise((t,r)=>{this.reject=r,this.resolve=t})}};var Jxj=1*1024*1024,rmi=class{constructor(t){if(this.s=t,this.deferred=null,this.endOfStream=!1,this.peekQueue=[],!t.read||!t.once)throw new Error("Expected an instance of stream.Readable");this.s.once("end",()=>this.reject(new F3)),this.s.once("error",r=>this.reject(r)),this.s.once("close",()=>this.reject(new Error("Stream closed")))}async peek(t,r,n){let i=await this.read(t,r,n);return this.peekQueue.push(t.subarray(r,r+i)),i}async read(t,r,n){if(n===0)return 0;if(this.peekQueue.length===0&&this.endOfStream)throw new F3;let i=n,a=0;for(;this.peekQueue.length>0&&i>0;){let u=this.peekQueue.pop();if(!u)throw new Error("peekData should be defined");let f=Math.min(u.length,i);t.set(u.subarray(0,f),r+a),a+=f,i-=f,f<u.length&&this.peekQueue.push(u.subarray(f))}for(;i>0&&!this.endOfStream;){let u=Math.min(i,Jxj),f=await this.readFromStream(t,r+a,u);if(a+=f,f<u)break;i-=f}return a}async readFromStream(t,r,n){let i=this.s.read(n);if(i)return t.set(i,r),i.length;{let a={buffer:t,offset:r,length:n,deferred:new SMa};return this.deferred=a.deferred,this.s.once("readable",()=>{this.readDeferred(a)}),a.deferred.promise}}readDeferred(t){let r=this.s.read(t.length);r?(t.buffer.set(r,t.offset),t.deferred.resolve(r.length),this.deferred=null):this.s.once("readable",()=>{this.readDeferred(t)})}reject(t){this.endOfStream=!0,this.deferred&&(this.deferred.reject(t),this.deferred=null)}};var STu=require("buffer"),X8n=class{constructor(t){this.position=0,this.numBuffer=new Uint8Array(8),this.fileInfo=t||{}}async readToken(t,r=this.position){let n=STu.Buffer.alloc(t.len);if(await this.readBuffer(n,{position:r})<t.len)throw new F3;return t.get(n,0)}async peekToken(t,r=this.position){let n=STu.Buffer.alloc(t.len);if(await this.peekBuffer(n,{position:r})<t.len)throw new F3;return t.get(n,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new F3;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new F3;return t.get(this.numBuffer,0)}async ignore(t){if(this.fileInfo.size!==void 0){let r=this.fileInfo.size-this.position;if(t>r)return this.position+=r,r}return this.position+=t,t}async close(){}normalizeOptions(t,r){if(r&&r.position!==void 0&&r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return r?{mayBeLess:r.mayBeLess===!0,offset:r.offset?r.offset:0,length:r.length?r.length:t.length-(r.offset?r.offset:0),position:r.position?r.position:this.position}:{mayBeLess:!1,offset:0,length:t.length,position:this.position}}};var Gxj=256e3,EMa=class extends X8n{constructor(t,r){super(r),this.streamReader=new rmi(t)}async getFileInfo(){return this.fileInfo}async readBuffer(t,r){let n=this.normalizeOptions(t,r),i=n.position-this.position;if(i>0)return await this.ignore(i),this.readBuffer(t,r);if(i<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let a=await this.streamReader.read(t,n.offset,n.length);if(this.position+=a,(!r||!r.mayBeLess)&&a<n.length)throw new F3;return a}async peekBuffer(t,r){let n=this.normalizeOptions(t,r),i=0;if(n.position){let a=n.position-this.position;if(a>0){let u=new Uint8Array(n.length+a);return i=await this.peekBuffer(u,{mayBeLess:n.mayBeLess}),t.set(u.subarray(a),n.offset),i-a}else if(a<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{i=await this.streamReader.peek(t,n.offset,n.length)}catch(a){if(r&&r.mayBeLess&&a instanceof F3)return 0;throw a}if(!n.mayBeLess&&i<n.length)throw new F3}return i}async ignore(t){let r=Math.min(Gxj,t),n=new Uint8Array(r),i=0;for(;i<t;){let a=t-i,u=await this.readBuffer(n,{length:Math.min(r,a)});if(u<0)return u;i+=u}return i}};var MMa=class extends X8n{constructor(t,r){super(r),this.uint8Array=t,this.fileInfo.size=this.fileInfo.size?this.fileInfo.size:t.length}async readBuffer(t,r){if(r&&r.position){if(r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");this.position=r.position}let n=await this.peekBuffer(t,r);return this.position+=n,n}async peekBuffer(t,r){let n=this.normalizeOptions(t,r),i=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&i<n.length)throw new F3;return t.set(this.uint8Array.subarray(n.position,n.position+i),n.offset),i}async close(){}};function Jkf(e,t){return t=t||{},new EMa(e,t)}function Gkf(e,t){return new MMa(e,t)}var pMr=require("buffer");var Ykf=yu(Kkf(),1),Xkf=require("buffer");function nie(e){return new DataView(e.buffer,e.byteOffset)}var Qkf={len:1,get(e,t){return nie(e).getUint8(t)},put(e,t,r){return nie(e).setUint8(t,r),t+1}},xMa={len:2,get(e,t){return nie(e).getUint16(t,!0)},put(e,t,r){return nie(e).setUint16(t,r,!0),t+2}},TMa={len:2,get(e,t){return nie(e).getUint16(t)},put(e,t,r){return nie(e).setUint16(t,r),t+2}};var Zkf={len:4,get(e,t){return nie(e).getUint32(t,!0)},put(e,t,r){return nie(e).setUint32(t,r,!0),t+4}},kkf={len:4,get(e,t){return nie(e).getUint32(t)},put(e,t,r){return nie(e).setUint32(t,r),t+4}};var eed={len:4,get(e,t){return nie(e).getInt32(t)},put(e,t,r){return nie(e).setInt32(t,r),t+4}};var ted={len:8,get(e,t){return nie(e).getBigUint64(t,!0)},put(e,t,r){return nie(e).setBigUint64(t,r,!0),t+8}};var dMr=class{constructor(t,r){this.len=t,this.encoding=r}get(t,r){return Xkf.Buffer.from(t).toString(this.encoding,r,r+this.len)}},fMr=class{constructor(t){this.len=t}static decode(t,r,n){let i="";for(let a=r;a<n;++a)i+=fMr.codePointToString(fMr.singleByteDecoder(t[a]));return i}static inRange(t,r,n){return r<=t&&t<=n}static codePointToString(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}static singleByteDecoder(t){if(fMr.inRange(t,0,127))return t;let r=fMr.windows1252[t-128];if(r===null)throw Error("invaliding encoding");return r}get(t,r=0){return fMr.decode(t,r,r+this.len)}};fMr.windows1252=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255];function red(e){return[...e].map(t=>t.charCodeAt(0))}function ned(e,t=0){let r=Number.parseInt(e.toString("utf8",148,154).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let n=8*32;for(let i=t;i<t+148;i++)n+=e[i];for(let i=t+156;i<t+512;i++)n+=e[i];return r===n}var ied={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4};var aed=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","ai","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx"],oed=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/x-apache-arrow","video/mp4","audio/midi","video/x-matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","audio/opus","video/ogg","audio/ogg","application/ogg","audio/x-flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/x-parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx"];var ued=4100;async function sed(e){return new MTu().fromBuffer(e)}function i9t(e,t,r){r={offset:0,...r};for(let[n,i]of t.entries())if(r.mask){if(i!==(r.mask[n]&e[n+r.offset]))return!1}else if(i!==e[n+r.offset])return!1;return!0}var MTu=class{constructor(t){this.detectors=t==null?void 0:t.customDetectors,this.fromTokenizer=this.fromTokenizer.bind(this),this.fromBuffer=this.fromBuffer.bind(this),this.parse=this.parse.bind(this)}async fromTokenizer(t){let r=t.position;for(let n of this.detectors||[]){let i=await n(t);if(i)return i;if(r!==t.position)return}return this.parse(t)}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`Buffer\` or \`ArrayBuffer\`, got \`${typeof t}\``);let r=t instanceof Uint8Array?t:new Uint8Array(t);if((r==null?void 0:r.length)>1)return this.fromTokenizer(Gkf(r))}async fromBlob(t){let r=await t.arrayBuffer();return this.fromBuffer(new Uint8Array(r))}async fromStream(t){let r=await Jkf(t);try{return await this.fromTokenizer(r)}finally{await r.close()}}async toDetectionStream(t,r={}){let{default:n}=await import("stream"),{sampleSize:i=ued}=r;return new Promise((a,u)=>{t.on("error",u),t.once("readable",()=>{(async()=>{try{let f=new n.PassThrough,d=n.pipeline?n.pipeline(t,f,()=>{}):t.pipe(f),c=t.read(i)??t.read()??pMr.Buffer.alloc(0);try{f.fileType=await this.fromBuffer(c)}catch(o){o instanceof F3?f.fileType=void 0:u(o)}a(d)}catch(f){u(f)}})()})})}check(t,r){return i9t(this.buffer,t,r)}checkString(t,r){return this.check(red(t),r)}async parse(t){if(this.buffer=pMr.Buffer.alloc(ued),t.fileInfo.size===void 0&&(t.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=t,await t.peekBuffer(this.buffer,{length:12,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await t.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.parse(t);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await t.ignore(6);let r=await t.readToken(ied);return t.position+r>t.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await t.ignore(r),this.fromTokenizer(t))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){try{for(;t.position+30<t.fileInfo.size;){await t.readBuffer(this.buffer,{length:30});let r={compressedSize:this.buffer.readUInt32LE(18),uncompressedSize:this.buffer.readUInt32LE(22),filenameLength:this.buffer.readUInt16LE(26),extraFieldLength:this.buffer.readUInt16LE(28)};if(r.filename=await t.readToken(new dMr(r.filenameLength,"utf-8")),await t.ignore(r.extraFieldLength),r.filename==="META-INF/mozilla.rsa")return{ext:"xpi",mime:"application/x-xpinstall"};if(r.filename.endsWith(".rels")||r.filename.endsWith(".xml"))switch(r.filename.split("/")[0]){case"_rels":break;case"word":return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};case"ppt":return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};case"xl":return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};default:break}if(r.filename.startsWith("xl/"))return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(r.filename.startsWith("3D/")&&r.filename.endsWith(".model"))return{ext:"3mf",mime:"model/3mf"};if(r.filename==="mimetype"&&r.compressedSize===r.uncompressedSize){let n=await t.readToken(new dMr(r.compressedSize,"utf-8"));switch(n=n.trim(),n){case"application/epub+zip":return{ext:"epub",mime:"application/epub+zip"};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:"application/vnd.oasis.opendocument.text"};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:"application/vnd.oasis.opendocument.spreadsheet"};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:"application/vnd.oasis.opendocument.presentation"};default:}}if(r.compressedSize===0){let n=-1;for(;n<0&&t.position<t.fileInfo.size;)await t.peekBuffer(this.buffer,{mayBeLess:!0}),n=this.buffer.indexOf("504B0304",0,"hex"),await t.ignore(n>=0?n:this.buffer.length)}else await t.ignore(r.compressedSize)}}catch(r){if(!(r instanceof F3))throw r}return{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await t.ignore(28);let r=pMr.Buffer.alloc(8);return await t.readBuffer(r),i9t(r,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/opus"}:i9t(r,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:i9t(r,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:i9t(r,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:i9t(r,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:i9t(r,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("ftyp",{offset:4})&&(this.buffer[8]&96)!==0){let r=this.buffer.toString("binary",8,12).replace("\0"," ").trim();switch(r){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return r.startsWith("3g")?r.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/x-flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF")){try{await t.ignore(1350);let r=10*1024*1024,n=pMr.Buffer.alloc(Math.min(r,t.fileInfo.size));if(await t.readBuffer(n,{mayBeLess:!0}),n.includes(pMr.Buffer.from("AIPrivateData")))return{ext:"ai",mime:"application/postscript"}}catch(r){if(!(r instanceof F3))throw r}return{ext:"pdf",mime:"application/pdf"}}if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let r=await this.readTiffHeader(!1);if(r)return r}if(this.check([77,77])){let r=await this.readTiffHeader(!0);if(r)return r}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function r(){let f=await t.peekNumber(Qkf),d=128,c=0;for(;(f&d)===0&&d!==0;)++c,d>>=1;let o=pMr.Buffer.alloc(c+1);return await t.readBuffer(o),o}async function n(){let f=await r(),d=await r();d[0]^=128>>d.length-1;let c=Math.min(6,d.length);return{id:f.readUIntBE(0,f.length),len:d.readUIntBE(d.length-c,c)}}async function i(f){for(;f>0;){let d=await n();if(d.id===17026)return(await t.readToken(new dMr(d.len,"utf-8"))).replaceAll(/\00.*$/g,"");await t.ignore(d.len),--f}}let a=await n();switch(await i(a.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/x-matroska"};default:return}}if(this.check([82,73,70,70])){if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1"))return{ext:"parquet",mime:"application/x-parquet"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let r=this.buffer.toString("binary",2,6);if(r.match("^d*")&&r>=1e3&&r<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await t.ignore(8),await t.readToken(new dMr(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("**ACE",{offset:7})&&(await t.peekBuffer(this.buffer,{length:14,mayBeLess:!0}),this.checkString("**",{offset:12})))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.check([137,80,78,71,13,10,26,10])){await t.ignore(8);async function r(){return{length:await t.readToken(eed),type:await t.readToken(new dMr(4,"binary"))}}do{let n=await r();if(n.length<0)return;switch(n.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await t.ignore(n.length+4)}}while(t.position+8<t.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/x-apache-arrow"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function r(){let n=pMr.Buffer.alloc(16);return await t.readBuffer(n),{id:n,size:Number(await t.readToken(ted))}}for(await t.ignore(30);t.position+24<t.fileInfo.size;){let n=await r(),i=n.size-24;if(i9t(n.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let a=pMr.Buffer.alloc(16);if(i-=await t.readBuffer(a),i9t(a,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(i9t(a,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await t.ignore(i)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await t.ignore(20),await t.readToken(new dMr(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.check([0,60,0,63,0,120,0,109,0,108],{offset:2})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await t.peekBuffer(this.buffer,{length:Math.min(256,t.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let r=this.buffer.readUInt32LE(12);if(r>12&&this.buffer.length>=r+16)try{let n=this.buffer.slice(16,r+16).toString();if(JSON.parse(n).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(await t.peekBuffer(this.buffer,{length:Math.min(512,t.fileInfo.size),mayBeLess:!0}),ned(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254]))return this.check([60,0,63,0,120,0,109,0,108,0],{offset:2})?{ext:"xml",mime:"application/xml"}:this.check([255,14,83,0,107,0,101,0,116,0,99,0,104,0,85,0,112,0,32,0,77,0,111,0,100,0,101,0,108,0],{offset:2})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:void 0;if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"};if(this.buffer.length>=2&&this.check([255,224],{offset:0,mask:[255,224]})){if(this.check([16],{offset:1,mask:[22]}))return this.check([8],{offset:1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}async readTiffTag(t){let r=await this.tokenizer.readToken(t?TMa:xMa);switch(this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(t){let r=await this.tokenizer.readToken(t?TMa:xMa);for(let n=0;n<r;++n){let i=await this.readTiffTag(t);if(i)return i}}async readTiffHeader(t){let r=(t?TMa:xMa).get(this.buffer,2),n=(t?kkf:Zkf).get(this.buffer,4);if(r===42){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=8&&(this.check([28,0,254,0],{offset:8})||this.check([31,0,11,0],{offset:8})))return{ext:"nef",mime:"image/x-nikon-nef"}}return await this.tokenizer.ignore(n),await this.readTiffIFD(t)??{ext:"tif",mime:"image/tiff"}}if(r===43)return{ext:"tif",mime:"image/tiff"}}};var U73=new Set(aed),V73=new Set(oed);var led=require("fs/promises"),fed=yu(require("path"),1),Xxj=new Set(["image/jpeg","image/png","image/gif","image/webp","image/tiff","image/x-icon","video/quicktime","video/mp4","video/webm","audio/mpeg","audio/ogg","audio/wav","application/pdf","application/xml","font/woff","font/woff2","font/otf","font/ttf"]),Qxj=new Set(["js","svg"]),Zxj=new Set(["ASCII","UTF-8","UTF-16","ISO-8859-1","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-9","ISO-8859-10","ISO-8859-13","ISO-8859-14","ISO-8859-15","ISO-8859-16","WINDOWS-1250","WINDOWS-1251","WINDOWS-1252","WINDOWS-1253","WINDOWS-1254","WINDOWS-1255","WINDOWS-1256","WINDOWS-1257","WINDOWS-1258","SHIFT_JIS","SHIFT-JIS","EUC-JP","ISO-2022-JP","BIG5","GB2312","GB18030","KOI8-R"]),xTu={name:"valid-file-types",create:()=>({filepath:async({absoluteFilepath:e,willBeUploaded:t})=>t?await Vh(e)?kxj(e):[]:[]})},kxj=async e=>{let t=await(0,led.readFile)(e),r=await sed(t);if(r!=null)return Xxj.has(r.mime)?[]:[{severity:"error",message:`The file type of ${r.mime} is not allowed: ${e}`}];let n=fed.default.extname(e).toLowerCase();if(n.startsWith(".")&&(n=n.substring(1)),Qxj.has(n)){let i=ced.default.detect(t);return i==null?[{severity:"error",message:`The encoding of the file could not be detected: ${e}`}]:Zxj.has(i.toUpperCase())?[]:[{severity:"error",message:`The encoding of ${i} is not allowed: ${e}`}]}return[{severity:"error",message:`File is not allowed to be uploaded: ${e}`}]};var TTu={name:"validate-version-file",create:()=>({versionFile:async({path:e,content:t})=>{let r=await SSa({value:t});return r.type==="success"?[]:[{severity:"error",message:`Failed to parse ${e}: ${r.message}`}]}})};function ded(){return[$xu,Vxu,Jxu,TTu,qkf,dSu,xTu,Gxu,Kxu]}async function qTu(e,t,r){return eTj({workspace:e,rules:ded(),context:t,loadApiWorkspace:r})}async function eTj({workspace:e,rules:t,context:r,loadApiWorkspace:n}){let i=[],a=await Promise.all(t.map(f=>f.create({workspace:e,logger:r.logger}))),u=Skf({relativeFilepath:zs.of(qwr),allRuleVisitors:a,addViolations:f=>{i.push(...f)}});return await Tkf(e.config,u,pf(e.absoluteFilePath,zs.of(qwr)),e.absoluteFilePath,r,n),i}async function CTu({workspace:e,loadAPIWorkspace:t,context:r,logWarnings:n,logSummary:i=!0}){let a=await qTu(e,r,t),{hasErrors:u}=DSa({violations:a,context:r,logWarnings:n,logSummary:i});return{hasErrors:u}}async function qMa({workspace:e,loadAPIWorkspace:t,context:r,logWarnings:n}){let{hasErrors:i}=await CTu({workspace:e,context:r,logWarnings:n,loadAPIWorkspace:t});i&&r.failAndThrow()}async function ped({loadProject:e,cliContext:t,port:r,bundlePath:n}){let i=await e(),a=i.docsWorkspaces;a!=null&&(await t.instrumentPostHogEvent({orgId:i.config.organization,command:"fern docs dev"}),await t.runTaskForWorkspace(a,async u=>{u.logger.info(`Starting server on port ${r}`),await iDu({initialProject:i,reloadProject:e,validateProject:async f=>{let d=f.docsWorkspaces;if(d!=null){await CTu({workspace:d,context:u,logWarnings:!0,logSummary:!1,loadAPIWorkspace:f.loadAPIWorkspace});for(let c of f.apiWorkspaces)await t.runTaskForWorkspace(c,async o=>{await fSu({workspace:await c.toFernWorkspace({context:u}),context:o,logWarnings:!1,logSummary:!1})})}},context:u,port:r,bundlePath:n})}))}async function _ed({project:e,cliContext:t,shouldFix:r}){await Promise.all(e.apiWorkspaces.map(async n=>{n instanceof Vne||await t.runTaskForWorkspace(n,async i=>{await Suu({workspace:await n.toFernWorkspace({context:i}),context:i,shouldFix:r})})}))}var hed=require("fs/promises"),yed=yu(require("path"),1);async function CMa({workspace:e,context:t,generationLanguage:r,keywords:n,smartCasing:i,disableExamples:a,audiences:u,readme:f}){return await UFt({workspace:e,context:t,logWarnings:!1}),JQ({workspace:e,generationLanguage:r,keywords:n,smartCasing:i,disableExamples:a,audiences:u,readme:f,version:void 0,packageName:void 0,context:t})}async function ved({project:e,outputFilepath:t,cliContext:r,audiences:n}){await Promise.all(e.apiWorkspaces.map(async i=>{await r.runTaskForWorkspace(i,async a=>{let u=await i.toFernWorkspace({context:a}),f=await CMa({workspace:u,context:a,generationLanguage:void 0,audiences:n,keywords:void 0,smartCasing:!1,disableExamples:!1,readme:void 0}),d=dwe({ir:f,snippetsConfig:{}}),c=yed.default.resolve(t);await(0,hed.writeFile)(c,await zwr(d,{pretty:!0})),a.logger.info(`Wrote FDR API definition to ${c}`)})}))}var Zr=Symbol(),fa=Symbol();var bed={laterVersion:"v10",earlierVersion:"v9",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.STOPLIGHT]:fa,[We.OPENAPI]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>{let t=sy(e.services,r=>({docs:void 0,...r}));for(let r of Object.values(e.subpackages))if(r.docs!=null&&r.service!=null){let n=t[r.service];if(n==null)throw new Error("Service does not exist: "+r.service);n.docs=r.docs}return{...e,services:t}}};var rr={};Wb(rr,{V1:()=>swx,V10:()=>cwx,V11:()=>lwx,V12:()=>fwx,V13:()=>dwx,V14:()=>pwx,V15:()=>_wx,V16:()=>hwx,V17:()=>ywx,V18:()=>vwx,V19:()=>bwx,V2:()=>gwx,V20:()=>mwx,V21:()=>Owx,V22:()=>Pwx,V23:()=>Nu0.FernIrV23,V24:()=>zu0.FernIrV24,V25:()=>Bu0.FernIrV25,V26:()=>Iu0.FernIrV26,V27:()=>Ru0.FernIrV27,V28:()=>Fu0.FernIrV28,V29:()=>Lu0.FernIrV29,V3:()=>jwx,V30:()=>Uu0.FernIrV30,V31:()=>Vu0.FernIrV31,V32:()=>Wu0.FernIrV32,V33:()=>Hu0.FernIrV33,V34:()=>$u0.FernIrV34,V35:()=>Ju0.FernIrV35,V36:()=>Gu0.FernIrV36,V37:()=>Ku0.FernIrV37,V38:()=>Yu0.FernIrV38,V39:()=>Xu0.FernIrV39,V4:()=>wwx,V40:()=>Qu0.FernIrV40,V41:()=>Zu0.FernIrV41,V42:()=>ku0.FernIrV42,V43:()=>es0.FernIrV43,V44:()=>ts0.FernIrV44,V45:()=>rs0.FernIrV45,V46:()=>ns0.FernIrV46,V47:()=>is0.FernIrV47,V48:()=>as0.FernIrV48,V49:()=>os0.FernIrV49,V5:()=>Dwx,V50:()=>us0.FernIrV50,V51:()=>ss0.FernIrV51,V52:()=>cs0.FernIrV52,V53:()=>y_,V6:()=>Swx,V7:()=>Ewx,V8:()=>Mwx,V9:()=>xwx});var swx=yu(pod(),1),cwx=yu(Ndd(),1),lwx=yu(ibd(),1),fwx=yu(twd(),1),dwx=yu(ZTd(),1),pwx=yu(Y4d(),1),_wx=yu(JId(),1),hwx=yu(iHd(),1),ywx=yu(yQd(),1),vwx=yu(Mip(),1),bwx=yu(Hfp(),1),gwx=yu(F0p(),1),mwx=yu(hjp(),1),Owx=yu(KTp(),1),Pwx=yu(E3p(),1),Nu0=yu(Jzp(),1),zu0=yu(x9p(),1),Bu0=yu(yHp(),1),Iu0=yu(uYp(),1),Ru0=yu(re_(),1),Fu0=yu(Zi_(),1),Lu0=yu(Kc_(),1),jwx=yu(Iy_(),1),Uu0=yu(Fm_(),1),Vu0=yu(Uw_(),1),Wu0=yu(Zx_(),1),Hu0=yu(lVu(),1),$u0=yu(O5_(),1),Ju0=yu(y9_(),1),Gu0=yu(f$_(),1),Ku0=yu(sQ_(),1),Yu0=yu(snh(),1),Xu0=yu(Dch(),1),wwx=yu(jyh(),1),Qu0=yu(LOh(),1),Zu0=yu(aEh(),1),ku0=yu(MCh(),1),es0=yu(kNh(),1),ts0=yu(DFh(),1),rs0=yu(d$h(),1),ns0=yu(aZh(),1),is0=yu(nay(),1),as0=yu(edy(),1),os0=yu(eby(),1),Dwx=yu(F1y(),1),us0=yu(Kxy(),1),ss0=yu(p4y(),1),cs0=yu(IIy(),1),Swx=yu($Vy(),1),Ewx=yu(kKy(),1),Mwx=yu(ut0(),1),xwx=yu(Au0(),1);var ls0={laterVersion:"v11",earlierVersion:"v10",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.5.0-rc0-1-g83a12940",[We.TYPESCRIPT_EXPRESS]:"0.5.0-rc0-1-g83a12940",[We.JAVA]:Zr,[We.JAVA_MODEL]:"0.0.134-15-ge1ac358",[We.JAVA_SDK]:"0.0.134-15-ge1ac358",[We.JAVA_SPRING]:"0.0.134-15-ge1ac358",[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.STOPLIGHT]:fa,[We.OPENAPI]:Zr,[We.POSTMAN]:"0.0.40-1-g9aa2117",[We.PYTHON_SDK]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,t)=>({...e,auth:Twx(e.auth,t)})};function Twx(e,t){return{...e,schemes:e.schemes.map(r=>qwx(r,t))}}function qwx(e,{taskContext:t,targetGenerator:r}){return rr.V11.auth.AuthScheme._visit(e,{bearer:rr.V10.auth.AuthScheme.bearer,basic:rr.V10.auth.AuthScheme.basic,header:n=>n.prefix!=null?t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support specifying an auth header prefix. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains an auth header prefix."):rr.V10.auth.AuthScheme.header({docs:n.docs,availability:{status:rr.V10.commons.AvailabilityStatus.GeneralAvailability,message:void 0},name:{name:n.name,wireValue:n.header},valueType:n.valueType}),_unknown:()=>{throw new Error("Unknown auth scheme: "+e._type)}})}var ds0={laterVersion:"v12",earlierVersion:"v11",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.5.0-rc0-6-g80f89f98",[We.TYPESCRIPT_EXPRESS]:"0.5.0-rc0-6-g80f89f98",[We.JAVA]:Zr,[We.JAVA_MODEL]:"0.1.0-1-gdb5c636",[We.JAVA_SDK]:"0.1.0-1-gdb5c636",[We.JAVA_SPRING]:"0.1.0-1-gdb5c636",[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.STOPLIGHT]:"0.0.23-8-g479c860",[We.OPENAPI]:"0.0.22-1-g1c86b58",[We.POSTMAN]:Zr,[We.PYTHON_SDK]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,{taskContext:t,targetGenerator:r})=>{let n=sy(e.types,i=>({...i,shape:rr.V12.types.Type._visit(i.shape,{union:rr.V11.types.Type.union,enum:rr.V11.types.Type.enum,object:rr.V11.types.Type.object,alias:a=>rr.V11.types.Type.alias({aliasOf:a.aliasOf,resolvedType:rr.V12.types.ResolvedTypeReference._visit(a.resolvedType,{container:rr.V11.types.ResolvedTypeReference.container,primitive:rr.V11.types.ResolvedTypeReference.primitive,named:u=>u.shape==="UNDISCRIMINATED_UNION"?t.failAndThrow(fs0({taskContext:t,targetGenerator:r})):rr.V11.types.ResolvedTypeReference.named({shape:u.shape,name:u.name}),unknown:rr.V11.types.ResolvedTypeReference.unknown,_unknown:()=>{throw new Error("Encountered unknown alias")}})}),undiscriminatedUnion:()=>t.failAndThrow(fs0({taskContext:t,targetGenerator:r})),_unknown:()=>{throw new Error("Encountered unknown shape")}})}));return{...e,types:n,services:sy(e.services,i=>Cwx(i,{taskContext:t,targetGenerator:r}))}}};function fs0(e){return e.targetGenerator!=null?`Generator ${e.targetGenerator.name}@${e.targetGenerator.version} does not support undiscriminated unions If you'd like to use this feature, please upgrade ${e.targetGenerator.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains an undiscriminated union."}function Cwx(e,t){return{...e,endpoints:e.endpoints.map(r=>Awx(r,t))}}function Awx(e,{taskContext:t,targetGenerator:r}){return e.streamingResponse!=null?t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support streaming responses. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains a streaming response."):{...e,requestBody:e.requestBody!=null?rr.V12.http.HttpRequestBody._visit(e.requestBody,{inlinedRequestBody:rr.V11.http.HttpRequestBody.inlinedRequestBody,reference:rr.V11.http.HttpRequestBody.reference,fileUpload:()=>t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support file upload requests. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains a file upload request."),_unknown:()=>{var n;throw new Error("Unknown HttpRequestBody type: "+((n=e.requestBody)==null?void 0:n.type))}}):void 0,response:e.response!=null?{docs:e.response.docs,type:e.response.responseBodyType}:{docs:void 0,type:void 0}}}var ps0={laterVersion:"v13",earlierVersion:"v12",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>({...e,types:sy(e.types,t=>t.shape._type!=="undiscriminatedUnion"?{...t,shape:t.shape}:{...t,shape:rr.V12.types.Type.undiscriminatedUnion({docs:void 0,members:t.shape.members})}),auth:{...e.auth,schemes:e.auth.schemes.map(t=>t._type!=="header"?t:{...t,name:t.name.name,header:t.name.wireValue})}})};var _s0={laterVersion:"v14",earlierVersion:"v13",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>{let t=sy(e.types,r=>({...r,shape:rr.V14.types.Type._visit(r.shape,{union:n=>rr.V13.types.Type.union({discriminant:n.discriminant,baseProperties:n.baseProperties.map(i=>({...i,valueType:ez(i.valueType)})),types:n.types.map(i=>Bwx(i))}),enum:rr.V13.types.Type.enum,object:n=>rr.V13.types.Type.object({...n,properties:n.properties.map(i=>({...i,valueType:ez(i.valueType)}))}),alias:n=>rr.V13.types.Type.alias({aliasOf:ez(n.aliasOf),resolvedType:Rwx(n.resolvedType)}),undiscriminatedUnion:n=>rr.V13.types.Type.undiscriminatedUnion(Fwx(n)),_unknown:()=>{throw new Error("Encountered unknown shape")}})}));return{...e,auth:Nwx(e.auth),headers:e.headers.map(r=>Kku(r)),types:t,services:sy(e.services,r=>Lwx(r)),errors:sy(e.errors,r=>Gwx(r))}}};function Nwx(e){return{docs:e.docs,requirement:e.requirement,schemes:e.schemes.map(t=>t._type!=="header"?t:rr.V13.auth.AuthScheme.header(zwx(t)))}}function zwx(e){return{docs:e.docs,prefix:e.prefix,name:e.name,valueType:ez(e.valueType)}}function Kku(e){return{docs:e.docs,availability:e.availability,name:e.name,valueType:ez(e.valueType)}}function ez(e){return rr.V14.types.TypeReference._visit(e,{container:t=>rr.V13.types.TypeReference.container(hs0(t)),primitive:t=>t==="DATE"?rr.V13.types.TypeReference.primitive(rr.V13.types.PrimitiveType.String):rr.V13.types.TypeReference.primitive(t),named:rr.V13.types.TypeReference.named,unknown:rr.V13.types.TypeReference.unknown,_unknown:()=>{throw new Error("Unknown type reference: "+e._type)}})}function hs0(e){return rr.V14.types.ContainerType._visit(e,{list:t=>rr.V13.types.ContainerType.list(ez(t)),optional:t=>rr.V13.types.ContainerType.optional(ez(t)),set:t=>rr.V13.types.ContainerType.set(ez(t)),map:({keyType:t,valueType:r})=>rr.V13.types.ContainerType.map({keyType:ez(t),valueType:ez(r)}),literal:rr.V13.types.ContainerType.literal,_unknown:()=>{throw new Error("Unknown ContainerType: "+e._type)}})}function Bwx(e){return{docs:e.docs,discriminantValue:e.discriminantValue,shape:Iwx(e.shape)}}function Iwx(e){return rr.V14.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>rr.V13.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>rr.V13.types.SingleUnionTypeProperties.singleProperty({name:t.name,type:ez(t.type)}),noProperties:rr.V13.types.SingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown SingleUnionTypeProperties: "+e._type)}})}function Rwx(e){return rr.V14.types.ResolvedTypeReference._visit(e,{container:t=>rr.V13.types.ResolvedTypeReference.container(hs0(t)),named:rr.V13.types.ResolvedTypeReference.named,primitive:t=>t==="DATE"?rr.V13.types.ResolvedTypeReference.primitive(rr.V13.types.PrimitiveType.String):rr.V13.types.ResolvedTypeReference.primitive(t),unknown:rr.V13.types.ResolvedTypeReference.unknown,_unknown:()=>{throw new Error("Unknown ResolvedTypeReference: "+e._type)}})}function Fwx(e){return{members:e.members.map(t=>({...t,type:ez(t.type)}))}}function Lwx(e){return{availability:e.availability,name:e.name,displayName:e.displayName,basePath:e.basePath,baseUrl:e.baseUrl,pathParameters:e.pathParameters.map(t=>ys0(t)),headers:e.headers.map(t=>Kku(t)),endpoints:e.endpoints.map(t=>Uwx(t))}}function ys0(e){return{availability:e.availability,docs:e.docs,name:e.name,valueType:ez(e.valueType)}}function Uwx(e){return{docs:e.docs,availability:e.availability,name:e.name,displayName:e.displayName,errors:e.errors,auth:e.auth,method:e.method,path:e.path,pathParameters:e.pathParameters.map(t=>ys0(t)),sdkRequest:e.sdkRequest!=null?Wwx(e.sdkRequest):void 0,requestBody:e.requestBody!=null?$wx(e.requestBody):void 0,response:e.response!=null?Jku(e.response):void 0,headers:e.headers.map(t=>Kku(t)),queryParameters:e.queryParameters.map(t=>Vwx(t)),examples:e.examples,streamingResponse:e.streamingResponse!=null?Gku(e.streamingResponse):void 0,sdkResponse:e.sdkResponse!=null?Jwx(e.sdkResponse):void 0}}function Vwx(e){return{availability:e.availability,docs:e.docs,name:e.name,valueType:ez(e.valueType),allowMultiple:e.allowMultiple}}function Wwx(e){return{requestParameterName:e.requestParameterName,shape:Hwx(e.shape)}}function Hwx(e){return rr.V14.http.SdkRequestShape._visit(e,{justRequestBody:t=>rr.V13.http.SdkRequestShape.justRequestBody({docs:t.docs,requestBodyType:ez(t.requestBodyType)}),wrapper:rr.V13.http.SdkRequestShape.wrapper,_unknown:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function $wx(e){return rr.V14.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>rr.V13.http.HttpRequestBody.inlinedRequestBody({name:t.name,extends:t.extends,properties:t.properties.map(r=>({docs:r.docs,name:r.name,valueType:ez(r.valueType)}))}),reference:t=>rr.V13.http.HttpRequestBody.reference({docs:t.docs,requestBodyType:ez(t.requestBodyType)}),fileUpload:t=>rr.V13.http.HttpRequestBody.fileUpload({name:t.name,properties:t.properties.map(r=>r.type==="bodyProperty"?{...r,valueType:ez(r.valueType)}:r)}),_unknown:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function Jku(e){return{docs:e.docs,responseBodyType:ez(e.responseBodyType)}}function Gku(e){return{dataEventType:ez(e.dataEventType),terminator:e.terminator}}function Jwx(e){return rr.V14.http.SdkResponse._visit(e,{streaming:t=>rr.V13.http.SdkResponse.streaming(Gku(t)),nonStreaming:t=>rr.V13.http.SdkResponse.nonStreaming(Jku(t)),maybeStreaming:t=>rr.V13.http.SdkResponse.maybeStreaming({condition:t.condition,nonStreaming:Jku(t.nonStreaming),streaming:Gku(t.streaming)}),_unknown:()=>{throw new Error("Encountered unknown sdk response")}})}function Gwx(e){return{docs:e.docs,name:e.name,discriminantValue:e.discriminantValue,type:e.type!=null?ez(e.type):void 0,statusCode:e.statusCode}}var vs0={laterVersion:"v15",earlierVersion:"v14",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:"0.0.52-3-gd9df38df",[We.PYTHON_PYDANTIC]:"0.0.52-3-gd9df38df",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"0.0.52-3-gd9df38df",[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>{let t=sy(e.types,r=>({...r,shape:rr.V15.types.Type._visit(r.shape,{union:n=>rr.V14.types.Type.union({discriminant:n.discriminant,baseProperties:n.baseProperties.map(i=>({...i,valueType:tz(i.valueType)})),types:n.types.map(i=>Xwx(i))}),enum:rr.V14.types.Type.enum,object:n=>rr.V14.types.Type.object({...n,properties:n.properties.map(i=>({...i,valueType:tz(i.valueType)}))}),alias:n=>rr.V14.types.Type.alias({aliasOf:tz(n.aliasOf),resolvedType:Zwx(n.resolvedType)}),undiscriminatedUnion:n=>rr.V14.types.Type.undiscriminatedUnion(kwx(n)),_unknown:()=>{throw new Error("Encountered unknown shape")}})}));return{...e,auth:Kwx(e.auth),headers:e.headers.map(r=>Qku(r)),types:t,services:sy(e.services,r=>eDx(r)),errors:sy(e.errors,r=>uDx(r))}}};function Kwx(e){return{docs:e.docs,requirement:e.requirement,schemes:e.schemes.map(t=>t._type!=="header"?t:rr.V14.auth.AuthScheme.header(Ywx(t)))}}function Ywx(e){return{docs:e.docs,prefix:e.prefix,name:e.name,valueType:tz(e.valueType)}}function Qku(e){return{docs:e.docs,availability:e.availability,name:e.name,valueType:tz(e.valueType)}}function tz(e){return rr.V15.types.TypeReference._visit(e,{container:t=>rr.V14.types.TypeReference.container(bs0(t)),primitive:t=>t==="BASE_64"?rr.V14.types.TypeReference.primitive(rr.V14.types.PrimitiveType.String):rr.V14.types.TypeReference.primitive(t),named:rr.V14.types.TypeReference.named,unknown:rr.V14.types.TypeReference.unknown,_unknown:()=>{throw new Error("Unknown type reference: "+e._type)}})}function bs0(e){return rr.V15.types.ContainerType._visit(e,{list:t=>rr.V14.types.ContainerType.list(tz(t)),optional:t=>rr.V14.types.ContainerType.optional(tz(t)),set:t=>rr.V14.types.ContainerType.set(tz(t)),map:({keyType:t,valueType:r})=>rr.V14.types.ContainerType.map({keyType:tz(t),valueType:tz(r)}),literal:rr.V14.types.ContainerType.literal,_unknown:()=>{throw new Error("Unknown ContainerType: "+e._type)}})}function Xwx(e){return{docs:e.docs,discriminantValue:e.discriminantValue,shape:Qwx(e.shape)}}function Qwx(e){return rr.V15.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>rr.V14.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>rr.V14.types.SingleUnionTypeProperties.singleProperty({name:t.name,type:tz(t.type)}),noProperties:rr.V14.types.SingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown SingleUnionTypeProperties: "+e._type)}})}function Zwx(e){return rr.V15.types.ResolvedTypeReference._visit(e,{container:t=>rr.V14.types.ResolvedTypeReference.container(bs0(t)),named:rr.V14.types.ResolvedTypeReference.named,primitive:t=>t==="BASE_64"?rr.V14.types.ResolvedTypeReference.primitive(rr.V14.types.PrimitiveType.String):rr.V14.types.ResolvedTypeReference.primitive(t),unknown:rr.V14.types.ResolvedTypeReference.unknown,_unknown:()=>{throw new Error("Unknown ResolvedTypeReference: "+e._type)}})}function kwx(e){return{members:e.members.map(t=>({...t,type:tz(t.type)}))}}function eDx(e){return{availability:e.availability,name:e.name,displayName:e.displayName,basePath:e.basePath,baseUrl:e.baseUrl,pathParameters:e.pathParameters.map(t=>gs0(t)),headers:e.headers.map(t=>Qku(t)),endpoints:e.endpoints.map(t=>tDx(t))}}function gs0(e){return{availability:e.availability,docs:e.docs,name:e.name,valueType:tz(e.valueType)}}function tDx(e){return{docs:e.docs,availability:e.availability,name:e.name,displayName:e.displayName,errors:e.errors,auth:e.auth,method:e.method,path:e.path,pathParameters:e.pathParameters.map(t=>gs0(t)),sdkRequest:e.sdkRequest!=null?nDx(e.sdkRequest):void 0,requestBody:e.requestBody!=null?aDx(e.requestBody):void 0,response:e.response!=null?Yku(e.response):void 0,headers:e.headers.map(t=>Qku(t)),queryParameters:e.queryParameters.map(t=>rDx(t)),examples:e.examples,streamingResponse:e.streamingResponse!=null?Xku(e.streamingResponse):void 0,sdkResponse:e.sdkResponse!=null?oDx(e.sdkResponse):void 0}}function rDx(e){return{availability:e.availability,docs:e.docs,name:e.name,valueType:tz(e.valueType),allowMultiple:e.allowMultiple}}function nDx(e){return{requestParameterName:e.requestParameterName,shape:iDx(e.shape)}}function iDx(e){return rr.V15.http.SdkRequestShape._visit(e,{justRequestBody:t=>rr.V14.http.SdkRequestShape.justRequestBody({docs:t.docs,requestBodyType:tz(t.requestBodyType)}),wrapper:rr.V14.http.SdkRequestShape.wrapper,_unknown:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function aDx(e){return rr.V15.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>rr.V14.http.HttpRequestBody.inlinedRequestBody({name:t.name,extends:t.extends,properties:t.properties.map(r=>({docs:r.docs,name:r.name,valueType:tz(r.valueType)}))}),reference:t=>rr.V14.http.HttpRequestBody.reference({docs:t.docs,requestBodyType:tz(t.requestBodyType)}),fileUpload:t=>rr.V14.http.HttpRequestBody.fileUpload({name:t.name,properties:t.properties.map(r=>r.type==="bodyProperty"?{...r,valueType:tz(r.valueType)}:r)}),_unknown:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function Yku(e){return{docs:e.docs,responseBodyType:tz(e.responseBodyType)}}function Xku(e){return{dataEventType:tz(e.dataEventType),terminator:e.terminator}}function oDx(e){return rr.V15.http.SdkResponse._visit(e,{streaming:t=>rr.V14.http.SdkResponse.streaming(Xku(t)),nonStreaming:t=>rr.V14.http.SdkResponse.nonStreaming(Yku(t)),maybeStreaming:t=>rr.V14.http.SdkResponse.maybeStreaming({condition:t.condition,nonStreaming:Yku(t.nonStreaming),streaming:Xku(t.streaming)}),_unknown:()=>{throw new Error("Encountered unknown sdk response")}})}function uDx(e){return{docs:e.docs,name:e.name,discriminantValue:e.discriminantValue,type:e.type!=null?tz(e.type):void 0,statusCode:e.statusCode}}var ms0={laterVersion:"v16",earlierVersion:"v15",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.5.4-1-g4e69d312",[We.TYPESCRIPT_EXPRESS]:"0.5.4-1-g4e69d312",[We.JAVA]:Zr,[We.JAVA_MODEL]:"0.3.8-rc6-1-gcf4b372",[We.JAVA_SDK]:"0.3.8-rc6-1-gcf4b372",[We.JAVA_SPRING]:"0.3.8-rc6-1-gcf4b372",[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,{taskContext:t,targetGenerator:r})=>e.basePath!=null?t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support specifying a base-path in api.yml. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains a root base-path."):{...e,services:sy(e.services,n=>({...n,pathParameters:Zku(n.pathParameters),endpoints:n.endpoints.map(i=>({...i,allPathParameters:Zku(i.allPathParameters),pathParameters:Zku(i.pathParameters)}))}))}};function Zku(e){return e.map(t=>sDx(t))}function sDx(e){return{...e,availability:{status:rr.V15.commons.AvailabilityStatus.GeneralAvailability,message:void 0}}}var Os0={laterVersion:"v17",earlierVersion:"v16",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,{taskContext:t,targetGenerator:r})=>{for(let[n,i]of Object.entries(e.types))if(i.shape._type==="union"&&i.shape.extends.length>0)return t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support union types with extensions. See ${n} in file ${i.name.fernFilepath.allParts.join("/")}. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains union types with extensions.");return{...e}}};var Ps0={laterVersion:"v18",earlierVersion:"v17",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.5.14-1-ga6817141",[We.TYPESCRIPT_EXPRESS]:"0.5.14-1-ga6817141",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:"0.3.0-3-ge125e311",[We.PYTHON_PYDANTIC]:"0.3.0-3-ge125e311",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"0.3.0-3-ge125e311",[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,{taskContext:t,targetGenerator:r})=>({...e,services:sy(e.services,n=>{var a;let i=(a=n.endpoints[0])==null?void 0:a.baseUrl;return n.endpoints.some(u=>u.baseUrl!==i)?t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support endpoint-level server URLs. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains endpoint-level server URLs."):{...n,baseUrl:i}})})};var ws0={laterVersion:"v19",earlierVersion:"v18",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.5.19-1-gef223230",[We.TYPESCRIPT_EXPRESS]:"0.5.19-1-gef223230",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:"0.3.4-rc0-9-ge815162f",[We.PYTHON_PYDANTIC]:"0.3.4-rc0-9-ge815162f",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:"0.0.44-1-gbf4b0f3",[We.PYTHON_SDK]:"0.3.4-rc0-9-ge815162f",[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,t)=>({...e,services:sy(e.services,r=>cDx(r,t)),types:sy(e.types,r=>hDx(r,t))})};function cDx(e,t){return{...e,endpoints:e.endpoints.map(r=>lDx(r,t))}}function lDx(e,t){return{...e,examples:e.examples.map(r=>fDx(r,t))}}function fDx(e,t){return{docs:e.docs,name:e.name,url:e.url,rootPathParameters:e.rootPathParameters.map(r=>kku(r,t)),servicePathParameters:e.servicePathParameters.map(r=>kku(r,t)),endpointPathParameters:e.endpointPathParameters.map(r=>kku(r,t)),serviceHeaders:e.serviceHeaders.map(r=>js0(r,t)),endpointHeaders:e.endpointHeaders.map(r=>js0(r,t)),queryParameters:e.queryParameters.map(r=>dDx(r,t)),request:e.request!=null?pDx(e.request,t):void 0,response:_Dx(e.response,t)}}function kku(e,t){return{key:e.key,value:xae(e.value,t)}}function js0(e,t){return{wireKey:e.wireKey,value:xae(e.value,t)}}function dDx(e,t){return{wireKey:e.wireKey,value:xae(e.value,t)}}function pDx(e,t){return rr.V19.http.ExampleRequestBody._visit(e,{inlinedRequestBody:r=>rr.V18.http.ExampleRequestBody.inlinedRequestBody({jsonExample:r.jsonExample,properties:r.properties.map(n=>({wireKey:n.wireKey,value:xae(n.value,t),originalTypeDeclaration:n.originalTypeDeclaration}))}),reference:r=>rr.V18.http.ExampleRequestBody.reference(xae(r,t)),_unknown:()=>{throw new Error("Unknown ExampleRequestBody: "+e.type)}})}function _Dx(e,t){return rr.V19.http.ExampleResponse._visit(e,{ok:r=>rr.V18.http.ExampleResponse.ok({body:r.body!=null?xae(r.body,t):void 0}),error:r=>rr.V18.http.ExampleResponse.error({error:r.error,body:r.body!=null?xae(r.body,t):void 0}),_unknown:()=>{throw new Error("Unknown ExampleResponse: "+e.type)}})}function hDx(e,t){return{...e,examples:e.examples.map(r=>yDx(r,t))}}function yDx(e,t){return{...e,shape:ees(e.shape,t)}}function ees(e,t){return rr.V19.types.ExampleTypeShape._visit(e,{alias:r=>rr.V18.types.ExampleTypeShape.alias({value:xae(r.value,t)}),object:r=>rr.V18.types.ExampleTypeShape.object({properties:r.properties.map(n=>({wireKey:n.wireKey,value:xae(n.value,t),originalTypeDeclaration:n.originalTypeDeclaration}))}),union:r=>rr.V18.types.ExampleTypeShape.union({wireDiscriminantValue:r.wireDiscriminantValue,properties:rr.V19.types.ExampleSingleUnionTypeProperties._visit(r.properties,{singleProperty:n=>rr.V18.types.ExampleSingleUnionTypeProperties.singleProperty({jsonExample:n.jsonExample,shape:Ds0(n.shape,t)}),samePropertiesAsObject:n=>rr.V18.types.ExampleSingleUnionTypeProperties.samePropertiesAsObject({typeName:n.typeName,shape:ees(n.shape,t)}),noProperties:rr.V18.types.ExampleSingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown ExampleSingleUnionTypeProperties: "+r.properties.type)}})}),enum:rr.V18.types.ExampleTypeShape.enum,_unknown:()=>{throw new Error("Unknown ExampleTypeShape: "+e.type)}})}function xae(e,t){return{jsonExample:e.jsonExample,shape:Ds0(e.shape,t)}}function Ds0(e,t){return rr.V19.types.ExampleTypeReferenceShape._visit(e,{primitive:r=>rr.V18.types.ExampleTypeReferenceShape.primitive(vDx(r,t)),named:r=>rr.V18.types.ExampleTypeReferenceShape.named({typeName:r.typeName,shape:ees(r.shape,t)}),container:r=>rr.V18.types.ExampleTypeReferenceShape.container(rr.V19.types.ExampleContainer._visit(r,{list:n=>rr.V18.types.ExampleContainer.list(n.map(i=>xae(i,t))),set:n=>rr.V18.types.ExampleContainer.set(n.map(i=>xae(i,t))),optional:n=>rr.V18.types.ExampleContainer.optional(n!=null?xae(n,t):void 0),map:n=>rr.V18.types.ExampleContainer.map(n.map(i=>({key:xae(i.key,t),value:xae(i.value,t)}))),_unknown:()=>{throw new Error("Unknown ExampleContainer: "+r.type)}})),unknown:rr.V18.types.ExampleTypeReferenceShape.unknown,_unknown:()=>{throw new Error("Unknown ExampleTypeReferenceShape: "+e.type)}})}function vDx(e,{taskContext:t,targetGenerator:r}){return e.type==="date"?t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support examples for dates. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains date examples."):e}var Ss0={laterVersion:"v2",earlierVersion:"v1",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.0.246",[We.TYPESCRIPT_EXPRESS]:"0.0.264",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:fa,[We.STOPLIGHT]:fa,[We.OPENAPI_PYTHON_CLIENT]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>({apiName:e.apiName,auth:e.auth,headers:e.headers,types:e.types,services:e.services,constants:e.constants,constantsV2:e.constantsV2,defaultEnvironment:e.defaultEnvironment,environments:e.environments,errorDiscriminant:e.errorDiscriminant,errorDiscriminationStrategy:e.errorDiscriminationStrategy,sdkConfig:e.sdkConfig,errors:e.errors.map(t=>({name:t.name,docs:t.docs,discriminantValue:{originalValue:t.discriminantValueV4.name.unsafeName.originalValue,camelCase:t.discriminantValueV4.name.unsafeName.camelCase,pascalCase:t.discriminantValueV4.name.unsafeName.pascalCase,snakeCase:t.discriminantValueV4.name.unsafeName.snakeCase,screamingSnakeCase:t.discriminantValueV4.name.unsafeName.screamingSnakeCase,wireValue:t.discriminantValueV4.wireValue},discriminantValueV2:t.discriminantValueV2,discriminantValueV3:t.discriminantValueV3,discriminantValueV4:t.discriminantValueV4,type:t.type,typeV2:t.typeV2,typeV3:t.typeV3,http:t.http,statusCode:t.statusCode}))})};var Es0={laterVersion:"v20",earlierVersion:"v19",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.5.26-rc0-3-gdfabd674",[We.TYPESCRIPT_BROWSER_SDK]:"0.5.26-rc0-3-gdfabd674",[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.5.20-3-g2505487f",[We.TYPESCRIPT_EXPRESS]:"0.5.20-3-g2505487f",[We.JAVA]:Zr,[We.JAVA_MODEL]:"0.3.10-rc2-1-g1c0d853",[We.JAVA_SDK]:"0.3.10-rc2-1-g1c0d853",[We.JAVA_SPRING]:"0.3.10-rc2-1-g1c0d853",[We.PYTHON_FASTAPI]:"0.3.6-rc1-2-g6050f7f8",[We.PYTHON_PYDANTIC]:"0.3.6-rc1-2-g6050f7f8",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"0.3.6-rc1-2-g6050f7f8",[We.GO_FIBER]:fa,[We.GO_MODEL]:"0.0.0",[We.GO_SDK]:"0.0.0",[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,t)=>({...e,services:sy(e.services,r=>bDx(r,t))})};function bDx(e,t){return{...e,endpoints:e.endpoints.map(r=>gDx(r,t))}}function gDx(e,t){return{...e,response:e.response!=null?Ms0(e.response,t):void 0,sdkResponse:e.sdkResponse!=null?mDx(e.sdkResponse,t):void 0}}function Ms0(e,t){return rr.V20.http.HttpResponse._visit(e,{fileDownload:()=>xs0(t),json:r=>r,_unknown:()=>{throw new Error("Unknown HttpResponse: "+e.type)}})}function mDx(e,t){return rr.V20.http.SdkResponse._visit(e,{fileDownload:()=>xs0(t),streaming:rr.V19.http.SdkResponse.streaming,maybeStreaming:r=>rr.V19.http.SdkResponse.maybeStreaming({condition:r.condition,streaming:r.streaming,nonStreaming:Ms0(r.nonStreaming,t)}),json:rr.V19.http.SdkResponse.nonStreaming,_unknown:()=>{throw new Error("Unknown SdkResponse: "+e.type)}})}function xs0({targetGenerator:e,taskContext:t}){return t.failAndThrow(e!=null?`Generator ${e.name}@${e.version} does not support file download. If you'd like to use this feature, please upgrade ${e.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains file download.")}var Ts0={laterVersion:"v21",earlierVersion:"v20",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:fa,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,t)=>({...e,services:sy(e.services,r=>ODx(r,t))})};function ODx(e,t){return{...e,endpoints:e.endpoints.map(r=>PDx(r,t))}}function PDx(e,t){return{...e,streamingResponse:e.streamingResponse!=null?tes(e.streamingResponse,t):void 0,sdkResponse:e.sdkResponse!=null?jDx(e.sdkResponse,t):void 0}}function tes(e,{taskContext:t,targetGenerator:r}){return{dataEventType:rr.V21.http.StreamingResponseChunkType._visit(e.dataEventType,{json:n=>n,text:()=>t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support streaming text responses. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains streaming text responses."),_unknown:()=>{throw new Error("Unknown StreamingResponseChunkType: "+e.dataEventType.type)}}),terminator:e.terminator}}function jDx(e,t){return rr.V21.http.SdkResponse._visit(e,{fileDownload:rr.V20.http.SdkResponse.fileDownload,streaming:r=>rr.V20.http.SdkResponse.streaming(tes(r,t)),maybeStreaming:r=>rr.V20.http.SdkResponse.maybeStreaming({condition:r.condition,streaming:tes(r.streaming,t),nonStreaming:r.nonStreaming}),json:rr.V20.http.SdkResponse.json,_unknown:()=>{throw new Error("Unknown SdkResponse: "+e.type)}})}var qs0={laterVersion:"v22",earlierVersion:"v21",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:"0.5.0-3-gac7ce7c",[We.GO_MODEL]:"0.0.14-8-g2fa39f7",[We.GO_SDK]:"0.0.14-8-g2fa39f7",[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>({...e,services:sy(e.services,t=>wDx(t))})};function wDx(e){return{...e,endpoints:e.endpoints.map(t=>DDx(t))}}function DDx(e){return{...e,...e.response!=null?rr.V22.http.HttpResponse._visit(e.response,{json:t=>({response:rr.V21.http.HttpResponse.json(t),streamingResponse:void 0,sdkResponse:rr.V21.http.SdkResponse.json(t)}),fileDownload:t=>({response:rr.V21.http.HttpResponse.fileDownload(t),streamingResponse:void 0,sdkResponse:rr.V21.http.SdkResponse.fileDownload(t)}),streaming:t=>({response:void 0,streamingResponse:t,sdkResponse:rr.V21.http.SdkResponse.streaming(t)}),_unknown:()=>{var t;throw new Error("Unknown HttpResponse: "+((t=e.response)==null?void 0:t.type))}}):{response:void 0,streamingResponse:void 0,sdkResponse:void 0}}}var Ns0={laterVersion:"v23",earlierVersion:"v22",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.7.4-rc3-4-g6cf92f81",[We.TYPESCRIPT_BROWSER_SDK]:"0.7.4-rc3-4-g6cf92f81",[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:"0.7.4-rc3-4-g6cf92f81",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:"0.0.28-3-g112d3dd",[We.STOPLIGHT]:"0.0.28-3-g112d3dd",[We.POSTMAN]:"0.0.44-4-gddab2ae",[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,t)=>{var i,a;let r=[],n={};for(let[u,f]of Object.entries(e.services)){let d=[];for(let c of f.endpoints){let o=SDx(c);o==null?r.push(c):d.push(o)}n[u]={...f,endpoints:d,headers:f.headers.map(c=>nes(c)),pathParameters:f.pathParameters.map(c=>p6a(c))}}return r.length>0&&(t.taskContext.logger.warn(`Generator ${(i=t.targetGenerator)==null?void 0:i.name}@${(a=t.targetGenerator)==null?void 0:a.version} does not support bytes requests. `),r.length===1&&r[0]!=null?t.taskContext.logger.warn(`Therefore, endpoint ${r[0].name.originalName} will be skipped.`):t.taskContext.logger.warn(`Therefore, endpoints ${r.map(u=>u.name.originalName).join(", ")} will be skipped.`)),{...e,auth:{...e.auth,schemes:e.auth.schemes.map(u=>MDx(u))},headers:e.headers.map(u=>nes(u)),types:sy(e.types,u=>xDx(u)),services:n,errors:sy(e.errors,u=>zDx(u)),subpackages:e.subpackages,pathParameters:e.pathParameters.map(u=>p6a(u)),variables:e.variables.map(u=>BDx(u))}}};function SDx(e){let t;if(!(e.requestBody!=null&&(t=EDx(e.requestBody),t==null)))return{...e,headers:e.headers.map(r=>nes(r)),pathParameters:e.pathParameters.map(r=>p6a(r)),allPathParameters:e.allPathParameters.map(r=>p6a(r)),queryParameters:e.queryParameters.map(r=>IDx(r)),requestBody:t,sdkRequest:e.sdkRequest!=null?{requestParameterName:e.sdkRequest.requestParameterName,shape:RDx(e.sdkRequest.shape)}:void 0,response:e.response!=null?FDx(e.response):void 0,examples:e.examples.map(r=>LDx(r))}}function EDx(e){switch(e.type){case"bytes":return;case"fileUpload":return rr.V22.http.HttpRequestBody.fileUpload({...e,properties:e.properties.map(t=>VDx(t))});case"inlinedRequestBody":return rr.V22.http.HttpRequestBody.inlinedRequestBody({...e,properties:e.properties.map(t=>WDx(t))});case"reference":return rr.V22.http.HttpRequestBody.reference({...e,requestBodyType:rz(e.requestBodyType)});default:fl(e)}}function nes(e){return{...e,valueType:rz(e.valueType)}}function MDx(e){return e._visit({bearer:rr.V22.auth.AuthScheme.bearer,basic:rr.V22.auth.AuthScheme.basic,header:t=>rr.V22.auth.AuthScheme.header({...t,valueType:rz(t.valueType)}),_other:()=>{throw new Error("Unknown auth scheme: "+e.type)}})}function xDx(e){return{...e,shape:TDx(e.shape),examples:e.examples.map(t=>qDx(t))}}function TDx(e){return e._visit({alias:t=>rr.V22.types.Type.alias({...t,aliasOf:rz(t.aliasOf),resolvedType:ADx(t.resolvedType)}),enum:rr.V22.types.Type.enum,object:t=>rr.V22.types.Type.object({...t,properties:t.properties.map(r=>Cs0(r))}),union:t=>rr.V22.types.Type.union({...t,baseProperties:t.baseProperties.map(r=>Cs0(r)),types:t.types.map(r=>({...r,shape:NDx(r.shape)}))}),undiscriminatedUnion:t=>rr.V22.types.Type.undiscriminatedUnion({...t,members:t.members.map(r=>({...r,type:rz(r.type)}))}),_other:()=>{throw new Error("Unknown type shape: "+e.type)}})}function qDx(e){return{...e,shape:ies(e.shape)}}function ies(e){return e._visit({alias:t=>rr.V22.types.ExampleTypeShape.alias({...t,value:yDe(t.value)}),enum:rr.V22.types.ExampleTypeShape.enum,object:t=>rr.V22.types.ExampleTypeShape.object({...t,properties:t.properties.map(r=>({...r,value:yDe(r.value)}))}),union:t=>rr.V22.types.ExampleTypeShape.union({...t,properties:CDx(t.properties)}),_other:()=>{throw new Error("Unknown example type shape: "+e.type)}})}function yDe(e){return{...e,shape:aes(e.shape)}}function aes(e){return e._visit({primitive:t=>rr.V22.types.ExampleTypeReferenceShape.primitive(t._visit({integer:rr.V22.types.ExamplePrimitive.integer,double:rr.V22.types.ExamplePrimitive.double,string:rr.V22.types.ExamplePrimitive.string,boolean:rr.V22.types.ExamplePrimitive.boolean,long:rr.V22.types.ExamplePrimitive.long,datetime:r=>rr.V22.types.ExamplePrimitive.datetime(r.toISOString()),date:rr.V22.types.ExamplePrimitive.date,uuid:rr.V22.types.ExamplePrimitive.uuid,_other:()=>{throw new Error("Unknown example primitive: "+t.type)}})),named:t=>rr.V22.types.ExampleTypeReferenceShape.named({...t,shape:ies(t.shape)}),container:t=>rr.V22.types.ExampleTypeReferenceShape.container(t._visit({list:r=>rr.V22.types.ExampleContainer.list(r.map(n=>yDe(n))),set:r=>rr.V22.types.ExampleContainer.set(r.map(n=>yDe(n))),optional:r=>rr.V22.types.ExampleContainer.optional(r!=null?yDe(r):void 0),map:r=>rr.V22.types.ExampleContainer.map(r.map(n=>({key:yDe(n.key),value:yDe(n.value)}))),_other:()=>{throw new Error("Unknown example container: "+t.type)}})),unknown:rr.V22.types.ExampleTypeReferenceShape.unknown,_other:()=>{throw new Error("Unknown example type reference shape: "+e.type)}})}function CDx(e){return e._visit({singleProperty:t=>rr.V22.types.ExampleSingleUnionTypeProperties.singleProperty({...t,shape:aes(t.shape)}),noProperties:rr.V22.types.ExampleSingleUnionTypeProperties.noProperties,samePropertiesAsObject:t=>rr.V22.types.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...t,shape:ies(t.shape)}),_other:()=>{throw new Error("Unknown example single union type properties: "+e.type)}})}function rz(e){return e._visit({container:t=>rr.V22.types.TypeReference.container(zs0(t)),primitive:rr.V22.types.TypeReference.primitive,named:rr.V22.types.TypeReference.named,unknown:rr.V22.types.TypeReference.unknown,_other:()=>{throw new Error("Unknown type reference: "+e.type)}})}function zs0(e){return e._visit({list:t=>rr.V22.types.ContainerType.list(rz(t)),set:t=>rr.V22.types.ContainerType.set(rz(t)),optional:t=>rr.V22.types.ContainerType.optional(rz(t)),map:t=>rr.V22.types.ContainerType.map({keyType:rz(t.keyType),valueType:rz(t.valueType)}),literal:rr.V22.types.ContainerType.literal,_other:()=>{throw new Error("Unknown container type: "+e.type)}})}function ADx(e){return e._visit({container:t=>rr.V22.types.ResolvedTypeReference.container(zs0(t)),primitive:rr.V22.types.ResolvedTypeReference.primitive,named:rr.V22.types.ResolvedTypeReference.named,unknown:rr.V22.types.ResolvedTypeReference.unknown,_other:()=>{throw new Error("Unknown resolved type reference: "+e.type)}})}function Cs0(e){return{...e,valueType:rz(e.valueType)}}function NDx(e){return e._visit({noProperties:rr.V22.types.SingleUnionTypeProperties.noProperties,singleProperty:t=>rr.V22.types.SingleUnionTypeProperties.singleProperty({...t,type:rz(t.type)}),samePropertiesAsObject:rr.V22.types.SingleUnionTypeProperties.samePropertiesAsObject,_other:()=>{throw new Error("Unknown single union type properties: "+e.propertiesType)}})}function zDx(e){return{...e,type:e.type!=null?rz(e.type):void 0}}function BDx(e){return{...e,type:rz(e.type)}}function p6a(e){return{...e,valueType:rz(e.valueType)}}function IDx(e){return{...e,valueType:rz(e.valueType)}}function RDx(e){return e._visit({justRequestBody:t=>rr.V22.http.SdkRequestShape.justRequestBody({...t,requestBodyType:rz(t.requestBodyType)}),wrapper:rr.V22.http.SdkRequestShape.wrapper,_other:()=>{throw new Error("Unknown SDK request shape: "+e.type)}})}function FDx(e){return e._visit({json:t=>rr.V22.http.HttpResponse.json({...t,responseBodyType:rz(t.responseBodyType)}),fileDownload:rr.V22.http.HttpResponse.fileDownload,streaming:t=>rr.V22.http.HttpResponse.streaming({...t,dataEventType:t.dataEventType._visit({json:r=>rr.V22.http.StreamingResponseChunkType.json(rz(r)),text:rr.V22.http.StreamingResponseChunkType.text,_other:()=>{throw new Error("Unknown streaming data event type: "+t.dataEventType.type)}})}),_other:()=>{throw new Error("Unknown response: "+e.type)}})}function LDx(e){return{...e,rootPathParameters:e.rootPathParameters.map(t=>res(t)),servicePathParameters:e.servicePathParameters.map(t=>res(t)),endpointPathParameters:e.endpointPathParameters.map(t=>res(t)),serviceHeaders:e.serviceHeaders.map(t=>As0(t)),endpointHeaders:e.endpointHeaders.map(t=>As0(t)),queryParameters:e.queryParameters.map(t=>UDx(t)),request:e.request!=null?e.request._visit({inlinedRequestBody:t=>rr.V22.http.ExampleRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,value:yDe(r.value)}))}),reference:t=>rr.V22.http.ExampleRequestBody.reference({...t,shape:aes(t.shape)}),_other:()=>{var t;throw new Error("Unknown example request body: "+((t=e.request)==null?void 0:t.type))}}):void 0,response:e.response._visit({ok:t=>rr.V22.http.ExampleResponse.ok({...t,body:t.body!=null?yDe(t.body):void 0}),error:t=>rr.V22.http.ExampleResponse.error({...t,body:t.body!=null?yDe(t.body):void 0}),_other:()=>{throw new Error("Unknown example response: "+e.response.type)}})}}function res(e){return{...e,value:yDe(e.value)}}function UDx(e){return{...e,value:yDe(e.value)}}function As0(e){return{...e,value:yDe(e.value)}}function VDx(e){return e._visit({file:rr.V22.http.FileUploadRequestProperty.file,bodyProperty:t=>rr.V22.http.FileUploadRequestProperty.bodyProperty({...t,valueType:rz(t.valueType)}),_other:()=>{throw new Error("Unknown file upload request body property: "+e.type)}})}function WDx(e){return{...e,valueType:rz(e.valueType)}}var tb={};Wb(tb,{V23:()=>nNA,V24:()=>iNA,V25:()=>aNA,V26:()=>oNA,V27:()=>uNA,V28:()=>sNA,V29:()=>cNA,V30:()=>lNA,V31:()=>fNA,V32:()=>dNA,V33:()=>pNA,V34:()=>_NA,V35:()=>hNA,V36:()=>yNA,V37:()=>vNA,V38:()=>bNA,V39:()=>gNA,V40:()=>mNA,V41:()=>ONA,V42:()=>PNA,V43:()=>jNA,V44:()=>wNA,V45:()=>DNA,V46:()=>SNA,V47:()=>ENA,V48:()=>MNA,V49:()=>xNA,V50:()=>TNA,V51:()=>qNA,V52:()=>CNA,V53:()=>Nv});var nNA=yu(Hs(),1),iNA=yu(ws(),1),aNA=yu(_s(),1),oNA=yu(ls(),1),uNA=yu(is(),1),sNA=yu(as(),1),cNA=yu(os(),1),lNA=yu(Xu(),1),fNA=yu(Gu(),1),dNA=yu(Lu(),1),pNA=yu(su(),1),_NA=yu(au(),1),hNA=yu(Ho(),1),yNA=yu($o(),1),vNA=yu(Vo(),1),bNA=yu(Io(),1),gNA=yu(wo(),1),mNA=yu(Do(),1),ONA=yu(mo(),1),PNA=yu(ho(),1),jNA=yu(_o(),1),wNA=yu(fo(),1),DNA=yu(no(),1),SNA=yu(eo(),1),ENA=yu(Xa(),1),MNA=yu(Ga(),1),xNA=yu(Ua(),1),TNA=yu(Ra(),1),qNA=yu(Ca(),1),CNA=yu(Da(),1);var Gig={laterVersion:"v24",earlierVersion:"v23",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V23.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),migrateBackwards:e=>({...e})};var Kig={laterVersion:"v25",earlierVersion:"v24",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:"0.4.9-1-ge0997b3",[We.JAVA_SDK]:"0.4.9-1-ge0997b3",[We.JAVA_SPRING]:"0.4.9-1-ge0997b3",[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V24.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),migrateBackwards:(e,t)=>{var a,u,f,d;let r=[],n=[],i={};for(let[c,o]of Object.entries(e.services)){let l=[];for(let g of o.endpoints){let O;if(g.sdkRequest!=null&&(O=ANA(g.sdkRequest),O==null)){r.push(g);continue}if(g.response!=null){let j=g.response._visit({fileDownload:S=>rr.V24.HttpResponse.fileDownload(S),json:S=>rr.V24.HttpResponse.json(S),streaming:S=>rr.V24.HttpResponse.streaming(S),text:()=>(n.push(g),rr.V24.HttpResponse.json({docs:void 0,responseBodyType:rr.V24.TypeReference.unknown()})),_other:()=>{throw new Error("Encountered unknown response type")}});l.push({...g,sdkRequest:O,response:j})}else l.push({...g,sdkRequest:O,response:void 0})}i[c]={...o,endpoints:l}}return n.length>0&&(t.taskContext.logger.warn(`Generator ${(a=t.targetGenerator)==null?void 0:a.name}@${(u=t.targetGenerator)==null?void 0:u.version} does not support text/plain responses. `),n.length===1&&n[0]!=null?t.taskContext.logger.warn(`Therefore, endpoint ${n[0].name.originalName} response type will be casted to unkown.`):t.taskContext.logger.warn(`Therefore, endpoints ${n.map(c=>c.name.originalName).join(", ")} response types will be casted to unkown.`)),r.length>0&&(t.taskContext.logger.warn(`Generator ${(f=t.targetGenerator)==null?void 0:f.name}@${(d=t.targetGenerator)==null?void 0:d.version} does not support bytes requests. `),r.length===1&&r[0]!=null?t.taskContext.logger.warn(`Therefore, endpoint ${r[0].name.originalName} will be skipped.`):t.taskContext.logger.warn(`Therefore, endpoints ${r.map(c=>c.name.originalName).join(", ")} will be skipped.`)),{...e,services:i}}};function ANA(e){let t=e.shape;if(t.type==="wrapper")return{shape:rr.V24.SdkRequestShape.wrapper({...t}),requestParameterName:e.requestParameterName};if(t.value.type==="typeReference")return{shape:rr.V24.SdkRequestShape.justRequestBody({...t.value}),requestParameterName:e.requestParameterName}}var Xig={laterVersion:"v26",earlierVersion:"v25",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:"0.5.0-rc2-16-g4177fafd",[We.PYTHON_PYDANTIC]:"0.5.0-rc2-16-g4177fafd",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"0.5.0-rc2-16-g4177fafd",[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V25.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),migrateBackwards:e=>({...e,types:Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,RNA(r)])),headers:e.headers.map(t=>FCo(t)),webhookGroups:Object.fromEntries(Object.entries(e.webhookGroups).map(([t,r])=>[t,r.map(n=>NNA(n))])),services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,zNA(r)]))})};function NNA(e){return{...e,headers:e.headers.map(t=>FCo(t)),availability:e.availability==null?{status:rr.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function zNA(e){return{...e,endpoints:e.endpoints.map(t=>BNA(t)),headers:e.headers.map(t=>FCo(t)),availability:e.availability==null?{status:rr.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function BNA(e){return{...e,headers:e.headers.map(t=>FCo(t)),queryParameters:e.queryParameters.map(t=>INA(t)),availability:e.availability==null?{status:rr.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function FCo(e){return{...e,availability:e.availability==null?{status:rr.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function INA(e){return{...e,availability:e.availability==null?{status:rr.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function RNA(e){return{...e,shape:e.shape._visit({union:t=>rr.V25.Type.union({...t,baseProperties:t.baseProperties.map(r=>Yig(r))}),object:t=>rr.V25.Type.object({...t,properties:t.properties.map(r=>Yig(r))}),enum:t=>rr.V25.Type.enum({...t,values:t.values.map(r=>FNA(r))}),alias:t=>rr.V25.Type.alias(t),undiscriminatedUnion:t=>rr.V25.Type.undiscriminatedUnion(t),_other:()=>{throw new Error("Encountered unknown shape")}}),availability:e.availability==null?{status:rr.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function Yig(e){return{...e,availability:e.availability==null?{status:rr.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function FNA(e){return{...e,availability:e.availability==null?{status:rr.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}var Qig={laterVersion:"v27",earlierVersion:"v26",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:"0.6.1-3-g94ee67a",[We.GO_MODEL]:"0.6.1-3-g94ee67a",[We.GO_SDK]:"0.6.1-3-g94ee67a",[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V26.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),migrateBackwards:e=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,LNA(r)]))})};function LNA(e){return{...e,endpoints:e.endpoints.map(t=>UNA(t))}}function UNA(e){return{...e,response:e.response!=null?VNA(e.response):void 0}}function VNA(e){if(e.type!=="json")return e;let t=e.value;return t.type==="response"?rr.V26.HttpResponse.json(t):rr.V26.HttpResponse.json({docs:t.docs,responseBodyType:t.responseBodyType})}var Zig={laterVersion:"v28",earlierVersion:"v27",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.8.1-1-g0f40bf18",[We.TYPESCRIPT_BROWSER_SDK]:"0.8.1-1-g0f40bf18",[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:"0.8.1-1-g0f40bf18",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:"0.9.0-2-g6b0be0e",[We.GO_MODEL]:"0.9.0-2-g6b0be0e",[We.GO_SDK]:"0.9.0-2-g6b0be0e",[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V27.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),migrateBackwards:e=>({...e,auth:v8A(e.auth),headers:UCo(e.headers),types:Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,P8A(r)])),services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,ZNA(r)])),webhookGroups:Object.fromEntries(Object.entries(e.webhookGroups).map(([t,r])=>[t,JNA(r)])),errors:Object.fromEntries(Object.entries(e.errors).map(([t,r])=>[t,$NA(r)])),pathParameters:LCo(e.pathParameters),variables:WNA(e.variables)})};function WNA(e){return e.map(t=>HNA(t))}function HNA(e){return{...e,type:M8(e.type)}}function $NA(e){return{...e,type:e.type!=null?M8(e.type):void 0}}function JNA(e){return e.map(t=>GNA(t))}function GNA(e){return{...e,headers:UCo(e.headers),payload:KNA(e.payload)}}function KNA(e){switch(e.type){case"inlinedPayload":return rr.V27.WebhookPayload.inlinedPayload(YNA(e));case"reference":return rr.V27.WebhookPayload.reference({...e,payloadType:M8(e.payloadType)})}}function YNA(e){return{...e,properties:XNA(e.properties)}}function XNA(e){return e.map(t=>QNA(t))}function QNA(e){return{...e,valueType:M8(e.valueType)}}function ZNA(e){return{...e,endpoints:kNA(e.endpoints),headers:UCo(e.headers),pathParameters:LCo(e.pathParameters)}}function kNA(e){return e.map(t=>e8A(t))}function e8A(e){return{...e,headers:UCo(e.headers),pathParameters:LCo(e.pathParameters),allPathParameters:LCo(e.allPathParameters),queryParameters:h8A(e.queryParameters),requestBody:e.requestBody!=null?s8A(e.requestBody):void 0,sdkRequest:e.sdkRequest!=null?a8A(e.sdkRequest):void 0,response:e.response!=null?t8A(e.response):void 0}}function t8A(e){switch(e.type){case"json":return rr.V27.HttpResponse.json(i8A(e.value));case"fileDownload":return rr.V27.HttpResponse.fileDownload(e);case"text":return rr.V27.HttpResponse.text(e);case"streaming":return rr.V27.HttpResponse.streaming(r8A(e));default:fl(e)}}function r8A(e){return{...e,dataEventType:n8A(e.dataEventType)}}function n8A(e){switch(e.type){case"json":return rr.V27.StreamingResponseChunkType.json(M8(e.json));case"text":return rr.V27.StreamingResponseChunkType.text();default:fl(e)}}function i8A(e){switch(e.type){case"response":return rr.V27.JsonResponse.response({...e,responseBodyType:M8(e.responseBodyType)});case"nestedPropertyAsResponse":return rr.V27.JsonResponse.nestedPropertyAsResponse({...e,responseBodyType:M8(e.responseBodyType),responseProperty:e.responseProperty!=null?rag(e.responseProperty):void 0});default:fl(e)}}function a8A(e){return{...e,shape:o8A(e.shape)}}function o8A(e){switch(e.type){case"justRequestBody":return rr.V27.SdkRequestShape.justRequestBody(u8A(e.value));case"wrapper":return rr.V27.SdkRequestShape.wrapper(e);default:fl(e)}}function u8A(e){switch(e.type){case"typeReference":return rr.V27.SdkRequestBodyType.typeReference(kig(e));case"bytes":return rr.V27.SdkRequestBodyType.bytes(e);default:fl(e)}}function s8A(e){switch(e.type){case"inlinedRequestBody":return rr.V27.HttpRequestBody.inlinedRequestBody(d8A(e));case"reference":return rr.V27.HttpRequestBody.reference(kig(e));case"fileUpload":return rr.V27.HttpRequestBody.fileUpload(c8A(e));case"bytes":return rr.V27.HttpRequestBody.bytes(e);default:fl(e)}}function c8A(e){return{...e,properties:l8A(e.properties)}}function l8A(e){return e.map(t=>f8A(t))}function f8A(e){switch(e.type){case"file":return rr.V27.FileUploadRequestProperty.file(e);case"bodyProperty":return rr.V27.FileUploadRequestProperty.bodyProperty(eag(e));default:fl(e)}}function kig(e){return{...e,requestBodyType:M8(e.requestBodyType)}}function d8A(e){return{...e,properties:p8A(e.properties)}}function p8A(e){return e.map(t=>eag(t))}function eag(e){return{...e,valueType:M8(e.valueType)}}function LCo(e){return e.map(t=>_8A(t))}function _8A(e){return{...e,valueType:M8(e.valueType)}}function h8A(e){return e.map(t=>y8A(t))}function y8A(e){return{...e,valueType:M8(e.valueType)}}function v8A(e){return{...e,schemes:b8A(e.schemes)}}function b8A(e){return e.map(t=>g8A(t))}function g8A(e){switch(e.type){case"basic":return rr.V27.AuthScheme.basic(e);case"bearer":return rr.V27.AuthScheme.bearer(e);case"header":return m8A(e);default:fl(e)}}function m8A(e){return rr.V27.AuthScheme.header({...e,valueType:M8(e.valueType)})}function UCo(e){return e.map(t=>O8A(t))}function O8A(e){return{...e,valueType:M8(e.valueType)}}function P8A(e){return{...e,shape:j8A(e.shape)}}function j8A(e){switch(e.type){case"alias":return rr.V27.Type.alias(w8A(e));case"enum":return rr.V27.Type.enum(e);case"object":return rr.V27.Type.object(D8A(e));case"union":return rr.V27.Type.union(S8A(e));case"undiscriminatedUnion":return rr.V27.Type.undiscriminatedUnion(E8A(e));default:fl(e)}}function w8A(e){return{aliasOf:M8(e.aliasOf),resolvedType:q8A(e.resolvedType)}}function D8A(e){return{...e,properties:tag(e.properties)}}function S8A(e){return{...e,types:M8A(e.types),baseProperties:tag(e.baseProperties)}}function E8A(e){return{members:T8A(e.members)}}function tag(e){return e.map(t=>rag(t))}function rag(e){return{...e,valueType:M8(e.valueType)}}function M8A(e){return e.map(t=>({...t,shape:x8A(t.shape)}))}function x8A(e){switch(e.propertiesType){case"samePropertiesAsObject":return rr.V27.SingleUnionTypeProperties.samePropertiesAsObject(e);case"singleProperty":return rr.V27.SingleUnionTypeProperties.singleProperty({name:e.name,type:M8(e.type)});case"noProperties":return rr.V27.SingleUnionTypeProperties.noProperties();default:fl(e)}}function T8A(e){return e.map(t=>({...t,type:M8(t.type)}))}function q8A(e){switch(e.type){case"container":return e.container.type==="literal"?e.container.literal.type==="boolean"?rr.V27.ResolvedTypeReference.primitive(rr.V27.PrimitiveType.Boolean):rr.V27.ResolvedTypeReference.container(rr.V27.ContainerType.literal(rr.V27.Literal.string(e.container.literal.string))):rr.V27.ResolvedTypeReference.container(nag(e.container));case"named":return rr.V27.ResolvedTypeReference.named(e);case"primitive":return rr.V27.ResolvedTypeReference.primitive(e.primitive);case"unknown":return rr.V27.ResolvedTypeReference.unknown();default:fl(e)}}function M8(e){switch(e.type){case"container":return e.container.type==="literal"?e.container.literal.type==="boolean"?rr.V27.TypeReference.primitive(rr.V27.PrimitiveType.Boolean):rr.V27.TypeReference.container(rr.V27.ContainerType.literal(rr.V27.Literal.string(e.container.literal.string))):rr.V27.TypeReference.container(nag(e.container));case"named":return rr.V27.TypeReference.named(e);case"primitive":return rr.V27.TypeReference.primitive(e.primitive);case"unknown":return rr.V27.TypeReference.unknown();default:fl(e)}}function nag(e){switch(e.type){case"list":return rr.V27.ContainerType.list(M8(e.list));case"map":return rr.V27.ContainerType.map({keyType:M8(e.keyType),valueType:M8(e.valueType)});case"optional":return rr.V27.ContainerType.optional(M8(e.optional));case"set":return rr.V27.ContainerType.set(M8(e.set));case"literal":if(e.literal.type==="boolean")throw new Error("Internal error; failed to transform boolean literal between IR versions");return rr.V27.ContainerType.literal(rr.V27.Literal.string(e.literal.string));default:fl(e)}}var aag={laterVersion:"v29",earlierVersion:"v28",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.8.6-1-g3d8d8591",[We.TYPESCRIPT_BROWSER_SDK]:"0.8.6-1-g3d8d8591",[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:"0.8.6-1-g3d8d8591",[We.JAVA]:Zr,[We.JAVA_MODEL]:"0.5.14-1-ge4bcd98",[We.JAVA_SDK]:"0.5.14-1-ge4bcd98",[We.JAVA_SPRING]:"0.5.14-1-ge4bcd98",[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V28.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,types:Object.fromEntries(Object.keys(e.types).map(t=>[t,C8A({typeId:t,allTypes:e.types})]))})};function C8A({typeId:e,allTypes:t}){let r=iag({typeId:e,allTypes:t});return{availability:r.availability,docs:r.docs,name:r.name,shape:r.shape,examples:r.examples,referencedTypes:Array.from(r.referencedTypes).map(n=>{let i=iag({typeId:n,allTypes:t});return{typeId:n,fernFilepath:i.name.fernFilepath,name:i.name.name}})}}function iag({typeId:e,allTypes:t}){let r=t[e];if(r==null)throw new Error(`Type definition for type id ${e} is undefined`);return r}function oag({inlinedRequest:e,allTypes:t}){let r=new Set,n=t.reduce((i,a)=>({...i,[sOc(a.name)]:a}),{});for(let i of e.extends)uag({typeName:i,typeNameToDeclaration:n,referencedTypes:r});for(let i of e.properties)Tkn({reference:i.valueType,typeNameToDeclaration:n,referencedTypes:r});return[...r].reduce((i,a)=>{let u=n[a];if(u==null)throw new Error("Cannot find declaration for ID: "+a);return[...i,u.name]},[])}function Tkn({reference:e,typeNameToDeclaration:t,referencedTypes:r}){rr.V2.types.TypeReference._visit(e,{primitive:vf,container:n=>{A8A({container:n,typeNameToDeclaration:t,referencedTypes:r})},named:n=>{uag({typeName:n,typeNameToDeclaration:t,referencedTypes:r})},unknown:vf,void:vf,_unknown:()=>{throw new Error("Unknown TypeRefrence: "+e._type)}})}function A8A({container:e,typeNameToDeclaration:t,referencedTypes:r}){rr.V2.types.ContainerType._visit(e,{list:n=>{Tkn({reference:n,typeNameToDeclaration:t,referencedTypes:r})},set:n=>{Tkn({reference:n,typeNameToDeclaration:t,referencedTypes:r})},optional:n=>{Tkn({reference:n,typeNameToDeclaration:t,referencedTypes:r})},map:({keyType:n,valueType:i})=>{Tkn({reference:n,typeNameToDeclaration:t,referencedTypes:r}),Tkn({reference:i,typeNameToDeclaration:t,referencedTypes:r})},literal:vf,_unknown:()=>{throw new Error("Unknown ContainerType: "+e._type)}})}function uag({typeName:e,typeNameToDeclaration:t,referencedTypes:r}){let n=sOc(e);r.add(n);let i=t[n];if(i==null)throw new Error("Cannot locate type: "+n);for(let a of i.referencedTypes)r.add(sOc(a))}function sOc(e){return[...e.fernFilepathV2.map(t=>t.unsafeName.originalValue),e.nameV3.unsafeName.originalValue].join(".")}var sag={laterVersion:"v3",earlierVersion:"v2",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.0.249",[We.TYPESCRIPT_EXPRESS]:"0.0.264",[We.JAVA]:Zr,[We.JAVA_MODEL]:"0.0.134-3-g97d4964",[We.JAVA_SDK]:"0.0.134-3-g97d4964",[We.JAVA_SPRING]:"0.0.134-3-g97d4964",[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:fa,[We.STOPLIGHT]:fa,[We.OPENAPI_PYTHON_CLIENT]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>{let t=[...e.types];return{apiName:e.apiName,auth:e.auth,headers:e.headers,types:t,errors:e.errors,constants:e.constants,constantsV2:e.constantsV2,defaultEnvironment:e.defaultEnvironment,environments:e.environments,errorDiscriminant:e.errorDiscriminant,errorDiscriminationStrategy:e.errorDiscriminationStrategy,sdkConfig:e.sdkConfig,services:{websocket:e.services.websocket,http:e.services.http.map(r=>({availability:r.availability,docs:r.docs,name:r.name,basePath:r.basePath,basePathV2:r.basePathV2,headers:r.headers,pathParameters:r.pathParameters,endpoints:r.endpoints.map(n=>N8A(r,n,e.types,i=>{t.push(i)}))}))}}}};function N8A(e,t,r,n){return{docs:t.docs,availability:t.availability,id:t.id,name:t.name,nameV2:t.nameV2,method:t.method,headers:t.headers,path:t.path,pathParameters:t.pathParameters,queryParameters:t.queryParameters,request:z8A(t,e,r,n),response:t.response,errors:t.errors,errorsV2:t.errorsV2,auth:t.auth}}function z8A(e,t,r,n){let i=e.requestBody;return i==null?{docs:void 0,type:rr.V2.types.TypeReference.void(),typeV2:void 0}:rr.V3.services.http.HttpRequestBody._visit(i,{reference:a=>({docs:a.docs,type:a.requestBodyType,typeV2:a.requestBodyType}),inlinedRequestBody:a=>{let u={fernFilepath:t.name.fernFilepath,fernFilepathV2:t.name.fernFilepathV2,name:a.name.unsafeName.originalValue,nameV2:{originalValue:a.name.unsafeName.originalValue,camelCase:a.name.unsafeName.camelCase,pascalCase:a.name.unsafeName.pascalCase,snakeCase:a.name.unsafeName.snakeCase,screamingSnakeCase:a.name.unsafeName.screamingSnakeCase},nameV3:a.name},f=rr.V2.types.Type.object({extends:a.extends,properties:a.properties.map(c=>({availability:e.availability,docs:c.docs,name:{originalValue:c.name.name.unsafeName.originalValue,camelCase:c.name.name.unsafeName.camelCase,pascalCase:c.name.name.unsafeName.pascalCase,snakeCase:c.name.name.unsafeName.snakeCase,screamingSnakeCase:c.name.name.unsafeName.screamingSnakeCase,wireValue:c.name.wireValue},nameV2:c.name,valueType:c.valueType}))});n({docs:void 0,availability:e.availability,name:u,shape:f,referencedTypes:oag({inlinedRequest:a,allTypes:r}),examples:[]});let d=rr.V2.types.TypeReference.named(u);return{docs:void 0,type:d,typeV2:d}},_unknown:()=>{throw new Error("Unknown HttpRequestBody type: "+i.type)}})}var cag={laterVersion:"v30",earlierVersion:"v29",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:"0.6.5-1-g0ef31b7a",[We.PYTHON_PYDANTIC]:"0.6.5-1-g0ef31b7a",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"0.6.5-1-g0ef31b7a",[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V29.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=new cOc(e);return{...e,types:t.convertTypes(e.types),services:t.convertServices(e.services)}}},cOc=class{ir;constructor(t){this.ir=t}convertTypes(t){return Object.fromEntries(Object.entries(t).map(([r,n])=>[r,this.convertType(n)]))}convertServices(t){return Object.fromEntries(Object.entries(t).map(([r,n])=>[r,this.convertService(n)]))}convertService(t){return{...t,endpoints:this.convertEndpoints(t.endpoints)}}convertEndpoints(t){return t.map(r=>({...r,examples:this.convertExampleEndpointCalls(r.examples)}))}convertExampleEndpointCalls(t){return t.map(r=>({...r,rootPathParameters:this.convertExamplePathParameters(r.rootPathParameters),servicePathParameters:this.convertExamplePathParameters(r.servicePathParameters),endpointPathParameters:this.convertExamplePathParameters(r.endpointPathParameters),serviceHeaders:this.convertExampleHeaders(r.serviceHeaders),endpointHeaders:this.convertExampleHeaders(r.endpointHeaders),queryParameters:this.convertExampleQueryParameters(r.queryParameters),request:r.request!=null?this.convertExampleRequestBody(r.request):void 0,response:this.convertExampleResponse(r.response)}))}convertExamplePathParameters(t){return t.map(r=>({key:r.name.originalName,value:this.convertExampleTypeReference(r.value)}))}convertExampleHeaders(t){return t.map(r=>({wireKey:r.name.wireValue,value:this.convertExampleTypeReference(r.value)}))}convertExampleQueryParameters(t){return t.map(r=>({wireKey:r.name.wireValue,value:this.convertExampleTypeReference(r.value)}))}convertExampleRequestBody(t){switch(t.type){case"inlinedRequestBody":return rr.V29.ExampleRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,wireKey:r.name.wireValue,value:this.convertExampleTypeReference(r.value)}))});case"reference":return rr.V29.ExampleRequestBody.reference(this.convertExampleTypeReference(t));default:fl(t)}}convertExampleResponse(t){switch(t.type){case"ok":return rr.V29.ExampleResponse.ok({body:t.body!=null?this.convertExampleTypeReference(t.body):void 0});case"error":return rr.V29.ExampleResponse.error({...t,body:t.body!=null?this.convertExampleTypeReference(t.body):void 0});default:fl(t)}}convertType(t){return{...t,examples:this.convertExampleTypes(t.examples)}}convertExampleTypes(t){return t.map(r=>this.convertExampleType(r))}convertExampleType(t){return{...t,shape:this.convertExampleTypeShape(t.shape)}}convertExampleTypeReferences(t){return t.map(r=>this.convertExampleTypeReference(r))}convertExampleTypeReference(t){return{...t,shape:this.convertExampleTypeReferenceShape(t.shape)}}convertExampleTypeReferenceShape(t){switch(t.type){case"primitive":return rr.V29.ExampleTypeReferenceShape.primitive(this.convertExamplePrimitive(t.primitive));case"container":return rr.V29.ExampleTypeReferenceShape.container(this.convertExampleContainer(t.container));case"named":return rr.V29.ExampleTypeReferenceShape.named(this.convertExampleNamedType(t));case"unknown":return rr.V29.ExampleTypeReferenceShape.unknown(t);default:fl(t)}}convertExamplePrimitive(t){switch(t.type){case"integer":return rr.V29.ExamplePrimitive.integer(t.integer);case"double":return rr.V29.ExamplePrimitive.double(t.double);case"string":return rr.V29.ExamplePrimitive.string(t.string.original);case"boolean":return rr.V29.ExamplePrimitive.boolean(t.boolean);case"long":return rr.V29.ExamplePrimitive.long(t.long);case"datetime":return rr.V29.ExamplePrimitive.datetime(t.datetime);case"date":return rr.V29.ExamplePrimitive.date(t.date);case"uuid":return rr.V29.ExamplePrimitive.uuid(t.uuid);default:fl(t)}}convertExampleContainer(t){switch(t.type){case"list":return rr.V29.ExampleContainer.list(this.convertExampleTypeReferences(t.list));case"set":return rr.V29.ExampleContainer.set(this.convertExampleTypeReferences(t.set));case"optional":return rr.V29.ExampleContainer.optional(t.optional!=null?this.convertExampleTypeReference(t.optional):void 0);case"map":return rr.V29.ExampleContainer.map(this.convertKeyValuePairs(t.map));default:fl(t)}}convertKeyValuePairs(t){return t.map(r=>({key:this.convertExampleTypeReference(r.key),value:this.convertExampleTypeReference(r.value)}))}convertExampleNamedType(t){return{...t,shape:this.convertExampleTypeShape(t.shape)}}convertExampleTypeShape(t){switch(t.type){case"alias":return rr.V29.ExampleTypeShape.alias({value:this.convertExampleTypeReference(t.value)});case"enum":return rr.V29.ExampleTypeShape.enum({wireValue:t.value.wireValue});case"object":return rr.V29.ExampleTypeShape.object(this.convertExampleObjectType(t));case"union":return rr.V29.ExampleTypeShape.union(this.convertExampleUnionType(t));default:fl(t)}}convertExampleObjectType(t){return{properties:t.properties.map(r=>({...r,wireKey:r.name.wireValue,value:this.convertExampleTypeReference(r.value)}))}}convertExampleUnionType(t){return{wireDiscriminantValue:t.singleUnionType.wireDiscriminantValue.wireValue,properties:this.convertExampleSingleUnionTypeProperties(t.singleUnionType.shape)}}convertExampleSingleUnionTypeProperties(t){var r;switch(t.type){case"samePropertiesAsObject":{let n=(r=this.ir.types[t.typeId])==null?void 0:r.name;if(n==null)throw new Error(`Internal error; type ID ${t.typeId} does not exist in the IR`);return rr.V29.ExampleSingleUnionTypeProperties.samePropertiesAsObject({typeName:n,shape:this.convertExampleTypeShape(rr.V30.ExampleTypeShape.object({properties:t.object.properties}))})}case"singleProperty":return rr.V29.ExampleSingleUnionTypeProperties.singleProperty({...t,shape:this.convertExampleTypeReferenceShape(t.shape)});case"noProperties":return rr.V29.ExampleSingleUnionTypeProperties.noProperties();default:fl(t)}}};var lag={laterVersion:"v31",earlierVersion:"v30",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.8.8",[We.TYPESCRIPT_BROWSER_SDK]:"0.8.8",[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:"0.8.8",[We.JAVA]:Zr,[We.JAVA_MODEL]:"0.7.0-rc0",[We.JAVA_SDK]:"0.7.0-rc0",[We.JAVA_SPRING]:"0.7.0-rc0",[We.PYTHON_FASTAPI]:"0.7.5-1-gb54fb677",[We.PYTHON_PYDANTIC]:"0.7.5-1-gb54fb677",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"0.7.5-1-gb54fb677",[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V30.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({apiName:e.apiName,apiDisplayName:e.apiDisplayName,apiDocs:e.apiDocs,auth:e.auth,headers:e.headers,types:e.types,webhookGroups:e.webhookGroups,errors:e.errors,subpackages:e.subpackages,rootPackage:e.rootPackage,constants:e.constants,environments:e.environments,basePath:e.basePath,pathParameters:e.pathParameters,errorDiscriminationStrategy:e.errorDiscriminationStrategy,sdkConfig:e.sdkConfig,variables:e.variables,serviceTypeReferenceInfo:e.serviceTypeReferenceInfo,services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{availability:r.availability,name:r.name,displayName:r.displayName,basePath:r.basePath,endpoints:r.endpoints.map(n=>({id:n.id,docs:n.docs,availability:n.availability,name:n.name,displayName:n.displayName,method:n.method,headers:n.headers,baseUrl:n.baseUrl,path:n.path,fullPath:n.fullPath,pathParameters:n.pathParameters,allPathParameters:n.allPathParameters,queryParameters:n.queryParameters,requestBody:n.requestBody,sdkRequest:n.sdkRequest,response:n.response,errors:n.errors,auth:n.auth,examples:n.examples})),headers:r.headers,pathParameters:r.pathParameters}]))})};var dag={laterVersion:"v32",earlierVersion:"v31",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:"0.9.4-2-g139cf36",[We.GO_MODEL]:"0.9.4-2-g139cf36",[We.GO_SDK]:"0.9.4-2-g139cf36",[We.RUBY_MODEL]:"0.0.0",[We.RUBY_SDK]:"0.0.0",[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V31.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,types:Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,{...r,examples:U8A(r.examples)}])),services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{...r,endpoints:r.endpoints.map(B8A)}]))})};function Z1n({examples:e,convert:t}){let r=[];for(let n of e){let i=t(n);i!=null&&r.push(i)}return r}function B8A(e){return{...e,examples:Z1n({examples:e.examples,convert:I8A})}}function I8A(e){let t;if(e.request!=null&&(t=R8A(e.request),t==null))return;let r=F8A(e.response);if(r!=null)return{...e,rootPathParameters:Z1n({examples:e.rootPathParameters,convert:lOc}),endpointPathParameters:Z1n({examples:e.endpointPathParameters,convert:lOc}),servicePathParameters:Z1n({examples:e.servicePathParameters,convert:lOc}),endpointHeaders:Z1n({examples:e.endpointHeaders,convert:fag}),serviceHeaders:Z1n({examples:e.serviceHeaders,convert:fag}),queryParameters:Z1n({examples:e.queryParameters,convert:L8A}),request:t,response:r}}function R8A(e){switch(e.type){case"inlinedRequestBody":{let t=[];for(let r of e.properties){let n=ZOe(r.value);n!=null&&t.push({...r,value:n})}return rr.V31.ExampleRequestBody.inlinedRequestBody({...e,properties:t})}case"reference":{let t=fOc(e.shape);return t==null?void 0:rr.V31.ExampleRequestBody.reference({...e,shape:t})}default:fl(e)}}function F8A(e){switch(e.type){case"ok":{if(e.body==null)return rr.V31.ExampleResponse.ok({body:void 0});let t=ZOe(e.body);return t==null?void 0:rr.V31.ExampleResponse.ok({body:t})}case"error":{if(e.body==null)return rr.V31.ExampleResponse.error({...e,body:void 0});let t=ZOe(e.body);return t==null?void 0:rr.V31.ExampleResponse.error({...e,body:t})}}}function lOc(e){let t=ZOe(e.value);if(t!=null)return{...e,value:t}}function fag(e){let t=ZOe(e.value);if(t!=null)return{...e,value:t}}function L8A(e){let t=ZOe(e.value);if(t!=null)return{...e,value:t}}function U8A(e){let t=[];for(let r of e){let n=V8A(r);n!=null&&t.push(n)}return t}function V8A(e){let t=pag(e.shape);if(t!=null)return{...e,shape:t}}function pag(e){switch(e.type){case"enum":return rr.V31.ExampleTypeShape.enum(e);case"alias":{let t=ZOe(e.value);return t==null?void 0:rr.V31.ExampleTypeShape.alias({value:t})}case"object":{let t=[];for(let r of e.properties){let n=ZOe(r.value);n!=null&&t.push({...r,value:n})}return rr.V31.ExampleTypeShape.object({properties:t})}case"union":{let t=W8A(e.singleUnionType);return t==null?void 0:rr.V31.ExampleTypeShape.union({...e,singleUnionType:t})}case"undiscriminatedUnion":return;default:fl(e)}}function ZOe(e){let t=fOc(e.shape);if(t!=null)return{shape:t,jsonExample:e.jsonExample}}function W8A(e){let t=H8A(e.shape);if(t!=null)return{...e,shape:t}}function H8A(e){switch(e.type){case"noProperties":return rr.V31.ExampleSingleUnionTypeProperties.noProperties();case"singleProperty":{let t=fOc(e.shape);return t==null?void 0:rr.V31.ExampleSingleUnionTypeProperties.singleProperty({...e,shape:t})}case"samePropertiesAsObject":{let t=[];for(let r of e.object.properties){let n=ZOe(r.value);n!=null&&t.push({...r,value:n})}return rr.V31.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...e,object:{properties:t}})}default:fl(e)}}function fOc(e){switch(e.type){case"container":{let t=$8A(e.container);return t==null?void 0:rr.V31.ExampleTypeReferenceShape.container(t)}case"named":{let t=pag(e.shape);return t==null?void 0:rr.V31.ExampleTypeReferenceShape.named({...e,shape:t})}case"primitive":return rr.V31.ExampleTypeReferenceShape.primitive(e.primitive);case"unknown":return rr.V31.ExampleTypeReferenceShape.unknown(e.unknown);default:fl(e)}}function $8A(e){switch(e.type){case"list":{let t=[];for(let r of e.list){let n=ZOe(r);n!=null&&t.push(n)}return rr.V31.ExampleContainer.list(t)}case"set":{let t=[];for(let r of e.set){let n=ZOe(r);n!=null&&t.push(n)}return rr.V31.ExampleContainer.set(t)}case"map":{let t=[];for(let r of e.map){let n=ZOe(r.key),i=ZOe(r.value);n!=null&&i!=null&&t.push({key:n,value:i})}return rr.V31.ExampleContainer.map(t)}case"optional":{if(e.optional==null)return rr.V31.ExampleContainer.optional();let t=ZOe(e.optional);return t==null?rr.V31.ExampleContainer.optional():rr.V31.ExampleContainer.optional(t)}default:fl(e)}}var _ag={laterVersion:"v33",earlierVersion:"v32",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.12.0",[We.TYPESCRIPT_BROWSER_SDK]:"0.12.0",[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:"0.13.0-3-g8c56a41",[We.GO_MODEL]:"0.13.0-3-g8c56a41",[We.GO_SDK]:"0.13.0-3-g8c56a41",[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:"0.0.0",[We.CSHARP_SDK]:"0.0.0",[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V32.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=new dOc(e);return{...e,services:Object.fromEntries(Object.entries(e.services).map(([r,n])=>[r,{...n,endpoints:n.endpoints.map(i=>t.convertEndpoint(i))}]))}}},dOc=class{ir;constructor(t){this.ir=t}convertEndpoint(t){return{...t,queryParameters:t.queryParameters.map(r=>this.isTypeReferenceObject(r.valueType)?{...r,valueType:rr.V33.TypeReference.container(rr.V33.ContainerType.optional(rr.V33.TypeReference.primitive("STRING")))}:r),examples:J8A({examples:t.examples,convert:G8A})}}isTypeReferenceObject(t){switch(t.type){case"container":return this.isContainerObject(t.container);case"named":return this.isNamedTypeObject(t);case"primitive":return!1;case"unknown":return!0;default:fl(t)}}isContainerObject(t){switch(t.type){case"map":case"list":case"set":return!0;case"optional":return this.isTypeReferenceObject(t.optional);case"literal":return!1;default:fl(t)}}isNamedTypeObject(t){let r=this.ir.types[t.typeId];if(r==null)return!0;switch(r.shape.type){case"alias":return this.isTypeReferenceObject(r.shape.aliasOf);case"enum":return!1;case"object":case"union":case"undiscriminatedUnion":return!0;default:fl(r.shape)}}};function J8A({examples:e,convert:t}){let r=[];for(let n of e){let i=t(n);i!=null&&r.push(i)}return r}function G8A(e){return{...e,queryParameters:e.queryParameters.filter(t=>!pOc(t.value))}}function pOc(e){switch(e.shape.type){case"container":return K8A(e.shape.container);case"named":return Y8A(e.shape);case"primitive":return!1;case"unknown":return!0;default:fl(e.shape)}}function K8A(e){switch(e.type){case"map":case"list":case"set":return!0;case"optional":return e.optional!=null&&pOc(e.optional);default:fl(e)}}function Y8A(e){switch(e.shape.type){case"alias":return pOc(e.shape.value);case"enum":return!1;case"object":case"union":case"undiscriminatedUnion":return!0;default:fl(e.shape)}}var qkn=yu(lVu(),1);var hag={laterVersion:"v34",earlierVersion:"v33",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"0.10.4",[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V33.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([r,n])=>[r,{...n,endpoints:n.endpoints.map(i=>{var a;return{...i,requestBody:(a=i.requestBody)==null?void 0:a._visit({inlinedRequestBody:u=>qkn.FernIrV33.HttpRequestBody.inlinedRequestBody(u),reference:u=>qkn.FernIrV33.HttpRequestBody.reference(u),fileUpload:u=>qkn.FernIrV33.HttpRequestBody.fileUpload({...u,properties:u.properties.map(f=>{var d,c,o,l;return f.type==="file"&&f.value.type==="fileArray"&&t.taskContext.logger.warn(`${i.method} ${i.fullPath.head} accepts a list of files however the ${(d=t.targetGenerator)==null?void 0:d.name}@${(c=t.targetGenerator)==null?void 0:c.version} only supports accepting a single file. File an [issue](https://github.com/fern-api/fern/issues) to add request for file arrays in ${(o=t.targetGenerator)==null?void 0:o.name}@${(l=t.targetGenerator)==null?void 0:l.version}!`),f.type==="file"?qkn.FernIrV33.FileUploadRequestProperty.file({...f.value}):f})}),bytes:u=>qkn.FernIrV33.HttpRequestBody.bytes(u),_other:u=>{}})}})}]))})};var yag={laterVersion:"v35",earlierVersion:"v34",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:"0.18.0",[We.GO_MODEL]:"0.18.0",[We.GO_SDK]:"0.18.0",[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V34.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{...r,endpoints:r.endpoints.map(n=>({docs:n.docs,availability:n.availability,id:n.id,name:n.name,displayName:n.displayName,method:n.method,headers:n.headers,baseUrl:n.baseUrl,path:n.path,fullPath:n.fullPath,pathParameters:n.pathParameters,allPathParameters:n.allPathParameters,queryParameters:n.queryParameters,requestBody:n.requestBody,sdkRequest:n.sdkRequest,response:n.response,errors:n.errors,auth:n.auth,idempotent:n.idempotent,examples:n.examples}))}]))})};var vag={laterVersion:"v36",earlierVersion:"v35",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"0.11.6",[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V35.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e})};var bag={laterVersion:"v37",earlierVersion:"v36",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.13.0",[We.TYPESCRIPT_BROWSER_SDK]:"0.13.0",[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.13.0",[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"0.12.0",[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V36.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([r,n])=>[r,{...n,endpoints:n.endpoints.map(i=>({...i,examples:i.examples.filter(a=>a.exampleType==="userProvided")}))}]))})};var gag={laterVersion:"v38",earlierVersion:"v37",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.15.0-rc0",[We.TYPESCRIPT_BROWSER_SDK]:"0.15.0-rc0",[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:"0.12.0-rc0",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:"0.9.0-rc0",[We.PYTHON_PYDANTIC]:"0.9.0-rc0",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"1.2.0-rc0",[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V37.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([r,n])=>[r,{...n,endpoints:n.endpoints.map(i=>{var a;return{...i,response:(a=i.response)==null?void 0:a._visit({fileDownload:u=>rr.V37.HttpResponse.fileDownload(u),json:u=>rr.V37.HttpResponse.json(u),streaming:u=>u._visit({json:f=>rr.V37.HttpResponse.streaming({dataEventType:rr.V37.StreamingResponseChunkType.json(f.payload),docs:f.docs,terminator:f.terminator}),sse:()=>{},text:f=>rr.V37.HttpResponse.streaming({dataEventType:rr.V37.StreamingResponseChunkType.text(),docs:f.docs,terminator:void 0}),_other:()=>{}}),text:u=>rr.V37.HttpResponse.text(u),_other:()=>{}})}})}]))})};var mag={laterVersion:"v39",earlierVersion:"v38",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:"0.9.0-rc1",[We.PYTHON_PYDANTIC]:"0.9.0-rc1",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"1.4.0-rc1",[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:"0.7.0-rc0",[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V38.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,auth:{...e.auth,schemes:e.auth.schemes.map(r=>X8A(r))}})};function X8A(e){switch(e.type){case"basic":return rr.V38.AuthScheme.basic(e);case"bearer":return rr.V38.AuthScheme.bearer(e);case"header":return rr.V38.AuthScheme.header(e);case"oauth":return rr.V38.AuthScheme.bearer({docs:e.docs,token:{originalName:"token",camelCase:{unsafeName:"token",safeName:"token"},pascalCase:{unsafeName:"Token",safeName:"Token"},snakeCase:{unsafeName:"token",safeName:"token"},screamingSnakeCase:{unsafeName:"TOKEN",safeName:"TOKEN"}},tokenEnvVar:void 0});default:fl(e)}}var jag={laterVersion:"v4",earlierVersion:"v3",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:"0.0.264",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI]:"0.0.11-4-g1c29f6c",[We.POSTMAN]:"0.0.32-rc0",[We.STOPLIGHT]:fa,[We.OPENAPI_PYTHON_CLIENT]:fa,[We.PYTHON_SDK]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>({apiName:e.apiName,auth:e.auth,headers:e.headers,types:e.types.map(t=>({docs:t.docs,availability:t.availability,name:t.name,shape:t.shape,examples:t.examples.map(r=>wag(r.shape)),referencedTypes:t.referencedTypes})),errors:e.errors,constants:e.constants,constantsV2:e.constantsV2,defaultEnvironment:e.defaultEnvironment,environments:e.environments,errorDiscriminant:e.errorDiscriminant,errorDiscriminationStrategy:e.errorDiscriminationStrategy,sdkConfig:e.sdkConfig,services:{...e.services,http:e.services.http.map(t=>({...t,endpoints:t.endpoints.map(r=>({...r,examples:r.examples.map(n=>t5A(n))}))}))}})};function wag(e){return rr.V4.types.ExampleTypeShape._visit(e,{object:t=>rr.V3.types.ExampleType.object(Q8A(t)),union:t=>rr.V3.types.ExampleType.union(k8A(t)),alias:t=>rr.V3.types.ExampleType.alias(e5A(t)),enum:rr.V3.types.ExampleType.enum,_unknown:()=>{throw new Error("Unknown ExampleTypeShape: "+e.type)}})}function Q8A(e){return{properties:e.properties.map(t=>({wireKey:t.wireKey,value:vee(t.value),originalTypeDeclaration:t.originalTypeDeclaration}))}}function vee(e){return rr.V4.types.ExampleTypeReferenceShape._visit(e.shape,{primitive:rr.V3.types.ExampleTypeReference.primitive,container:t=>rr.V3.types.ExampleTypeReference.container(Z8A(t)),named:t=>rr.V3.types.ExampleTypeReference.named(Dag(t)),unknown:rr.V3.types.ExampleTypeReference.unknown,_unknown:()=>{throw new Error("Unknown ExampleTypeReference: "+e.shape.type)}})}function Z8A(e){return rr.V4.types.ExampleContainer._visit(e,{list:t=>rr.V3.types.ExampleContainer.list(t.map(vee)),set:t=>rr.V3.types.ExampleContainer.set(t.map(vee)),optional:t=>rr.V3.types.ExampleContainer.optional(t!=null?vee(t):void 0),map:t=>rr.V3.types.ExampleContainer.map(t.map(r=>({key:vee(r.key),value:vee(r.value)}))),_unknown:()=>{throw new Error("Unknown ExampleContainer: "+e.type)}})}function Dag(e){return{typeName:e.typeName,shape:wag(e.shape)}}function k8A(e){return{wireDiscriminantValue:e.wireDiscriminantValue,properties:rr.V4.types.ExampleSingleUnionTypeProperties._visit(e.properties,{samePropertiesAsObject:t=>rr.V3.types.ExampleSingleUnionTypeProperties.samePropertiesAsObject(Dag(t)),singleProperty:t=>rr.V3.types.ExampleSingleUnionTypeProperties.singleProperty(vee(t)),noProperties:()=>rr.V3.types.ExampleSingleUnionTypeProperties.noProperties(),_unknown:()=>{throw new Error("Unknown ExampleSingleUnionTypeProperties: "+e.properties.type)}})}}function e5A(e){return{value:vee(e.value)}}function t5A(e){return{servicePathParameters:e.servicePathParameters.map(t=>Oag(t)),endpointPathParameters:e.servicePathParameters.map(t=>Oag(t)),serviceHeaders:e.serviceHeaders.map(t=>Pag(t)),endpointHeaders:e.endpointHeaders.map(t=>Pag(t)),queryParameters:e.queryParameters.map(t=>r5A(t)),request:e.request!=null?n5A(e.request):void 0,response:a5A(e.response)}}function Oag(e){return{key:e.key,value:vee(e.value)}}function Pag(e){return{key:e.wireKey,value:vee(e.value)}}function r5A(e){return{key:e.wireKey,value:vee(e.value)}}function n5A(e){return rr.V4.services.http.ExampleRequestBody._visit(e,{inlinedRequestBody:t=>rr.V3.services.http.ExampleRequestBody.inlinedRequestBody({properties:t.properties.map(r=>i5A(r))}),reference:t=>rr.V3.services.http.ExampleRequestBody.reference(vee(t)),_unknown:()=>{throw new Error("Unknown ExampleRequestBody: "+e.type)}})}function i5A(e){return{wireKey:e.wireKey,value:vee(e.value),originalTypeDeclaration:e.originalTypeDeclaration}}function a5A(e){return rr.V4.services.http.ExampleResponse._visit(e,{ok:t=>rr.V3.services.http.ExampleResponse.ok({body:t.body!=null?vee(t.body):void 0}),error:t=>rr.V3.services.http.ExampleResponse.error({error:t.error,body:t.body!=null?vee(t.body):void 0}),_unknown:()=>{throw new Error("Unknown ExampleResponse: "+e.type)}})}var Sag={laterVersion:"v40",earlierVersion:"v39",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:"0.20.0",[We.GO_MODEL]:"0.20.0",[We.GO_SDK]:"0.20.0",[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V39.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e})};var Eag={laterVersion:"v41",earlierVersion:"v40",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V40.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,errors:Object.fromEntries(Object.entries(e.errors).map(([r,n])=>[r,{name:n.name,discriminantValue:n.discriminantValue,type:n.type,statusCode:n.statusCode,docs:n.docs}]))})};var Mag={laterVersion:"v42",earlierVersion:"v41",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:"0.8.0-rc0",[We.JAVA_SDK]:"0.9.0-rc0",[We.JAVA_SPRING]:"0.8.0-rc0",[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V41.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,auth:{...e.auth,schemes:e.auth.schemes.map(r=>o5A(r))}})};function o5A(e){switch(e.type){case"basic":return rr.V41.AuthScheme.basic(e);case"bearer":return rr.V41.AuthScheme.bearer(e);case"header":return rr.V41.AuthScheme.header(e);case"oauth":return rr.V41.AuthScheme.oauth(u5A(e));default:fl(e)}}function u5A(e){var t;switch(e.configuration.type){case"clientCredentials":return{...e,configuration:rr.V41.OAuthConfiguration.clientCredentials({...e.configuration,tokenEndpoint:{...e.configuration.tokenEndpoint,endpointReference:e.configuration.tokenEndpoint.endpointReference.endpointId},refreshEndpoint:e.configuration.refreshEndpoint!=null?{...e.configuration.refreshEndpoint,endpointReference:(t=e.configuration.refreshEndpoint)==null?void 0:t.endpointReference.endpointId}:void 0})};default:fl(e.configuration.type)}}var xag={laterVersion:"v43",earlierVersion:"v42",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.17.0",[We.TYPESCRIPT_BROWSER_SDK]:"0.17.0",[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:"0.13.0",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V42.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([r,n])=>[r,{...n,endpoints:n.endpoints.map(i=>{var a;return{...i,response:(a=i.response)==null?void 0:a.body}})}]))})};var qag={laterVersion:"v44",earlierVersion:"v43",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V43.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([r,n])=>[r,{...n,endpoints:n.endpoints.map(i=>({...i,examples:i.examples.map(a=>s5A({example:a})).filter(FS)}))}]))})};function s5A({example:e}){return e._visit({userProvided:t=>rr.V43.HttpEndpointExample.userProvided(Tag({example:t})),generated:t=>rr.V43.HttpEndpointExample.generated(Tag({example:t})),_other:()=>{}})}function Tag({example:e}){return{...e,response:c5A({example:e.response})}}function c5A({example:e}){switch(e.type){case"ok":return l5A({example:e.value});case"error":return rr.V43.ExampleResponse.error(e);default:fl(e)}}function l5A({example:e}){switch(e.type){case"body":return rr.V43.ExampleResponse.ok({body:e.value});case"sse":return rr.V43.ExampleResponse.ok({body:void 0});case"stream":return rr.V43.ExampleResponse.ok({body:void 0});default:fl(e)}}var Cag={laterVersion:"v45",earlierVersion:"v44",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V44.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=sy(e.types,r=>({...r,shape:rr.V45.types.Type._visit(r.shape,{union:n=>rr.V44.types.Type.union({...n,baseProperties:n.baseProperties.map(i=>({...i,valueType:uC(i.valueType)})),types:n.types.map(i=>P5A(i))}),enum:rr.V44.types.Type.enum,object:n=>rr.V44.types.Type.object({...n,properties:n.properties.map(i=>({...i,valueType:uC(i.valueType)}))}),alias:n=>rr.V44.types.Type.alias({aliasOf:uC(n.aliasOf),resolvedType:w5A(n.resolvedType)}),undiscriminatedUnion:n=>rr.V44.types.Type.undiscriminatedUnion(D5A(n)),_other:()=>{throw new Error("Encountered unknown shape")}})}));return{...e,auth:v5A(e.auth),headers:e.headers.map(r=>Ckn(r)),idempotencyHeaders:e.idempotencyHeaders.map(r=>Ckn(r)),types:t,services:sy(e.services,r=>S5A(r)),errors:sy(e.errors,r=>V5A(r)),webhookGroups:sy(e.webhookGroups,r=>_5A(r)),websocketChannels:sy(e.websocketChannels,r=>f5A(r)),pathParameters:e.pathParameters.map(r=>y9i(r)),variables:e.variables.map(r=>E5A(r))}}};function f5A(e){return{...e,headers:e.headers.map(t=>Ckn(t)),queryParameters:e.queryParameters.map(t=>v9i(t)),pathParameters:e.pathParameters.map(t=>y9i(t)),messages:e.messages.map(t=>d5A(t))}}function d5A(e){return{...e,body:p5A(e.body)}}function p5A(e){switch(e.type){case"inlinedBody":return rr.V44.websocket.WebSocketMessageBody.inlinedBody({...e,properties:e.properties.map(t=>({...t,valueType:uC(t.valueType)}))});case"reference":return rr.V44.websocket.WebSocketMessageBody.reference({...e,bodyType:uC(e.bodyType)})}}function _5A(e){return e.map(t=>h5A(t))}function h5A(e){return{...e,headers:e.headers.map(t=>Ckn(t)),payload:y5A(e.payload)}}function y5A(e){switch(e.type){case"reference":return rr.V44.webhooks.WebhookPayload.reference({...e,payloadType:uC(e.payloadType)});case"inlinedPayload":return rr.V44.webhooks.WebhookPayload.inlinedPayload({...e,properties:e.properties.map(t=>({...t,valueType:uC(t.valueType)}))})}}function v5A(e){return{...e,schemes:e.schemes.map(t=>{switch(t.type){case"basic":return rr.V44.auth.AuthScheme.basic(t);case"bearer":return rr.V44.auth.AuthScheme.bearer(t);case"header":return rr.V44.auth.AuthScheme.header(b5A(t));case"oauth":return rr.V44.auth.AuthScheme.oauth(g5A(t))}})}}function b5A(e){return{...e,valueType:uC(e.valueType)}}function g5A(e){return{...e,configuration:rr.V44.auth.OAuthConfiguration.clientCredentials({...e.configuration,tokenEndpoint:m5A(e.configuration.tokenEndpoint),refreshEndpoint:e.configuration.refreshEndpoint!=null?O5A(e.configuration.refreshEndpoint):void 0})}}function m5A(e){return{...e,requestProperties:{clientId:VCo(e.requestProperties.clientId),clientSecret:VCo(e.requestProperties.clientSecret),scopes:e.requestProperties.scopes!=null?VCo(e.requestProperties.scopes):void 0},responseProperties:{accessToken:cAr(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?cAr(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?cAr(e.responseProperties.refreshToken):void 0}}}function O5A(e){return{...e,requestProperties:{refreshToken:VCo(e.requestProperties.refreshToken)},responseProperties:{accessToken:cAr(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?cAr(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?cAr(e.responseProperties.refreshToken):void 0}}}function Ckn(e){return{...e,valueType:uC(e.valueType)}}function uC(e){return rr.V45.types.TypeReference._visit(e,{container:t=>rr.V44.types.TypeReference.container(Aag(t)),primitive:t=>t.v1==="BIG_INTEGER"?rr.V44.types.TypeReference.primitive(rr.V44.types.PrimitiveType.String):rr.V44.types.TypeReference.primitive(t.v1),named:rr.V44.types.TypeReference.named,unknown:rr.V44.types.TypeReference.unknown,_other:()=>{throw new Error("Unknown type reference: "+e.type)}})}function Aag(e){return rr.V45.types.ContainerType._visit(e,{list:t=>rr.V44.types.ContainerType.list(uC(t)),optional:t=>rr.V44.types.ContainerType.optional(uC(t)),set:t=>rr.V44.types.ContainerType.set(uC(t)),map:({keyType:t,valueType:r})=>rr.V44.types.ContainerType.map({keyType:uC(t),valueType:uC(r)}),literal:rr.V44.types.ContainerType.literal,_other:()=>{throw new Error("Unknown ContainerType: "+e.type)}})}function P5A(e){return{...e,shape:j5A(e.shape)}}function j5A(e){return rr.V45.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>rr.V44.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>rr.V44.types.SingleUnionTypeProperties.singleProperty({...t,type:uC(t.type)}),noProperties:rr.V44.types.SingleUnionTypeProperties.noProperties,_other:()=>{throw new Error(`Unknown SingleUnionTypeProperties: ${JSON.stringify(e)}`)}})}function w5A(e){return rr.V45.types.ResolvedTypeReference._visit(e,{container:t=>rr.V44.types.ResolvedTypeReference.container(Aag(t)),named:rr.V44.types.ResolvedTypeReference.named,primitive:t=>t.v1==="BIG_INTEGER"?rr.V44.types.ResolvedTypeReference.primitive(rr.V44.types.PrimitiveType.String):rr.V44.types.ResolvedTypeReference.primitive(t.v1),unknown:rr.V44.types.ResolvedTypeReference.unknown,_other:()=>{throw new Error("Unknown ResolvedTypeReference: "+e.type)}})}function D5A(e){return{members:e.members.map(t=>({...t,type:uC(t.type)}))}}function S5A(e){return{...e,pathParameters:e.pathParameters.map(t=>y9i(t)),headers:e.headers.map(t=>Ckn(t)),endpoints:e.endpoints.map(t=>M5A(t))}}function y9i(e){return{...e,valueType:uC(e.valueType)}}function E5A(e){return{...e,type:uC(e.type)}}function M5A(e){return{...e,pagination:e.pagination!=null?A5A(e.pagination):void 0,allPathParameters:e.allPathParameters.map(t=>y9i(t)),pathParameters:e.pathParameters.map(t=>y9i(t)),sdkRequest:e.sdkRequest!=null?I5A(e.sdkRequest):void 0,requestBody:e.requestBody!=null?L5A(e.requestBody):void 0,response:e.response!=null?x5A(e.response):void 0,headers:e.headers.map(t=>Ckn(t)),queryParameters:e.queryParameters.map(t=>v9i(t))}}function x5A(e){return{...e,body:e.body!=null?T5A(e.body):void 0}}function T5A(e){switch(e.type){case"json":return rr.V44.http.HttpResponseBody.json(q5A(e.value));case"fileDownload":return rr.V44.http.HttpResponseBody.fileDownload(e);case"text":return rr.V44.http.HttpResponseBody.text(e);case"streaming":return rr.V44.http.HttpResponseBody.streaming(C5A(e.value))}}function q5A(e){switch(e.type){case"response":return rr.V44.http.JsonResponse.response({...e,responseBodyType:uC(e.responseBodyType)});case"nestedPropertyAsResponse":return rr.V44.http.JsonResponse.nestedPropertyAsResponse({...e,responseBodyType:uC(e.responseBodyType),responseProperty:e.responseProperty!=null?_Oc(e.responseProperty):void 0})}}function C5A(e){switch(e.type){case"json":return rr.V44.http.StreamingResponse.json({...e,payload:uC(e.payload)});case"text":return rr.V44.http.StreamingResponse.text(e);case"sse":return rr.V44.http.StreamingResponse.sse({...e,payload:uC(e.payload)})}}function A5A(e){switch(e.type){case"cursor":return rr.V44.http.Pagination.cursor(N5A(e));case"offset":return rr.V44.http.Pagination.offset(z5A(e))}}function N5A(e){return{...e,page:v9i(e.page),next:cAr(e.next),results:cAr(e.results)}}function z5A(e){return{...e,page:v9i(e.page),results:cAr(e.results)}}function VCo(e){return{...e,property:B5A(e.property)}}function B5A(e){switch(e.type){case"query":return rr.V44.RequestPropertyValue.query(v9i(e));case"body":return rr.V44.RequestPropertyValue.body(_Oc(e))}}function cAr(e){return{...e,property:_Oc(e.property)}}function _Oc(e){return{...e,valueType:uC(e.valueType)}}function v9i(e){return{...e,valueType:uC(e.valueType)}}function I5A(e){return{...e,shape:R5A(e.shape)}}function R5A(e){return rr.V45.http.SdkRequestShape._visit(e,{justRequestBody:t=>rr.V44.http.SdkRequestShape.justRequestBody(F5A(t)),wrapper:rr.V44.http.SdkRequestShape.wrapper,_other:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function F5A(e){switch(e.type){case"bytes":return rr.V44.http.SdkRequestBodyType.bytes(e);case"typeReference":return rr.V44.http.SdkRequestBodyType.typeReference({...e,requestBodyType:uC(e.requestBodyType)})}}function L5A(e){return rr.V45.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>rr.V44.http.HttpRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,valueType:uC(r.valueType)}))}),reference:t=>rr.V44.http.HttpRequestBody.reference({...t,requestBodyType:uC(t.requestBodyType)}),fileUpload:t=>rr.V44.http.HttpRequestBody.fileUpload({...t,properties:t.properties.map(r=>{switch(r.type){case"bodyProperty":return rr.V44.http.FileUploadRequestProperty.bodyProperty({...r,valueType:uC(r.valueType)});case"file":return rr.V44.http.FileUploadRequestProperty.file(U5A(r.value))}})}),bytes:t=>rr.V44.http.HttpRequestBody.bytes(t),_other:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function U5A(e){switch(e.type){case"file":return rr.V44.http.FileProperty.file(e);case"fileArray":return rr.V44.http.FileProperty.fileArray(e)}}function V5A(e){return{...e,type:e.type!=null?uC(e.type):void 0}}var zag={laterVersion:"v46",earlierVersion:"v45",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.21.0",[We.TYPESCRIPT_BROWSER_SDK]:"0.21.0",[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:"0.16.0",[We.JAVA]:Zr,[We.JAVA_MODEL]:"0.9.0",[We.JAVA_SDK]:"0.10.0",[We.JAVA_SPRING]:"0.9.0",[We.PYTHON_FASTAPI]:"0.10.1",[We.PYTHON_PYDANTIC]:"0.9.1",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"2.9.9",[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V45.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,types:Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,{...r,examples:W5A(r.examples)}])),services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{...r,endpoints:r.endpoints.map(n=>({...n,examples:H5A(n.examples)}))}])),websocketChannels:e.websocketChannels!=null?Object.fromEntries(Object.entries(e.websocketChannels).map(([t,r])=>[t,{...r,examples:$5A(r.examples)}])):void 0,errors:Object.fromEntries(Object.entries(e.errors).map(([t,r])=>[t,{...r,examples:r.examples.map(n=>({...n,shape:Oz(n.shape)}))}]))})};function Oz(e){return e.shape._visit({container:t=>({...e,shape:t._visit({list:r=>rr.V45.ExampleTypeReferenceShape.container(rr.V45.ExampleContainer.list(r.map(n=>Oz(n)))),set:r=>rr.V45.ExampleTypeReferenceShape.container(rr.V45.ExampleContainer.set(r.map(n=>Oz(n)))),map:r=>rr.V45.ExampleTypeReferenceShape.container(rr.V45.ExampleContainer.map(r.map(n=>({key:Oz(n.key),value:Oz(n.value)})))),optional:r=>rr.V45.ExampleTypeReferenceShape.container(rr.V45.ExampleContainer.optional(r!=null?Oz(r):void 0)),literal:r=>rr.V45.ExampleTypeReferenceShape.primitive(r._visit({string:n=>rr.V45.ExamplePrimitive.string(n),integer:n=>rr.V45.ExamplePrimitive.integer(n),double:n=>rr.V45.ExamplePrimitive.double(n),long:n=>rr.V45.ExamplePrimitive.long(n),boolean:n=>rr.V45.ExamplePrimitive.boolean(n),datetime:n=>rr.V45.ExamplePrimitive.datetime(n),date:n=>rr.V45.ExamplePrimitive.date(n),uuid:n=>rr.V45.ExamplePrimitive.uuid(n),_other:n=>{throw new Error(`Unexpected value: ${JSON.stringify(n)}`)}})),_other:r=>{throw new Error(`Unexpected value: ${JSON.stringify(r)}`)}})}),named:t=>({...e,shape:rr.V45.ExampleTypeReferenceShape.named({...t,shape:Bag(t.shape)})}),primitive:t=>({...e,shape:rr.V45.ExampleTypeReferenceShape.primitive(t._visit({string:r=>rr.V45.ExamplePrimitive.string(r),integer:r=>rr.V45.ExamplePrimitive.integer(r),double:r=>rr.V45.ExamplePrimitive.double(r),long:r=>rr.V45.ExamplePrimitive.long(r),boolean:r=>rr.V45.ExamplePrimitive.boolean(r),datetime:r=>rr.V45.ExamplePrimitive.datetime(r),date:r=>rr.V45.ExamplePrimitive.date(r),uuid:r=>rr.V45.ExamplePrimitive.uuid(r),_other:r=>{throw new Error(`Unexpected value: ${JSON.stringify(r)}`)}}))}),unknown:t=>({...e,shape:rr.V45.ExampleTypeReferenceShape.unknown(t)}),_other:t=>{throw new Error(`Unexpected value: ${JSON.stringify(t)}`)}})}function Nag(e){return{...e,properties:e.properties.map(t=>({...t,value:Oz(t.value)}))}}function Bag(e){return e.type==="alias"?rr.V45.ExampleTypeShape.alias({value:Oz(e.value)}):e.type==="object"?rr.V45.ExampleTypeShape.object(Nag(e)):e.type==="union"?rr.V45.ExampleTypeShape.union({...e,singleUnionType:{...e.singleUnionType,shape:e.singleUnionType.shape._visit({samePropertiesAsObject:t=>rr.V45.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...t,object:Nag(t.object)}),singleProperty:t=>rr.V45.ExampleSingleUnionTypeProperties.singleProperty(Oz(t)),noProperties:()=>rr.V45.ExampleSingleUnionTypeProperties.noProperties(),_other:t=>{throw new Error(`Unexpected value: ${JSON.stringify(t)}`)}})}}):e.type==="undiscriminatedUnion"?rr.V45.ExampleTypeShape.undiscriminatedUnion({...e,singleUnionType:Oz(e.singleUnionType)}):rr.V45.ExampleTypeShape.enum(e)}function W5A(e){return e.map(t=>({...t,shape:Bag(t.shape)}))}function WCo(e){return e.map(t=>({...t,value:Oz(t.value)}))}function hOc(e){return e.map(t=>({...t,value:Oz(t.value)}))}function Iag(e){return e.map(t=>({...t,value:Oz(t.value)}))}function H5A(e){return e.map(t=>{var n;let r={...t,rootPathParameters:WCo(t.rootPathParameters),servicePathParameters:WCo(t.servicePathParameters),endpointPathParameters:WCo(t.endpointPathParameters),serviceHeaders:hOc(t.serviceHeaders),endpointHeaders:hOc(t.endpointHeaders),queryParameters:Iag(t.queryParameters),request:(n=t.request)==null?void 0:n._visit({inlinedRequestBody:i=>rr.V45.ExampleRequestBody.inlinedRequestBody({...i,properties:i.properties.map(a=>({...a,value:Oz(a.value)}))}),reference:i=>rr.V45.ExampleRequestBody.reference(Oz(i)),_other:i=>{throw new Error(`Unexpected value: ${JSON.stringify(i)}`)}}),response:t.response._visit({ok:i=>rr.V45.ExampleResponse.ok(i._visit({body:a=>rr.V45.ExampleEndpointSuccessResponse.body(a!=null?Oz(a):void 0),stream:a=>rr.V45.ExampleEndpointSuccessResponse.stream(a.map(Oz)),sse:a=>rr.V45.ExampleEndpointSuccessResponse.sse(a.map(u=>({...u,data:Oz(u.data)}))),_other:a=>{throw new Error(`Unexpected value: ${JSON.stringify(a)}`)}})),error:i=>rr.V45.ExampleResponse.error({...i,body:i.body!=null?Oz(i.body):void 0}),_other:i=>{throw new Error(`Unexpected value: ${JSON.stringify(i)}`)}})};return t._visit({userProvided:()=>rr.V45.HttpEndpointExample.userProvided(r),generated:()=>rr.V45.HttpEndpointExample.generated(r),_other:i=>{throw new Error(`Unexpected value: ${JSON.stringify(i)}`)}})})}function $5A(e){return e.map(t=>({...t,pathParameters:WCo(t.pathParameters),headers:hOc(t.headers),queryParameters:Iag(t.queryParameters),messages:t.messages.map(r=>({...r,body:r.body._visit({inlinedBody:n=>rr.V45.ExampleWebSocketMessageBody.inlinedBody({...n,properties:n.properties.map(i=>({...i,value:Oz(i.value)}))}),reference:n=>rr.V45.ExampleWebSocketMessageBody.reference(Oz(n)),_other:n=>{throw new Error(`Unexpected value: ${JSON.stringify(n)}`)}})}))}))}var Rag={laterVersion:"v47",earlierVersion:"v46",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V46.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>{let n=r.endpoints.map(i=>{let{autogeneratedExamples:a,userSpecifiedExamples:u,...f}=i;return{...f,autogeneratedExamples:void 0,userSpecifiedExamples:void 0,examples:[...i.userSpecifiedExamples.map(c=>{if(c.example!=null)return rr.V46.HttpEndpointExample.userProvided({...c.example,codeSamples:c.codeSamples})}).filter(FS),...i.autogeneratedExamples.map(c=>rr.V46.HttpEndpointExample.generated({...c.example,codeSamples:void 0}))]}});return[t,{...r,endpoints:n}]}))})};var Fag={laterVersion:"v48",earlierVersion:"v47",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.29.0",[We.TYPESCRIPT_BROWSER_SDK]:"0.29.0",[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:"0.17.0",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V47.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=Object.fromEntries(Object.entries(e.services).map(([r,n])=>{let i=n.endpoints.map(a=>({...a,pagination:a.pagination!=null?G5A(a.pagination):void 0}));return[r,{...n,endpoints:i}]}));return{...e,sdkConfig:{...e.sdkConfig,hasPaginatedEndpoints:J5A(t)},services:t}}};function J5A(e){for(let t of Object.values(e))for(let r of t.endpoints)if(r.pagination!=null)return!0;return!1}function G5A(e){switch(e.type){case"cursor":{let t=K5A(e);return t!=null?rr.V47.Pagination.cursor(t):void 0}case"offset":{let t=Y5A(e);return t!=null?rr.V47.Pagination.offset(t):void 0}default:fl(e)}}function K5A(e){let t=Lag(e.page);if(t!=null)return{...e,page:t}}function Y5A(e){if(e.step!=null)return;let t=Lag(e.page);if(t!=null)return{...e,page:t}}function Lag(e){switch(e.property.type){case"query":return e.property}}var Uag={laterVersion:"v49",earlierVersion:"v48",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:"0.11.0-rc0",[We.PYTHON_PYDANTIC]:"0.10.0-rc0",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:"2.11.0-rc0",[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V48.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=Object.fromEntries(Object.entries(e.services).map(([r,n])=>{let i=n.endpoints.flatMap(a=>{var d,c,o;let u;return((d=a.response)==null?void 0:d.body)!=null&&(u=(c=a.response.body)==null?void 0:c._visit({json:l=>rr.V48.HttpResponseBody.json({...l}),fileDownload:l=>rr.V48.HttpResponseBody.fileDownload({...l}),text:l=>rr.V48.HttpResponseBody.text({...l}),streaming:l=>rr.V48.HttpResponseBody.streaming({...l}),streamParameter:()=>{},_other:()=>{}}),u==null)?[]:{...a,response:a.response==null?void 0:{statusCode:(o=a.response)==null?void 0:o.statusCode,body:u}}});return[r,{...n,endpoints:i}]}));return{...e,services:t}}};function dNt(e){return{originalValue:e.originalName,camelCase:e.camelCase.unsafeName,pascalCase:e.pascalCase.unsafeName,snakeCase:e.snakeCase.unsafeName,screamingSnakeCase:e.screamingSnakeCase.unsafeName}}function tEe(e){return{...dNt(e.name),wireValue:e.wireValue}}function wF(e){return{safeName:{originalValue:e.originalName,camelCase:e.camelCase.safeName,pascalCase:e.pascalCase.safeName,snakeCase:e.snakeCase.safeName,screamingSnakeCase:e.screamingSnakeCase.safeName},unsafeName:{originalValue:e.originalName,camelCase:e.camelCase.unsafeName,pascalCase:e.pascalCase.unsafeName,snakeCase:e.snakeCase.unsafeName,screamingSnakeCase:e.screamingSnakeCase.unsafeName}}}function DF(e){return{wireValue:e.wireValue,name:wF(e.name)}}function Akn(e){return rr.V5.types.ContainerType._visit(e,{list:t=>rr.V4.types.ContainerType.list(yN(t)),set:t=>rr.V4.types.ContainerType.set(yN(t)),map:({keyType:t,valueType:r})=>rr.V4.types.ContainerType.map({keyType:yN(t),valueType:yN(r)}),optional:t=>rr.V4.types.ContainerType.optional(yN(t)),literal:t=>rr.V5.types.Literal._visit(t,{string:r=>rr.V4.types.ContainerType.literal(rr.V4.types.Literal.string(r)),_unknown:()=>{throw new Error("Unknown Literal: "+t.type)}}),_unknown:()=>{throw new Error("Unknown ContainerType: "+e._type)}})}function k1n(e){return e.map(t=>dNt(t))}function ejn(e){return e.map(t=>wF(t))}function AU(e){return{fernFilepath:k1n(e.fernFilepath),fernFilepathV2:ejn(e.fernFilepath),name:e.name.originalName,nameV2:dNt(e.name),nameV3:wF(e.name)}}function yN(e){return rr.V5.types.TypeReference._visit(e,{named:t=>rr.V4.types.TypeReference.named(AU(t)),container:t=>rr.V4.types.TypeReference.container(Akn(t)),primitive:t=>rr.V4.types.TypeReference.primitive(t),unknown:rr.V4.types.TypeReference.unknown,_unknown:()=>{throw new Error("Unkonwn TypeReference: "+e._type)}})}function tjn(e){return{name:tEe(e.name),nameV2:DF(e.name),valueType:yN(e.valueType),availability:e.availability,docs:e.docs}}function Vag(e){return{docs:e.docs,requirement:e.requirement,schemes:e.schemes.map(t=>X5A(t))}}function X5A(e){return rr.V5.auth.AuthScheme._visit(e,{basic:rr.V4.auth.AuthScheme.basic,bearer:rr.V4.auth.AuthScheme.bearer,header:t=>rr.V4.auth.AuthScheme.header(tjn(t)),_unknown:()=>{throw new Error("Unknown AuthScheme: "+e._type)}})}function Wag(e){return{docs:e.docs,id:e.id,url:e.url,name:wF(e.name)}}function Hag({errorDeclaration:e,errorDiscriminationStrategy:t,typeReferenceResolver:r}){let n=e.type!=null?rr.V4.types.Type.alias({aliasOf:yN(e.type),resolvedType:r.resolveTypeReference(e.type)}):void 0;return{docs:e.docs,name:{name:e.name.name.originalName,nameV2:dNt(e.name.name),nameV3:wF(e.name.name),fernFilepath:k1n(e.name.fernFilepath),fernFilepathV2:ejn(e.name.fernFilepath)},discriminantValueV2:DF(e.discriminantValue),discriminantValueV3:rr.V5.ir.ErrorDiscriminationStrategy._visit(t,{statusCode:rr.V4.errors.ErrorDeclarationDiscriminantValue.statusCode,property:i=>rr.V4.errors.ErrorDeclarationDiscriminantValue.property(DF(i.contentProperty)),_unknown:()=>{throw new Error("Unknown ErrorDiscriminationStrategy: "+t.type)}}),discriminantValueV4:DF(e.discriminantValue),type:n??rr.V4.types.Type.alias({aliasOf:rr.V4.types.TypeReference.void(),resolvedType:rr.V4.types.ResolvedTypeReference.void()}),typeV2:n,typeV3:e.type!=null?yN(e.type):e.type,http:{statusCode:e.statusCode},statusCode:e.statusCode}}function bee(e){return{jsonExample:e.jsonExample,shape:$ag(e.shape)}}function $ag(e){return rr.V5.types.ExampleTypeReferenceShape._visit(e,{primitive:rr.V4.types.ExampleTypeReferenceShape.primitive,container:t=>rr.V4.types.ExampleTypeReferenceShape.container(Z5A(t)),unknown:rr.V4.types.ExampleTypeReferenceShape.unknown,named:t=>rr.V4.types.ExampleTypeReferenceShape.named(Q5A(t)),_unknown:()=>{throw new Error("Unknown ExampleTypeReferenceShape: "+e.type)}})}function Q5A(e){return{typeName:AU(e.typeName),shape:HCo(e.shape)}}function Z5A(e){return rr.V5.types.ExampleContainer._visit(e,{list:t=>rr.V4.types.ExampleContainer.list(t.map(r=>bee(r))),set:t=>rr.V4.types.ExampleContainer.set(t.map(r=>bee(r))),optional:t=>rr.V4.types.ExampleContainer.optional(t!=null?bee(t):void 0),map:t=>rr.V4.types.ExampleContainer.map(t.map(r=>({key:bee(r.key),value:bee(r.value)}))),_unknown:()=>{throw new Error("Unknown ExampleContainer: "+e.type)}})}function HCo(e){return rr.V5.types.ExampleTypeShape._visit(e,{alias:t=>rr.V4.types.ExampleTypeShape.alias({value:bee(t.value)}),object:t=>rr.V4.types.ExampleTypeShape.object({properties:t.properties.map(r=>({wireKey:r.wireKey,value:bee(r.value),originalTypeDeclaration:AU(r.originalTypeDeclaration)}))}),union:t=>rr.V4.types.ExampleTypeShape.union({wireDiscriminantValue:t.wireDiscriminantValue,properties:rr.V5.types.ExampleSingleUnionTypeProperties._visit(t.properties,{samePropertiesAsObject:r=>rr.V4.types.ExampleSingleUnionTypeProperties.samePropertiesAsObject({typeName:AU(r.typeName),shape:HCo(r.shape)}),singleProperty:r=>rr.V4.types.ExampleSingleUnionTypeProperties.singleProperty({jsonExample:r.jsonExample,shape:$ag(r.shape)}),noProperties:rr.V4.types.ExampleSingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown ExampleSingleUnionTypeProperties: "+t.properties.type)}})}),enum:t=>rr.V4.types.ExampleTypeShape.enum({wireValue:t.wireValue}),_unknown:()=>{throw new Error("Unknown ExampleTypeShape: "+e.type)}})}function Kag({service:e,errorResolver:t}){return{docs:e.docs,availability:e.availability,displayName:e.displayName,name:k5A(e.name),basePath:ezA(e.basePath),basePathV2:e.basePath,endpoints:e.endpoints.map(r=>tzA({endpoint:r,errorResolver:t})),headers:e.headers.map(r=>tjn(r)),pathParameters:e.pathParameters.map(r=>Yag(r))}}function k5A(e){return{name:e.name.pascalCase.unsafeName,fernFilepath:k1n(e.fernFilepath),fernFilepathV2:ejn(e.fernFilepath)}}function ezA(e){return e.parts.reduce((t,r)=>t+`{${r.pathParameter}}`+r.tail,e.head)}function tzA({endpoint:e,errorResolver:t}){return{docs:e.docs,availability:e.availability,id:e.name.originalName,name:dNt(e.name),nameV2:wF(e.name),displayName:e.displayName,method:e.method,headers:e.headers.map(r=>tjn(r)),path:e.path,pathParameters:e.pathParameters.map(r=>Yag(r)),queryParameters:e.queryParameters.map(r=>rzA(r)),requestBody:e.requestBody!=null?nzA(e.requestBody):void 0,sdkRequest:e.sdkRequest!=null?izA(e.sdkRequest):void 0,response:azA(e.response),errors:e.errors.map(r=>ozA(r)),errorsV2:uzA({responseErrors:e.errors,errorResolver:t}),auth:e.auth,examples:e.examples.map(r=>lzA(r))}}function Yag(e){return{docs:e.docs,availability:e.availability,name:dNt(e.name),nameV2:wF(e.name),valueType:yN(e.valueType)}}function rzA(e){return{docs:e.docs,availability:e.availability,name:tEe(e.name),nameV2:DF(e.name),valueType:yN(e.valueType),allowMultiple:e.allowMultiple}}function nzA(e){return rr.V5.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>rr.V4.services.http.HttpRequestBody.inlinedRequestBody({name:wF(t.name),extends:t.extends.map(r=>AU(r)),properties:t.properties.map(r=>({docs:r.docs,name:DF(r.name),valueType:yN(r.valueType)}))}),reference:t=>rr.V4.services.http.HttpRequestBody.reference({docs:t.docs,requestBodyType:yN(t.requestBodyType)}),_unknown:()=>{throw new Error("Unknown HttpRequestBody type: "+e.type)}})}function izA(e){return{requestParameterName:wF(e.requestParameterName),shape:rr.V5.http.SdkRequestShape._visit(e.shape,{justRequestBody:t=>rr.V4.services.http.SdkRequestShape.justRequestBody({docs:t.docs,requestBodyType:yN(t.requestBodyType)}),wrapper:t=>rr.V4.services.http.SdkRequestShape.wrapper({wrapperName:wF(t.wrapperName),bodyKey:wF(t.bodyKey)}),_unknown:()=>{throw new Error("Unknown SdkRequestShape type: "+e.shape.type)}})}}function azA(e){let t=e.type!=null?yN(e.type):void 0;return{docs:e.docs,type:t??rr.V4.types.TypeReference.void(),typeV2:t}}function ozA(e){return{docs:e.docs,error:yOc(e.error)}}function uzA({responseErrors:e,errorResolver:t}){return{discriminant:{originalValue:"errorName",camelCase:"errorName",snakeCase:"error_name",pascalCase:"ErrorName",screamingSnakeCase:"ERROR_NAME",wireValue:"errorName"},types:e.map(r=>szA({responseError:r,errorResolver:t}))}}function szA({responseError:e,errorResolver:t}){let r=t.getDeclaration(e.error);return{docs:e.docs,discriminantValue:tEe(r.discriminantValue),shape:czA({responseError:e,declaration:r})}}function czA({responseError:e,declaration:t}){return t.type==null?rr.V4.services.commons.ResponseErrorShape.noProperties():rr.V4.services.commons.ResponseErrorShape.singleProperty({name:{originalValue:"content",camelCase:"content",snakeCase:"content",pascalCase:"Content",screamingSnakeCase:"CONTENT",wireValue:"content"},error:yOc(e.error)})}function yOc(e){return{name:e.name.originalName,nameV2:dNt(e.name),nameV3:wF(e.name),fernFilepath:k1n(e.fernFilepath),fernFilepathV2:ejn(e.fernFilepath)}}function lzA(e){var t;return{docs:e.docs,name:(t=e.name)==null?void 0:t.originalName,servicePathParameters:e.servicePathParameters.map(r=>Jag(r)),endpointPathParameters:e.endpointPathParameters.map(r=>Jag(r)),serviceHeaders:e.serviceHeaders.map(r=>Gag(r)),endpointHeaders:e.endpointHeaders.map(r=>Gag(r)),queryParameters:e.queryParameters.map(r=>fzA(r)),request:e.request!=null?dzA(e.request):void 0,response:_zA(e.response)}}function Jag(e){return{key:e.key,value:bee(e.value)}}function Gag(e){return{wireKey:e.wireKey,value:bee(e.value)}}function fzA(e){return{wireKey:e.wireKey,value:bee(e.value)}}function dzA(e){return rr.V5.http.ExampleRequestBody._visit(e,{inlinedRequestBody:t=>rr.V4.services.http.ExampleRequestBody.inlinedRequestBody({jsonExample:t.jsonExample,properties:t.properties.map(r=>pzA(r))}),reference:t=>rr.V4.services.http.ExampleRequestBody.reference(bee(t)),_unknown:()=>{throw new Error("Unknown ExampleRequestBody: "+e.type)}})}function pzA(e){return{wireKey:e.wireKey,value:bee(e.value),originalTypeDeclaration:e.originalTypeDeclaration!=null?AU(e.originalTypeDeclaration):void 0}}function _zA(e){return rr.V5.http.ExampleResponse._visit(e,{ok:t=>rr.V4.services.http.ExampleResponse.ok({body:t.body!=null?bee(t.body):void 0}),error:t=>rr.V4.services.http.ExampleResponse.error({error:yOc(t.error),body:t.body!=null?bee(t.body):void 0}),_unknown:()=>{throw new Error("Unknown ExampleResponse: "+e.type)}})}function Xag(e){return{docs:e.docs,availability:e.availability,name:AU(e.name),shape:hzA(e.shape),examples:e.examples.map(t=>yzA(t)),referencedTypes:e.referencedTypes.map(t=>AU(t))}}function hzA(e){return rr.V5.types.Type._visit(e,{alias:({aliasOf:t,resolvedType:r})=>rr.V4.types.Type.alias({aliasOf:yN(t),resolvedType:vzA(r)}),enum:t=>rr.V4.types.Type.enum({values:t.values.map(r=>({docs:r.docs,availability:r.availability,name:tEe(r.name),nameV2:DF(r.name),value:r.name.wireValue}))}),object:t=>rr.V4.types.Type.object({extends:t.extends.map(r=>AU(r)),properties:t.properties.map(r=>({docs:r.docs,availability:r.availability,name:tEe(r.name),nameV2:DF(r.name),valueType:yN(r.valueType)}))}),union:t=>rr.V4.types.Type.union({discriminant:t.discriminant.wireValue,discriminantV2:tEe(t.discriminant),discriminantV3:DF(t.discriminant),types:t.types.map(r=>({docs:r.docs,discriminantValue:tEe(r.discriminantValue),discriminantValueV2:DF(r.discriminantValue),valueType:rr.V5.types.SingleUnionTypeProperties._visit(r.shape,{samePropertiesAsObject:n=>rr.V4.types.TypeReference.named(AU(n)),singleProperty:n=>yN(n.type),noProperties:rr.V4.types.TypeReference.void,_unknown:()=>{throw new Error("Unknown SingleUnionTypeProperties: "+r.shape._type)}}),shape:rr.V5.types.SingleUnionTypeProperties._visit(r.shape,{samePropertiesAsObject:n=>rr.V4.types.SingleUnionTypeProperties.samePropertiesAsObject(AU(n)),singleProperty:n=>rr.V4.types.SingleUnionTypeProperties.singleProperty({name:tEe(n.name),nameV2:DF(n.name),type:yN(n.type)}),noProperties:rr.V4.types.SingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown SingleUnionTypeProperties: "+r.shape._type)}})}))}),_unknown:()=>{throw new Error("Unknown shape: "+e._type)}})}function yzA(e){var t;return{docs:e.docs,jsonExample:e.jsonExample,name:(t=e.name)==null?void 0:t.originalName,shape:HCo(e.shape)}}function vzA(e){return rr.V5.types.ResolvedTypeReference._visit(e,{named:t=>rr.V4.types.ResolvedTypeReference.named({name:AU(t.name),shape:bzA(t.shape)}),container:t=>rr.V4.types.ResolvedTypeReference.container(Akn(t)),primitive:rr.V4.types.ResolvedTypeReference.primitive,unknown:rr.V4.types.ResolvedTypeReference.unknown,_unknown:()=>{throw new Error("Unknown ResolvedTypeReference: "+e._type)}})}function bzA(e){return rr.V5.types.ShapeType._visit(e,{enum:()=>rr.V5.types.ShapeType.Enum,object:()=>rr.V5.types.ShapeType.Object,union:()=>rr.V5.types.ShapeType.Union,_unknown:()=>{throw new Error("Unknown ShapeType: "+e)}})}var $Co=class{errors;constructor(t){this.errors=t.errors.reduce((r,n)=>({...r,[Qag(n.name)]:n}),{})}getDeclaration(t){let r=Qag(t),n=this.errors[r];if(n==null)throw new Error("Error does not exist: "+r);return n}};function Qag(e){return`${e.fernFilepath.join("/")}:${e.name.originalName}`}var JCo=class{types;constructor(t){this.types=t.types.reduce((r,n)=>({...r,[Zag(n.name)]:n}),{})}resolveTypeReference(t){return rr.V5.types.TypeReference._visit(t,{container:r=>rr.V4.types.ResolvedTypeReference.container(Akn(r)),named:r=>{let n=this.getTypeDeclaration(r);return n.shape._type==="alias"?this.resolveTypeReference(n.shape.aliasOf):rr.V4.types.ResolvedTypeReference.named({name:AU(r),shape:gzA(n.shape._type)})},primitive:rr.V4.types.ResolvedTypeReference.primitive,unknown:rr.V4.types.ResolvedTypeReference.unknown,_unknown:()=>{throw new Error("Unknown TypeReference: "+t._type)}})}getTypeDeclaration(t){let r=Zag(t),n=this.types[r];if(n==null)throw new Error("Type does not exist: "+n);return n}};function Zag(e){return`${e.fernFilepath.join("/")}:${e.name.originalName}`}function gzA(e){switch(e){case"object":return rr.V4.types.ShapeType.Object;case"union":return rr.V4.types.ShapeType.Union;case"enum":return rr.V4.types.ShapeType.Enum;default:fl(e)}}var kag={laterVersion:"v5",earlierVersion:"v4",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.0.257-2-g46fe4ff",[We.TYPESCRIPT_EXPRESS]:"0.0.264",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:"0.0.33-9-gf683b5e",[We.PYTHON_PYDANTIC]:"0.0.33-9-gf683b5e",[We.OPENAPI]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:fa,[We.STOPLIGHT]:fa,[We.OPENAPI_PYTHON_CLIENT]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>{let t=new JCo(e),r=new $Co(e);return{apiName:e.apiName.originalName,apiDisplayName:e.apiDisplayName,apiDocs:e.apiDocs,auth:Vag(e.auth),headers:e.headers.map(n=>tjn(n)),types:e.types.map(n=>Xag(n)),services:{http:e.services.map(n=>Kag({service:n,errorResolver:r})),websocket:[]},errors:e.errors.map(n=>Hag({errorDeclaration:n,errorDiscriminationStrategy:e.errorDiscriminationStrategy,typeReferenceResolver:t})),constants:{errorDiscriminant:"_error",errorInstanceIdKey:"_errorInstanceId",unknownErrorDiscriminantValue:"_unknown"},constantsV2:{errors:{errorInstanceIdKey:tEe(e.constants.errorInstanceIdKey),errorDiscriminant:{originalValue:"error",camelCase:"error",snakeCase:"error",pascalCase:"Error",screamingSnakeCase:"ERROR",wireValue:"error"},errorContentKey:{originalValue:"content",camelCase:"content",snakeCase:"content",pascalCase:"Content",screamingSnakeCase:"CONTENT",wireValue:"content"}},errorsV2:{errorInstanceIdKey:DF(e.constants.errorInstanceIdKey),errorDiscriminant:{name:{unsafeName:{originalValue:"error",camelCase:"error",snakeCase:"error",pascalCase:"Error",screamingSnakeCase:"ERROR"},safeName:{originalValue:"error",camelCase:"error",snakeCase:"error",pascalCase:"Error",screamingSnakeCase:"ERROR"}},wireValue:"error"},errorContentKey:{name:{unsafeName:{originalValue:"content",camelCase:"content",snakeCase:"content",pascalCase:"Content",screamingSnakeCase:"CONTENT"},safeName:{originalValue:"content",camelCase:"content",snakeCase:"content",pascalCase:"Content",screamingSnakeCase:"CONTENT"}},wireValue:"content"}}},defaultEnvironment:e.defaultEnvironment,environments:e.environments.map(n=>Wag(n)),errorDiscriminant:e.errorDiscriminationStrategy.type==="property"?wF(e.errorDiscriminationStrategy.discriminant.name):void 0,errorDiscriminationStrategy:rr.V5.ir.ErrorDiscriminationStrategy._visit(e.errorDiscriminationStrategy,{statusCode:rr.V4.ir.ErrorDiscriminationStrategy.statusCode,property:n=>rr.V4.ir.ErrorDiscriminationStrategy.property({discriminant:DF(n.discriminant),contentProperty:DF(n.contentProperty)}),_unknown:()=>{throw new Error("Unknown ErrorDiscriminationStrategy: "+e.errorDiscriminationStrategy.type)}}),sdkConfig:e.sdkConfig}}};var eog={laterVersion:"v50",earlierVersion:"v49",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.34.0",[We.TYPESCRIPT_BROWSER_SDK]:"0.34.0",[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:"0.17.2",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:"0.0.0",[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V49.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=sy(e.types,r=>({...r,shape:rr.V50.types.Type._visit(r.shape,{union:n=>rr.V49.types.Type.union({...n,baseProperties:n.baseProperties.map(i=>({...i,valueType:sC(i.valueType)})),types:n.types.map(i=>qzA(i))}),enum:rr.V49.types.Type.enum,object:n=>rr.V49.types.Type.object({...n,properties:n.properties.map(i=>({...i,valueType:sC(i.valueType)}))}),alias:n=>rr.V49.types.Type.alias({aliasOf:sC(n.aliasOf),resolvedType:AzA(n.resolvedType)}),undiscriminatedUnion:n=>rr.V49.types.Type.undiscriminatedUnion(NzA(n)),_other:()=>{throw new Error("Encountered unknown shape")}})}));return{...e,auth:SzA(e.auth),headers:e.headers.map(r=>Nkn(r)),idempotencyHeaders:e.idempotencyHeaders.map(r=>Nkn(r)),types:t,services:sy(e.services,r=>zzA(r)),errors:sy(e.errors,r=>QzA(r)),webhookGroups:sy(e.webhookGroups,r=>jzA(r)),websocketChannels:sy(e.websocketChannels,r=>mzA(r)),pathParameters:e.pathParameters.map(r=>b9i(r)),variables:e.variables.map(r=>BzA(r))}}};function mzA(e){return{...e,headers:e.headers.map(t=>Nkn(t)),queryParameters:e.queryParameters.map(t=>bOc(t)),pathParameters:e.pathParameters.map(t=>b9i(t)),messages:e.messages.map(t=>OzA(t))}}function OzA(e){return{...e,body:PzA(e.body)}}function PzA(e){switch(e.type){case"inlinedBody":return rr.V49.websocket.WebSocketMessageBody.inlinedBody({...e,properties:e.properties.map(t=>({...t,valueType:sC(t.valueType)}))});case"reference":return rr.V49.websocket.WebSocketMessageBody.reference({...e,bodyType:sC(e.bodyType)})}}function jzA(e){return e.map(t=>wzA(t))}function wzA(e){return{...e,headers:e.headers.map(t=>Nkn(t)),payload:DzA(e.payload)}}function DzA(e){switch(e.type){case"reference":return rr.V49.webhooks.WebhookPayload.reference({...e,payloadType:sC(e.payloadType)});case"inlinedPayload":return rr.V49.webhooks.WebhookPayload.inlinedPayload({...e,properties:e.properties.map(t=>({...t,valueType:sC(t.valueType)}))})}}function SzA(e){return{...e,schemes:e.schemes.map(t=>{switch(t.type){case"basic":return rr.V49.auth.AuthScheme.basic(t);case"bearer":return rr.V49.auth.AuthScheme.bearer(t);case"header":return rr.V49.auth.AuthScheme.header(EzA(t));case"oauth":return rr.V49.auth.AuthScheme.oauth(MzA(t))}})}}function EzA(e){return{...e,valueType:sC(e.valueType)}}function MzA(e){return{...e,configuration:rr.V49.auth.OAuthConfiguration.clientCredentials({...e.configuration,tokenEndpoint:xzA(e.configuration.tokenEndpoint),refreshEndpoint:e.configuration.refreshEndpoint!=null?TzA(e.configuration.refreshEndpoint):void 0})}}function xzA(e){return{...e,requestProperties:{clientId:KJr(e.requestProperties.clientId),clientSecret:KJr(e.requestProperties.clientSecret),scopes:e.requestProperties.scopes!=null?KJr(e.requestProperties.scopes):void 0},responseProperties:{accessToken:lAr(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?lAr(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?lAr(e.responseProperties.refreshToken):void 0}}}function TzA(e){return{...e,requestProperties:{refreshToken:KJr(e.requestProperties.refreshToken)},responseProperties:{accessToken:lAr(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?lAr(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?lAr(e.responseProperties.refreshToken):void 0}}}function Nkn(e){return{...e,valueType:sC(e.valueType)}}function sC(e){return rr.V50.types.TypeReference._visit(e,{container:t=>rr.V49.types.TypeReference.container(tog(t)),primitive:t=>{var r,n,i;return((r=t.v2)==null?void 0:r.type)==="integer"?rr.V49.types.TypeReference.primitive({v1:t.v1,v2:rr.V49.types.PrimitiveTypeV2.integer(t.v2)}):((n=t.v2)==null?void 0:n.type)==="double"?rr.V49.types.TypeReference.primitive({v1:t.v1,v2:rr.V49.types.PrimitiveTypeV2.double(t.v2)}):((i=t.v2)==null?void 0:i.type)==="string"?rr.V49.types.TypeReference.primitive({v1:t.v1,v2:rr.V49.types.PrimitiveTypeV2.string(t.v2)}):rr.V49.types.TypeReference.primitive({v1:t.v1,v2:void 0})},named:rr.V49.types.TypeReference.named,unknown:rr.V49.types.TypeReference.unknown,_other:()=>{throw new Error("Unknown type reference: "+e.type)}})}function tog(e){return rr.V50.types.ContainerType._visit(e,{list:t=>rr.V49.types.ContainerType.list(sC(t)),optional:t=>rr.V49.types.ContainerType.optional(sC(t)),set:t=>rr.V49.types.ContainerType.set(sC(t)),map:({keyType:t,valueType:r})=>rr.V49.types.ContainerType.map({keyType:sC(t),valueType:sC(r)}),literal:rr.V49.types.ContainerType.literal,_other:()=>{throw new Error("Unknown ContainerType: "+e.type)}})}function qzA(e){return{...e,shape:CzA(e.shape)}}function CzA(e){return rr.V50.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>rr.V49.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>rr.V49.types.SingleUnionTypeProperties.singleProperty({...t,type:sC(t.type)}),noProperties:rr.V49.types.SingleUnionTypeProperties.noProperties,_other:()=>{throw new Error(`Unknown SingleUnionTypeProperties: ${JSON.stringify(e)}`)}})}function AzA(e){return rr.V50.types.ResolvedTypeReference._visit(e,{container:t=>rr.V49.types.ResolvedTypeReference.container(tog(t)),named:rr.V49.types.ResolvedTypeReference.named,primitive:t=>{var r,n,i;return((r=t.v2)==null?void 0:r.type)==="integer"?rr.V49.types.ResolvedTypeReference.primitive({v1:t.v1,v2:rr.V49.types.PrimitiveTypeV2.integer(t.v2)}):((n=t.v2)==null?void 0:n.type)==="double"?rr.V49.types.ResolvedTypeReference.primitive({v1:t.v1,v2:rr.V49.types.PrimitiveTypeV2.double(t.v2)}):((i=t.v2)==null?void 0:i.type)==="string"?rr.V49.types.ResolvedTypeReference.primitive({v1:t.v1,v2:rr.V49.types.PrimitiveTypeV2.string(t.v2)}):rr.V49.types.ResolvedTypeReference.primitive({v1:t.v1,v2:void 0})},unknown:rr.V49.types.ResolvedTypeReference.unknown,_other:()=>{throw new Error("Unknown ResolvedTypeReference: "+e.type)}})}function NzA(e){return{members:e.members.map(t=>({...t,type:sC(t.type)}))}}function zzA(e){return{...e,pathParameters:e.pathParameters.map(t=>b9i(t)),headers:e.headers.map(t=>Nkn(t)),endpoints:e.endpoints.map(t=>IzA(t))}}function b9i(e){return{...e,valueType:sC(e.valueType)}}function BzA(e){return{...e,type:sC(e.type)}}function IzA(e){return{...e,pagination:e.pagination!=null?VzA(e.pagination):void 0,allPathParameters:e.allPathParameters.map(t=>b9i(t)),pathParameters:e.pathParameters.map(t=>b9i(t)),sdkRequest:e.sdkRequest!=null?JzA(e.sdkRequest):void 0,requestBody:e.requestBody!=null?YzA(e.requestBody):void 0,response:e.response!=null?RzA(e.response):void 0,headers:e.headers.map(t=>Nkn(t)),queryParameters:e.queryParameters.map(t=>bOc(t))}}function RzA(e){return{...e,body:e.body!=null?FzA(e.body):void 0}}function FzA(e){switch(e.type){case"json":return rr.V49.http.HttpResponseBody.json(rog(e.value));case"fileDownload":return rr.V49.http.HttpResponseBody.fileDownload(e);case"text":return rr.V49.http.HttpResponseBody.text(e);case"streaming":return rr.V49.http.HttpResponseBody.streaming(nog(e.value));case"streamParameter":return rr.V49.http.HttpResponseBody.streamParameter(UzA(e))}}function rog(e){switch(e.type){case"response":return rr.V49.http.JsonResponse.response({...e,responseBodyType:sC(e.responseBodyType)});case"nestedPropertyAsResponse":return rr.V49.http.JsonResponse.nestedPropertyAsResponse({...e,responseBodyType:sC(e.responseBodyType),responseProperty:e.responseProperty!=null?vOc(e.responseProperty):void 0})}}function nog(e){switch(e.type){case"json":return rr.V49.http.StreamingResponse.json({...e,payload:sC(e.payload)});case"text":return rr.V49.http.StreamingResponse.text(e);case"sse":return rr.V49.http.StreamingResponse.sse({...e,payload:sC(e.payload)})}}function LzA(e){switch(e.type){case"json":return rr.V49.http.NonStreamHttpResponseBody.json(rog(e.value));case"text":return rr.V49.http.NonStreamHttpResponseBody.text(e);case"fileDownload":return rr.V49.http.NonStreamHttpResponseBody.fileDownload(e)}}function UzA(e){return{nonStreamResponse:LzA(e.nonStreamResponse),streamResponse:nog(e.streamResponse)}}function VzA(e){switch(e.type){case"cursor":return rr.V49.http.Pagination.cursor(WzA(e));case"offset":return rr.V49.http.Pagination.offset(HzA(e))}}function WzA(e){return{...e,page:KJr(e.page),next:lAr(e.next),results:lAr(e.results)}}function HzA(e){return{...e,page:KJr(e.page),results:lAr(e.results),step:e.step!=null?KJr(e.step):void 0}}function KJr(e){return{...e,property:$zA(e.property)}}function $zA(e){switch(e.type){case"query":return rr.V49.RequestPropertyValue.query(bOc(e));case"body":return rr.V49.RequestPropertyValue.body(vOc(e))}}function lAr(e){return{...e,property:vOc(e.property)}}function vOc(e){return{...e,valueType:sC(e.valueType)}}function bOc(e){return{...e,valueType:sC(e.valueType)}}function JzA(e){return{...e,streamParameter:e.streamParameter!=null?KJr(e.streamParameter):void 0,shape:GzA(e.shape)}}function GzA(e){return rr.V50.http.SdkRequestShape._visit(e,{justRequestBody:t=>rr.V49.http.SdkRequestShape.justRequestBody(KzA(t)),wrapper:rr.V49.http.SdkRequestShape.wrapper,_other:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function KzA(e){switch(e.type){case"bytes":return rr.V49.http.SdkRequestBodyType.bytes(e);case"typeReference":return rr.V49.http.SdkRequestBodyType.typeReference({...e,requestBodyType:sC(e.requestBodyType)})}}function YzA(e){return rr.V50.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>rr.V49.http.HttpRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,valueType:sC(r.valueType)}))}),reference:t=>rr.V49.http.HttpRequestBody.reference({...t,requestBodyType:sC(t.requestBodyType)}),fileUpload:t=>rr.V49.http.HttpRequestBody.fileUpload({...t,properties:t.properties.map(r=>{switch(r.type){case"bodyProperty":return rr.V49.http.FileUploadRequestProperty.bodyProperty({...r,valueType:sC(r.valueType)});case"file":return rr.V49.http.FileUploadRequestProperty.file(XzA(r.value))}})}),bytes:t=>rr.V49.http.HttpRequestBody.bytes(t),_other:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function XzA(e){switch(e.type){case"file":return rr.V49.http.FileProperty.file(e);case"fileArray":return rr.V49.http.FileProperty.fileArray(e)}}function QzA(e){return{...e,type:e.type!=null?sC(e.type):void 0}}var oog={laterVersion:"v51",earlierVersion:"v50",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:"0.1.2",[We.SWIFT_MODEL]:Zr,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V50.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=sy(e.types,r=>{let n=r.autogeneratedExamples.map(a=>iog(a)),i=r.userProvidedExamples.map(a=>iog(a));return{...r,examples:[...n,...i]}});return{...e,types:t,services:sy(e.services,r=>sBA(r)),errors:sy(e.errors,r=>pBA(r)),webhookGroups:sy(e.webhookGroups,r=>tBA(r)),websocketChannels:sy(e.websocketChannels,r=>ZzA(r))}}};function ZzA(e){return{...e,examples:e.examples.map(t=>kzA(t))}}function kzA(e){return{...e,pathParameters:e.pathParameters.map(t=>GCo(t)),headers:e.headers.map(t=>gOc(t)),queryParameters:e.queryParameters.map(t=>uog(t)),messages:e.messages.map(t=>({...t,body:eBA(t.body)}))}}function uog(e){return{...e,value:SF(e.value)}}function gOc(e){return{...e,value:SF(e.value)}}function GCo(e){return{...e,value:SF(e.value)}}function eBA(e){switch(e.type){case"inlinedBody":return rr.V50.ExampleWebSocketMessageBody.inlinedBody(sog(e));case"reference":return rr.V50.ExampleWebSocketMessageBody.reference(SF(e))}}function sog(e){return{...e,properties:e.properties.map(t=>({...t,value:SF(t.value)}))}}function tBA(e){return e.map(t=>{var r;return{...t,examples:(r=t.examples)==null?void 0:r.map(n=>({...n,payload:SF(n.payload)}))}})}function iog(e){return{...e,shape:cog(e.shape)}}function mOc(e){switch(e.type){case"primitive":return rr.V50.ExampleTypeReferenceShape.primitive({...e.primitive});case"container":return rr.V50.ExampleTypeReferenceShape.container(rBA(e));case"unknown":return rr.V50.ExampleTypeReferenceShape.unknown(e.unknown);case"named":return rr.V50.ExampleTypeReferenceShape.named({...e,typeName:e.typeName,shape:cog(e.shape)})}}function rBA(e){switch(e.container.type){case"list":return rr.V50.ExampleContainer.list(e.container.list.map(t=>SF(t)));case"set":return rr.V50.ExampleContainer.set(e.container.set.map(t=>SF(t)));case"optional":return rr.V50.ExampleContainer.optional(e.container.optional!=null?SF(e.container.optional):void 0);case"map":return rr.V50.ExampleContainer.map(e.container.map.map(t=>({key:SF(t.key),value:SF(t.value)})));case"literal":return rr.V50.ExampleContainer.literal(e.container.literal)}}function SF(e){return{...e,shape:mOc(e.shape)}}function cog(e){switch(e.type){case"object":return rr.V50.ExampleTypeShape.object({properties:e.properties.map(t=>log(t))});case"alias":return rr.V50.ExampleTypeShape.alias({value:{...SF(e.value)}});case"enum":return rr.V50.ExampleTypeShape.enum(e);case"union":return rr.V50.ExampleTypeShape.union(iBA(e));case"undiscriminatedUnion":return rr.V50.ExampleTypeShape.undiscriminatedUnion(nBA(e))}}function nBA(e){return{...e,singleUnionType:SF(e.singleUnionType)}}function iBA(e){return{...e,singleUnionType:aBA(e.singleUnionType)}}function aBA(e){return{...e,shape:oBA(e.shape)}}function oBA(e){switch(e.type){case"samePropertiesAsObject":return rr.V50.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...e,object:uBA(e.object)});case"singleProperty":return rr.V50.ExampleSingleUnionTypeProperties.singleProperty({...e,shape:mOc(e.shape)});case"noProperties":return rr.V50.ExampleSingleUnionTypeProperties.noProperties()}}function uBA(e){return{...e,properties:e.properties.map(t=>log(t))}}function log(e){return{...e,value:{...e.value,shape:mOc(e.value.shape)}}}function sBA(e){return{...e,endpoints:e.endpoints.map(t=>cBA(t))}}function cBA(e){return{...e,autogeneratedExamples:e.autogeneratedExamples.map(t=>({...t,example:aog(t.example)})),userSpecifiedExamples:e.userSpecifiedExamples.map(t=>({...t,example:t.example!=null?aog(t.example):void 0}))}}function aog(e){return{...e,rootPathParameters:e.rootPathParameters.map(t=>GCo(t)),servicePathParameters:e.servicePathParameters.map(t=>GCo(t)),endpointPathParameters:e.endpointPathParameters.map(t=>GCo(t)),serviceHeaders:e.serviceHeaders.map(t=>gOc(t)),endpointHeaders:e.endpointHeaders.map(t=>gOc(t)),queryParameters:e.queryParameters.map(t=>uog(t)),request:e.request!=null?dBA(e.request):void 0,response:lBA(e.response)}}function lBA(e){switch(e.type){case"error":return rr.V50.ExampleResponse.error({...e,body:e.body!=null?SF(e.body):void 0});case"ok":return rr.V50.ExampleResponse.ok(fBA(e))}}function fBA(e){switch(e.value.type){case"body":return rr.V50.ExampleEndpointSuccessResponse.body(e.value.value!=null?SF(e.value.value):void 0);case"stream":return rr.V50.ExampleEndpointSuccessResponse.stream(e.value.value.map(t=>SF(t)));case"sse":return rr.V50.ExampleEndpointSuccessResponse.sse(e.value.value.map(t=>({...t,data:SF(t.data)})))}}function dBA(e){switch(e.type){case"inlinedRequestBody":return rr.V50.ExampleRequestBody.inlinedRequestBody(sog(e));case"reference":return rr.V50.ExampleRequestBody.reference(SF(e))}}function pBA(e){return{...e,examples:e.examples.map(t=>({...t,shape:SF(t.shape)}))}}var pog={laterVersion:"v52",earlierVersion:"v51",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:Zr,[We.TYPESCRIPT_BROWSER_SDK]:Zr,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:Zr,[We.TYPESCRIPT_EXPRESS]:Zr,[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:Zr,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:Zr,[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:Zr,[We.SWIFT_MODEL]:Zr,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>tb.V51.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,apiVersion:e.apiVersion!=null?hBA(e.apiVersion):void 0,auth:jBA(e.auth),headers:e.headers.map(t=>rjn(t)),idempotencyHeaders:e.idempotencyHeaders.map(t=>rjn(t)),types:_BA(e.types),services:sy(e.services,t=>NBA(t)),webhookGroups:sy(e.webhookGroups,t=>gBA(t)),websocketChannels:sy(e.websocketChannels,t=>yBA(t)),errors:sy(e.errors,t=>XBA(t)),pathParameters:e.pathParameters.map(t=>g9i(t)),variables:e.variables.map(t=>zBA(t))})};function _BA(e){return sy(e,t=>({...t,autogeneratedExamples:t.autogeneratedExamples.map(r=>fog(r)),userProvidedExamples:t.userProvidedExamples.map(r=>fog(r)),shape:rr.V52.types.Type._visit(t.shape,{union:r=>rr.V51.types.Type.union({...r,baseProperties:r.baseProperties.map(n=>({...n,valueType:tT(n.valueType)})),types:r.types.map(n=>TBA(n))}),enum:rr.V51.types.Type.enum,object:r=>rr.V51.types.Type.object({...r,properties:r.properties.map(n=>({...n,valueType:tT(n.valueType)}))}),alias:r=>rr.V51.types.Type.alias({aliasOf:tT(r.aliasOf),resolvedType:CBA(r.resolvedType)}),undiscriminatedUnion:r=>rr.V51.types.Type.undiscriminatedUnion(ABA(r)),_other:()=>{throw new Error("Encountered unknown shape")}})}))}function hBA(e){return rr.V51.ApiVersionScheme.header({...e,header:rjn(e.header)})}function yBA(e){return{...e,headers:e.headers.map(t=>rjn(t)),queryParameters:e.queryParameters.map(t=>jOc(t)),pathParameters:e.pathParameters.map(t=>g9i(t)),messages:e.messages.map(t=>vBA(t)),examples:e.examples.map(t=>QBA(t))}}function vBA(e){return{...e,body:bBA(e.body)}}function bBA(e){switch(e.type){case"inlinedBody":return rr.V51.websocket.WebSocketMessageBody.inlinedBody({...e,properties:e.properties.map(t=>({...t,valueType:tT(t.valueType)}))});case"reference":return rr.V51.websocket.WebSocketMessageBody.reference({...e,bodyType:tT(e.bodyType)})}}function gBA(e){return e.map(t=>mBA(t))}function mBA(e){return{...e,headers:e.headers.map(t=>rjn(t)),payload:OBA(e.payload),examples:e.examples!=null?e.examples.map(t=>PBA(t)):void 0}}function OBA(e){switch(e.type){case"reference":return rr.V51.webhooks.WebhookPayload.reference({...e,payloadType:tT(e.payloadType)});case"inlinedPayload":return rr.V51.webhooks.WebhookPayload.inlinedPayload({...e,properties:e.properties.map(t=>({...t,valueType:tT(t.valueType)}))})}}function PBA(e){return{...e,payload:EF(e.payload)}}function jBA(e){return{...e,schemes:e.schemes.map(t=>{switch(t.type){case"basic":return rr.V51.auth.AuthScheme.basic(t);case"bearer":return rr.V51.auth.AuthScheme.bearer(t);case"header":return rr.V51.auth.AuthScheme.header(wBA(t));case"oauth":return rr.V51.auth.AuthScheme.oauth(DBA(t))}})}}function wBA(e){return{...e,valueType:tT(e.valueType)}}function DBA(e){return{...e,configuration:rr.V51.auth.OAuthConfiguration.clientCredentials({...e.configuration,tokenEndpoint:SBA(e.configuration.tokenEndpoint),refreshEndpoint:e.configuration.refreshEndpoint!=null?EBA(e.configuration.refreshEndpoint):void 0})}}function SBA(e){return{...e,requestProperties:{clientId:YJr(e.requestProperties.clientId),clientSecret:YJr(e.requestProperties.clientSecret),scopes:e.requestProperties.scopes!=null?YJr(e.requestProperties.scopes):void 0},responseProperties:{accessToken:fAr(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?fAr(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?fAr(e.responseProperties.refreshToken):void 0}}}function EBA(e){return{...e,requestProperties:{refreshToken:YJr(e.requestProperties.refreshToken)},responseProperties:{accessToken:fAr(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?fAr(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?fAr(e.responseProperties.refreshToken):void 0}}}function rjn(e){return{...e,valueType:tT(e.valueType)}}function tT(e){return rr.V52.types.TypeReference._visit(e,{container:t=>rr.V51.types.TypeReference.container(hog(t)),primitive:t=>rr.V51.types.TypeReference.primitive(_og(t)),named:rr.V51.types.TypeReference.named,unknown:rr.V51.types.TypeReference.unknown,_other:()=>{throw new Error("Unknown type reference: "+e.type)}})}function _og(e){return{v1:MBA(e.v1),v2:e.v2!=null?xBA(e.v2):void 0}}function MBA(e){switch(e){case"UINT":return rr.V51.types.PrimitiveTypeV1.Integer;case"UINT_64":return rr.V51.types.PrimitiveTypeV1.Long}return e}function xBA(e){switch(e.type){case"integer":return rr.V51.types.PrimitiveTypeV2.integer(e);case"double":return rr.V51.types.PrimitiveTypeV2.double(e);case"string":return rr.V51.types.PrimitiveTypeV2.string(e);case"boolean":return rr.V51.types.PrimitiveTypeV2.boolean(e);case"long":return rr.V51.types.PrimitiveTypeV2.long(e);case"bigInteger":return rr.V51.types.PrimitiveTypeV2.bigInteger(e);case"uint":return;case"uint64":return;default:fl(e)}}function hog(e){return rr.V52.types.ContainerType._visit(e,{list:t=>rr.V51.types.ContainerType.list(tT(t)),optional:t=>rr.V51.types.ContainerType.optional(tT(t)),set:t=>rr.V51.types.ContainerType.set(tT(t)),map:({keyType:t,valueType:r})=>rr.V51.types.ContainerType.map({keyType:tT(t),valueType:tT(r)}),literal:rr.V51.types.ContainerType.literal,_other:()=>{throw new Error("Unknown ContainerType: "+e.type)}})}function TBA(e){return{...e,shape:qBA(e.shape)}}function qBA(e){return rr.V52.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>rr.V51.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>rr.V51.types.SingleUnionTypeProperties.singleProperty({...t,type:tT(t.type)}),noProperties:rr.V51.types.SingleUnionTypeProperties.noProperties,_other:()=>{throw new Error(`Unknown SingleUnionTypeProperties: ${JSON.stringify(e)}`)}})}function CBA(e){return rr.V52.types.ResolvedTypeReference._visit(e,{container:t=>rr.V51.types.ResolvedTypeReference.container(hog(t)),named:rr.V51.types.ResolvedTypeReference.named,primitive:t=>rr.V51.types.ResolvedTypeReference.primitive(_og(t)),unknown:rr.V51.types.ResolvedTypeReference.unknown,_other:()=>{throw new Error("Unknown ResolvedTypeReference: "+e.type)}})}function ABA(e){return{members:e.members.map(t=>({...t,type:tT(t.type)}))}}function NBA(e){return{...e,pathParameters:e.pathParameters.map(t=>g9i(t)),headers:e.headers.map(t=>rjn(t)),endpoints:e.endpoints.map(t=>BBA(t))}}function g9i(e){return{...e,valueType:tT(e.valueType)}}function zBA(e){return{...e,type:tT(e.type)}}function BBA(e){return{...e,pagination:e.pagination!=null?UBA(e.pagination):void 0,allPathParameters:e.allPathParameters.map(t=>g9i(t)),pathParameters:e.pathParameters.map(t=>g9i(t)),sdkRequest:e.sdkRequest!=null?$BA(e.sdkRequest):void 0,requestBody:e.requestBody!=null?KBA(e.requestBody):void 0,response:e.response!=null?IBA(e.response):void 0,headers:e.headers.map(t=>rjn(t)),queryParameters:e.queryParameters.map(t=>jOc(t)),autogeneratedExamples:e.autogeneratedExamples.map(t=>({...t,example:dog(t.example)})),userSpecifiedExamples:e.userSpecifiedExamples.map(t=>({...t,example:t.example!=null?dog(t.example):void 0}))}}function IBA(e){return{...e,body:e.body!=null?RBA(e.body):void 0}}function RBA(e){switch(e.type){case"json":return rr.V51.http.HttpResponseBody.json(yog(e.value));case"fileDownload":return rr.V51.http.HttpResponseBody.fileDownload(e);case"text":return rr.V51.http.HttpResponseBody.text(e);case"streaming":return rr.V51.http.HttpResponseBody.streaming(vog(e.value));case"streamParameter":return rr.V51.http.HttpResponseBody.streamParameter(LBA(e))}}function yog(e){switch(e.type){case"response":return rr.V51.http.JsonResponse.response({...e,responseBodyType:tT(e.responseBodyType)});case"nestedPropertyAsResponse":return rr.V51.http.JsonResponse.nestedPropertyAsResponse({...e,responseBodyType:tT(e.responseBodyType),responseProperty:e.responseProperty!=null?POc(e.responseProperty):void 0})}}function vog(e){switch(e.type){case"json":return rr.V51.http.StreamingResponse.json({...e,payload:tT(e.payload)});case"text":return rr.V51.http.StreamingResponse.text(e);case"sse":return rr.V51.http.StreamingResponse.sse({...e,payload:tT(e.payload)})}}function FBA(e){switch(e.type){case"json":return rr.V51.http.NonStreamHttpResponseBody.json(yog(e.value));case"text":return rr.V51.http.NonStreamHttpResponseBody.text(e);case"fileDownload":return rr.V51.http.NonStreamHttpResponseBody.fileDownload(e)}}function LBA(e){return{nonStreamResponse:FBA(e.nonStreamResponse),streamResponse:vog(e.streamResponse)}}function UBA(e){switch(e.type){case"cursor":return rr.V51.http.Pagination.cursor(VBA(e));case"offset":return rr.V51.http.Pagination.offset(WBA(e))}}function VBA(e){return{...e,page:YJr(e.page),next:fAr(e.next),results:fAr(e.results)}}function WBA(e){return{...e,page:YJr(e.page),results:fAr(e.results),step:e.step!=null?YJr(e.step):void 0}}function YJr(e){return{...e,property:HBA(e.property)}}function HBA(e){switch(e.type){case"query":return rr.V51.RequestPropertyValue.query(jOc(e));case"body":return rr.V51.RequestPropertyValue.body(POc(e))}}function fAr(e){return{...e,property:POc(e.property)}}function POc(e){return{...e,valueType:tT(e.valueType)}}function jOc(e){return{...e,valueType:tT(e.valueType)}}function $BA(e){return{...e,streamParameter:e.streamParameter!=null?YJr(e.streamParameter):void 0,shape:JBA(e.shape)}}function JBA(e){return rr.V52.http.SdkRequestShape._visit(e,{justRequestBody:t=>rr.V51.http.SdkRequestShape.justRequestBody(GBA(t)),wrapper:rr.V51.http.SdkRequestShape.wrapper,_other:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function GBA(e){switch(e.type){case"bytes":return rr.V51.http.SdkRequestBodyType.bytes(e);case"typeReference":return rr.V51.http.SdkRequestBodyType.typeReference({...e,requestBodyType:tT(e.requestBodyType)})}}function KBA(e){return rr.V52.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>rr.V51.http.HttpRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,valueType:tT(r.valueType)}))}),reference:t=>rr.V51.http.HttpRequestBody.reference({...t,requestBodyType:tT(t.requestBodyType)}),fileUpload:t=>rr.V51.http.HttpRequestBody.fileUpload({...t,properties:t.properties.map(r=>{switch(r.type){case"bodyProperty":return rr.V51.http.FileUploadRequestProperty.bodyProperty({...r,valueType:tT(r.valueType)});case"file":return rr.V51.http.FileUploadRequestProperty.file(YBA(r.value))}})}),bytes:t=>rr.V51.http.HttpRequestBody.bytes(t),_other:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function YBA(e){switch(e.type){case"file":return rr.V51.http.FileProperty.file(e);case"fileArray":return rr.V51.http.FileProperty.fileArray(e)}}function XBA(e){return{...e,type:e.type!=null?tT(e.type):void 0,examples:e.examples.map(t=>({...t,shape:EF(t.shape)}))}}function QBA(e){return{...e,pathParameters:e.pathParameters.map(t=>KCo(t)),headers:e.headers.map(t=>OOc(t)),queryParameters:e.queryParameters.map(t=>bog(t)),messages:e.messages.map(t=>({...t,body:ZBA(t.body)}))}}function bog(e){return{...e,value:EF(e.value)}}function OOc(e){return{...e,value:EF(e.value)}}function KCo(e){return{...e,value:EF(e.value)}}function ZBA(e){switch(e.type){case"inlinedBody":return rr.V51.ExampleWebSocketMessageBody.inlinedBody(gog(e));case"reference":return rr.V51.ExampleWebSocketMessageBody.reference(EF(e))}}function gog(e){return{...e,properties:e.properties.map(t=>({...t,value:EF(t.value)}))}}function fog(e){return{...e,shape:Oog(e.shape)}}function wOc(e){switch(e.type){case"primitive":return rr.V51.ExampleTypeReferenceShape.primitive(kBA(e));case"container":return rr.V51.ExampleTypeReferenceShape.container(eIA(e));case"unknown":return rr.V51.ExampleTypeReferenceShape.unknown(e.unknown);case"named":return rr.V51.ExampleTypeReferenceShape.named({...e,typeName:e.typeName,shape:Oog(e.shape)})}}function mog(e){switch(e.type){case"integer":return rr.V51.ExamplePrimitive.integer(e.integer);case"uint":return rr.V51.ExamplePrimitive.integer(e.uint);case"uint64":return rr.V51.ExamplePrimitive.integer(e.uint64);case"double":return rr.V51.ExamplePrimitive.double(e.double);case"long":return rr.V51.ExamplePrimitive.long(e.long);case"boolean":return rr.V51.ExamplePrimitive.boolean(e.boolean);case"string":return rr.V51.ExamplePrimitive.string(e.string);case"date":return rr.V51.ExamplePrimitive.date(e.date);case"datetime":return rr.V51.ExamplePrimitive.datetime(e.datetime);case"uuid":return rr.V51.ExamplePrimitive.uuid(e.uuid)}}function kBA(e){return mog(e.primitive)}function eIA(e){switch(e.container.type){case"list":return rr.V51.ExampleContainer.list({list:e.container.list.map(t=>EF(t)),itemType:tT(e.container.itemType)});case"set":return rr.V51.ExampleContainer.set({set:e.container.set.map(t=>EF(t)),itemType:tT(e.container.itemType)});case"optional":return rr.V51.ExampleContainer.optional({optional:e.container.optional!=null?EF(e.container.optional):void 0,valueType:tT(e.container.valueType)});case"map":return rr.V51.ExampleContainer.map({map:e.container.map.map(t=>({key:EF(t.key),value:EF(t.value)})),keyType:tT(e.container.keyType),valueType:tT(e.container.valueType)});case"literal":return rr.V51.ExampleContainer.literal({literal:mog(e.container.literal)})}}function EF(e){return{...e,shape:wOc(e.shape)}}function Oog(e){switch(e.type){case"object":return rr.V51.ExampleTypeShape.object({properties:e.properties.map(t=>Pog(t))});case"alias":return rr.V51.ExampleTypeShape.alias({value:{...EF(e.value)}});case"enum":return rr.V51.ExampleTypeShape.enum(e);case"union":return rr.V51.ExampleTypeShape.union(rIA(e));case"undiscriminatedUnion":return rr.V51.ExampleTypeShape.undiscriminatedUnion(tIA(e))}}function tIA(e){return{...e,singleUnionType:EF(e.singleUnionType)}}function rIA(e){return{...e,singleUnionType:nIA(e.singleUnionType)}}function nIA(e){return{...e,shape:iIA(e.shape)}}function iIA(e){switch(e.type){case"samePropertiesAsObject":return rr.V51.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...e,object:aIA(e.object)});case"singleProperty":return rr.V51.ExampleSingleUnionTypeProperties.singleProperty({...e,shape:wOc(e.shape)});case"noProperties":return rr.V51.ExampleSingleUnionTypeProperties.noProperties()}}function aIA(e){return{...e,properties:e.properties.map(t=>Pog(t))}}function Pog(e){return{...e,value:{...e.value,shape:wOc(e.value.shape)}}}function dog(e){return{...e,rootPathParameters:e.rootPathParameters.map(t=>KCo(t)),servicePathParameters:e.servicePathParameters.map(t=>KCo(t)),endpointPathParameters:e.endpointPathParameters.map(t=>KCo(t)),serviceHeaders:e.serviceHeaders.map(t=>OOc(t)),endpointHeaders:e.endpointHeaders.map(t=>OOc(t)),queryParameters:e.queryParameters.map(t=>bog(t)),request:e.request!=null?sIA(e.request):void 0,response:oIA(e.response)}}function oIA(e){switch(e.type){case"error":return rr.V51.ExampleResponse.error({...e,body:e.body!=null?EF(e.body):void 0});case"ok":return rr.V51.ExampleResponse.ok(uIA(e))}}function uIA(e){switch(e.value.type){case"body":return rr.V51.ExampleEndpointSuccessResponse.body(e.value.value!=null?EF(e.value.value):void 0);case"stream":return rr.V51.ExampleEndpointSuccessResponse.stream(e.value.value.map(t=>EF(t)));case"sse":return rr.V51.ExampleEndpointSuccessResponse.sse(e.value.value.map(t=>({...t,data:EF(t.data)})))}}function sIA(e){switch(e.type){case"inlinedRequestBody":return rr.V51.ExampleRequestBody.inlinedRequestBody(gog(e));case"reference":return rr.V51.ExampleRequestBody.reference(EF(e))}}var Dog={laterVersion:"v53",earlierVersion:"v52",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:"0.38.0-rc0",[We.TYPESCRIPT_BROWSER_SDK]:"0.38.0-rc0",[We.TYPESCRIPT]:"0.38.0-rc0",[We.TYPESCRIPT_SDK]:"0.38.0-rc0",[We.TYPESCRIPT_EXPRESS]:"0.17.3",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:"1.1.0-rc0",[We.PYTHON_PYDANTIC]:"1.1.0-rc0",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:"0.1.0",[We.STOPLIGHT]:Zr,[We.POSTMAN]:"0.2.0",[We.PYTHON_SDK]:"3.3.0-rc0",[We.GO_FIBER]:Zr,[We.GO_MODEL]:Zr,[We.GO_SDK]:Zr,[We.RUBY_MODEL]:Zr,[We.RUBY_SDK]:Zr,[We.CSHARP_MODEL]:Zr,[We.CSHARP_SDK]:"0.5.0",[We.SWIFT_MODEL]:Zr,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:"0.1.0"},jsonifyEarlierVersion:e=>tb.V52.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,apiVersion:e.apiVersion!=null?lIA(e.apiVersion):void 0,auth:bIA(e.auth),headers:e.headers.map(t=>njn(t)),idempotencyHeaders:e.idempotencyHeaders.map(t=>njn(t)),types:cIA(e.types),services:sy(e.services,t=>xIA(t)),webhookGroups:sy(e.webhookGroups,t=>_IA(t)),websocketChannels:sy(e.websocketChannels,t=>fIA(t)),errors:sy(e.errors,t=>$IA(t)),pathParameters:e.pathParameters.map(t=>m9i(t)),variables:e.variables.map(t=>TIA(t))})};function cIA(e){return sy(e,t=>({...t,autogeneratedExamples:t.autogeneratedExamples.map(r=>jog(r)),userProvidedExamples:t.userProvidedExamples.map(r=>jog(r)),shape:rr.V53.types.Type._visit(t.shape,{union:r=>rr.V52.types.Type.union({...r,baseProperties:r.baseProperties.map(n=>({...n,valueType:rT(n.valueType)})),types:r.types.map(n=>DIA(n))}),enum:rr.V52.types.Type.enum,object:r=>rr.V52.types.Type.object({...r,properties:r.properties.map(n=>({...n,valueType:rT(n.valueType)}))}),alias:r=>rr.V52.types.Type.alias({aliasOf:rT(r.aliasOf),resolvedType:EIA(r.resolvedType)}),undiscriminatedUnion:r=>rr.V52.types.Type.undiscriminatedUnion(MIA(r)),_other:()=>{throw new Error("Encountered unknown shape")}})}))}function lIA(e){return rr.V52.ApiVersionScheme.header({...e,header:njn(e.header)})}function fIA(e){return{...e,headers:e.headers.map(t=>njn(t)),queryParameters:e.queryParameters.map(t=>EOc(t)),pathParameters:e.pathParameters.map(t=>m9i(t)),messages:e.messages.map(t=>dIA(t)),examples:e.examples.map(t=>JIA(t))}}function dIA(e){return{...e,body:pIA(e.body)}}function pIA(e){switch(e.type){case"inlinedBody":return rr.V52.websocket.WebSocketMessageBody.inlinedBody({...e,properties:e.properties.map(t=>({...t,valueType:rT(t.valueType)}))});case"reference":return rr.V52.websocket.WebSocketMessageBody.reference({...e,bodyType:rT(e.bodyType)})}}function _IA(e){return e.map(t=>hIA(t))}function hIA(e){return{...e,headers:e.headers.map(t=>njn(t)),payload:yIA(e.payload),examples:e.examples!=null?e.examples.map(t=>vIA(t)):void 0}}function yIA(e){switch(e.type){case"reference":return rr.V52.webhooks.WebhookPayload.reference({...e,payloadType:rT(e.payloadType)});case"inlinedPayload":return rr.V52.webhooks.WebhookPayload.inlinedPayload({...e,properties:e.properties.map(t=>({...t,valueType:rT(t.valueType)}))})}}function vIA(e){return{...e,payload:MF(e.payload)}}function bIA(e){return{...e,schemes:e.schemes.map(t=>{switch(t.type){case"basic":return rr.V52.auth.AuthScheme.basic(t);case"bearer":return rr.V52.auth.AuthScheme.bearer(t);case"header":return rr.V52.auth.AuthScheme.header(gIA(t));case"oauth":return rr.V52.auth.AuthScheme.oauth(mIA(t))}})}}function gIA(e){return{...e,valueType:rT(e.valueType)}}function mIA(e){return{...e,configuration:rr.V52.auth.OAuthConfiguration.clientCredentials({...e.configuration,tokenEndpoint:OIA(e.configuration.tokenEndpoint),refreshEndpoint:e.configuration.refreshEndpoint!=null?PIA(e.configuration.refreshEndpoint):void 0})}}function OIA(e){return{...e,requestProperties:{clientId:XJr(e.requestProperties.clientId),clientSecret:XJr(e.requestProperties.clientSecret),scopes:e.requestProperties.scopes!=null?XJr(e.requestProperties.scopes):void 0},responseProperties:{accessToken:dAr(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?dAr(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?dAr(e.responseProperties.refreshToken):void 0}}}function PIA(e){return{...e,requestProperties:{refreshToken:XJr(e.requestProperties.refreshToken)},responseProperties:{accessToken:dAr(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?dAr(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?dAr(e.responseProperties.refreshToken):void 0}}}function njn(e){return{...e,valueType:rT(e.valueType)}}function rT(e){return rr.V53.types.TypeReference._visit(e,{container:t=>rr.V52.types.TypeReference.container(Eog(t)),primitive:t=>rr.V52.types.TypeReference.primitive(Sog(t)),named:rr.V52.types.TypeReference.named,unknown:rr.V52.types.TypeReference.unknown,_other:()=>{throw new Error("Unknown type reference: "+e.type)}})}function Sog(e){return{v1:jIA(e.v1),v2:e.v2!=null?wIA(e.v2):void 0}}function jIA(e){switch(e){case"FLOAT":return rr.V52.types.PrimitiveTypeV1.Double}return e}function wIA(e){switch(e.type){case"integer":return rr.V52.types.PrimitiveTypeV2.integer(e);case"double":return rr.V52.types.PrimitiveTypeV2.double(e);case"string":return rr.V52.types.PrimitiveTypeV2.string(e);case"boolean":return rr.V52.types.PrimitiveTypeV2.boolean(e);case"long":return rr.V52.types.PrimitiveTypeV2.long(e);case"bigInteger":return rr.V52.types.PrimitiveTypeV2.bigInteger(e);case"uint":return rr.V52.types.PrimitiveTypeV2.uint();case"uint64":return rr.V52.types.PrimitiveTypeV2.uint64();case"date":return;case"dateTime":return;case"uuid":return;case"base64":return;case"float":return;default:fl(e)}}function Eog(e){return rr.V53.types.ContainerType._visit(e,{list:t=>rr.V52.types.ContainerType.list(rT(t)),optional:t=>rr.V52.types.ContainerType.optional(rT(t)),set:t=>rr.V52.types.ContainerType.set(rT(t)),map:({keyType:t,valueType:r})=>rr.V52.types.ContainerType.map({keyType:rT(t),valueType:rT(r)}),literal:rr.V52.types.ContainerType.literal,_other:()=>{throw new Error("Unknown ContainerType: "+e.type)}})}function DIA(e){return{...e,shape:SIA(e.shape)}}function SIA(e){return rr.V53.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>rr.V52.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>rr.V52.types.SingleUnionTypeProperties.singleProperty({...t,type:rT(t.type)}),noProperties:rr.V52.types.SingleUnionTypeProperties.noProperties,_other:()=>{throw new Error(`Unknown SingleUnionTypeProperties: ${JSON.stringify(e)}`)}})}function EIA(e){return rr.V53.types.ResolvedTypeReference._visit(e,{container:t=>rr.V52.types.ResolvedTypeReference.container(Eog(t)),named:rr.V52.types.ResolvedTypeReference.named,primitive:t=>rr.V52.types.ResolvedTypeReference.primitive(Sog(t)),unknown:rr.V52.types.ResolvedTypeReference.unknown,_other:()=>{throw new Error("Unknown ResolvedTypeReference: "+e.type)}})}function MIA(e){return{members:e.members.map(t=>({...t,type:rT(t.type)}))}}function xIA(e){return{...e,pathParameters:e.pathParameters.map(t=>m9i(t)),headers:e.headers.map(t=>njn(t)),endpoints:e.endpoints.map(t=>qIA(t))}}function m9i(e){return{...e,valueType:rT(e.valueType)}}function TIA(e){return{...e,type:rT(e.type)}}function qIA(e){return{...e,pagination:e.pagination!=null?BIA(e.pagination):void 0,allPathParameters:e.allPathParameters.map(t=>m9i(t)),pathParameters:e.pathParameters.map(t=>m9i(t)),sdkRequest:e.sdkRequest!=null?LIA(e.sdkRequest):void 0,requestBody:e.requestBody!=null?WIA(e.requestBody):void 0,response:e.response!=null?CIA(e.response):void 0,headers:e.headers.map(t=>njn(t)),queryParameters:e.queryParameters.map(t=>EOc(t)),autogeneratedExamples:e.autogeneratedExamples.map(t=>({...t,example:wog(t.example)})),userSpecifiedExamples:e.userSpecifiedExamples.map(t=>({...t,example:t.example!=null?wog(t.example):void 0}))}}function CIA(e){return{...e,body:e.body!=null?AIA(e.body):void 0}}function AIA(e){switch(e.type){case"json":return rr.V52.http.HttpResponseBody.json(Mog(e.value));case"fileDownload":return rr.V52.http.HttpResponseBody.fileDownload(e);case"text":return rr.V52.http.HttpResponseBody.text(e);case"streaming":return rr.V52.http.HttpResponseBody.streaming(xog(e.value));case"streamParameter":return rr.V52.http.HttpResponseBody.streamParameter(zIA(e))}}function Mog(e){switch(e.type){case"response":return rr.V52.http.JsonResponse.response({...e,responseBodyType:rT(e.responseBodyType)});case"nestedPropertyAsResponse":return rr.V52.http.JsonResponse.nestedPropertyAsResponse({...e,responseBodyType:rT(e.responseBodyType),responseProperty:e.responseProperty!=null?SOc(e.responseProperty):void 0})}}function xog(e){switch(e.type){case"json":return rr.V52.http.StreamingResponse.json({...e,payload:rT(e.payload)});case"text":return rr.V52.http.StreamingResponse.text(e);case"sse":return rr.V52.http.StreamingResponse.sse({...e,payload:rT(e.payload)})}}function NIA(e){switch(e.type){case"json":return rr.V52.http.NonStreamHttpResponseBody.json(Mog(e.value));case"text":return rr.V52.http.NonStreamHttpResponseBody.text(e);case"fileDownload":return rr.V52.http.NonStreamHttpResponseBody.fileDownload(e)}}function zIA(e){return{nonStreamResponse:NIA(e.nonStreamResponse),streamResponse:xog(e.streamResponse)}}function BIA(e){switch(e.type){case"cursor":return rr.V52.http.Pagination.cursor(IIA(e));case"offset":return rr.V52.http.Pagination.offset(RIA(e))}}function IIA(e){return{...e,page:XJr(e.page),next:dAr(e.next),results:dAr(e.results)}}function RIA(e){return{...e,page:XJr(e.page),results:dAr(e.results),step:e.step!=null?XJr(e.step):void 0}}function XJr(e){return{...e,property:FIA(e.property)}}function FIA(e){switch(e.type){case"query":return rr.V52.RequestPropertyValue.query(EOc(e));case"body":return rr.V52.RequestPropertyValue.body(SOc(e))}}function dAr(e){return{...e,property:SOc(e.property)}}function SOc(e){return{...e,valueType:rT(e.valueType)}}function EOc(e){return{...e,valueType:rT(e.valueType)}}function LIA(e){return{...e,streamParameter:e.streamParameter!=null?XJr(e.streamParameter):void 0,shape:UIA(e.shape)}}function UIA(e){return rr.V53.http.SdkRequestShape._visit(e,{justRequestBody:t=>rr.V52.http.SdkRequestShape.justRequestBody(VIA(t)),wrapper:rr.V52.http.SdkRequestShape.wrapper,_other:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function VIA(e){switch(e.type){case"bytes":return rr.V52.http.SdkRequestBodyType.bytes(e);case"typeReference":return rr.V52.http.SdkRequestBodyType.typeReference({...e,requestBodyType:rT(e.requestBodyType)})}}function WIA(e){return rr.V53.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>rr.V52.http.HttpRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,valueType:rT(r.valueType)}))}),reference:t=>rr.V52.http.HttpRequestBody.reference({...t,requestBodyType:rT(t.requestBodyType)}),fileUpload:t=>rr.V52.http.HttpRequestBody.fileUpload({...t,properties:t.properties.map(r=>{switch(r.type){case"bodyProperty":return rr.V52.http.FileUploadRequestProperty.bodyProperty({...r,valueType:rT(r.valueType)});case"file":return rr.V52.http.FileUploadRequestProperty.file(HIA(r.value))}})}),bytes:t=>rr.V52.http.HttpRequestBody.bytes(t),_other:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function HIA(e){switch(e.type){case"file":return rr.V52.http.FileProperty.file(e);case"fileArray":return rr.V52.http.FileProperty.fileArray(e)}}function $IA(e){return{...e,type:e.type!=null?rT(e.type):void 0,examples:e.examples.map(t=>({...t,shape:MF(t.shape)}))}}function JIA(e){return{...e,pathParameters:e.pathParameters.map(t=>YCo(t)),headers:e.headers.map(t=>DOc(t)),queryParameters:e.queryParameters.map(t=>Tog(t)),messages:e.messages.map(t=>({...t,body:GIA(t.body)}))}}function Tog(e){return{...e,value:MF(e.value)}}function DOc(e){return{...e,value:MF(e.value)}}function YCo(e){return{...e,value:MF(e.value)}}function GIA(e){switch(e.type){case"inlinedBody":return rr.V52.ExampleWebSocketMessageBody.inlinedBody(qog(e));case"reference":return rr.V52.ExampleWebSocketMessageBody.reference(MF(e))}}function qog(e){return{...e,properties:e.properties.map(t=>({...t,value:MF(t.value)}))}}function jog(e){return{...e,shape:Aog(e.shape)}}function MOc(e){switch(e.type){case"primitive":return rr.V52.ExampleTypeReferenceShape.primitive(KIA(e));case"container":return rr.V52.ExampleTypeReferenceShape.container(YIA(e));case"unknown":return rr.V52.ExampleTypeReferenceShape.unknown(e.unknown);case"named":return rr.V52.ExampleTypeReferenceShape.named({...e,typeName:e.typeName,shape:Aog(e.shape)})}}function Cog(e){switch(e.type){case"integer":return rr.V52.ExamplePrimitive.integer(e.integer);case"uint":return rr.V52.ExamplePrimitive.integer(e.uint);case"uint64":return rr.V52.ExamplePrimitive.integer(e.uint64);case"float":return rr.V52.ExamplePrimitive.double(e.float);case"double":return rr.V52.ExamplePrimitive.double(e.double);case"long":return rr.V52.ExamplePrimitive.long(e.long);case"boolean":return rr.V52.ExamplePrimitive.boolean(e.boolean);case"string":return rr.V52.ExamplePrimitive.string(e.string);case"date":return rr.V52.ExamplePrimitive.date(e.date);case"datetime":return rr.V52.ExamplePrimitive.datetime(e.datetime);case"uuid":return rr.V52.ExamplePrimitive.uuid(e.uuid);case"base64":return rr.V52.ExamplePrimitive.string({original:e.base64});case"bigInteger":return rr.V52.ExamplePrimitive.string({original:e.bigInteger})}}function KIA(e){return Cog(e.primitive)}function YIA(e){switch(e.container.type){case"list":return rr.V52.ExampleContainer.list({list:e.container.list.map(t=>MF(t)),itemType:rT(e.container.itemType)});case"set":return rr.V52.ExampleContainer.set({set:e.container.set.map(t=>MF(t)),itemType:rT(e.container.itemType)});case"optional":return rr.V52.ExampleContainer.optional({optional:e.container.optional!=null?MF(e.container.optional):void 0,valueType:rT(e.container.valueType)});case"map":return rr.V52.ExampleContainer.map({map:e.container.map.map(t=>({key:MF(t.key),value:MF(t.value)})),keyType:rT(e.container.keyType),valueType:rT(e.container.valueType)});case"literal":return rr.V52.ExampleContainer.literal({literal:Cog(e.container.literal)})}}function MF(e){return{...e,shape:MOc(e.shape)}}function Aog(e){switch(e.type){case"object":return rr.V52.ExampleTypeShape.object({properties:e.properties.map(t=>Nog(t))});case"alias":return rr.V52.ExampleTypeShape.alias({value:{...MF(e.value)}});case"enum":return rr.V52.ExampleTypeShape.enum(e);case"union":return rr.V52.ExampleTypeShape.union(QIA(e));case"undiscriminatedUnion":return rr.V52.ExampleTypeShape.undiscriminatedUnion(XIA(e))}}function XIA(e){return{...e,singleUnionType:MF(e.singleUnionType)}}function QIA(e){return{...e,singleUnionType:ZIA(e.singleUnionType)}}function ZIA(e){return{...e,shape:kIA(e.shape)}}function kIA(e){switch(e.type){case"samePropertiesAsObject":return rr.V52.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...e,object:eRA(e.object)});case"singleProperty":return rr.V52.ExampleSingleUnionTypeProperties.singleProperty({...e,shape:MOc(e.shape)});case"noProperties":return rr.V52.ExampleSingleUnionTypeProperties.noProperties()}}function eRA(e){return{...e,properties:e.properties.map(t=>Nog(t))}}function Nog(e){return{...e,value:{...e.value,shape:MOc(e.value.shape)}}}function wog(e){return{...e,rootPathParameters:e.rootPathParameters.map(t=>YCo(t)),servicePathParameters:e.servicePathParameters.map(t=>YCo(t)),endpointPathParameters:e.endpointPathParameters.map(t=>YCo(t)),serviceHeaders:e.serviceHeaders.map(t=>DOc(t)),endpointHeaders:e.endpointHeaders.map(t=>DOc(t)),queryParameters:e.queryParameters.map(t=>Tog(t)),request:e.request!=null?nRA(e.request):void 0,response:tRA(e.response)}}function tRA(e){switch(e.type){case"error":return rr.V52.ExampleResponse.error({...e,body:e.body!=null?MF(e.body):void 0});case"ok":return rr.V52.ExampleResponse.ok(rRA(e))}}function rRA(e){switch(e.value.type){case"body":return rr.V52.ExampleEndpointSuccessResponse.body(e.value.value!=null?MF(e.value.value):void 0);case"stream":return rr.V52.ExampleEndpointSuccessResponse.stream(e.value.value.map(t=>MF(t)));case"sse":return rr.V52.ExampleEndpointSuccessResponse.sse(e.value.value.map(t=>({...t,data:MF(t.data)})))}}function nRA(e){switch(e.type){case"inlinedRequestBody":return rr.V52.ExampleRequestBody.inlinedRequestBody(qog(e));case"reference":return rr.V52.ExampleRequestBody.reference(MF(e))}}var zog={laterVersion:"v6",earlierVersion:"v5",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.0.257-4-ge56e5d2",[We.TYPESCRIPT_EXPRESS]:"0.0.264",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:"0.0.35-1-g071a04a",[We.PYTHON_PYDANTIC]:"0.0.35-1-g071a04a",[We.OPENAPI]:"0.0.16-1-ga2c0ada",[We.STOPLIGHT]:fa,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:fa,[We.OPENAPI_PYTHON_CLIENT]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,{taskContext:t,targetGenerator:r})=>{var n;return{...e,defaultEnvironment:(n=e.environments)==null?void 0:n.defaultEnvironment,environments:e.environments!=null?rr.V6.environment.Environments._visit(e.environments.environments,{singleBaseUrl:i=>i.environments,multipleBaseUrls:()=>t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support specifying multiple URLs for a single environment. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains a multiple URls for a single environment."),_unknown:()=>{var i;throw new Error("Unknown Environments: "+((i=e.environments)==null?void 0:i.environments.type))}}):[]}}};var Bog={laterVersion:"v7",earlierVersion:"v6",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.0.268",[We.TYPESCRIPT_EXPRESS]:"0.0.268",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:Zr,[We.PYTHON_PYDANTIC]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:fa,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:fa,[We.OPENAPI_PYTHON_CLIENT]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>({...e,services:e.services.map(t=>{let r=t.name.fernFilepath[t.name.fernFilepath.length-1],n=r!=null?`${r.pascalCase.safeName}Service`:"Service",i=r!=null?`${r.camelCase.unsafeName}Service`:"Service",a=r!=null?`${r.snakeCase.unsafeName}_service`:"service",u=a.toUpperCase(),f=OV(i);return{...t,name:{name:{originalName:n,camelCase:{safeName:i,unsafeName:i},snakeCase:{safeName:a,unsafeName:a},screamingSnakeCase:{safeName:u,unsafeName:u},pascalCase:{safeName:f,unsafeName:f}},fernFilepath:t.name.fernFilepath}}})})};var Fog={laterVersion:"v8",earlierVersion:"v7",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.0.273-5-g1b00245b",[We.TYPESCRIPT_EXPRESS]:"0.0.273-5-g1b00245b",[We.JAVA]:Zr,[We.JAVA_MODEL]:Zr,[We.JAVA_SDK]:Zr,[We.JAVA_SPRING]:Zr,[We.PYTHON_FASTAPI]:"0.0.45-1-g8bb600f",[We.PYTHON_PYDANTIC]:"0.0.45-1-g8bb600f",[We.OPENAPI_PYTHON_CLIENT]:"0.0.0",[We.OPENAPI]:"0.0.20-1-gbbeb9bd",[We.STOPLIGHT]:fa,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>({...e,auth:iRA(e.auth),headers:e.headers.map(t=>XCo(t)),types:e.types.map(t=>aRA(t)),errors:e.errors.map(t=>dRA(t)),services:e.services.map(t=>pRA(t))})};function xOc(e){return e.allParts}function iRA(e){return{docs:e.docs,requirement:e.requirement,schemes:e.schemes.map(t=>t._type!=="header"?t:rr.V7.auth.AuthScheme.header(XCo(t)))}}function XCo(e){return{docs:e.docs,availability:e.availability,name:e.name,valueType:RY(e.valueType)}}function RY(e){return rr.V8.types.TypeReference._visit(e,{container:t=>rr.V7.types.TypeReference.container(Log(t)),named:t=>rr.V7.types.TypeReference.named(pNt(t)),primitive:rr.V7.types.TypeReference.primitive,unknown:rr.V7.types.TypeReference.unknown,_unknown:()=>{throw new Error("Unknown type reference: "+e._type)}})}function Log(e){return rr.V8.types.ContainerType._visit(e,{list:t=>rr.V7.types.ContainerType.list(RY(t)),optional:t=>rr.V7.types.ContainerType.optional(RY(t)),set:t=>rr.V7.types.ContainerType.set(RY(t)),map:({keyType:t,valueType:r})=>rr.V7.types.ContainerType.map({keyType:RY(t),valueType:RY(r)}),literal:rr.V7.types.ContainerType.literal,_unknown:()=>{throw new Error("Unknown ContainerType: "+e._type)}})}function pNt(e){return{name:e.name,fernFilepath:xOc(e.fernFilepath)}}function aRA(e){return{docs:e.docs,availability:e.availability,name:pNt(e.name),shape:oRA(e.shape),examples:e.examples.map(t=>lRA(t)),referencedTypes:e.referencedTypes.map(t=>pNt(t))}}function oRA(e){return rr.V8.types.Type._visit(e,{alias:t=>rr.V7.types.Type.alias({aliasOf:RY(t.aliasOf),resolvedType:uRA(t.resolvedType)}),enum:rr.V7.types.Type.enum,object:t=>rr.V7.types.Type.object({extends:t.extends.map(r=>pNt(r)),properties:t.properties.map(r=>({docs:r.docs,availability:r.availability,name:r.name,valueType:RY(r.valueType)}))}),union:t=>rr.V7.types.Type.union({discriminant:t.discriminant,types:t.types.map(r=>sRA(r))}),_unknown:()=>{throw new Error("Unknown Type shape: "+e._type)}})}function uRA(e){return rr.V8.types.ResolvedTypeReference._visit(e,{container:t=>rr.V7.types.ResolvedTypeReference.container(Log(t)),named:t=>rr.V7.types.ResolvedTypeReference.named({name:pNt(t.name),shape:t.shape}),primitive:rr.V7.types.ResolvedTypeReference.primitive,unknown:rr.V7.types.ResolvedTypeReference.unknown,_unknown:()=>{throw new Error("Unknown ResolvedTypeReference: "+e._type)}})}function sRA(e){return{docs:e.docs,discriminantValue:e.discriminantValue,shape:cRA(e.shape)}}function cRA(e){return rr.V8.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>rr.V7.types.SingleUnionTypeProperties.samePropertiesAsObject(pNt(t)),singleProperty:t=>rr.V7.types.SingleUnionTypeProperties.singleProperty({name:t.name,type:RY(t.type)}),noProperties:rr.V7.types.SingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown SingleUnionTypeProperties: "+e._type)}})}function lRA(e){return{jsonExample:e.jsonExample,docs:e.docs,name:e.name,shape:TOc(e.shape)}}function TOc(e){return rr.V8.types.ExampleTypeShape._visit(e,{alias:t=>rr.V7.types.ExampleTypeShape.alias({value:kOe(t.value)}),enum:rr.V7.types.ExampleTypeShape.enum,object:t=>rr.V7.types.ExampleTypeShape.object({properties:t.properties.map(r=>({wireKey:r.wireKey,value:kOe(r.value),originalTypeDeclaration:pNt(r.originalTypeDeclaration)}))}),union:t=>rr.V7.types.ExampleTypeShape.union({wireDiscriminantValue:t.wireDiscriminantValue,properties:fRA(t.properties)}),_unknown:()=>{throw new Error("Unkonwn ExampleTypeShape: "+e.type)}})}function kOe(e){return{jsonExample:e.jsonExample,shape:Uog(e.shape)}}function Uog(e){return rr.V8.types.ExampleTypeReferenceShape._visit(e,{named:t=>rr.V7.types.ExampleTypeReferenceShape.named({typeName:pNt(t.typeName),shape:TOc(t.shape)}),container:t=>rr.V7.types.ExampleTypeReferenceShape.container(rr.V8.types.ExampleContainer._visit(t,{list:r=>rr.V7.types.ExampleContainer.list(r.map(n=>kOe(n))),set:r=>rr.V7.types.ExampleContainer.set(r.map(n=>kOe(n))),optional:r=>rr.V7.types.ExampleContainer.optional(r!=null?kOe(r):void 0),map:r=>rr.V7.types.ExampleContainer.map(r.map(n=>({key:kOe(n.key),value:kOe(n.value)}))),_unknown:()=>{throw new Error("Unknown ExampleContainer: "+t.type)}})),primitive:rr.V7.types.ExampleTypeReferenceShape.primitive,unknown:rr.V7.types.ExampleTypeReferenceShape.unknown,_unknown:()=>{throw new Error("Unknown ExampleTypeReferenceShape: "+e.type)}})}function fRA(e){return rr.V8.types.ExampleSingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>rr.V7.types.ExampleSingleUnionTypeProperties.samePropertiesAsObject({typeName:pNt(t.typeName),shape:TOc(t.shape)}),singleProperty:t=>rr.V7.types.ExampleSingleUnionTypeProperties.singleProperty({jsonExample:t.jsonExample,shape:Uog(t.shape)}),noProperties:rr.V7.types.ExampleSingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown ExampleSingleUnionTypeProperties: "+e.type)}})}function dRA(e){return{docs:e.docs,name:qOc(e.name),discriminantValue:e.discriminantValue,type:e.type!=null?RY(e.type):void 0,statusCode:e.statusCode}}function qOc(e){return{name:e.name,fernFilepath:xOc(e.fernFilepath)}}function pRA(e){return{docs:e.docs,availability:e.availability,name:{fernFilepath:xOc(e.name.fernFilepath)},displayName:e.displayName,basePath:e.basePath,baseUrl:e.baseUrl,pathParameters:e.pathParameters.map(t=>Vog(t)),headers:e.headers.map(t=>XCo(t)),endpoints:e.endpoints.map(t=>_RA(t))}}function Vog(e){return{availability:e.availability,docs:e.docs,name:e.name,valueType:RY(e.valueType)}}function _RA(e){return{docs:e.docs,availability:e.availability,name:e.name,displayName:e.displayName,errors:e.errors.map(t=>hRA(t)),auth:e.auth,method:e.method,path:e.path,pathParameters:e.pathParameters.map(t=>Vog(t)),sdkRequest:e.sdkRequest!=null?vRA(e.sdkRequest):void 0,requestBody:e.requestBody!=null?gRA(e.requestBody):void 0,response:mRA(e.response),headers:e.headers.map(t=>XCo(t)),queryParameters:e.queryParameters.map(t=>yRA(t)),examples:e.examples.map(t=>ORA(t))}}function hRA(e){return{docs:e.docs,error:qOc(e.error)}}function yRA(e){return{availability:e.availability,docs:e.docs,name:e.name,valueType:RY(e.valueType),allowMultiple:e.allowMultiple}}function vRA(e){return{requestParameterName:e.requestParameterName,shape:bRA(e.shape)}}function bRA(e){return rr.V8.http.SdkRequestShape._visit(e,{justRequestBody:t=>rr.V7.http.SdkRequestShape.justRequestBody({docs:t.docs,requestBodyType:RY(t.requestBodyType)}),wrapper:rr.V7.http.SdkRequestShape.wrapper,_unknown:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function gRA(e){return rr.V8.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>rr.V7.http.HttpRequestBody.inlinedRequestBody({name:t.name,extends:t.extends.map(r=>pNt(r)),properties:t.properties.map(r=>({docs:r.docs,name:r.name,valueType:RY(r.valueType)}))}),reference:t=>rr.V7.http.HttpRequestBody.reference({docs:t.docs,requestBodyType:RY(t.requestBodyType)}),_unknown:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function mRA(e){return{docs:e.docs,type:e.type!=null?RY(e.type):void 0}}function ORA(e){return{name:e.name,docs:e.docs,servicePathParameters:e.servicePathParameters.map(t=>Iog(t)),endpointPathParameters:e.endpointPathParameters.map(t=>Iog(t)),queryParameters:e.queryParameters.map(t=>PRA(t)),serviceHeaders:e.serviceHeaders.map(t=>Rog(t)),endpointHeaders:e.endpointHeaders.map(t=>Rog(t)),request:e.request!=null?jRA(e.request):void 0,response:wRA(e.response)}}function Iog(e){return{key:e.key,value:kOe(e.value)}}function PRA(e){return{wireKey:e.wireKey,value:kOe(e.value)}}function Rog(e){return{wireKey:e.wireKey,value:kOe(e.value)}}function jRA(e){return rr.V8.http.ExampleRequestBody._visit(e,{inlinedRequestBody:t=>rr.V7.http.ExampleRequestBody.inlinedRequestBody({jsonExample:t.jsonExample,properties:t.properties.map(r=>({wireKey:r.wireKey,value:kOe(r.value),originalTypeDeclaration:r.originalTypeDeclaration!=null?pNt(r.originalTypeDeclaration):void 0}))}),reference:t=>rr.V7.http.ExampleRequestBody.reference(kOe(t)),_unknown:()=>{throw new Error("Unknown ExampleRequestBody: "+e.type)}})}function wRA(e){return rr.V8.http.ExampleResponse._visit(e,{ok:t=>rr.V7.http.ExampleResponse.ok({body:t.body!=null?kOe(t.body):void 0}),error:t=>rr.V7.http.ExampleResponse.error({error:qOc(t.error),body:t.body!=null?kOe(t.body):void 0}),_unknown:()=>{throw new Error("Unknown ExampleResponse: "+e.type)}})}var Wog={laterVersion:"v9",earlierVersion:"v8",firstGeneratorVersionToConsumeNewIR:{[We.TYPESCRIPT_NODE_SDK]:fa,[We.TYPESCRIPT_BROWSER_SDK]:fa,[We.TYPESCRIPT]:Zr,[We.TYPESCRIPT_SDK]:"0.3.0-2-g85e8aa08",[We.TYPESCRIPT_EXPRESS]:"0.3.0-2-g85e8aa08",[We.JAVA]:Zr,[We.JAVA_MODEL]:"0.0.134-4-gef1ec4f",[We.JAVA_SDK]:"0.0.134-4-gef1ec4f",[We.JAVA_SPRING]:"0.0.134-4-gef1ec4f",[We.PYTHON_FASTAPI]:"0.0.51-1-g977dd1f",[We.PYTHON_PYDANTIC]:"0.0.51-1-g977dd1f",[We.OPENAPI_PYTHON_CLIENT]:Zr,[We.OPENAPI]:Zr,[We.STOPLIGHT]:fa,[We.POSTMAN]:Zr,[We.PYTHON_SDK]:fa,[We.GO_FIBER]:fa,[We.GO_MODEL]:fa,[We.GO_SDK]:fa,[We.RUBY_MODEL]:fa,[We.RUBY_SDK]:fa,[We.CSHARP_MODEL]:fa,[We.CSHARP_SDK]:fa,[We.SWIFT_MODEL]:fa,[We.SWIFT_SDK]:fa,[We.PHP_MODEL]:fa,[We.PHP_SDK]:fa},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,{taskContext:t,targetGenerator:r})=>{for(let[n,i]of Object.entries(e.types))i.shape._type==="union"&&i.shape.baseProperties.length>0&&t.failWithoutThrowing(r!=null?`Type ${i.name.name.originalName} uses base-properties. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains a union with base-properties.");return t.getResult()===E4.Failure&&t.failAndThrow(),{...e,types:Object.values(e.types),errors:Object.values(e.errors),services:Object.values(e.services)}}};function O9i(){return SRA}var QCo=class{migrations;constructor(t){this.migrations=t}withMigration(t){return new COc([...this.migrations,t])}},COc=class extends QCo{build(){return new AOc(this.migrations)}},AOc=class{migrations;constructor(t){this.migrations=t}migrateForGenerator({intermediateRepresentation:t,context:r,targetGenerator:n}){return this.migrate({intermediateRepresentation:t,shouldMigrate:i=>this.shouldRunMigration({migration:i,targetGenerator:n}),context:r,targetGenerator:n})}migrateThroughMigration({migration:t,intermediateRepresentation:r,context:n,targetGenerator:i}){return this.migrateThroughVersion({version:t.earlierVersion,intermediateRepresentation:r,context:n,targetGenerator:i})}migrateThroughVersion({version:t,intermediateRepresentation:r,context:n,targetGenerator:i}){var d;let a=!1;if(((d=this.migrations[0])==null?void 0:d.laterVersion)===t)return{ir:r,jsonify:()=>Promise.resolve().then(()=>Nv.IntermediateRepresentation.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}))};let f=this.migrate({intermediateRepresentation:r,shouldMigrate:c=>{let o=c.earlierVersion===t;return a||(a=o),o||!a},context:n,targetGenerator:i});return a||n.failAndThrow(`IR ${t} does not exist`),f}migrate({intermediateRepresentation:t,shouldMigrate:r,context:n,targetGenerator:i}){let a=t,u=async()=>await Nv.IntermediateRepresentation.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"});for(let f of this.migrations){if(!r(f))break;n.logger.debug(`Migrating IR from ${f.laterVersion} to ${f.earlierVersion}`),a=f.migrateBackwards(a,{taskContext:n,targetGenerator:i}),u=()=>Promise.resolve().then(()=>f.jsonifyEarlierVersion(a))}return{ir:a,jsonify:u}}shouldRunMigration({migration:t,targetGenerator:r}){let n=t.firstGeneratorVersionToConsumeNewIR[r.name];if(n==null)throw new Error(`Cannot migrate intermediate representation. Unrecognized generator: ${r.name}. If leveraging a custom generator, ensure you are specifying "ir-version" within the generator configuration.`);switch(n){case Zr:return!0;case fa:throw new Error(`Cannot migrate intermediate representation. Generator was created after intermediate representation ${t.laterVersion}.`)}return One(n,r.version)}},DRA={Builder:new QCo([])},SRA=DRA.Builder.withMigration(Dog).withMigration(pog).withMigration(oog).withMigration(eog).withMigration(Uag).withMigration(Fag).withMigration(Rag).withMigration(zag).withMigration(Cag).withMigration(qag).withMigration(xag).withMigration(Mag).withMigration(Eag).withMigration(Sag).withMigration(mag).withMigration(gag).withMigration(bag).withMigration(vag).withMigration(yag).withMigration(hag).withMigration(_ag).withMigration(dag).withMigration(lag).withMigration(cag).withMigration(aag).withMigration(Zig).withMigration(Qig).withMigration(Xig).withMigration(Kig).withMigration(Gig).withMigration(Ns0).withMigration(qs0).withMigration(Ts0).withMigration(Es0).withMigration(ws0).withMigration(Ps0).withMigration(Os0).withMigration(ms0).withMigration(vs0).withMigration(_s0).withMigration(ps0).withMigration(ds0).withMigration(ls0).withMigration(bed).withMigration(Wog).withMigration(Fog).withMigration(Bog).withMigration(zog).withMigration(kag).withMigration(jag).withMigration(sag).withMigration(Ss0).build();function P9i({intermediateRepresentation:e,context:t,targetGenerator:r}){return O9i().migrateForGenerator({intermediateRepresentation:e,context:t,targetGenerator:r}).jsonify()}function NOc({intermediateRepresentation:e,context:t,targetGenerator:r,irVersion:n}){return O9i().migrateThroughVersion({version:n,intermediateRepresentation:e,context:t,targetGenerator:r}).jsonify()}function j9i({intermediateRepresentation:e,context:t,version:r}){return O9i().migrateThroughVersion({version:r,intermediateRepresentation:e,context:t}).jsonify()}var Hog=require("fs/promises"),$og=yu(require("path"),1);async function Jog({project:e,irFilepath:t,cliContext:r,generationLanguage:n,audiences:i,version:a,keywords:u,smartCasing:f,readme:d}){await Promise.all(e.apiWorkspaces.map(async c=>{await r.runTaskForWorkspace(c,async o=>{r.logger.info(`Generating IR for workspace ${c.workspaceName}`);let l=await c.toFernWorkspace({context:o}),g=await ERA({workspace:l,context:o,generationLanguage:n,keywords:u,smartCasing:f,disableExamples:!1,audiences:i,version:a,readme:d}),O=$og.default.resolve(t);await(0,Hog.writeFile)(O,await zwr(g,{pretty:!0})),o.logger.info(`Wrote IR to ${O}`)})}))}async function ERA({workspace:e,context:t,generationLanguage:r,audiences:n,keywords:i,smartCasing:a,disableExamples:u,version:f,readme:d}){let c=await CMa({workspace:e,context:t,generationLanguage:r,audiences:n,keywords:i,smartCasing:a,disableExamples:u,readme:d});return f==null?Nv.IntermediateRepresentation.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"}):j9i({intermediateRepresentation:c,version:f,context:t})}var Gog=require("fs/promises"),Kog=yu(require("path"),1);async function Yog({project:e,irFilepath:t,cliContext:r,sdkLanguage:n}){await Promise.all(e.apiWorkspaces.map(async i=>{await r.runTaskForWorkspace(i,async a=>{if(i instanceof P7n){a.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(i instanceof Vne))return;let u=await wen({context:a,specs:i.specs}),f=await Ytn({absoluteFilePathToWorkspace:i.absoluteFilePath,specs:u,taskContext:a}),d=Kog.default.resolve(t),c=await Ng.OpenApiIntermediateRepresentation.jsonOrThrow(f,{skipValidation:!0});await(0,Gog.writeFile)(d,await zwr(c,{pretty:!0})),a.logger.info(`Wrote IR to ${d}`)})}))}var ZCo=require("fs/promises");async function Qog({project:e,includeModels:t,cliContext:r}){await Promise.all(e.apiWorkspaces.map(async n=>{await r.runTaskForWorkspace(n,async i=>{n instanceof Vne?await xRA({workspace:n,context:i,includeModels:t}):i.logger.warn("Skipping fern workspace definition generation")})}))}async function MRA(e,t){let r=null;try{let n=(await(0,ZCo.readFile)(e,"utf8")).toString();try{r=JSON.parse(n)}catch{r=av.load(n,{json:!0})}}catch{return t.failAndThrow(`Failed to read OpenAPI overrides from file ${e}`)}return r}async function xRA({workspace:e,includeModels:t,context:r}){let n=await wen({context:r,specs:e.specs});for(let i of n){let a=await Ytn({absoluteFilePathToWorkspace:e.absoluteFilePath,specs:[i],taskContext:r}),u={};i.absoluteFilepathToOverrides!==void 0&&(u=await MRA(i.absoluteFilepathToOverrides,r));let f="path"in u?u.path:{};for(let o of a.endpoints){let l=F0i(o);o.path in f||(f[o.path]={});let g=f[o.path];if(g!=null&&g[o.method]==null){let O=l.file.split("/").map(S=>S.replace(".yml","")).filter(S=>S!=="__package__"),j={};O.length>0&&(j["x-fern-sdk-group-name"]=O),j["x-fern-sdk-method-name"]=l.endpointId,g[o.method.toLowerCase()]=j}else u==null&&r.logger.warn(`Endpoint ${o.path} ${o.method} is defined multiple times`)}let d="path"in u?u.path:{};if(t){Xog(d,a.groupedSchemas.rootSchemas);for(let[o,l]of Object.entries(a.groupedSchemas.namespacedSchemas))Xog(d,l)}let c={schemas:d};await(0,ZCo.writeFile)(pf(Cg(i.absoluteFilepath),zs.of("openapi-overrides.yml")),av.dump({paths:f,components:c}))}}function Xog(e,t){for(let[r,n]of Object.entries(t)){if(r in e)continue;let i={};i["x-fern-type-name"]="nameOverride"in n?n.nameOverride??r:r,e[r]=i}}var kCo="api",Zog="group";var kog=".preview";var ypg=yu(NP(),1),iqt=yu(dpg(),1),uEe=yu(cC(),1);var fGr=yu(require("path"),1),gjn="/fern",mjn=fGr.default.join(gjn,"output"),YPc=fGr.default.join(gjn,"config.json"),O6o=fGr.default.join(gjn,"ir.json"),Q9i=fGr.default.join(gjn,"snippet.json"),Z9i=fGr.default.join(gjn,"snippet-templates.json"),JvB=fGr.default.join(gjn,"generators"),ppg=fGr.default.join(gjn,"sources");var U$A="0.0.1";function _pg(e){return e!=null?ypg.GithubPublishInfo._visit(e,{npm:t=>iqt.FernGeneratorExec.GithubPublishInfo.npm({registryUrl:t.registryUrl,packageName:t.packageName,tokenEnvironmentVariable:(0,uEe.EnvironmentVariable)(t.token??"")}),maven:t=>{var r,n;return iqt.FernGeneratorExec.GithubPublishInfo.maven({registryUrl:t.registryUrl,coordinate:t.coordinate,usernameEnvironmentVariable:(0,uEe.EnvironmentVariable)(((r=t.credentials)==null?void 0:r.username)??""),passwordEnvironmentVariable:(0,uEe.EnvironmentVariable)(((n=t.credentials)==null?void 0:n.password)??""),signature:t.signature!=null?{keyIdEnvironmentVariable:(0,uEe.EnvironmentVariable)(t.signature.keyId??""),passwordEnvironmentVariable:(0,uEe.EnvironmentVariable)(t.signature.password??""),secretKeyEnvironmentVariable:(0,uEe.EnvironmentVariable)(t.signature.secretKey??"")}:void 0})},pypi:t=>{var r,n;return iqt.FernGeneratorExec.GithubPublishInfo.pypi({registryUrl:t.registryUrl,packageName:t.packageName,usernameEnvironmentVariable:(0,uEe.EnvironmentVariable)(((r=t.credentials)==null?void 0:r.username)??""),passwordEnvironmentVariable:(0,uEe.EnvironmentVariable)(((n=t.credentials)==null?void 0:n.password)??"")})},rubygems:t=>iqt.FernGeneratorExec.GithubPublishInfo.rubygems({registryUrl:t.registryUrl,packageName:t.packageName,apiKeyEnvironmentVariable:(0,uEe.EnvironmentVariable)(t.apiKey??"")}),postman:t=>iqt.FernGeneratorExec.GithubPublishInfo.postman({apiKeyEnvironmentVariable:(0,uEe.EnvironmentVariable)(t.apiKey??""),workspaceIdEnvironmentVariable:(0,uEe.EnvironmentVariable)(t.workspaceId??"")}),nuget:t=>iqt.FernGeneratorExec.GithubPublishInfo.nuget({registryUrl:t.registryUrl,packageName:t.packageName,apiKeyEnvironmentVariable:(0,uEe.EnvironmentVariable)(t.apiKey??"")}),_other:()=>{}}):void 0}function vpg({generatorInvocation:e,customConfig:t,workspaceName:r,organization:n,outputVersion:i=U$A,absolutePathToSnippet:a,absolutePathToSnippetTemplates:u,writeUnitTests:f,generateOauthClients:d,generatePaginatedClients:c}){let o=[],l=e.outputMode._visit({publish:g=>({...hpg(i,g),publishingMetadata:e.publishMetadata}),publishV2:g=>({...hpg(i,g),publishingMetadata:e.publishMetadata}),downloadFiles:()=>({mode:iqt.FernGeneratorExec.OutputMode.downloadFiles(),path:mjn,publishingMetadata:e.publishMetadata}),github:g=>{let O={mode:iqt.FernGeneratorExec.OutputMode.github({repoUrl:`https://github.com/${g.owner}/${g.repo}`,version:i,publishInfo:_pg(g.publishInfo),installationToken:void 0}),path:mjn,publishingMetadata:e.publishMetadata};return a!==void 0&&(o.push(`${a}:${Q9i}`),O.snippetFilepath=Q9i),u!==void 0&&(o.push(`${u}:${Z9i}`),O.snippetTemplateFilepath=Z9i),O},githubV2:g=>{let O=g._visit({commitAndRelease:S=>`https://github.com/${S.owner}/${S.repo}`,push:S=>`https://github.com/${S.owner}/${S.repo}`,pullRequest:S=>`https://github.com/${S.owner}/${S.repo}`,_other:()=>{throw new Error("Encountered unknown github mode")}}),j={mode:iqt.FernGeneratorExec.OutputMode.github({repoUrl:O,version:i,publishInfo:_pg(g.publishInfo)}),path:mjn,publishingMetadata:e.publishMetadata};return a!==void 0&&(o.push(`${a}:${Q9i}`),j.snippetFilepath=Q9i),u!==void 0&&(o.push(`${u}:${Z9i}`),j.snippetTemplateFilepath=Z9i),j},_other:()=>{throw new Error("Output type did not match any of the types supported by Fern")}});return{binds:o,config:{irFilepath:O6o,output:l,publish:void 0,customConfig:t,workspaceName:r,organization:n,environment:iqt.FernGeneratorExec.GeneratorEnvironment.local(),dryRun:!1,whitelabel:!1,writeUnitTests:f,generateOauthClients:d,generatePaginatedClients:c}}}function hpg(e,t){let r;return"registryOverrides"in t?r=t.registryOverrides.maven??t.registryOverrides.npm:r!=null&&(r=t._visit({mavenOverride:n=>n,npmOverride:n=>n,pypiOverride:n=>n,rubyGemsOverride:n=>n,postman:n=>n,nugetOverride:n=>n,_other:()=>{}})),{mode:iqt.FernGeneratorExec.OutputMode.publish({registries:{maven:{group:"",password:(r==null?void 0:r.password)??"",registryUrl:(r==null?void 0:r.registryUrl)??"",username:(r==null?void 0:r.username)??""},npm:{registryUrl:(r==null?void 0:r.registryUrl)??"",scope:"",token:(r==null?void 0:r.token)??""}},publishTarget:void 0,registriesV2:{maven:{password:(r==null?void 0:r.password)??"",registryUrl:(r==null?void 0:r.registryUrl)??"",username:(r==null?void 0:r.username)??"",coordinate:(r==null?void 0:r.coordinate)??"",signature:r==null?void 0:r.signature},npm:{registryUrl:(r==null?void 0:r.registryUrl)??"",token:(r==null?void 0:r.token)??"",packageName:(r==null?void 0:r.packageName)??""},pypi:{packageName:(r==null?void 0:r.coordinate)??"",password:(r==null?void 0:r.password)??"",registryUrl:(r==null?void 0:r.registryUrl)??"",username:(r==null?void 0:r.username)??"",pypiMetadata:r==null?void 0:r.pypiMetadata},rubygems:{registryUrl:(r==null?void 0:r.registryUrl)??"",apiKey:(r==null?void 0:r.apiKey)??"",packageName:(r==null?void 0:r.packageName)??""},nuget:{registryUrl:(r==null?void 0:r.registryUrl)??"",apiKey:(r==null?void 0:r.apiKey)??"",packageName:(r==null?void 0:r.packageName)??""}},version:e}),path:mjn}}async function bpg({workspace:e,audiences:t,generatorInvocation:r,context:n,irVersionOverride:i,version:a,packageName:u,sourceConfig:f}){let d=await JQ({workspace:e,audiences:t,generationLanguage:r.language,keywords:r.keywords,smartCasing:r.smartCasing,disableExamples:r.disableExamples,readme:r.readme,version:a,packageName:u,context:n});f!=null&&(d.sourceConfig=f),n.logger.debug("Generated IR");let c=i!=null?await j9i({intermediateRepresentation:d,context:n,version:i}):await P9i({intermediateRepresentation:d,context:n,targetGenerator:{name:r.name,version:r.version}});return{latest:d,migrated:c}}var G0g=yu(J0g(),1),K0g=require("fs/promises"),Y0g=require("stream"),X0g=yu(Kte(),1);async function uwc({imageName:e,args:t,binds:r,writeLogsToFile:n=!0,removeAfterCompletion:i=!1}){let a=new G0g.default,u=()=>hQA({docker:a,imageName:e,args:t,binds:r,removeAfterCompletion:i,writeLogsToFile:n});try{await u()}catch(f){if((f==null?void 0:f.statusCode)===404)await yQA(a,e),await u();else throw f}}async function hQA({docker:e,imageName:t,args:r,binds:n,removeAfterCompletion:i,writeLogsToFile:a}){let u="",[f,d]=await e.run(t,r??[],new Y0g.Writable({write(c,o,l){u+=c.toString(),setImmediate(l)}}),{HostConfig:{Binds:n},User:"root"});if(i&&await d.remove(),f.Error!=null)throw f.Error;if(f.StatusCode!==0)if(a){let c=await X0g.default.file();throw await(0,K0g.writeFile)(c.path,u),new Error(`Docker exited with a non-zero exit code. Logs here: ${c.path}`)}else throw new Error("Docker exited with a non-zero exit code.")}async function yQA(e,t){let r=await e.pull(t);await new Promise((n,i)=>{e.modem.followProgress(r,a=>{a!=null?i(a):n()})})}var k0g=yu(J_(),1),evg=require("fs/promises"),Vei=yu(Kte(),1);var Q0g=yu(KDa(),1),OPe=require("fs/promises"),Z0g=yu(Kte(),1),C7o=class{context;absolutePathToTmpOutputDirectory;absolutePathToTmpSnippetJSON;absolutePathToTmpSnippetTemplatesJSON;absolutePathToLocalSnippetTemplateJSON;absolutePathToLocalOutput;absolutePathToLocalSnippetJSON;constructor({context:t,absolutePathToTmpOutputDirectory:r,absolutePathToTmpSnippetJSON:n,absolutePathToLocalSnippetTemplateJSON:i,absolutePathToLocalOutput:a,absolutePathToLocalSnippetJSON:u,absolutePathToTmpSnippetTemplatesJSON:f}){this.context=t,this.absolutePathToLocalOutput=a,this.absolutePathToTmpOutputDirectory=r,this.absolutePathToTmpSnippetJSON=n,this.absolutePathToLocalSnippetJSON=u,this.absolutePathToLocalSnippetTemplateJSON=i,this.absolutePathToTmpSnippetTemplatesJSON=f}async copyGeneratedFiles(){await this.isFernIgnorePresent()?await this.copyGeneratedFilesWithFernIgnore():await this.copyGeneratedFilesNoFernIgnore(),this.absolutePathToTmpSnippetJSON!=null&&this.absolutePathToLocalSnippetJSON!=null&&await Vh(this.absolutePathToTmpSnippetJSON)&&await this.copySnippetJSON({absolutePathToTmpSnippetJSON:this.absolutePathToTmpSnippetJSON,absolutePathToLocalSnippetJSON:this.absolutePathToLocalSnippetJSON}),this.absolutePathToTmpSnippetTemplatesJSON!=null&&this.absolutePathToLocalSnippetTemplateJSON!=null&&await Vh(this.absolutePathToTmpSnippetTemplatesJSON)&&await this.copySnippetJSON({absolutePathToTmpSnippetJSON:this.absolutePathToTmpSnippetTemplatesJSON,absolutePathToLocalSnippetJSON:this.absolutePathToLocalSnippetTemplateJSON})}async isFernIgnorePresent(){let t=R_.of(pf(this.absolutePathToLocalOutput,zs.of(IGi)));return await Vh(t)}async copyGeneratedFilesWithFernIgnore(){let t=R_.of((await Z0g.default.dir({})).path),r=R_.of(pf(this.absolutePathToLocalOutput,zs.of(IGi))),n=await bQA({absolutePathToFernignore:r});await(0,OPe.cp)(this.absolutePathToLocalOutput,t,{recursive:!0}),await this.runGitCommand(["init"],t),await this.runGitCommand(["add","."],t),(await this.runGitCommand(["config","--list"],t)).includes("user.name")||(await this.runGitCommand(["config","user.name","fern-api"],t),await this.runGitCommand(["config","user.email","info@buildwithfern.com"],t)),await this.runGitCommand(["commit","--allow-empty","-m",'"init"'],t),await this.runGitCommand(["rm","-rf","."],t),await this.copyGeneratedFilesToDirectory(t),await this.runGitCommand(["reset","--",...n],t),await this.runGitCommand(["restore","."],t),await(0,OPe.rmdir)(this.absolutePathToLocalOutput,{recursive:!0}),await(0,OPe.cp)(t,this.absolutePathToLocalOutput,{recursive:!0})}async copyGeneratedFilesNoFernIgnore(){this.context.logger.debug(`rm -rf ${this.absolutePathToLocalOutput}`),await(0,OPe.rm)(this.absolutePathToLocalOutput,{force:!0,recursive:!0}),await this.copyGeneratedFilesToDirectory(this.absolutePathToLocalOutput)}async copyGeneratedFilesToDirectory(t){let[r,...n]=await(0,OPe.readdir)(this.absolutePathToTmpOutputDirectory);if(r!=null)if(this.context.logger.debug(`Copying generated files to ${t}`),r.endsWith(".zip")){await(0,Q0g.default)(pf(this.absolutePathToTmpOutputDirectory,zs.of(r)),t);for(let i of n)await(0,OPe.cp)(pf(this.absolutePathToTmpOutputDirectory,zs.of(i)),pf(t,zs.of(i)),{recursive:!0})}else await(0,OPe.cp)(this.absolutePathToTmpOutputDirectory,t,{recursive:!0})}async copySnippetJSON({absolutePathToTmpSnippetJSON:t,absolutePathToLocalSnippetJSON:r}){this.context.logger.debug(`Copying generated snippets to ${r}`),await(0,OPe.cp)(t,r)}async runGitCommand(t,r){return(await $je(this.context.logger,"git",t,{cwd:r,doNotPipeOutput:!0})).stdout}},vQA=/\r?\n/;async function bQA({absolutePathToFernignore:e}){let t=(await(0,OPe.readFile)(e)).toString();return[IGi,...t.trim().split(vQA).filter(r=>!r.startsWith("#")&&r.length>0)]}async function tvg({organization:e,workspace:t,generatorInvocation:r,absolutePathToLocalOutput:n,absolutePathToLocalSnippetJSON:i,absolutePathToLocalSnippetTemplateJSON:a,absolutePathToFernConfig:u,audiences:f,workspaceTempDir:d,keepDocker:c,context:o,irVersionOverride:l,outputVersionOverride:g,writeUnitTests:O,generateOauthClients:j,generatePaginatedClients:S}){let{latest:x,migrated:A}=await bpg({workspace:t,audiences:f,generatorInvocation:r,context:o,irVersionOverride:l,packageName:pg.getPackageName({generatorInvocation:r}),version:g,sourceConfig:OQA(t)}),z=await gQA({workspaceTempDir:d,context:o,ir:A});o.logger.debug("Wrote IR to: "+z);let N=await Vei.default.file({tmpdir:d.path}),C=R_.of(N.path);o.logger.debug("Will write config.json to: "+C);let U=await Vei.default.dir({tmpdir:d.path}),Y=R_.of(U.path);o.logger.debug("Will write output to: "+Y);let te;if(i!=null){let ee=await Vei.default.file({tmpdir:d.path});te=R_.of(ee.path),o.logger.debug("Will write snippet.json to: "+te)}let G;if(a!=null){let ee=await Vei.default.file({tmpdir:d.path});G=R_.of(ee.path),o.logger.debug("Will write snippet-templates.json to: "+G)}return await mQA({absolutePathToOutput:Y,absolutePathToSnippet:te,absolutePathToSnippetTemplates:G,absolutePathToIr:z,absolutePathToWriteConfigJson:C,workspaceName:t.definition.rootApiFile.contents.name,organization:e,outputVersion:g,keepDocker:c,generatorInvocation:r,context:o,writeUnitTests:O,generateOauthClients:j,generatePaginatedClients:S,sources:t.getSources()}),await new C7o({context:o,absolutePathToLocalOutput:n,absolutePathToTmpOutputDirectory:Y,absolutePathToLocalSnippetJSON:i,absolutePathToLocalSnippetTemplateJSON:a,absolutePathToTmpSnippetJSON:te,absolutePathToTmpSnippetTemplatesJSON:G}).copyGeneratedFiles(),{absolutePathToIr:z,absolutePathToConfigJson:C,ir:x}}async function gQA({ir:e,workspaceTempDir:t,context:r}){r.logger.debug("Migrated IR");let n=await Vei.default.file({tmpdir:t.path}),i=R_.of(n.path);return await esi(i,e,{pretty:!1}),r.logger.debug(`Wrote IR to ${i}`),i}async function mQA({workspaceName:e,organization:t,outputVersion:r,absolutePathToOutput:n,absolutePathToSnippet:i,absolutePathToSnippetTemplates:a,absolutePathToIr:u,absolutePathToWriteConfigJson:f,keepDocker:d,generatorInvocation:c,writeUnitTests:o,generateOauthClients:l,generatePaginatedClients:g,sources:O}){let{name:j,version:S,config:x}=c,A=`${j}:${S}`,z=[`${f}:${YPc}:ro`,`${u}:${O6o}:ro`,`${n}:${mjn}`];for(let te of O)z.push(`${te.absoluteFilePath}:${rvg(te)}:ro`);let{config:N,binds:C}=vpg({generatorInvocation:c,customConfig:x,workspaceName:e,outputVersion:r,organization:t,absolutePathToSnippet:i,absolutePathToSnippetTemplates:a,writeUnitTests:o,generateOauthClients:l,generatePaginatedClients:g});z.push(...C);let U=await k0g.GeneratorConfig.json(N);if(!U.ok)throw new Error(`Failed to parse config.json into ${f}`);if(await(0,evg.writeFile)(f,JSON.stringify(U.value,void 0,4)),!await SLo(f,5e3))throw new Error(`Failed to create ${f}`);await uwc({imageName:A,args:[YPc],binds:z,removeAfterCompletion:!d})}function OQA(e){return{sources:e.getSources().map(t=>t.type==="protobuf"?tne.proto({id:t.id,protoRootUrl:`file:///${rvg(t)}`}):tne.openapi())}}function rvg(e){return`${ppg}/${e.id}`}var swc=yu(require("os"),1),nvg=yu(require("path"),1),ivg=yu(Kte(),1);async function cwc({projectConfig:e,workspace:t,generatorGroup:r,keepDocker:n,context:i}){let a=await PQA();(await Promise.all(r.generators.map(async f=>i.runInteractiveTask({name:f.name},async d=>{if(f.absolutePathToLocalOutput==null)d.failWithoutThrowing("Cannot generate because output location is not local-file-system");else{let c=await t.toFernWorkspace({context:i},L0i(f));await tvg({organization:e.organization,absolutePathToFernConfig:e._absolutePath,workspace:c,generatorInvocation:f,absolutePathToLocalOutput:f.absolutePathToLocalOutput,absolutePathToLocalSnippetJSON:void 0,absolutePathToLocalSnippetTemplateJSON:void 0,audiences:r.audiences,workspaceTempDir:a,keepDocker:n,context:d,irVersionOverride:f.irVersionOverride,outputVersionOverride:void 0,writeUnitTests:!1,generateOauthClients:!1,generatePaginatedClients:!1}),d.logger.info(al.green("Wrote files to "+f.absolutePathToLocalOutput))}})))).some(f=>!f)&&i.failAndThrow()}async function PQA(){return ivg.default.dir({tmpdir:swc.default.platform()==="darwin"?nvg.default.join("/private",swc.default.tmpdir()):void 0,prefix:"fern"})}var F7o=yu(PZr(),1);var avg=yu(vRt(),1);var ovg=require("fs"),A7o=require("fs/promises"),uvg=require("stream/promises");async function svg({snippetsS3PreSignedReadUrl:e,absolutePathToLocalSnippetJSON:t,context:r}){try{await jQA({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}),r.logger.info(al.green(`Downloaded to ${t}`))}catch{r.logger.debug(al.yellow("Failed to download snippet.json from output."))}}async function jQA({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await avg.default.get(e,{responseType:"stream"});await Vh(t)&&await(0,A7o.rm)(t,{recursive:!0}),await(0,A7o.mkdir)(Cg(t),{recursive:!0}),await(0,uvg.pipeline)(r.data,(0,ovg.createWriteStream)(t))}var Wei=yu(PZr(),1),LLi=yu(vRt(),1),cvg=yu(A3r(),1),PPe=require("fs/promises");var lvg=require("path"),fvg=yu(f0a(),1),dvg=yu(Kte(),1);async function pvg({projectConfig:e,workspace:t,organization:r,intermediateRepresentation:n,generatorInvocation:i,version:a,context:u,shouldLogS3Url:f,token:d,whitelabel:c,irVersionOverride:o,absolutePathToPreview:l}){let g=await wQA({projectConfig:e,workspace:t,organization:r,generatorInvocation:i,version:a,context:u,shouldLogS3Url:f,token:d,whitelabel:c,absolutePathToPreview:l});return await DQA({intermediateRepresentation:n,job:g,context:u,generatorInvocation:i,irVersionOverride:o}),g}async function wQA({projectConfig:e,workspace:t,organization:r,generatorInvocation:n,version:i,context:a,shouldLogS3Url:u,token:f,whitelabel:d,absolutePathToPreview:c}){let o=ZDr({token:f.value}),l={id:n.name,version:n.version,outputMode:n.outputMode,customConfig:n.config,publishMetadata:n.publishMetadata},g;if(n.outputMode.type.startsWith("github"))try{let j=await dvg.default.dir(),S=R_.of(j.path);a.logger.debug(`Writing mock fern definition to ${S}`);let x=pf(S,zs.of(Qqt)),A=pf(x,zs.of(p9));await(0,PPe.mkdir)(A,{recursive:!0});let z=pf(A,zs.of(iB));await(0,PPe.writeFile)(z,av.dump(t.definition.rootApiFile.contents)),await _vg({absolutePathToDefinitionDirectory:A,definition:t.definition});let N=pf(x,zs.of(N8t));await(0,PPe.writeFile)(N,JSON.stringify(e.rawConfig,void 0,2));try{let Y=t.getSources();for(let te of Y){let G=await(0,PPe.readFile)(te.absoluteFilePath),$=(0,lvg.relative)(t.absoluteFilePath,te.absoluteFilePath),ee=pf(x,zs.of($));await(0,PPe.mkdir)(Cg(ee),{recursive:!0}),await(0,PPe.writeFile)(ee,G)}}catch(Y){a.logger.debug(`Failed to write source files to disk, continuing: ${Y}`)}let C=pf(S,zs.of("definition.tgz"));await fvg.default.create({file:C,cwd:x},["."]),a.logger.debug("Getting upload URL for Fern definition.");let U=await o.remoteGen.getDefinitionUploadUrl({apiName:t.definition.rootApiFile.contents.name,organizationName:r,version:i});U.ok?(a.logger.debug("Uploading definition..."),await LLi.default.put(U.body.s3Url,await(0,PPe.readFile)(C)),g={definitionS3DownloadUrl:U.body.s3Url,outputPath:".mock",cliVersion:e.version}):U.error.content.reason==="status-code"?a.logger.debug(`Failed with status-code to get upload URL with status code ${U.error.content.statusCode}, continuing: ${U.error.content.body}`):U.error.content.reason==="non-json"?a.logger.debug(`Failed with non-json to get upload URL with status code ${U.error.content.statusCode}, continuing: ${U.error.content.rawBody}`):U.error.content.reason==="unknown"&&a.logger.debug(`Failed to get upload URL as unknown error occurred continuing: ${U.error.content.errorMessage}`)}catch(j){a.logger.debug(`Failed to upload definition to S3, continuing: ${j}`)}let O=await o.remoteGen.createJobV3({apiName:t.definition.rootApiFile.contents.name,version:i,organizationName:r,generators:[l],uploadToS3:EQA({outputMode:n.outputMode,generatorInvocation:n,absolutePathToPreview:c,shouldLogS3Url:u}),whitelabel:d,fernDefinitionMetadata:g,preview:c!=null});return O.ok?O.body:SQA(O.error)._visit({illegalApiNameError:()=>a.failAndThrow("API name is invalid: "+t.definition.rootApiFile.contents.name),illegalApiVersionError:()=>a.failAndThrow("API version is invalid: "+i),cannotPublishToNpmScope:({validScope:j,invalidScope:S})=>a.failAndThrow(`You do not have permission to publish to ${S} (expected ${j})`),cannotPublishToMavenGroup:({validGroup:j,invalidGroup:S})=>a.failAndThrow(`You do not have permission to publish to ${S} (expected ${j})`),cannotPublishPypiPackage:({validPrefix:j,invalidPackageName:S})=>a.failAndThrow(`You do not have permission to publish to ${S} (expected ${j})`),generatorsDoNotExistError:j=>a.failAndThrow("Generators do not exist: "+j.nonExistentGenerators.map(S=>`${S.id}@${S.version}`).join(", ")),insufficientPermissions:()=>a.failAndThrow("Insufficient permissions."),orgNotConfiguredForWhitelabel:()=>a.failAndThrow("Your org is not configured for white-labeling. Please reach out to support@buildwithfern.com."),_other:j=>a.failAndThrow("Failed to create job",j)})}async function _vg({absolutePathToDefinitionDirectory:e,definition:t}){for(let[r,n]of Object.entries(t.namedDefinitionFiles)){let i=pf(e,zs.of(r));await(0,PPe.mkdir)(Cg(i),{recursive:!0}),await(0,PPe.writeFile)(i,av.dump(n.contents))}for(let[r,n]of Object.entries(t.packageMarkers))if(n.contents.export==null){let i=pf(e,zs.of(r));await(0,PPe.mkdir)(Cg(i),{recursive:!0}),await(0,PPe.writeFile)(i,av.dump(n.contents))}for(let[r,n]of Object.entries(t.importedDefinitions))await _vg({absolutePathToDefinitionDirectory:pf(e,zs.of(r)),definition:n.definition})}async function DQA({intermediateRepresentation:e,generatorInvocation:t,job:r,context:n,irVersionOverride:i}){var c;let a=i==null?await P9i({intermediateRepresentation:e,context:n,targetGenerator:{name:t.name,version:t.version}}):await NOc({intermediateRepresentation:e,context:n,irVersion:i,targetGenerator:{name:t.name,version:t.version}}),u=new cvg.default,f=await zwr(a,{onWrite:o=>{n.logger.debug("Wrote IR to disk: "+o)}});u.append("file",f);let d=$S(cXo(),`/api/remote-gen/jobs/${r.jobId}/start`);try{await LLi.default.post(d,u,{headers:u.getHeaders(),maxBodyLength:1/0})}catch(o){let l=o instanceof LLi.AxiosError?(c=o.response)==null?void 0:c.data:o;n.logger.debug(`POST ${d} failed with ${JSON.stringify(o)}`),n.failAndThrow("Failed to start job",l)}}function SQA(e){if((e==null?void 0:e.reason)==="status-code"){let t=e.body;switch(t==null?void 0:t._error){case"IllegalApiNameError":return Wei.FernFiddle.remoteGen.createJobV3.Error.illegalApiNameError();case"GeneratorsDoNotExistError":return Wei.FernFiddle.remoteGen.createJobV3.Error.generatorsDoNotExistError(t.body);case"CannotPublishToNpmScope":return Wei.FernFiddle.remoteGen.createJobV3.Error.cannotPublishToNpmScope(t.body);case"CannotPublishToMavenScope":return Wei.FernFiddle.remoteGen.createJobV3.Error.cannotPublishToMavenGroup(t.body);case"InsufficientPermissions":return Wei.FernFiddle.remoteGen.createJobV3.Error.insufficientPermissions(t.body)}}return e}function EQA({outputMode:e,generatorInvocation:t,absolutePathToPreview:r,shouldLogS3Url:n}){return e.type==="downloadFiles"||t.absolutePathToLocalSnippets!=null||r!=null||n}var hvg=ZDr();var MQA=3;function yvg({job:e,taskId:t,taskHandler:r,context:n}){let i=0,a=async()=>{let u=await hvg.remoteGen.getJobStatus(e.jobId);if(u.ok)return u.body[t];n.logger.debug("Failed to get job status.",JSON.stringify(u.error.content))};return new Promise((u,f)=>{d();async function d(){try{let c=await a();if(c==null)i++,i===MQA&&n.failAndThrow(`Failed to get job status after ${i} attempts.`),setTimeout(d,2e3+1e3*i);else{i=0;let o=await r.processUpdate(c);r.isFinished?u(o):setTimeout(d,2e3)}}catch(c){f(c)}}})}var mvg=yu(vRt(),1);var Ovg=yu(KDa(),1),Pvg=require("fs"),B7o=require("fs/promises"),fwc=yu(require("path"),1),jvg=require("stream/promises");var N7o=yu(gvg(),1);function xAr(e,t,{target:r="stdout",...n}={}){return N7o.default[r]?C6n.link(e,t):n.fallback===!1?e:typeof n.fallback=="function"?n.fallback(e,t):`${e} (\u200B${t}\u200B)`}xAr.isSupported=N7o.default.stdout;xAr.stderr=(e,t,r={})=>xAr(e,t,{target:"stderr",...r});xAr.stderr.isSupported=N7o.default.stderr;var wvg=yu(Kte(),1);var $ei,Jei,Gei,z7o=class{constructor({interactiveTaskContext:t,generatorInvocation:r,absolutePathToPreview:n}){dv(this,"context");dv(this,"generatorInvocation");dv(this,"absolutePathToPreview");dv(this,"lengthOfLastLogs",0);lh(this,$ei,!1);lh(this,Jei,!1);lh(this,Gei,void 0);this.context=t,this.generatorInvocation=r,this.absolutePathToPreview=n}async processUpdate(t){t==null&&this.context.failAndThrow("Task is missing on job status");let r=t.packages.map(i=>i.coordinate._visit({npm:a=>`${a.name}@${a.version}`,maven:a=>`${a.group}:${a.artifact}:${a.version}`,pypi:a=>`${a.name} ${a.version}`,ruby:a=>`${a.name}:${a.version}`,nuget:a=>`${a.name} ${a.version}`,_other:()=>"<unknown package>"}));this.absolutePathToPreview==null&&this.context.setSubtitle(r.length>0?r.map(i=>`\u25E6 ${i}`).join(`
2269
- `):void 0);for(let i of t.logs.slice(this.lengthOfLastLogs))this.context.logger.log(CQA(i.level),i.message);this.lengthOfLastLogs=t.logs.length;let n=i=>{this.context.logger.debug(`Generated files. ${xAr("View here",i,{fallback:(a,u)=>`${a}: ${u}`})}`)};return await t.status._visit({notStarted:vf,running:vf,failed:({message:i,s3PreSignedReadUrl:a})=>{a!=null&&n(a),this.context.failAndThrow(i)},finished:async i=>{if(i.s3PreSignedReadUrlV2!=null){n(i.s3PreSignedReadUrlV2);let a=this.getAbsolutePathToLocalOutput();a!=null&&await TQA({s3PreSignedReadUrl:i.s3PreSignedReadUrlV2,absolutePathToLocalOutput:a,context:this.context})}if(this.absolutePathToPreview==null)for(let a of r)this.context.logger.info(`Published ${a}`);pv(this,$ei,!0),pv(this,Jei,i.createdSnippets!=null?i.createdSnippets:!1),pv(this,Gei,i.snippetsS3PreSignedReadUrl)},_other:()=>{this.context.logger.warn("Received unknown update type: "+t.status.type)}}),yc(this,$ei)?{createdSnippets:yc(this,Jei),snippetsS3PreSignedReadUrl:yc(this,Gei)}:void 0}getAbsolutePathToLocalOutput(){return this.absolutePathToPreview!=null?pf(this.absolutePathToPreview,zs.of(fwc.default.basename(this.generatorInvocation.name))):this.generatorInvocation.absolutePathToLocalOutput}get isFinished(){return yc(this,$ei)}get createdSnippets(){return yc(this,Jei)}get snippetsS3PreSignedReadUrl(){return yc(this,Gei)}};$ei=new WeakMap,Jei=new WeakMap,Gei=new WeakMap;async function TQA({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t,context:r}){try{await qQA({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}),r.logger.info(al.green(`Downloaded to ${t}`))}catch(n){r.failAndThrow("Failed to download files",n)}}async function qQA({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await mvg.default.get(e,{responseType:"stream"}),n=await wvg.default.dir({prefix:"fern",unsafeCleanup:!0}),i=fwc.default.join(n.path,"output.zip");await(0,jvg.pipeline)(r.data,(0,Pvg.createWriteStream)(i)),await Vh(t)&&await(0,B7o.rm)(t,{recursive:!0}),await(0,B7o.mkdir)(t,{recursive:!0}),await(0,Ovg.default)(i,t)}function CQA(e){switch(e){case"DEBUG":return vM.Debug;case"INFO":return vM.Info;case"WARN":return vM.Warn;case"ERROR":return vM.Error;default:return vM.Info}}var R7o=require("fs/promises"),Dvg=yu(Kte(),1),AQA="proto.zip",I7o=class{sourceTypes;context;sources;constructor(t,r){this.context=t,this.sources=Object.fromEntries(r.map(n=>[n.id,n])),this.sourceTypes=new Set(Object.values(this.sources).map(n=>n.type))}async uploadSources(t){for(let[r,n]of Object.entries(t)){let i=this.getSourceOrThrow(r);await this.uploadSource(i,n.uploadUrl)}return this.convertFdrSourceUploadsToSourceConfig(t)}async uploadSource(t,r){let n=await this.getUploadCommand(t),i=await(0,R7o.readFile)(n.absoluteFilePath),a=await fetch(r,{method:"PUT",body:i,headers:{"Content-Type":"application/octet-stream"}});await n.cleanup(),a.ok||this.context.failAndThrow(`Failed to upload source file: ${t.absoluteFilePath}. Status: ${a.status}, ${a.statusText}`)}async getUploadCommand(t){if(t.type==="protobuf"){let r=await this.zipSource(t.absoluteFilePath);return{absoluteFilePath:r,cleanup:async()=>{this.context.logger.debug(`Removing ${r}`),await(0,R7o.unlink)(r)}}}return{absoluteFilePath:t.absoluteFilePath,cleanup:async()=>{}}}async zipSource(t){let r=await Dvg.default.dir(),n=pf(R_.of(r.path),zs.of(AQA));return this.context.logger.debug(`Zipping source ${t} into ${n}`),await $je(this.context.logger,"zip",["-r",n,"."],{cwd:t,doNotPipeOutput:!0}),n}convertFdrSourceUploadsToSourceConfig(t){let r=[];for(let[n,i]of Object.entries(t))switch(this.getSourceOrThrow(n).type){case"protobuf":r.push(tne.proto({id:n,protoRootUrl:i.downloadUrl}));continue;case"openapi":r.push(tne.openapi());continue;case"asyncapi":continue}return{sources:r}}getSourceOrThrow(t){let r=this.sources[t];return r==null&&this.context.failAndThrow(`Internal error; server responded with source id "${t}" which does not exist in the workspace.`),r}};async function Svg({projectConfig:e,organization:t,workspace:r,interactiveTaskContext:n,generatorInvocation:i,version:a,audiences:u,shouldLogS3Url:f,token:d,whitelabel:c,irVersionOverride:o,absolutePathToPreview:l,readme:g}){let O=BZr({token:d.value}),j=pg.getPackageName({generatorInvocation:i}),S=await JQ({workspace:r,generationLanguage:i.language,keywords:i.keywords,smartCasing:i.smartCasing,disableExamples:i.disableExamples,audiences:u,readme:g,packageName:j,version:a??await zQA({fdr:O,packageName:j,generatorInvocation:i}),context:n}),x=r.getSources(),A=dwe({ir:S,snippetsConfig:{}}),z=await O.api.v1.register.registerApiDefinition({orgId:t,apiId:S.apiName.originalName,definition:A,sources:x.length>0?BQA(x):void 0}),N,C;z.ok&&(N=z.body.apiDefinitionId,C=z.body.sources);let U=new I7o(n,x);if(C==null&&U.sourceTypes.has("protobuf")&&n.failAndThrow("Did not successfully upload Protobuf source files."),C!=null){n.logger.debug("Uploading source files ...");let Je=await U.uploadSources(C);n.logger.debug("Setting IR source configuration ..."),S.sourceConfig=Je}let Y=l!=null,te=Je=>cMn(Je,{onError:Dt=>n.failAndThrow(Dt)},{substituteAsEmpty:Y}),G=te(i),$=await pvg({projectConfig:e,workspace:r,organization:t,generatorInvocation:G,context:n,version:a,intermediateRepresentation:{...S,publishConfig:NQA({generatorInvocation:G})},shouldLogS3Url:f,token:d,whitelabel:c!=null?te(c):void 0,irVersionOverride:o,absolutePathToPreview:l});n.logger.debug(`Job ID: ${$.jobId}`);let ee=$.taskIds[0];if(ee==null){n.failAndThrow("Did not receive a task ID.");return}n.logger.debug(`Task ID: ${ee}`);let Ve=new z7o({job:$,taskId:ee,generatorInvocation:i,interactiveTaskContext:n,absolutePathToPreview:l});return await yvg({job:$,taskHandler:Ve,taskId:ee,context:n})}function NQA({generatorInvocation:e}){return e.outputMode._visit({downloadFiles:()=>{},github:()=>{},githubV2:()=>{},publish:()=>{},publishV2:t=>t._visit({mavenOverride:()=>{},pypiOverride:()=>{},nugetOverride:()=>{},npmOverride:()=>{},rubyGemsOverride:()=>{},postman:r=>{var i,a,u;let n;return((a=(i=e.raw)==null?void 0:i.output)==null?void 0:a.location)==="postman"&&(n=(u=e.raw.output)==null?void 0:u["collection-id"]),y_.PublishingConfig.direct({target:y_.PublishTarget.postman({apiKey:r.apiKey,workspaceId:r.workspaceId,collectionId:n})})},_other:()=>{}}),_other:()=>{}})}async function zQA({fdr:e,packageName:t,generatorInvocation:r}){if(r.language==null)return;let n;switch(r.language){case"csharp":n="Csharp";break;case"go":n="Go";break;case"java":n="Java";break;case"python":n="Python";break;case"ruby":n="Ruby";break;case"typescript":n="TypeScript";break;default:return}if(t==null)return;let i=await e.sdks.versions.computeSemanticVersion({githubRepository:r.outputMode.type==="githubV2"?`${r.outputMode.githubV2.owner}/${r.outputMode.githubV2.repo}`:void 0,language:n,package:t});if(!!i.ok)return i.body.version}function BQA(e){return Object.fromEntries(Object.values(e).map(t=>[t.id,{type:t.type==="protobuf"?"proto":t.type}]))}async function dwc({projectConfig:e,organization:t,workspace:r,context:n,generatorGroup:i,version:a,shouldLogS3Url:u,token:f,whitelabel:d,absolutePathToPreview:c,mode:o}){if(i.generators.length===0)return n.logger.warn("No generators specified."),null;let l=[],g=[];return l.push(...i.generators.map(j=>n.runInteractiveTask({name:j.name},async S=>{let x=await r.toFernWorkspace({context:n},L0i(j)),A=await Svg({projectConfig:e,organization:t,workspace:x,interactiveTaskContext:S,generatorInvocation:{...j,outputMode:j.outputMode._visit({downloadFiles:()=>j.outputMode,github:z=>F7o.FernFiddle.OutputMode.github({...z,makePr:o==="pull-request"}),githubV2:z=>o==="pull-request"?F7o.FernFiddle.OutputMode.githubV2(F7o.FernFiddle.GithubOutputModeV2.pullRequest(z)):j.outputMode,publish:()=>j.outputMode,publishV2:()=>j.outputMode,_other:()=>j.outputMode})},version:a,audiences:i.audiences,shouldLogS3Url:u,token:f,whitelabel:d,readme:j.readme,irVersionOverride:j.irVersionOverride,absolutePathToPreview:c});A!=null&&A.createdSnippets&&(g.push(j),j.absolutePathToLocalSnippets!=null&&A.snippetsS3PreSignedReadUrl!=null&&await svg({snippetsS3PreSignedReadUrl:A.snippetsS3PreSignedReadUrl,absolutePathToLocalSnippetJSON:j.absolutePathToLocalSnippets,context:S}))}))),(await Promise.all(l)).some(j=>!j)&&n.failAndThrow(),{snippetsProducedBy:g}}var ybg=yu(vRt(),1);var vbg=require("fs/promises");var qwc=yu(zci(),1);var cbg=yu(sbg(),1);var lbg=require("util"),_kA=(0,lbg.promisify)(cbg.default);async function fbg(e,t,r){let n=Fui(e,t),i=[];for(let a of n){let u=await Promise.all(a.map(async f=>{try{let d=await _kA(f);return d==null||d.height==null||d.width==null?void 0:{filePath:f,width:d.width,height:d.height,blurDataUrl:void 0}}catch(d){r.logger.error(`Failed to measure image size for ${f}. ${d==null?void 0:d.message}`);return}}));i.push(...u.filter(FS))}return new Map(i.map(a=>[a.filePath,a]))}var hkA=10,dbg=10;async function bbg({token:e,organization:t,docsWorkspace:r,domain:n,customDomains:i,fernWorkspaces:a,context:u,preview:f,editThisPage:d,isPrivate:c=!1}){let o=BZr({token:e.value}),l=c?{type:"private",authType:"sso"}:{type:"public"},g,O=i[0]??n,j=ykA(n),x=await new Prn(n,r,a,u,d,async z=>{let N=new Map(z.map($=>[$.absoluteFilePath,$])),U=z.map($=>({...$,mediaType:qwc.lookup($.absoluteFilePath)})).filter($=>$.mediaType!==!1).filter($=>{var ee;return((ee=sA.parse($.mediaType))==null?void 0:ee.isImage())??!1}).map($=>$.absoluteFilePath),Y=await fbg(U,hkA,u),te=[];[...Y.values()].forEach($=>{let ee=N.get($.filePath);if(ee==null)return;let Ve={filePath:RGi(ee.relativeFilePath),width:$.width,height:$.height,blurDataUrl:$.blurDataUrl};te.push(Ve)});let G=z.filter(({absoluteFilePath:$})=>!Y.has($)).map(({relativeFilePath:$})=>RGi($));if(f){let $=await o.docs.v2.write.startDocsPreviewRegister({orgId:t,authConfig:c?{type:"private",authType:"sso"}:{type:"public"},filepaths:G,images:te,basePath:j});return $.ok?(O=$.body.previewUrl,g=$.body.docsRegistrationId,await pbg($.body.uploadUrls,r.absoluteFilePath,u,dbg),_bg($.body.uploadUrls,r.absoluteFilePath)):await hbg($.error,u)}else{let $=await o.docs.v2.write.startDocsRegister({domain:n,customDomains:i,authConfig:l,apiId:"",orgId:t,filepaths:G,images:te});return $.ok?(g=$.body.docsRegistrationId,await pbg($.body.uploadUrls,r.absoluteFilePath,u,dbg),_bg($.body.uploadUrls,r.absoluteFilePath)):hbg($.error,u)}},async({ir:z,snippetsConfig:N,playgroundConfig:C,apiName:U})=>{let Y=dwe({ir:z,snippetsConfig:N,playgroundConfig:C});u.logger.debug("Calling registerAPI... ",JSON.stringify(Y,void 0,4));let te=await o.api.v1.register.registerApiDefinition({orgId:t,apiId:z.apiName.originalName,definition:Y});if(te.ok)return u.logger.debug(`Registered API Definition ${te.body.apiDefinitionId}`),te.body.apiDefinitionId;switch(te.error.error){case"UnauthorizedError":case"UserNotInOrgError":return u.failAndThrow("You do not have permissions to register the docs. Reach out to support@buildwithfern.com");default:return U!=null?u.failAndThrow(`Failed to register API ${U}`,te.error):u.failAndThrow("Failed to register API",te.error)}}).resolve();if(g==null)return u.failAndThrow("Failed to publish docs.","Docs registration ID is missing.");u.logger.debug("Calling registerDocs... ",JSON.stringify(x,void 0,4));let A=await o.docs.v2.write.finishDocsRegister(g,{docsDefinition:x});if(A.ok){let z=qEr(O),N=xAr(z,z);u.logger.info(al.green(`Published docs to ${N}`))}else switch(A.error.error){case"UnauthorizedError":case"UserNotInOrgError":return u.failAndThrow("Insufficient permissions. Failed to publish docs to "+n);case"DocsRegistrationIdNotFound":return u.failAndThrow("Failed to publish docs to "+n,`Docs registration ID ${g} does not exist.`);default:return u.failAndThrow("Failed to publish docs to "+n,A.error)}}async function pbg(e,t,r,n){let i=Date.now(),a=Object.keys(e).length;r.logger.debug(`Start uploading ${a} files...`);let u=Fui(Object.entries(e),n),f=0;for(let c of u){await Promise.all(c.map(async([l,{uploadUrl:g}])=>{let O=zs.of(l),j=w2(t,O);try{let S=qwc.lookup(j);await ybg.default.put(g,await(0,vbg.readFile)(j),{headers:{"Content-Type":S===!1?"application/octet-stream":S}})}catch(S){r.failAndThrow(`Failed to upload ${j}`,S)}}));let o=Date.now();f+=c.length,r.logger.debug(`Uploaded ${f}/${a} files in ${o-i}ms`)}let d=Date.now();r.logger.debug(`Finished uploading ${a} files in ${d-i}ms`)}function _bg(e,t){let r=[];for(let[n,i]of Object.entries(e)){let a=zs.of(n),u=w2(t,a);r.push({relativeFilePath:a,absoluteFilePath:u,fileId:i.fileId})}return r}async function hbg(e,t){switch(await t.instrumentPostHogEvent({command:"docs-generation",properties:{error:JSON.stringify(e)}}),e.error){case"InvalidCustomDomainError":return t.failAndThrow("Your docs domain should end with docs.buildwithfern.com");case"InvalidDomainError":return t.failAndThrow("Please make sure that none of your custom domains are not overlapping (i.e. one is a substring of another)");case"UnauthorizedError":return t.failAndThrow("Please make sure that your FERN_TOKEN is set.");case"UserNotInOrgError":return t.failAndThrow("Please verify if you have access to the organization you are trying to publish the docs to. If you are not a member of the organization, please reach out to the organization owner.");case"UnavailableError":return t.failAndThrow("Failed to publish docs. Please try again later or reach out to Fern support at support@buildwithfern.com.");default:return t.failAndThrow("Failed to publish docs.",e)}}function ykA(e){try{return new URL(qEr(e)).pathname}catch{return}}async function Cwc({organization:e,fernWorkspaces:t,docsWorkspace:r,context:n,token:i,instanceUrl:a,preview:u}){var o;let f=r.config.instances;if(r.config=cMn(r.config,{onError:l=>n.failAndThrow(l)},{substituteAsEmpty:u}),f.length===0){n.failAndThrow("No instances specified in docs.yml! Cannot register docs.");return}if(f.length>1&&a==null){n.failAndThrow(`More than one docs instances. Please specify one (e.g. --instance ${(o=f[0])==null?void 0:o.url})`);return}let d=f.find(l=>l.url===a)??f[0];if(d==null){n.failAndThrow(`No docs instance with url ${a}. Failed to register.`);return}let c=[];d.customDomain!=null&&(typeof d.customDomain=="string"?c.push(d.customDomain):Array.isArray(d.customDomain)&&c.push(...d.customDomain)),await n.runInteractiveTask({name:d.url},async()=>{await bbg({docsWorkspace:r,customDomains:c,domain:d.url,token:i,organization:e,context:n,fernWorkspaces:t,preview:u,audiences:d.audiences,editThisPage:d.editThisPage,isPrivate:d.private})})}async function gbg({organization:e,workspace:t,projectConfig:r,context:n,groupName:i,version:a,shouldLogS3Url:u,token:f,useLocalDocker:d,keepDocker:c,absolutePathToPreview:o,mode:l}){if(t.generatorsConfiguration==null){n.logger.warn("This workspaces has no generators.yml");return}if(t.generatorsConfiguration.groups.length===0){n.logger.warn(`This workspaces has no groups specified in ${a5}`);return}let g=i??t.generatorsConfiguration.defaultGroup;if(g==null)return n.failAndThrow(`No group specified. Use the --${Zog} option, or set "${jNc}" in ${a5}`);let O=t.generatorsConfiguration.groups.find(j=>j.groupName===g);if(O==null)return n.failAndThrow(`Group '${g}' does not exist.`);if(await UFt({workspace:await t.toFernWorkspace({context:n}),context:n,logWarnings:!1}),d)await cwc({projectConfig:r,workspace:t,generatorGroup:O,keepDocker:c,context:n});else{if(!f)return n.failAndThrow("Please run fern login");await dwc({projectConfig:r,organization:e,workspace:t,context:n,generatorGroup:O,version:a,shouldLogS3Url:u,token:f,whitelabel:t.generatorsConfiguration.whitelabel,absolutePathToPreview:o,mode:l})}}var mbg={PullRequest:"pull-request"};async function Awc({project:e,cliContext:t,version:r,groupName:n,shouldLogS3Url:i,keepDocker:a,useLocalDocker:u,preview:f,mode:d}){let c;if(!u){let o=await t.runTask(async l=>s2e(l));o.type==="user"&&await t.runTask(async l=>{await rSr({organization:e.config.organization,token:o,context:l})}),c=o}await t.instrumentPostHogEvent({orgId:e.config.organization,command:"fern generate",properties:{workspaces:e.apiWorkspaces.map(o=>{var l;return{name:o.workspaceName,group:n,generators:(l=o.generatorsConfiguration)==null?void 0:l.groups.filter(g=>n==null?!0:g.groupName===n).map(g=>g.generators.map(O=>({name:O.name,version:O.version,outputMode:O.outputMode.type,config:O.config})))}})}}),await Promise.all(e.apiWorkspaces.map(async o=>{await t.runTaskForWorkspace(o,async l=>{let g=f?pf(o.absoluteFilePath,zs.of(kog)):void 0;g!=null&&l.logger.info(`Writing preview to ${g}`),await gbg({organization:e.config.organization,workspace:o,projectConfig:e.config,context:l,version:r,groupName:n,shouldLogS3Url:i,token:c,useLocalDocker:u,keepDocker:a,absolutePathToPreview:g,mode:d})})}))}async function Obg({project:e,cliContext:t,instance:r,preview:n}){let i=e.docsWorkspaces;if(i==null)return;let a=await t.runTask(async u=>s2e(u));a.type==="user"&&await t.runTask(async u=>{await rSr({organization:e.config.organization,token:a,context:u})}),await t.instrumentPostHogEvent({orgId:e.config.organization,command:"fern generate --docs"}),await t.runTaskForWorkspace(i,async u=>{await qMa({workspace:i,context:u,logWarnings:!1,loadAPIWorkspace:e.loadAPIWorkspace});let f=await Promise.all(e.apiWorkspaces.map(async d=>d.toFernWorkspace({context:u},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1})));await Cwc({organization:e.config.organization,fernWorkspaces:f,docsWorkspace:i,context:u,token:a,instanceUrl:r,preview:n})})}var Nwc=yu(pju(),1);var Mjn=class{app=(0,Nwc.default)();context;server=void 0;port=void 0;constructor({context:t,ir:r,port:n}){this.context=t,this.app.use(Nwc.default.json({limit:"50mb",strict:!1})),this.port=n;let i=new Map;for(let d of Object.values(r.services))for(let c of d.endpoints){let o=vkA(c);t.logger.debug(`Registering ${c.method} ${o} ...`);let l=i.get(o)??new Map,g=l.get(c.method)??[];i.set(o,l.set(c.method,[...g,c]))}let a=(d,c)=>{let o=d[0],l=c[0],g=o.split("/"),O=l.split("/");if(g.length!==O.length)return g.length-O.length;for(let j=0;j<Math.min(g.length,O.length);j++){let S=g[j],x=O[j];if(S===x)continue;if(S==null||x==null)return S==null?-1:1;let A=S.startsWith(":"),z=x.startsWith(":");return A&&!z?1:!A&&z?-1:S.localeCompare(x)}return 0},f=Array.from(i).sort(a);for(let[d,c]of f)for(let[o,l]of c)switch(o){case"GET":this.app.get(d,VLi(l));break;case"POST":this.app.post(d,VLi(l));break;case"PUT":this.app.put(d,VLi(l));break;case"PATCH":this.app.patch(d,VLi(l));break;case"DELETE":this.app.delete(d,VLi(l));break}}stop(){var t;(t=this.server)==null||t.close()}async start(){return this.port=this.port??await Tpi(),this.server=this.app.listen(this.port),this.context.logger.info(`Running Fern mock server on localhost: ${this.port}`),this.port}async keepAlive(){await new Promise(()=>{})}};function vkA(e){let t="";e.fullPath.head.length>0&&(t=$S(t,e.fullPath.head));for(let r of e.fullPath.parts)t=$S(t,":"+r.pathParameter),r.tail.length>0&&(t=$S(t,r.tail));return t.startsWith("/")?t:`/${t}`}function VLi(e){let t=!1;return(r,n)=>{var i;for(let a of e)for(let u of[...a.autogeneratedExamples,...a.userSpecifiedExamples])if(t=!0,u.example!=null&&bkA(r,u.example)){(i=u.example.response)==null||i._visit({ok:f=>{f._visit({body:d=>{var c,o,l;if(d==null){n.sendStatus(((c=a.response)==null?void 0:c.statusCode)??204);return}if(((l=(o=a.response)==null?void 0:o.body)==null?void 0:l.type)==="text"){n.contentType("text/plain"),n.send(d.jsonExample);return}n.json(d.jsonExample)},stream:d=>{d.forEach(c=>{n.write(c.jsonExample)}),n.end()},sse:d=>{n.setHeader("Content-Type","text/event-stream"),d.forEach(c=>{n.write(`event: ${c.event}
2269
+ `):void 0);for(let i of t.logs.slice(this.lengthOfLastLogs))this.context.logger.log(CQA(i.level),i.message);this.lengthOfLastLogs=t.logs.length;let n=i=>{this.context.logger.debug(`Generated files. ${xAr("View here",i,{fallback:(a,u)=>`${a}: ${u}`})}`)};return await t.status._visit({notStarted:vf,running:vf,failed:({message:i,s3PreSignedReadUrl:a})=>{a!=null&&n(a),this.context.failAndThrow(i)},finished:async i=>{if(i.s3PreSignedReadUrlV2!=null){n(i.s3PreSignedReadUrlV2);let a=this.getAbsolutePathToLocalOutput();a!=null&&await TQA({s3PreSignedReadUrl:i.s3PreSignedReadUrlV2,absolutePathToLocalOutput:a,context:this.context})}if(this.absolutePathToPreview==null)for(let a of r)this.context.logger.info(`Published ${a}`);pv(this,$ei,!0),pv(this,Jei,i.createdSnippets!=null?i.createdSnippets:!1),pv(this,Gei,i.snippetsS3PreSignedReadUrl)},_other:()=>{this.context.logger.warn("Received unknown update type: "+t.status.type)}}),yc(this,$ei)?{createdSnippets:yc(this,Jei),snippetsS3PreSignedReadUrl:yc(this,Gei)}:void 0}getAbsolutePathToLocalOutput(){return this.absolutePathToPreview!=null?pf(this.absolutePathToPreview,zs.of(fwc.default.basename(this.generatorInvocation.name))):this.generatorInvocation.absolutePathToLocalOutput}get isFinished(){return yc(this,$ei)}get createdSnippets(){return yc(this,Jei)}get snippetsS3PreSignedReadUrl(){return yc(this,Gei)}};$ei=new WeakMap,Jei=new WeakMap,Gei=new WeakMap;async function TQA({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t,context:r}){try{await qQA({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}),r.logger.info(al.green(`Downloaded to ${t}`))}catch(n){r.failAndThrow("Failed to download files",n)}}async function qQA({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await mvg.default.get(e,{responseType:"stream"}),n=await wvg.default.dir({prefix:"fern",unsafeCleanup:!0}),i=fwc.default.join(n.path,"output.zip");await(0,jvg.pipeline)(r.data,(0,Pvg.createWriteStream)(i)),await Vh(t)&&await(0,B7o.rm)(t,{recursive:!0}),await(0,B7o.mkdir)(t,{recursive:!0}),await(0,Ovg.default)(i,t)}function CQA(e){switch(e){case"DEBUG":return vM.Debug;case"INFO":return vM.Info;case"WARN":return vM.Warn;case"ERROR":return vM.Error;default:return vM.Info}}var R7o=require("fs/promises"),Dvg=yu(Kte(),1),AQA="proto.zip",I7o=class{sourceTypes;context;sources;constructor(t,r){this.context=t,this.sources=Object.fromEntries(r.map(n=>[n.id,n])),this.sourceTypes=new Set(Object.values(this.sources).map(n=>n.type))}async uploadSources(t){for(let[r,n]of Object.entries(t)){let i=this.getSourceOrThrow(r);await this.uploadSource(i,n.uploadUrl)}return this.convertFdrSourceUploadsToSourceConfig(t)}async uploadSource(t,r){let n=await this.getUploadCommand(t),i=await(0,R7o.readFile)(n.absoluteFilePath),a=await fetch(r,{method:"PUT",body:i,headers:{"Content-Type":"application/octet-stream"}});await n.cleanup(),a.ok||this.context.failAndThrow(`Failed to upload source file: ${t.absoluteFilePath}. Status: ${a.status}, ${a.statusText}`)}async getUploadCommand(t){if(t.type==="protobuf"){let r=await this.zipSource(t.absoluteFilePath);return{absoluteFilePath:r,cleanup:async()=>{this.context.logger.debug(`Removing ${r}`),await(0,R7o.unlink)(r)}}}return{absoluteFilePath:t.absoluteFilePath,cleanup:async()=>{}}}async zipSource(t){let r=await Dvg.default.dir(),n=pf(R_.of(r.path),zs.of(AQA));return this.context.logger.debug(`Zipping source ${t} into ${n}`),await $je(this.context.logger,"zip",["-r",n,"."],{cwd:t,doNotPipeOutput:!0}),n}convertFdrSourceUploadsToSourceConfig(t){let r=[];for(let[n,i]of Object.entries(t))switch(this.getSourceOrThrow(n).type){case"protobuf":r.push(tne.proto({id:n,protoRootUrl:i.downloadUrl}));continue;case"openapi":r.push(tne.openapi());continue;case"asyncapi":continue}return{sources:r}}getSourceOrThrow(t){let r=this.sources[t];return r==null&&this.context.failAndThrow(`Internal error; server responded with source id "${t}" which does not exist in the workspace.`),r}};async function Svg({projectConfig:e,organization:t,workspace:r,interactiveTaskContext:n,generatorInvocation:i,version:a,audiences:u,shouldLogS3Url:f,token:d,whitelabel:c,irVersionOverride:o,absolutePathToPreview:l,readme:g}){let O=BZr({token:d.value}),j=pg.getPackageName({generatorInvocation:i}),S=await JQ({workspace:r,generationLanguage:i.language,keywords:i.keywords,smartCasing:i.smartCasing,disableExamples:i.disableExamples,audiences:u,readme:g,packageName:j,version:a??await zQA({fdr:O,packageName:j,generatorInvocation:i}),context:n}),x=r.getSources(),A=dwe({ir:S,snippetsConfig:{}}),z=await O.api.v1.register.registerApiDefinition({orgId:t,apiId:S.apiName.originalName,definition:A,sources:x.length>0?BQA(x):void 0}),N,C;z.ok&&(N=z.body.apiDefinitionId,C=z.body.sources);let U=new I7o(n,x);if(C==null&&U.sourceTypes.has("protobuf")&&n.failAndThrow("Did not successfully upload Protobuf source files."),C!=null){n.logger.debug("Uploading source files ...");let Je=await U.uploadSources(C);n.logger.debug("Setting IR source configuration ..."),S.sourceConfig=Je}let Y=l!=null,te=Je=>cMn(Je,{onError:Dt=>n.failAndThrow(Dt)},{substituteAsEmpty:Y}),G=te(i),$=await pvg({projectConfig:e,workspace:r,organization:t,generatorInvocation:G,context:n,version:a,intermediateRepresentation:{...S,fdrApiDefinitionId:N,publishConfig:NQA({generatorInvocation:G})},shouldLogS3Url:f,token:d,whitelabel:c!=null?te(c):void 0,irVersionOverride:o,absolutePathToPreview:l});n.logger.debug(`Job ID: ${$.jobId}`);let ee=$.taskIds[0];if(ee==null){n.failAndThrow("Did not receive a task ID.");return}n.logger.debug(`Task ID: ${ee}`);let Ve=new z7o({job:$,taskId:ee,generatorInvocation:i,interactiveTaskContext:n,absolutePathToPreview:l});return await yvg({job:$,taskHandler:Ve,taskId:ee,context:n})}function NQA({generatorInvocation:e}){return e.outputMode._visit({downloadFiles:()=>{},github:()=>{},githubV2:()=>{},publish:()=>{},publishV2:t=>t._visit({mavenOverride:()=>{},pypiOverride:()=>{},nugetOverride:()=>{},npmOverride:()=>{},rubyGemsOverride:()=>{},postman:r=>{var i,a,u;let n;return((a=(i=e.raw)==null?void 0:i.output)==null?void 0:a.location)==="postman"&&(n=(u=e.raw.output)==null?void 0:u["collection-id"]),y_.PublishingConfig.direct({target:y_.PublishTarget.postman({apiKey:r.apiKey,workspaceId:r.workspaceId,collectionId:n})})},_other:()=>{}}),_other:()=>{}})}async function zQA({fdr:e,packageName:t,generatorInvocation:r}){if(r.language==null)return;let n;switch(r.language){case"csharp":n="Csharp";break;case"go":n="Go";break;case"java":n="Java";break;case"python":n="Python";break;case"ruby":n="Ruby";break;case"typescript":n="TypeScript";break;default:return}if(t==null)return;let i=await e.sdks.versions.computeSemanticVersion({githubRepository:r.outputMode.type==="githubV2"?`${r.outputMode.githubV2.owner}/${r.outputMode.githubV2.repo}`:void 0,language:n,package:t});if(!!i.ok)return i.body.version}function BQA(e){return Object.fromEntries(Object.values(e).map(t=>[t.id,{type:t.type==="protobuf"?"proto":t.type}]))}async function dwc({projectConfig:e,organization:t,workspace:r,context:n,generatorGroup:i,version:a,shouldLogS3Url:u,token:f,whitelabel:d,absolutePathToPreview:c,mode:o}){if(i.generators.length===0)return n.logger.warn("No generators specified."),null;let l=[],g=[];return l.push(...i.generators.map(j=>n.runInteractiveTask({name:j.name},async S=>{let x=await r.toFernWorkspace({context:n},L0i(j)),A=await Svg({projectConfig:e,organization:t,workspace:x,interactiveTaskContext:S,generatorInvocation:{...j,outputMode:j.outputMode._visit({downloadFiles:()=>j.outputMode,github:z=>F7o.FernFiddle.OutputMode.github({...z,makePr:o==="pull-request"}),githubV2:z=>o==="pull-request"?F7o.FernFiddle.OutputMode.githubV2(F7o.FernFiddle.GithubOutputModeV2.pullRequest(z)):j.outputMode,publish:()=>j.outputMode,publishV2:()=>j.outputMode,_other:()=>j.outputMode})},version:a,audiences:i.audiences,shouldLogS3Url:u,token:f,whitelabel:d,readme:j.readme,irVersionOverride:j.irVersionOverride,absolutePathToPreview:c});A!=null&&A.createdSnippets&&(g.push(j),j.absolutePathToLocalSnippets!=null&&A.snippetsS3PreSignedReadUrl!=null&&await svg({snippetsS3PreSignedReadUrl:A.snippetsS3PreSignedReadUrl,absolutePathToLocalSnippetJSON:j.absolutePathToLocalSnippets,context:S}))}))),(await Promise.all(l)).some(j=>!j)&&n.failAndThrow(),{snippetsProducedBy:g}}var ybg=yu(vRt(),1);var vbg=require("fs/promises");var qwc=yu(zci(),1);var cbg=yu(sbg(),1);var lbg=require("util"),_kA=(0,lbg.promisify)(cbg.default);async function fbg(e,t,r){let n=Fui(e,t),i=[];for(let a of n){let u=await Promise.all(a.map(async f=>{try{let d=await _kA(f);return d==null||d.height==null||d.width==null?void 0:{filePath:f,width:d.width,height:d.height,blurDataUrl:void 0}}catch(d){r.logger.error(`Failed to measure image size for ${f}. ${d==null?void 0:d.message}`);return}}));i.push(...u.filter(FS))}return new Map(i.map(a=>[a.filePath,a]))}var hkA=10,dbg=10;async function bbg({token:e,organization:t,docsWorkspace:r,domain:n,customDomains:i,fernWorkspaces:a,context:u,preview:f,editThisPage:d,isPrivate:c=!1}){let o=BZr({token:e.value}),l=c?{type:"private",authType:"sso"}:{type:"public"},g,O=i[0]??n,j=ykA(n),x=await new Prn(n,r,a,u,d,async z=>{let N=new Map(z.map($=>[$.absoluteFilePath,$])),U=z.map($=>({...$,mediaType:qwc.lookup($.absoluteFilePath)})).filter($=>$.mediaType!==!1).filter($=>{var ee;return((ee=sA.parse($.mediaType))==null?void 0:ee.isImage())??!1}).map($=>$.absoluteFilePath),Y=await fbg(U,hkA,u),te=[];[...Y.values()].forEach($=>{let ee=N.get($.filePath);if(ee==null)return;let Ve={filePath:RGi(ee.relativeFilePath),width:$.width,height:$.height,blurDataUrl:$.blurDataUrl};te.push(Ve)});let G=z.filter(({absoluteFilePath:$})=>!Y.has($)).map(({relativeFilePath:$})=>RGi($));if(f){let $=await o.docs.v2.write.startDocsPreviewRegister({orgId:t,authConfig:c?{type:"private",authType:"sso"}:{type:"public"},filepaths:G,images:te,basePath:j});return $.ok?(O=$.body.previewUrl,g=$.body.docsRegistrationId,await pbg($.body.uploadUrls,r.absoluteFilePath,u,dbg),_bg($.body.uploadUrls,r.absoluteFilePath)):await hbg($.error,u)}else{let $=await o.docs.v2.write.startDocsRegister({domain:n,customDomains:i,authConfig:l,apiId:"",orgId:t,filepaths:G,images:te});return $.ok?(g=$.body.docsRegistrationId,await pbg($.body.uploadUrls,r.absoluteFilePath,u,dbg),_bg($.body.uploadUrls,r.absoluteFilePath)):hbg($.error,u)}},async({ir:z,snippetsConfig:N,playgroundConfig:C,apiName:U})=>{let Y=dwe({ir:z,snippetsConfig:N,playgroundConfig:C});u.logger.debug("Calling registerAPI... ",JSON.stringify(Y,void 0,4));let te=await o.api.v1.register.registerApiDefinition({orgId:t,apiId:z.apiName.originalName,definition:Y});if(te.ok)return u.logger.debug(`Registered API Definition ${te.body.apiDefinitionId}`),te.body.apiDefinitionId;switch(te.error.error){case"UnauthorizedError":case"UserNotInOrgError":return u.failAndThrow("You do not have permissions to register the docs. Reach out to support@buildwithfern.com");default:return U!=null?u.failAndThrow(`Failed to register API ${U}`,te.error):u.failAndThrow("Failed to register API",te.error)}}).resolve();if(g==null)return u.failAndThrow("Failed to publish docs.","Docs registration ID is missing.");u.logger.debug("Calling registerDocs... ",JSON.stringify(x,void 0,4));let A=await o.docs.v2.write.finishDocsRegister(g,{docsDefinition:x});if(A.ok){let z=qEr(O),N=xAr(z,z);u.logger.info(al.green(`Published docs to ${N}`))}else switch(A.error.error){case"UnauthorizedError":case"UserNotInOrgError":return u.failAndThrow("Insufficient permissions. Failed to publish docs to "+n);case"DocsRegistrationIdNotFound":return u.failAndThrow("Failed to publish docs to "+n,`Docs registration ID ${g} does not exist.`);default:return u.failAndThrow("Failed to publish docs to "+n,A.error)}}async function pbg(e,t,r,n){let i=Date.now(),a=Object.keys(e).length;r.logger.debug(`Start uploading ${a} files...`);let u=Fui(Object.entries(e),n),f=0;for(let c of u){await Promise.all(c.map(async([l,{uploadUrl:g}])=>{let O=zs.of(l),j=w2(t,O);try{let S=qwc.lookup(j);await ybg.default.put(g,await(0,vbg.readFile)(j),{headers:{"Content-Type":S===!1?"application/octet-stream":S}})}catch(S){r.failAndThrow(`Failed to upload ${j}`,S)}}));let o=Date.now();f+=c.length,r.logger.debug(`Uploaded ${f}/${a} files in ${o-i}ms`)}let d=Date.now();r.logger.debug(`Finished uploading ${a} files in ${d-i}ms`)}function _bg(e,t){let r=[];for(let[n,i]of Object.entries(e)){let a=zs.of(n),u=w2(t,a);r.push({relativeFilePath:a,absoluteFilePath:u,fileId:i.fileId})}return r}async function hbg(e,t){switch(await t.instrumentPostHogEvent({command:"docs-generation",properties:{error:JSON.stringify(e)}}),e.error){case"InvalidCustomDomainError":return t.failAndThrow("Your docs domain should end with docs.buildwithfern.com");case"InvalidDomainError":return t.failAndThrow("Please make sure that none of your custom domains are not overlapping (i.e. one is a substring of another)");case"UnauthorizedError":return t.failAndThrow("Please make sure that your FERN_TOKEN is set.");case"UserNotInOrgError":return t.failAndThrow("Please verify if you have access to the organization you are trying to publish the docs to. If you are not a member of the organization, please reach out to the organization owner.");case"UnavailableError":return t.failAndThrow("Failed to publish docs. Please try again later or reach out to Fern support at support@buildwithfern.com.");default:return t.failAndThrow("Failed to publish docs.",e)}}function ykA(e){try{return new URL(qEr(e)).pathname}catch{return}}async function Cwc({organization:e,fernWorkspaces:t,docsWorkspace:r,context:n,token:i,instanceUrl:a,preview:u}){var o;let f=r.config.instances;if(r.config=cMn(r.config,{onError:l=>n.failAndThrow(l)},{substituteAsEmpty:u}),f.length===0){n.failAndThrow("No instances specified in docs.yml! Cannot register docs.");return}if(f.length>1&&a==null){n.failAndThrow(`More than one docs instances. Please specify one (e.g. --instance ${(o=f[0])==null?void 0:o.url})`);return}let d=f.find(l=>l.url===a)??f[0];if(d==null){n.failAndThrow(`No docs instance with url ${a}. Failed to register.`);return}let c=[];d.customDomain!=null&&(typeof d.customDomain=="string"?c.push(d.customDomain):Array.isArray(d.customDomain)&&c.push(...d.customDomain)),await n.runInteractiveTask({name:d.url},async()=>{await bbg({docsWorkspace:r,customDomains:c,domain:d.url,token:i,organization:e,context:n,fernWorkspaces:t,preview:u,audiences:d.audiences,editThisPage:d.editThisPage,isPrivate:d.private})})}async function gbg({organization:e,workspace:t,projectConfig:r,context:n,groupName:i,version:a,shouldLogS3Url:u,token:f,useLocalDocker:d,keepDocker:c,absolutePathToPreview:o,mode:l}){if(t.generatorsConfiguration==null){n.logger.warn("This workspaces has no generators.yml");return}if(t.generatorsConfiguration.groups.length===0){n.logger.warn(`This workspaces has no groups specified in ${a5}`);return}let g=i??t.generatorsConfiguration.defaultGroup;if(g==null)return n.failAndThrow(`No group specified. Use the --${Zog} option, or set "${jNc}" in ${a5}`);let O=t.generatorsConfiguration.groups.find(j=>j.groupName===g);if(O==null)return n.failAndThrow(`Group '${g}' does not exist.`);if(await UFt({workspace:await t.toFernWorkspace({context:n}),context:n,logWarnings:!1}),d)await cwc({projectConfig:r,workspace:t,generatorGroup:O,keepDocker:c,context:n});else{if(!f)return n.failAndThrow("Please run fern login");await dwc({projectConfig:r,organization:e,workspace:t,context:n,generatorGroup:O,version:a,shouldLogS3Url:u,token:f,whitelabel:t.generatorsConfiguration.whitelabel,absolutePathToPreview:o,mode:l})}}var mbg={PullRequest:"pull-request"};async function Awc({project:e,cliContext:t,version:r,groupName:n,shouldLogS3Url:i,keepDocker:a,useLocalDocker:u,preview:f,mode:d}){let c;if(!u){let o=await t.runTask(async l=>s2e(l));o.type==="user"&&await t.runTask(async l=>{await rSr({organization:e.config.organization,token:o,context:l})}),c=o}await t.instrumentPostHogEvent({orgId:e.config.organization,command:"fern generate",properties:{workspaces:e.apiWorkspaces.map(o=>{var l;return{name:o.workspaceName,group:n,generators:(l=o.generatorsConfiguration)==null?void 0:l.groups.filter(g=>n==null?!0:g.groupName===n).map(g=>g.generators.map(O=>({name:O.name,version:O.version,outputMode:O.outputMode.type,config:O.config})))}})}}),await Promise.all(e.apiWorkspaces.map(async o=>{await t.runTaskForWorkspace(o,async l=>{let g=f?pf(o.absoluteFilePath,zs.of(kog)):void 0;g!=null&&l.logger.info(`Writing preview to ${g}`),await gbg({organization:e.config.organization,workspace:o,projectConfig:e.config,context:l,version:r,groupName:n,shouldLogS3Url:i,token:c,useLocalDocker:u,keepDocker:a,absolutePathToPreview:g,mode:d})})}))}async function Obg({project:e,cliContext:t,instance:r,preview:n}){let i=e.docsWorkspaces;if(i==null)return;let a=await t.runTask(async u=>s2e(u));a.type==="user"&&await t.runTask(async u=>{await rSr({organization:e.config.organization,token:a,context:u})}),await t.instrumentPostHogEvent({orgId:e.config.organization,command:"fern generate --docs"}),await t.runTaskForWorkspace(i,async u=>{await qMa({workspace:i,context:u,logWarnings:!1,loadAPIWorkspace:e.loadAPIWorkspace});let f=await Promise.all(e.apiWorkspaces.map(async d=>d.toFernWorkspace({context:u},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1})));await Cwc({organization:e.config.organization,fernWorkspaces:f,docsWorkspace:i,context:u,token:a,instanceUrl:r,preview:n})})}var Nwc=yu(pju(),1);var Mjn=class{app=(0,Nwc.default)();context;server=void 0;port=void 0;constructor({context:t,ir:r,port:n}){this.context=t,this.app.use(Nwc.default.json({limit:"50mb",strict:!1})),this.port=n;let i=new Map;for(let d of Object.values(r.services))for(let c of d.endpoints){let o=vkA(c);t.logger.debug(`Registering ${c.method} ${o} ...`);let l=i.get(o)??new Map,g=l.get(c.method)??[];i.set(o,l.set(c.method,[...g,c]))}let a=(d,c)=>{let o=d[0],l=c[0],g=o.split("/"),O=l.split("/");if(g.length!==O.length)return g.length-O.length;for(let j=0;j<Math.min(g.length,O.length);j++){let S=g[j],x=O[j];if(S===x)continue;if(S==null||x==null)return S==null?-1:1;let A=S.startsWith(":"),z=x.startsWith(":");return A&&!z?1:!A&&z?-1:S.localeCompare(x)}return 0},f=Array.from(i).sort(a);for(let[d,c]of f)for(let[o,l]of c)switch(o){case"GET":this.app.get(d,VLi(l));break;case"POST":this.app.post(d,VLi(l));break;case"PUT":this.app.put(d,VLi(l));break;case"PATCH":this.app.patch(d,VLi(l));break;case"DELETE":this.app.delete(d,VLi(l));break}}stop(){var t;(t=this.server)==null||t.close()}async start(){return this.port=this.port??await Tpi(),this.server=this.app.listen(this.port),this.context.logger.info(`Running Fern mock server on localhost: ${this.port}`),this.port}async keepAlive(){await new Promise(()=>{})}};function vkA(e){let t="";e.fullPath.head.length>0&&(t=$S(t,e.fullPath.head));for(let r of e.fullPath.parts)t=$S(t,":"+r.pathParameter),r.tail.length>0&&(t=$S(t,r.tail));return t.startsWith("/")?t:`/${t}`}function VLi(e){let t=!1;return(r,n)=>{var i;for(let a of e)for(let u of[...a.autogeneratedExamples,...a.userSpecifiedExamples])if(t=!0,u.example!=null&&bkA(r,u.example)){(i=u.example.response)==null||i._visit({ok:f=>{f._visit({body:d=>{var c,o,l;if(d==null){n.sendStatus(((c=a.response)==null?void 0:c.statusCode)??204);return}if(((l=(o=a.response)==null?void 0:o.body)==null?void 0:l.type)==="text"){n.contentType("text/plain"),n.send(d.jsonExample);return}n.json(d.jsonExample)},stream:d=>{d.forEach(c=>{n.write(c.jsonExample)}),n.end()},sse:d=>{n.setHeader("Content-Type","text/event-stream"),d.forEach(c=>{n.write(`event: ${c.event}
2270
2270
  `),n.write(`data: ${JSON.stringify(c.data.jsonExample)}
2271
2271
 
2272
2272
  `)}),n.end()},_other:Yqt})},error:f=>{var d;n.status(((d=a.response)==null?void 0:d.statusCode)??500),f.body==null?n.end():n.json(f.body.jsonExample)},_other:Yqt});return}if(!t){n.status(500).send("This endpoint doesn't have any examples");return}n.status(404).send(`Unrecognized example request: ${JSON.stringify(r.headers)} ${JSON.stringify(r.params)} ${JSON.stringify(r.query)} ${JSON.stringify(r.body)}`)}}function Pbg(e){let t=new Date(e);return!isNaN(t.getTime())}function zwc(e,t){if(!(RO(e)||RO(t))&&typeof e=="string"&&typeof t=="string"){if(e===t)return!0;if(Pbg(e)&&Pbg(t)){let r=new Date(e),n=new Date(t);return Math.abs(r.getTime()-n.getTime())<=12*60*60*1e3}}}function bkA(e,t){return gkA(t,e)&&mkA(t,e)&&OkA(t,e.headers)&&PkA(t,e)}function gkA(e,t){let r=jkA([...e.rootPathParameters,...e.servicePathParameters,...e.endpointPathParameters]);return!(Object.keys(r).length!==Object.keys(t.params).length||Object.keys(r).length>0&&!Wui(t.params,r,zwc))}function mkA(e,t){let r=jbg(e.queryParameters);if(Object.keys(r).length!==Object.keys(t.query).length)return!1;let n={};for(let[i,a]of Object.entries(t.query))a instanceof Date&&a!=null?n[i]=a.toISOString():n[i]=a;return Wui(r,n,zwc)}function OkA(e,t){let r=jbg([...e.serviceHeaders,...e.endpointHeaders]);for(let[n,i]of Object.entries(r)){let a=typeof i=="string"?i:typeof i=="boolean"?`"${i}"`:JSON.stringify(i);if(t[n.toLowerCase()]!==a)return!1}return!0}function PkA(e,t){if(e.request==null)return wkA(t.body)&&Object.keys(t.body).length===0;for(let[r,n]of Object.entries(t.body))n instanceof Date&&n!=null&&(t.body[r]=n.toISOString());return Wui(t.body,e.request.jsonExample,zwc)}function jbg(e){let t={};return e.forEach(r=>{let n=r.value.jsonExample,i=typeof n=="string"?n:JSON.stringify(n);t[r.name.wireValue]=i}),t}function jkA(e){let t={};return e.forEach(r=>{let n=r.value.jsonExample,i=typeof n=="string"?n:JSON.stringify(n);t[r.name.originalName]=i}),t}function wkA(e){return typeof e=="object"&&e!=null}async function wbg({cliContext:e,project:t,port:r}){if(await e.instrumentPostHogEvent({orgId:t.config.organization,command:"fern mock"}),t.apiWorkspaces.length!==1||t.apiWorkspaces[0]==null)return e.failAndThrow(`No API specified. Use the --${kCo} option.`);let n=t.apiWorkspaces[0];await e.runTaskForWorkspace(n,async i=>{let a=await n.toFernWorkspace({context:i});await UFt({context:i,logWarnings:!1,workspace:a});let u=await JQ({workspace:a,audiences:{type:"all"},generationLanguage:void 0,keywords:void 0,smartCasing:!1,disableExamples:!1,readme:void 0,version:void 0,packageName:void 0,context:i}),f=new Mjn({context:i,ir:u,port:r});await f.start(),await f.keepAlive()})}var Dbg=yu(PZr(),1),Sbg=yu(vRt(),1),Ebg=require("fs/promises"),Mbg=yu(require("path"),1),xbg=yu(f0a(),1),Tbg=yu(Kte(),1);async function qbg({project:e,cliContext:t,token:r,version:n}){r.type==="user"&&await t.runTask(async a=>{await rSr({organization:e.config.organization,token:r,context:a})});let i=ZDr({token:r.value});await Promise.all(e.apiWorkspaces.map(async a=>{await t.runTaskForWorkspace(a,async u=>{if(a instanceof Vne){u.failWithoutThrowing("Registering from OpenAPI not currently supported.");return}let f=await a.toFernWorkspace({context:u}),d=await i.definitionRegistry.registerUsingOrgToken({apiId:Dbg.FernFiddle.ApiId(f.definition.rootApiFile.contents.name),version:n,cliVersion:t.environment.packageVersion,yamlSchemaVersion:`${1}`});if(!d.ok){d.error._visit({versionAlreadyExists:()=>{u.failAndThrow(`Version ${n??""} is already registered`)},_other:l=>{u.failAndThrow("Failed to register",l)}});return}let c=await Tbg.default.dir(),o=Mbg.default.join(c.path,"definition.tgz");u.logger.debug(`Compressing definition at ${c.path}`),await xbg.default.create({file:o,cwd:f.absoluteFilePath},["."]),u.logger.info("Uploading definition..."),await Sbg.default.put(d.body.definitionS3UploadUrl,await(0,Ebg.readFile)(o)),u.logger.info(`Registered @${e.config.organization}/${f.definition.rootApiFile.contents.name}:${d.body.version}`)})}))}async function Cbg({project:e,cliContext:t,token:r}){await Promise.all(e.apiWorkspaces.map(async n=>{await t.runTaskForWorkspace(n,async i=>{await p1u({organization:e.config.organization,workspace:await n.toFernWorkspace({context:i}),context:i,token:r,audiences:{type:"all"},snippetsConfig:{}}),i.logger.info(al.green("Registered API"))})}))}async function Abg({cliContext:e,project:t,testCommand:r,generationLanguage:n}){if(await e.instrumentPostHogEvent({orgId:t.config.organization,command:"fern test"}),r==null)return e.failAndThrow("No test command specified. Use the --command option.");if(t.apiWorkspaces.length!==1||t.apiWorkspaces[0]==null)return e.failAndThrow(`No API specified. Use the --${kCo} option.`);let i=t.apiWorkspaces[0];await e.runTaskForWorkspace(i,async a=>{let u=await i.toFernWorkspace({context:a});await UFt({context:a,logWarnings:!1,workspace:u});let f=await JQ({workspace:u,audiences:{type:"all"},generationLanguage:void 0,keywords:void 0,smartCasing:!1,disableExamples:!1,readme:void 0,version:void 0,packageName:void 0,context:a}),d=new Mjn({context:a,ir:f,port:void 0}),o=`http://localhost:${await d.start()}`;a.logger.info("Running tests..."),a.logger.info(`>> ${r}`),a.logger.debug(`envvar set: TESTS_BASE_URL=${o}`);let l=r.split(" && ").map(g=>g.split(" "));for(let g of l){let{failed:O}=await $je(e.logger,g[0]??"",g.slice(1),{reject:!1,env:{TESTS_BASE_URL:o}});O&&(d.stop(),a.logger.error("Tests failed, Fern mock server stopping."),a.logger.error("View test output above."),e.failAndThrow())}d.stop(),a.logger.info("Fern mock server stopped.")})}var Nbg=yu(M2(),1);async function zbg({orgId:e,taskContext:t}){let r=await s2e(t),i=await ICt({token:r.value}).registry.generateRegistryTokens({organizationId:Nbg.FernVenusApi.OrganizationId(e)});if(i.ok){t.logger.info(al.green(`Generated a FERN_TOKEN for ${e}: ${i.body.npm.token}`));return}i.error._visit({organizationNotFoundError:()=>t.failAndThrow(`Failed to create token because the organization ${e} was not found. Please reach out to support@buildwithfern.com`),unauthorizedError:()=>t.failAndThrow(`Failed to create token because you are not in the ${e} organization. Please reach out to support@buildwithfern.com`),_other:()=>t.failAndThrow("Failed to create token. Please reach out to support@buildwithfern.com")})}var Bbg=yu(require("fs"),1),WLi=require("fs/promises");var Ibg=require("stream"),Rbg=require("stream/promises");async function p4o(e,t,r){let n=await fetch(e);if(n.ok&&n.body){r.debug("Origin successfully fetched, writing to file");let i=Bbg.createWriteStream(t);await(0,Rbg.finished)(Ibg.Readable.fromWeb(n.body).pipe(i));let a=await(0,WLi.readFile)(t,"utf8");try{await(0,WLi.writeFile)(t,JSON.stringify(JSON.parse(a),void 0,2),"utf8")}catch{await(0,WLi.writeFile)(t,av.dump(av.load(a)),"utf8")}r.debug("File written successfully")}}async function Fbg({cliContext:e,project:{apiWorkspaces:t}}){for(let r of t)r.type!=="fern"&&await e.runTaskForWorkspace(r,async n=>{let i=await pg.loadRawGeneratorsConfiguration({absolutePathToWorkspace:r.absoluteFilePath,context:n})??{};if(await wBt()==null)return n.failAndThrow("Fern directory not found.");if(i.api!=null){let u;i.api instanceof Array?u=i.api:u=[i.api];for(let f of u)if(!pg.isRawProtobufAPIDefinitionSchema(f)){if(RO(f)&&"origin"in f&&f.origin!=null)e.logger.info(`Origin found, fetching spec from ${f.origin}`),await p4o(f.origin,pf(r.absoluteFilePath,zs.of(f.path)),e.logger);else if(RO(f))for(let[d,c]of Object.entries(f))RO(c)&&"origin"in c&&typeof c.origin=="string"&&"path"in c&&typeof c.path=="string"&&(e.logger.info(`Origin found, fetching spec from ${c.origin}`),await p4o(c.origin,pf(r.absoluteFilePath,zs.of(c.path)),e.logger))}}else if(i[pg.ASYNC_API_LOCATION_KEY]!=null){if(i[pg.API_ORIGIN_LOCATION_KEY]!=null){e.logger.info(`Origin found, fetching spec from ${i[pg.API_ORIGIN_LOCATION_KEY]}`);let u=i[pg.API_ORIGIN_LOCATION_KEY],f=i[pg.ASYNC_API_LOCATION_KEY];u!=null&&f!=null&&await p4o(u,pf(r.absoluteFilePath,zs.of(f)),e.logger)}}else if(i[pg.OPENAPI_LOCATION_KEY]!=null){let u=i[pg.OPENAPI_LOCATION_KEY],f=typeof u!="string"?(u==null?void 0:u.origin)??i[pg.API_ORIGIN_LOCATION_KEY]:i[pg.API_ORIGIN_LOCATION_KEY],d=typeof u!="string"?u==null?void 0:u.path:u;f!=null&&d!=null&&(origin=f,e.logger.info(`Origin found, fetching spec from ${f}`),await p4o(f,pf(r.absoluteFilePath,zs.of(d)),e.logger))}})}var _4o=require("fs/promises");var Lbg=yu(bJ(),1),Ubg="fern";async function Vbg(e){let t=await DkA();return t==null&&e.failAndThrow(`Directory "${Ubg}" not found.`),(await(0,Lbg.default)("*/definition/**/*.yml",{cwd:t,absolute:!0})).map(R_.of)}async function DkA(){let e=await KT(Ubg,{type:"directory"});if(e!=null)return R_.of(e)}var Bwc={name:"discriminant",summary:`Adds 'discriminant: "_type"' to all discriminated types.`,run:async({context:e})=>{let t=await Vbg(e);for(let r of t)try{let n=await SkA(r),i=EkA(n);await(0,_4o.writeFile)(r,i)}catch(n){e.failAndThrow("Failed to migrate "+r,n)}}};async function SkA(e){return(await(0,_4o.readFile)(e)).toString()}var Wbg=/^(\s{2,})union:\s*$/gm;function EkA(e){return e.replaceAll(Wbg,t=>{let r=[...t.matchAll(Wbg)][0],n=r==null?void 0:r[1];if(n==null)return t;let i=" ".repeat(n.length*1.5);return[`${n}discriminant:`,`${i}value: _type`,`${i}name: type`,t].join(`