fern-api 0.66.30 → 0.66.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +3 -3
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1710,7 +1710,7 @@ ${u$p.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&cfc(th
|
|
|
1710
1710
|
`+ztn.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?ztn.default.cyan(y$p(t,this.opt.mask)):ztn.default.italic(ztn.default.dim("[hidden]")):this.opt.mask?y$p(t,this.opt.mask):ztn.default.italic(ztn.default.dim("[input is hidden] "))}getSpinningValue(t){return this.getMaskedValue(t)}filterInput(t){return t||(this.opt.default==null?"":this.opt.default)}onEnd(t){this.status="answered",this.answer=t.value,this.render(),this.screen.done(),this.done(t.value)}onError(t){this.render(t.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}};var CGo=ci(p5(),1),UGp=ci(tdc(),1),VGp=ci(rqe(),1);var L7a=class extends _5{_run(t){this.done=t,this.editorResult=new VGp.Subject;let r=c$(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?CGo.default.dim("Received"):CGo.default.dim("Press <enter> to launch your preferred editor."),t&&(r=CGo.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,UGp.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 QGp=require("stream");var $Gp=ci(require("readline"),1),GGp=ci(HGp(),1),Wtn=class{constructor(t){this.rl||=$Gp.default.createInterface(j$D(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 j$D(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let n=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw n.isTtyError=!0,n}let r=new GGp.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var U7a=class extends Wtn{constructor(t={}){super(t),this.log=new QGp.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return P7a(this.rl,this.bottomBar.split(`
|
|
1711
1711
|
`).length),this}updateBottomBar(t){return P7a(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+`
|
|
1712
1712
|
`}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&&oGo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var FM=ci(rqe(),1),YGp=ci(W3a(),1);var BGo=ci(rqe(),1),JGp=ci(W3a(),1),IGo=function(e,t,r){return typeof e[t]!="function"?(0,BGo.of)(e):(0,BGo.from)((0,JGp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var KGp={set:(e,t="",r)=>{let i=e;t.split(".").forEach((n,a,u)=>{n==="__proto__"||n==="constructor"||(a===u.length-1?i[n]=r:(!(n in i)||typeof i[n]!="object")&&(i[n]={}),i=i[n])})},get:(e,t="",r)=>{let i=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((u,c)=>u!=null?u[c]:u,e),n=i(/[,[\]]+?/)||i(/[,.[\]]+?/);return n===void 0||n===e?r:n}},XWn=class extends Wtn{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let i;return Array.isArray(t)?i=(0,FM.from)(t):(0,FM.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,FM.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,FM.from)([t]),this.process=i.pipe((0,FM.concatMap)(this.processQuestion.bind(this)),(0,FM.publish)()),this.process.connect(),this.process.pipe((0,FM.reduce)((n,a)=>(KGp.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,FM.defer)(()=>(0,FM.of)(t).pipe((0,FM.concatMap)(this.setDefaultType.bind(this)),(0,FM.concatMap)(this.filterIfRunnable.bind(this)),(0,FM.concatMap)(()=>IGo(t,"message",this.answers)),(0,FM.concatMap)(()=>IGo(t,"default",this.answers)),(0,FM.concatMap)(()=>IGo(t,"choices",this.answers)),(0,FM.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,FM.defer)(()=>(0,FM.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,FM.defer)(()=>(0,FM.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&KGp.get(this.answers,t.name)!==void 0)return FM.EMPTY;if(t.when===!1)return FM.EMPTY;if(typeof t.when!="function")return(0,FM.of)(t);let{answers:r}=this;return(0,FM.defer)(()=>(0,FM.from)((0,YGp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,FM.filter)(i=>i!=null)))}};function XGp(e){let t=function(r,i){let n;try{n=new XWn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",w7a),this.registerPrompt("input",Itn),this.registerPrompt("number",S7a),this.registerPrompt("confirm",D7a),this.registerPrompt("rawlist",E7a),this.registerPrompt("expand",M7a),this.registerPrompt("checkbox",A7a),this.registerPrompt("password",q7a),this.registerPrompt("editor",L7a)},t.restoreDefaultPrompts(),t}var idc=XGp();function S$D(e,t){idc.registerPrompt(e,t)}function D$D(){idc.restoreDefaultPrompts()}var E$D={prompt:idc,ui:{BottomBar:U7a,Prompt:XWn},createPromptModule:XGp,registerPrompt:S$D,restoreDefaultPrompts:D$D,Separator:pue},zGo=E$D;var cHn=require("path"),TJp=require("fs"),CJp=require("readline"),rJp="posthog-node";function sJD(e,{organization:t,projectId:r,prefix:i,severityAllowList:n=["error"]}={}){return a=>{if(!(n==="*"||n.includes(a.level)))return a;a.tags||(a.tags={});let c=a.tags[iQo.POSTHOG_ID_TAG];if(c===void 0)return a;let d=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${c}`,d).toString();a.tags["PostHog Person URL"]=s;let o=a.exception?.values||[],l=o.map(g=>({...g,stacktrace:g.stacktrace?{...g.stacktrace,type:"raw",frames:(g.stacktrace.frames||[]).map(O=>({...O,platform:"node:javascript"}))}:void 0})),b={$exception_message:o[0]?.value||a.message,$exception_type:o[0]?.type,$exception_personURL:s,$exception_level:a.level,$exception_list:l,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:o[0]?.value||a.message,$sentry_exception_type:o[0]?.type,$sentry_tags:a.tags};return t&&r&&(b.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:b}),a}}var iQo=class{constructor(t,r,i,n){this.name=rJp,this.name=rJp,this.setupOnce=function(a,u){let c=u()?.getClient()?.getDsn()?.projectId;a(sJD(t,{organization:r,projectId:c,prefix:i,severityAllowList:n}))}}};iQo.POSTHOG_ID_TAG="posthog_distinct_id";var ZGo="0123456789abcdef",nQo=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=ZGo.charAt(this.bytes[r]>>>4),t+=ZGo.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=ZGo.charAt(this.bytes[r]>>>4),t+=ZGo.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},Gdc=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??cJD()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return nQo.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,nQo.ofInner(t)}},cJD=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),iJp,Qdc=()=>lJD().toString(),lJD=()=>(iJp||(iJp=new Gdc)).generate();function fJD(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(u=>u.name!=="domainUncaughtExceptionClear"&&u._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function dJD(e,t){global.process.on("uncaughtException",fJD(e,t))}function pJD(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var kGo,nJp,eQo;function _JD(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return eQo&&r.length===nJp||(nJp=r.length,eQo=r.reduce((i,n)=>{kGo||(kGo={});let a=kGo[n];if(a)i[a[0]]=a[1];else{let u=e(n);for(let c=u.length-1;c>=0;c--){let s=u[c]?.filename,o=t[n];if(s&&o){i[s]=o,kGo[n]=[s,o];break}}}return i},{})),eQo}function hJD(e){return typeof Event<"u"&&BJp(e,Event)}function yJD(e){return IJp(e,"Object")}function tpc(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return BJp(e,Error)}}function BJp(e,t){try{return e instanceof t}catch{return!1}}function vJD(e){return IJp(e,"ErrorEvent")}function IJp(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function bJD(e,t,r,i){let a=i&&i.mechanism||{handled:!0,type:"generic"},u=zJp(a,r,i);return{$exception_list:await Promise.all(u.map(async s=>{let o=await SJD(e,t,s);return o.value=o.value||"",o.type=o.type||"Error",o.mechanism=a,o}))}}function zJp(e,t,r){let i=gJD(e,t,r);return i.cause?[i,...zJp(e,i.cause,r)]:[i]}function gJD(e,t,r){if(tpc(t))return t;if(e.synthetic=!0,yJD(t)){let n=OJD(t);if(n)return n;let a=mJD(t),u=r?.syntheticException||new Error(a);return u.message=a,u}let i=r?.syntheticException||new Error(t);return i.message=`${t}`,i}function OJD(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(tpc(r))return r}}function mJD(e){if("name"in e&&typeof e.name=="string"){let i=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(i+=` with message '${e.message}'`),i}else if("message"in e&&typeof e.message=="string")return e.message;let t=jJD(e);if(vJD(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=PJD(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function PJD(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function jJD(e,t=40){let r=Object.keys(wJD(e));r.sort();let i=r[0];if(!i)return"[object has no keys]";if(i.length>=t)return aJp(i,t);for(let n=r.length;n>0;n--){let a=r.slice(0,n).join(", ");if(!(a.length>t))return n===r.length?a:aJp(a,t)}return""}function aJp(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function wJD(e){return tpc(e)?{message:e.message,name:e.name,stack:e.stack,...oJp(e)}:hJD(e)?{type:e.type,target:uJp(e.target),currentTarget:uJp(e.currentTarget),...oJp(e)}:e}function oJp(e){if(typeof e=="object"&&e!==null){let t={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}else return{}}function uJp(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function SJD(e,t,r){let i={type:r.name||r.constructor.name,value:r.message},n=DJD(e,r);for(let a of t)n=await a(n);return n.length&&(i.stacktrace={frames:n,type:"raw"}),i}function DJD(e,t){return EJD(e(t.stack||"",1),e)}function EJD(e,t){let r=_JD(t);return e.forEach(i=>{i.filename&&(i.chunk_id=r[i.filename])}),e}var MJD=2e3,oHn=class e{static async captureException(t,r,i,n,a){let u={...a};n||(u.$process_person_profile=!1);let c=await bJD(this.stackParser,this.frameModifiers,r,i);t.capture({event:"$exception",distinctId:n||Qdc(),properties:{...c,...u}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(dJD(this.onException.bind(this),this.onFatalError.bind(this)),pJD(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(MJD)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function AJD(e=process.argv[1]?(0,cHn.dirname)(process.argv[1]):process.cwd(),t=cHn.sep==="\\"){let r=t?sJp(e):e;return i=>{if(!i)return;let n=t?sJp(i):i,{dir:a,base:u,ext:c}=cHn.posix.parse(n);(c===".js"||c===".mjs"||c===".cjs")&&(u=u.slice(0,c.length*-1));let d=decodeURIComponent(u);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${d}`;if(a.startsWith(r)){let o=a.slice(r.length+1).replace(/\//g,".");return o?`${o}:${d}`:d}return d}}function sJp(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var aQo=class{constructor(t){this._maxSize=t,this._cache=new Map}get(t){let r=this._cache.get(t);if(r!==void 0)return this._cache.delete(t),this._cache.set(t,r),r}set(t,r){this._cache.set(t,r)}reduce(){for(;this._cache.size>=this._maxSize;){let t=this._cache.keys().next().value;t&&this._cache.delete(t)}}},rQo=new aQo(25),xJp=new aQo(20),rpc=7,qJD=1e3,TJD=1e4;async function CJD(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],u=a?.filename;if(!a||typeof u!="string"||typeof a.lineno!="number"||xJD(u)||RJD(a))continue;t[u]||(t[u]=[]),t[u].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(xJp.get(n))continue;let a=t[n];if(!a)continue;a.sort((d,s)=>d-s);let u=FJD(a);if(u.every(d=>NJD(n,d)))continue;let c=LJD(rQo,n,{});i.push(BJD(n,u,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&IJD(e,rQo),rQo.reduce(),e}function BJD(e,t,r){return new Promise(i=>{let n=(0,TJp.createReadStream)(e),a=(0,CJp.createInterface)({input:n});function u(){n.destroy(),i()}let c=0,d=0,s=t[d];if(s===void 0){u();return}let o=s[0],l=s[1];function b(){xJp.set(e,1),a.close(),a.removeAllListeners(),u()}n.on("error",b),a.on("error",b),a.on("close",u),a.on("line",g=>{if(c++,!(c<o)&&(r[c]=UJD(g,0),c>=l)){if(d===t.length-1){a.close(),a.removeAllListeners();return}d++;let O=t[d];if(O===void 0){a.close(),a.removeAllListeners();return}o=O[0],l=O[1]}})})}function IJD(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let i=t.get(r.filename);if(i===void 0)continue;zJD(r.lineno,r,i)}}function zJD(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=RJp(e);n<e;n++){let a=r[n];if(a===void 0){cJp(t);return}t.pre_context.push(a)}if(r[e]===void 0){cJp(t);return}t.context_line=r[e];let i=NJp(e);t.post_context=[];for(let n=e+1;n<=i;n++){let a=r[n];if(a===void 0)break;t.post_context.push(a)}}function cJp(e){delete e.pre_context,delete e.context_line,delete e.post_context}function xJD(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function RJD(e){return e.lineno!==void 0&&e.lineno>TJD||e.colno!==void 0&&e.colno>qJD}function NJD(e,t){let r=rQo.get(e);if(r===void 0)return!1;for(let i=t[0];i<=t[1];i++)if(r[i]===void 0)return!1;return!0}function FJD(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=lJp(r),n=[];for(;;){if(t===e.length-1){n.push(i);break}let a=e[t+1];if(typeof a!="number")break;a<=i[1]?i[1]=a+rpc:(n.push(i),i=lJp(a)),t++}return n}function lJp(e){return[RJp(e),NJp(e)]}function RJp(e){return Math.max(1,e-rpc)}function NJp(e){return e+rpc}function LJD(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function UJD(e,t){let r=e,i=r.length;if(i<=150)return r;t>i&&(t=i);let n=Math.max(t-60,0);n<5&&(n=0);let a=Math.min(n+140,i);return a>i-5&&(a=i),a===i&&(n=Math.max(a-140,0)),r=r.slice(n,a),n>0&&(r=`...${r}`),a<i&&(r+="..."),r}var VJD="4.18.0",gue;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.DecideEndpointWasHit="decide_endpoint_was_hit",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config"})(gue||(gue={}));var fJp;(function(e){e.Left="left",e.Right="right",e.Center="center"})(fJp||(fJp={}));var dJp;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(dJp||(dJp={}));var pJp;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(pJp||(pJp={}));var _Jp;(function(e){e.Html="html",e.Text="text"})(_Jp||(_Jp={}));var hJp;(function(e){e.Number="number",e.Emoji="emoji"})(hJp||(hJp={}));var yJp;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(yJp||(yJp={}));var vJp;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(vJp||(vJp={}));var bJp;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(bJp||(bJp={}));var gJp;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(gJp||(gJp={}));var WJD=e=>{if("flags"in e){let t=$JD(e.flags),r=GJD(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,FJp(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,HJD(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function HJD(e,t,r){return{key:e,enabled:typeof t=="string"?!0:t,variant:typeof t=="string"?t:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:r?JSON.stringify(r):void 0,description:void 0}}}var $JD=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,ipc(r)]).filter(([,t])=>t!==void 0)),GJD=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let i=t[r];return i.enabled&&i.metadata&&i.metadata.payload!==void 0}).map(r=>{let i=t[r].metadata?.payload;return[r,i?FJp(i):void 0]}))},ipc=e=>e===void 0?void 0:e.variant??e.enabled,FJp=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},QJD=1,JJD=new Set(["61be3dd8","96f6df5f","8cfdba9b","bf027177","e59430a8","7fa5500b","569798e9","04809ff7","0ebc61a5","32de7f98","3beeb69a","12d34ad9","733853ec","0645bb64","5dcbee21","b1f95fa3","2189e408","82b460c2","3a8cc979","29ef8843","2cdbf767","38084b54","50f9f8de","41d0df91","5c236689","c11aedd3","ada46672","f4331ee1","42fed62a","c957462c","d62f705a","e0162666","01b3e5cf","441cef7f","bb9cafee","8f348eb0","b2553f3a","97469d7d","39f21a76","03706dcc","27d50569","307584a7","6433e92e","150c7fbb","49f57f22","3772f65b","01eb8256","3c9e9234","f853c7f7","c0ac4b67","cd609d40","10ca9b1a","8a87f11b","8e8e5216","1f6b63b3","db7943dd","79b7164c","07f78e33","2d21b6fd","952db5ee","a7d3b43f","1924dd9c","84e1b8f6","dff631b6","c5aa8a79","fa133a95","498a4508","24748755","98f3d658","21bbda67","7dbfed69","be3ec24c","fc80b8e2","75cc0998"]),KJD="utf8";function YJD(e,t){if(!e||typeof e!="string"||XJD(e))throw new Error(t)}function XJD(e){return e.trim().length===0}function ZJD(e){return e?.replace(/\/+$/,"")}async function kJD(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function OJp(){return new Date().getTime()}function Hdc(){return new Date().toISOString()}function oQo(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function eKD(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function tKD(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16).padStart(8,"0")}function rKD(e,t=0,r){let i=tKD(e);return r?.has(i)?!1:parseInt(i,16)/4294967295<t}function mJp(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var X7a=String.fromCharCode,PJp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",tQo={};function iKD(e,t){if(!tQo[e]){tQo[e]={};for(let r=0;r<e.length;r++)tQo[e][e.charAt(r)]=r}return tQo[e][t]}var nHn={compressToBase64:function(e){if(e==null)return"";let t=nHn._compress(e,6,function(r){return PJp.charAt(r)});switch(t.length%4){default:case 0:return t;case 1:return t+"===";case 2:return t+"==";case 3:return t+"="}},decompressFromBase64:function(e){return e==null?"":e==""?null:nHn._decompress(e.length,32,function(t){return iKD(PJp,e.charAt(t))})},compress:function(e){return nHn._compress(e,16,function(t){return X7a(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,c,d="",s="",o="",l=2,b=3,g=2,O=0,m=0,P;for(P=0;P<e.length;P+=1)if(d=e.charAt(P),Object.prototype.hasOwnProperty.call(i,d)||(i[d]=b++,n[d]=!0),s=o+d,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(c=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1}else{for(c=1,u=0;u<g;u++)O=O<<1|c,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=0;for(c=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1}l--,l==0&&(l=Math.pow(2,g),g++),delete n[o]}else for(c=i[o],u=0;u<g;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1;l--,l==0&&(l=Math.pow(2,g),g++),i[s]=b++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(c=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1}else{for(c=1,u=0;u<g;u++)O=O<<1|c,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=0;for(c=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1}l--,l==0&&(l=Math.pow(2,g),g++),delete n[o]}else for(c=i[o],u=0;u<g;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1;l--,l==0&&(l=Math.pow(2,g),g++)}for(c=2,u=0;u<g;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:nHn._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,c=4,d=3,s="",o,l,b,g,O,m,P;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=X7a(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=X7a(b);break;case 2:return""}for(i[3]=P,l=P,n.push(P);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,d),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(P=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[c++]=X7a(b),P=c-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[c++]=X7a(b),P=c-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[P])s=i[P];else if(P===c)s=l+l.charAt(0);else return null;n.push(s),i[c++]=l+s.charAt(0),u--,l=s,u==0&&(u=Math.pow(2,d),d++)}}},Jdc=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}},uHn=class extends Error{constructor(t,r){super("HTTP error while fetching PostHog: status="+t.status+", reqByteLength="+r),this.response=t,this.reqByteLength=r,this.name="PostHogFetchHttpError"}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}},Z7a=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function jJp(e){if(e instanceof uHn){let t="";try{t=await e.text}catch{}console.error(`Error while flushing PostHog: message=${e.message}, response body=${t}`,e)}else console.error("Error while flushing PostHog",e);return Promise.resolve()}function $dc(e){return typeof e=="object"&&(e instanceof uHn||e instanceof Z7a)}function wJp(e){return typeof e=="object"&&e instanceof uHn&&e.status===413}var Kdc;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(Kdc||(Kdc={}));var Ydc=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new Jdc,this._isInitialized=!1,YJD(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=ZJD(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.preloadFeatureFlags=r?.preloadFeatureFlags??!0,this.defaultOptIn=r?.defaultOptIn??!0,this.disableSurveys=r?.disableSurveys??!1,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:$dc},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=r?.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(gue.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(gue.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(gue.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=Qdc();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}async identifyStatelessImmediate(t,r,i){let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",n,i)}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}async captureStatelessImmediate(t,r,i,n){let a=this.buildPayload({distinct_id:t,event:r,properties:i});await this.sendImmediate("capture",a,n)}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}async aliasStatelessImmediate(t,r,i,n){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,n)}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",c,n)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,i,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(n=>n.json()).catch(n=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",n)),this._events.emit("error",n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let c=rKD(this.apiKey,QJD,JJD)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,d={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",c)),this.fetchWithRetry(c,d,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(s=>s.json()).then(s=>WJD(s)).catch(s=>{this._events.emit("error",s)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,i,n,a,u);if(c===void 0)return{response:void 0,requestId:void 0};let d=ipc(c.response);return d===void 0&&(d=!1),{response:d,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,i={},n={},a={},u){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,i,n,a,u,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u,[t]);if(!c)return;let d=c[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a,u){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,u)).payloads}async getFeatureFlagsStateless(t,r={},i={},n={},a,u){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,u)}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a,u){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,i,n,a,u);return c?{flags:c.featureFlags,payloads:c.featureFlagPayloads,requestId:c.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},i={},n={},a,u){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),u&&(c.flag_keys_to_evaluate=u);let d=await this.getDecide(t,r,i,n,c);if(d!==void 0)return d.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),d.quotaLimited?.includes(Kdc.FeatureFlags)?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:d?.requestId}):d}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this.logMsgIfDebug(()=>console.log("PostHog Debug","Loading surveys is disabled.")),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},n=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let u=`Surveys API could not be loaded: ${a.status}`,c=new Error(u);this.logMsgIfDebug(()=>console.error(c)),this._events.emit("error",new Error(u));return}return a.json()}).catch(a=>{this.logMsgIfDebug(()=>console.error("Surveys API could not be loaded",a)),this._events.emit("error",a)}))?.surveys;return n&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(n))),n??[]}get props(){return this._props||(this._props=this.getPersistedProperty(gue.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(gue.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(gue.Props,this.props)})}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n=this.prepareMessage(t,r,i),a=this.getPersistedProperty(gue.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:n}),this.setPersistedProperty(gue.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=oQo(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,i){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized||await this._initPromise,this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={api_key:this.apiKey,batch:[this.prepareMessage(t,r,i)],sent_at:Hdc()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),u=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${OJp()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,c=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(nHn.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(u,c)}catch(d){this._events.emit("error",d)}}prepareMessage(t,r,i){let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:Hdc(),uuid:i?.uuid?i.uuid:Qdc()};return(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId),n}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await jJp(t)})}async flush(){let t=mJp([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),mJp([t]).then(()=>{this.flushPromise===t&&(this.flushPromise=null)}),t}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(gue.Queue)||[];if(!t.length)return;let r=[],i=t.length;for(;t.length>0&&r.length<i;){let n=t.slice(0,this.maxBatchSize),a=n.map(b=>b.message),u=()=>{let g=(this.getPersistedProperty(gue.Queue)||[]).slice(n.length);this.setPersistedProperty(gue.Queue,g),t=g},c={api_key:this.apiKey,batch:a,sent_at:Hdc()};this.historicalMigration&&(c.historical_migration=!0);let d=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${OJp()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,o=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(nHn.compressToBase64(d))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:d},l={retryCheck:b=>wJp(b)?!1:$dc(b)};try{await this.fetchWithRetry(s,o,l)}catch(b){if(wJp(b)&&a.length>1){this.maxBatchSize=Math.max(1,Math.floor(a.length/2)),this.logMsgIfDebug(()=>console.warn(`Received 413 when sending batch of size ${a.length}, reducing batch size to ${this.maxBatchSize}`));continue}throw b instanceof Z7a||u(),this._events.emit("error",b),b}u(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,i,n){var a;(a=AbortSignal).timeout??(a.timeout=function(s){let o=new AbortController;return setTimeout(()=>o.abort(),s),o.signal});let u=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(u,KJD)}catch{c=new TextEncoder().encode(u).length}return await kJD(async()=>{let d=null;try{d=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(o){throw new Z7a(o)}if(!(r.mode==="no-cors")&&(d.status<200||d.status>=400))throw new uHn(d,c);return d},{...this._retryOptions,...i})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let i=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(gue.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!$dc(n))throw n;await jJp(n)}};return Promise.race([new Promise((n,a)=>{oQo(()=>{this.logMsgIfDebug(()=>console.error("Timed out while shutting down PostHog")),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),i()])}async shutdown(t=3e4){return this.shutdownPromise?this.logMsgIfDebug(()=>console.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup")):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}},Xdc=eKD();if(!Xdc){let e=tJp();Xdc=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var LJp=Xdc,uQo=class{constructor(t){this.factory=t}async getValue(){return this.value!==void 0?this.value:(this.initializationPromise===void 0&&(this.initializationPromise=(async()=>{try{let t=await this.factory();return this.value=t,t}finally{this.initializationPromise=void 0}})()),this.initializationPromise)}isInitialized(){return this.value!==void 0}async waitForInitialization(){this.isInitialized()||await this.getValue()}},UJp=new uQo(async()=>{try{return await import("crypto")}catch{return}});async function nKD(){return await UJp.getValue()}var aKD=new uQo(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await UJp.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function oKD(){return await aKD.getValue()}async function uKD(e){let t=await nKD();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await oKD();if(r){let i=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(i)).map(a=>a.toString(16).padStart(2,"0")).join("")}throw new Error("No crypto implementation available. Tried Node Crypto API and Web SubtleCrypto API")}var sKD=60*1e3,cKD=1152921504606847e3,lKD=["is_not"],aHn=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},h5=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Zdc=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=c.fetch||LJp,this.onError=c.onError,this.customHeaders=u,this.onLoad=c.onLoad,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,c;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){c=d;break}if(c!==void 0)try{u=await this.computeFlagLocally(c,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof h5?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async d=>{try{let s=await this.computeFlagLocally(d,t,r,i,n);a[d.key]=s;let o=await this.computeFeatureFlagPayloadLocally(d.key,s);o&&(u[d.key]=o)}catch(s){s instanceof h5||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),c=!0}})),{response:a,payloads:u,fallbackToDecide:c}}async computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new h5("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let d=this.groupTypeMapping[String(c)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new h5("Flag has unknown group type index");if(!(d in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[d];return await this.matchFeatureFlagProperties(t,i[d],s)}else return await this.matchFeatureFlagProperties(t,r,n)}async matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,c,d=[...a].sort((s,o)=>{let l=!!s.variant,b=!!o.variant;return l&&b?0:l?-1:b?1:0});for(let s of d)try{if(await this.isConditionMatch(t,r,s,i)){let o=s.variant,l=n.multivariate?.variants||[];o&&l.some(b=>b.key===o)?c=o:c=await this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof h5)u=!0;else throw o}if(c!==void 0)return c;if(u)throw new h5("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((i.properties||[]).length>0){for(let c of i.properties){let d=c.type,s=!1;if(d==="cohort"?s=WJp(c,n,this.cohorts,this.debugMode):s=VJp(c,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&await SJp(t.key,r)>a/100)}async getMatchingVariant(t,r){let i=await SJp(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{n=i+c.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:c.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(sKD,this.pollingInterval*2**this.backOffCount):this.pollingInterval}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.getPollingInterval());try{let t=await this._requestFeatureFlagDefinitions();if(!t)return;switch(t.status){case 401:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new aHn(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new aHn(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new aHn(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let r=await t.json()??{};if(!("flags"in r)){this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`));return}this.featureFlags=r.flags??[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||{},this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof aHn&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET"){return{method:t,headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions(),i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=oQo(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,i=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;n=oQo(()=>{a.abort()},this.timeout),i.signal=a.signal}try{return this.fetch(r,i)}finally{clearTimeout(n)}}};async function SJp(e,t,r=""){let i=await uKD(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/cKD}function VJp(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new h5("Operator is_not_set is not supported")}else throw new h5(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!lKD.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,o){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function d(s,o,l){if(l==="gt")return s>o;if(l==="gte")return s>=o;if(l==="lt")return s<o;if(l==="lte")return s<=o;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(n,u);case"is_not":return!c(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return DJp(String(n))&&String(u).match(String(n))!==null;case"not_regex":return DJp(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?d(u,String(n),a):d(u,s,a):d(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=fKD(String(n));if(s==null&&(s=EJp(n)),s==null)throw new h5(`Invalid date: ${n}`);let o=EJp(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new h5(`Unknown operator: ${a}`)}}function WJp(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new h5("can't match cohort without a given cohort property value");let a=r[n];return HJp(a,t,r,i)}function HJp(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let c of a)try{let d=HJp(c,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof h5)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),u=!0;else throw d}if(u)throw new h5("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let c of a)try{let d;c.type==="cohort"?d=WJp(c,t,r,i):d=VJp(c,t);let s=c.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof h5)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),u=!0;else throw d}if(u)throw new h5("can't match cohort without a given cohort property value");return n==="AND"}}function DJp(e){try{return new RegExp(e),!0}catch{return!1}}function EJp(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new h5(`${e} is in an invalid date format`)}else throw new h5(`The date provided ${e} must be a string, number, or date object`)}function fKD(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var kdc=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},dKD=100,MJp=30*1e3,pKD=50*1e3,epc=class extends Ydc{constructor(t,r={}){if(super(t,r),this._memoryStorage=new kdc,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,dKD):MJp,r.personalApiKey){if(r.personalApiKey.includes("phc_"))throw new Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');this.featureFlagsPoller=new Zdc({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},onLoad:i=>{this._events.emit("localEvaluationFlagsLoaded",i)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new oHn(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||pKD}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):LJp(t,r)}getLibraryVersion(){return VJD}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:u,timestamp:c,disableGeoip:d,uuid:s}=t,o=g=>{super.captureStateless(r,i,g,{timestamp:c,disableGeoip:d,uuid:s})},l=async(g,O,m)=>(await super.getFeatureFlagsStateless(g,O,void 0,void 0,m)).flags,b=Promise.resolve().then(async()=>{if(u)return await l(r,a,d);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let g={};for(let[O,m]of Object.entries(a||{}))g[O]=String(m);return await this.getAllFlags(r,{groups:g,disableGeoip:d,onlyEvaluateLocally:!0})}return{}}).then(g=>{let O={};if(g)for(let[P,D]of Object.entries(g))O[`$feature/${P}`]=D;let m=Object.keys(g||{}).filter(P=>g?.[P]!==!1).sort();return m.length>0&&(O.$active_feature_flags=m),O}).catch(()=>({})).then(g=>{o({...g,...n,$groups:a})});this.addPendingPromise(b)}async captureImmediate(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:u,timestamp:c,disableGeoip:d,uuid:s}=t,o=g=>super.captureStatelessImmediate(r,i,g,{timestamp:c,disableGeoip:d,uuid:s}),l=async(g,O,m)=>(await super.getFeatureFlagsStateless(g,O,void 0,void 0,m)).flags;await Promise.resolve().then(async()=>{if(u)return await l(r,a,d);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let g={};for(let[O,m]of Object.entries(a||{}))g[O]=String(m);return await this.getAllFlags(r,{groups:g,disableGeoip:d,onlyEvaluateLocally:!0})}return{}}).then(g=>{let O={};if(g)for(let[P,D]of Object.entries(g))O[`$feature/${P}`]=D;let m=Object.keys(g||{}).filter(P=>g?.[P]!==!1).sort();return m.length>0&&(O.$active_feature_flags=m),O}).catch(()=>({})).then(g=>{o({...g,...n,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:n},{disableGeoip:i})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=MJp){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let i=setTimeout(()=>{n(),r(!1)},t),n=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(i),n(),r(a>0)})})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:c,personProperties:d,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,d,s);d=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),b=l!==void 0,g,O;if(!b&&!u){let P=await super.getFeatureFlagDetailStateless(t,r,n,d,s,a);if(P===void 0)return;O=P.response,l=ipc(O),g=P?.requestId}let m=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(m))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(m):this.distinctIdHasSentFlagCalls[r]=[m],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:O?.metadata?.id,$feature_flag_version:O?.metadata?.version,$feature_flag_reason:O?.reason?.description??O?.reason?.code,locally_evaluated:b,[`$feature/${t}`]:l,$feature_flag_request_id:g},groups:n,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:d,personProperties:s,groupProperties:o}=n||{},l=this.addLocalPersonAndGroupProperties(r,a,s,o);s=l.allPersonProperties,o=l.allGroupProperties;let b;return this.featureFlagsPoller!==void 0&&(i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i))),c==null&&(c=!1),d==null&&(d=!0),c==null&&(c=!1),!(b!==void 0)&&!c&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:c}=r||{},d=this.addLocalPersonAndGroupProperties(t,i,u,c);u=d.allPersonProperties,c=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,c),o={},l={},b=!0;if(s&&(o=s.response,l=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,c,n);o={...o,...g.flags||{}},l={...l,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let c of Object.keys(r))u[c]={$group_key:r[c],...n?.[c]||{}};return{allPersonProperties:a,allGroupProperties:u}}captureException(t,r,i){let n=new Error("PostHog syntheticException");oHn.captureException(this,t,{syntheticException:n},r,i)}},AJp=/\(error: (.*)\)/,$Jp=50,GJp="?";function _KD(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return i=>{let n=i.match(r);if(n){let a,u,c,d,s;if(n[1]){c=n[1];let b=c.lastIndexOf(".");if(c[b-1]==="."&&b--,b>0){a=c.slice(0,b),u=c.slice(b+1);let g=a.indexOf(".Module");g>0&&(c=c.slice(g+1),a=a.slice(0,g))}d=void 0}u&&(d=a,s=u),u==="<anonymous>"&&(s=void 0,c=void 0),c===void 0&&(s=s||GJp,c=d?`${d}.${s}`:s);let o=n[2]?.startsWith("file://")?n[2].slice(7):n[2],l=n[5]==="native";return o?.match(/\/[A-Z]:/)&&(o=o.slice(1)),!o&&n[5]&&!l&&(o=n[5]),{filename:o?decodeURI(o):void 0,module:e?e(o):void 0,function:c,lineno:qJp(n[3]),colno:qJp(n[4]),in_app:hKD(o||"",l),platform:"node:javascript"}}if(i.match(t))return{filename:i,platform:"node:javascript"}}}function hKD(e,t=!1){return!(t||e&&!e.startsWith("/")&&!e.match(/^[A-Z]:/)&&!e.startsWith(".")&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&e!==void 0&&!e.includes("node_modules/")}function qJp(e){return parseInt(e||"",10)||void 0}function yKD(e){return[90,_KD(e)]}function vKD(e){let r=[yKD(e)].sort((i,n)=>i[0]-n[0]).map(i=>i[1]);return(i,n=0)=>{let a=[],u=i.split(`
|
|
1713
|
-
`);for(let c=n;c<u.length;c++){let d=u[c];if(d.length>1024)continue;let s=AJp.test(d)?d.replace(AJp,"$1"):d;if(!s.match(/\S*Error: /)){for(let o of r){let l=o(s);if(l){a.push(l);break}}if(a.length>=$Jp)break}}return bKD(a)}}function bKD(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,$Jp).map(r=>({...r,filename:r.filename||gKD(t).filename,function:r.function||GJp}))}function gKD(e){return e[e.length-1]||{}}oHn.stackParser=vKD(AJD());oHn.frameModifiers=[CJD];var sHn=class extends epc{getLibraryId(){return"posthog-node"}};var sQo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new sHn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.66.30",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var k7a=class{async sendEvent(){}async identify(){}async flush(){}};var lHn=require("fs/promises"),YJp=require("os"),XJp=require("path");var QJp=ci(require("crypto")),lQo=new Uint8Array(256),cQo=lQo.length;function npc(){return cQo>lQo.length-16&&(QJp.default.randomFillSync(lQo),cQo=0),lQo.slice(cQo,cQo+=16)}var d$=[];for(let e=0;e<256;++e)d$.push((e+256).toString(16).slice(1));function JJp(e,t=0){return d$[e[t+0]]+d$[e[t+1]]+d$[e[t+2]]+d$[e[t+3]]+"-"+d$[e[t+4]]+d$[e[t+5]]+"-"+d$[e[t+6]]+d$[e[t+7]]+"-"+d$[e[t+8]]+d$[e[t+9]]+"-"+d$[e[t+10]]+d$[e[t+11]]+d$[e[t+12]]+d$[e[t+13]]+d$[e[t+14]]+d$[e[t+15]]}var KJp=ci(require("crypto")),apc={randomUUID:KJp.default.randomUUID};function OKD(e,t,r){if(apc.randomUUID&&!t&&!e)return apc.randomUUID();e=e||{};let i=e.random||(e.rng||npc)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return JJp(i)}var Oue=OKD;var mKD="id",PKD=".fern",eFa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new sHn(r),this.userId=t==null?void 0:Hac(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.66.30",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Bu($c.of((0,YJp.homedir)()),za.of(PKD),za.of(mKD));await Cf(t)||(await(0,lHn.mkdir)((0,XJp.dirname)(t),{recursive:!0}),await(0,lHn.writeFile)(t,Oue())),this.persistedDistinctId=(await(0,lHn.readFile)(t)).toString()}return this.persistedDistinctId}};var opc;async function fHn(){return opc==null&&(opc=await jKD()),opc}async function jKD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new k7a;let r=await DLo();return r!=null?new eFa({token:r,posthogApiKey:e}):await uVn()!=null?new sQo({posthogApiKey:e}):new eFa({token:void 0,posthogApiKey:e})}catch{return new k7a}}function tFa(e,t){return function(){return e.apply(t,arguments)}}var{toString:wKD}=Object.prototype,{getPrototypeOf:spc}=Object,{iterator:dQo,toStringTag:kJp}=Symbol,pQo=(e=>t=>{let r=wKD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),kGt=e=>(e=e.toLowerCase(),t=>pQo(t)===e),_Qo=e=>t=>typeof t===e,{isArray:dHn}=Array,rFa=_Qo("undefined");function SKD(e){return e!==null&&!rFa(e)&&e.constructor!==null&&!rFa(e.constructor)&&mue(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var eKp=kGt("ArrayBuffer");function DKD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&eKp(e.buffer),t}var EKD=_Qo("string"),mue=_Qo("function"),tKp=_Qo("number"),hQo=e=>e!==null&&typeof e=="object",MKD=e=>e===!0||e===!1,fQo=e=>{if(pQo(e)!=="object")return!1;let t=spc(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(kJp in e)&&!(dQo in e)},AKD=kGt("Date"),qKD=kGt("File"),TKD=kGt("Blob"),CKD=kGt("FileList"),BKD=e=>hQo(e)&&mue(e.pipe),IKD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||mue(e.append)&&((t=pQo(e))==="formdata"||t==="object"&&mue(e.toString)&&e.toString()==="[object FormData]"))},zKD=kGt("URLSearchParams"),[xKD,RKD,NKD,FKD]=["ReadableStream","Request","Response","Headers"].map(kGt),LKD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function iFa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),dHn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,c;for(i=0;i<u;i++)c=a[i],t.call(null,e[c],c,e)}}function rKp(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var Ktn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,iKp=e=>!rFa(e)&&e!==Ktn;function upc(){let{caseless:e}=iKp(this)&&this||{},t={},r=(i,n)=>{let a=e&&rKp(t,n)||n;fQo(t[a])&&fQo(i)?t[a]=upc(t[a],i):fQo(i)?t[a]=upc({},i):dHn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&iFa(arguments[i],r);return t}var UKD=(e,t,r,{allOwnKeys:i}={})=>(iFa(t,(n,a)=>{r&&mue(n)?e[a]=tFa(n,r):e[a]=n},{allOwnKeys:i}),e),VKD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),WKD=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},HKD=(e,t,r,i)=>{let n,a,u,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!c[u]&&(t[u]=e[u],c[u]=!0);e=r!==!1&&spc(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},$KD=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},GKD=e=>{if(!e)return null;if(dHn(e))return e;let t=e.length;if(!tKp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},QKD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&spc(Uint8Array)),JKD=(e,t)=>{let i=(e&&e[dQo]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},KKD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},YKD=kGt("HTMLFormElement"),XKD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),ZJp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),ZKD=kGt("RegExp"),nKp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};iFa(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},kKD=e=>{nKp(e,(t,r)=>{if(mue(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(mue(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},eYD=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return dHn(e)?i(e):i(String(e).split(t)),r},tYD=()=>{},rYD=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function iYD(e){return!!(e&&mue(e.append)&&e[kJp]==="FormData"&&e[dQo])}var nYD=e=>{let t=new Array(10),r=(i,n)=>{if(hQo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=dHn(i)?[]:{};return iFa(i,(u,c)=>{let d=r(u,n+1);!rFa(d)&&(a[c]=d)}),t[n]=void 0,a}}return i};return r(e,0)},aYD=kGt("AsyncFunction"),oYD=e=>e&&(hQo(e)||mue(e))&&mue(e.then)&&mue(e.catch),aKp=((e,t)=>e?setImmediate:t?((r,i)=>(Ktn.addEventListener("message",({source:n,data:a})=>{n===Ktn&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),Ktn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",mue(Ktn.postMessage)),uYD=typeof queueMicrotask<"u"?queueMicrotask.bind(Ktn):typeof process<"u"&&process.nextTick||aKp,sYD=e=>e!=null&&mue(e[dQo]),hs={isArray:dHn,isArrayBuffer:eKp,isBuffer:SKD,isFormData:IKD,isArrayBufferView:DKD,isString:EKD,isNumber:tKp,isBoolean:MKD,isObject:hQo,isPlainObject:fQo,isReadableStream:xKD,isRequest:RKD,isResponse:NKD,isHeaders:FKD,isUndefined:rFa,isDate:AKD,isFile:qKD,isBlob:TKD,isRegExp:ZKD,isFunction:mue,isStream:BKD,isURLSearchParams:zKD,isTypedArray:QKD,isFileList:CKD,forEach:iFa,merge:upc,extend:UKD,trim:LKD,stripBOM:VKD,inherits:WKD,toFlatObject:HKD,kindOf:pQo,kindOfTest:kGt,endsWith:$KD,toArray:GKD,forEachEntry:JKD,matchAll:KKD,isHTMLForm:YKD,hasOwnProperty:ZJp,hasOwnProp:ZJp,reduceDescriptors:nKp,freezeMethods:kKD,toObjectSet:eYD,toCamelCase:XKD,noop:tYD,toFiniteNumber:rYD,findKey:rKp,global:Ktn,isContextDefined:iKp,isSpecCompliantForm:iYD,toJSONObject:nYD,isAsyncFn:aYD,isThenable:oYD,setImmediate:aKp,asap:uYD,isIterable:sYD};function pHn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}hs.inherits(pHn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:hs.toJSONObject(this.config),code:this.code,status:this.status}}});var oKp=pHn.prototype,uKp={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{uKp[e]={value:e}});Object.defineProperties(pHn,uKp);Object.defineProperty(oKp,"isAxiosError",{value:!0});pHn.from=(e,t,r,i,n,a)=>{let u=Object.create(oKp);return hs.toFlatObject(e,u,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),pHn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var o_=pHn;var sKp=ci(xGo(),1),yQo=sKp.default;function cpc(e){return hs.isPlainObject(e)||hs.isArray(e)}function lKp(e){return hs.endsWith(e,"[]")?e.slice(0,-2):e}function cKp(e,t,r){return e?e.concat(t).map(function(n,a){return n=lKp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function cYD(e){return hs.isArray(e)&&!e.some(cpc)}var lYD=hs.toFlatObject(hs,{},null,function(t){return/^is[A-Z]/.test(t)});function fYD(e,t,r){if(!hs.isObject(e))throw new TypeError("target must be an object");t=t||new(yQo||FormData),r=hs.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,P){return!hs.isUndefined(P[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&hs.isSpecCompliantForm(t);if(!hs.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(hs.isDate(O))return O.toISOString();if(hs.isBoolean(O))return O.toString();if(!d&&hs.isBlob(O))throw new o_("Blob is not supported. Use a Buffer instead.");return hs.isArrayBuffer(O)||hs.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,P){let D=O;if(O&&!P&&typeof O=="object"){if(hs.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(hs.isArray(O)&&cYD(O)||(hs.isFileList(O)||hs.endsWith(m,"[]"))&&(D=hs.toArray(O)))return m=lKp(m),D.forEach(function(M,E){!(hs.isUndefined(M)||M===null)&&t.append(u===!0?cKp([m],E,a):u===null?m:m+"[]",s(M))}),!1}return cpc(O)?!0:(t.append(cKp(P,m,a),s(O)),!1)}let l=[],b=Object.assign(lYD,{defaultVisitor:o,convertValue:s,isVisitable:cpc});function g(O,m){if(!hs.isUndefined(O)){if(l.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));l.push(O),hs.forEach(O,function(D,A){(!(hs.isUndefined(D)||D===null)&&n.call(t,D,hs.isString(A)?A.trim():A,m,b))===!0&&g(D,m?m.concat(A):[A])}),l.pop()}}if(!hs.isObject(e))throw new TypeError("data must be an object");return g(e),t}var Fxi=fYD;function fKp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function dKp(e,t){this._pairs=[],e&&Fxi(e,this,t)}var pKp=dKp.prototype;pKp.append=function(t,r){this._pairs.push([t,r])};pKp.toString=function(t){let r=t?function(i){return t.call(this,i,fKp)}:fKp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var _Kp=dKp;function dYD(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Ytn(e,t,r){if(!t)return e;let i=r&&r.encode||dYD;hs.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=hs.isURLSearchParams(t)?t.toString():new _Kp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var lpc=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){hs.forEach(this.handlers,function(i){i!==null&&t(i)})}},fpc=lpc;var _Hn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var bKp=ci(require("crypto"),1);var hKp=ci(require("url"),1),yKp=hKp.default.URLSearchParams;var dpc="abcdefghijklmnopqrstuvwxyz",vKp="0123456789",gKp={DIGIT:vKp,ALPHA:dpc,ALPHA_DIGIT:dpc+dpc.toUpperCase()+vKp},pYD=(e=16,t=gKp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);bKp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},OKp={isNode:!0,classes:{URLSearchParams:yKp,FormData:yQo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:gKp,generateString:pYD,protocols:["http","https","file","data"]};var hpc={};xa(hpc,{hasBrowserEnv:()=>_pc,hasStandardBrowserEnv:()=>_YD,hasStandardBrowserWebWorkerEnv:()=>hYD,navigator:()=>ppc,origin:()=>yYD});var _pc=typeof window<"u"&&typeof document<"u",ppc=typeof navigator=="object"&&navigator||void 0,_YD=_pc&&(!ppc||["ReactNative","NativeScript","NS"].indexOf(ppc.product)<0),hYD=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",yYD=_pc&&window.location.href||"http://localhost";var lq={...hpc,...OKp};function ypc(e,t){return Fxi(e,new lq.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return lq.isNode&&hs.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function vYD(e){return hs.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function bYD(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function gYD(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let c=Number.isFinite(+u),d=a>=r.length;return u=!u&&hs.isArray(n)?n.length:u,d?(hs.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!c):((!n[u]||!hs.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&hs.isArray(n[u])&&(n[u]=bYD(n[u])),!c)}if(hs.isFormData(e)&&hs.isFunction(e.entries)){let r={};return hs.forEachEntry(e,(i,n)=>{t(vYD(i),n,r,0)}),r}return null}var vQo=gYD;function OYD(e,t,r){if(hs.isString(e))try{return(t||JSON.parse)(e),hs.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var vpc={transitional:_Hn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=hs.isObject(t);if(a&&hs.isHTMLForm(t)&&(t=new FormData(t)),hs.isFormData(t))return n?JSON.stringify(vQo(t)):t;if(hs.isArrayBuffer(t)||hs.isBuffer(t)||hs.isStream(t)||hs.isFile(t)||hs.isBlob(t)||hs.isReadableStream(t))return t;if(hs.isArrayBufferView(t))return t.buffer;if(hs.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return ypc(t,this.formSerializer).toString();if((c=hs.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return Fxi(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),OYD(t)):t}],transformResponse:[function(t){let r=this.transitional||vpc.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(hs.isResponse(t)||hs.isReadableStream(t))return t;if(t&&hs.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(c){if(u)throw c.name==="SyntaxError"?o_.from(c,o_.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:lq.classes.FormData,Blob:lq.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};hs.forEach(["delete","get","head","post","put","patch"],e=>{vpc.headers[e]={}});var hHn=vpc;var mYD=hs.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),mKp=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1713
|
+
`);for(let c=n;c<u.length;c++){let d=u[c];if(d.length>1024)continue;let s=AJp.test(d)?d.replace(AJp,"$1"):d;if(!s.match(/\S*Error: /)){for(let o of r){let l=o(s);if(l){a.push(l);break}}if(a.length>=$Jp)break}}return bKD(a)}}function bKD(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,$Jp).map(r=>({...r,filename:r.filename||gKD(t).filename,function:r.function||GJp}))}function gKD(e){return e[e.length-1]||{}}oHn.stackParser=vKD(AJD());oHn.frameModifiers=[CJD];var sHn=class extends epc{getLibraryId(){return"posthog-node"}};var sQo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new sHn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.66.31",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var k7a=class{async sendEvent(){}async identify(){}async flush(){}};var lHn=require("fs/promises"),YJp=require("os"),XJp=require("path");var QJp=ci(require("crypto")),lQo=new Uint8Array(256),cQo=lQo.length;function npc(){return cQo>lQo.length-16&&(QJp.default.randomFillSync(lQo),cQo=0),lQo.slice(cQo,cQo+=16)}var d$=[];for(let e=0;e<256;++e)d$.push((e+256).toString(16).slice(1));function JJp(e,t=0){return d$[e[t+0]]+d$[e[t+1]]+d$[e[t+2]]+d$[e[t+3]]+"-"+d$[e[t+4]]+d$[e[t+5]]+"-"+d$[e[t+6]]+d$[e[t+7]]+"-"+d$[e[t+8]]+d$[e[t+9]]+"-"+d$[e[t+10]]+d$[e[t+11]]+d$[e[t+12]]+d$[e[t+13]]+d$[e[t+14]]+d$[e[t+15]]}var KJp=ci(require("crypto")),apc={randomUUID:KJp.default.randomUUID};function OKD(e,t,r){if(apc.randomUUID&&!t&&!e)return apc.randomUUID();e=e||{};let i=e.random||(e.rng||npc)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return JJp(i)}var Oue=OKD;var mKD="id",PKD=".fern",eFa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new sHn(r),this.userId=t==null?void 0:Hac(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.66.31",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Bu($c.of((0,YJp.homedir)()),za.of(PKD),za.of(mKD));await Cf(t)||(await(0,lHn.mkdir)((0,XJp.dirname)(t),{recursive:!0}),await(0,lHn.writeFile)(t,Oue())),this.persistedDistinctId=(await(0,lHn.readFile)(t)).toString()}return this.persistedDistinctId}};var opc;async function fHn(){return opc==null&&(opc=await jKD()),opc}async function jKD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new k7a;let r=await DLo();return r!=null?new eFa({token:r,posthogApiKey:e}):await uVn()!=null?new sQo({posthogApiKey:e}):new eFa({token:void 0,posthogApiKey:e})}catch{return new k7a}}function tFa(e,t){return function(){return e.apply(t,arguments)}}var{toString:wKD}=Object.prototype,{getPrototypeOf:spc}=Object,{iterator:dQo,toStringTag:kJp}=Symbol,pQo=(e=>t=>{let r=wKD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),kGt=e=>(e=e.toLowerCase(),t=>pQo(t)===e),_Qo=e=>t=>typeof t===e,{isArray:dHn}=Array,rFa=_Qo("undefined");function SKD(e){return e!==null&&!rFa(e)&&e.constructor!==null&&!rFa(e.constructor)&&mue(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var eKp=kGt("ArrayBuffer");function DKD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&eKp(e.buffer),t}var EKD=_Qo("string"),mue=_Qo("function"),tKp=_Qo("number"),hQo=e=>e!==null&&typeof e=="object",MKD=e=>e===!0||e===!1,fQo=e=>{if(pQo(e)!=="object")return!1;let t=spc(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(kJp in e)&&!(dQo in e)},AKD=kGt("Date"),qKD=kGt("File"),TKD=kGt("Blob"),CKD=kGt("FileList"),BKD=e=>hQo(e)&&mue(e.pipe),IKD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||mue(e.append)&&((t=pQo(e))==="formdata"||t==="object"&&mue(e.toString)&&e.toString()==="[object FormData]"))},zKD=kGt("URLSearchParams"),[xKD,RKD,NKD,FKD]=["ReadableStream","Request","Response","Headers"].map(kGt),LKD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function iFa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),dHn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,c;for(i=0;i<u;i++)c=a[i],t.call(null,e[c],c,e)}}function rKp(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var Ktn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,iKp=e=>!rFa(e)&&e!==Ktn;function upc(){let{caseless:e}=iKp(this)&&this||{},t={},r=(i,n)=>{let a=e&&rKp(t,n)||n;fQo(t[a])&&fQo(i)?t[a]=upc(t[a],i):fQo(i)?t[a]=upc({},i):dHn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&iFa(arguments[i],r);return t}var UKD=(e,t,r,{allOwnKeys:i}={})=>(iFa(t,(n,a)=>{r&&mue(n)?e[a]=tFa(n,r):e[a]=n},{allOwnKeys:i}),e),VKD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),WKD=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},HKD=(e,t,r,i)=>{let n,a,u,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!c[u]&&(t[u]=e[u],c[u]=!0);e=r!==!1&&spc(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},$KD=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},GKD=e=>{if(!e)return null;if(dHn(e))return e;let t=e.length;if(!tKp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},QKD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&spc(Uint8Array)),JKD=(e,t)=>{let i=(e&&e[dQo]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},KKD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},YKD=kGt("HTMLFormElement"),XKD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),ZJp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),ZKD=kGt("RegExp"),nKp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};iFa(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},kKD=e=>{nKp(e,(t,r)=>{if(mue(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(mue(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},eYD=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return dHn(e)?i(e):i(String(e).split(t)),r},tYD=()=>{},rYD=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function iYD(e){return!!(e&&mue(e.append)&&e[kJp]==="FormData"&&e[dQo])}var nYD=e=>{let t=new Array(10),r=(i,n)=>{if(hQo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=dHn(i)?[]:{};return iFa(i,(u,c)=>{let d=r(u,n+1);!rFa(d)&&(a[c]=d)}),t[n]=void 0,a}}return i};return r(e,0)},aYD=kGt("AsyncFunction"),oYD=e=>e&&(hQo(e)||mue(e))&&mue(e.then)&&mue(e.catch),aKp=((e,t)=>e?setImmediate:t?((r,i)=>(Ktn.addEventListener("message",({source:n,data:a})=>{n===Ktn&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),Ktn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",mue(Ktn.postMessage)),uYD=typeof queueMicrotask<"u"?queueMicrotask.bind(Ktn):typeof process<"u"&&process.nextTick||aKp,sYD=e=>e!=null&&mue(e[dQo]),hs={isArray:dHn,isArrayBuffer:eKp,isBuffer:SKD,isFormData:IKD,isArrayBufferView:DKD,isString:EKD,isNumber:tKp,isBoolean:MKD,isObject:hQo,isPlainObject:fQo,isReadableStream:xKD,isRequest:RKD,isResponse:NKD,isHeaders:FKD,isUndefined:rFa,isDate:AKD,isFile:qKD,isBlob:TKD,isRegExp:ZKD,isFunction:mue,isStream:BKD,isURLSearchParams:zKD,isTypedArray:QKD,isFileList:CKD,forEach:iFa,merge:upc,extend:UKD,trim:LKD,stripBOM:VKD,inherits:WKD,toFlatObject:HKD,kindOf:pQo,kindOfTest:kGt,endsWith:$KD,toArray:GKD,forEachEntry:JKD,matchAll:KKD,isHTMLForm:YKD,hasOwnProperty:ZJp,hasOwnProp:ZJp,reduceDescriptors:nKp,freezeMethods:kKD,toObjectSet:eYD,toCamelCase:XKD,noop:tYD,toFiniteNumber:rYD,findKey:rKp,global:Ktn,isContextDefined:iKp,isSpecCompliantForm:iYD,toJSONObject:nYD,isAsyncFn:aYD,isThenable:oYD,setImmediate:aKp,asap:uYD,isIterable:sYD};function pHn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}hs.inherits(pHn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:hs.toJSONObject(this.config),code:this.code,status:this.status}}});var oKp=pHn.prototype,uKp={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{uKp[e]={value:e}});Object.defineProperties(pHn,uKp);Object.defineProperty(oKp,"isAxiosError",{value:!0});pHn.from=(e,t,r,i,n,a)=>{let u=Object.create(oKp);return hs.toFlatObject(e,u,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),pHn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var o_=pHn;var sKp=ci(xGo(),1),yQo=sKp.default;function cpc(e){return hs.isPlainObject(e)||hs.isArray(e)}function lKp(e){return hs.endsWith(e,"[]")?e.slice(0,-2):e}function cKp(e,t,r){return e?e.concat(t).map(function(n,a){return n=lKp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function cYD(e){return hs.isArray(e)&&!e.some(cpc)}var lYD=hs.toFlatObject(hs,{},null,function(t){return/^is[A-Z]/.test(t)});function fYD(e,t,r){if(!hs.isObject(e))throw new TypeError("target must be an object");t=t||new(yQo||FormData),r=hs.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,P){return!hs.isUndefined(P[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&hs.isSpecCompliantForm(t);if(!hs.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(hs.isDate(O))return O.toISOString();if(hs.isBoolean(O))return O.toString();if(!d&&hs.isBlob(O))throw new o_("Blob is not supported. Use a Buffer instead.");return hs.isArrayBuffer(O)||hs.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,P){let D=O;if(O&&!P&&typeof O=="object"){if(hs.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(hs.isArray(O)&&cYD(O)||(hs.isFileList(O)||hs.endsWith(m,"[]"))&&(D=hs.toArray(O)))return m=lKp(m),D.forEach(function(M,E){!(hs.isUndefined(M)||M===null)&&t.append(u===!0?cKp([m],E,a):u===null?m:m+"[]",s(M))}),!1}return cpc(O)?!0:(t.append(cKp(P,m,a),s(O)),!1)}let l=[],b=Object.assign(lYD,{defaultVisitor:o,convertValue:s,isVisitable:cpc});function g(O,m){if(!hs.isUndefined(O)){if(l.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));l.push(O),hs.forEach(O,function(D,A){(!(hs.isUndefined(D)||D===null)&&n.call(t,D,hs.isString(A)?A.trim():A,m,b))===!0&&g(D,m?m.concat(A):[A])}),l.pop()}}if(!hs.isObject(e))throw new TypeError("data must be an object");return g(e),t}var Fxi=fYD;function fKp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function dKp(e,t){this._pairs=[],e&&Fxi(e,this,t)}var pKp=dKp.prototype;pKp.append=function(t,r){this._pairs.push([t,r])};pKp.toString=function(t){let r=t?function(i){return t.call(this,i,fKp)}:fKp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var _Kp=dKp;function dYD(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Ytn(e,t,r){if(!t)return e;let i=r&&r.encode||dYD;hs.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=hs.isURLSearchParams(t)?t.toString():new _Kp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var lpc=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){hs.forEach(this.handlers,function(i){i!==null&&t(i)})}},fpc=lpc;var _Hn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var bKp=ci(require("crypto"),1);var hKp=ci(require("url"),1),yKp=hKp.default.URLSearchParams;var dpc="abcdefghijklmnopqrstuvwxyz",vKp="0123456789",gKp={DIGIT:vKp,ALPHA:dpc,ALPHA_DIGIT:dpc+dpc.toUpperCase()+vKp},pYD=(e=16,t=gKp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);bKp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},OKp={isNode:!0,classes:{URLSearchParams:yKp,FormData:yQo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:gKp,generateString:pYD,protocols:["http","https","file","data"]};var hpc={};xa(hpc,{hasBrowserEnv:()=>_pc,hasStandardBrowserEnv:()=>_YD,hasStandardBrowserWebWorkerEnv:()=>hYD,navigator:()=>ppc,origin:()=>yYD});var _pc=typeof window<"u"&&typeof document<"u",ppc=typeof navigator=="object"&&navigator||void 0,_YD=_pc&&(!ppc||["ReactNative","NativeScript","NS"].indexOf(ppc.product)<0),hYD=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",yYD=_pc&&window.location.href||"http://localhost";var lq={...hpc,...OKp};function ypc(e,t){return Fxi(e,new lq.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return lq.isNode&&hs.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function vYD(e){return hs.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function bYD(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function gYD(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let c=Number.isFinite(+u),d=a>=r.length;return u=!u&&hs.isArray(n)?n.length:u,d?(hs.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!c):((!n[u]||!hs.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&hs.isArray(n[u])&&(n[u]=bYD(n[u])),!c)}if(hs.isFormData(e)&&hs.isFunction(e.entries)){let r={};return hs.forEachEntry(e,(i,n)=>{t(vYD(i),n,r,0)}),r}return null}var vQo=gYD;function OYD(e,t,r){if(hs.isString(e))try{return(t||JSON.parse)(e),hs.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var vpc={transitional:_Hn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=hs.isObject(t);if(a&&hs.isHTMLForm(t)&&(t=new FormData(t)),hs.isFormData(t))return n?JSON.stringify(vQo(t)):t;if(hs.isArrayBuffer(t)||hs.isBuffer(t)||hs.isStream(t)||hs.isFile(t)||hs.isBlob(t)||hs.isReadableStream(t))return t;if(hs.isArrayBufferView(t))return t.buffer;if(hs.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return ypc(t,this.formSerializer).toString();if((c=hs.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return Fxi(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),OYD(t)):t}],transformResponse:[function(t){let r=this.transitional||vpc.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(hs.isResponse(t)||hs.isReadableStream(t))return t;if(t&&hs.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(c){if(u)throw c.name==="SyntaxError"?o_.from(c,o_.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:lq.classes.FormData,Blob:lq.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};hs.forEach(["delete","get","head","post","put","patch"],e=>{vpc.headers[e]={}});var hHn=vpc;var mYD=hs.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),mKp=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1714
1714
|
`).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&mYD[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var PKp=Symbol("internals");function nFa(e){return e&&String(e).trim().toLowerCase()}function bQo(e){return e===!1||e==null?e:hs.isArray(e)?e.map(bQo):String(e)}function PYD(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,i;for(;i=r.exec(e);)t[i[1]]=i[2];return t}var jYD=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function bpc(e,t,r,i,n){if(hs.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!hs.isString(t)){if(hs.isString(i))return t.indexOf(i)!==-1;if(hs.isRegExp(i))return i.test(t)}}function wYD(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function SYD(e,t){let r=hs.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,u){return this[i].call(this,t,n,a,u)},configurable:!0})})}var yHn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,d,s){let o=nFa(d);if(!o)throw new Error("header name must be a non-empty string");let l=hs.findKey(n,o);(!l||n[l]===void 0||s===!0||s===void 0&&n[l]!==!1)&&(n[l||d]=bQo(c))}let u=(c,d)=>hs.forEach(c,(s,o)=>a(s,o,d));if(hs.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(hs.isString(t)&&(t=t.trim())&&!jYD(t))u(mKp(t),r);else if(hs.isObject(t)&&hs.isIterable(t)){let c={},d,s;for(let o of t){if(!hs.isArray(o))throw TypeError("Object iterator must return a key-value pair");c[s=o[0]]=(d=c[s])?hs.isArray(d)?[...d,o[1]]:[d,o[1]]:o[1]}u(c,r)}else t!=null&&a(r,t,i);return this}get(t,r){if(t=nFa(t),t){let i=hs.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return PYD(n);if(hs.isFunction(r))return r.call(this,n,i);if(hs.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=nFa(t),t){let i=hs.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||bpc(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=nFa(u),u){let c=hs.findKey(i,u);c&&(!r||bpc(i,i[c],c,r))&&(delete i[c],n=!0)}}return hs.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||bpc(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return hs.forEach(this,(n,a)=>{let u=hs.findKey(i,a);if(u){r[u]=bQo(n),delete r[a];return}let c=t?wYD(a):String(a).trim();c!==a&&delete r[a],r[c]=bQo(n),i[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return hs.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&hs.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
1715
1715
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[PKp]=this[PKp]={accessors:{}}).accessors,n=this.prototype;function a(u){let c=nFa(u);i[c]||(SYD(n,u),i[c]=!0)}return hs.isArray(t)?t.forEach(a):a(t),this}};yHn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);hs.reduceDescriptors(yHn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});hs.freezeMethods(yHn);var mN=yHn;function aFa(e,t){let r=this||hHn,i=t||r,n=mN.from(i.headers),a=i.data;return hs.forEach(e,function(c){a=c.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function oFa(e){return!!(e&&e.__CANCEL__)}function jKp(e,t,r){o_.call(this,e??"canceled",o_.ERR_CANCELED,t,r),this.name="CanceledError"}hs.inherits(jKp,o_,{__CANCEL__:!0});var nqe=jKp;function har(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new o_("Request failed with status code "+r.status,[o_.ERR_BAD_REQUEST,o_.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function gpc(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Opc(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Xtn(e,t,r){let i=!gpc(t);return e&&(i||r==!1)?Opc(e,t):t}var FKp=ci(V7a(),1),LKp=ci(require("http"),1),UKp=ci(require("https"),1),VKp=ci(require("util"),1),WKp=ci(Odc(),1),WOi=ci(require("zlib"),1);var Ztn="1.10.0";function uFa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var DYD=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function mpc(e,t,r){let i=r&&r.Blob||lq.classes.Blob,n=uFa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=DYD.exec(e);if(!a)throw new o_("Invalid URL",o_.ERR_INVALID_URL);let u=a[1],c=a[2],d=a[3],s=Buffer.from(decodeURIComponent(d),c?"base64":"utf8");if(t){if(!i)throw new o_("Blob is not supported",o_.ERR_NOT_SUPPORT);return new i([s],{type:u})}return s}throw new o_("Unsupported protocol "+n,o_.ERR_NOT_SUPPORT)}var ern=ci(require("stream"),1);var wKp=ci(require("stream"),1);var Ppc=Symbol("internals"),jpc=class extends wKp.default.Transform{constructor(t){t=hs.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!hs.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[Ppc]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",i=>{i==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[Ppc];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[Ppc],a=n.maxRate,u=this.readableHighWaterMark,c=n.timeWindow,d=1e3/c,s=a/d,o=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,l=(g,O)=>{let m=Buffer.byteLength(g);n.bytesSeen+=m,n.bytes+=m,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(g)?process.nextTick(O):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(O)}},b=(g,O)=>{let m=Buffer.byteLength(g),P=null,D=u,A,M=0;if(a){let E=Date.now();(!n.ts||(M=E-n.ts)>=c)&&(n.ts=E,A=s-n.bytes,n.bytes=A<0?-A:0,M=0),A=s-n.bytes}if(a){if(A<=0)return setTimeout(()=>{O(null,g)},c-M);A<D&&(D=A)}D&&m>D&&m-D>o&&(P=g.subarray(D),g=g.subarray(0,D)),l(g,P?()=>{process.nextTick(O,null,P)}:O)};b(t,function g(O,m){if(O)return i(O);m?b(m,g):i(null)})}},wpc=jpc;var HKp=require("events");var DKp=ci(require("util"),1),EKp=require("stream");var{asyncIterator:SKp}=Symbol,EYD=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[SKp]?yield*e[SKp]():yield e},gQo=EYD;var MYD=lq.ALPHABET.ALPHA_DIGIT+"-_",sFa=typeof TextEncoder=="function"?new TextEncoder:new DKp.default.TextEncoder,ktn=`\r
|
|
1716
1716
|
`,AYD=sFa.encode(ktn),qYD=2,Spc=class{constructor(t,r){let{escapeName:i}=this.constructor,n=hs.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${ktn}`;n?r=sFa.encode(String(r).replace(/\r?\n|\r\n?/g,ktn)):a+=`Content-Type: ${r.type||"application/octet-stream"}${ktn}`,this.headers=sFa.encode(a+ktn),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+qYD,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;hs.isTypedArray(t)?yield t:yield*gQo(t),yield AYD}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},TYD=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+lq.generateString(n,MYD)}=r||{};if(!hs.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let u=sFa.encode("--"+a+ktn),c=sFa.encode("--"+a+"--"+ktn),d=c.byteLength,s=Array.from(e.entries()).map(([l,b])=>{let g=new Spc(l,b);return d+=g.size,g});d+=u.byteLength*s.length,d=hs.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),EKp.Readable.from(async function*(){for(let l of s)yield u,yield*l.encode();yield c}())},MKp=TYD;var AKp=ci(require("stream"),1),Dpc=class extends AKp.default.Transform{__transform(t,r,i){this.push(t),i()}_transform(t,r,i){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let n=Buffer.alloc(2);n[0]=120,n[1]=156,this.push(n,r)}this.__transform(t,r,i)}},qKp=Dpc;var CYD=(e,t)=>hs.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,TKp=CYD;function BYD(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,u;return t=t!==void 0?t:1e3,function(d){let s=Date.now(),o=i[a];u||(u=s),r[n]=d,i[n]=s;let l=a,b=0;for(;l!==n;)b+=r[l++],l=l%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-u<t)return;let g=o&&s-o;return g?Math.round(b*1e3/g):void 0}}var CKp=BYD;function IYD(e,t){let r=0,i=1e3/t,n,a,u=(s,o=Date.now())=>{r=o,n=null,a&&(clearTimeout(a),a=null),e.apply(null,s)};return[(...s)=>{let o=Date.now(),l=o-r;l>=i?u(s,o):(n=s,a||(a=setTimeout(()=>{a=null,u(n)},i-l)))},()=>n&&u(n)]}var BKp=IYD;var VOi=(e,t,r=3)=>{let i=0,n=CKp(50,250);return BKp(a=>{let u=a.loaded,c=a.lengthComputable?a.total:void 0,d=u-i,s=n(d),o=u<=c;i=u;let l={loaded:u,total:c,progress:c?u/c:void 0,bytes:d,rate:s||void 0,estimated:s&&c&&o?(c-u)/s:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},vHn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},bHn=e=>(...t)=>hs.asap(()=>e(...t));var IKp={flush:WOi.default.constants.Z_SYNC_FLUSH,finishFlush:WOi.default.constants.Z_SYNC_FLUSH},zYD={flush:WOi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:WOi.default.constants.BROTLI_OPERATION_FLUSH},zKp=hs.isFunction(WOi.default.createBrotliDecompress),{http:xYD,https:RYD}=WKp.default,NYD=/https:?/,xKp=lq.protocols.map(e=>e+":"),RKp=(e,[t,r])=>(e.on("end",r).on("error",r),t);function FYD(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function $Kp(e,t,r){let i=t;if(!i&&i!==!1){let n=FKp.default.getProxyForUrl(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){$Kp(a,t,a.href)}}var LYD=typeof process<"u"&&hs.kindOf(process)==="process",UYD=e=>new Promise((t,r)=>{let i,n,a=(d,s)=>{n||(n=!0,i&&i(d,s))},u=d=>{a(d),t(d)},c=d=>{a(d,!0),r(d)};e(u,c,d=>i=d).catch(c)}),VYD=({address:e,family:t})=>{if(!hs.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},NKp=(e,t)=>VYD(hs.isObject(e)?e:{address:e,family:t}),GKp=LYD&&function(t){return UYD(async function(i,n,a){let{data:u,lookup:c,family:d}=t,{responseType:s,responseEncoding:o}=t,l=t.method.toUpperCase(),b,g=!1,O;if(c){let me=TKp(c,Le=>hs.isArray(Le)?Le:[Le]);c=(Le,vt,De)=>{me(Le,vt,(Ae,Ct,Pe)=>{if(Ae)return De(Ae);let St=hs.isArray(Ct)?Ct.map(at=>NKp(at)):[NKp(Ct,Pe)];vt.all?De(Ae,St):De(Ae,St[0].address,St[0].family)})}}let m=new HKp.EventEmitter,P=()=>{t.cancelToken&&t.cancelToken.unsubscribe(D),t.signal&&t.signal.removeEventListener("abort",D),m.removeAllListeners()};a((me,Le)=>{b=!0,Le&&(g=!0,P())});function D(me){m.emit("abort",!me||me.type?new nqe(null,t,O):me)}m.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(D),t.signal&&(t.signal.aborted?D():t.signal.addEventListener("abort",D)));let A=Xtn(t.baseURL,t.url,t.allowAbsoluteUrls),M=new URL(A,lq.hasBrowserEnv?lq.origin:void 0),E=M.protocol||xKp[0];if(E==="data:"){let me;if(l!=="GET")return har(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{me=mpc(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Le){throw o_.from(Le,o_.ERR_BAD_REQUEST,t)}return s==="text"?(me=me.toString(o),(!o||o==="utf8")&&(me=hs.stripBOM(me))):s==="stream"&&(me=ern.default.Readable.from(me)),har(i,n,{data:me,status:200,statusText:"OK",headers:new mN,config:t})}if(xKp.indexOf(E)===-1)return n(new o_("Unsupported protocol "+E,o_.ERR_BAD_REQUEST,t));let T=mN.from(t.headers).normalize();T.set("User-Agent","axios/"+Ztn,!1);let{onUploadProgress:z,onDownloadProgress:$}=t,I=t.maxRate,N,U;if(hs.isSpecCompliantForm(u)){let me=T.getContentType(/boundary=([-_\w\d]{10,70})/i);u=MKp(u,Le=>{T.set(Le)},{tag:`axios-${Ztn}-boundary`,boundary:me&&me[1]||void 0})}else if(hs.isFormData(u)&&hs.isFunction(u.getHeaders)){if(T.set(u.getHeaders()),!T.hasContentLength())try{let me=await VKp.default.promisify(u.getLength).call(u);Number.isFinite(me)&&me>=0&&T.setContentLength(me)}catch{}}else if(hs.isBlob(u)||hs.isFile(u))u.size&&T.setContentType(u.type||"application/octet-stream"),T.setContentLength(u.size||0),u=ern.default.Readable.from(gQo(u));else if(u&&!hs.isStream(u)){if(!Buffer.isBuffer(u))if(hs.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(hs.isString(u))u=Buffer.from(u,"utf-8");else return n(new o_("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",o_.ERR_BAD_REQUEST,t));if(T.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new o_("Request body larger than maxBodyLength limit",o_.ERR_BAD_REQUEST,t))}let Y=hs.toFiniteNumber(T.getContentLength());hs.isArray(I)?(N=I[0],U=I[1]):N=U=I,u&&(z||N)&&(hs.isStream(u)||(u=ern.default.Readable.from(u,{objectMode:!1})),u=ern.default.pipeline([u,new wpc({maxRate:hs.toFiniteNumber(N)})],hs.noop),z&&u.on("progress",RKp(u,vHn(Y,VOi(bHn(z),!1,3)))));let J;if(t.auth){let me=t.auth.username||"",Le=t.auth.password||"";J=me+":"+Le}if(!J&&M.username){let me=M.username,Le=M.password;J=me+":"+Le}J&&T.delete("authorization");let X;try{X=Ytn(M.pathname+M.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(me){let Le=new Error(me.message);return Le.config=t,Le.url=t.url,Le.exists=!0,n(Le)}T.set("Accept-Encoding","gzip, compress, deflate"+(zKp?", br":""),!1);let oe={path:X,method:l,headers:T.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:J,protocol:E,family:d,beforeRedirect:FYD,beforeRedirects:{}};!hs.isUndefined(c)&&(oe.lookup=c),t.socketPath?oe.socketPath=t.socketPath:(oe.hostname=M.hostname.startsWith("[")?M.hostname.slice(1,-1):M.hostname,oe.port=M.port,$Kp(oe,t.proxy,E+"//"+M.hostname+(M.port?":"+M.port:"")+oe.path));let pe,de=NYD.test(oe.protocol);if(oe.agent=de?t.httpsAgent:t.httpAgent,t.transport?pe=t.transport:t.maxRedirects===0?pe=de?UKp.default:LKp.default:(t.maxRedirects&&(oe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(oe.beforeRedirects.config=t.beforeRedirect),pe=de?RYD:xYD),t.maxBodyLength>-1?oe.maxBodyLength=t.maxBodyLength:oe.maxBodyLength=1/0,t.insecureHTTPParser&&(oe.insecureHTTPParser=t.insecureHTTPParser),O=pe.request(oe,function(Le){if(O.destroyed)return;let vt=[Le],De=+Le.headers["content-length"];if($||U){let at=new wpc({maxRate:hs.toFiniteNumber(U)});$&&at.on("progress",RKp(at,vHn(De,VOi(bHn($),!0,3)))),vt.push(at)}let Ae=Le,Ct=Le.req||O;if(t.decompress!==!1&&Le.headers["content-encoding"])switch((l==="HEAD"||Le.statusCode===204)&&delete Le.headers["content-encoding"],(Le.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":vt.push(WOi.default.createUnzip(IKp)),delete Le.headers["content-encoding"];break;case"deflate":vt.push(new qKp),vt.push(WOi.default.createUnzip(IKp)),delete Le.headers["content-encoding"];break;case"br":zKp&&(vt.push(WOi.default.createBrotliDecompress(zYD)),delete Le.headers["content-encoding"])}Ae=vt.length>1?ern.default.pipeline(vt,hs.noop):vt[0];let Pe=ern.default.finished(Ae,()=>{Pe(),P()}),St={status:Le.statusCode,statusText:Le.statusMessage,headers:new mN(Le.headers),config:t,request:Ct};if(s==="stream")St.data=Ae,har(i,n,St);else{let at=[],Oe=0;Ae.on("data",function(bt){at.push(bt),Oe+=bt.length,t.maxContentLength>-1&&Oe>t.maxContentLength&&(g=!0,Ae.destroy(),n(new o_("maxContentLength size of "+t.maxContentLength+" exceeded",o_.ERR_BAD_RESPONSE,t,Ct)))}),Ae.on("aborted",function(){if(g)return;let bt=new o_("stream has been aborted",o_.ERR_BAD_RESPONSE,t,Ct);Ae.destroy(bt),n(bt)}),Ae.on("error",function(bt){O.destroyed||n(o_.from(bt,null,t,Ct))}),Ae.on("end",function(){try{let bt=at.length===1?at[0]:Buffer.concat(at);s!=="arraybuffer"&&(bt=bt.toString(o),(!o||o==="utf8")&&(bt=hs.stripBOM(bt))),St.data=bt}catch(bt){return n(o_.from(bt,null,t,St.request,St))}har(i,n,St)})}m.once("abort",at=>{Ae.destroyed||(Ae.emit("error",at),Ae.destroy())})}),m.once("abort",me=>{n(me),O.destroy(me)}),O.on("error",function(Le){n(o_.from(Le,null,t,O))}),O.on("socket",function(Le){Le.setKeepAlive(!0,1e3*60)}),t.timeout){let me=parseInt(t.timeout,10);if(Number.isNaN(me)){n(new o_("error trying to parse `config.timeout` to int",o_.ERR_BAD_OPTION_VALUE,t,O));return}O.setTimeout(me,function(){if(b)return;let vt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",De=t.transitional||_Hn;t.timeoutErrorMessage&&(vt=t.timeoutErrorMessage),n(new o_(vt,De.clarifyTimeoutError?o_.ETIMEDOUT:o_.ECONNABORTED,t,O)),D()})}if(hs.isStream(u)){let me=!1,Le=!1;u.on("end",()=>{me=!0}),u.once("error",vt=>{Le=!0,O.destroy(vt)}),u.on("close",()=>{!me&&!Le&&D(new nqe("Request stream has been aborted",t,O))}),u.pipe(O)}else O.end(u)})};var QKp=lq.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,lq.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(lq.origin),lq.navigator&&/(msie|trident)/i.test(lq.navigator.userAgent)):()=>!0;var JKp=lq.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];hs.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),hs.isString(i)&&u.push("path="+i),hs.isString(n)&&u.push("domain="+n),a===!0&&u.push("secure"),document.cookie=u.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var KKp=e=>e instanceof mN?{...e}:e;function eQt(e,t){t=t||{};let r={};function i(s,o,l,b){return hs.isPlainObject(s)&&hs.isPlainObject(o)?hs.merge.call({caseless:b},s,o):hs.isPlainObject(o)?hs.merge({},o):hs.isArray(o)?o.slice():o}function n(s,o,l,b){if(hs.isUndefined(o)){if(!hs.isUndefined(s))return i(void 0,s,l,b)}else return i(s,o,l,b)}function a(s,o){if(!hs.isUndefined(o))return i(void 0,o)}function u(s,o){if(hs.isUndefined(o)){if(!hs.isUndefined(s))return i(void 0,s)}else return i(void 0,o)}function c(s,o,l){if(l in t)return i(s,o);if(l in e)return i(void 0,s)}let d={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:c,headers:(s,o,l)=>n(KKp(s),KKp(o),l,!0)};return hs.forEach(Object.keys(Object.assign({},e,t)),function(o){let l=d[o]||n,b=l(e[o],t[o],o);hs.isUndefined(b)&&l!==c||(r[o]=b)}),r}var OQo=e=>{let t=eQt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:c}=t;t.headers=u=mN.from(u),t.url=Ytn(Xtn(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&u.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let d;if(hs.isFormData(r)){if(lq.hasStandardBrowserEnv||lq.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((d=u.getContentType())!==!1){let[s,...o]=d?d.split(";").map(l=>l.trim()).filter(Boolean):[];u.setContentType([s||"multipart/form-data",...o].join("; "))}}if(lq.hasStandardBrowserEnv&&(i&&hs.isFunction(i)&&(i=i(t)),i||i!==!1&&QKp(t.url))){let s=n&&a&&JKp.read(a);s&&u.set(n,s)}return t};var WYD=typeof XMLHttpRequest<"u",YKp=WYD&&function(e){return new Promise(function(r,i){let n=OQo(e),a=n.data,u=mN.from(n.headers).normalize(),{responseType:c,onUploadProgress:d,onDownloadProgress:s}=n,o,l,b,g,O;function m(){g&&g(),O&&O(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let P=new XMLHttpRequest;P.open(n.method.toUpperCase(),n.url,!0),P.timeout=n.timeout;function D(){if(!P)return;let M=mN.from("getAllResponseHeaders"in P&&P.getAllResponseHeaders()),T={data:!c||c==="text"||c==="json"?P.responseText:P.response,status:P.status,statusText:P.statusText,headers:M,config:e,request:P};har(function($){r($),m()},function($){i($),m()},T),P=null}"onloadend"in P?P.onloadend=D:P.onreadystatechange=function(){!P||P.readyState!==4||P.status===0&&!(P.responseURL&&P.responseURL.indexOf("file:")===0)||setTimeout(D)},P.onabort=function(){P&&(i(new o_("Request aborted",o_.ECONNABORTED,e,P)),P=null)},P.onerror=function(){i(new o_("Network Error",o_.ERR_NETWORK,e,P)),P=null},P.ontimeout=function(){let E=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",T=n.transitional||_Hn;n.timeoutErrorMessage&&(E=n.timeoutErrorMessage),i(new o_(E,T.clarifyTimeoutError?o_.ETIMEDOUT:o_.ECONNABORTED,e,P)),P=null},a===void 0&&u.setContentType(null),"setRequestHeader"in P&&hs.forEach(u.toJSON(),function(E,T){P.setRequestHeader(T,E)}),hs.isUndefined(n.withCredentials)||(P.withCredentials=!!n.withCredentials),c&&c!=="json"&&(P.responseType=n.responseType),s&&([b,O]=VOi(s,!0),P.addEventListener("progress",b)),d&&P.upload&&([l,g]=VOi(d),P.upload.addEventListener("progress",l),P.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(o=M=>{P&&(i(!M||M.type?new nqe(null,e,P):M),P.abort(),P=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let A=uFa(n.url);if(A&&lq.protocols.indexOf(A)===-1){i(new o_("Unsupported protocol "+A+":",o_.ERR_BAD_REQUEST,e));return}P.send(a||null)})};var HYD=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,c();let o=s instanceof Error?s:this.reason;i.abort(o instanceof o_?o:new nqe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new o_(`timeout ${t} of ms exceeded`,o_.ETIMEDOUT))},t),c=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:d}=i;return d.unsubscribe=()=>hs.asap(c),d}},XKp=HYD;var $YD=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let i=0,n;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},GYD=async function*(e,t){for await(let r of QYD(e))yield*$YD(r,t)},QYD=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:i}=await t.read();if(r)break;yield i}}finally{await t.cancel()}},Epc=(e,t,r,i)=>{let n=GYD(e,t),a=0,u,c=d=>{u||(u=!0,i&&i(d))};return new ReadableStream({async pull(d){try{let{done:s,value:o}=await n.next();if(s){c(),d.close();return}let l=o.byteLength;if(r){let b=a+=l;r(b)}d.enqueue(new Uint8Array(o))}catch(s){throw c(s),s}},cancel(d){return c(d),n.return()}},{highWaterMark:2})};var PQo=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",kKp=PQo&&typeof ReadableStream=="function",JYD=PQo&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),eYp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},KYD=kKp&&eYp(()=>{let e=!1,t=new Request(lq.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),ZKp=64*1024,Mpc=kKp&&eYp(()=>hs.isReadableStream(new Response("").body)),mQo={stream:Mpc&&(e=>e.body)};PQo&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!mQo[t]&&(mQo[t]=hs.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new o_(`Response type '${t}' is not supported`,o_.ERR_NOT_SUPPORT,i)})})})(new Response);var YYD=async e=>{if(e==null)return 0;if(hs.isBlob(e))return e.size;if(hs.isSpecCompliantForm(e))return(await new Request(lq.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(hs.isArrayBufferView(e)||hs.isArrayBuffer(e))return e.byteLength;if(hs.isURLSearchParams(e)&&(e=e+""),hs.isString(e))return(await JYD(e)).byteLength},XYD=async(e,t)=>{let r=hs.toFiniteNumber(e.getContentLength());return r??YYD(t)},tYp=PQo&&(async e=>{let{url:t,method:r,data:i,signal:n,cancelToken:a,timeout:u,onDownloadProgress:c,onUploadProgress:d,responseType:s,headers:o,withCredentials:l="same-origin",fetchOptions:b}=OQo(e);s=s?(s+"").toLowerCase():"text";let g=XKp([n,a&&a.toAbortSignal()],u),O,m=g&&g.unsubscribe&&(()=>{g.unsubscribe()}),P;try{if(d&&KYD&&r!=="get"&&r!=="head"&&(P=await XYD(o,i))!==0){let T=new Request(t,{method:"POST",body:i,duplex:"half"}),z;if(hs.isFormData(i)&&(z=T.headers.get("content-type"))&&o.setContentType(z),T.body){let[$,I]=vHn(P,VOi(bHn(d)));i=Epc(T.body,ZKp,$,I)}}hs.isString(l)||(l=l?"include":"omit");let D="credentials"in Request.prototype;O=new Request(t,{...b,signal:g,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:i,duplex:"half",credentials:D?l:void 0});let A=await fetch(O,b),M=Mpc&&(s==="stream"||s==="response");if(Mpc&&(c||M&&m)){let T={};["status","statusText","headers"].forEach(N=>{T[N]=A[N]});let z=hs.toFiniteNumber(A.headers.get("content-length")),[$,I]=c&&vHn(z,VOi(bHn(c),!0))||[];A=new Response(Epc(A.body,ZKp,$,()=>{I&&I(),m&&m()}),T)}s=s||"text";let E=await mQo[hs.findKey(mQo,s)||"text"](A,e);return!M&&m&&m(),await new Promise((T,z)=>{har(T,z,{data:E,headers:mN.from(A.headers),status:A.status,statusText:A.statusText,config:e,request:O})})}catch(D){throw m&&m(),D&&D.name==="TypeError"&&/Load failed|fetch/i.test(D.message)?Object.assign(new o_("Network Error",o_.ERR_NETWORK,e,O),{cause:D.cause||D}):o_.from(D,D&&D.code,e,O)}});var Apc={http:GKp,xhr:YKp,fetch:tYp};hs.forEach(Apc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var rYp=e=>`- ${e}`,ZYD=e=>hs.isFunction(e)||e===null||e===!1,jQo={getAdapter:e=>{e=hs.isArray(e)?e:[e];let{length:t}=e,r,i,n={};for(let a=0;a<t;a++){r=e[a];let u;if(i=r,!ZYD(r)&&(i=Apc[(u=String(r)).toLowerCase()],i===void 0))throw new o_(`Unknown adapter '${u}'`);if(i)break;n[u||"#"+a]=i}if(!i){let a=Object.entries(n).map(([c,d])=>`adapter ${c} `+(d===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
|
|
@@ -1954,10 +1954,10 @@ ${M}${A}${E}${zg_.default.cursorHide}`});function Tru({message:e,error:t,logger:
|
|
|
1954
1954
|
Run ${Bs.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1955
1955
|
Run ${Bs.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),OHn(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function Uwc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!nO_(e))return;let n=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((c,d)=>c.generatorName.localeCompare(d.generatorName)||c.currentVersion.localeCompare(d.currentVersion));for(let c of u)n+=`
|
|
1956
1956
|
${await HAE(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Bs.dim(c.currentVersion)+Bs.reset(" \u2192 ")+Bs.green(c.latestVersion);return n+=`
|
|
1957
|
-
`,i?OHn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function HAE(e){let r=await new iO_.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 $AE({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await oO_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,l)=>{c.versions[s]==null&&(c.versions[s]={});let b=AIi(o.name,l),g=await uir({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:l});g!=null&&(c.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),c}let u={type:"multiApi",versions:{}};return await oO_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,d,s,o)=>{if(c==null)return;u.versions[c]==null&&(u.versions[c]={}),u.versions[c][d]==null&&(u.versions[c][d]={});let l=AIi(s.name,o),b=await uir({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[c][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function oO_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let c=await AGt({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(c==null||c.groups==null)){for(let d of c.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function uO_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,c]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=xue(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function xru({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let c=await $AE({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[d,s]of Object.entries(c.versions))u.push(...uO_(s,d,t.logger));else u.push(...uO_(c.versions,void 0,t.logger))}return u}var _5a=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),c=u?`status code ${u}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var CJn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Vwc=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),sO_=typeof globalThis.AbortController=="function",cO_=typeof globalThis.ReadableStream=="function",lO_=typeof globalThis.FormData=="function",Rru=["get","post","put","patch","head","delete"],GAE=()=>{};GAE();var fO_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},Nru=2147483647,dO_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Fru=Symbol("stop"),pO_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},_O_={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var QAE=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=dO_,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},hO_=(e,t)=>{let r=Number(e.headers.get("content-length"))||0,i=0;return e.status===204?(t&&t({percent:1,totalBytes:r,transferredBytes:i},new Uint8Array),new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers})):new Response(new ReadableStream({async start(n){let a=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){let{done:c,value:d}=await a.read();if(c){n.close();return}if(t){i+=d.byteLength;let s=r===0?0:i/r;t({percent:s,transferredBytes:i,totalBytes:r},d)}n.enqueue(d),await u()}await u()}}),{status:e.status,statusText:e.statusText,headers:e.headers})},yO_=(e,t)=>{let r=QAE(e.body),i=0;return new Request(e,{duplex:"half",body:new ReadableStream({async start(n){let a=e.body instanceof ReadableStream?e.body.getReader():new Response("").body.getReader();async function u(){let{done:c,value:d}=await a.read();if(c){t&&t({percent:1,transferredBytes:i,totalBytes:Math.max(r,i)},new Uint8Array),n.close();return}i+=d.byteLength;let s=r===0?0:i/r;(r<i||s===1)&&(s=.99),t&&t({percent:Number(s.toFixed(2)),transferredBytes:i,totalBytes:r},d),n.enqueue(d),await u()}await u()}})})};var BJn=e=>e!==null&&typeof e=="object";var h5a=(...e)=>{for(let t of e)if((!BJn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return $wc({},...e)},Wwc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function Lru(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:$wc(e[r]??[],t[r]??[])}var Hwc=(e={},t={})=>({beforeRequest:Lru(e,t,"beforeRequest"),beforeRetry:Lru(e,t,"beforeRetry"),afterResponse:Lru(e,t,"afterResponse"),beforeError:Lru(e,t,"beforeError")}),$wc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(BJn(n)){for(let[a,u]of Object.entries(n))BJn(u)&&a in t&&(u=$wc(t[a],u)),t={...t,[a]:u};BJn(n.hooks)&&(i=Hwc(i,n.hooks),t.hooks=i),BJn(n.headers)&&(r=Wwc(r,n.headers),t.headers=r)}return t};var bO_=e=>Rru.includes(e)?e.toUpperCase():e,JAE=["get","put","head","delete","options","trace"],KAE=[408,413,429,500,502,503,504],YAE=[413,429,503],vO_={limit:2,methods:JAE,statusCodes:KAE,afterStatusCodes:YAE,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},gO_=(e={})=>{if(typeof e=="number")return{...vO_,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{...vO_,...e}};async function Gwc(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new CJn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function Qwc(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var OO_=(e,t)=>{let r={};for(let i in t)!(i in _O_)&&!(i in pO_)&&!(i in e)&&(r[i]=t[i]);return r};var y5a=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>Nru)throw new RangeError(`The \`timeout\` option cannot be greater than ${Nru}`);await Promise.resolve();let c=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let d=new _5a(c,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!cO_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return hO_(c.clone(),i._options.onDownloadProgress)}return c},u=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{i.request.bodyUsed||await i.request.body?.cancel()});for(let[c,d]of Object.entries(fO_))u[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let s=await u;if(c==="json"){if(s.status===204||(await s.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await s.text())}return s[c]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Wwc(this._input.headers,r.headers),hooks:Hwc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:bO_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:gO_(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(sO_){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(Vwc&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(lO_&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Vwc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=yO_(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof CJn)throw t;if(t instanceof _5a){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),Nru);if(this._retryCount<1)throw r;await Qwc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===Fru)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=OO_(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):Gwc(r,t,this.abortController,this._options)}};var Jwc=e=>{let t=(r,i)=>y5a.create(r,h5a(e,i));for(let r of Rru)t[r]=(i,n)=>y5a.create(i,h5a(e,n,{method:r}));return t.create=r=>Jwc(h5a(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Jwc(h5a(e,r))),t.stop=Fru,t},XAE=Jwc(),mO_=XAE;var HO_=ci(WO_(),1);function kwc(e){let t=(0,HO_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Nm_=ci(Rm_(),1),Fm_=ci(KIi(),1),d1c=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},p1c=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function _1c(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??kwc(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Nm_.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,c&&(d.authorization=`${c.type} ${c.token}`);let s;try{s=await mO_(u,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new d1c(e):l}if(t.allVersions)return s;let o=new p1c(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(i&&!l)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!l){let g=Object.keys(s.versions);if(r=Fm_.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function P5a(e,t){let{version:r}=await _1c(e.toLowerCase(),t);return r}async function gNi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:P5a(e.packageName,{version:t?"prerelease":"latest"})}var Lm_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Zru=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Ab.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new zru(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(n==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.66.30"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Bs.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new UL}failWithoutThrowing(t,r){this.didSucceed=!1,Tru({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await fHn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await aO_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1957
|
+
`,i?OHn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function HAE(e){let r=await new iO_.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 $AE({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await oO_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,l)=>{c.versions[s]==null&&(c.versions[s]={});let b=AIi(o.name,l),g=await uir({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:l});g!=null&&(c.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),c}let u={type:"multiApi",versions:{}};return await oO_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,d,s,o)=>{if(c==null)return;u.versions[c]==null&&(u.versions[c]={}),u.versions[c][d]==null&&(u.versions[c][d]={});let l=AIi(s.name,o),b=await uir({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[c][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function oO_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let c=await AGt({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(c==null||c.groups==null)){for(let d of c.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function uO_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,c]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=xue(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function xru({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let c=await $AE({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[d,s]of Object.entries(c.versions))u.push(...uO_(s,d,t.logger));else u.push(...uO_(c.versions,void 0,t.logger))}return u}var _5a=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),c=u?`status code ${u}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var CJn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Vwc=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),sO_=typeof globalThis.AbortController=="function",cO_=typeof globalThis.ReadableStream=="function",lO_=typeof globalThis.FormData=="function",Rru=["get","post","put","patch","head","delete"],GAE=()=>{};GAE();var fO_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},Nru=2147483647,dO_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Fru=Symbol("stop"),pO_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},_O_={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var QAE=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=dO_,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},hO_=(e,t)=>{let r=Number(e.headers.get("content-length"))||0,i=0;return e.status===204?(t&&t({percent:1,totalBytes:r,transferredBytes:i},new Uint8Array),new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers})):new Response(new ReadableStream({async start(n){let a=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){let{done:c,value:d}=await a.read();if(c){n.close();return}if(t){i+=d.byteLength;let s=r===0?0:i/r;t({percent:s,transferredBytes:i,totalBytes:r},d)}n.enqueue(d),await u()}await u()}}),{status:e.status,statusText:e.statusText,headers:e.headers})},yO_=(e,t)=>{let r=QAE(e.body),i=0;return new Request(e,{duplex:"half",body:new ReadableStream({async start(n){let a=e.body instanceof ReadableStream?e.body.getReader():new Response("").body.getReader();async function u(){let{done:c,value:d}=await a.read();if(c){t&&t({percent:1,transferredBytes:i,totalBytes:Math.max(r,i)},new Uint8Array),n.close();return}i+=d.byteLength;let s=r===0?0:i/r;(r<i||s===1)&&(s=.99),t&&t({percent:Number(s.toFixed(2)),transferredBytes:i,totalBytes:r},d),n.enqueue(d),await u()}await u()}})})};var BJn=e=>e!==null&&typeof e=="object";var h5a=(...e)=>{for(let t of e)if((!BJn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return $wc({},...e)},Wwc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function Lru(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:$wc(e[r]??[],t[r]??[])}var Hwc=(e={},t={})=>({beforeRequest:Lru(e,t,"beforeRequest"),beforeRetry:Lru(e,t,"beforeRetry"),afterResponse:Lru(e,t,"afterResponse"),beforeError:Lru(e,t,"beforeError")}),$wc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(BJn(n)){for(let[a,u]of Object.entries(n))BJn(u)&&a in t&&(u=$wc(t[a],u)),t={...t,[a]:u};BJn(n.hooks)&&(i=Hwc(i,n.hooks),t.hooks=i),BJn(n.headers)&&(r=Wwc(r,n.headers),t.headers=r)}return t};var bO_=e=>Rru.includes(e)?e.toUpperCase():e,JAE=["get","put","head","delete","options","trace"],KAE=[408,413,429,500,502,503,504],YAE=[413,429,503],vO_={limit:2,methods:JAE,statusCodes:KAE,afterStatusCodes:YAE,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},gO_=(e={})=>{if(typeof e=="number")return{...vO_,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{...vO_,...e}};async function Gwc(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new CJn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function Qwc(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var OO_=(e,t)=>{let r={};for(let i in t)!(i in _O_)&&!(i in pO_)&&!(i in e)&&(r[i]=t[i]);return r};var y5a=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>Nru)throw new RangeError(`The \`timeout\` option cannot be greater than ${Nru}`);await Promise.resolve();let c=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let d=new _5a(c,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!cO_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return hO_(c.clone(),i._options.onDownloadProgress)}return c},u=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{i.request.bodyUsed||await i.request.body?.cancel()});for(let[c,d]of Object.entries(fO_))u[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let s=await u;if(c==="json"){if(s.status===204||(await s.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await s.text())}return s[c]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Wwc(this._input.headers,r.headers),hooks:Hwc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:bO_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:gO_(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(sO_){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(Vwc&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(lO_&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Vwc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=yO_(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof CJn)throw t;if(t instanceof _5a){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),Nru);if(this._retryCount<1)throw r;await Qwc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===Fru)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=OO_(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):Gwc(r,t,this.abortController,this._options)}};var Jwc=e=>{let t=(r,i)=>y5a.create(r,h5a(e,i));for(let r of Rru)t[r]=(i,n)=>y5a.create(i,h5a(e,n,{method:r}));return t.create=r=>Jwc(h5a(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Jwc(h5a(e,r))),t.stop=Fru,t},XAE=Jwc(),mO_=XAE;var HO_=ci(WO_(),1);function kwc(e){let t=(0,HO_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Nm_=ci(Rm_(),1),Fm_=ci(KIi(),1),d1c=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},p1c=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function _1c(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??kwc(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Nm_.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,c&&(d.authorization=`${c.type} ${c.token}`);let s;try{s=await mO_(u,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new d1c(e):l}if(t.allVersions)return s;let o=new p1c(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(i&&!l)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!l){let g=Object.keys(s.versions);if(r=Fm_.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function P5a(e,t){let{version:r}=await _1c(e.toLowerCase(),t);return r}async function gNi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:P5a(e.packageName,{version:t?"prerelease":"latest"})}var Lm_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Zru=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Ab.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new zru(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(n==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.66.31"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Bs.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new UL}failWithoutThrowing(t,r){this.didSucceed=!1,Tru({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await fHn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await aO_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1958
1958
|
`)||(r+=`
|
|
1959
1959
|
`),this.stderr.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram({code:t}={}){process.exit(t??(this.didSucceed?0:1))}longestWorkspaceName;registerWorkspaces(t){let r=SHs(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new u5a(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let i=this.addTaskWithInit(t).start(),n;try{n=await r(i)}catch(a){throw a.message.includes("globalThis")?(i.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),i.failWithoutThrowing()):i.failWithoutThrowing(void 0,a),new UL}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await fHn()).sendEvent(t)}logger=mtr((t,...r)=>this.log(t,...r));stderr=mtr((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=Um_(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?Um_(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=Lm_[this.numTasks++%Lm_.length],u=Bs.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===LI.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let i=t.filter(n=>UBi.indexOf(n.level)>=UBi.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===Ab.Debug,stderr:r})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await gNi({cliEnvironment:this.environment,includePreReleases:t}),i=xue(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await xru({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await Dwc({message:t,default:r})}async getInput(t){return await Ewc({message:t.message,default:t.default})}};function Um_(e){return`[${e}]:`}var LQt=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};var Tqe=class extends LQt{definition;sources;type="fern";constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var Fmi={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!1,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1};function j5a({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??Fmi.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??Fmi.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??Fmi.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??Fmi.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??Fmi.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??Fmi.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??Fmi.inlinePathParameters,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??Fmi.useBytesForBinaryResponse,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??Fmi.respectForwardCompatibleEnums}}var RK={openapi:e=>({...e,type:"openapi",_visit:function(t){return RK._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return RK._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 LJn={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return LJn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var AU={basic:e=>({...e,type:"basic",_visit:function(t){return AU._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return AU._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return AU._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return AU._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return AU._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 rO={primitive:e=>({value:e,type:"primitive",_visit:function(t){return rO._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return rO._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return rO._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return rO._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return rO._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return rO._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return rO._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return rO._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 M_={int:e=>({value:e,type:"int",_visit:function(t){return M_._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return M_._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return M_._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return M_._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return M_._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return M_._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return M_._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return M_._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return M_._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return M_._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return M_._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 ONi={boolean:e=>({value:e,type:"boolean",_visit:function(t){return ONi._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return ONi._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 mNi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return mNi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return mNi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var S$={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case S$.GenerallyAvailable:return t.generallyAvailable();case S$.Beta:return t.beta();case S$.Deprecated:return t.deprecated();default:return t._other()}}};var DFe={cursor:e=>({...e,type:"cursor",_visit:function(t){return DFe._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return DFe._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return DFe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var Lmi={language:e=>({...e,type:"language",_visit:function(t){return Lmi._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return Lmi._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 D$={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 D$.Curl:return t.curl();case D$.Python:return t.python();case D$.Javascript:return t.javascript();case D$.Typescript:return t.typescript();case D$.Go:return t.go();case D$.Ruby:return t.ruby();case D$.Csharp:return t.csharp();case D$.Java:return t.java();case D$.Js:return t.js();case D$.Node:return t.node();case D$.Ts:return t.ts();case D$.Nodets:return t.nodets();case D$.Golang:return t.golang();case D$.Dotnet:return t.dotnet();case D$.Jvm:return t.jvm();default:return t._other()}}};var UQt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return UQt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return UQt._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 VQt={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return VQt._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return VQt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var E$={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case E$.Get:return t.get();case E$.Post:return t.post();case E$.Put:return t.put();case E$.Patch:return t.patch();case E$.Delete:return t.delete();case E$.Head:return t.head();case E$.Options:return t.options();case E$.Trace:return t.trace();default:return t._other()}}};var lor={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return lor._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return lor._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return lor._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return lor._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);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var Umi={file:e=>({...e,type:"file",_visit:function(t){return Umi._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return Umi._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 NK={file:e=>({...e,type:"file",_visit:function(t){return NK._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return NK._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return NK._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return NK._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return NK._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return NK._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return NK._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var wv={primitive:e=>({...e,type:"primitive",_visit:function(t){return wv._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return wv._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return wv._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return wv._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return wv._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return wv._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return wv._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return wv._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return wv._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return wv._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return wv._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 Ww={int:e=>({...e,type:"int",_visit:function(t){return Ww._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Ww._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Ww._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Ww._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Ww._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Ww._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Ww._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Ww._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Ww._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Ww._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Ww._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 mx={boolean:e=>({value:e,type:"boolean",_visit:function(t){return mx._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return mx._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 Vmi={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return Vmi._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return Vmi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var zee={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return zee._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return zee._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return zee._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return zee._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);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var EB={file:e=>({...e,type:"file",_visit:function(t){return EB._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return EB._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return EB._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return EB._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return EB._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return EB._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return EB._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Nl={primitive:e=>({...e,type:"primitive",_visit:function(t){return Nl._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Nl._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Nl._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Nl._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Nl._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Nl._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Nl._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Nl._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Nl._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Nl._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Nl._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 xee={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return xee._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return xee._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var bp={int:e=>({...e,type:"int",_visit:function(t){return bp._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return bp._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return bp._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return bp._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return bp._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return bp._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return bp._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return bp._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return bp._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return bp._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return bp._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 Bv={};xa(Bv,{AllOfPropertyConflict:()=>cKn,ArraySchema:()=>hnu,ArraySchemaWithExample:()=>Gnu,Availability:()=>siu,Base64WithExample:()=>Unu,BasicSecurityScheme:()=>fiu,BearerSecurityScheme:()=>diu,BooleanSchema:()=>cnu,BooleanWithExample:()=>Vnu,BytesResponse:()=>eKn,CasingOverrides:()=>hiu,CommonProperty:()=>jnu,CommonPropertyWithExample:()=>tau,CursorPagination:()=>Giu,CustomCodeSample:()=>Hiu,CustomCodeSampleLanguage:()=>Uiu,CustomCodeSampleSdk:()=>Wiu,CustomPagination:()=>Jiu,DateWithExample:()=>Lnu,DatetimeWithExample:()=>Fnu,DiscriminatedOneOfSchema:()=>mnu,DiscriminatedOneOfSchemaWithExample:()=>knu,DoubleSchema:()=>unu,DoubleWithExample:()=>Rnu,Encoding:()=>uiu,Endpoint:()=>Kiu,EndpointExample:()=>nKn,EndpointResponseExample:()=>Liu,EndpointSdkName:()=>_or,EndpointWithExample:()=>vP_,EnumSchema:()=>HJn,EnumSchemaWithExample:()=>Hnu,EnumValue:()=>wNi,ErrorExample:()=>ziu,FernExample:()=>Riu,FileResponse:()=>ZJn,FileSchema:()=>Eiu,FloatWithExample:()=>xnu,FormUrlEncodedRequest:()=>Ciu,FullEndpointExample:()=>$iu,FullExample:()=>QT,FullObjectExample:()=>Piu,FullOneOfExample:()=>wiu,GlobalHeader:()=>fnu,Header:()=>DNi,HeaderExample:()=>iKn,HeaderSecurityScheme:()=>piu,HeaderWithExample:()=>ANi,HttpEndpointServer:()=>tKn,HttpError:()=>xiu,HttpErrorWithExample:()=>Tnu,HttpMethod:()=>QJn,IdempotencyHeader:()=>dnu,Int64WithExample:()=>Bnu,IntSchema:()=>anu,IntWithExample:()=>Cnu,JsonRequest:()=>Tiu,JsonRequestWithExample:()=>Enu,JsonResponse:()=>kJn,JsonResponseWithExample:()=>dKn,KeyValuePair:()=>jiu,LiteralExample:()=>miu,LiteralSchema:()=>sKn,LiteralSchemaValue:()=>pnu,LongSchema:()=>onu,MapSchema:()=>ynu,MapSchemaWithExample:()=>Qnu,MultipartRequest:()=>XJn,MultipartRequestProperty:()=>qiu,MultipartRequestPropertyEncoding:()=>Aiu,MultipartSchema:()=>Miu,NamedFullExample:()=>MFe,Namespace:()=>yiu,NamespaceId:()=>Oiu,NullableSchema:()=>bnu,NullableSchemaWithExample:()=>Knu,OauthSecurityScheme:()=>biu,ObjectProperty:()=>Onu,ObjectPropertyConflictInfo:()=>lKn,ObjectPropertyWithExample:()=>Znu,ObjectSchema:()=>_nu,ObjectSchemaWithExample:()=>Ynu,OctetStreamRequest:()=>YJn,OffsetPagination:()=>Qiu,OneOfSchema:()=>gnu,OneOfSchemaWithExample:()=>Xnu,OpenApiIntermediateRepresentation:()=>hP_,OpenApiSource:()=>iiu,OptionalSchema:()=>vnu,OptionalSchemaWithExample:()=>Jnu,Pagination:()=>aKn,ParseFormUrlEncodedRequest:()=>Mnu,ParseMultipartRequest:()=>Dnu,ParseOctetStreamRequest:()=>Snu,PathParameter:()=>JJn,PathParameterExample:()=>Niu,PathParameterWithExample:()=>wnu,PrimitiveExample:()=>GJn,PrimitiveSchema:()=>MNi,PrimitiveSchemaValue:()=>lnu,PrimitiveSchemaValueWithExample:()=>Wnu,PrimitiveSchemaWithExample:()=>pKn,PropertyKey:()=>$Jn,ProtobufEncoding:()=>oiu,ProtobufSource:()=>niu,QueryParameter:()=>KJn,QueryParameterExample:()=>rKn,QueryParameterWithExample:()=>fKn,QuerySecurityScheme:()=>_iu,ReferencedSchema:()=>hor,Request:()=>Biu,RequestWithExample:()=>Anu,Response:()=>Iiu,ResponseWithExample:()=>qnu,Schema:()=>um,SchemaId:()=>Ree,SchemaWithExample:()=>VM,Schemas:()=>nnu,SdkGroup:()=>viu,SdkGroupInfo:()=>Siu,SdkGroupName:()=>SNi,SecurityScheme:()=>giu,SecuritySchemeId:()=>liu,Server:()=>E5a,Source:()=>aiu,StatusCode:()=>dor,StreamingResponseExample:()=>Fiu,StringSchema:()=>snu,StringSchemaWithExample:()=>Nnu,SupportedSdkLanguage:()=>Viu,Tag:()=>ciu,TagId:()=>Nee,Tags:()=>Diu,TextResponse:()=>ENi,Uint64WithExample:()=>znu,UintWithExample:()=>Inu,UnDiscriminatedOneOfSchema:()=>Pnu,UnDiscriminatedOneOfSchemaWithExample:()=>eau,UnknownSchemaWithExample:()=>$nu,Webhook:()=>Yiu,WebhookExampleCall:()=>uKn,WebhookHttpMethod:()=>oKn,WebhookWithExample:()=>bP_,WebsocketChannel:()=>inu,WebsocketHandshake:()=>Xiu,WebsocketHandshakeWithExample:()=>yP_,WebsocketMessageExample:()=>tnu,WebsocketMessageOrigin:()=>Ziu,WebsocketMessageSchema:()=>kiu,WebsocketServer:()=>enu,WebsocketSessionExample:()=>rnu,WithAvailability:()=>cy,WithDescription:()=>Of,WithEncoding:()=>Nue,WithInline:()=>UM,WithName:()=>bg,WithNamespace:()=>L0,WithSdkGroupName:()=>Jm,WithSdkMethodName:()=>por,WithSource:()=>zh,WithStatusCode:()=>EFe,WithTitle:()=>Qm,commons:()=>g1c,example:()=>O1c,finalIr:()=>m1c,parseIr:()=>P1c});var g1c={};xa(g1c,{BasicSecurityScheme:()=>fiu,BearerSecurityScheme:()=>diu,Encoding:()=>uiu,HeaderSecurityScheme:()=>piu,Namespace:()=>yiu,NamespaceId:()=>Oiu,OauthSecurityScheme:()=>biu,OpenApiSource:()=>iiu,ProtobufEncoding:()=>oiu,ProtobufSource:()=>niu,QuerySecurityScheme:()=>_iu,SchemaId:()=>Ree,SdkGroup:()=>viu,SdkGroupName:()=>SNi,SecurityScheme:()=>giu,SecuritySchemeId:()=>liu,Server:()=>E5a,Source:()=>aiu,StatusCode:()=>dor,Tag:()=>ciu,TagId:()=>Nee,WithAvailability:()=>cy,WithDescription:()=>Of,WithEncoding:()=>Nue,WithInline:()=>UM,WithName:()=>bg,WithNamespace:()=>L0,WithSdkGroupName:()=>Jm,WithSdkMethodName:()=>por,WithSource:()=>zh,WithStatusCode:()=>EFe,WithTitle:()=>Qm});var gt={};xa(gt,{JsonError:()=>UJn,ParseError:()=>VJn,any:()=>rP_,bigint:()=>Wm_,boolean:()=>iP_,booleanLiteral:()=>tP_,date:()=>Hm_,discriminant:()=>dP_,enum_:()=>eiu,getObjectLikeUtils:()=>WQt,getObjectUtils:()=>Vnn,getSchemaUtils:()=>GT,isProperty:()=>jNi,lazy:()=>$m_,lazyObject:()=>Zm_,list:()=>riu,number:()=>nP_,object:()=>tiu,objectWithoutOptionalProperties:()=>Xm_,optional:()=>h1c,property:()=>Qm_,record:()=>sP_,set:()=>cP_,string:()=>aP_,stringLiteral:()=>eP_,transform:()=>y1c,undiscriminatedUnion:()=>fP_,union:()=>_P_,unknown:()=>oP_,withParsedProperties:()=>b1c});var vw={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function _q(e,t){return`Expected ${t}. Received ${iTE(e)}.`}function iTE(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function qU(e){return{...e,json:Vm_(e.json),parse:Vm_(e.parse)}}function Vm_(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1960
|
-
`)),{ok:!0,value:t}):i}}function kru(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var UJn=class e extends Error{errors;constructor(t){super(t.map(kru).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var VJn=class e extends Error{errors;constructor(t){super(t.map(kru).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function GT(e){return{optional:()=>h1c(e),transform:t=>y1c(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new VJn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new UJn(i.errors)}}}function h1c(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>vw.OPTIONAL};return{...t,...GT(t)}}function y1c(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...GT(r)}}function Wm_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:_q(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:_q(t,"bigint")}]},getType:()=>vw.BIGINT};return{...qU(e),...GT(e)}}var nTE=/^([+-]?\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 Hm_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:_q(t,"string")}]}:nTE.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:_q(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:_q(t,"Date object")}]},getType:()=>vw.DATE};return{...qU(e),...GT(e)}}function FK(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...qU(r),...GT(r)}}}function eiu(e){let t=new Set(e);return FK(vw.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:_q(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:_q(i,"enum")}]}:{ok:!0,value:i})()}function $m_(e){let t=v1c(e);return{...t,...GT(t)}}function v1c(e){return{parse:(t,r)=>WJn(e).parse(t,r),json:(t,r)=>WJn(e).json(t,r),getType:()=>WJn(e).getType()}}function WJn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function w5a(e){return Object.entries(e)}function S5a(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function PNi(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 D5a(e){return Object.keys(e)}function Gm_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function WQt(e){return{withParsedProperties:t=>b1c(e,t)}}function b1c(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((c,[d,s])=>({...c,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!PNi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:_q(i,"object")}]};let a=new Set(Object.keys(t)),u=S5a(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...GT(r),...WQt(r)}}function Qm_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function jNi(e){return e.isProperty}function tiu(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>jNi(i)?i.rawKey:r),_getParsedProperties:()=>D5a(e),parse:(r,i)=>{let n={},a=[];for(let[u,c]of w5a(e)){let d=jNi(c)?c.rawKey:u,s=jNi(c)?c.valueSchema:c,o={rawKey:d,parsedKey:u,valueSchema:s};n[d]=o,Ym_(s)&&a.push(d)}return Jm_({value:r,requiredKeys:a,getProperty:u=>{let c=n[u];if(c!=null)return{transformedKey:c.parsedKey,transform:d=>c.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of w5a(e)){let c=jNi(u)?u.valueSchema:u;Ym_(c)&&n.push(a)}return Jm_({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return jNi(u)?{transformedKey:u.rawKey,transform:c=>u.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>u.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>vw.OBJECT};return{...qU(t),...GT(t),...WQt(t),...Vnn(t)}}function Jm_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!PNi(e))return{ok:!1,errors:[{path:a,message:_q(e,"object")}]};let u=new Set(t),c=[],d={};for(let[s,o]of Object.entries(e)){let l=r(s);if(l!=null){u.delete(s);let b=l.transform(o);b.ok?d[l.transformedKey]=b.value:(d[s]=o,c.push(...b.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=o;break}}return c.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:d}:{ok:!1,errors:c}}function Vnn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>Km_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>Km_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>vw.OBJECT};return{...r,...GT(r),...WQt(r),...Vnn(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>vw.OBJECT};return{...t,...GT(t),...WQt(t),...Vnn(t)}}}}function Km_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=Gm_(D5a(t),s=>n.has(s)),c=r(S5a(t,u)),d=i(S5a(t,a));return c.ok&&d.ok?{ok:!0,value:{...c.value,...d.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...d.ok?[]:d.errors]}}function Ym_(e){return!aTE(e)}function aTE(e){switch(e.getType()){case vw.ANY:case vw.UNKNOWN:case vw.OPTIONAL:return!0;default:return!1}}function Xm_(e){return tiu(e)}function Zm_(e){let t={...v1c(e),_getRawProperties:()=>WJn(e)._getRawProperties(),_getParsedProperties:()=>WJn(e)._getParsedProperties()};return{...t,...GT(t),...WQt(t),...Vnn(t)}}function riu(e){let t={parse:(r,i)=>km_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>km_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>vw.LIST};return{...qU(t),...GT(t)}}function km_(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:_q(e,"list"),path:[]}]}}function eP_(e){return FK(vw.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:_q(r,`"${e}"`)}]})()}function tP_(e){return FK(vw.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:_q(r,`${e.toString()}`)}]})()}var rP_=FK(vw.ANY,e=>({ok:!0,value:e}));var iP_=FK(vw.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:_q(e,"boolean")}]});var nP_=FK(vw.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:_q(e,"number")}]});var aP_=FK(vw.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:_q(e,"string")}]});var oP_=FK(vw.UNKNOWN,e=>({ok:!0,value:e}));function sP_(e,t){let r={parse:(i,n)=>uP_({value:i,isKeyNumeric:e.getType()===vw.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>uP_({value:i,isKeyNumeric:e.getType()===vw.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>vw.RECORD};return{...qU(r),...GT(r)}}function uP_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return PNi(e)?w5a(e).reduce((a,[u,c])=>{if(c==null)return a;let d=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),l=i(c,s);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let b=[];return d.ok||b.push(...d.errors),o.ok||b.push(...o.errors),l.ok||b.push(...l.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:_q(e,"object")}]}}function cP_(e){let t=riu(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:_q(i,"Set")}]},getType:()=>vw.SET};return{...qU(r),...GT(r)}}function fP_(e){let t={parse:(r,i)=>lP_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>lP_((n,a)=>n.json(r,a),e,i),getType:()=>vw.UNDISCRIMINATED_UNION};return{...qU(t),...GT(t)}}function lP_(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let c of u.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function dP_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function _P_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=eiu(D5a(t)),a={parse:(u,c)=>pP_({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(u,c)=>pP_({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>vw.UNION};return{...qU(a),...GT(a),...WQt(a)}}function pP_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:c=[]}){if(!PNi(e))return{ok:!1,errors:[{path:c,message:_q(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let o=i(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=n(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let b=u(s,l);return b.ok?{ok:!0,value:{[r]:d,...b.value}}:b}var Qm=gt.objectWithoutOptionalProperties({title:gt.string().optional()});var iiu=gt.objectWithoutOptionalProperties({file:gt.string()});var niu=gt.objectWithoutOptionalProperties({file:gt.string()});var aiu=gt.union("type",{openapi:iiu,protobuf:niu}).transform({transform:e=>{switch(e.type){case"openapi":return RK.openapi(e);case"protobuf":return RK.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var zh=gt.objectWithoutOptionalProperties({source:aiu.optional()});var oiu=gt.objectWithoutOptionalProperties({typeName:gt.string()});var uiu=gt.union("type",{protobuf:oiu}).transform({transform:e=>{switch(e.type){case"protobuf":return LJn.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Nue=gt.objectWithoutOptionalProperties({encoding:uiu.optional()});var Of=gt.objectWithoutOptionalProperties({description:gt.string().optional()});var siu=gt.enum_(["GenerallyAvailable","Beta","Deprecated"]);var cy=gt.objectWithoutOptionalProperties({availability:siu.optional()});var dor=gt.number();var EFe=gt.objectWithoutOptionalProperties({statusCode:dor.optional()});var bg=gt.objectWithoutOptionalProperties({nameOverride:gt.string().optional(),generatedName:gt.string()});var UM=gt.objectWithoutOptionalProperties({inline:gt.boolean().optional()});var Ree=gt.string();var Nee=gt.string();var ciu=gt.objectWithoutOptionalProperties({id:Nee}).extend(Of);var liu=gt.string();var fiu=gt.objectWithoutOptionalProperties({usernameVariableName:gt.string().optional(),usernameEnvVar:gt.string().optional(),passwordVariableName:gt.string().optional(),passwordEnvVar:gt.string().optional()});var diu=gt.objectWithoutOptionalProperties({tokenVariableName:gt.string().optional(),tokenEnvVar:gt.string().optional()});var piu=gt.objectWithoutOptionalProperties({headerName:gt.string(),prefix:gt.string().optional(),headerVariableName:gt.string().optional(),headerEnvVar:gt.string().optional()});var _iu=gt.objectWithoutOptionalProperties({queryParameterName:gt.string()});var hiu=gt.objectWithoutOptionalProperties({snake:gt.string().optional(),camel:gt.string().optional(),screamingSnake:gt.string().optional(),pascal:gt.string().optional()});var wNi=gt.objectWithoutOptionalProperties({nameOverride:gt.string().optional(),generatedName:gt.string(),value:gt.string(),casing:hiu.optional()}).extend(Of).extend(cy);var yiu=gt.objectWithoutOptionalProperties({type:gt.stringLiteral("namespace"),name:gt.string()});var viu=gt.undiscriminatedUnion([gt.string(),yiu]);var SNi=gt.list(viu);var Jm=gt.objectWithoutOptionalProperties({groupName:SNi.optional()});var L0=gt.objectWithoutOptionalProperties({namespace:gt.string().optional()});var HJn=gt.objectWithoutOptionalProperties({default:wNi.optional(),values:gt.list(wNi)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm).extend(UM);var biu=gt.objectWithoutOptionalProperties({scopesEnum:HJn.optional()});var giu=gt.union("type",{basic:fiu,bearer:diu,header:piu,query:_iu,oauth:biu}).transform({transform:e=>{switch(e.type){case"basic":return AU.basic(e);case"bearer":return AU.bearer(e);case"header":return AU.header(e);case"query":return AU.query(e);case"oauth":return AU.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var E5a=gt.objectWithoutOptionalProperties({name:gt.string().optional(),url:gt.string(),audiences:gt.list(gt.string()).optional()}).extend(Of);var Oiu=gt.string();var por=gt.objectWithoutOptionalProperties({sdkMethodName:gt.string().optional()});var O1c={};xa(O1c,{FullExample:()=>QT,FullObjectExample:()=>Piu,FullOneOfExample:()=>wiu,KeyValuePair:()=>jiu,LiteralExample:()=>miu,PrimitiveExample:()=>GJn,PropertyKey:()=>$Jn});var $Jn=gt.string();var GJn=gt.union("type",{int:gt.object({value:gt.number()}),int64:gt.object({value:gt.number()}),uint:gt.object({value:gt.number()}),uint64:gt.object({value:gt.number()}),float:gt.object({value:gt.number()}),double:gt.object({value:gt.number()}),string:gt.object({value:gt.string()}),datetime:gt.object({value:gt.string()}),date:gt.object({value:gt.string()}),base64:gt.object({value:gt.string()}),boolean:gt.object({value:gt.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return M_.int(e.value);case"int64":return M_.int64(e.value);case"uint":return M_.uint(e.value);case"uint64":return M_.uint64(e.value);case"float":return M_.float(e.value);case"double":return M_.double(e.value);case"string":return M_.string(e.value);case"datetime":return M_.datetime(e.value);case"date":return M_.date(e.value);case"base64":return M_.base64(e.value);case"boolean":return M_.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var miu=gt.union("type",{boolean:gt.object({value:gt.boolean()}),string:gt.object({value:gt.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return ONi.boolean(e.value);case"string":return ONi.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var QT=gt.union("type",{primitive:gt.object({value:GJn}),object:gt.lazyObject(()=>Piu),array:gt.object({value:gt.list(gt.lazy(()=>QT))}),map:gt.object({value:gt.list(gt.lazyObject(()=>jiu))}),enum:gt.object({value:gt.string()}),literal:gt.object({value:miu}),oneOf:gt.object({value:gt.lazy(()=>wiu)}),unknown:gt.object({value:gt.lazy(()=>QT)})}).transform({transform:e=>{switch(e.type){case"primitive":return rO.primitive(e.value);case"object":return rO.object(e);case"array":return rO.array(e.value);case"map":return rO.map(e.value);case"enum":return rO.enum(e.value);case"literal":return rO.literal(e.value);case"oneOf":return rO.oneOf(e.value);case"unknown":return rO.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Piu=gt.objectWithoutOptionalProperties({properties:gt.record($Jn,gt.lazy(()=>QT))});var jiu=gt.objectWithoutOptionalProperties({key:GJn,value:gt.lazy(()=>QT)});var wiu=gt.union("type",{discriminated:gt.object({value:gt.record($Jn,gt.lazy(()=>QT))}),undiscriminated:gt.object({value:gt.lazy(()=>QT)})}).transform({transform:e=>{switch(e.type){case"discriminated":return mNi.discriminated(e.value);case"undiscriminated":return mNi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var m1c={};xa(m1c,{AllOfPropertyConflict:()=>cKn,ArraySchema:()=>hnu,Availability:()=>siu,BooleanSchema:()=>cnu,BytesResponse:()=>eKn,CasingOverrides:()=>hiu,CommonProperty:()=>jnu,CursorPagination:()=>Giu,CustomCodeSample:()=>Hiu,CustomCodeSampleLanguage:()=>Uiu,CustomCodeSampleSdk:()=>Wiu,CustomPagination:()=>Jiu,DiscriminatedOneOfSchema:()=>mnu,DoubleSchema:()=>unu,Endpoint:()=>Kiu,EndpointExample:()=>nKn,EndpointResponseExample:()=>Liu,EndpointSdkName:()=>_or,EnumSchema:()=>HJn,EnumValue:()=>wNi,ErrorExample:()=>ziu,FernExample:()=>Riu,FileResponse:()=>ZJn,FileSchema:()=>Eiu,FormUrlEncodedRequest:()=>Ciu,FullEndpointExample:()=>$iu,GlobalHeader:()=>fnu,Header:()=>DNi,HeaderExample:()=>iKn,HttpEndpointServer:()=>tKn,HttpError:()=>xiu,HttpMethod:()=>QJn,IdempotencyHeader:()=>dnu,IntSchema:()=>anu,JsonRequest:()=>Tiu,JsonResponse:()=>kJn,LiteralSchema:()=>sKn,LiteralSchemaValue:()=>pnu,LongSchema:()=>onu,MapSchema:()=>ynu,MultipartRequest:()=>XJn,MultipartRequestProperty:()=>qiu,MultipartRequestPropertyEncoding:()=>Aiu,MultipartSchema:()=>Miu,NullableSchema:()=>bnu,ObjectProperty:()=>Onu,ObjectPropertyConflictInfo:()=>lKn,ObjectSchema:()=>_nu,OctetStreamRequest:()=>YJn,OffsetPagination:()=>Qiu,OneOfSchema:()=>gnu,OpenApiIntermediateRepresentation:()=>hP_,OptionalSchema:()=>vnu,Pagination:()=>aKn,PathParameter:()=>JJn,PathParameterExample:()=>Niu,PrimitiveSchema:()=>MNi,PrimitiveSchemaValue:()=>lnu,QueryParameter:()=>KJn,QueryParameterExample:()=>rKn,ReferencedSchema:()=>hor,Request:()=>Biu,Response:()=>Iiu,Schema:()=>um,Schemas:()=>nnu,SdkGroupInfo:()=>Siu,StreamingResponseExample:()=>Fiu,StringSchema:()=>snu,SupportedSdkLanguage:()=>Viu,Tags:()=>Diu,TextResponse:()=>ENi,UnDiscriminatedOneOfSchema:()=>Pnu,Webhook:()=>Yiu,WebhookExampleCall:()=>uKn,WebhookHttpMethod:()=>oKn,WebsocketChannel:()=>inu,WebsocketHandshake:()=>Xiu,WebsocketMessageExample:()=>tnu,WebsocketMessageOrigin:()=>Ziu,WebsocketMessageSchema:()=>kiu,WebsocketServer:()=>enu,WebsocketSessionExample:()=>rnu});var Siu=gt.objectWithoutOptionalProperties({summary:gt.string().optional(),description:gt.string().optional()});var Diu=gt.objectWithoutOptionalProperties({tagsById:gt.record(Nee,ciu),orderedTagIds:gt.list(Nee).optional()});var QJn=gt.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var JJn=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>um),variableReference:gt.string().optional(),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var KJn=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>um),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var DNi=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>um),env:gt.string().optional(),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var _or=gt.objectWithoutOptionalProperties({groupName:SNi,methodName:gt.string()});var YJn=gt.objectWithoutOptionalProperties({contentType:gt.string().optional()}).extend(Of).extend(zh);var Eiu=gt.objectWithoutOptionalProperties({isOptional:gt.boolean(),isArray:gt.boolean()}).extend(Of);var Miu=gt.union("type",{file:Eiu,json:gt.object({value:gt.lazy(()=>um)})}).transform({transform:e=>{switch(e.type){case"file":return Umi.file(e);case"json":return Umi.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Aiu=gt.enum_(["json","form"]);var qiu=gt.objectWithoutOptionalProperties({key:gt.string(),schema:Miu,contentType:gt.string().optional(),exploded:gt.boolean().optional(),encoding:Aiu.optional()}).extend(Of);var XJn=gt.objectWithoutOptionalProperties({name:gt.string().optional(),properties:gt.list(qiu)}).extend(Of).extend(zh);var Tiu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>um),contentType:gt.string().optional(),additionalProperties:gt.boolean()}).extend(Of).extend(zh);var Ciu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>um),contentType:gt.string().optional(),additionalProperties:gt.boolean()}).extend(Of).extend(zh);var Biu=gt.union("type",{octetStream:YJn,multipart:XJn,json:Tiu,formUrlEncoded:Ciu}).transform({transform:e=>{switch(e.type){case"octetStream":return lor.octetStream(e);case"multipart":return lor.multipart(e);case"json":return lor.json(e);case"formUrlEncoded":return lor.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var ZJn=gt.objectWithoutOptionalProperties({}).extend(Of).extend(zh).extend(EFe);var kJn=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>um),responseProperty:gt.string().optional()}).extend(Of).extend(zh).extend(EFe);var ENi=gt.objectWithoutOptionalProperties({}).extend(Of).extend(zh).extend(EFe);var eKn=gt.objectWithoutOptionalProperties({}).extend(Of).extend(zh).extend(EFe);var Iiu=gt.union("type",{file:ZJn,json:kJn,text:ENi,bytes:eKn,streamingSse:kJn,streamingText:ENi,streamingJson:kJn}).transform({transform:e=>{switch(e.type){case"file":return NK.file(e);case"json":return NK.json(e);case"text":return NK.text(e);case"bytes":return NK.bytes(e);case"streamingSse":return NK.streamingSse(e);case"streamingText":return NK.streamingText(e);case"streamingJson":return NK.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var ziu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),description:gt.string().optional(),example:gt.lazy(()=>QT)});var xiu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>um).optional(),examples:gt.list(ziu).optional()}).extend(Of).extend(bg).extend(zh);var tKn=gt.objectWithoutOptionalProperties({name:gt.string().optional(),url:gt.string().optional(),audiences:gt.list(gt.string()).optional()});var Riu=gt.unknown();var Niu=gt.objectWithoutOptionalProperties({name:gt.string(),parameterNameOverride:gt.string().optional(),value:gt.lazy(()=>QT)});var rKn=gt.objectWithoutOptionalProperties({name:gt.string(),value:gt.lazy(()=>QT)});var iKn=gt.objectWithoutOptionalProperties({name:gt.string(),value:gt.lazy(()=>QT)});var Fiu=gt.objectWithoutOptionalProperties({sse:gt.boolean(),events:gt.list(gt.lazy(()=>QT))});var Liu=gt.union("type",{withStreaming:Fiu,withoutStreaming:gt.object({value:gt.lazy(()=>QT)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return VQt.withStreaming(e);case"withoutStreaming":return VQt.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Uiu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),language:gt.string(),code:gt.string(),install:gt.string().optional()}).extend(Of);var Viu=gt.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var Wiu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),sdk:Viu,code:gt.string()}).extend(Of);var Hiu=gt.union("type",{language:Uiu,sdk:Wiu}).transform({transform:e=>{switch(e.type){case"language":return Lmi.language(e);case"sdk":return Lmi.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var $iu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),pathParameters:gt.list(Niu).optional(),queryParameters:gt.list(rKn).optional(),headers:gt.list(iKn).optional(),request:gt.lazy(()=>QT).optional(),response:Liu.optional(),codeSamples:gt.list(Hiu)}).extend(Of);var nKn=gt.union("type",{unknown:gt.object({value:Riu}),full:$iu}).transform({transform:e=>{switch(e.type){case"unknown":return UQt.unknown(e.value);case"full":return UQt.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var Giu=gt.objectWithoutOptionalProperties({cursor:gt.string(),nextCursor:gt.property("next_cursor",gt.string()),results:gt.string()});var Qiu=gt.objectWithoutOptionalProperties({offset:gt.string(),results:gt.string(),step:gt.string().optional(),hasNextPage:gt.string().optional()});var Jiu=gt.objectWithoutOptionalProperties({results:gt.string()});var aKn=gt.union("type",{cursor:Giu,offset:Qiu,custom:Jiu}).transform({transform:e=>{switch(e.type){case"cursor":return DFe.cursor(e);case"offset":return DFe.offset(e);case"custom":return DFe.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var Kiu=gt.objectWithoutOptionalProperties({authed:gt.boolean(),internal:gt.boolean().optional(),idempotent:gt.boolean().optional(),method:QJn,audiences:gt.list(gt.string()),path:gt.string(),summary:gt.string().optional(),operationId:gt.string().optional(),tags:gt.list(Nee),pathParameters:gt.list(JJn),queryParameters:gt.list(KJn),headers:gt.list(DNi),sdkName:_or.optional(),generatedRequestName:gt.string(),requestNameOverride:gt.string().optional(),request:Biu.optional(),response:Iiu.optional(),errors:gt.record(dor,xiu),servers:gt.list(tKn),examples:gt.list(nKn),pagination:aKn.optional()}).extend(Of).extend(cy).extend(zh).extend(L0);var oKn=gt.enum_(["GET","POST"]);var uKn=gt.objectWithoutOptionalProperties({name:gt.string().optional(),payload:gt.lazy(()=>QT)}).extend(Of);var Yiu=gt.objectWithoutOptionalProperties({audiences:gt.list(gt.string()),sdkName:_or.optional(),method:oKn,summary:gt.string().optional(),operationId:gt.string(),tags:gt.list(Nee),headers:gt.list(DNi),generatedPayloadName:gt.string(),payload:gt.lazy(()=>um),examples:gt.list(uKn)}).extend(Of).extend(zh).extend(L0);var Xiu=gt.objectWithoutOptionalProperties({queryParameters:gt.list(KJn),headers:gt.list(DNi),pathParameters:gt.list(JJn)});var Ziu=gt.enum_(["client","server"]);var kiu=gt.objectWithoutOptionalProperties({name:gt.string(),origin:Ziu,body:gt.lazy(()=>um)});var enu=gt.objectWithoutOptionalProperties({name:gt.string(),url:gt.string()});var tnu=gt.objectWithoutOptionalProperties({messageType:gt.string(),payload:gt.lazy(()=>QT)}).extend(Of);var rnu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),queryParameters:gt.list(rKn).optional(),headers:gt.list(iKn).optional(),messages:gt.list(tnu)}).extend(Of);var inu=gt.objectWithoutOptionalProperties({audiences:gt.list(gt.string()),path:gt.string(),groupName:SNi,summary:gt.string().optional(),handshake:Xiu,messages:gt.list(kiu),servers:gt.list(enu),examples:gt.list(rnu)}).extend(Of).extend(zh);var nnu=gt.objectWithoutOptionalProperties({rootSchemas:gt.record(Ree,gt.lazy(()=>um)),namespacedSchemas:gt.record(Oiu,gt.record(Ree,gt.lazy(()=>um)))});var anu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),minimum:gt.number().optional(),maximum:gt.number().optional(),exclusiveMinimum:gt.boolean().optional(),exclusiveMaximum:gt.boolean().optional(),multipleOf:gt.number().optional()});var onu=gt.objectWithoutOptionalProperties({default:gt.number().optional()});var unu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),minimum:gt.number().optional(),maximum:gt.number().optional(),exclusiveMinimum:gt.boolean().optional(),exclusiveMaximum:gt.boolean().optional(),multipleOf:gt.number().optional()});var snu=gt.objectWithoutOptionalProperties({default:gt.string().optional(),pattern:gt.string().optional(),format:gt.string().optional(),minLength:gt.number().optional(),maxLength:gt.number().optional()});var cnu=gt.objectWithoutOptionalProperties({default:gt.boolean().optional()});var lnu=gt.union("type",{int:anu,int64:onu,uint:gt.object({}),uint64:gt.object({}),float:gt.object({}),double:unu,string:snu,datetime:gt.object({}),date:gt.object({}),base64:gt.object({}),boolean:cnu}).transform({transform:e=>{switch(e.type){case"int":return Ww.int(e);case"int64":return Ww.int64(e);case"uint":return Ww.uint();case"uint64":return Ww.uint64();case"float":return Ww.float();case"double":return Ww.double(e);case"string":return Ww.string(e);case"datetime":return Ww.datetime();case"date":return Ww.date();case"base64":return Ww.base64();case"boolean":return Ww.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var MNi=gt.objectWithoutOptionalProperties({schema:lnu}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm);var fnu=gt.objectWithoutOptionalProperties({header:gt.string(),name:gt.string().optional(),optional:gt.boolean().optional(),env:gt.string().optional(),schema:gt.lazy(()=>um).optional()});var dnu=gt.objectWithoutOptionalProperties({header:gt.string(),name:gt.string().optional(),env:gt.string().optional(),schema:gt.lazy(()=>um).optional()});var hP_=gt.objectWithoutOptionalProperties({apiVersion:gt.unknown().optional(),title:gt.string().optional(),description:gt.string().optional(),basePath:gt.string().optional(),servers:gt.list(E5a),websocketServers:gt.list(E5a),groups:gt.record(gt.string(),Siu),tags:Diu,hasEndpointsMarkedInternal:gt.boolean(),endpoints:gt.list(Kiu),webhooks:gt.list(Yiu),channels:gt.record(gt.string(),inu),groupedSchemas:nnu,variables:gt.record(gt.string(),MNi),nonRequestReferencedSchemas:gt.set(Ree),securitySchemes:gt.record(liu,giu),globalHeaders:gt.list(fnu).optional(),idempotencyHeaders:gt.list(dnu).optional()});var hor=gt.objectWithoutOptionalProperties({schema:Ree}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm);var pnu=gt.union("type",{boolean:gt.object({value:gt.boolean()}),string:gt.object({value:gt.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return mx.boolean(e.value);case"string":return mx.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var sKn=gt.objectWithoutOptionalProperties({value:pnu}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm);var um=gt.union("type",{primitive:MNi,object:gt.lazyObject(()=>_nu),array:gt.lazyObject(()=>hnu),map:gt.lazyObject(()=>ynu),optional:gt.lazyObject(()=>vnu),enum:HJn,reference:hor,literal:sKn,oneOf:gt.object({value:gt.lazy(()=>gnu)}),nullable:gt.lazyObject(()=>bnu),unknown:bg}).transform({transform:e=>{switch(e.type){case"primitive":return wv.primitive(e);case"object":return wv.object(e);case"array":return wv.array(e);case"map":return wv.map(e);case"optional":return wv.optional(e);case"enum":return wv.enum(e);case"reference":return wv.reference(e);case"literal":return wv.literal(e);case"oneOf":return wv.oneOf(e.value);case"nullable":return wv.nullable(e);case"unknown":return wv.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var cKn=gt.objectWithoutOptionalProperties({propertyKey:gt.string(),allOfSchemaIds:gt.list(Ree),conflictingTypeSignatures:gt.boolean()});var _nu=gt.objectWithoutOptionalProperties({allOf:gt.list(hor),properties:gt.list(gt.lazyObject(()=>Onu)),allOfPropertyConflicts:gt.list(cKn),additionalProperties:gt.boolean()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm).extend(UM);var lKn=gt.objectWithoutOptionalProperties({differentSchema:gt.boolean()});var Onu=gt.objectWithoutOptionalProperties({key:gt.string(),schema:gt.lazy(()=>um),readonly:gt.boolean().optional(),writeonly:gt.boolean().optional(),conflict:gt.record(Ree,lKn),generatedName:gt.string(),nameOverride:gt.string().optional(),audiences:gt.list(gt.string())}).extend(cy);var hnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>um)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var ynu=gt.objectWithoutOptionalProperties({key:MNi,value:gt.lazy(()=>um)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(Qm).extend(UM);var vnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>um)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var bnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>um)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var gnu=gt.union("type",{discriminated:gt.lazyObject(()=>mnu),undiscriminated:gt.lazyObject(()=>Pnu)}).transform({transform:e=>{switch(e.type){case"discriminated":return Vmi.discriminated(e);case"undiscriminated":return Vmi.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var mnu=gt.objectWithoutOptionalProperties({discriminantProperty:gt.string(),commonProperties:gt.list(gt.lazyObject(()=>jnu)),schemas:gt.record(gt.string(),gt.lazy(()=>um))}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(zh).extend(Qm).extend(UM);var jnu=gt.objectWithoutOptionalProperties({key:gt.string(),schema:gt.lazy(()=>um)});var Pnu=gt.objectWithoutOptionalProperties({schemas:gt.list(gt.lazy(()=>um))}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(zh).extend(Qm).extend(UM);var P1c={};xa(P1c,{ArraySchemaWithExample:()=>Gnu,Base64WithExample:()=>Unu,BooleanWithExample:()=>Vnu,CommonPropertyWithExample:()=>tau,DateWithExample:()=>Lnu,DatetimeWithExample:()=>Fnu,DiscriminatedOneOfSchemaWithExample:()=>knu,DoubleWithExample:()=>Rnu,EndpointWithExample:()=>vP_,EnumSchemaWithExample:()=>Hnu,FloatWithExample:()=>xnu,HeaderWithExample:()=>ANi,HttpErrorWithExample:()=>Tnu,Int64WithExample:()=>Bnu,IntWithExample:()=>Cnu,JsonRequestWithExample:()=>Enu,JsonResponseWithExample:()=>dKn,MapSchemaWithExample:()=>Qnu,NamedFullExample:()=>MFe,NullableSchemaWithExample:()=>Knu,ObjectPropertyWithExample:()=>Znu,ObjectSchemaWithExample:()=>Ynu,OneOfSchemaWithExample:()=>Xnu,OptionalSchemaWithExample:()=>Jnu,ParseFormUrlEncodedRequest:()=>Mnu,ParseMultipartRequest:()=>Dnu,ParseOctetStreamRequest:()=>Snu,PathParameterWithExample:()=>wnu,PrimitiveSchemaValueWithExample:()=>Wnu,PrimitiveSchemaWithExample:()=>pKn,QueryParameterWithExample:()=>fKn,RequestWithExample:()=>Anu,ResponseWithExample:()=>qnu,SchemaWithExample:()=>VM,StringSchemaWithExample:()=>Nnu,Uint64WithExample:()=>znu,UintWithExample:()=>Inu,UnDiscriminatedOneOfSchemaWithExample:()=>eau,UnknownSchemaWithExample:()=>$nu,WebhookWithExample:()=>bP_,WebsocketHandshakeWithExample:()=>yP_});var MFe=gt.objectWithoutOptionalProperties({name:gt.string().optional(),value:gt.unknown()}).extend(Of);var fKn=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>VM),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var ANi=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>VM),env:gt.string().optional(),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var yP_=gt.objectWithoutOptionalProperties({queryParameters:gt.list(fKn),headers:gt.list(ANi)});var wnu=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>VM),variableReference:gt.string().optional(),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var Snu=gt.objectWithoutOptionalProperties({}).extend(YJn).extend(por);var Dnu=gt.objectWithoutOptionalProperties({}).extend(XJn).extend(por);var Enu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>VM),contentType:gt.string().optional(),fullExamples:gt.list(MFe).optional(),additionalProperties:gt.boolean()}).extend(Of).extend(zh).extend(por);var Mnu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>VM),contentType:gt.string().optional(),fullExamples:gt.list(MFe).optional(),additionalProperties:gt.boolean()}).extend(Of).extend(zh).extend(por);var Anu=gt.union("type",{octetStream:Snu,multipart:Dnu,json:Enu,formUrlEncoded:Mnu}).transform({transform:e=>{switch(e.type){case"octetStream":return zee.octetStream(e);case"multipart":return zee.multipart(e);case"json":return zee.json(e);case"formUrlEncoded":return zee.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var dKn=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>VM),responseProperty:gt.string().optional(),fullExamples:gt.list(MFe).optional()}).extend(Of).extend(zh).extend(EFe);var qnu=gt.union("type",{file:ZJn,json:dKn,text:ENi,bytes:eKn,streamingSse:dKn,streamingText:ENi,streamingJson:dKn}).transform({transform:e=>{switch(e.type){case"file":return EB.file(e);case"json":return EB.json(e);case"text":return EB.text(e);case"bytes":return EB.bytes(e);case"streamingSse":return EB.streamingSse(e);case"streamingText":return EB.streamingText(e);case"streamingJson":return EB.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Tnu=gt.objectWithoutOptionalProperties({statusCode:dor,schema:gt.lazy(()=>VM),fullExamples:gt.list(MFe).optional()}).extend(Of).extend(bg).extend(zh);var vP_=gt.objectWithoutOptionalProperties({authed:gt.boolean(),internal:gt.boolean().optional(),idempotent:gt.boolean().optional(),method:QJn,audiences:gt.list(gt.string()),path:gt.string(),summary:gt.string().optional(),operationId:gt.string().optional(),tags:gt.list(Nee),pathParameters:gt.list(wnu),queryParameters:gt.list(fKn),headers:gt.list(ANi),sdkName:_or.optional(),generatedRequestName:gt.string(),requestNameOverride:gt.string().optional(),request:Anu.optional(),response:qnu.optional(),errors:gt.record(dor,Tnu),servers:gt.list(tKn),examples:gt.list(nKn),pagination:aKn.optional()}).extend(Of).extend(cy).extend(zh).extend(L0);var bP_=gt.objectWithoutOptionalProperties({audiences:gt.list(gt.string()),sdkName:_or.optional(),method:oKn,summary:gt.string().optional(),operationId:gt.string(),tags:gt.list(Nee),headers:gt.list(ANi),generatedPayloadName:gt.string(),payload:gt.lazy(()=>VM),examples:gt.list(uKn)}).extend(Of).extend(zh).extend(L0);var Cnu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),minimum:gt.number().optional(),maximum:gt.number().optional(),exclusiveMinimum:gt.boolean().optional(),exclusiveMaximum:gt.boolean().optional(),multipleOf:gt.number().optional(),example:gt.number().optional()});var Bnu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),example:gt.number().optional()});var Inu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),example:gt.number().optional()});var znu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),example:gt.number().optional()});var xnu=gt.objectWithoutOptionalProperties({example:gt.number().optional()});var Rnu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),minimum:gt.number().optional(),maximum:gt.number().optional(),exclusiveMinimum:gt.boolean().optional(),exclusiveMaximum:gt.boolean().optional(),multipleOf:gt.number().optional(),example:gt.number().optional()});var Nnu=gt.objectWithoutOptionalProperties({default:gt.string().optional(),pattern:gt.string().optional(),format:gt.string().optional(),minLength:gt.number().optional(),maxLength:gt.number().optional(),example:gt.string().optional()});var Fnu=gt.objectWithoutOptionalProperties({example:gt.string().optional()});var Lnu=gt.objectWithoutOptionalProperties({example:gt.string().optional()});var Unu=gt.objectWithoutOptionalProperties({example:gt.string().optional()});var Vnu=gt.objectWithoutOptionalProperties({default:gt.boolean().optional(),example:gt.boolean().optional()});var Wnu=gt.union("type",{int:Cnu,int64:Bnu,uint:Inu,uint64:znu,float:xnu,double:Rnu,string:Nnu,datetime:Fnu,date:Lnu,base64:Unu,boolean:Vnu}).transform({transform:e=>{switch(e.type){case"int":return bp.int(e);case"int64":return bp.int64(e);case"uint":return bp.uint(e);case"uint64":return bp.uint64(e);case"float":return bp.float(e);case"double":return bp.double(e);case"string":return bp.string(e);case"datetime":return bp.datetime(e);case"date":return bp.date(e);case"base64":return bp.base64(e);case"boolean":return bp.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var pKn=gt.objectWithoutOptionalProperties({schema:Wnu}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm);var Hnu=gt.objectWithoutOptionalProperties({default:wNi.optional(),values:gt.list(wNi),example:gt.string().optional()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm).extend(UM);var $nu=gt.objectWithoutOptionalProperties({example:gt.unknown()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm);var VM=gt.union("type",{primitive:pKn,object:gt.lazyObject(()=>Ynu),array:gt.lazyObject(()=>Gnu),map:gt.lazyObject(()=>Qnu),optional:gt.lazyObject(()=>Jnu),enum:Hnu,reference:hor,literal:sKn,oneOf:gt.object({value:gt.lazy(()=>Xnu)}),nullable:gt.lazyObject(()=>Knu),unknown:$nu}).transform({transform:e=>{switch(e.type){case"primitive":return Nl.primitive(e);case"object":return Nl.object(e);case"array":return Nl.array(e);case"map":return Nl.map(e);case"optional":return Nl.optional(e);case"enum":return Nl.enum(e);case"reference":return Nl.reference(e);case"literal":return Nl.literal(e);case"oneOf":return Nl.oneOf(e.value);case"nullable":return Nl.nullable(e);case"unknown":return Nl.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var Gnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>VM),example:gt.list(gt.unknown()).optional()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var Qnu=gt.objectWithoutOptionalProperties({key:pKn,value:gt.lazy(()=>VM),example:gt.unknown().optional()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(Qm).extend(UM);var Jnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>VM)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var Knu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>VM)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var Ynu=gt.objectWithoutOptionalProperties({allOf:gt.list(hor),properties:gt.list(gt.lazyObject(()=>Znu)),allOfPropertyConflicts:gt.list(cKn),fullExamples:gt.list(MFe).optional(),additionalProperties:gt.boolean()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm).extend(UM);var Znu=gt.objectWithoutOptionalProperties({key:gt.string(),schema:gt.lazy(()=>VM),readonly:gt.boolean().optional(),writeonly:gt.boolean().optional(),audiences:gt.list(gt.string()),conflict:gt.record(Ree,lKn),nameOverride:gt.string().optional(),generatedName:gt.string()}).extend(cy);var Xnu=gt.union("type",{discriminated:gt.lazyObject(()=>knu),undiscriminated:gt.lazyObject(()=>eau)}).transform({transform:e=>{switch(e.type){case"discriminated":return xee.discriminated(e);case"undiscriminated":return xee.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var knu=gt.objectWithoutOptionalProperties({discriminantProperty:gt.string(),commonProperties:gt.list(gt.lazyObject(()=>tau)),schemas:gt.record(gt.string(),gt.lazy(()=>VM))}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(zh).extend(Qm).extend(UM);var tau=gt.objectWithoutOptionalProperties({key:gt.string(),schema:gt.lazy(()=>VM)});var eau=gt.objectWithoutOptionalProperties({schemas:gt.list(gt.lazy(()=>VM))}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(zh).extend(Qm).extend(UM);var gP_=/^(\d+)/,_Kn=/^[a-zA-Z][a-zA-Z0-9_]*$/,OP_={"<":"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 qNi(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),c=e%10;return c===0?i[u]:`${i[u]}_${t[c]}`}if(e<1e3){let u=Math.floor(e/100),c=e%100;return c===0?`${t[u]}_hundred`:`${t[u]}_hundred_${qNi(c)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${qNi(a)}`}function M5a(e){let t=e.match(gP_);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=qNi(n);return i.length>0?`${a}_${i}`:a}}}function hKn(e){let t=M5a(e),r=OP_[e];return t!=null?eI(F_(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":eI(F_(e)))}function Fue(e,t){return e.type==="primitive"&&t.type==="primitive"?mP_(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?oTE(e.values,t.values):e.type==="array"&&t.type==="array"?Fue(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"?Fue(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?uTE(e.value,t.value):e.type==="object"&&t.type==="object"?sTE(e,t):e.type==="map"&&t.type==="map"?mP_(e.key.schema,t.key.schema)&&Fue(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function mP_(e,t){return e.type===t.type}function oTE(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return Y8(r,i)}function uTE(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,i])=>{let n=t.schemas[r];return n==null?!1:Fue(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:Fue(r,n)}):!1}function sTE(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:Fue(a,n.schema)})}function ER(e){switch(e){case S$.Deprecated:return"deprecated";case S$.Beta:return"pre-release";case S$.GenerallyAvailable:return"generally-available";default:return}}function cTE(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function PP_(e){let t=e?cTE(e):void 0;if(t==null||t.length===0)return xZi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(F_(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(F_(n.name)):r.push(n.name,xZi);break}default:Ao(n.type)}else Ao(n);return r.join("/")}function TNi(e){return Dy.of(`${PP_(e)}.yml`)}function j1c({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?xZi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,PP_(r))}function jP_({sdkName:e,namespaceOverride:t}){return Dy.of(`${j1c({sdkName:e,namespaceOverride:t})}.yml`)}function wP_({location:e,namespaceOverride:t}){return t!=null?X3(Dy.of(t),e):e}function rau(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Ao(e.type)}}function yKn(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:Ao(e)}}function hq(e){return typeof e=="string"?e:e.type}function vKn(e){if(typeof e!="string")return e.docs}function A5a(e){if(typeof e!="string")return e.default}function w1c(e){if(typeof e!="string")return e.validation}var lTE=-2147483648,fTE=2147483647,dTE=-17976931348623157e292,pTE=17976931348623157e292;function iO({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return iau(e);case"array":return E1c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return M1c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return D1c({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return q1c();case"optional":return nau({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return A1c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return PTE({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,T1c(e);case"object":return jTE({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return wTE({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:Ao(e)}}function iau(e){switch(e.schema.type){case"string":return yTE({description:e.description,schema:e.schema});case"int":return vTE({description:e.description,schema:e.schema});case"float":return bTE({description:e.description,schema:e.schema});case"double":return gTE({description:e.description,schema:e.schema});case"boolean":return _TE({description:e.description,schema:e.schema});case"int64":return hTE({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:ER(e.availability)}:{}}}function _TE({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function hTE({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function yTE({description:e,schema:t}){let r="string",i=OTE(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function vTE({description:e,schema:t}){let r="integer",i=DP_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function bTE({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function gTE({description:e,schema:t}){let r="double",i=DP_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function OTE(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=mTE(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function mTE(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 DP_(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=S1c(r,t),i=S1c(i,t),n=S1c(n,t),!(r==null&&i==null&&a==null&&u==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:u,multipleOf:n}}function S1c(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[lTE,fTE]:[dTE,pTE];return e<r||e>i?void 0:e}function D1c({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=STE(n)??e.schema,u=yKn(n),c=DTE(n),d=aau({context:r,fileContainingReference:t,declarationFile:TNi(u),type:a}),s=n.type==="nullable"?`optional<${d}>`:d;return e.description==null&&c==null?s:{type:n.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function E1c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=iO({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=`list<${hq(u)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{},type:c}}function M1c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=iau(e.key),c=iO({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),d=e.encoding!=null?rau(e.encoding):void 0,s=`map<${hq(u)}, ${hq(c)}>`;if(e.description==null&&d==null&&e.title==null)return s;let o={type:s};return e.description!=null&&(o.docs=e.description),e.encoding!=null&&(o.encoding=d),e.availability!=null&&(o.availability=ER(e.availability)),o}function A1c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.respectNullableSchemas)return nau({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let u=iO({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hq(u),d=vKn(u),s=A5a(u),o=w1c(u),l=c.startsWith("nullable<")?c:`nullable<${c}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return SP_({typeReference:l,itemType:c});let b={type:l};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=ER(e.availability)),SP_({typeReference:b,itemType:c})}function nau({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=iO({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hq(u),d=vKn(u),s=A5a(u),o=w1c(u),l=c.startsWith("optional<")?c:`optional<${c}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return l;let b={type:l};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=ER(e.availability)),b}function q1c(){return"unknown"}function T1c(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Ao(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function PTE({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=q5a(e,n),u=e.nameOverride??e.generatedName;i.builder.addType(r,{name:u,schema:a.schema});let c=aau({type:u,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return c;let d={type:c};return e.description!=null&&(d.docs=e.description),e.default!=null&&(d.default=e.default.value),e.availability!=null&&(d.availability=ER(e.availability)),d}function jTE({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=C1c({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:u.schema});let d=aau({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function wTE({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=B1c({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:u.schema});let d=aau({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{...e.title!=null?{"display-name":e.title}:{},type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function aau({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function STE(e){return wv._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 DTE(e){return wv._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 SP_({typeReference:e,itemType:t}){return t.startsWith("optional<")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var j5;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(j5||(j5={}));function Wmi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Ao(e)}}function MP_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=ATE(e);break;case"array":a=ETE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=MTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=qTE({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=CTE(e.nameOverride,e.generatedName);break;case"optional":a=AP_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=TTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=q5a(e,n);break;case"literal":a=BTE(e,e.nameOverride,e.generatedName);break;case"object":a=C1c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=B1c({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:Ao(e)}return a}function C1c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(j5.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),u=!1,c={},d=new Set;for(let g of e.properties){if(g.readonly&&(u=!0),a&&g.readonly)continue;if(Object.keys(g.conflict).length>0){if(Object.entries(g.conflict).every(([E,T])=>!T.differentSchema))continue;Object.entries(g.conflict).forEach(([E])=>{I1c({property:g.key,schemaId:E,context:t,namespace:i}).forEach(z=>{d.add(z)})})}let O=iO({schema:g.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),m=g.audiences,P=g.nameOverride,D=ER(g.availability),A=RTE(g);c[g.key]=xTE({typeReference:O,audiences:m,name:P,availability:D,propertyAccess:A})}let s=new Set;for(let g of e.allOfPropertyConflicts)g.allOfSchemaIds.forEach(O=>d.add(O)),g.conflictingTypeSignatures&&s.add(g.propertyKey);let o=[];for(let g of e.allOf){let O=qP_({schema:g.schema,context:t,namespace:i});if(O==null||d.has(g.schema)||d.has(O))continue;let m=iO({schema:wv.reference(g),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(hq(m))}for(let g of d){let O=z1c(t,g,i);for(let m of O.properties)c[m.key]==null&&(s.has(m.key)&&(c[m.key]="unknown"),c[m.key]=iO({schema:m.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let m of O.allOf){if(d.has(m.schema))continue;let P=iO({schema:wv.reference(m),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(hq(P))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([g,O])=>zTE(g)?[g,typeof O=="string"?{type:O,name:`_${g}`}:{...O,name:`_${g}`}]:[g,O]))};o.length>0&&(l.extends=o),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=ER(e.availability)),e.source!=null&&(l.source=Wmi(e.source)),l.inline=x1c(e,n);let b=e.nameOverride??e.generatedName;return{name:u&&t.respectReadonlySchemas&&!a?`${b}Read`:b,schema:l}}function I1c({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return I1c({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:u}=z1c(r,t,i),c=a.some(s=>s.key===e),d=[...u.flatMap(s=>I1c({property:e,context:r,schemaId:s.schema,namespace:i}))];if(c||d.length>0)return[t,...d]}return[]}function z1c(e,t,r){let i=e.getSchema(t,r);if(i==null)return{properties:[],allOf:[]};if(i.type==="object")return{properties:i.properties,allOf:i.allOf};if(i.type==="reference")return z1c(e,i.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${i.type}`)}function ETE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:E1c({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function MTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:M1c({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function ATE(e){let t=iau(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function EP_(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function q5a(e,t){let r={enum:e.values.map(a=>{let u=a.nameOverride??a.generatedName,c=a.value;if(u===c&&a.description==null&&(a.casing==null||EP_(a.casing)))return u;let d={value:a.value};if(u!==c&&(d.name=u),a.description!=null&&(d.docs=a.description),a.casing!=null&&!EP_(a.casing)){let s={},o=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,o=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,o=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,o=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,o=!0),o&&(d.casing=s)}return d})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=x1c(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?Wmi(e.source):void 0};for(let a of r.enum){let u=typeof a=="string"?a:a.name??a.value;i.has(u.toLowerCase())||(n.enum.push(a),i.add(u.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function qTE({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:D1c({schema:e,context:t,fileContainingReference:r,namespace:i})}}function TTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:A1c({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:AP_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function AP_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:nau({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function CTE(e,t){return{name:e??t,schema:q1c()}}function BTE(e,t,r){return{name:t??r,schema:T1c(e)}}function B1c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?rau(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=iO({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let d={};for(let[s,o]of Object.entries(e.schemas))d[s]=iO({schema:o,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?ER(e.availability):void 0,union:d,encoding:a,source:e.source!=null?Wmi(e.source):void 0}}}let u=[];for(let c of e.schemas)u.push(iO({schema:c,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:u,encoding:a,source:e.source!=null?Wmi(e.source):void 0,inline:x1c(e,n)}}}var ITE=/^[0-9]/;function zTE(e){return ITE.test(e)}function qP_({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?qP_({context:t,schema:i.schema,namespace:r}):e}function xTE({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function x1c(e,t){return e.inline===!0||t>0?!0:void 0}function RTE(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return i7.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return i7.ObjectPropertyAccess.WriteOnly}}function TP_(e){let t=e.replace(/^x-|^X-/,"");return F_(t)}var CP_="BasicAuthScheme",oau="BearerAuthScheme";function BP_(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:CP_,schema:n}),t||(e.builder.setAuth(CP_),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:oau,schema:n}),t||(e.builder.setAuth(oau),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??TP_(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:oau,schema:n}),t||(e.builder.setAuth(oau),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(Dy.of("__package__.yml"),{name:"OauthScope",schema:q5a(i.scopesEnum,0).schema})}}function yor({header:e,context:t,fileContainingReference:r,namespace:i}){let n=iO({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=hq(n),u=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:F_(u);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let d={type:a};return c!==e.name&&(d.name=c),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=ER(e.availability)),d}function uau({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=iO({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return hq(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:hq(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=ER(e.availability)),a}function cau({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=R1c({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=hq(n.value),u=A5a(n.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return u!=null&&(c.default=u),n.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=ER(e.availability)),NTE(n.value)&&n.value.validation!==void 0&&(c.validation=n.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function R1c({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:Dy.of(CS),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[],u=!1;for(let[c,d]of Object.entries(n.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(u=!0),d.type==="literal"&&d.value.type==="string"&&(_Kn.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:hKn(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),u&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[c,d]=n.value.schemas;if(c!=null&&d!=null&&sau({array:c,primitive:d}))return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&sau({array:c,primitive:d}))return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[c,d]of Object.entries(n.value.schemas))return R1c({schema:d,context:t,fileContainingReference:r,namespace:i})}else if(t.objectQueryParameters)return{value:iO({schema:e,context:t,fileContainingReference:r,declarationFile:Dy.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let n=t.getSchema(e.value.schema,i);if(n==null)return;if(n.type==="array")return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:Dy.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:iO({schema:e,context:t,fileContainingReference:r,declarationFile:Dy.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let n=[],a=!1;for(let[u,c]of Object.entries(e.value.value.schemas))c.type==="primitive"&&c.schema.type==="string"&&(a=!0),c.type==="literal"&&c.value.type==="string"&&(_Kn.test(c.value.value)?n.push(c.value.value):n.push({value:c.value.value,name:hKn(c.value.value)}));if(n.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:n}}),a&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[u,c]=e.value.value.schemas;if(u!=null&&c!=null&&sau({array:u,primitive:c}))return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(u!=null&&c!=null&&sau({array:c,primitive:u}))return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}if(t.objectQueryParameters)return{value:iO({schema:e,context:t,fileContainingReference:r,declarationFile:Dy.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!1};for(let[u,c]of Object.entries(e.value.value.schemas))return R1c({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.objectQueryParameters?{value:iO({schema:e,context:t,fileContainingReference:r,declarationFile:Dy.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:iO({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:iO({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function sau({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function NTE(e){return e.type!=null}function IP_({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"]=FTE(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=LTE({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=CNi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function FTE(e){let t={};return e.forEach(r=>{let i=CNi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function LTE({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=CNi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function CNi(e){switch(e.type){case"primitive":return zP_(e.value);case"object":return xP_(e.properties);case"array":return UTE(e.value);case"map":return VTE(e.value);case"oneOf":return WTE(e.value);case"enum":return e.value;case"literal":return HTE(e.value);case"unknown":return CNi(e.value);default:Ao(e)}}function zP_(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:Ao(e)}}function xP_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,CNi(r)]))}function UTE(e){return e.map(t=>CNi(t))}function VTE(e){return Object.fromEntries(e.map(t=>[zP_(t.key),CNi(t.value)]))}function WTE(e){return e.type==="discriminated"?xP_(e.value):CNi(e.value)}function HTE(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ao(e)}}function Hmi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function lau(e,t){return t??(e?.groupName!=null?Hmi(e.groupName):void 0)}function RP_({channel:e,context:t,declarationFile:r}){let i={path:e.path,url:e.servers[0]?.name,auth:!1};e.audiences!=null&&e.audiences.length>0&&(i.audiences=e.audiences),e.summary!=null&&(i["display-name"]=e.summary),e.description!=null&&(i.docs=e.description);let n=Hmi(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=uau({pathParameter:d,context:t,fileContainingReference:r,namespace:n});Object.keys(a).length>0&&(i["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let s=cau({queryParameter:d,context:t,fileContainingReference:r,namespace:n});s!=null&&(u[d.name]=s)}Object.keys(u).length>0&&(i["query-parameters"]=u);let c={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let s=yor({header:d,context:t,fileContainingReference:r,namespace:n});c[d.name]=s}Object.keys(c).length>0&&(i.headers=c),t.builder.addChannel(r,{channel:i});for(let d of e.messages)t.builder.addChannelMessage(r,{messageId:d.name,message:{origin:d.origin,body:iO({schema:d.body,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}});for(let d of e.examples){let s=IP_({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:s})}}var $mi="Base",$TE="Default";function BNi(e){return Object.entries(e).reduce((t,[r,i])=>(fUn(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function NP_(e){if(e.environmentOverrides!=null){for(let[g,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:g,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 g of e.ir.servers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){r.push(O);continue}t[g.name]=O}let i={},n=[];for(let g of e.ir.endpoints)for(let O of g.servers){if(O.url==null)continue;let m=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){n.push(m);continue}i[O.name]=m}let a={},u=[];for(let g of e.ir.websocketServers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){u.push(O);continue}a[g.name]=O}let c=Object.keys(t).length,d=c>0,s=Object.keys(i).length>0,o=Object.keys(a).length>0;if(!d&&!s&&o&&e.ir.servers.length===0){for(let[g,O]of Object.entries(a))e.builder.addEnvironment({name:g,schema:O});e.builder.setDefaultEnvironment(Object.keys(a)[0]),e.builder.setDefaultUrl($mi);return}if(n.length>0&&e.logger.error(`Skipping endpoint level servers ${n.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),!d){let g=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(g!=null){let m=O?{url:g,audiences:O}:g;t[$TE]=m}}let l=Object.values(t).map(g=>typeof g=="string"?g:g.url),b=r.filter(g=>{let O=typeof g=="string"?g:g.url;return!l.includes(O)});if(b.length>0&&e.logger.error(`Skipping top level servers ${b.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),s)if(c===1){let g=Object.keys(t)[0],O=Object.values(t)[0],m=typeof O=="string"?O:O.url;e.builder.addEnvironment({name:g,schema:{urls:{[$mi]:m,...BNi(i),...BNi(a)}}}),e.builder.setDefaultEnvironment(g),e.builder.setDefaultUrl($mi)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(e.builder.addEnvironment({name:O,schema:{urls:{[$mi]:typeof m=="string"?m:m.url,...BNi(i),...BNi(a)}}}),e.builder.setDefaultEnvironment(O),g=!1):e.builder.addEnvironment({name:O,schema:{urls:{[$mi]:typeof m=="string"?m:m.url,...BNi(i),...BNi(a)}}});e.builder.setDefaultUrl($mi)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(o?e.builder.addEnvironment({name:O,schema:{urls:{[$mi]:typeof m=="string"?m:m.url,...BNi(a)}}}):e.builder.addEnvironment({name:O,schema:m}),e.builder.setDefaultEnvironment(O),g=!1):o?e.builder.addEnvironment({name:O,schema:{urls:{[$mi]:typeof m=="string"?m:m.url,...BNi(a)}}}):e.builder.addEnvironment({name:O,schema:m});o&&e.builder.setDefaultUrl($mi)}}function fau(e){return hq(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var N1c=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},GTE=.75,QTE=new Set("authorization");function FP_(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?yKn(i.schema):void 0,u=a!=null?Hmi(a):void 0,c=Dy.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?hq(iO({schema:i.schema,context:e,fileContainingReference:u?X3(Dy.of(F_(u)),c):c,namespace:u,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(QTE.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let c=t[a.name],d=yor({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:Dy.of(lF),context:e,namespace:void 0});u=new N1c(d),r[a.name]=u}u.increment()}let i=e.ir.endpoints.length*GTE;for(let[n,a]of Object.entries(r)){let u=t[n],c=a.count===e.ir.endpoints.length,d=a.count>=i;u==null&&(c?e.builder.addGlobalHeader({name:n,schema:a.schema}):d&&e.builder.addGlobalHeader({name:n,schema:fau(a.schema)}))}}}function LP_(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?yKn(t.schema):void 0,i=r!=null?Hmi(r):void 0,n=yor({header:{...t,schema:t.schema??wv.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:Ww.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:Dy.of(lF),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:fau(n)})}}function LK(e){switch(e.type){case"primitive":return VP_(e.value);case"object":return WP_(e.properties);case"array":return HP_(e.value);case"map":return KTE(e.value);case"oneOf":return YTE(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return XTE(e.value);case"unknown":return LK(e.value);default:Ao(e)}}function UP_(e){switch(e.type){case"withStreaming":return e.sse?{stream:JTE(e.events)}:{stream:HP_(e.events)};case"withoutStreaming":return{body:LK(e.value)};default:Ao(e)}}function VP_(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}`: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:Ao(e)}}function WP_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,LK(r)]))}function JTE(e){return e.map(t=>({event:"",data:LK(t)}))}function HP_(e){return e.map(t=>LK(t))}function KTE(e){return Object.fromEntries(e.map(t=>[VP_(t.key),LK(t.value)]))}function YTE(e){return e.type==="discriminated"?WP_(e.value):LK(e.value)}function XTE(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ao(e)}}function $P_({endpointExample:e,context:t}){let r={};if(e.type!=="full")return 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"]=ZTE(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=kTE(e.queryParameters));let i=e.headers!=null&&e.headers.length>0,n=t.builder.getGlobalHeaders(),a=Object.keys(n).length>0,u=new Set(e.headers?.map(c=>c.name)??[]);if(i||a){let c=[];if(e.headers!=null)for(let d of e.headers)d.name!==t.builder.getAuthHeaderName()&&c.push(d);for(let[d,s]of Object.entries(n))if(!u.has(d))if(s!=null&&typeof s=="object"&&s.type!=null){let o=SF({type:s.type,_default:void 0,validation:void 0,visitor:{primitive:l=>l.toString(),map:l=>l.toString(),list:l=>l,optional:l=>l,nullable:l=>l,set:l=>l,named:l=>l,literal:l=>{if(l.type==="string")return l.string;if(l.type==="boolean")return l.boolean.toString()},unknown:Ko}});o!=null&&c.push({name:d,value:rO.literal(ONi.string(o))})}else c.push({name:d,value:rO.primitive(M_.string(d))});r.headers=eCE({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=LK(e.request)),e.response!=null&&(r.response=UP_(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(c=>c.type==="language"?{name:c.name??void 0,docs:c.description??void 0,language:c.language,code:c.code,install:c.install??void 0}:{name:c.name??void 0,docs:c.description??void 0,sdk:c.sdk,code:c.code}).filter(bv)),r}function ZTE(e){let t={};return e.forEach(r=>{let i=LK(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function kTE(e){let t={};return e.forEach(r=>{let i=LK(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function eCE({context:e,namedFullExamples:t}){let r={};return t.forEach(i=>{let n=LK(i.value);n!=null&&(r[i.name]=n)}),r}function GP_(e){return E$._visit(e,{get:()=>i7.HttpMethodSchema.Get,post:()=>i7.HttpMethodSchema.Post,put:()=>i7.HttpMethodSchema.Put,patch:()=>i7.HttpMethodSchema.Patch,delete:()=>i7.HttpMethodSchema.Delete,head:()=>i7.HttpMethodSchema.Head,options:()=>{throw new Error("OPTIONS is unsupported")},trace:()=>{throw new Error("TRACE is unsupported")},_other:()=>{throw new Error("Unknown http method is unsupported")}})}function QP_(e){return e==="POST"||e==="PUT"||e==="PATCH"}function JP_({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,u=e.path,c=lau(e.sdkName,e.namespace),d={};for(let P of e.pathParameters)P.parameterNameOverride&&(u=u.replace(P.name,P.parameterNameOverride)),d[P.parameterNameOverride??P.name]=uau({pathParameter:P,context:r,fileContainingReference:t,namespace:c}),a.add(P.name);let s={};for(let P of e.queryParameters){let D=cau({queryParameter:P,context:r,fileContainingReference:t,namespace:c});D!=null&&(s[P.name]=D,a.add(P.name))}let o;if(e.pagination!=null)switch(e.pagination.type){case"cursor":o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":o={type:"custom",results:e.pagination.results};break;default:Ao(e.pagination)}let l={path:u,method:GP_(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?Wmi(e.source):void 0};!iCE({context:r,request:e.request})&&Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let b={},g=r.builder.getGlobalHeaderNames(),O=r.builder.getAuthHeaderName();O!=null&&g.add(O);let m=e.headers.filter(P=>!g.has(P.name));for(let P of m){let D=yor({header:P,context:r,fileContainingReference:t,namespace:c});b[P.name]=D,a.add(typeof D=="string"?P.name:D.name??P.name)}if(e.request!=null){r.setInState(j5.Request);let P=rCE({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(b).length>0?b:void 0,usedNames:a,namespace:c});l.request=P.value,n=[...n,...P.schemaIdsToExclude??[]],r.unsetInState(j5.Request)}else{let P=r.inlinePathParameters&&Object.keys(d).length>0,D=Object.keys(s).length>0,A=Object.keys(b).length>0,M={};(P||D||A)&&(M.name=e.requestNameOverride??e.generatedRequestName),P&&(M["path-parameters"]=d),D&&(M["query-parameters"]=s),A&&(M.headers=b),Object.keys(M).length>0&&(l.request=M)}if(e.response!=null&&e.response._visit({json:P=>{let D=iO({schema:P.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:P.description??void 0,type:hq(D)},P.statusCode!=null&&(l.response["status-code"]=P.statusCode),P.responseProperty!=null&&(l.response.property=P.responseProperty)},streamingJson:P=>{let D=iO({schema:P.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:P.description??void 0,type:hq(D),format:"json"}},streamingSse:P=>{let D=iO({schema:P.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:P.description??void 0,type:hq(D),format:"sse"}},file:P=>{l.response={docs:P.description??void 0,type:"file","status-code":P.statusCode}},bytes:P=>{l.response={docs:P.description??void 0,type:"bytes","status-code":P.statusCode}},streamingText:P=>{l["response-stream"]={docs:P.description??void 0,type:"text"}},text:P=>{l.response={docs:P.description??void 0,type:"text","status-code":P.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let P=r.getDefaultServerName(),D=e.servers[0];D==null?P!=null&&(l.url=P):l.url=D.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=ER(e.availability)),Object.entries(e.errors).forEach(([P,D])=>{let A=D.generatedName,M=Dy.of(CS);r.builder.enableUniqueErrorsPerEndpoint&&(A=`${e.generatedRequestName}${D.generatedName}`,D.schema!=null&&(D.schema.type!=="reference"&&D.schema.type!=="oneOf"?D.schema.generatedName=`${e.generatedRequestName}${D.schema.generatedName}`:D.schema.type==="oneOf"&&(D.schema.value.generatedName=`${e.generatedRequestName}${D.schema.value.generatedName}`)));let E={"status-code":parseInt(P)},T=wP_({location:KP_,namespaceOverride:c});if(D.schema!=null){let I=iO({schema:D.schema,context:r,fileContainingReference:T,declarationFile:T,namespace:c,declarationDepth:0});E.type=hq(I),E.docs=D.description}r.builder.addError(T,{name:A,schema:r.isErrorUnknownSchema(parseInt(P))?{...E,type:"unknown"}:E}),l.errors==null&&(l.errors=[]);let z=r.builder.addImport({file:t,fileToImport:T});l.errors.push(z!=null?`${z}.${A}`:A),E.type!=null&&D.examples?.forEach(I=>{let N={value:LK(I.example),name:I.name,docs:I.description};r.builder.addErrorExample(T,{name:A,example:N})})}),e.examples.length>0&&(l.examples=tCE({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[F1c,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function tCE({endpointExamples:e,context:t}){return e.map(r=>{try{return $P_({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function rCE({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:u,queryParameters:c,nonRequestReferencedSchemas:d,headers:s,usedNames:o,namespace:l}){if(i.type==="json"||i.type==="formUrlEncoded"){let b=i.schema.type==="reference"?i.schema.schema:void 0,g=i.schema.type==="reference"?r.getSchema(i.schema.schema,l):i.schema;if(g?.type!=="object"||b!=null&&d.includes(b)){let A=iO({schema:i.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),M={schemaIdsToExclude:[],value:{body:A}},E=Object.keys(u??{}).length>0,T=Object.keys(c??{}).length>0,z=Object.keys(s??{}).length>0;return E&&(M.value["path-parameters"]=u),T&&(M.value["query-parameters"]=c),z&&(M.value.headers=s),(E||T||z)&&(M.value.name=n??a),i.contentType!=null&&(M.value["content-type"]=i.contentType),i.description!=null&&(M.value.docs=i.description),M}let O=Object.fromEntries(g.properties.filter(A=>A.readonly==null?!0:!(QP_(e.method)&&A.readonly)).map(A=>{let M=iO({schema:A.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:1}),E=A.nameOverride??A.key,T=ER(A.availability);if(!o.has(E)&&A.audiences.length<=0)return o.add(E),A.nameOverride!=null?[A.key,{type:hq(M),docs:vKn(M),name:A.nameOverride,availability:T}]:[A.key,T?{...typeof M=="string"?{type:M}:M,availability:T}:M];let z={type:hq(M),docs:vKn(M)};return o.has(E)&&(z.name=A.generatedName),A.audiences.length>0&&(z.audiences=A.audiences),T!=null&&(z.availability=T),o.add(E),[A.key,z]})),m=g.allOf.map(A=>{let M=iO({schema:wv.reference(A),fileContainingReference:t,context:r,namespace:l,declarationDepth:0});return hq(M)}).filter(A=>A!=="unknown"),P={properties:O};m.length>0&&(P.extends=m),i.additionalProperties&&(P["extra-properties"]=!0);let D={name:n??g.nameOverride??g.generatedName,"path-parameters":u,"query-parameters":c,headers:s,body:P};return i.contentType!=null&&(D["content-type"]=i.contentType),i.description!=null&&(D.docs=i.description),{schemaIdsToExclude:b!=null?[b]:[],value:D}}else{if(i.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":i.contentType??Uq.APPLICATION_OCTET_STREAM,"query-parameters":c,...i.description?{docs:i.description}:{}}};if(i.type==="multipart"){let b=Object.fromEntries(i.properties.map(g=>{if(g.schema.type==="file"){let O=g.schema.isArray?"list<file>":"file";if(O=g.schema.isOptional?`optional<${O}>`:O,g.description!=null||g.contentType!=null){let m={type:O};if(g.description!=null&&(m.docs=g.description),g.contentType!=null){let P=g.contentType.split(",")[0];m["content-type"]=P}return[g.key,m]}return[g.key,O]}else{let O=iO({schema:g.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(g.contentType||g.exploded||g.encoding){let m=typeof O=="string"?{type:O}:O;g.contentType!=null&&(m["content-type"]=g.contentType),g.encoding==="form"?m.style="form":g.encoding==="json"?m.style="json":g.exploded&&(m.style="exploded"),O=m}return[g.key,O]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":u,"query-parameters":c,headers:s,body:{properties:b},"content-type":Uq.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else Ao(i)}}function iCE({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:Ao(t)}}function nCE({location:e,namespaceOverride:t}){return t!=null?{...e,file:X3(Dy.of(t),e.file)}:e}function aCE(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:Dy.of(`${F_(r)}.yml`),endpointId:e.summary!=null?F_(e.summary):F_(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Dy.of(CS),endpointId:F_(e.summary)}:{file:Dy.of(CS),endpointId:F_(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Dy.of(CS),endpointId:i};let n=T5a(r),a=T5a(i);if(Y8(n,a))return{file:Dy.of("__package__.yml"),endpointId:r};let u=sCE({operationId:i,tag:r,path:e.path,method:e.method});if(u!=null)return u;let c=[];for(let d=0;d<n.length;++d){let s=n[d];if(s!=null&&s===a[d])c.push(s);else{let o=F_(r);return{file:Dy.of(`${o}.yml`),endpointId:i,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:Dy.of(F_(c.join("_"))+".yml"),endpointId:F_(a.slice(c.length).join("_")),tag:r}}function C5a(e){let t=e.tags[0];if(e.sdkName!=null){let r=j1c({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Dy.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return nCE({namespaceOverride:e.namespace,location:aCE(e)})}function T5a(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=MNe(t),t}var oCE=new RegExp("[^a-zA-Z0-9{}]+"),uCE=new RegExp("[{}]","g");function sCE({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(oCE).join("_").replaceAll(uCE,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:Dy.of(F_(t)+".yml"),endpointId:F_(e.slice(0,-1*a.length)),tag:t}}function YP_(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:u,file:c,tag:d}=C5a(a),s=c.split(".")[0];s!=null&&t.add(s);let o;if(a.sdkName!=null){let g=e.ir.groups;for(let O of a.sdkName.groupName){let m=typeof O=="string"?O:O.name,P=g[m];if(P==null)break;if(P.summary!=null||P.description!=null){o=g[m];break}}}let l=d==null?void 0:i.tagsById[d];e.setInState(j5.Endpoint),e.setEndpointMethod(a.method);let b=JP_({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(j5.Endpoint),n=[...n,...b.schemaIdsToExclude],e.builder.addEndpoint(c,{name:u,schema:b.value,source:a.source!=null?Wmi(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":o?.summary??l?.id,docs:o?.description??l?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function XP_(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?Hmi(r.groupName):void 0,n=iO({schema:wv.primitive(r),context:e,fileContainingReference:Dy.of(CS),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:hq(n),docs:r.description??void 0}})}}function ZP_(e){for(let t of e.ir.webhooks){let r=fCE({webhook:t,context:e});if(r==null)continue;let i=lau(t.sdkName,t.namespace),n={};for(let u of t.headers)n[u.name]=yor({header:u,context:e,fileContainingReference:r.file,namespace:i});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:n,payload:iO({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:LK(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function cCE({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:X3(Dy.of(t),e.file)}:e}function lCE({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:Dy.of(CS),endpointId:i};let n=T5a(r),a=T5a(i);if(Y8(n,a))return{file:Dy.of("__package__.yml"),endpointId:r};let u=[];for(let c=0;c<n.length;++c){let d=n[c];if(d!=null&&d===a[c])u.push(d);else{let s=F_(r);return{file:Dy.of(`${s}.yml`),endpointId:i,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:Dy.of(F_(u.join("_"))+".yml"),endpointId:F_(a.slice(u.length).join("_")),tag:r}}function fCE({webhook:e,context:t}){return e.sdkName!=null?{file:jP_({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:cCE({namespaceOverride:e.namespace,location:lCE({webhook:e,context:t})})}var dCE=Dy.of(CS);function ej_(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return kP_({namespace:e.namespace,groupName:e.groupName});case"oneOf":return kP_({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return dCE;default:Ao(e)}}function kP_({namespace:e,groupName:t}){return e!=null&&t!=null?TNi([{type:"namespace",name:e},...t]):e!=null?TNi([{type:"namespace",name:e}]):TNi(t)}var F1c="external",KP_=Dy.of(CS);function tj_({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let u=ej_(a),c=MP_({schema:a,context:i,declarationFile:u,namespace:r,declarationDepth:0});if(_zi(c.schema)){let d=hq(c.schema);if(d===(c.name??n)||d===`optional<${c.name??n}>`)continue}i.builder.addType(u,{name:c.name??n,schema:c.schema})}}function rj_(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),NP_(e),FP_(e),LP_(e),BP_(e),XP_(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(F1c);let t=YP_(e),r=t.sdkGroups;e.setInState(j5.Webhook),ZP_(e),e.unsetInState(j5.Webhook),e.setInState(j5.Channel);for(let n of Object.values(e.ir.channels)){let a=TNi(n.groupName);RP_({channel:n,context:e,declarationFile:a})}e.unsetInState(j5.Channel);let i=pCE({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});tj_({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))tj_({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function pCE({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}var B5a=class{context;constructor(t){this.context=t}};var dau=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,c]of Object.entries(i.files)){let d=n!=null?Dy.of(`${n}${Q$t}${u}`):Dy.of(u);t[d]=c}let a=Object.keys(i.directories).sort();for(let u of a){let c=n!=null?`${n}${Q$t}${u}`:u,d=i.directories[u];r(d,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(Q$t))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Dy.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var Wnn=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new dau,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),i!=null&&(u.service["base-path"]=i),n!=null&&(u.service["display-name"]=n),a!=null&&(u.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return jir(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))ij_(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(ij_(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??F_((FNe(r)+"/"+iki(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Dy.of(lF))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=bBo(FNe(O5n.of(`/${t}`)),O5n.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=bBo(FNe(O5n.of(`/${t}`)),O5n.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===Dy.of(lF))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>Y8(c,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=X3(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:X3(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,u])=>[a,{...u,path:X3(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===CS?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 ij_(e){return e?.header!=null}var pau=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;useBytesForBinaryResponse;respectForwardCompatibleEnums;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=u,this.globalHeaderOverrides=a,this.detectGlobalHeaders=i?.detectGlobalHeaders??!0,this.objectQueryParameters=i?.objectQueryParameters??!1,this.respectReadonlySchemas=i?.respectReadonlySchemas??!1,this.respectNullableSchemas=i?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=i?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=i?.inlinePathParameters??!1,this.useBytesForBinaryResponse=i?.useBytesForBinaryResponse??!1,this.respectForwardCompatibleEnums=i?.respectForwardCompatibleEnums??!1,this.referencedSchemaIds=i?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=i?.enableUniqueErrorsPerEndpoint??!1,this.builder=new Wnn(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let d of r.endpoints)for(let[s,o]of Object.entries(d.errors)){let l=parseInt(s),b=c[l];b==null&&o.schema!=null?c[l]=o.schema:b!=null&&o.schema!=null&&Fue(b,o.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.onlyIncludeReferencedSchemas&&this.isInAnyState(j5.Channel,j5.Endpoint,j5.Webhook)}markSchemaAsReferenced(t,r){switch(t.type){case"primitive":return;case"object":this.markObjectSchemaAsReferenced(t,r);return;case"array":this.markSchemaAsReferenced(t.value,r);return;case"map":this.markSchemaAsReferenced(t.value,r);return;case"optional":this.markSchemaAsReferenced(t.value,r);return;case"reference":this.markSchemaIdAsReferenced(t.schema,r);return;case"oneOf":this.markOneofSchemaAsReferenced(t.value,r);return;case"nullable":this.markSchemaAsReferenced(t.value,r);return;case"enum":return;case"literal":return;case"unknown":return;default:Ao(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:Ao(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function L1c(e){let t=new pau(e);return rj_(t)}var _au=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=L1c({taskContext:t,ir:r,options:j5a({overrides:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.args.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.args.objectQueryParameters,useBytesForBinaryResponse:i?.useBytesForBinaryResponse??this.args.useBytesForBinaryResponse,respectForwardCompatibleEnums:i?.respectForwardCompatibleEnums??this.args.respectForwardCompatibleEnums}}),authOverrides:i?.auth!=null?{auth:i.auth}:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:Rd.dump(a.rootApiFile)},namedDefinitionFiles:{...Dd(a.definitionFiles,u=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Rd.dump(u),contents:u})),[Dy.of(CS)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Rd.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var I5a=class extends LQt{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;converter;constructor(t){super(t),this.inlinePathParameters=t.inlinePathParameters,this.objectQueryParameters=t.objectQueryParameters,this.onlyIncludeReferencedSchemas=t.onlyIncludeReferencedSchemas,this.respectReadonlySchemas=t.respectReadonlySchemas,this.respectNullableSchemas=t.respectNullableSchemas,this.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.inlineAllOfSchemas=t.inlineAllOfSchemas,this.converter=new _au(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new Tqe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion})}};var M$={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"};var bKn={of(e){return e}};var nj_={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},U1c={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:nj_,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},ad={SOURCE:bKn.of("source"),SDK_NAMESPACE:bKn.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:bKn.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:bKn.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:bKn.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",IS_DISCRIMINATED:"x-fern-discriminated"};var O7={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!0,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1};function HQt({options:e,overrides:t}){return{disableExamples:t?.disableExamples??O7.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??O7.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??O7.useTitlesAsName,audiences:t?.audiences??e?.audiences??O7.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??O7.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??O7.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??O7.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??O7.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??O7.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??O7.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??O7.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??O7.shouldUseUndiscriminatedUnionsWithLiterals,shouldUseIdiomaticRequestNames:t?.shouldUseIdiomaticRequestNames??e?.shouldUseIdiomaticRequestNames??O7.shouldUseIdiomaticRequestNames,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??O7.objectQueryParameters,filter:t?.filter??e?.filter??O7.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??O7.asyncApiNaming,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??O7.useBytesForBinaryResponse,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0,defaultFormParameterEncoding:t?.defaultFormParameterEncoding??e?.defaultFormParameterEncoding??void 0,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??O7.respectForwardCompatibleEnums,additionalPropertiesDefaultsTo:t?.additionalPropertiesDefaultsTo??e?.additionalPropertiesDefaultsTo??O7.additionalPropertiesDefaultsTo,typeDatesAsStrings:t?.typeDatesAsStrings??e?.typeDatesAsStrings??O7.typeDatesAsStrings,preserveSingleSchemaOneOf:t?.preserveSingleSchemaOneOf??e?.preserveSingleSchemaOneOf??O7.preserveSingleSchemaOneOf,inlineAllOfSchemas:t?.inlineAllOfSchemas??e?.inlineAllOfSchemas??O7.inlineAllOfSchemas}}var aj_={naming:"v1"};function hf(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function z5a(e,t,r,i,n=[]){try{let a=hf(e,t);if(a!=null)return r.parse(a)}catch{let u=MNe(n).join(" -> ");i.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}function Hnn(e){let t=hf(e,"examples");if(t!=null){if(Array.isArray(t))return t;if(typeof t=="object"&&t!==null)return Object.values(t).map(r=>typeof r=="object"&&r!==null&&"value"in r?r.value:r)}return[]}function oj_({schema:e,logger:t}){return hf(e,ad.ENCODING)??void 0}function uj_(e){return hf(e,ad.FERN_ENUM)}function sj_({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let u=hf(i,ad.SDK_NAMESPACE),c=hf(i,ad.SDK_GROUP_NAME),d=hf(i,ad.TYPE_DEFINITION);if(d!=null)return x5a({fernType:d,nameOverride:e,generatedName:t,title:r,description:n,availability:a,namespace:u,groupName:typeof c=="string"?[c]:c})}function x5a({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c}){return SF({type:e,_default:void 0,validation:void 0,visitor:{primitive:d=>{switch(d.v1){case"BASE_64":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.base64({example:void 0})});case"BOOLEAN":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.boolean({default:void 0,example:void 0})});case"DATE":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.date({example:void 0})});case"DATE_TIME":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.datetime({example:void 0})});case"FLOAT":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.float({example:void 0})});case"DOUBLE":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.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 Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.uint({default:void 0,example:void 0})});case"INTEGER":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.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 Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.uint64({default:void 0,example:void 0})});case"LONG":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Ao(d.v1)}},unknown:()=>Nl.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,namespace:u,groupName:c}),map:({keyType:d,valueType:s})=>d?.type==="primitive"&&s!=null?Nl.map({nameOverride:t,generatedName:r,title:i,key:d,value:s,description:n,availability:a,namespace:u,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:d=>d!=null?Nl.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:c,example:void 0,inline:void 0}):void 0,optional:d=>d!=null?Nl.optional({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:c,inline:void 0}):void 0,nullable:d=>d!=null?Nl.nullable({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:c,inline:void 0}):void 0,set:d=>d!=null?Nl.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:c,example:void 0,inline:void 0}):void 0,literal:d=>Nl.literal({nameOverride:t,generatedName:r,title:i,value:d._visit({string:s=>mx.string(s),boolean:s=>mx.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:u,groupName:c}),named:d=>Nl.reference({schema:d,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,source:RK.openapi({file:"<memory>"})})}})}function cj_(e){let t=hf(e,ad.SOURCE);if(t!=null)return t.endsWith(".proto")?RK.protobuf({file:t}):RK.openapi({file:t})}function $nn(e){if(e!=null&&typeof e=="boolean")return e}function tp(e){return e.$ref!=null}function lj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:u,wrapAsNullable:c,context:d,namespace:s,groupName:o,example:l,encoding:b,source:g}){return n===void 0&&(n=d.options.additionalPropertiesDefaultsTo),typeof n=="boolean"||gKn(n,d.options)?hau({nameOverride:e,generatedName:t,title:r,wrapAsNullable:c,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:bp.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:Nl.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:void 0,groupName:void 0}),namespace:s,groupName:o,example:l,encoding:b}):hau({nameOverride:e,generatedName:t,title:r,wrapAsNullable:c,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:bp.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:fj_(s0(n,d.options.optionalAdditionalProperties?c:!1,d,[...i,"Value"],g,s,void 0,void 0,void 0)),namespace:s,groupName:o,example:l,encoding:b})}function fj_(e){switch(e.type){case"array":case"enum":case"map":case"object":e.inline=!0;break;case"literal":case"primitive":case"reference":case"unknown":break;case"nullable":case"optional":e.inline=!0,e.value=fj_(e.value);break;case"oneOf":e.value.inline=!0;break;default:Ao(e)}return e}function hau({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsNullable:a,description:u,availability:c,namespace:d,groupName:s,example:o,encoding:l}){return a?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:i.availability,key:i,value:n,namespace:d,groupName:s,encoding:l,example:o,inline:void 0}),description:u,availability:c,namespace:d,groupName:s,inline:void 0}):Nl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:c,key:i,value:n,namespace:d,groupName:s,encoding:l,example:o,inline:void 0})}function gKn(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!tp(e)&&Object.keys(e).length===0}function dj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:u,wrapAsNullable:c,context:d,namespace:s,groupName:o,example:l,source:b}){let g=n==null?Nl.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:s,groupName:o}):s0(n,!1,d,[...i,"Item"],b,s);return _CE({nameOverride:e,generatedName:t,title:r,namespace:s,groupName:o,itemSchema:g,wrapAsNullable:c,description:a,availability:u,example:l})}function _CE({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsNullable:n,description:a,availability:u,namespace:c,groupName:d,example:s}){return n?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,namespace:c,groupName:d,example:s,inline:void 0}),description:a,availability:u,namespace:c,groupName:d,inline:void 0}):Nl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,namespace:c,groupName:d,example:s,inline:void 0})}function UK(e){switch(hf(e,ad.AVAILABILITY)){case"deprecated":return S$.Deprecated;case"beta":return S$.Beta;case"generally-available":return S$.GenerallyAvailable;default:break}if(!tp(e)&&e.deprecated)return S$.Deprecated}function V1c({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:c,wrapAsNullable:d,discriminator:s,context:o,namespace:l,groupName:b,encoding:g,source:O}){let m=s.propertyName,P=Object.fromEntries(Object.entries(s.mapping??{}).map(([A,M])=>{let E=Gmi({$ref:M},!1,o,[M],g,O,l);return o.markReferencedByDiscriminatedUnion({$ref:M},m,1),[A,E]})),D=Object.entries(n).filter(([A])=>A!==m).map(([A,M])=>{let E=c!=null&&c.includes(A),T=s0(M,!E,o,[...i,A],O,l);return{key:A,schema:T}});return pj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:D,description:a,availability:u,discriminant:m,subtypes:P,namespace:l,groupName:b,source:O})}function W1c({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:c,wrapAsNullable:d,discriminant:s,variants:o,context:l,namespace:b,groupName:g,encoding:O,source:m}){let P=Object.fromEntries(Object.entries(o).map(([A,M])=>{if(tp(M)){let E=Gmi(M,!1,l,[M.$ref],O,m,b);return l.markReferencedByDiscriminatedUnion(M,s,1),[A,E]}else{let E=OKn(M,!1,l,[...i,A],O,m,b,new Set([s]));return[A,E]}})),D=Object.entries(n).filter(([A])=>A!==s).map(([A,M])=>{let E=c!=null&&c.includes(A),T=s0(M,!E,l,[...i,A],m,b);return{key:A,schema:T}});return pj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:D,description:a,availability:u,discriminant:s,subtypes:P,namespace:b,groupName:g,source:m})}function pj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,availability:u,discriminant:c,subtypes:d,namespace:s,groupName:o,source:l}){return i?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.oneOf(xee.discriminated({description:a,availability:u,discriminantProperty:c,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,namespace:s,groupName:o,encoding:void 0,source:l,inline:void 0})),namespace:s,groupName:o,description:a,availability:u,inline:void 0}):Nl.oneOf(xee.discriminated({description:a,availability:u,discriminantProperty:c,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,namespace:s,groupName:o,encoding:void 0,source:l,inline:void 0}))}function _j_(e){if(e.proto!=null)return LJn.protobuf({typeName:e.proto.type})}function INi({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:u,description:c,availability:d,wrapAsNullable:s,namespace:o,groupName:l,context:b,source:g,inline:O}){let m=yCE(n??[]),P=new Set(a),D=Array.from(P).map((M,E)=>{let T=i?.[M],z=m[E],$=_Kn.test(M),I=T?.name??z,N=$?M:hKn(M);return I!=null&&!_Kn.test(I)&&(b?.logger.warn(`Enum name override ${I} is not a valid name. Falling back on ${N}.`),I=void 0),{nameOverride:I,generatedName:N,value:M,description:T?.description,availability:d,casing:{snake:T?.casing?.snake??void 0,pascal:T?.casing?.pascal??void 0,screamingSnake:T?.casing?.screamingSnake??void 0,camel:T?.casing?.camel??void 0}}}),A=u!=null?D.find(M=>M.value===u):void 0;return hCE({wrapAsNullable:s,nameOverride:e,generatedName:t,title:r,values:D,_default:A,description:c,availability:d,namespace:o,groupName:l,source:g,inline:O})}function hCE({wrapAsNullable:e,nameOverride:t,generatedName:r,title:i,values:n,_default:a,description:u,availability:c,namespace:d,groupName:s,source:o,inline:l}){return e?Nl.nullable({nameOverride:t,generatedName:r,title:i,value:Nl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,default:a,availability:c,example:void 0,namespace:d,groupName:s,source:o,inline:l}),description:u,availability:c,namespace:d,groupName:s,inline:l}):Nl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,availability:c,default:a,example:void 0,namespace:d,groupName:s,source:o,inline:l})}function yCE(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function hj_({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:o,availability:l,wrapAsNullable:b,example:g,namespace:O,groupName:m}){return i==="int64"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="uint32"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="uint64"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):w5({nameOverride:e,generatedName:t,title:r,primitive:bp.int({default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m})}function yj_(e){return typeof e=="string"?mx.string(e):typeof e=="boolean"?mx.boolean(e):mx.string(`${e}`)}function vj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,value:n,description:a,availability:u,namespace:c,groupName:d}){return i?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.literal({nameOverride:e,generatedName:t,title:r,value:yj_(n),description:a,availability:u,namespace:c,groupName:d}),description:a,availability:u,namespace:c,groupName:d,inline:void 0}):Nl.literal({nameOverride:e,generatedName:t,title:r,value:yj_(n),description:a,availability:u,namespace:c,groupName:d})}function H1c({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:o,availability:l,wrapAsNullable:b,example:g,namespace:O,groupName:m}){return i==null||i==="double"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.double({default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="float"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.float({example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="int32"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.int({default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="int64"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="uint32"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="uint64"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="time-delta"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.float({example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):w5({nameOverride:e,generatedName:t,title:r,primitive:bp.float({example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m})}var vCE={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},bCE={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}}},gCE={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}}},OCE={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},mCE={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},PCE={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},jCE={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},wCE={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function yau(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[vCE,bCE,gCE,OCE,mCE,PCE,jCE,wCE],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:c}=a.applyStrategy(t);t=u,r=[...r,...c]}}while(t.join("")!==n.join(""));return r}function S5(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:eI(F_(n))).join("");return/^\d/.test(i)?M5a(i)??i:i}function $1c(e){let t=e.join("_");return F_(t)}function DA(e){switch(e.type){case"object":return wv.object({allOf:e.allOf,properties:e.properties.map(t=>DCE(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:e.inline});case"array":return wv.array({description:e.description,availability:e.availability,value:DA(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return wv.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,source:e.source,inline:e.inline});case"literal":return wv.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"nullable":return wv.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:DA(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return wv.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:DA(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return wv.primitive({description:e.description,availability:e.availability,schema:bj_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return wv.map({description:e.description,availability:e.availability,key:wv.primitive({description:e.key.description,availability:e.key.availability,schema:bj_(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:DA(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return wv.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return wv.oneOf(SCE(e.value));case"unknown":return wv.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Ao(e)}}function SCE(e){switch(e.type){case"discriminated":return Vmi.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:DA(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,DA(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return Vmi.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>DA(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:Ao(e)}}function bj_(e){switch(e.type){case"string":return Ww.string(e);case"base64":return Ww.base64();case"boolean":return Ww.boolean(e);case"date":return Ww.date();case"datetime":return Ww.datetime();case"double":return Ww.double(e);case"float":return Ww.float();case"int":return Ww.int(e);case"int64":return Ww.int64(e);case"uint":return Ww.uint();case"uint64":return Ww.uint64();default:Ao(e)}}function DCE(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:DA(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function vau(e,t){return Fue(DA(e),DA(t))}function gj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:u,wrapAsNullable:c,allOf:d,context:s,propertiesToExclude:o,namespace:l,groupName:b,fullExamples:g,additionalProperties:O,availability:m,source:P}){let D=[...u??[]],A={...n},M=[],E=[];for(let N of d)if(!s.options.inlineAllOfSchemas&&tp(N)){let U=s.resolveSchemaReference(N);if(U.discriminator!=null&&U.discriminator.mapping!=null)continue;if(U.oneOf!=null||U.anyOf!=null){let J=U.oneOf??U.anyOf;if(J!=null){for(let X of J){let oe=tp(X)?s.resolveSchemaReference(X):X,pe=s0(oe,!1,s.DUMMY,i,P,l);pe.type==="object"&&M.push(...pe.properties.map(de=>de.schema.type!=="optional"&&de.schema.type!=="nullable"?{...de,schema:Nl.optional({nameOverride:void 0,generatedName:"",title:void 0,value:de.schema,description:void 0,availability:de.availability,namespace:void 0,groupName:void 0,inline:void 0})}:de))}continue}}let Y=zNi(N);if(Y==null)continue;E.push({schemaId:Y,convertedSchema:G1c(N,[Y],P,s.options.preserveSchemaIds),properties:Oj_({schema:N,context:s,breadcrumbs:i,source:P,namespace:l})}),s.markSchemaAsReferencedByNonRequest(Y)}else if(tp(N)){let U=s.resolveSchemaReference(N),Y=s0(U,!1,s,i,P,l);Y.type==="object"&&M.push(...Y.properties)}else{let U=N.required??[];M=M.map(J=>(J.schema.type==="optional"||J.schema.type==="nullable")&&U.includes(J.key)?{...J,schema:J.schema.value}:J);let Y=s0(N,!1,s,i,P,l);Y.type==="object"&&M.push(...Y.properties)}let T={};for(let N of E)for(let[U,Y]of Object.entries(N.properties)){let J=T[U];J!=null?(J.schemaIds.push(N.schemaId),J.schemas.some(oe=>vau(oe,Y))||J.schemas.push(Y)):T[U]={schemaIds:[N.schemaId],schemas:[Y]}}let z=[];for(let[N,U]of Object.entries(T))U.schemaIds.length>1&&z.push({propertyKey:N,allOfSchemaIds:U.schemaIds,conflictingTypeSignatures:U.schemas.length>1});let $=Object.fromEntries(Object.entries(A).filter(([N,U])=>!(!tp(U)&&U.type==="null"))),I=Object.entries($).map(([N,U])=>{let Y=hf(U,ad.AUDIENCES)??[],J=UK(U),X=tp(U)?!1:U.readOnly,oe=tp(U)?!1:U.writeOnly,pe=D.includes(N)&&!X,de=hf(U,ad.FERN_PROPERTY_NAME),me=[...i,N],Le=$1c(me),vt=pe?s0(U,!1,s,me,P,l):Nl.optional({nameOverride:e,generatedName:Le,title:r,description:void 0,availability:J,value:s0(U,!1,s,me,P,l),namespace:l,groupName:b,inline:void 0}),De={};for(let Ae of E){let Ct=Ae.properties[N];Ct!=null&&!vau(vt,Ct)?De[Ae.schemaId]={differentSchema:!0}:Ct!=null&&(De[Ae.schemaId]={differentSchema:!1})}return{key:N,schema:vt,nameOverride:de,audiences:Y,conflict:De,generatedName:$1c([...i,N]),availability:J,readonly:X,writeonly:oe}});return I.push(...M.map(N=>{let U=N.conflict;for(let Y of E){let J=Y.properties[N.key];J!=null&&!vau(N.schema,J)?U[Y.schemaId]={differentSchema:!0}:J!=null&&(U[Y.schemaId]={differentSchema:!1})}return{...N,conflict:U}})),ECE({nameOverride:e,generatedName:t,title:r,wrapAsNullable:c,properties:I.filter(N=>!o.has(N.key)),description:a,allOf:E.map(N=>N.convertedSchema),allOfPropertyConflicts:z,namespace:l,groupName:b,fullExamples:g,additionalProperties:O,availability:m,source:P,context:s})}function ECE({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,allOf:u,allOfPropertyConflicts:c,namespace:d,groupName:s,fullExamples:o,additionalProperties:l,availability:b,source:g,context:O}){return i?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:c,namespace:d,groupName:s,fullExamples:o,additionalProperties:gKn(l,O.options),availability:void 0,source:g,inline:void 0}),description:a,availability:b,namespace:d,groupName:s,inline:void 0}):Nl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:c,namespace:d,groupName:s,fullExamples:o,additionalProperties:gKn(l,O.options),availability:b,source:g,inline:void 0})}function Oj_({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[u,c]=tp(e)?[t.resolveSchemaReference(e),yau(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...Oj_({schema:d,context:t,breadcrumbs:c,source:i,namespace:n})};for(let[d,s]of Object.entries(u.properties??{})){let o=s0(s,!1,t,[...c,d],i,n);a[d]=o}return a}function xNi({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsNullable:u,context:c,subtypes:d,namespace:s,groupName:o,encoding:l,source:b,subtypePrefixOverrides:g}){let O=qCE({schemas:d}),m=d.flatMap((D,A)=>{if(!tp(D)&&D.enum!=null&&c.options.coerceEnumsToLiterals&&D.type==="string")return D.enum.map(E=>Nl.literal({nameOverride:void 0,generatedName:S5([t,E],c.options.preserveSchemaIds),title:void 0,value:mx.string(String(E)),namespace:s,groupName:void 0,description:void 0,availability:E.availability}));let M=O[A];if(g!=null){let E=g[A];E!=null&&"name"in E&&(M=E.name)}return[s0(D,!1,c,[...i,M??`${A}`],b,s)]}),P=MCE(m);return ACE({uniqueSubtypes:P,nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,namespace:s,groupName:o,context:c,encoding:l,source:b})}function MCE(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let u=e[a];if(i!=null&&u!=null&&Fue(i,u)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function ACE({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,namespace:c,groupName:d,context:s,encoding:o,source:l}){if(Object.entries(e).every(([g,O])=>O.type==="literal")){let g={},O=[];return Object.entries(e).forEach(([m,P])=>{P.type==="literal"&&P.value.type==="string"&&(O.push(P.value.value),P.description!=null&&(g[P.value.value]={description:P.description}))}),INi({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,fernEnum:g,enumVarNames:void 0,enumValues:O,_default:void 0,namespace:c,groupName:d,context:s,source:l,inline:void 0})}return e.length===1&&e[0]!=null&&!s.options.preserveSingleSchemaOneOf?e[0]:mj_({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,subtypes:e,namespace:c,groupName:d,encoding:o,source:l})}function Q1c({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsNullable:a,context:u,namespace:c,groupName:d,discriminator:s,encoding:o,source:l}){let b=Object.entries(s.mapping??{}).map(([m,P],D)=>{let A={$ref:P},M=Gmi(A,!1,u,[P],o,l,c);return u.markSchemaWithDiscriminantValue(A,s.propertyName,m),M.type==="object"&&(M.properties={[s.propertyName]:Nl.literal({nameOverride:void 0,generatedName:S5([t,m],u.options.preserveSchemaIds),title:void 0,value:mx.string(m),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...M.properties.filter(E=>E.key!==s.propertyName)}),M}),g=[];for(let m=0;m<b.length;++m){let P=b[m],D=!1;for(let A=m+1;A<b.length;++A){let M=b[A];if(P!=null&&M!=null&&Fue(P,M)){D=!0;break}}P!=null&&!D&&g.push(P)}if(Object.entries(g).every(([m,P])=>P.type==="literal")){let m={},P=[];return Object.entries(g).forEach(([D,A])=>{A.type==="literal"&&A.value.type==="string"&&(P.push(A.value.value),A.description!=null&&(m[A.value.value]={description:A.description}))}),INi({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,fernEnum:m,enumVarNames:void 0,enumValues:P,_default:void 0,namespace:c,groupName:d,context:u,source:l,inline:void 0})}return g.length===1&&g[0]!=null&&!u.options.preserveSingleSchemaOneOf?g[0]:mj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,subtypes:g,namespace:c,groupName:d,encoding:o,source:l})}function qCE({schemas:e}){let t={},r=0;for(let a of e){if(!tp(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),c={},d=u;for(let[s,o]of Object.entries(t)){let l=IAo(o,u);d=IAo(d,o),c[s]=l}c[r]=d,t=c}}r++}let i=[],n=0;for(let a of e){let u=t[n];if(u!=null&&u.length>0){let c=u.sort();if(c[0]!=null){i.push(c[0]),++n;continue}}tp(a)?i.push(qNi(n)??`${n}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?i.push(""):i.push(qNi(n)??`${n}`),++n}return i}function mj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,description:n,availability:a,subtypes:u,namespace:c,groupName:d,encoding:s,source:o}){return i?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.oneOf(xee.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,namespace:c,groupName:d,encoding:s,source:o,inline:void 0})),description:n,availability:a,namespace:c,groupName:d,inline:void 0}):Nl.oneOf(xee.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,namespace:c,groupName:d,encoding:s,source:o,inline:void 0}))}function mKn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function bau({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=Hnn(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function Pj_({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=Hnn(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function vor({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=Hnn(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function jj_({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=Hnn(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var Gnn="#/components/schemas/";function s0(e,t,r,i,n,a,u=!1,c=new Set,d){let s=cj_(e)??n,o=NCE({schema:e,logger:r.logger});if(tp(e)){let l=zNi(e);return l!=null?(u?r.markSchemaAsReferencedByRequest(l):r.markSchemaAsReferencedByNonRequest(l),Gmi(e,t,r,i,o,s,a)):OKn(r.resolveSchemaReference(e),t,r,yau(e.$ref),o,s,a,c,u,d)}return OKn(e,t,r,i,o,s,a,c,u,d)}function Gmi(e,t,r,i,n,a,u){let c=e.$ref.includes("properties")?OKn(r.resolveSchemaReference(e),t,r,i,n,a,u,new Set):Nl.reference(G1c(e,i,a,r.options.preserveSchemaIds));return t?Nl.nullable({title:void 0,nameOverride:void 0,generatedName:S5(i,r.options.preserveSchemaIds),value:c,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0}):c}function TCE(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function OKn(e,t,r,i,n,a,u,c=new Set,d=!1,s){typeof e=="string"&&(e={type:e});let o=hf(e,ad.TYPE_NAME)??(r.options.useTitlesAsName?TCE(e.title):void 0),l=hf(e,ad.SDK_GROUP_NAME)??hf(e,M$.TAGS)?.[0],b=(typeof l=="string"?[l]:l)??[];b=r.resolveGroupName(b);let g=S5(i,r.options.preserveSchemaIds),O=e.title,m=e.description,P=UK(e),D=[];e.example!=null&&D.push({name:void 0,value:e.example,description:void 0});let A=hf(e,M$.EXAMPLES);A!=null&&Object.keys(A).length>0&&D.push(...Object.entries(A).map(([T,z])=>({name:z?.summary??T,value:z.value,description:z.description})));let M=Hnn(e);M!=null&&Object.keys(M).length>0&&D.push(...M.map(T=>({name:void 0,value:T,description:void 0})));let E=sj_({schema:e,description:m,title:O,nameOverride:o,generatedName:g,availability:P});if(E!=null)return E;if(Array.isArray(e.type)){let T=e.type.indexOf("null"),z=T!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&z)e.type.splice(T,1),e.type=e.type[0],e.nullable=!0;else if(z&&(e.type.splice(T,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let $=new Set([...e.oneOf,...e.type]);e.oneOf=[...$]}}if(!t&&e.nullable===!0)return OKn(e,!0,r,i,n,a,u,c,d,s);if("const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(!mau(e.enum))return w5({nameOverride:o,generatedName:g,title:O,primitive:bp.string({default:mKn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:vor({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b,wrapAsNullable:t,description:m,availability:P});let T=uj_(e);return e.enum.length===1&&e.enum[0]!=null&&T==null?vj_({nameOverride:o,generatedName:g,title:O,wrapAsNullable:t,value:e.enum[0],description:m,availability:P,namespace:u,groupName:b}):INi({nameOverride:o,generatedName:g,title:O,fernEnum:T,enumVarNames:hf(e,[M$.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:m,availability:P,wrapAsNullable:t,namespace:u,groupName:b,context:r,source:a,inline:void 0})}if(mau(e.type)&&e.type.length>1){let T=e.type.includes("null"),z=e.type.filter($=>$!=="null").map($=>({type:$,nullable:T}));return xNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t,context:r,subtypes:z,namespace:u,groupName:b,encoding:n,source:a})}if(e.type==="boolean"){let T=hf(e,ad.BOOLEAN_LITERAL);return T!=null?wj_({nameOverride:o,generatedName:g,title:O,literal:mx.boolean(T),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b}):w5({nameOverride:o,generatedName:g,title:O,primitive:bp.boolean({default:CCE(e.default),example:Pj_({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b})}if(e.type==="number")return H1c({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:$nn(e.exclusiveMinimum),exclusiveMaximum:$nn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:bau({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="integer")return hj_({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:$nn(e.exclusiveMinimum),exclusiveMaximum:$nn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:bau({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="float")return H1c({nameOverride:o,generatedName:g,title:O,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:$nn(e.exclusiveMinimum),exclusiveMaximum:$nn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:bau({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="string"){if(e.format==="date-time")return w5({nameOverride:o,generatedName:g,title:O,primitive:bp.datetime({example:vor({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b});if(e.format==="date"&&r.options.typeDatesAsStrings===!1)return w5({nameOverride:o,generatedName:g,title:O,primitive:bp.date({example:vor({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b});if(e.format==="json-string")return Nl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:P,namespace:u,groupName:b,example:void 0});let T=Ej_(e,"const");return T!=null?wj_({nameOverride:o,generatedName:g,title:O,literal:mx.string(T),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b}):w5({nameOverride:o,generatedName:g,title:O,primitive:bp.string({default:mKn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:vor({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b,wrapAsNullable:t,description:m,availability:P})}if(e.type==="array")return dj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,item:e.items,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,example:jj_({schema:e,logger:r.logger,fallback:s}),source:a});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&gau(e))return lj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,additionalProperties:e.additionalProperties,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,example:e.example,source:a});if(e.oneOf!=null&&e.oneOf.length>0&&hf(e,ad.IS_DISCRIMINATED)===!1)return xNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t,context:r,subtypes:e.oneOf,namespace:u,groupName:b,encoding:n,source:a});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?Q1c({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,discriminator:e.discriminator,encoding:n,source:a}):V1c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,source:a});if(e.oneOf!=null&&e.oneOf.length>0){let T=hf(e,ad.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||T?Q1c({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,discriminator:e.discriminator,encoding:n,source:a}):V1c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,source:a});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(r.options.preserveSingleSchemaOneOf)return xNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t,context:r,subtypes:e.oneOf.filter($=>tp($)||$.type!=="null"),encoding:n,namespace:u,groupName:b,source:a});let z=s0(e.oneOf[0],t,r,i,a,u,d);return PKn(z,m,u,b)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let N=e.oneOf[0],U=e.oneOf[1];if(!tp(N)&&N.type==="null")return s0(U,!0,r,i,a,u);if(!tp(U)&&U.type==="null")return s0(N,!0,r,i,a,u)}let z=zCE({schemas:e.oneOf});if(z!=null)return INi({nameOverride:o,generatedName:g,title:O,fernEnum:void 0,enumVarNames:void 0,enumValues:z,_default:e.default,description:m,availability:P,wrapAsNullable:t,namespace:u,groupName:b,context:r,source:a,inline:void 0});let $=Sj_({schemas:e.oneOf,context:r});if($!=null&&!r.options.discriminatedUnionV2&&!T)return W1c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:P,wrapAsNullable:t,discriminant:$.discriminant,variants:$.schemas,context:r,namespace:u,groupName:b,encoding:n,source:a});let I=e.oneOf.filter(N=>!tp(N)&&N.type==="null").length>0;return xNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t||I,context:r,subtypes:e.oneOf.filter(N=>tp(N)||N.type!=="null"),encoding:n,namespace:u,groupName:b,source:a})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let $=s0(e.anyOf[0],t,r,i,a,u,d);return PKn($,m,u,b)}if(e.anyOf.length===2){let[$,I]=e.anyOf;if($!=null&&I!=null){if(!tp($)&&$.type==="null"){let N=s0(I,!0,r,i,a,u);return PKn(N,m,u,b)}else if(!tp(I)&&I.type==="null"){let N=s0($,!0,r,i,a,u);return PKn(N,m,u,b)}}}let T=Sj_({schemas:e.anyOf,context:r});if(T!=null&&!r.options.discriminatedUnionV2)return W1c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:P,wrapAsNullable:t,discriminant:T.discriminant,variants:T.schemas,context:r,namespace:u,groupName:b,encoding:n,source:a});let z=e.anyOf.filter($=>!tp($)&&$.type==="null").length>0;return xNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t||z,context:r,subtypes:e.anyOf.filter($=>tp($)||$.type!=="null"),encoding:n,namespace:u,groupName:b,source:a})}if(e.allOf!=null||e.properties!=null){let T=[];for(let $ of e.allOf??[])(tp($)||Object.keys($).length>0)&&T.push($);if((e.properties==null||gau(e))&&T.length===1&&T[0]!=null){let $=s0(T[0],t,r,i,a,u,d);return PKn($,m,u,b)}let z=T.filter($=>{let I=Oau($);return I||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify($)}`),I});if((e.properties==null||gau(e))&&z.length===1&&z[0]!=null){let $=s0(z[0],t,r,i,a,u,d);return PKn($,m,u,b)}return gj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},description:m,required:e.required,wrapAsNullable:t,allOf:z,context:r,propertiesToExclude:c,namespace:u,groupName:b,fullExamples:D,additionalProperties:e.additionalProperties,availability:P,encoding:n,source:a})}if(e.type==="object"&&BCE(e)&&ICE(e)&&gau(e))return hau({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${g}Key`,title:void 0,description:void 0,availability:void 0,schema:bp.string({default:mKn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:vor({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b},valueSchema:Nl.unknown({nameOverride:void 0,generatedName:`${g}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:b}),namespace:u,groupName:b,encoding:n,example:e.example});if(e.type==null){let T=e.example??e.default;return Nl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:P,namespace:u,groupName:b,example:T})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(i)} value=${JSON.stringify(e)}`)}function CCE(e){if(e!=null){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase();if(t==="true")return!0;if(t==="false")return!1}}}function zNi(e){if(e.$ref.startsWith(Gnn))return e.$ref.replace(Gnn,"")}function G1c(e,t,r,i){let n=hf(e,ad.TYPE_NAME),a=S5(t,i),u=e.description,c=UK(e),d=zNi(e);if(d==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return wv.reference({generatedName:a,nameOverride:n,title:void 0,schema:d,description:u??void 0,availability:c,namespace:void 0,groupName:void 0,source:r})}function BCE(e){return e.oneOf==null||e.oneOf.length===0}function ICE(e){return e.allOf==null||e.allOf.length===0}function gau(e){return e.properties==null||Vq(e.properties)===0}function mau(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function PKn(e,t,r,i){return e.type==="reference"?Nl.reference({...e,description:t,availability:e.availability,namespace:r,groupName:i}):e.type==="optional"?Nl.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0}):e.type==="nullable"?Nl.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0}):e}function Oau(e){return tp(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>Oau(t)):e.oneOf!=null?e.oneOf.every(t=>Oau(t)):e.anyOf!=null?e.anyOf.every(t=>Oau(t)):!1}function wj_({literal:e,wrapAsNullable:t,namespace:r,groupName:i,description:n,availability:a,nameOverride:u,generatedName:c,title:d}){return t?Nl.nullable({nameOverride:u,generatedName:c,title:d,value:Nl.literal({nameOverride:u,generatedName:c,title:d,value:e,description:n,availability:a,namespace:r,groupName:i}),namespace:r,groupName:i,description:n,availability:a,inline:void 0}):Nl.literal({nameOverride:u,generatedName:c,title:d,value:e,namespace:r,groupName:i,description:n,availability:a})}function w5({primitive:e,wrapAsNullable:t,namespace:r,groupName:i,description:n,availability:a,generatedName:u,nameOverride:c,title:d}){return i=typeof i=="string"?[i]:i,t?Nl.nullable({nameOverride:c,generatedName:u,title:d,value:Nl.primitive({nameOverride:c,generatedName:u,title:d,schema:e,description:n,availability:a,namespace:r,groupName:i}),namespace:r,groupName:i,description:n,availability:a,inline:void 0}):Nl.primitive({nameOverride:c,generatedName:u,title:d,schema:e,description:n,availability:a,namespace:r,groupName:i})}function zCE({schemas:e}){let t=new Set;for(let r of e){if(tp(r))return;if(r.enum!=null&&mau(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function Sj_({schemas:e,context:t}){let r={};for(let i of e){let n=Dj_({schema:i,context:t});for(let[a,u]of Object.entries(n)){let c=r[a];c!=null?c[u]=i:r[a]={[u]:i}}}for(let[i,n]of Object.entries(r))if(Object.keys(n).length===e.length)return{discriminant:i,schemas:n}}function Dj_({schema:e,context:t}){let r=tp(e)?t.resolveSchemaReference(e):e;return xCE({schema:r,context:t})}function xCE({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=Dj_({schema:i,context:t});for(let[a,u]of Object.entries(n??{}))r[a]=u}return r}for(let[i,n]of Object.entries(e.properties??{})){let a=tp(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&mau(a.enum)&&RCE(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let u=Ej_(a,"const");a.type==="string"&&u!=null&&(r[i]=u),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function RCE(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 Ej_(e,t){let r=e[t];if(r!=null)return r}function NCE({schema:e,logger:t}){let r=oj_({schema:e,logger:t});if(r!=null)return _j_(r)}var jKn=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:i,namespace:n}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=i,this.namespace=n}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 i=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};i.push(n)}return i.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(Gnn))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let i=t.$ref.substring(Gnn.length).split("/"),n=this.document.components;if(n==null||n.schemas==null)throw new Error("Document does not have components.schemas.");let[a,u,c]=i;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let d=n.schemas[a];if(d==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if(tp(d)&&(d=this.resolveSchemaReference(d)),u==="properties"&&c!=null){let s=d.properties?.[c];if(s==null)throw new Error(`Property "${c}" not found on "${a}". Full ref: ${t.$ref}`);tp(s)?d=this.resolveSchemaReference(s):d=s}return d}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,i){}markSchemaWithDiscriminantValue(t,r,i){}};var Pau=class extends jKn{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",i=this.document.components;if(i==null||i.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let n=t.$ref.substring(r.length),a=i.messages[n];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function wKn(e,t){let r={};if(e!=null)return{rootSchemas:r,namespacedSchemas:{[e]:t}};let i={};for(let[n,a]of Object.entries(t))switch(a.type){case"object":case"array":case"map":case"optional":case"enum":case"literal":case"reference":case"nullable":case"primitive":{if(a.namespace==null){r[n]=a;continue}let u=a.namespace;i[u]??={},i[u][n]=a;continue}case"oneOf":case"unknown":r[n]=a;continue;default:Ao(a)}return{rootSchemas:r,namespacedSchemas:i}}function RNi(e){if(typeof e=="string")return rO.primitive(M_.string(e));if(typeof e=="number")return Number.isInteger(e)?rO.primitive(M_.int(e)):rO.primitive(M_.double(e));if(typeof e=="boolean")return rO.primitive(M_.boolean(e));if(Array.isArray(e)){let t=e.map(r=>RNi(r));return t.length===0?void 0:rO.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,i]of Object.entries(e)){let n=RNi(i);n!=null&&t.push({key:M_.string(r),value:n})}return rO.map(t)}}function R5a(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function Mj_(e){if(e!=null&&Array.isArray(e))return e}var NNi=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,i){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=i}buildExample({schema:t,exampleId:r,example:i,options:n,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:i,options:{...n,maxCheckerDepth:n.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:i,depth:n,visitedSchemaIds:a,options:u,skipReadonly:c}){switch(i.type){case"enum":return typeof r=="string"&&Aj_({schema:i,value:r})?rO.enum(r):i.values[0]!=null?rO.enum(i.values[0]?.value):void 0;case"literal":return rO.literal(i.value);case"nullable":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u)))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:c});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"optional":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u))||Object.is(r,null))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:c});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"primitive":{let d=this.buildExampleFromPrimitive({schema:i.schema,example:r,options:u});return rO.primitive(d)}case"reference":{let d=this.schemas[i.schema];if(d!=null&&!a.has(i.schema)){a.add(i.schema);let s=d?.type==="object"&&!this.nonRequestReferencedSchemas.has(i.schema),o=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:n,options:u,skipReadonly:s||this.context.options.respectReadonlySchemas?c:!1});return a.delete(i.schema),o}return}case"oneOf":switch(i.value.type){case"discriminated":{let d={},s={},o={},l=R5a(r),b=l?.[i.value.discriminantProperty],g=i.value.schemas[b],O=[],m=this.getDiscriminatedUnionVariantSchema(i.value,l);m!=null&&O.push(m),O.push(...Object.entries(i.value.schemas));for(let P of O)if(b!=null&&g!=null&&g.type==="object"){s=this.getAllProperties(g),o=this.getAllRequiredProperties(g),d[i.value.discriminantProperty]=rO.primitive(M_.string(b));break}else{let D=this.buildExampleHelper({exampleId:t,schema:P[1],example:void 0,visitedSchemaIds:a,depth:n,options:u,skipReadonly:c});if(D!=null){this.mergeExampleWith(D,d),d[i.value.discriminantProperty]=rO.primitive(M_.string(P[0]));break}}for(let P of i.value.commonProperties){s[P.key]={schema:P.schema,readonly:!1};let D=this.getResolvedSchema(P.schema);D.type!=="optional"&&D.type!=="nullable"&&(o[P.key]=P.schema)}for(let[P,D]of Object.entries(s)){let A=P in o;if(A&&l?.[P]!=null){let M=this.buildExampleHelper({schema:D.schema,exampleId:t,example:l[P],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:c});if(M!=null)d[P]=M;else return}else{let M=this.buildExampleHelper({exampleId:t,schema:D.schema,example:l?.[P],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:c});if(M!=null)d[P]=M;else if(A)return}}return rO.oneOf(mNi.discriminated(d))}case"undiscriminated":{let d=this.getUnDiscriminatedUnionVariantSchema(i.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:n,options:u,skipReadonly:c});break}}return;case"unknown":if(r!=null){let d=RNi(r);if(d!=null)return rO.unknown(d)}return u.ignoreOptionals||this.exceedsMaxDepth(n,u)?void 0:u.isParameter?rO.primitive(M_.string(u.name??"string")):rO.map([{key:M_.string("key"),value:rO.primitive(M_.string("value"))}]);case"array":{let d=Mj_(r),s=[];if(d!=null&&d.length>0)for(let o of d){let l=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:c});l!=null&&s.push(l)}else if(i.example!=null&&i.example.length>0)for(let o of i.example){let l=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:c});l!=null&&s.push(l)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:c});o!=null&&s.push(o)}return rO.array(s)}case"map":{let d=R5a(r??i.example);if(d!=null&&Object.entries(d).length>0){let l=[];for(let[b,g]of Object.entries(d)){let O=this.buildExampleFromPrimitive({schema:i.key.schema,example:b,options:u}),m=this.buildExampleHelper({exampleId:t,example:g,schema:i.value,visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:c});m!=null&&l.push({key:O,value:m})}return rO.map(l)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return rO.map([{key:M_.string("key"),value:rO.unknown(rO.primitive(M_.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:i.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,visitedSchemaIds:a,depth:n+1,options:{...u,name:"value"},skipReadonly:c});return o!=null?rO.map([{key:s,value:o}]):rO.map([])}case"object":{let d={},s=i.fullExamples?.find(g=>g.name===t)??i.fullExamples?.find(g=>g.name==null)??i.fullExamples?.[0],o=R5a(r)??(s!=null?R5a(s.value):{})??{},l=this.getAllProperties(i),b=this.getAllRequiredProperties(i);for(let[g,O]of Object.entries(l)){if(c&&O.readonly||O.schema._visit({optional:A=>typeof A.availability=="string"&&A.availability==="Deprecated",primitive:()=>!1,object:()=>!1,array:()=>!1,map:()=>!1,enum:()=>!1,reference:()=>!1,literal:()=>!1,oneOf:()=>!1,nullable:()=>!1,unknown:()=>!1,_other:()=>!1}))continue;let m=g in b,P=Object.keys(o).includes(g),D=this.buildExampleHelper({schema:O.schema,exampleId:t,example:o[g],visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:c});if(m&&D!=null)d[g]=D;else{if(m)return;(P&&D!=null||!u.ignoreOptionals&&D!=null)&&(d[g]=D)}}if(i.additionalProperties){for(let[g,O]of Object.entries(o))if(!(g in d)){let m=this.buildExampleHelper({schema:Nl.unknown({example:O,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0}),exampleId:t,example:O,visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:c});m!=null&&(d[g]=m)}}return rO.object({properties:d})}default:Ao(i)}}mergeExampleWith(t,r){t._visit({array:Ko,enum:Ko,literal:Ko,map:i=>{for(let n of i){let a=n.key;a.type==="string"&&(r[a.value]=n.value)}},object:i=>{for(let[n,a]of Object.entries(i.properties))r[n]=a},oneOf:i=>{if(i.type==="discriminated")for(let[n,a]of Object.entries(i.value))r[n]=a;else this.mergeExampleWith(i.value,r)},primitive:Ko,unknown:Ko,_other:Ko})}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 i=r?.[t.discriminantProperty];if(i==null||typeof i!="string")return Object.entries(t.schemas)[0];let n=t.schemas[i];return n==null?Object.entries(t.schemas)[0]:[i,n]}getUnDiscriminatedUnionVariantSchema(t,r){return r==null?t.schemas[0]:t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,u)=>u.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return Aj_({schema:t,value:r})?5:0;case"object":{if(!Rw(r))return 0;let i=this.getAllProperties(t),n=0;for(let[a,u]of Object.entries(i))r[a]!=null?(n++,n+=this.calcExampleHeuristic(u.schema,r[a])):n--;return n}case"array":{if(!Array.isArray(r))return 0;let i=0;for(let n of r)i+=this.calcExampleHeuristic(t.value,n);return i}case"map":{if(!Rw(r))return 0;let i=0;for(let[,n]of Object.entries(r))i+=this.calcExampleHeuristic(t.value,n);return i}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let i=this.getResolvedSchema(t);return i==null?0:this.calcExampleHeuristic(i,r)}case"oneOf":return Object.values(t.value.schemas).map(n=>this.calcExampleHeuristic(n,r)).sort((n,a)=>a-n)[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,i=new Set,n){if(this.exceedsMaxCheckerDepth(r,n))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,i,n);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,i,n);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,i,n))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!i.has(t.schema)){i.add(t.schema);let u=this.hasExample(a,r,i,n);return i.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,i,n));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 i of t.properties)r[i.key]={schema:i.schema,readonly:i.readonly??!1};for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let i of t.properties){let n=this.getResolvedSchema(i.schema);n.type!=="optional"&&n.type!=="nullable"&&(r[i.key]=i.schema)}for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);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:i}){switch(r.type){case"string":return t!=null&&typeof t=="string"?M_.string(t):r.example!=null?M_.string(r.example):M_.string(i.name??Qh.STRING);case"base64":return t!=null&&typeof t=="string"?M_.base64(t):r.example!=null?M_.base64(r.example):M_.base64(Qh.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?M_.boolean(t):r.example!=null?M_.boolean(r.example):M_.boolean(Qh.BOOLEAN);case"date":return t!=null&&typeof t=="string"?M_.date(t):r.example!=null?M_.date(r.example):M_.date(Qh.DATE);case"datetime":return t!=null&&typeof t=="string"?M_.datetime(t):r.example!=null?M_.datetime(r.example):M_.datetime(Qh.DATE_TIME);case"double":return t!=null&&typeof t=="number"?M_.double(t):r.example!=null?M_.double(r.example):M_.double(Qh.DOUBLE);case"float":return t!=null&&typeof t=="number"?M_.float(t):r.example!=null?M_.float(r.example):M_.float(Qh.FLOAT);case"int":return t!=null&&typeof t=="number"?M_.int(t):r.example!=null?M_.int(r.example):M_.int(Qh.INT);case"int64":return t!=null&&typeof t=="number"?M_.int64(t):r.example!=null?M_.int64(r.example):M_.int64(Qh.INT64);case"uint":return t!=null&&typeof t=="number"?M_.uint(t):r.example!=null?M_.uint(r.example):M_.uint(Qh.UINT);case"uint64":return t!=null&&typeof t=="number"?M_.uint64(t):r.example!=null?M_.uint64(r.example):M_.uint64(Qh.UINT64);default:Ao(r)}}};function Aj_({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function $Qt(e){switch(e.type){case"object":return Nl.object({allOf:e.allOf,properties:e.properties.map(t=>LCE(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:void 0});case"array":return Nl.array({description:e.description,availability:e.availability,value:$Qt(e.value),generatedName:e.generatedName,title:e.title,namespace:e.namespace,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return Nl.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,example:void 0,source:e.source,inline:void 0});case"literal":return Nl.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName});case"nullable":return Nl.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:$Qt(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return Nl.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:$Qt(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return Nl.primitive({description:e.description,availability:e.availability,schema:qj_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Nl.map({description:e.description,availability:e.availability,key:Nl.primitive({description:e.key.description,availability:e.key.availability,schema:qj_(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:$Qt(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return Nl.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return Nl.oneOf(FCE(e.value));case"unknown":return Nl.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,namespace:void 0,groupName:void 0,description:void 0,availability:void 0});default:Ao(e)}}function FCE(e){switch(e.type){case"discriminated":return xee.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:$Qt(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,$Qt(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return xee.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>$Qt(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:Ao(e)}}function qj_(e){switch(e.type){case"string":return bp.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return bp.base64({example:void 0});case"boolean":return bp.boolean({default:e.default,example:void 0});case"date":return bp.date({example:void 0});case"datetime":return bp.datetime({example:void 0});case"double":return bp.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 bp.float({example:void 0});case"int":return bp.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 bp.int64({default:e.default,example:void 0});case"uint":return bp.uint({default:void 0,example:void 0});case"uint64":return bp.uint64({default:void 0,example:void 0});default:Ao(e)}}function LCE(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:$Qt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function jau(e){return e.type!=="optional"&&e.type!=="nullable"}function J1c(e){return e==="POST"||e==="PUT"||e==="PATCH"}function N5a(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 wau=class{schemas;context;globalHeaders;exampleTypeFactory;logger;constructor(t,r,i){this.schemas=t,this.context=r,this.globalHeaders=i,this.schemas=t,this.exampleTypeFactory=new NNi(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=VCE(t.request),i=WCE(t.response);if(r?.type==="unsupported"||i?.type==="unsupported")return[];let n=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:J1c(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});b!=null&&n.push([void 0,b])}else for(let{name:b,value:g}of r.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:J1c(t.method),schema:r.schema,exampleId:b,example:g,options:{isParameter:!1,ignoreOptionals:!0}});O!=null&&n.push([b,O])}if(l&&n.length===0)return this.logger.trace(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(i!=null&&i.type==="present"){let l=this.isSchemaRequired(i.schema);if(i.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:void 0,example:void 0,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});b!=null&&(t.response?.type==="json"?a.push([void 0,VQt.withoutStreaming(b)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,VQt.withStreaming({sse:t.response?.type==="streamingSse",events:[b]})]))}else for(let{name:b,value:g}of i.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:b,example:g,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});O!=null&&(t.response?.type==="json"?a.push([b,VQt.withoutStreaming(O)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,VQt.withStreaming({sse:t.response?.type==="streamingSse",events:[O]})]))}if(l&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let l of t.pathParameters){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!GQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&u.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:g})}let c=[];for(let l of t.queryParameters){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!GQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&c.push({name:l.name,value:g})}let d=[];for(let l of t.headers){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!GQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&d.push({name:l.name,value:g})}for(let l of this.globalHeaders){let b=l.schema!=null?$Qt(l.schema):Nl.primitive({nameOverride:void 0,generatedName:"",title:void 0,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,schema:bp.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})}),g=this.exampleTypeFactory.buildExample({schema:b,exampleId:void 0,example:void 0,options:{name:l.header,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!GQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for global header ${l.header} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),g==null)return[];g!=null&&d.push({name:l.header,value:g})}let s=[];t.request!=null&&t.response!=null?s=UCE(n,a):t.request!=null?s=n.map(([l,b])=>({id:l,request:b,response:void 0})):t.response!=null&&(s=a.map(([l,b])=>({id:l,request:void 0,response:b})));let o=t.examples.filter(l=>N5a(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let b=l.value["code-samples"];if(b!=null)return this.convertCodeSamples(b)}return}else return l.codeSamples}).filter(l=>bv(l));return s.length===0?[UQt.full({name:void 0,description:void 0,pathParameters:u,queryParameters:c,headers:d,request:void 0,response:void 0,codeSamples:o})]:s.map(({id:l,request:b,response:g})=>UQt.full({name:l,description:void 0,pathParameters:u,queryParameters:c,headers:d,request:b,response:g,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?Lmi.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):Lmi.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?D$.Csharp:r.sdk,code:r.code})).filter(bv)}isSchemaRequired(t){return jau(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function UCE(e,t){let r=[];if(e.length<=1){let[n,a]=e[0]??[];if(t.length===0)return r.push({id:n,request:a,response:void 0}),r;for(let[u,c]of t)r.push({id:u??n,request:a,response:c});return r}if(t.length<=1){let[n,a]=t[0]??[];if(t.length===0)return r.push({id:n,request:void 0,response:a}),r;for(let[u,c]of e)r.push({id:u??n,request:c,response:a});return r}let i=new Set;for(let[n,a]of e){let u=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(n==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let c=!1;for(let d=0;d<t.length;d++){let[s,o]=t[d];s==null||i.has(d)||n===s&&(r.push({id:n,request:a,response:o}),s!=null&&i.add(d),c=!0)}!c&&u!=null&&r.push({id:n,request:a,response:u})}for(let n=0;n<t.length;n++){if(i.has(n))continue;let[a,u]=t[n],c=e.find(([d])=>d==null)?.[1]??e[0]?.[1];c!=null&&r.push({id:a,request:c,response:u})}return r}function VCE(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:HCE(e),examples:[]}:e.type==="json"||e.type==="formUrlEncoded"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function WCE(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"&&e.type!=="streamingSse"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function GQt(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return GQt(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return GQt(e.value.value);default:return!1}default:Ao(e)}}function HCE(e){return Nl.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:$Qt(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,writeonly:void 0,inline:void 0}).filter(bv),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source,inline:void 0})}var SKn=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new NNi(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,handshake:i,source:n,namespace:a}){let u=[];for(let c of r){let d=[];for(let l of i.queryParameters){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.queryParameters?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});g!=null&&!GQt(g)&&(g=void 0),!(b&&g==null)&&g!=null&&d.push({name:l.name,value:g})}let s=[];for(let l of i.headers){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.headers?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});g!=null&&!GQt(g)&&(g=void 0),!(b&&g==null)&&g!=null&&s.push({name:l.name,value:g})}let o=[];for(let l of c.messages){let b=t.getExampleMessageReference(l),g=t.resolveMessageReference({$ref:b}),O=tp(g.payload)?t.resolveSchemaReference(g.payload):g.payload,m=this.exampleTypeFactory.buildExample({schema:s0(O,!1,t,[l.messageId],n,a),exampleId:void 0,example:l.value,options:{isParameter:!1,ignoreOptionals:!0}});m!=null&&o.push({messageType:l.type,payload:m,description:void 0})}u.push({name:c.summary,queryParameters:d,headers:s,description:c.description,messages:o})}return u}buildWebsocketSessionExample({handshake:t,messages:r}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},n=[];for(let u of t.queryParameters){let c=this.isSchemaRequired(u.schema),d=this.exampleTypeFactory.buildExample({schema:u.schema,exampleId:void 0,example:void 0,options:{name:u.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!GQt(d)&&(d=void 0),c&&d==null)return;d!=null&&n.push({name:u.name,value:d})}let a=[];for(let u of t.headers){let c=this.isSchemaRequired(u.schema),d=this.exampleTypeFactory.buildExample({schema:u.schema,exampleId:void 0,example:void 0,options:{name:u.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!GQt(d)&&(d=void 0),c&&d==null)return;d!=null&&a.push({name:u.name,value:d})}for(let u of r){let c=this.exampleTypeFactory.buildExample({schema:u.payload,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});c!=null&&i.messages.push({messageType:u.type,payload:c,description:void 0})}return i}isSchemaRequired(t){return jau(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 Fee={FERN_PARAMETER_OPTIONAL:"x-fern-optional",FERN_CHANNEL_ADDRESS:"x-fern-address",FERN_DISPLAY_NAME:"x-fern-display-name",FERN_SDK_GROUP_NAME:"x-fern-sdk-group-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",FERN_ENUM:"x-fern-enum",IGNORE:"x-fern-ignore"};function Sau(e){return hf(e,Fee.FERN_EXAMPLES)??[]}function Dau(e,t){return t.includes("://")?t:`${e}://${t}`}function Eau(e){return e.startsWith("/")?e:"/"+e}function Bj_({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={};for(let[s,o]of Object.entries(n.components?.schemas??{})){let l=s0(o,!1,e,[s],r,e.namespace);a[s]=l}let c=new SKn(a,e),d={};for(let[s,o]of Object.entries(n.servers??{}))d[s]={name:s,url:Dau(o.protocol,o.url)};for(let[s,o]of Object.entries(n.channels??{})){let l=hf(o,Fee.IGNORE);if(l!=null&&l){e.logger.debug(`Channel ${s} is marked with x-fern-ignore. Skipping.`);continue}let b=[];if(o.parameters!=null)for(let[D,A]of Object.entries(o.parameters??{}))b.push({name:D,description:A.description,parameterNameOverride:void 0,schema:A.schema!=null?s0(A.schema,!1,e,t,r,e.namespace):Nl.primitive({schema:bp.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,namespace:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:UK(A),source:r});let g=[],O=[];if(o.bindings?.ws!=null){if(o.bindings.ws.headers!=null){let D=o.bindings.ws.headers.required??[];for(let[A,M]of Object.entries(o.bindings.ws.headers.properties??{})){if(tp(M)){let E=e.resolveSchemaReference(M);g.push({name:A,schema:Gmi(M,!1,e,t,void 0,r,e.namespace),description:E.description,parameterNameOverride:void 0,env:void 0,availability:UK(E),source:r});continue}g.push({name:A,schema:s0(M,!D.includes(A),e,[...t,A],r,e.namespace),description:M.description,parameterNameOverride:void 0,env:void 0,availability:UK(M),source:r})}}if(o.bindings.ws.query!=null){let D=o.bindings.ws.query.required??[];for(let[A,M]of Object.entries(o.bindings.ws.query.properties??{})){if(tp(M)){let E=e.resolveSchemaReference(M);O.push({name:A,schema:Gmi(M,!1,e,t,void 0,r,e.namespace),description:E.description,parameterNameOverride:void 0,availability:UK(E),source:r});continue}O.push({name:A,schema:s0(M,!D.includes(A),e,[...t,A],r,e.namespace),description:M.description,parameterNameOverride:void 0,availability:UK(M),source:r})}}}let m;o.publish!=null&&("oneOf"in o.publish.message?m=Tj_({generatedName:o.publish.operationId??"PublishEvent",event:o.publish,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):m=Cj_({action:"Publish",channelPath:s,message:o.publish.message,context:e,source:r}));let P;if(o.subscribe!=null&&("oneOf"in o.subscribe.message?P=Tj_({generatedName:o.subscribe.operationId??"SubscribeEvent",event:o.subscribe,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):P=Cj_({action:"Subscribe",channelPath:s,message:o.subscribe.message,context:e,source:r})),g.length>0||O.length>0||m!=null||P!=null){let D=Sau(o),A=[];if(D.length>0)A=c.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:D,handshake:{headers:g,queryParameters:O},source:r,namespace:e.namespace});else{let z=[];m!=null&&z.push({type:"publish",payload:m}),P!=null&&z.push({type:"subscribe",payload:P});let $=c.buildWebsocketSessionExample({handshake:{headers:g,queryParameters:O},messages:z});$!=null&&A.push($)}let M=hf(o,Fee.FERN_CHANNEL_ADDRESS),E=M??Eau(s),T=[];m!=null&&T.push({origin:"client",name:"publish",body:DA(m)}),P!=null&&T.push({origin:"server",name:"subscribe",body:DA(P)}),u[s]={audiences:hf(o,ad.AUDIENCES)??[],handshake:{headers:g.map(z=>({...z,schema:DA(z.schema),env:z.env})),queryParameters:O.map(z=>({...z,schema:DA(z.schema)})),pathParameters:b.map(z=>({...z,parameterNameOverride:void 0,schema:DA(z.schema)}))},groupName:e.resolveGroupName([hf(o,Fee.FERN_SDK_GROUP_NAME)??s]),messages:T,servers:(o.servers?.map(z=>d[z])??Object.values(d)).filter(z=>z!=null),summary:hf(o,Fee.FERN_DISPLAY_NAME),path:E,description:o.description,examples:A,source:r}}}return{groupedSchemas:wKn(e.namespace,a),channels:u??void 0,servers:Object.values(d),basePath:hf(n,Fee.BASE_PATH)}}function Tj_({generatedName:e,event:t,context:r,breadcrumbs:i,source:n,options:a,asyncApiOptions:u}){if("oneOf"in t.message&&t.message.oneOf!=null){let c=[],d=[];for(let s of t.message.oneOf){let o,l={type:"notFound"};if(tp(s)){let b=r.resolveMessageReference(s);!tp(b.payload)&&u.naming==="v2"?(l=b.name?{type:"name",name:b.name}:l,o={...b.payload,title:b.name??b.payload.title,description:b.name??b.payload.description}):o=b.payload}else o=s;d.push(l),c.push(o)}return xNi({description:t.description??t.message.description,availability:UK(t.message),subtypes:c,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:i,context:r,encoding:void 0,source:n,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}function Cj_({action:e,channelPath:t,message:r,context:i,source:n}){if(r.payload!=null){let a=r.payload;return tp(r.payload)&&(a=i.resolveSchemaReference(r.payload)),s0(a,!1,i,[t,e],n,i.namespace)}}var Mau=class extends jKn{getExampleMessageReference(t){return`#/channels/${t.channelId}/messages/${t.messageId}`}resolveParameterReference(t){let r="#/components/parameters/";if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve ${t.$ref}`);let i=t.$ref.substring(r.length),n=this.document.components.parameters[i];if(n==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in n?this.resolveParameterReference(n):n}resolveMessageReference(t){let r="#/channels/",i="#/components/messages/";if(t.$ref.startsWith(r)){let c=t.$ref.split("/"),d=c[2],s=c[4];if(d==null||s==null||!this.document.channels?.[d])throw new Error(`Failed to resolve message reference ${t.$ref} in channel ${d}`);let l=this.document.channels[d].messages?.[s];if(l==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in l?this.resolveMessageReference(l):{name:s,...l}}let n=this.document.components;if(!t.$ref.startsWith(i)||!n?.messages)throw new Error(`Failed to resolve message reference: ${t.$ref} in v3 components`);let a=t.$ref.substring(i.length),u=n.messages[a];if(u==null)throw new Error(`${t.$ref} is undefined`);return{name:a,...u}}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}};var Ij_="#/channels/",zj_="#/servers/",K1c="$message.";function Rj_({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={},c={},d=[],s={};for(let[O,m]of Object.entries(n.components?.schemas??{}))a[O]=s0(m,!1,e,[O],r,e.namespace);for(let[O,m]of Object.entries(n.channels??{}))if(u[O]||(u[O]={}),m.messages){for(let[P,D]of Object.entries(m.messages))if(e.isReferenceObject(D)||e.isMessageWithPayload(D))if(c[P]||(c[P]=[]),e.isReferenceObject(D)){let A=e.resolveMessageReference(D);c[P].push({channelId:O,payload:A.payload})}else c[P].push({channelId:O,payload:D.payload})}for(let[O,m]of Object.entries(c))if(m.length===1){let P=m[0],D=P.channelId;u[D]=u[D]||{},u[D][O]=s0(P.payload,!1,e,[O],r,e.namespace)}else{d.push(O);for(let{channelId:P,payload:D}of m){let A=`${P}_${O}`;u[P]||(u[P]={}),u[P][A]=s0(D,!1,e,[A],r,e.namespace)}}let o=Object.values(u).reduce((O,m)=>({...O,...m}),{}),l=new SKn(o,e),b={};for(let[O,m]of Object.entries(n.servers??{}))b[O]={name:O,url:Dau(m.protocol,m.host)};let g={};for(let[O,m]of Object.entries(n.operations??{})){if(hf(m,Fee.IGNORE))continue;let P=$CE(m);if(g[P]||(g[P]={subscribe:[],publish:[],__parsedMessages:[]}),m.action==="receive")g[P].subscribe.push(...m.messages);else if(m.action==="send")g[P].publish.push(...m.messages);else throw new Error(`Operation ${O} has an invalid action: ${m.action}`)}for(let[O,m]of Object.entries(g)){let P=[];P.push(...xj_({messages:m.subscribe,channelPath:O,origin:"server",messageSchemas:u[O]??{},duplicatedMessageIds:d,context:e})),P.push(...xj_({messages:m.publish,channelPath:O,origin:"client",messageSchemas:u[O]??{},duplicatedMessageIds:d,context:e})),g[O]!=null&&(g[O].__parsedMessages=P)}for(let[O,m]of Object.entries(n.channels??{})){if(hf(m,Fee.IGNORE))continue;let P=[],D=[],A=[];if(m.parameters!=null)for(let[M,E]of Object.entries(m.parameters)){let T=e.isReferenceObject(E)?e.resolveParameterReference(E):E,{type:z,parameterKey:$}=T.location!=null?GCE(T.location):{type:m.address?.includes(`={${M}}`)?"query":"path",parameterKey:M},I=hf(T,Fee.FERN_PARAMETER_OPTIONAL),N=eI(F_(O))+eI(F_(M)),U={...T,type:"string",title:N,example:T.examples?.[0],default:T.default,enum:T.enum,required:void 0},Y=s0(U,!1,e,[$],r,e.namespace);I&&(Y=Nl.optional({value:Y,description:void 0,availability:void 0,generatedName:"",title:N,namespace:void 0,groupName:void 0,nameOverride:void 0,inline:void 0}));let J={name:$,description:T.description,parameterNameOverride:void 0,schema:Y,variableReference:void 0,availability:UK(E),source:r};z==="header"?P.push({...J,env:void 0}):z==="path"?D.push(J):(z==="payload"||z==="query")&&A.push(J)}if(P.length>0||A.length>0||g[O]!=null&&(g[O].publish!=null||g[O].subscribe!=null)){let M=Sau(m),E=g[O]?.__parsedMessages??[],T=[];if(M.length>0)T=l.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:M,handshake:{headers:P,queryParameters:A},source:r,namespace:e.namespace});else{let z=[],{examplePublishMessage:$,exampleSubscribeMessage:I}=JCE({messages:E,messageSchemas:u[O]??{}});$!=null&&z.push($),I!=null&&z.push(I);let N=l.buildWebsocketSessionExample({handshake:{headers:P,queryParameters:A},messages:z});N!=null&&T.push(N)}s[O]={audiences:hf(m,ad.AUDIENCES)??[],handshake:{headers:P.map(z=>({...z,schema:DA(z.schema),env:z.env})),queryParameters:A.map(z=>({...z,schema:DA(z.schema)})),pathParameters:D.map(z=>({...z,parameterNameOverride:void 0,schema:DA(z.schema)}))},groupName:e.resolveGroupName([hf(m,Fee.FERN_SDK_GROUP_NAME)??O]),messages:E,summary:hf(m,Fee.FERN_DISPLAY_NAME),servers:m.servers?.map(z=>QCE(b,z))??Object.values(b),path:m.address?.split("?")[0]??Eau(O),description:m.description,examples:T,source:r}}}return{groupedSchemas:wKn(e.namespace,a),channels:s,servers:Object.values(b),basePath:hf(n,Fee.BASE_PATH)}}function $CE(e){if(!e.channel.$ref.startsWith(Ij_))throw new Error(`Failed to resolve channel path from operation ${e.channel.$ref}`);return e.channel.$ref.substring(Ij_.length)}function GCE(e){try{let[t,r]=e.split("#/");if(t==null||r==null)throw new Error(`Invalid location format: ${e}; unable to parse message type and parameter key`);if(!t.startsWith(K1c))throw new Error(`Invalid location format: ${e}; expected ${K1c} prefix`);let i=t.substring(K1c.length);if(i!=="header"&&i!=="path"&&i!=="payload")throw new Error(`Invalid message type: ${i}. Must be one of: header, path, payload`);return{type:i,parameterKey:r}}catch{throw new Error(`Invalid location format: ${e}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`)}}function QCE(e,t){if(!t.$ref.startsWith(zj_))throw new Error(`Failed to resolve server name from server ref ${t.$ref}`);let r=t.$ref.substring(zj_.length),i=e[r];if(i==null)throw new Error(`Failed to find server with name ${r}`);return i}function xj_({messages:e,channelPath:t,origin:r,messageSchemas:i,duplicatedMessageIds:n,context:a}){let u=[];return e.forEach((c,d)=>{let o=a.resolveMessageReference(c).name;n.includes(o)&&(o=`${t}_${o}`);let l=i[o];l!=null&&u.push({origin:r,name:o??`${r}Message${d+1}`,body:DA(l)})}),u}function JCE({messages:e,messageSchemas:t}){let r=e.find(u=>u.origin==="client")?.name,i=e.find(u=>u.origin==="server")?.name,n=r!=null?t[r]:void 0,a=i!=null?t[i]:void 0;return{examplePublishMessage:n!=null&&r!=null?{type:r,payload:n}:void 0,exampleSubscribeMessage:a!=null&&i!=null?{type:i,payload:a}:void 0}}function Nj_({document:e,taskContext:t,options:r,source:i,asyncApiOptions:n,namespace:a}){let u=[];if(a!=null&&u.push(a),parseFloat(e.asyncapi)<3){let c=e;c.tags?.[0]!=null?u.push(c.tags[0].name):n.naming!=="v2"&&u.push("websocket");let d=new Pau({document:c,taskContext:t,options:r,namespace:a});return Bj_({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:c})}else{let c=e,d=new Mau({document:c,taskContext:t,options:r,namespace:a});return Rj_({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:c})}}function Fj_(e){return hf(e,ad.ASYNC_CONFIG)}var Lj_="$request.";function Uj_(e){let t=hf(e,ad.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",streamDescription:t["stream-description"],streamConditionProperty:KCE(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function KCE(e){return e.startsWith(Lj_)?e.slice(Lj_.length):e}function Vj_(e){let t=e;if(t.cursor!=null)return DFe.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});if("offset"in e){let r=e;return DFe.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}if("type"in e&&e.type==="custom"){let r=e;return DFe.custom({results:r.results})}throw new Error("Invalid pagination extension")}function Wj_(e,t){let r=hf(t,ad.PAGINATION);if(r!=null){if(typeof r=="boolean"){let i=hf(e,ad.PAGINATION);if(typeof i=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return i==null?void 0:Vj_(i)}return Vj_(r)}}function Hj_(e){let t=YCE(e),r={};return Y1c({obj:t,occurrences:r,breadcrumbs:[]}),r}function Y1c({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let i of e)Y1c({obj:i,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let i=e.$ref;t[i]==null?t[i]=1:t[i]+=1;return}for(let i in e)Y1c({obj:e[i],occurrences:t,breadcrumbs:[...r,i]})}}}function YCE(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?F5a(r.get):void 0,put:r?.put!=null?F5a(r.put):void 0,post:r?.post!=null?F5a(r.post):void 0,patch:r?.patch!=null?F5a(r.patch):void 0,delete:r?.delete!=null?F5a(r.delete):void 0}]))}}function F5a(e){return{...e,requestBody:e.requestBody!=null?tp(e.requestBody)?e.requestBody:XCE(e.requestBody):void 0}}function XCE(e){let t,r;for(let i in e.content){let n=Uq.parse(i);n!=null&&(n.isJSON()?t=e.content[i]:n.isMultipart()&&(r=e.content[i]))}return r!=null&&t!=null?{...e,content:{[Uq.MULTIPART_FORM_DATA]:r}}:e}var Aau=class{endpoints;parser=new Pen;constructor({context:t,options:r}){this.endpoints=r.filter?.endpoints?new Set(this.validateAndFilterEndpoints({context:t,endpoints:r.filter.endpoints})):void 0}skipEndpoint({method:t,path:r}){return this.endpoints!=null&&!this.endpoints.has(`${t} ${r}`)}hasEndpoints(){return this.endpoints!=null}validateAndFilterEndpoints({context:t,endpoints:r}){let i=[];for(let n of r){let a=this.parser.tryParse(n);if(a==null){t.logger.debug(`Ignoring configured filter endpoint "${n}"; expected format "POST /users/get"`);continue}i.push(`${a.method} ${a.path}`)}return i}};var $j_="#/components/parameters/",Gj_="#/components/responses/",Qj_="#/components/examples/",Jj_="#/components/requestBodies/",DKn=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=i,this.refOccurrences=Hj_(t),this.options=n,this.source=a,this.filter=new Aau({context:r,options:n}),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 i={type:"namespace",name:this.namespace};r.push(i)}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(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return{"x-fern-type":"unknown"};if(Array.isArray(i)){let a=parseInt(n,10);if(isNaN(a)||a<0||a>=i.length)return{"x-fern-type":"unknown"};i=i[a]}else i=i[n]}return i==null?(this.logger.warn(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):(tp(i)&&(i=this.resolveSchemaReference(i)),i)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith($j_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring($j_.length),i=this.document.components.parameters[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return tp(i)?this.resolveParameterReference(i):i}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(Jj_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(Jj_.length),i=this.document.components.requestBodies[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return tp(i)?this.resolveRequestBodyReference(i):i}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(Gj_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(Gj_.length),i=this.document.components.responses[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return tp(i)?this.resolveResponseReference(i):i}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(Qj_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(Qj_.length),i=this.document.components.examples[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return tp(i)?this.resolveExampleReference(i):i}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}};var Qnn=class extends DKn{constructor({document:t,taskContext:r,options:i,source:n,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:i,source:n,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,i){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,i){}getDiscriminatedUnionMetadata(t){}};var ZCE=ou.object({lang:ou.string(),label:ou.optional(ou.string()),source:ou.string()}),X1c=ou.array(ZCE);var Kj_={README_EXT:"x-readme"};function kCE(e){if(!Array.isArray(e))return!1;for(let t of e)if(!Rw(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function Yj_(e){let t=hf(e,Kj_.README_EXT);if(!Rw(t))return[];let r=t["code-samples"];if(!kCE(r))return[];let i=[];for(let n of r)i.push({name:n.name,language:n.language,code:n.code,install:n.install,docs:void 0});return i}function Xj_(e,t,r){let n=(hf(t,ad.EXAMPLES)??[]).filter(s=>{let o=i7.serialization.ExampleEndpointCallSchema.parse(s);return o.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),o.ok}),a=z5a(t,M$.REDOCLY_CODE_SAMPLES_KEBAB,X1c,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],c=[...z5a(t,M$.REDOCLY_CODE_SAMPLES_CAMEL,X1c,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];c.length>0&&n.push({"code-samples":c.map(s=>({name:s.label??s.lang,language:s.lang,code:s.source,install:void 0,docs:void 0}))});let d=Yj_(t);return d.length>0&&n.push({"code-samples":d}),n.map(UQt.unknown)}function Zj_(e){let t=hf(e,ad.AVAILABILITY);if(t==="ga"||t==="generally-available")return S$.GenerallyAvailable;if(t==="beta"||t==="pre-release")return S$.Beta;if(t==="deprecated")return S$.Deprecated;if(e.deprecated)return S$.Deprecated}function qau(e){return{url:eBE({url:e.url,variables:e.variables??{}}),description:e.description,name:tBE(e),audiences:hf(e,ad.AUDIENCES)}}function eBE({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,n.default]));for(let[i,n]of Object.entries(r))e=e.replace(`{${i}}`,encodeURIComponent(n));return e}function tBE(e){let t=hf(e,[ad.SERVER_NAME_V1,ad.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function kj_(e){return hf(e,ad.PARAMETER_NAME)}function ew_(e){return hf(e,ad.SDK_VARIABLE)}function Tau({path:e,httpMethod:t,parameters:r,context:i,requestBreadcrumbs:n,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let c of r){let d=hf(c,ad.IGNORE);if(d!=null&&d){i.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=tp(c)?i.resolveParameterReference(c):c,o=s.required??!1,l=UK(s),b=[...n,s.name],g=S5(b,i.options.preserveSchemaIds),O=s.schema!=null?s0(s.schema,!o,i,b,a,i.namespace,!1,new Set,vor({schema:s,logger:i.logger})):o?Nl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:bp.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:vor({schema:s,logger:i.logger})}),description:void 0,availability:l,namespace:void 0,groupName:void 0}):Nl.optional({nameOverride:void 0,generatedName:g,title:void 0,value:Nl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:bp.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:vor({schema:s,logger:i.logger})}),description:void 0,availability:void 0,namespace:void 0,groupName:void 0}),description:void 0,availability:l,namespace:void 0,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!tp(s.schema)&&s.schema.default!=null){let P=s.schema.default;typeof P=="string"&&P.length>0&&(O=Nl.literal({nameOverride:void 0,generatedName:g,title:void 0,value:mx.string(P),description:void 0,availability:l,namespace:void 0,groupName:void 0}))}let m={name:s.name,schema:O,description:s.description,parameterNameOverride:kj_(s),availability:l,source:a};s.in==="query"?u.queryParameters.push(m):s.in==="path"?u.pathParameters.push({...m,variableReference:ew_(s)}):s.in==="header"?!rBE.has(s.name.toLowerCase())&&!i.authHeaders.has(s.name)?u.headers.push({...m,env:void 0}):i.logger.debug(`Ignoring ${s.name} header, in ${t.toUpperCase()} ${e}`):i.logger.warn(`Skipping ${s.in} parameter, ${s.name}, in ${t.toUpperCase()} ${e}`)}return u}var rBE=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function tw_(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r,schema:n??{},examples:L5a(i,t)}}}function iBE(e){return e.includes("json")||e==="*/*"}function Z1c({content:e,context:t}){for(let[r,i]of Object.entries(e))if(Cau({mediaType:r,mediaTypeObject:i,context:t})!=null)return[r,i]}function Cau({mediaType:e,mediaTypeObject:t,context:r}){if(!iBE(e))return;let i=t.schema;return{contentType:e.includes("*")?void 0:e,schema:i??{},examples:L5a(t,r)}}function Bau({content:e,context:t}){let r=Z1c({content:e,context:t});if(!r)return;let[i,n]=r;return Cau({mediaType:i,mediaTypeObject:n,context:t})}function rw_(e,t){for(let r of Object.keys(e)){let i=e[r];if(i==null)continue;return{schema:i.schema??{},examples:L5a(i,t)}}}function L5a(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let i=hf(e,M$.EXAMPLES);return i!=null&&Object.keys(i).length>0&&r.push(...Object.entries(i).map(([n,a])=>({name:a.summary??n,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([n,a])=>{let u=tp(a)?t.resolveExampleReference(a):a;return{name:u.summary??n,value:u.value,description:u.description}})),r}function nBE({content:e,context:t}){for(let[r,i]of Object.entries(e))if(nw_({mediaType:r,mediaTypeObject:i,context:t}))return[r,i]}function nw_({mediaType:e,mediaTypeObject:t,context:r}){if(Uq.parse(e)?.isURLEncoded())return{schema:t.schema,contentType:e,examples:L5a(t,r)}}function aBE({content:e}){for(let[t,r]of Object.entries(e))if(aw_({mediaType:t,mediaTypeObject:r}))return[t,r]}function aw_({mediaType:e,mediaTypeObject:t}){if(Uq.parse(e)?.isMultipart())return{schema:t.schema,encoding:t.encoding}}function ow_({mediaType:e}){return Uq.parse(e)?.isBinary()??!1}function oBE({content:e}){for(let[t,r]of Object.entries(e))if(ow_({mediaType:t}))return[t,r]}function uBE(e,t){let r=tp(e)?k1c(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([i,n])=>!tp(n)&&n.type==="string"&&n.format==="binary")!=null}function zau({content:e,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u}){let c=oBE({content:e});if(c){let[b,g]=c;return bor({mediaType:b,mediaTypeObject:g,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u})}let d=aBE({content:e}),s=Z1c({content:e,context:i}),o=sBE({json:s,multipart:d,document:r,visitor:{json:([b,g])=>bor({mediaType:b,mediaTypeObject:g,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u}),multipart:([b,g])=>bor({mediaType:b,mediaTypeObject:g,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u}),neither:()=>{}}});if(o)return o;let l=nBE({content:e,context:i});if(l){let[b,g]=l;return bor({mediaType:b,mediaTypeObject:g,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u})}}function sBE({json:e,multipart:t,document:r,visitor:i}){if(!e&&!t)return i.neither();let[,n]=e??[void 0,void 0],[,a]=t??[void 0,void 0];return!n?.schema&&!a?.schema?i.neither():n?.schema&&a?.schema?n.schema&&uBE(n.schema,r)?i.multipart(t):i.json(e):n?.schema?i.json(e):a?.schema?i.multipart(t):i.neither()}function bor({mediaType:e,mediaTypeObject:t,description:r,document:i,context:n,requestBreadcrumbs:a,source:u,namespace:c}){let d=cBE({mediaTypeObject:t});if(ow_({mediaType:e}))return zee.octetStream({description:r,source:u,sdkMethodName:d,contentType:e});let s=aw_({mediaType:e,mediaTypeObject:t}),o=s?.schema,l=s?.encoding;if(o){let O=tp(o)?k1c(o,i):{id:void 0,schema:o},m=s0(O.schema,!1,n,a,u,c,!1),P=[];if(m.type==="object")for(let D of m.properties){let{isFile:A,isOptional:M,isArray:E,description:T}=Iau({schema:D.schema});if(A){let z=iw_(D.key,l);P.push({key:D.key,schema:Umi.file({isOptional:M,isArray:E,description:T}),description:T,contentType:z,exploded:!1,encoding:z==null?n.options.defaultFormParameterEncoding:void 0})}else{let z=iw_(D.key,l);P.push({key:D.key,schema:Umi.json(D.schema),description:void 0,contentType:z,exploded:l?.[D.key]?.explode,encoding:z==null?n.options.defaultFormParameterEncoding:fBE(z)})}}return zee.multipart({name:tp(o)&&n.getNumberOfOccurrencesForRef(o)===1?O.id:void 0,description:O.schema.description,properties:P,source:u,sdkMethodName:d})}let b=Cau({mediaType:e,mediaTypeObject:t,context:n});if(b){let O=s0(b.schema,!1,n,a,u,c,!0);return zee.json({description:void 0,schema:O,contentType:b.contentType,fullExamples:b.examples,additionalProperties:!tp(b.schema)&&gKn(b.schema.additionalProperties,n.options),source:u,sdkMethodName:d})}let g=nw_({mediaType:e,mediaTypeObject:t,context:n});if(g!=null&&g.schema!=null){let O=s0(g.schema,!1,n,a,u,c,!1);return zee.formUrlEncoded({schema:O,description:r,contentType:g.contentType,source:u,fullExamples:g.examples,additionalProperties:!1,sdkMethodName:d})}}function cBE({mediaTypeObject:e}){return hf(e,ad.SDK_METHOD_NAME)}var lBE={"application/json":"json"};function fBE(e){return e?lBE[e]:void 0}function k1c(e,t){if(!e.$ref.startsWith(Gnn))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=zNi(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let i=t.components?.schemas?.[r];if(i==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return tp(i)?k1c(i,t):{id:r,schema:i}}function Iau({schema:e,isOptional:t,isArray:r,description:i}){return pBE(e)?Iau({schema:e.value,isOptional:!0,isArray:r,description:e.description}):_BE(e)?Iau({schema:e.value,isOptional:t,isArray:r,description:e.description}):hBE(e)?Iau({schema:e.value,isOptional:t,isArray:!0,description:e.description}):dBE(e)?{isFile:!0,isOptional:t??!1,isArray:r??!1,description:i??e.description}:{isFile:!1,isOptional:t??!1,isArray:r??!1,description:void 0}}function dBE(e){return e.type==="primitive"&&e.schema.type==="string"&&e.schema.format==="binary"}function pBE(e){return e.type==="optional"}function _BE(e){return e.type==="nullable"}function hBE(e){return e.type==="array"}function iw_(e,t){return t?.[e]?.contentType}var eSc={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",498:"InvalidTokenError",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"},uw_=new Set(Object.values(eSc));var yBE=["200","201","202","204"];function cw_({operationContext:e,responses:t,context:r,responseBreadcrumbs:i,responseStatusCode:n,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let c=vBE({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,s;for(let o of n!=null?[n]:yBE){let l=t[o];l!=null&&(d=!0,s==null&&(s=sw_({operationContext:e,response:l,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace,statusCode:typeof o=="string"?parseInt(o):o})))}if(s==null&&!d&&t.default!=null&&(s=sw_({operationContext:e,response:t.default,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:c};case"streamingJson":case"streamingSse":return{value:s,errors:c};case"bytes":case"file":case"text":case"streamingText":return{value:s,errors:c};default:Ao(s)}return{value:void 0,errors:c}}function sw_({operationContext:e,streamFormat:t,response:r,context:i,responseBreadcrumbs:n,source:a,namespace:u,statusCode:c}){let d=tp(r)?i.resolveResponseReference(r):r;if(d.content!=null&&Object.entries(d.content).find(([b,g])=>{if(g.schema==null)return!1;let O=tp(g.schema)?i.resolveSchemaReference(g.schema):g.schema;return O.type==="string"&&O.format==="binary"}))return i.options.useBytesForBinaryResponse&&t==null?EB.bytes({description:d.description,source:a,statusCode:c}):EB.file({description:d.description,source:a,statusCode:c});let s=tw_(d.content??{},i);if(s!=null&&t!=null)switch(t){case"json":return EB.streamingJson({statusCode:c,description:d.description,responseProperty:hf(e.operation,ad.RESPONSE_PROPERTY),fullExamples:s.examples,schema:s0(s.schema,!1,i,n,a,u),source:a});case"sse":return EB.streamingSse({description:d.description,responseProperty:void 0,fullExamples:s.examples,schema:s0(s.schema,!1,i,n,a,u),source:a,statusCode:c})}let o=Bau({context:i,content:d.content??{}});if(o){if(t!=null)switch(t){case"json":return EB.streamingJson({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:s0(o.schema,!1,i,n,a,u),source:a,statusCode:c});case"sse":return EB.streamingSse({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:s0(o.schema,!1,i,n,a,u),source:a,statusCode:c})}return EB.json({description:d.description,schema:s0(o.schema,!1,i,n,a,u),responseProperty:hf(e.operation,ad.RESPONSE_PROPERTY),fullExamples:o.examples,source:a,statusCode:c})}for(let[l,b]of Object.entries(d.content??{})){let g=Uq.parse(l);if(g!=null){if(g.isOctetStream()||g.isPDF()||g.isAudio()||g.isImage()||g.isVideo()||g.isMultiPartMixed())return EB.file({description:d.description,source:a,statusCode:c});if(g.isPlainText()){let O=b.schema;if(O==null)return EB.text({description:d.description,source:a,statusCode:c});let m=tp(O)?i.resolveSchemaReference(O):O;return m.type==="string"&&m.format==="byte"?EB.file({description:d.description,source:a,statusCode:c}):EB.text({description:d.description,source:a,statusCode:c})}}}}function vBE({responses:e,context:t,source:r,namespace:i}){let n={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let c=parseInt(a);if(c<400||c>600)continue;let d=tp(u)?t.resolveResponseReference(u):u,s=rw_(d.content??{},t),o=eSc[c];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}n[c]={statusCode:c,nameOverride:void 0,generatedName:o,description:d.description,schema:s0(s?.schema??{},!1,t,[o,"Body"],r,i),fullExamples:s?.examples,source:r}}return n}function Qmi({operationContext:e,context:t,responseStatusCode:r,suffix:i,streamFormat:n,source:a}){let{document:u,operation:c,path:d,method:s,baseBreadcrumbs:o}=e,l=hf(c,ad.IDEMPOTENT),b=hf(c,[ad.REQUEST_NAME_V1,ad.REQUEST_NAME_V2]),g=[...o,"Request"],O=Tau({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:g,path:d,httpMethod:s,source:a}),m=/{([^}]+)}/g,D=[...d.matchAll(m)].map(I=>I[1]).filter(I=>!O.pathParameters.some(N=>N.name===I));if(D.length>0)for(let I of D)O.pathParameters.push({name:I??"",variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:Nl.primitive({schema:bp.string({default:void 0,example:void 0,format:void 0,maxLength:void 0,minLength:void 0,pattern:void 0}),description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0,availability:void 0,title:void 0}),description:void 0});let A=(()=>{if(e.method==="GET")return[void 0];if(!c.requestBody)return[void 0];let I=tp(c.requestBody)?t.resolveRequestBodyReference(c.requestBody):c.requestBody,N=Object.values(I.content).every(Y=>bBE({mediaTypeObject:Y})!=null),U=[];if(N)return U.push(...Object.entries(I.content).map(([Y,J])=>{let X=bor({mediaType:Y,mediaTypeObject:J,description:I.description,document:u,context:new Qnn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:g,source:a,namespace:t.namespace});return lw_({context:t,convertedParameters:O})&&X!=null&&(X.type==="json"||X.type==="formUrlEncoded")&&X.schema.type!=="object"&&c.requestBody!=null?X=bor({mediaType:Y,mediaTypeObject:J,description:I.description,document:u,context:t,requestBreadcrumbs:[...g,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(X=bor({mediaType:Y,mediaTypeObject:J,description:I.description,document:u,context:t,requestBreadcrumbs:[...g],source:a,namespace:t.namespace})),X}).filter(Y=>Y!=null)),U.length===0?[void 0]:U;{let Y=zau({content:I.content,description:I.description,document:u,context:new Qnn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:g,source:a,namespace:t.namespace});return lw_({context:t,convertedParameters:O})&&Y!=null&&(Y.type==="json"||Y.type==="formUrlEncoded")&&Y.schema.type!=="object"&&c.requestBody!=null?Y=zau({content:I.content,description:I.description,document:u,context:t,requestBreadcrumbs:[...g,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(Y=zau({content:I.content,description:I.description,document:u,context:t,requestBreadcrumbs:[...g],source:a,namespace:t.namespace})),[Y]}})(),M=[...o,"Response"],E=cw_({operationContext:e,streamFormat:n,responses:c.responses,context:t,responseBreadcrumbs:M,responseStatusCode:r,source:a}),T=Zj_(c),z=Xj_(e,c,t),$=hf(c,ad.SERVER_NAME_V2);return A.map(I=>({summary:c.summary,internal:hf(c,M$.INTERNAL),idempotent:l,audiences:hf(c,ad.AUDIENCES)??[],operationId:c.operationId!=null&&i!=null?c.operationId+"_"+i:c.operationId,tags:t.resolveTagsToTagIds(c.tags),namespace:t.namespace,sdkName:gBE({operationContext:e,request:I}),pathParameters:O.pathParameters,queryParameters:O.queryParameters,headers:O.headers,requestNameOverride:b??void 0,generatedRequestName:S5(g,t.options.preserveSchemaIds),request:I,response:E.value,errors:E.errors,servers:$!=null?[{name:$,url:void 0,audiences:void 0}]:(c.servers??[]).map(N=>qau(N)),description:c.description,authed:OBE(c,u),availability:T,method:s,path:d,examples:z,pagination:e.pagination,source:a}))}function bBE({mediaTypeObject:e}){return hf(e,ad.SDK_METHOD_NAME)}function gBE({operationContext:e,request:t}){return!t||!t.sdkMethodName?e.sdkMethodName:e.sdkMethodName?{groupName:[...e.sdkMethodName.groupName],methodName:t.sdkMethodName??e.sdkMethodName.methodName}:{groupName:[],methodName:t.sdkMethodName}}function OBE(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function lw_({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function dw_({operationContext:e,context:t,asyncExtension:r,source:i}){let{operation:n,pathItemParameters:a,operationParameters:u}=e,c=r.discriminant.name,d=r.discriminant.value,s=r["response-status-code"],o=fw_({context:t,headerToIgnore:c,parameters:a}),l=fw_({context:t,headerToIgnore:c,parameters:u}),b=Qmi({operationContext:{...e,pathItemParameters:o,operationParameters:l,operation:{...n,responses:Object.fromEntries(Object.entries(n.responses).filter(([O])=>parseInt(O)!==s))}},context:t,streamFormat:void 0,source:i}),g=Qmi({operationContext:{...e,pathItemParameters:o,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:i});return g.forEach(O=>{O.headers.push({name:c,schema:Nl.literal({nameOverride:void 0,generatedName:S5([c],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:mx.string(d),namespace:void 0,groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:i})}),{sync:b,async:g}}function fw_({context:e,headerToIgnore:t,parameters:r}){return r.filter(i=>{let n=tp(i)?e.resolveParameterReference(i):i;return!(n.in==="header"&&n.name===t)})}var tSc="stream";function yw_({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:Qmi({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:[]};case"streamCondition":{let i=pw_({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(i?.schemaReference!=null){let s=zNi(i.schemaReference);s!=null&&t.excludeSchema(s)}let n=_w_({operation:e.operation,response:r.responseStream}),a=Qmi({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+tSc}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:i?.requestBody,responses:n},baseBreadcrumbs:[...e.baseBreadcrumbs,tSc]},context:t,streamFormat:r.format,suffix:tSc,source:t.source});a.forEach(s=>{s.examples=s.examples.filter(o=>hw_(o,t)!==!1)});let u=pw_({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),c=_w_({operation:e.operation,response:r.response}),d=Qmi({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:c}},context:t,source:t.source});return d.forEach(s=>{s.examples=s.examples.filter(o=>hw_(o,t)!==!0)}),{streaming:a,nonStreaming:d}}default:Ao(r)}}function pw_({context:e,operation:t,streamingExtension:r,isStreaming:i}){if(t.requestBody==null)return;let n=tp(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=Bau({content:n.content,context:e});if(a==null)return;let u=tp(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let c=u.properties?.[r.streamConditionProperty];c!=null&&tp(c)&&(c=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":i,...c??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[Uq.APPLICATION_JSON]:{schema:d}}},schemaReference:tp(a.schema)?a.schema:void 0}}function _w_({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[Uq.APPLICATION_JSON]:{schema:t}}}}}function hw_(e,t){return e._visit({unknown:r=>{let i=i7.serialization.ExampleEndpointCallSchema.parse(r);if(i.ok&&i.value.response!=null)return i.value.response.stream!=null},full:()=>{},_other:()=>{}})}function vw_({context:e,operationContext:t,source:r}){let{document:i,operation:n,path:a,method:u,baseBreadcrumbs:c,sdkMethodName:d}=t,s=[...c,"Payload"],o=Tau({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:u,source:r});if(n.requestBody==null)return e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Missing a request body`),[];let l=n.operationId;if(l==null)return e.logger.error(`Skipping webhook ${a} because no operation id present`),[];if(u!=="POST"&&u!=="GET")return e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Not POST or GET`),[];let b=tp(n.requestBody)?e.resolveRequestBodyReference(n.requestBody):n.requestBody;return Object.entries(b.content).map(([g,O])=>bor({mediaType:g,mediaTypeObject:O,description:b.description,document:i,context:e,requestBreadcrumbs:[...c,"Payload"],source:r,namespace:e.namespace})).filter(g=>g!=null).map(g=>{if(g==null||g.type!=="json"&&g.type!=="formUrlEncoded"){e.logger.error(`Skipping webhook ${a} because non-json and non-formUrlEncoded request body`);return}return{summary:n.summary,audiences:hf(n,ad.AUDIENCES)??[],sdkName:d,namespace:e.namespace,method:u,operationId:l,tags:e.resolveTagsToTagIds(n.tags),headers:o.headers,generatedPayloadName:S5(s,e.options.preserveSchemaIds),payload:g.schema,description:n.description,examples:mBE(g.fullExamples),source:r}}).filter(g=>g!=null)}function mBE(e){if(e==null)return[];let t=[];for(let r of e){let i=RNi(r.value);i!=null&&t.push({description:r.description,name:r.name,payload:i})}return t}function rSc({context:e,pathItemContext:t,operation:r,convertToWebhook:i}){let n=hf(r,ad.IGNORE);if(n!=null&&n){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=PBE(r,e),u=Wj_(e.document,r),c={...t,sdkMethodName:a,baseBreadcrumbs:jBE({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path,shouldUseIdiomaticRequestNames:e.options.shouldUseIdiomaticRequestNames}),operation:r,operationParameters:r.parameters??[],pagination:u};if(i)return{type:"webhook",value:vw_({context:e,operationContext:c,source:e.source})};let d=Uj_(r);if(d!=null){let l=yw_({context:e,operationContext:c,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let s=Fj_(r);if(s!=null){let l=dw_({context:e,operationContext:c,asyncExtension:s,source:e.source});return{type:"async",async:l.async,sync:l.sync}}return{type:"http",value:Qmi({context:e,operationContext:c,streamFormat:void 0,source:e.source})}}function PBE(e,t){let r=hf(e,ad.SDK_METHOD_NAME),i=hf(e,ad.SDK_GROUP_NAME)??[];if(r!=null){let n=typeof i=="string"?[i]:i;return n=t.resolveGroupName(n),{groupName:n,methodName:r}}}function jBE({sdkMethodName:e,operation:t,httpMethod:r,path:i,shouldUseIdiomaticRequestNames:n}){let a=[];if(e!=null){if(n&&a.push(e.methodName),e.groupName.length>0){let u=e.groupName[e.groupName.length-1];u!=null&&a.push(typeof u=="string"?u:u.name)}n||a.push(e.methodName)}else t.operationId!=null?a.push(t.operationId):a.push(F_(`${r}_${i.split("/").join("_")}`));return a}function bw_(e,t,r,i){let n=[],a=Ow_(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(i.filter.skipEndpoint({method:c.method,path:e})){i.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=wBE({operation:c.operation}),s=rSc({context:i,pathItemContext:{...u,method:c.method},operation:c.operation,convertToWebhook:d});s&&n.push(s)}return n}function gw_(e,t,r,i){let n=[],a=Ow_(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(i.filter.skipEndpoint({method:c.method,path:e})){i.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=rSc({context:i,pathItemContext:{...u,method:c.method},operation:c.operation,convertToWebhook:!0});d&&n.push(d)}return n}function Ow_(e){let t=[];return e.get!=null&&t.push({method:E$.Get,operation:e.get}),e.post!=null&&t.push({method:E$.Post,operation:e.post}),e.put!=null&&t.push({method:E$.Put,operation:e.put}),e.delete!=null&&t.push({method:E$.Delete,operation:e.delete}),e.patch!=null&&t.push({method:E$.Patch,operation:e.patch}),e.head!=null&&t.push({method:E$.Head,operation:e.head}),t}function wBE({operation:e}){return hf(e,[ad.WEBHOOK])??!1}function mw_(e){let t=hf(e,ad.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=hf(e,ad.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function Pw_(e){return hf(e,ad.FERN_BASIC_AUTH)}function iSc(e,t){if(tp(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return SBE(e,t)}function SBE(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=hf(e,M$.BEARER_FORMAT),i=hf(e,ad.FERN_HEADER_AUTH);return AU.header({headerName:e.name,prefix:r!=null?"Bearer":i?.prefix,headerVariableName:i?.name??hf(e,ad.HEADER_VARIABLE_NAME),headerEnvVar:i?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="bearer"){let r=hf(e,ad.FERN_BEARER_TOKEN);return AU.bearer({tokenVariableName:r?.name??hf(e,ad.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="basic"){let r=Pw_(e),i=mw_(e);return AU.basic({usernameVariableName:r?.username?.name??i.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??i.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return AU.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return AU.oauth({scopesEnum:DBE(e,t)})}}function DBE(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let i=INi({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([a,u])=>[a,{description:u}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsNullable:!1,namespace:void 0,groupName:void 0,context:void 0,source:t,inline:void 0}),n=DA(i);if(n.type==="enum")return n}}function jw_(e){return hf(e,ad.BASE_PATH)}var EBE=ou.record(ou.string(),ou.object({summary:ou.string().optional(),description:ou.string().optional()}));function ww_({document:e,context:t}){return z5a(e,ad.GROUPS,EBE,t.logger)}function Sw_({context:e,document:t}){return hf(t,ad.FERN_VERSION)??void 0}function Dw_(e){let t=hf(e,ad.FERN_GLOBAL_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?x5a({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function Ew_(e){let t=hf(e,ad.FERN_IDEMPOTENCY_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?x5a({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function Mw_(e,t){let r=hf(e,ad.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([i,n])=>{if(n.type==="string")return[i,{nameOverride:void 0,generatedName:S5([i],t),title:n.title,schema:Ww.string({default:mKn(n),pattern:n.pattern,format:n.format,minLength:n.minLength,maxLength:n.maxLength}),description:n.description,availability:void 0,namespace:void 0,groupName:void 0}];throw new Error(`Variable ${i} has unsupported schema ${JSON.stringify(n)}`)}))}var MBE="webhooks";function Aw_(e){return hf(e,MBE)??{}}var xau=class extends DKn{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discriminatedUnionReferences={};discriminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u})}getDummy(){return new Qnn({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,i){let n=this.discriminatedUnionReferences[t.$ref];n!=null?(n.discriminants.add(r),n.numReferences+=i):this.discriminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:i}}getReferencesFromDiscriminatedUnion(t){return this.discriminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,i){let n=this.discriminatedUnionMetadata[t.$ref];n!=null?n.discriminants.set(r,i):this.discriminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,i]])}}getDiscriminatedUnionMetadata(t){return this.discriminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function qw_(e){return hf(e,ad.RESOLUTIONS)}function Tw_({openapi:e}){let t=qw_(e);if(t==null)return e;let r={};for(let i of t){let n=`#/components/schemas/${i.name}`;for(let a of i.resolutions)e=ABE({openapi:e,schemaReference:a,schemaName:i.name}),e=Cw_({openapi:e,replaceReference:a,schemaReference:n,replacedReferences:r}),r={...r,...Object.fromEntries(i.resolutions.map(u=>[n,u]))}}return e}function ABE({openapi:e,schemaReference:t,schemaName:r}){let i=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),n=e;for(let a of i){let u=n[a];if(u==null)return e;n=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=n,e}function Cw_({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:i}){let n=Object.keys(i).filter(d=>t.startsWith(d)).sort((d,s)=>s.length-d.length)[0];if(n!=null){let d=i[n];if(d!=null){let s=r.replace(n,d);return Cw_({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replaceAll("~1","/")),u=e;for(let d of a.slice(0,-1)){let s=u[d];if(s==null)return e;u=s}let c=a[a.length-1];return c==null||(u[c]={$ref:r}),e}function Iw_({openApi:e,taskContext:t,options:r,source:i,namespace:n}){e=Tw_({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([I,N])=>iSc(N,i)==null?[]:[I,iSc(N,i)])),u=new Set(...Object.entries(a).map(([I,N])=>N.type==="basic"||N.type==="bearer"?"Authorization":N.type==="header"?N.headerName:null)),c=Mw_(e,r.preserveSchemaIds),d=Dw_(e),s=Ew_(e),o=r.audiences??[],l=[],b=[],g=new xau({document:e,taskContext:t,authHeaders:u,options:r,source:i,namespace:n});g.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([I,N])=>{if(N==null)return;t.logger.debug(`Converting path ${I}`);let U=bw_(I,N,e,g);for(let Y of U){let J=Bw_({operation:Y});if(!(o.length>0&&!o.some(X=>J.includes(X))))switch(Y.type){case"async":l.push(...Y.sync),l.push(...Y.async);break;case"http":l.push(...Y.value);break;case"streaming":l.push(...Y.streaming),Y.nonStreaming&&l.push(...Y.nonStreaming);break;case"webhook":b.push(...Y.value);break;default:Ao(Y)}}}),Object.entries(Aw_(e)).forEach(([I,N])=>{if(N==null)return;t.logger.debug(`Converting path ${I}`);let U=gw_(I,N,e,g);for(let Y of U){let J=Bw_({operation:Y});o.length>0&&!o.some(X=>J.includes(X))||b.push(...Y.value)}});let O=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([I,N])=>{let U=hf(N,ad.SDK_NAMESPACE);if(!tp(N)){let Y=hf(N,ad.IGNORE);if(Y!=null&&Y)return[];if(uw_.has(I))return[I,s0({...N,"x-fern-type-name":`${I}Body`},!1,g,[I],i,U??n)]}return[I,s0(N,!1,g,[I],i,U??n)]}).filter(I=>I.length>0)),m=qBE(O,g,i),P=TBE(m,g),D={};for(let[I,N]of Object.entries(P)){let U=DA(N);g.isSchemaExcluded(I)||(D[I]=U,t.logger.debug(`Converted schema ${I}`))}let A=new NNi(P,g.nonRequestReferencedSchemas,g),M=b.map(I=>{let U=I.examples;if(!r.disableExamples&&U.length===0){let Y=A.buildExample({schema:I.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});Y!=null&&(U=[{name:void 0,description:void 0,payload:Y}])}return{...I,payload:DA(I.payload),examples:U}}),E=new wau(P,g,d),T=l.map(I=>{let N=I.examples,U=N;if(!r.disableExamples&&(N.length===0||N.every(N5a))){let X=E.buildEndpointExample(I);X.length>0&&(U=[...X,...N.filter(oe=>!N5a(oe))])}let Y=I.request,J=I.response;return{...I,request:Y?.type==="json"||Y?.type==="formUrlEncoded"?{...Y,schema:DA(Y.schema)}:Y,response:J?.type==="json"?{...J,schema:DA(J.schema)}:J,queryParameters:I.queryParameters.map(X=>({description:X.description,name:X.name,schema:DA(X.schema),parameterNameOverride:X.parameterNameOverride,availability:X.availability,source:X.source})),pathParameters:I.pathParameters.map(X=>({description:X.description,name:X.name,schema:DA(X.schema),parameterNameOverride:X.parameterNameOverride,variableReference:X.variableReference,availability:X.availability,source:X.source})),headers:I.headers.map(X=>({description:X.description,name:X.name,schema:DA(X.schema),parameterNameOverride:X.parameterNameOverride,env:X.env,availability:X.availability,source:X.source})),examples:U,errors:Dd(I.errors,X=>{let oe=X.fullExamples?.map(pe=>{let de=RNi(pe.value);if(de!=null)return{name:pe.name,description:pe.description,example:de}}).filter(bv);if(oe?.length===0){let pe=A.buildExample({schema:X.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});pe!=null&&oe.push({name:void 0,description:void 0,example:pe})}return{generatedName:X.generatedName,nameOverride:X.nameOverride,schema:DA(X.schema),description:X.description,source:X.source,examples:oe}})}}),z=ww_({document:e,context:g});return{apiVersion:Sw_({context:g,document:e}),basePath:jw_(e),title:e.info.title??"",description:e.info.description,groups:Object.fromEntries(Object.entries(z??{}).map(([I,N])=>[I,{summary:N.summary??void 0,description:N.description??void 0}])),servers:(e.servers??[]).map(I=>qau(I)),websocketServers:[],tags:{tagsById:Object.fromEntries((e.tags??[]).map(I=>[I.name,{id:I.name,description:I.description}])),orderedTagIds:e.tags?.map(I=>I.name)},endpoints:T,webhooks:M,channels:{},groupedSchemas:wKn(n,D),securitySchemes:a,hasEndpointsMarkedInternal:T.some(I=>I.internal),nonRequestReferencedSchemas:g.getReferencedSchemas(),variables:c,globalHeaders:d,idempotencyHeaders:s}}function qBE(e,t,r){let i={};for(let[n,a]of Object.entries(e)){if(a.type!=="object"){i[n]=a;continue}let u={$ref:`#/components/schemas/${n}`},c=t.getReferencesFromDiscriminatedUnion(u);if(c==null){i[n]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!c.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!c.discriminants.has(o.propertyKey)),source:r};i[n]=d;let s=zw_({schema:a,schemas:e});for(let o of[...new Set(s)]){let l=i[o]??e[o];l==null||l.type!=="object"||(i[o]={...l,type:"object",properties:l.properties.filter(b=>!c.discriminants.has(b.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(b=>!c.discriminants.has(b.propertyKey))})}}return i}function TBE(e,t){let r={};for(let[i,n]of Object.entries(e)){if(n.type!=="object"){r[i]=n;continue}let a={$ref:`#/components/schemas/${i}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[i]=n;continue}let c=[];for(let s of n.properties)if(u.discriminants.has(s.key)){let o=u.discriminants.get(s.key);o!=null&&c.push({...s,schema:Nl.literal({nameOverride:void 0,generatedName:S5([n.generatedName,o],t.options.preserveSchemaIds),title:void 0,value:mx.string(o),namespace:void 0,groupName:void 0,description:void 0,availability:n.availability})})}else c.push(s);let d={...n,type:"object",properties:c};r[i]=d}return r}function zw_({schema:e,schemas:t}){let r=[];for(let i of e.allOf){r.push(i.schema);let n=t[i.schema];n!=null&&n.type==="object"&&r.push(...zw_({schema:n,schemas:t}))}return r}function Rau(e){return[...new Set(e)]}function Bw_({operation:e}){let t=[];switch(e.type){case"async":t=Rau(e.async.flatMap(r=>r.audiences));break;case"http":t=Rau(e.value.flatMap(r=>r.audiences));break;case"streaming":t=Rau(e.streaming.flatMap(r=>r.audiences));break;case"webhook":t=Rau(e.value.flatMap(r=>r.audiences));break;default:Ao(e)}return t}function Jnn({context:e,documents:t,options:r}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],websocketServers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channels:{},groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let n of t){let a=n.source!=null?n.source:RK.openapi({file:"<memory>"});switch(n.type){case"openapi":{let u=Iw_({taskContext:e,openApi:n.value,options:HQt({options:n.settings,overrides:r}),source:a,namespace:n.namespace});i=BBE(i,u);break}case"asyncapi":{let u=Nj_({document:n.value,taskContext:e,options:HQt({options:n.settings,overrides:r}),source:a,asyncApiOptions:CBE({options:n.settings}),namespace:n.namespace});u.servers!=null&&(i.websocketServers=[...i.websocketServers,...u.servers.map(c=>({...c,audiences:void 0,description:void 0}))]),u.channels!=null&&(i.channels={...i.channels,...u.channels}),u.groupedSchemas!=null&&(i.groupedSchemas=xw_(i.groupedSchemas,u.groupedSchemas)),u.basePath!=null&&(i.basePath=u.basePath);break}default:Ao(n)}}return i}function CBE({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??aj_.naming}}function BBE(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],websocketServers:[...e.websocketServers,...t.websocketServers],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],channels:{...e.channels,...t.channels},groupedSchemas:xw_(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 xw_(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,i]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...i}:e.namespacedSchemas[r]=i;return e}var uB_=ci(Bcu(),1),Icu={config:new uB_.Config({apis:{},styleguide:{plugins:[U1c],rules:{struct:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};function jYn(e){if(e.settings==null&&e.raw?.api?.auth==null)return;let t={detectGlobalHeaders:!0};return e.settings?.unions==="v1"&&(t.discriminatedUnionV2=!0),e.raw?.api?.auth!=null&&(t.auth=e.raw?.api?.auth),t}function $9a(e){return e.swagger!=null}function yqc(e){return e.openapi!=null}function G9a({options:e,overrides:t}={}){return{...HQt({options:e,overrides:t}),...j5a({options:e,overrides:t})}}function d3i(e,t={}){return{...Object.fromEntries(sF(e.namedDefinitionFiles).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...sF(e.importedDefinitions).reduce((r,[i,n])=>({...r,...Sza(d3i(n.definition,{defaultURL:n.url}),(a,u)=>X3(i,Dy.of(u)))}),{})}}function Q9a(e,t={}){return{...Object.fromEntries(sF(e.packageMarkers).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...sF(e.importedDefinitions).reduce((r,[i,n])=>({...r,...Sza(Q9a(n.definition,{defaultURL:n.url}),(a,u)=>X3(i,Dy.of(u)))}),{})}}function fPi(e){return{...Q9a(e),...d3i(e)}}function Que(e,t){return fPi(e.definition)[t]?.contents}function KF(e,t){for(let[r,i]of sF(fPi(e.definition)))t(r,i.contents,{isPackageMarker:iki(r)===CS,defaultUrl:i.defaultUrl})}function Oan(e,t){for(let[r,i]of sF(Q9a(e.definition)))t(r,i.contents)}function NFe({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Bs.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Bs.dim(r)),i.join(`
|
|
1960
|
+
`)),{ok:!0,value:t}):i}}function kru(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var UJn=class e extends Error{errors;constructor(t){super(t.map(kru).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var VJn=class e extends Error{errors;constructor(t){super(t.map(kru).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function GT(e){return{optional:()=>h1c(e),transform:t=>y1c(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new VJn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new UJn(i.errors)}}}function h1c(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>vw.OPTIONAL};return{...t,...GT(t)}}function y1c(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...GT(r)}}function Wm_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:_q(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:_q(t,"bigint")}]},getType:()=>vw.BIGINT};return{...qU(e),...GT(e)}}var nTE=/^([+-]?\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 Hm_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:_q(t,"string")}]}:nTE.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:_q(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:_q(t,"Date object")}]},getType:()=>vw.DATE};return{...qU(e),...GT(e)}}function FK(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...qU(r),...GT(r)}}}function eiu(e){let t=new Set(e);return FK(vw.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:_q(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:_q(i,"enum")}]}:{ok:!0,value:i})()}function $m_(e){let t=v1c(e);return{...t,...GT(t)}}function v1c(e){return{parse:(t,r)=>WJn(e).parse(t,r),json:(t,r)=>WJn(e).json(t,r),getType:()=>WJn(e).getType()}}function WJn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function w5a(e){return Object.entries(e)}function S5a(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function PNi(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 D5a(e){return Object.keys(e)}function Gm_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function WQt(e){return{withParsedProperties:t=>b1c(e,t)}}function b1c(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((c,[d,s])=>({...c,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!PNi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:_q(i,"object")}]};let a=new Set(Object.keys(t)),u=S5a(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...GT(r),...WQt(r)}}function Qm_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function jNi(e){return e.isProperty}function tiu(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>jNi(i)?i.rawKey:r),_getParsedProperties:()=>D5a(e),parse:(r,i)=>{let n={},a=[];for(let[u,c]of w5a(e)){let d=jNi(c)?c.rawKey:u,s=jNi(c)?c.valueSchema:c,o={rawKey:d,parsedKey:u,valueSchema:s};n[d]=o,Ym_(s)&&a.push(d)}return Jm_({value:r,requiredKeys:a,getProperty:u=>{let c=n[u];if(c!=null)return{transformedKey:c.parsedKey,transform:d=>c.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of w5a(e)){let c=jNi(u)?u.valueSchema:u;Ym_(c)&&n.push(a)}return Jm_({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return jNi(u)?{transformedKey:u.rawKey,transform:c=>u.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>u.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>vw.OBJECT};return{...qU(t),...GT(t),...WQt(t),...Vnn(t)}}function Jm_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!PNi(e))return{ok:!1,errors:[{path:a,message:_q(e,"object")}]};let u=new Set(t),c=[],d={};for(let[s,o]of Object.entries(e)){let l=r(s);if(l!=null){u.delete(s);let b=l.transform(o);b.ok?d[l.transformedKey]=b.value:(d[s]=o,c.push(...b.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=o;break}}return c.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:d}:{ok:!1,errors:c}}function Vnn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>Km_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>Km_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>vw.OBJECT};return{...r,...GT(r),...WQt(r),...Vnn(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>vw.OBJECT};return{...t,...GT(t),...WQt(t),...Vnn(t)}}}}function Km_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=Gm_(D5a(t),s=>n.has(s)),c=r(S5a(t,u)),d=i(S5a(t,a));return c.ok&&d.ok?{ok:!0,value:{...c.value,...d.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...d.ok?[]:d.errors]}}function Ym_(e){return!aTE(e)}function aTE(e){switch(e.getType()){case vw.ANY:case vw.UNKNOWN:case vw.OPTIONAL:return!0;default:return!1}}function Xm_(e){return tiu(e)}function Zm_(e){let t={...v1c(e),_getRawProperties:()=>WJn(e)._getRawProperties(),_getParsedProperties:()=>WJn(e)._getParsedProperties()};return{...t,...GT(t),...WQt(t),...Vnn(t)}}function riu(e){let t={parse:(r,i)=>km_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>km_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>vw.LIST};return{...qU(t),...GT(t)}}function km_(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:_q(e,"list"),path:[]}]}}function eP_(e){return FK(vw.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:_q(r,`"${e}"`)}]})()}function tP_(e){return FK(vw.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:_q(r,`${e.toString()}`)}]})()}var rP_=FK(vw.ANY,e=>({ok:!0,value:e}));var iP_=FK(vw.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:_q(e,"boolean")}]});var nP_=FK(vw.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:_q(e,"number")}]});var aP_=FK(vw.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:_q(e,"string")}]});var oP_=FK(vw.UNKNOWN,e=>({ok:!0,value:e}));function sP_(e,t){let r={parse:(i,n)=>uP_({value:i,isKeyNumeric:e.getType()===vw.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>uP_({value:i,isKeyNumeric:e.getType()===vw.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>vw.RECORD};return{...qU(r),...GT(r)}}function uP_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return PNi(e)?w5a(e).reduce((a,[u,c])=>{if(c==null)return a;let d=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),l=i(c,s);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let b=[];return d.ok||b.push(...d.errors),o.ok||b.push(...o.errors),l.ok||b.push(...l.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:_q(e,"object")}]}}function cP_(e){let t=riu(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:_q(i,"Set")}]},getType:()=>vw.SET};return{...qU(r),...GT(r)}}function fP_(e){let t={parse:(r,i)=>lP_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>lP_((n,a)=>n.json(r,a),e,i),getType:()=>vw.UNDISCRIMINATED_UNION};return{...qU(t),...GT(t)}}function lP_(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let c of u.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function dP_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function _P_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=eiu(D5a(t)),a={parse:(u,c)=>pP_({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(u,c)=>pP_({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>vw.UNION};return{...qU(a),...GT(a),...WQt(a)}}function pP_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:c=[]}){if(!PNi(e))return{ok:!1,errors:[{path:c,message:_q(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let o=i(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=n(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let b=u(s,l);return b.ok?{ok:!0,value:{[r]:d,...b.value}}:b}var Qm=gt.objectWithoutOptionalProperties({title:gt.string().optional()});var iiu=gt.objectWithoutOptionalProperties({file:gt.string()});var niu=gt.objectWithoutOptionalProperties({file:gt.string()});var aiu=gt.union("type",{openapi:iiu,protobuf:niu}).transform({transform:e=>{switch(e.type){case"openapi":return RK.openapi(e);case"protobuf":return RK.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var zh=gt.objectWithoutOptionalProperties({source:aiu.optional()});var oiu=gt.objectWithoutOptionalProperties({typeName:gt.string()});var uiu=gt.union("type",{protobuf:oiu}).transform({transform:e=>{switch(e.type){case"protobuf":return LJn.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Nue=gt.objectWithoutOptionalProperties({encoding:uiu.optional()});var Of=gt.objectWithoutOptionalProperties({description:gt.string().optional()});var siu=gt.enum_(["GenerallyAvailable","Beta","Deprecated"]);var cy=gt.objectWithoutOptionalProperties({availability:siu.optional()});var dor=gt.number();var EFe=gt.objectWithoutOptionalProperties({statusCode:dor.optional()});var bg=gt.objectWithoutOptionalProperties({nameOverride:gt.string().optional(),generatedName:gt.string()});var UM=gt.objectWithoutOptionalProperties({inline:gt.boolean().optional()});var Ree=gt.string();var Nee=gt.string();var ciu=gt.objectWithoutOptionalProperties({id:Nee}).extend(Of);var liu=gt.string();var fiu=gt.objectWithoutOptionalProperties({usernameVariableName:gt.string().optional(),usernameEnvVar:gt.string().optional(),passwordVariableName:gt.string().optional(),passwordEnvVar:gt.string().optional()});var diu=gt.objectWithoutOptionalProperties({tokenVariableName:gt.string().optional(),tokenEnvVar:gt.string().optional()});var piu=gt.objectWithoutOptionalProperties({headerName:gt.string(),prefix:gt.string().optional(),headerVariableName:gt.string().optional(),headerEnvVar:gt.string().optional()});var _iu=gt.objectWithoutOptionalProperties({queryParameterName:gt.string()});var hiu=gt.objectWithoutOptionalProperties({snake:gt.string().optional(),camel:gt.string().optional(),screamingSnake:gt.string().optional(),pascal:gt.string().optional()});var wNi=gt.objectWithoutOptionalProperties({nameOverride:gt.string().optional(),generatedName:gt.string(),value:gt.string(),casing:hiu.optional()}).extend(Of).extend(cy);var yiu=gt.objectWithoutOptionalProperties({type:gt.stringLiteral("namespace"),name:gt.string()});var viu=gt.undiscriminatedUnion([gt.string(),yiu]);var SNi=gt.list(viu);var Jm=gt.objectWithoutOptionalProperties({groupName:SNi.optional()});var L0=gt.objectWithoutOptionalProperties({namespace:gt.string().optional()});var HJn=gt.objectWithoutOptionalProperties({default:wNi.optional(),values:gt.list(wNi)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm).extend(UM);var biu=gt.objectWithoutOptionalProperties({scopesEnum:HJn.optional()});var giu=gt.union("type",{basic:fiu,bearer:diu,header:piu,query:_iu,oauth:biu}).transform({transform:e=>{switch(e.type){case"basic":return AU.basic(e);case"bearer":return AU.bearer(e);case"header":return AU.header(e);case"query":return AU.query(e);case"oauth":return AU.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var E5a=gt.objectWithoutOptionalProperties({name:gt.string().optional(),url:gt.string(),audiences:gt.list(gt.string()).optional()}).extend(Of);var Oiu=gt.string();var por=gt.objectWithoutOptionalProperties({sdkMethodName:gt.string().optional()});var O1c={};xa(O1c,{FullExample:()=>QT,FullObjectExample:()=>Piu,FullOneOfExample:()=>wiu,KeyValuePair:()=>jiu,LiteralExample:()=>miu,PrimitiveExample:()=>GJn,PropertyKey:()=>$Jn});var $Jn=gt.string();var GJn=gt.union("type",{int:gt.object({value:gt.number()}),int64:gt.object({value:gt.number()}),uint:gt.object({value:gt.number()}),uint64:gt.object({value:gt.number()}),float:gt.object({value:gt.number()}),double:gt.object({value:gt.number()}),string:gt.object({value:gt.string()}),datetime:gt.object({value:gt.string()}),date:gt.object({value:gt.string()}),base64:gt.object({value:gt.string()}),boolean:gt.object({value:gt.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return M_.int(e.value);case"int64":return M_.int64(e.value);case"uint":return M_.uint(e.value);case"uint64":return M_.uint64(e.value);case"float":return M_.float(e.value);case"double":return M_.double(e.value);case"string":return M_.string(e.value);case"datetime":return M_.datetime(e.value);case"date":return M_.date(e.value);case"base64":return M_.base64(e.value);case"boolean":return M_.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var miu=gt.union("type",{boolean:gt.object({value:gt.boolean()}),string:gt.object({value:gt.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return ONi.boolean(e.value);case"string":return ONi.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var QT=gt.union("type",{primitive:gt.object({value:GJn}),object:gt.lazyObject(()=>Piu),array:gt.object({value:gt.list(gt.lazy(()=>QT))}),map:gt.object({value:gt.list(gt.lazyObject(()=>jiu))}),enum:gt.object({value:gt.string()}),literal:gt.object({value:miu}),oneOf:gt.object({value:gt.lazy(()=>wiu)}),unknown:gt.object({value:gt.lazy(()=>QT)})}).transform({transform:e=>{switch(e.type){case"primitive":return rO.primitive(e.value);case"object":return rO.object(e);case"array":return rO.array(e.value);case"map":return rO.map(e.value);case"enum":return rO.enum(e.value);case"literal":return rO.literal(e.value);case"oneOf":return rO.oneOf(e.value);case"unknown":return rO.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Piu=gt.objectWithoutOptionalProperties({properties:gt.record($Jn,gt.lazy(()=>QT))});var jiu=gt.objectWithoutOptionalProperties({key:GJn,value:gt.lazy(()=>QT)});var wiu=gt.union("type",{discriminated:gt.object({value:gt.record($Jn,gt.lazy(()=>QT))}),undiscriminated:gt.object({value:gt.lazy(()=>QT)})}).transform({transform:e=>{switch(e.type){case"discriminated":return mNi.discriminated(e.value);case"undiscriminated":return mNi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var m1c={};xa(m1c,{AllOfPropertyConflict:()=>cKn,ArraySchema:()=>hnu,Availability:()=>siu,BooleanSchema:()=>cnu,BytesResponse:()=>eKn,CasingOverrides:()=>hiu,CommonProperty:()=>jnu,CursorPagination:()=>Giu,CustomCodeSample:()=>Hiu,CustomCodeSampleLanguage:()=>Uiu,CustomCodeSampleSdk:()=>Wiu,CustomPagination:()=>Jiu,DiscriminatedOneOfSchema:()=>mnu,DoubleSchema:()=>unu,Endpoint:()=>Kiu,EndpointExample:()=>nKn,EndpointResponseExample:()=>Liu,EndpointSdkName:()=>_or,EnumSchema:()=>HJn,EnumValue:()=>wNi,ErrorExample:()=>ziu,FernExample:()=>Riu,FileResponse:()=>ZJn,FileSchema:()=>Eiu,FormUrlEncodedRequest:()=>Ciu,FullEndpointExample:()=>$iu,GlobalHeader:()=>fnu,Header:()=>DNi,HeaderExample:()=>iKn,HttpEndpointServer:()=>tKn,HttpError:()=>xiu,HttpMethod:()=>QJn,IdempotencyHeader:()=>dnu,IntSchema:()=>anu,JsonRequest:()=>Tiu,JsonResponse:()=>kJn,LiteralSchema:()=>sKn,LiteralSchemaValue:()=>pnu,LongSchema:()=>onu,MapSchema:()=>ynu,MultipartRequest:()=>XJn,MultipartRequestProperty:()=>qiu,MultipartRequestPropertyEncoding:()=>Aiu,MultipartSchema:()=>Miu,NullableSchema:()=>bnu,ObjectProperty:()=>Onu,ObjectPropertyConflictInfo:()=>lKn,ObjectSchema:()=>_nu,OctetStreamRequest:()=>YJn,OffsetPagination:()=>Qiu,OneOfSchema:()=>gnu,OpenApiIntermediateRepresentation:()=>hP_,OptionalSchema:()=>vnu,Pagination:()=>aKn,PathParameter:()=>JJn,PathParameterExample:()=>Niu,PrimitiveSchema:()=>MNi,PrimitiveSchemaValue:()=>lnu,QueryParameter:()=>KJn,QueryParameterExample:()=>rKn,ReferencedSchema:()=>hor,Request:()=>Biu,Response:()=>Iiu,Schema:()=>um,Schemas:()=>nnu,SdkGroupInfo:()=>Siu,StreamingResponseExample:()=>Fiu,StringSchema:()=>snu,SupportedSdkLanguage:()=>Viu,Tags:()=>Diu,TextResponse:()=>ENi,UnDiscriminatedOneOfSchema:()=>Pnu,Webhook:()=>Yiu,WebhookExampleCall:()=>uKn,WebhookHttpMethod:()=>oKn,WebsocketChannel:()=>inu,WebsocketHandshake:()=>Xiu,WebsocketMessageExample:()=>tnu,WebsocketMessageOrigin:()=>Ziu,WebsocketMessageSchema:()=>kiu,WebsocketServer:()=>enu,WebsocketSessionExample:()=>rnu});var Siu=gt.objectWithoutOptionalProperties({summary:gt.string().optional(),description:gt.string().optional()});var Diu=gt.objectWithoutOptionalProperties({tagsById:gt.record(Nee,ciu),orderedTagIds:gt.list(Nee).optional()});var QJn=gt.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var JJn=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>um),variableReference:gt.string().optional(),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var KJn=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>um),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var DNi=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>um),env:gt.string().optional(),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var _or=gt.objectWithoutOptionalProperties({groupName:SNi,methodName:gt.string()});var YJn=gt.objectWithoutOptionalProperties({contentType:gt.string().optional()}).extend(Of).extend(zh);var Eiu=gt.objectWithoutOptionalProperties({isOptional:gt.boolean(),isArray:gt.boolean()}).extend(Of);var Miu=gt.union("type",{file:Eiu,json:gt.object({value:gt.lazy(()=>um)})}).transform({transform:e=>{switch(e.type){case"file":return Umi.file(e);case"json":return Umi.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Aiu=gt.enum_(["json","form"]);var qiu=gt.objectWithoutOptionalProperties({key:gt.string(),schema:Miu,contentType:gt.string().optional(),exploded:gt.boolean().optional(),encoding:Aiu.optional()}).extend(Of);var XJn=gt.objectWithoutOptionalProperties({name:gt.string().optional(),properties:gt.list(qiu)}).extend(Of).extend(zh);var Tiu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>um),contentType:gt.string().optional(),additionalProperties:gt.boolean()}).extend(Of).extend(zh);var Ciu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>um),contentType:gt.string().optional(),additionalProperties:gt.boolean()}).extend(Of).extend(zh);var Biu=gt.union("type",{octetStream:YJn,multipart:XJn,json:Tiu,formUrlEncoded:Ciu}).transform({transform:e=>{switch(e.type){case"octetStream":return lor.octetStream(e);case"multipart":return lor.multipart(e);case"json":return lor.json(e);case"formUrlEncoded":return lor.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var ZJn=gt.objectWithoutOptionalProperties({}).extend(Of).extend(zh).extend(EFe);var kJn=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>um),responseProperty:gt.string().optional()}).extend(Of).extend(zh).extend(EFe);var ENi=gt.objectWithoutOptionalProperties({}).extend(Of).extend(zh).extend(EFe);var eKn=gt.objectWithoutOptionalProperties({}).extend(Of).extend(zh).extend(EFe);var Iiu=gt.union("type",{file:ZJn,json:kJn,text:ENi,bytes:eKn,streamingSse:kJn,streamingText:ENi,streamingJson:kJn}).transform({transform:e=>{switch(e.type){case"file":return NK.file(e);case"json":return NK.json(e);case"text":return NK.text(e);case"bytes":return NK.bytes(e);case"streamingSse":return NK.streamingSse(e);case"streamingText":return NK.streamingText(e);case"streamingJson":return NK.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var ziu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),description:gt.string().optional(),example:gt.lazy(()=>QT)});var xiu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>um).optional(),examples:gt.list(ziu).optional()}).extend(Of).extend(bg).extend(zh);var tKn=gt.objectWithoutOptionalProperties({name:gt.string().optional(),url:gt.string().optional(),audiences:gt.list(gt.string()).optional()});var Riu=gt.unknown();var Niu=gt.objectWithoutOptionalProperties({name:gt.string(),parameterNameOverride:gt.string().optional(),value:gt.lazy(()=>QT)});var rKn=gt.objectWithoutOptionalProperties({name:gt.string(),value:gt.lazy(()=>QT)});var iKn=gt.objectWithoutOptionalProperties({name:gt.string(),value:gt.lazy(()=>QT)});var Fiu=gt.objectWithoutOptionalProperties({sse:gt.boolean(),events:gt.list(gt.lazy(()=>QT))});var Liu=gt.union("type",{withStreaming:Fiu,withoutStreaming:gt.object({value:gt.lazy(()=>QT)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return VQt.withStreaming(e);case"withoutStreaming":return VQt.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Uiu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),language:gt.string(),code:gt.string(),install:gt.string().optional()}).extend(Of);var Viu=gt.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var Wiu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),sdk:Viu,code:gt.string()}).extend(Of);var Hiu=gt.union("type",{language:Uiu,sdk:Wiu}).transform({transform:e=>{switch(e.type){case"language":return Lmi.language(e);case"sdk":return Lmi.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var $iu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),pathParameters:gt.list(Niu).optional(),queryParameters:gt.list(rKn).optional(),headers:gt.list(iKn).optional(),request:gt.lazy(()=>QT).optional(),response:Liu.optional(),codeSamples:gt.list(Hiu)}).extend(Of);var nKn=gt.union("type",{unknown:gt.object({value:Riu}),full:$iu}).transform({transform:e=>{switch(e.type){case"unknown":return UQt.unknown(e.value);case"full":return UQt.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var Giu=gt.objectWithoutOptionalProperties({cursor:gt.string(),nextCursor:gt.property("next_cursor",gt.string()),results:gt.string()});var Qiu=gt.objectWithoutOptionalProperties({offset:gt.string(),results:gt.string(),step:gt.string().optional(),hasNextPage:gt.string().optional()});var Jiu=gt.objectWithoutOptionalProperties({results:gt.string()});var aKn=gt.union("type",{cursor:Giu,offset:Qiu,custom:Jiu}).transform({transform:e=>{switch(e.type){case"cursor":return DFe.cursor(e);case"offset":return DFe.offset(e);case"custom":return DFe.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var Kiu=gt.objectWithoutOptionalProperties({authed:gt.boolean(),internal:gt.boolean().optional(),idempotent:gt.boolean().optional(),method:QJn,audiences:gt.list(gt.string()),path:gt.string(),summary:gt.string().optional(),operationId:gt.string().optional(),tags:gt.list(Nee),pathParameters:gt.list(JJn),queryParameters:gt.list(KJn),headers:gt.list(DNi),sdkName:_or.optional(),generatedRequestName:gt.string(),requestNameOverride:gt.string().optional(),request:Biu.optional(),response:Iiu.optional(),errors:gt.record(dor,xiu),servers:gt.list(tKn),examples:gt.list(nKn),pagination:aKn.optional()}).extend(Of).extend(cy).extend(zh).extend(L0);var oKn=gt.enum_(["GET","POST"]);var uKn=gt.objectWithoutOptionalProperties({name:gt.string().optional(),payload:gt.lazy(()=>QT)}).extend(Of);var Yiu=gt.objectWithoutOptionalProperties({audiences:gt.list(gt.string()),sdkName:_or.optional(),method:oKn,summary:gt.string().optional(),operationId:gt.string(),tags:gt.list(Nee),headers:gt.list(DNi),generatedPayloadName:gt.string(),payload:gt.lazy(()=>um),examples:gt.list(uKn)}).extend(Of).extend(zh).extend(L0);var Xiu=gt.objectWithoutOptionalProperties({queryParameters:gt.list(KJn),headers:gt.list(DNi),pathParameters:gt.list(JJn)});var Ziu=gt.enum_(["client","server"]);var kiu=gt.objectWithoutOptionalProperties({name:gt.string(),origin:Ziu,body:gt.lazy(()=>um)});var enu=gt.objectWithoutOptionalProperties({name:gt.string(),url:gt.string()});var tnu=gt.objectWithoutOptionalProperties({messageType:gt.string(),payload:gt.lazy(()=>QT)}).extend(Of);var rnu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),queryParameters:gt.list(rKn).optional(),headers:gt.list(iKn).optional(),messages:gt.list(tnu)}).extend(Of);var inu=gt.objectWithoutOptionalProperties({audiences:gt.list(gt.string()),path:gt.string(),groupName:SNi,summary:gt.string().optional(),handshake:Xiu,messages:gt.list(kiu),servers:gt.list(enu),examples:gt.list(rnu)}).extend(Of).extend(zh);var nnu=gt.objectWithoutOptionalProperties({rootSchemas:gt.record(Ree,gt.lazy(()=>um)),namespacedSchemas:gt.record(Oiu,gt.record(Ree,gt.lazy(()=>um)))});var anu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),minimum:gt.number().optional(),maximum:gt.number().optional(),exclusiveMinimum:gt.boolean().optional(),exclusiveMaximum:gt.boolean().optional(),multipleOf:gt.number().optional()});var onu=gt.objectWithoutOptionalProperties({default:gt.number().optional()});var unu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),minimum:gt.number().optional(),maximum:gt.number().optional(),exclusiveMinimum:gt.boolean().optional(),exclusiveMaximum:gt.boolean().optional(),multipleOf:gt.number().optional()});var snu=gt.objectWithoutOptionalProperties({default:gt.string().optional(),pattern:gt.string().optional(),format:gt.string().optional(),minLength:gt.number().optional(),maxLength:gt.number().optional()});var cnu=gt.objectWithoutOptionalProperties({default:gt.boolean().optional()});var lnu=gt.union("type",{int:anu,int64:onu,uint:gt.object({}),uint64:gt.object({}),float:gt.object({}),double:unu,string:snu,datetime:gt.object({}),date:gt.object({}),base64:gt.object({}),boolean:cnu}).transform({transform:e=>{switch(e.type){case"int":return Ww.int(e);case"int64":return Ww.int64(e);case"uint":return Ww.uint();case"uint64":return Ww.uint64();case"float":return Ww.float();case"double":return Ww.double(e);case"string":return Ww.string(e);case"datetime":return Ww.datetime();case"date":return Ww.date();case"base64":return Ww.base64();case"boolean":return Ww.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var MNi=gt.objectWithoutOptionalProperties({schema:lnu}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm);var fnu=gt.objectWithoutOptionalProperties({header:gt.string(),name:gt.string().optional(),optional:gt.boolean().optional(),env:gt.string().optional(),schema:gt.lazy(()=>um).optional()});var dnu=gt.objectWithoutOptionalProperties({header:gt.string(),name:gt.string().optional(),env:gt.string().optional(),schema:gt.lazy(()=>um).optional()});var hP_=gt.objectWithoutOptionalProperties({apiVersion:gt.unknown().optional(),title:gt.string().optional(),description:gt.string().optional(),basePath:gt.string().optional(),servers:gt.list(E5a),websocketServers:gt.list(E5a),groups:gt.record(gt.string(),Siu),tags:Diu,hasEndpointsMarkedInternal:gt.boolean(),endpoints:gt.list(Kiu),webhooks:gt.list(Yiu),channels:gt.record(gt.string(),inu),groupedSchemas:nnu,variables:gt.record(gt.string(),MNi),nonRequestReferencedSchemas:gt.set(Ree),securitySchemes:gt.record(liu,giu),globalHeaders:gt.list(fnu).optional(),idempotencyHeaders:gt.list(dnu).optional()});var hor=gt.objectWithoutOptionalProperties({schema:Ree}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm);var pnu=gt.union("type",{boolean:gt.object({value:gt.boolean()}),string:gt.object({value:gt.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return mx.boolean(e.value);case"string":return mx.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var sKn=gt.objectWithoutOptionalProperties({value:pnu}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm);var um=gt.union("type",{primitive:MNi,object:gt.lazyObject(()=>_nu),array:gt.lazyObject(()=>hnu),map:gt.lazyObject(()=>ynu),optional:gt.lazyObject(()=>vnu),enum:HJn,reference:hor,literal:sKn,oneOf:gt.object({value:gt.lazy(()=>gnu)}),nullable:gt.lazyObject(()=>bnu),unknown:bg}).transform({transform:e=>{switch(e.type){case"primitive":return wv.primitive(e);case"object":return wv.object(e);case"array":return wv.array(e);case"map":return wv.map(e);case"optional":return wv.optional(e);case"enum":return wv.enum(e);case"reference":return wv.reference(e);case"literal":return wv.literal(e);case"oneOf":return wv.oneOf(e.value);case"nullable":return wv.nullable(e);case"unknown":return wv.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var cKn=gt.objectWithoutOptionalProperties({propertyKey:gt.string(),allOfSchemaIds:gt.list(Ree),conflictingTypeSignatures:gt.boolean()});var _nu=gt.objectWithoutOptionalProperties({allOf:gt.list(hor),properties:gt.list(gt.lazyObject(()=>Onu)),allOfPropertyConflicts:gt.list(cKn),additionalProperties:gt.boolean()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm).extend(UM);var lKn=gt.objectWithoutOptionalProperties({differentSchema:gt.boolean()});var Onu=gt.objectWithoutOptionalProperties({key:gt.string(),schema:gt.lazy(()=>um),readonly:gt.boolean().optional(),writeonly:gt.boolean().optional(),conflict:gt.record(Ree,lKn),generatedName:gt.string(),nameOverride:gt.string().optional(),audiences:gt.list(gt.string())}).extend(cy);var hnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>um)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var ynu=gt.objectWithoutOptionalProperties({key:MNi,value:gt.lazy(()=>um)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(Qm).extend(UM);var vnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>um)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var bnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>um)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var gnu=gt.union("type",{discriminated:gt.lazyObject(()=>mnu),undiscriminated:gt.lazyObject(()=>Pnu)}).transform({transform:e=>{switch(e.type){case"discriminated":return Vmi.discriminated(e);case"undiscriminated":return Vmi.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var mnu=gt.objectWithoutOptionalProperties({discriminantProperty:gt.string(),commonProperties:gt.list(gt.lazyObject(()=>jnu)),schemas:gt.record(gt.string(),gt.lazy(()=>um))}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(zh).extend(Qm).extend(UM);var jnu=gt.objectWithoutOptionalProperties({key:gt.string(),schema:gt.lazy(()=>um)});var Pnu=gt.objectWithoutOptionalProperties({schemas:gt.list(gt.lazy(()=>um))}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(zh).extend(Qm).extend(UM);var P1c={};xa(P1c,{ArraySchemaWithExample:()=>Gnu,Base64WithExample:()=>Unu,BooleanWithExample:()=>Vnu,CommonPropertyWithExample:()=>tau,DateWithExample:()=>Lnu,DatetimeWithExample:()=>Fnu,DiscriminatedOneOfSchemaWithExample:()=>knu,DoubleWithExample:()=>Rnu,EndpointWithExample:()=>vP_,EnumSchemaWithExample:()=>Hnu,FloatWithExample:()=>xnu,HeaderWithExample:()=>ANi,HttpErrorWithExample:()=>Tnu,Int64WithExample:()=>Bnu,IntWithExample:()=>Cnu,JsonRequestWithExample:()=>Enu,JsonResponseWithExample:()=>dKn,MapSchemaWithExample:()=>Qnu,NamedFullExample:()=>MFe,NullableSchemaWithExample:()=>Knu,ObjectPropertyWithExample:()=>Znu,ObjectSchemaWithExample:()=>Ynu,OneOfSchemaWithExample:()=>Xnu,OptionalSchemaWithExample:()=>Jnu,ParseFormUrlEncodedRequest:()=>Mnu,ParseMultipartRequest:()=>Dnu,ParseOctetStreamRequest:()=>Snu,PathParameterWithExample:()=>wnu,PrimitiveSchemaValueWithExample:()=>Wnu,PrimitiveSchemaWithExample:()=>pKn,QueryParameterWithExample:()=>fKn,RequestWithExample:()=>Anu,ResponseWithExample:()=>qnu,SchemaWithExample:()=>VM,StringSchemaWithExample:()=>Nnu,Uint64WithExample:()=>znu,UintWithExample:()=>Inu,UnDiscriminatedOneOfSchemaWithExample:()=>eau,UnknownSchemaWithExample:()=>$nu,WebhookWithExample:()=>bP_,WebsocketHandshakeWithExample:()=>yP_});var MFe=gt.objectWithoutOptionalProperties({name:gt.string().optional(),value:gt.unknown()}).extend(Of);var fKn=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>VM),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var ANi=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>VM),env:gt.string().optional(),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var yP_=gt.objectWithoutOptionalProperties({queryParameters:gt.list(fKn),headers:gt.list(ANi)});var wnu=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>VM),variableReference:gt.string().optional(),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var Snu=gt.objectWithoutOptionalProperties({}).extend(YJn).extend(por);var Dnu=gt.objectWithoutOptionalProperties({}).extend(XJn).extend(por);var Enu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>VM),contentType:gt.string().optional(),fullExamples:gt.list(MFe).optional(),additionalProperties:gt.boolean()}).extend(Of).extend(zh).extend(por);var Mnu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>VM),contentType:gt.string().optional(),fullExamples:gt.list(MFe).optional(),additionalProperties:gt.boolean()}).extend(Of).extend(zh).extend(por);var Anu=gt.union("type",{octetStream:Snu,multipart:Dnu,json:Enu,formUrlEncoded:Mnu}).transform({transform:e=>{switch(e.type){case"octetStream":return zee.octetStream(e);case"multipart":return zee.multipart(e);case"json":return zee.json(e);case"formUrlEncoded":return zee.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var dKn=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>VM),responseProperty:gt.string().optional(),fullExamples:gt.list(MFe).optional()}).extend(Of).extend(zh).extend(EFe);var qnu=gt.union("type",{file:ZJn,json:dKn,text:ENi,bytes:eKn,streamingSse:dKn,streamingText:ENi,streamingJson:dKn}).transform({transform:e=>{switch(e.type){case"file":return EB.file(e);case"json":return EB.json(e);case"text":return EB.text(e);case"bytes":return EB.bytes(e);case"streamingSse":return EB.streamingSse(e);case"streamingText":return EB.streamingText(e);case"streamingJson":return EB.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Tnu=gt.objectWithoutOptionalProperties({statusCode:dor,schema:gt.lazy(()=>VM),fullExamples:gt.list(MFe).optional()}).extend(Of).extend(bg).extend(zh);var vP_=gt.objectWithoutOptionalProperties({authed:gt.boolean(),internal:gt.boolean().optional(),idempotent:gt.boolean().optional(),method:QJn,audiences:gt.list(gt.string()),path:gt.string(),summary:gt.string().optional(),operationId:gt.string().optional(),tags:gt.list(Nee),pathParameters:gt.list(wnu),queryParameters:gt.list(fKn),headers:gt.list(ANi),sdkName:_or.optional(),generatedRequestName:gt.string(),requestNameOverride:gt.string().optional(),request:Anu.optional(),response:qnu.optional(),errors:gt.record(dor,Tnu),servers:gt.list(tKn),examples:gt.list(nKn),pagination:aKn.optional()}).extend(Of).extend(cy).extend(zh).extend(L0);var bP_=gt.objectWithoutOptionalProperties({audiences:gt.list(gt.string()),sdkName:_or.optional(),method:oKn,summary:gt.string().optional(),operationId:gt.string(),tags:gt.list(Nee),headers:gt.list(ANi),generatedPayloadName:gt.string(),payload:gt.lazy(()=>VM),examples:gt.list(uKn)}).extend(Of).extend(zh).extend(L0);var Cnu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),minimum:gt.number().optional(),maximum:gt.number().optional(),exclusiveMinimum:gt.boolean().optional(),exclusiveMaximum:gt.boolean().optional(),multipleOf:gt.number().optional(),example:gt.number().optional()});var Bnu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),example:gt.number().optional()});var Inu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),example:gt.number().optional()});var znu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),example:gt.number().optional()});var xnu=gt.objectWithoutOptionalProperties({example:gt.number().optional()});var Rnu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),minimum:gt.number().optional(),maximum:gt.number().optional(),exclusiveMinimum:gt.boolean().optional(),exclusiveMaximum:gt.boolean().optional(),multipleOf:gt.number().optional(),example:gt.number().optional()});var Nnu=gt.objectWithoutOptionalProperties({default:gt.string().optional(),pattern:gt.string().optional(),format:gt.string().optional(),minLength:gt.number().optional(),maxLength:gt.number().optional(),example:gt.string().optional()});var Fnu=gt.objectWithoutOptionalProperties({example:gt.string().optional()});var Lnu=gt.objectWithoutOptionalProperties({example:gt.string().optional()});var Unu=gt.objectWithoutOptionalProperties({example:gt.string().optional()});var Vnu=gt.objectWithoutOptionalProperties({default:gt.boolean().optional(),example:gt.boolean().optional()});var Wnu=gt.union("type",{int:Cnu,int64:Bnu,uint:Inu,uint64:znu,float:xnu,double:Rnu,string:Nnu,datetime:Fnu,date:Lnu,base64:Unu,boolean:Vnu}).transform({transform:e=>{switch(e.type){case"int":return bp.int(e);case"int64":return bp.int64(e);case"uint":return bp.uint(e);case"uint64":return bp.uint64(e);case"float":return bp.float(e);case"double":return bp.double(e);case"string":return bp.string(e);case"datetime":return bp.datetime(e);case"date":return bp.date(e);case"base64":return bp.base64(e);case"boolean":return bp.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var pKn=gt.objectWithoutOptionalProperties({schema:Wnu}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm);var Hnu=gt.objectWithoutOptionalProperties({default:wNi.optional(),values:gt.list(wNi),example:gt.string().optional()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm).extend(UM);var $nu=gt.objectWithoutOptionalProperties({example:gt.unknown()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm);var VM=gt.union("type",{primitive:pKn,object:gt.lazyObject(()=>Ynu),array:gt.lazyObject(()=>Gnu),map:gt.lazyObject(()=>Qnu),optional:gt.lazyObject(()=>Jnu),enum:Hnu,reference:hor,literal:sKn,oneOf:gt.object({value:gt.lazy(()=>Xnu)}),nullable:gt.lazyObject(()=>Knu),unknown:$nu}).transform({transform:e=>{switch(e.type){case"primitive":return Nl.primitive(e);case"object":return Nl.object(e);case"array":return Nl.array(e);case"map":return Nl.map(e);case"optional":return Nl.optional(e);case"enum":return Nl.enum(e);case"reference":return Nl.reference(e);case"literal":return Nl.literal(e);case"oneOf":return Nl.oneOf(e.value);case"nullable":return Nl.nullable(e);case"unknown":return Nl.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var Gnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>VM),example:gt.list(gt.unknown()).optional()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var Qnu=gt.objectWithoutOptionalProperties({key:pKn,value:gt.lazy(()=>VM),example:gt.unknown().optional()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(Qm).extend(UM);var Jnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>VM)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var Knu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>VM)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var Ynu=gt.objectWithoutOptionalProperties({allOf:gt.list(hor),properties:gt.list(gt.lazyObject(()=>Znu)),allOfPropertyConflicts:gt.list(cKn),fullExamples:gt.list(MFe).optional(),additionalProperties:gt.boolean()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm).extend(UM);var Znu=gt.objectWithoutOptionalProperties({key:gt.string(),schema:gt.lazy(()=>VM),readonly:gt.boolean().optional(),writeonly:gt.boolean().optional(),audiences:gt.list(gt.string()),conflict:gt.record(Ree,lKn),nameOverride:gt.string().optional(),generatedName:gt.string()}).extend(cy);var Xnu=gt.union("type",{discriminated:gt.lazyObject(()=>knu),undiscriminated:gt.lazyObject(()=>eau)}).transform({transform:e=>{switch(e.type){case"discriminated":return xee.discriminated(e);case"undiscriminated":return xee.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var knu=gt.objectWithoutOptionalProperties({discriminantProperty:gt.string(),commonProperties:gt.list(gt.lazyObject(()=>tau)),schemas:gt.record(gt.string(),gt.lazy(()=>VM))}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(zh).extend(Qm).extend(UM);var tau=gt.objectWithoutOptionalProperties({key:gt.string(),schema:gt.lazy(()=>VM)});var eau=gt.objectWithoutOptionalProperties({schemas:gt.list(gt.lazy(()=>VM))}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(zh).extend(Qm).extend(UM);var gP_=/^(\d+)/,_Kn=/^[a-zA-Z][a-zA-Z0-9_]*$/,OP_={"<":"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 qNi(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),c=e%10;return c===0?i[u]:`${i[u]}_${t[c]}`}if(e<1e3){let u=Math.floor(e/100),c=e%100;return c===0?`${t[u]}_hundred`:`${t[u]}_hundred_${qNi(c)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${qNi(a)}`}function M5a(e){let t=e.match(gP_);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=qNi(n);return i.length>0?`${a}_${i}`:a}}}function hKn(e){let t=M5a(e),r=OP_[e];return t!=null?eI(F_(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":eI(F_(e)))}function Fue(e,t){return e.type==="primitive"&&t.type==="primitive"?mP_(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?oTE(e.values,t.values):e.type==="array"&&t.type==="array"?Fue(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"?Fue(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?uTE(e.value,t.value):e.type==="object"&&t.type==="object"?sTE(e,t):e.type==="map"&&t.type==="map"?mP_(e.key.schema,t.key.schema)&&Fue(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function mP_(e,t){return e.type===t.type}function oTE(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return Y8(r,i)}function uTE(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,i])=>{let n=t.schemas[r];return n==null?!1:Fue(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:Fue(r,n)}):!1}function sTE(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:Fue(a,n.schema)})}function ER(e){switch(e){case S$.Deprecated:return"deprecated";case S$.Beta:return"pre-release";case S$.GenerallyAvailable:return"generally-available";default:return}}function cTE(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function PP_(e){let t=e?cTE(e):void 0;if(t==null||t.length===0)return xZi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(F_(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(F_(n.name)):r.push(n.name,xZi);break}default:Ao(n.type)}else Ao(n);return r.join("/")}function TNi(e){return Dy.of(`${PP_(e)}.yml`)}function j1c({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?xZi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,PP_(r))}function jP_({sdkName:e,namespaceOverride:t}){return Dy.of(`${j1c({sdkName:e,namespaceOverride:t})}.yml`)}function wP_({location:e,namespaceOverride:t}){return t!=null?X3(Dy.of(t),e):e}function rau(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Ao(e.type)}}function yKn(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:Ao(e)}}function hq(e){return typeof e=="string"?e:e.type}function vKn(e){if(typeof e!="string")return e.docs}function A5a(e){if(typeof e!="string")return e.default}function w1c(e){if(typeof e!="string")return e.validation}var lTE=-2147483648,fTE=2147483647,dTE=-17976931348623157e292,pTE=17976931348623157e292;function iO({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return iau(e);case"array":return E1c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return M1c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return D1c({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return q1c();case"optional":return nau({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return A1c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return PTE({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,T1c(e);case"object":return jTE({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return wTE({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:Ao(e)}}function iau(e){switch(e.schema.type){case"string":return yTE({description:e.description,schema:e.schema});case"int":return vTE({description:e.description,schema:e.schema});case"float":return bTE({description:e.description,schema:e.schema});case"double":return gTE({description:e.description,schema:e.schema});case"boolean":return _TE({description:e.description,schema:e.schema});case"int64":return hTE({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:ER(e.availability)}:{}}}function _TE({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function hTE({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function yTE({description:e,schema:t}){let r="string",i=OTE(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function vTE({description:e,schema:t}){let r="integer",i=DP_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function bTE({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function gTE({description:e,schema:t}){let r="double",i=DP_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function OTE(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=mTE(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function mTE(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 DP_(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=S1c(r,t),i=S1c(i,t),n=S1c(n,t),!(r==null&&i==null&&a==null&&u==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:u,multipleOf:n}}function S1c(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[lTE,fTE]:[dTE,pTE];return e<r||e>i?void 0:e}function D1c({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=STE(n)??e.schema,u=yKn(n),c=DTE(n),d=aau({context:r,fileContainingReference:t,declarationFile:TNi(u),type:a}),s=n.type==="nullable"?`optional<${d}>`:d;return e.description==null&&c==null?s:{type:n.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function E1c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=iO({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=`list<${hq(u)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{},type:c}}function M1c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=iau(e.key),c=iO({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),d=e.encoding!=null?rau(e.encoding):void 0,s=`map<${hq(u)}, ${hq(c)}>`;if(e.description==null&&d==null&&e.title==null)return s;let o={type:s};return e.description!=null&&(o.docs=e.description),e.encoding!=null&&(o.encoding=d),e.availability!=null&&(o.availability=ER(e.availability)),o}function A1c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.respectNullableSchemas)return nau({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let u=iO({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hq(u),d=vKn(u),s=A5a(u),o=w1c(u),l=c.startsWith("nullable<")?c:`nullable<${c}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return SP_({typeReference:l,itemType:c});let b={type:l};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=ER(e.availability)),SP_({typeReference:b,itemType:c})}function nau({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=iO({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hq(u),d=vKn(u),s=A5a(u),o=w1c(u),l=c.startsWith("optional<")?c:`optional<${c}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return l;let b={type:l};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=ER(e.availability)),b}function q1c(){return"unknown"}function T1c(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Ao(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function PTE({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=q5a(e,n),u=e.nameOverride??e.generatedName;i.builder.addType(r,{name:u,schema:a.schema});let c=aau({type:u,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return c;let d={type:c};return e.description!=null&&(d.docs=e.description),e.default!=null&&(d.default=e.default.value),e.availability!=null&&(d.availability=ER(e.availability)),d}function jTE({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=C1c({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:u.schema});let d=aau({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function wTE({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=B1c({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:u.schema});let d=aau({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{...e.title!=null?{"display-name":e.title}:{},type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function aau({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function STE(e){return wv._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 DTE(e){return wv._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 SP_({typeReference:e,itemType:t}){return t.startsWith("optional<")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var j5;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(j5||(j5={}));function Wmi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Ao(e)}}function MP_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=ATE(e);break;case"array":a=ETE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=MTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=qTE({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=CTE(e.nameOverride,e.generatedName);break;case"optional":a=AP_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=TTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=q5a(e,n);break;case"literal":a=BTE(e,e.nameOverride,e.generatedName);break;case"object":a=C1c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=B1c({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:Ao(e)}return a}function C1c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(j5.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),u=!1,c={},d=new Set;for(let g of e.properties){if(g.readonly&&(u=!0),a&&g.readonly)continue;if(Object.keys(g.conflict).length>0){if(Object.entries(g.conflict).every(([E,T])=>!T.differentSchema))continue;Object.entries(g.conflict).forEach(([E])=>{I1c({property:g.key,schemaId:E,context:t,namespace:i}).forEach(z=>{d.add(z)})})}let O=iO({schema:g.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),m=g.audiences,P=g.nameOverride,D=ER(g.availability),A=RTE(g);c[g.key]=xTE({typeReference:O,audiences:m,name:P,availability:D,propertyAccess:A})}let s=new Set;for(let g of e.allOfPropertyConflicts)g.allOfSchemaIds.forEach(O=>d.add(O)),g.conflictingTypeSignatures&&s.add(g.propertyKey);let o=[];for(let g of e.allOf){let O=qP_({schema:g.schema,context:t,namespace:i});if(O==null||d.has(g.schema)||d.has(O))continue;let m=iO({schema:wv.reference(g),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(hq(m))}for(let g of d){let O=z1c(t,g,i);for(let m of O.properties)c[m.key]==null&&(s.has(m.key)&&(c[m.key]="unknown"),c[m.key]=iO({schema:m.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let m of O.allOf){if(d.has(m.schema))continue;let P=iO({schema:wv.reference(m),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(hq(P))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([g,O])=>zTE(g)?[g,typeof O=="string"?{type:O,name:`_${g}`}:{...O,name:`_${g}`}]:[g,O]))};o.length>0&&(l.extends=o),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=ER(e.availability)),e.source!=null&&(l.source=Wmi(e.source)),l.inline=x1c(e,n);let b=e.nameOverride??e.generatedName;return{name:u&&t.respectReadonlySchemas&&!a?`${b}Read`:b,schema:l}}function I1c({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return I1c({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:u}=z1c(r,t,i),c=a.some(s=>s.key===e),d=[...u.flatMap(s=>I1c({property:e,context:r,schemaId:s.schema,namespace:i}))];if(c||d.length>0)return[t,...d]}return[]}function z1c(e,t,r){let i=e.getSchema(t,r);if(i==null)return{properties:[],allOf:[]};if(i.type==="object")return{properties:i.properties,allOf:i.allOf};if(i.type==="reference")return z1c(e,i.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${i.type}`)}function ETE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:E1c({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function MTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:M1c({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function ATE(e){let t=iau(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function EP_(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function q5a(e,t){let r={enum:e.values.map(a=>{let u=a.nameOverride??a.generatedName,c=a.value;if(u===c&&a.description==null&&(a.casing==null||EP_(a.casing)))return u;let d={value:a.value};if(u!==c&&(d.name=u),a.description!=null&&(d.docs=a.description),a.casing!=null&&!EP_(a.casing)){let s={},o=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,o=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,o=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,o=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,o=!0),o&&(d.casing=s)}return d})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=x1c(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?Wmi(e.source):void 0};for(let a of r.enum){let u=typeof a=="string"?a:a.name??a.value;i.has(u.toLowerCase())||(n.enum.push(a),i.add(u.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function qTE({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:D1c({schema:e,context:t,fileContainingReference:r,namespace:i})}}function TTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:A1c({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:AP_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function AP_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:nau({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function CTE(e,t){return{name:e??t,schema:q1c()}}function BTE(e,t,r){return{name:t??r,schema:T1c(e)}}function B1c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?rau(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=iO({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let d={};for(let[s,o]of Object.entries(e.schemas))d[s]=iO({schema:o,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?ER(e.availability):void 0,union:d,encoding:a,source:e.source!=null?Wmi(e.source):void 0}}}let u=[];for(let c of e.schemas)u.push(iO({schema:c,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:u,encoding:a,source:e.source!=null?Wmi(e.source):void 0,inline:x1c(e,n)}}}var ITE=/^[0-9]/;function zTE(e){return ITE.test(e)}function qP_({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?qP_({context:t,schema:i.schema,namespace:r}):e}function xTE({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function x1c(e,t){return e.inline===!0||t>0?!0:void 0}function RTE(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return i7.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return i7.ObjectPropertyAccess.WriteOnly}}function TP_(e){let t=e.replace(/^x-|^X-/,"");return F_(t)}var CP_="BasicAuthScheme",oau="BearerAuthScheme";function BP_(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:CP_,schema:n}),t||(e.builder.setAuth(CP_),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:oau,schema:n}),t||(e.builder.setAuth(oau),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??TP_(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:oau,schema:n}),t||(e.builder.setAuth(oau),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(Dy.of("__package__.yml"),{name:"OauthScope",schema:q5a(i.scopesEnum,0).schema})}}function yor({header:e,context:t,fileContainingReference:r,namespace:i}){let n=iO({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=hq(n),u=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:F_(u);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let d={type:a};return c!==e.name&&(d.name=c),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=ER(e.availability)),d}function uau({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=iO({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return hq(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:hq(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=ER(e.availability)),a}function cau({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=R1c({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=hq(n.value),u=A5a(n.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return u!=null&&(c.default=u),n.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=ER(e.availability)),NTE(n.value)&&n.value.validation!==void 0&&(c.validation=n.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function R1c({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:Dy.of(CS),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[],u=!1;for(let[c,d]of Object.entries(n.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(u=!0),d.type==="literal"&&d.value.type==="string"&&(_Kn.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:hKn(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),u&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[c,d]=n.value.schemas;if(c!=null&&d!=null&&sau({array:c,primitive:d}))return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&sau({array:c,primitive:d}))return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[c,d]of Object.entries(n.value.schemas))return R1c({schema:d,context:t,fileContainingReference:r,namespace:i})}else if(t.objectQueryParameters)return{value:iO({schema:e,context:t,fileContainingReference:r,declarationFile:Dy.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let n=t.getSchema(e.value.schema,i);if(n==null)return;if(n.type==="array")return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:Dy.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:iO({schema:e,context:t,fileContainingReference:r,declarationFile:Dy.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let n=[],a=!1;for(let[u,c]of Object.entries(e.value.value.schemas))c.type==="primitive"&&c.schema.type==="string"&&(a=!0),c.type==="literal"&&c.value.type==="string"&&(_Kn.test(c.value.value)?n.push(c.value.value):n.push({value:c.value.value,name:hKn(c.value.value)}));if(n.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:n}}),a&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[u,c]=e.value.value.schemas;if(u!=null&&c!=null&&sau({array:u,primitive:c}))return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(u!=null&&c!=null&&sau({array:c,primitive:u}))return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}if(t.objectQueryParameters)return{value:iO({schema:e,context:t,fileContainingReference:r,declarationFile:Dy.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!1};for(let[u,c]of Object.entries(e.value.value.schemas))return R1c({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.objectQueryParameters?{value:iO({schema:e,context:t,fileContainingReference:r,declarationFile:Dy.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:iO({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:iO({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function sau({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function NTE(e){return e.type!=null}function IP_({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"]=FTE(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=LTE({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=CNi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function FTE(e){let t={};return e.forEach(r=>{let i=CNi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function LTE({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=CNi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function CNi(e){switch(e.type){case"primitive":return zP_(e.value);case"object":return xP_(e.properties);case"array":return UTE(e.value);case"map":return VTE(e.value);case"oneOf":return WTE(e.value);case"enum":return e.value;case"literal":return HTE(e.value);case"unknown":return CNi(e.value);default:Ao(e)}}function zP_(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:Ao(e)}}function xP_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,CNi(r)]))}function UTE(e){return e.map(t=>CNi(t))}function VTE(e){return Object.fromEntries(e.map(t=>[zP_(t.key),CNi(t.value)]))}function WTE(e){return e.type==="discriminated"?xP_(e.value):CNi(e.value)}function HTE(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ao(e)}}function Hmi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function lau(e,t){return t??(e?.groupName!=null?Hmi(e.groupName):void 0)}function RP_({channel:e,context:t,declarationFile:r}){let i={path:e.path,url:e.servers[0]?.name,auth:!1};e.audiences!=null&&e.audiences.length>0&&(i.audiences=e.audiences),e.summary!=null&&(i["display-name"]=e.summary),e.description!=null&&(i.docs=e.description);let n=Hmi(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=uau({pathParameter:d,context:t,fileContainingReference:r,namespace:n});Object.keys(a).length>0&&(i["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let s=cau({queryParameter:d,context:t,fileContainingReference:r,namespace:n});s!=null&&(u[d.name]=s)}Object.keys(u).length>0&&(i["query-parameters"]=u);let c={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let s=yor({header:d,context:t,fileContainingReference:r,namespace:n});c[d.name]=s}Object.keys(c).length>0&&(i.headers=c),t.builder.addChannel(r,{channel:i});for(let d of e.messages)t.builder.addChannelMessage(r,{messageId:d.name,message:{origin:d.origin,body:iO({schema:d.body,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}});for(let d of e.examples){let s=IP_({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:s})}}var $mi="Base",$TE="Default";function BNi(e){return Object.entries(e).reduce((t,[r,i])=>(fUn(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function NP_(e){if(e.environmentOverrides!=null){for(let[g,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:g,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 g of e.ir.servers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){r.push(O);continue}t[g.name]=O}let i={},n=[];for(let g of e.ir.endpoints)for(let O of g.servers){if(O.url==null)continue;let m=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){n.push(m);continue}i[O.name]=m}let a={},u=[];for(let g of e.ir.websocketServers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){u.push(O);continue}a[g.name]=O}let c=Object.keys(t).length,d=c>0,s=Object.keys(i).length>0,o=Object.keys(a).length>0;if(!d&&!s&&o&&e.ir.servers.length===0){for(let[g,O]of Object.entries(a))e.builder.addEnvironment({name:g,schema:O});e.builder.setDefaultEnvironment(Object.keys(a)[0]),e.builder.setDefaultUrl($mi);return}if(n.length>0&&e.logger.error(`Skipping endpoint level servers ${n.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),!d){let g=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(g!=null){let m=O?{url:g,audiences:O}:g;t[$TE]=m}}let l=Object.values(t).map(g=>typeof g=="string"?g:g.url),b=r.filter(g=>{let O=typeof g=="string"?g:g.url;return!l.includes(O)});if(b.length>0&&e.logger.error(`Skipping top level servers ${b.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),s)if(c===1){let g=Object.keys(t)[0],O=Object.values(t)[0],m=typeof O=="string"?O:O.url;e.builder.addEnvironment({name:g,schema:{urls:{[$mi]:m,...BNi(i),...BNi(a)}}}),e.builder.setDefaultEnvironment(g),e.builder.setDefaultUrl($mi)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(e.builder.addEnvironment({name:O,schema:{urls:{[$mi]:typeof m=="string"?m:m.url,...BNi(i),...BNi(a)}}}),e.builder.setDefaultEnvironment(O),g=!1):e.builder.addEnvironment({name:O,schema:{urls:{[$mi]:typeof m=="string"?m:m.url,...BNi(i),...BNi(a)}}});e.builder.setDefaultUrl($mi)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(o?e.builder.addEnvironment({name:O,schema:{urls:{[$mi]:typeof m=="string"?m:m.url,...BNi(a)}}}):e.builder.addEnvironment({name:O,schema:m}),e.builder.setDefaultEnvironment(O),g=!1):o?e.builder.addEnvironment({name:O,schema:{urls:{[$mi]:typeof m=="string"?m:m.url,...BNi(a)}}}):e.builder.addEnvironment({name:O,schema:m});o&&e.builder.setDefaultUrl($mi)}}function fau(e){return hq(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var N1c=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},GTE=.75,QTE=new Set("authorization");function FP_(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?yKn(i.schema):void 0,u=a!=null?Hmi(a):void 0,c=Dy.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?hq(iO({schema:i.schema,context:e,fileContainingReference:u?X3(Dy.of(F_(u)),c):c,namespace:u,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(QTE.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let c=t[a.name],d=yor({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:Dy.of(lF),context:e,namespace:void 0});u=new N1c(d),r[a.name]=u}u.increment()}let i=e.ir.endpoints.length*GTE;for(let[n,a]of Object.entries(r)){let u=t[n],c=a.count===e.ir.endpoints.length,d=a.count>=i;u==null&&(c?e.builder.addGlobalHeader({name:n,schema:a.schema}):d&&e.builder.addGlobalHeader({name:n,schema:fau(a.schema)}))}}}function LP_(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?yKn(t.schema):void 0,i=r!=null?Hmi(r):void 0,n=yor({header:{...t,schema:t.schema??wv.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:Ww.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:Dy.of(lF),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:fau(n)})}}function LK(e){switch(e.type){case"primitive":return VP_(e.value);case"object":return WP_(e.properties);case"array":return HP_(e.value);case"map":return KTE(e.value);case"oneOf":return YTE(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return XTE(e.value);case"unknown":return LK(e.value);default:Ao(e)}}function UP_(e){switch(e.type){case"withStreaming":return e.sse?{stream:JTE(e.events)}:{stream:HP_(e.events)};case"withoutStreaming":return{body:LK(e.value)};default:Ao(e)}}function VP_(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}`: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:Ao(e)}}function WP_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,LK(r)]))}function JTE(e){return e.map(t=>({event:"",data:LK(t)}))}function HP_(e){return e.map(t=>LK(t))}function KTE(e){return Object.fromEntries(e.map(t=>[VP_(t.key),LK(t.value)]))}function YTE(e){return e.type==="discriminated"?WP_(e.value):LK(e.value)}function XTE(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ao(e)}}function $P_({endpointExample:e,context:t}){let r={};if(e.type!=="full")return 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"]=ZTE(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=kTE(e.queryParameters));let i=e.headers!=null&&e.headers.length>0,n=t.builder.getGlobalHeaders(),a=Object.keys(n).length>0,u=new Set(e.headers?.map(c=>c.name)??[]);if(i||a){let c=[];if(e.headers!=null)for(let d of e.headers)d.name!==t.builder.getAuthHeaderName()&&c.push(d);for(let[d,s]of Object.entries(n))if(!u.has(d))if(s!=null&&typeof s=="object"&&s.type!=null){let o=SF({type:s.type,_default:void 0,validation:void 0,visitor:{primitive:l=>l.toString(),map:l=>l.toString(),list:l=>l,optional:l=>l,nullable:l=>l,set:l=>l,named:l=>l,literal:l=>{if(l.type==="string")return l.string;if(l.type==="boolean")return l.boolean.toString()},unknown:Ko}});o!=null&&c.push({name:d,value:rO.literal(ONi.string(o))})}else c.push({name:d,value:rO.primitive(M_.string(d))});r.headers=eCE({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=LK(e.request)),e.response!=null&&(r.response=UP_(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(c=>c.type==="language"?{name:c.name??void 0,docs:c.description??void 0,language:c.language,code:c.code,install:c.install??void 0}:{name:c.name??void 0,docs:c.description??void 0,sdk:c.sdk,code:c.code}).filter(bv)),r}function ZTE(e){let t={};return e.forEach(r=>{let i=LK(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function kTE(e){let t={};return e.forEach(r=>{let i=LK(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function eCE({context:e,namedFullExamples:t}){let r={};return t.forEach(i=>{let n=LK(i.value);n!=null&&(r[i.name]=n)}),r}function GP_(e){return E$._visit(e,{get:()=>i7.HttpMethodSchema.Get,post:()=>i7.HttpMethodSchema.Post,put:()=>i7.HttpMethodSchema.Put,patch:()=>i7.HttpMethodSchema.Patch,delete:()=>i7.HttpMethodSchema.Delete,head:()=>i7.HttpMethodSchema.Head,options:()=>{throw new Error("OPTIONS is unsupported")},trace:()=>{throw new Error("TRACE is unsupported")},_other:()=>{throw new Error("Unknown http method is unsupported")}})}function QP_(e){return e==="POST"||e==="PUT"||e==="PATCH"}function JP_({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,u=e.path,c=lau(e.sdkName,e.namespace),d={};for(let P of e.pathParameters)P.parameterNameOverride&&(u=u.replace(P.name,P.parameterNameOverride)),d[P.parameterNameOverride??P.name]=uau({pathParameter:P,context:r,fileContainingReference:t,namespace:c}),a.add(P.name);let s={};for(let P of e.queryParameters){let D=cau({queryParameter:P,context:r,fileContainingReference:t,namespace:c});D!=null&&(s[P.name]=D,a.add(P.name))}let o;if(e.pagination!=null)switch(e.pagination.type){case"cursor":o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":o={type:"custom",results:e.pagination.results};break;default:Ao(e.pagination)}let l={path:u,method:GP_(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?Wmi(e.source):void 0};!iCE({context:r,request:e.request})&&Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let b={},g=r.builder.getGlobalHeaderNames(),O=r.builder.getAuthHeaderName();O!=null&&g.add(O);let m=e.headers.filter(P=>!g.has(P.name));for(let P of m){let D=yor({header:P,context:r,fileContainingReference:t,namespace:c});b[P.name]=D,a.add(typeof D=="string"?P.name:D.name??P.name)}if(e.request!=null){r.setInState(j5.Request);let P=rCE({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(b).length>0?b:void 0,usedNames:a,namespace:c});l.request=P.value,n=[...n,...P.schemaIdsToExclude??[]],r.unsetInState(j5.Request)}else{let P=r.inlinePathParameters&&Object.keys(d).length>0,D=Object.keys(s).length>0,A=Object.keys(b).length>0,M={};(P||D||A)&&(M.name=e.requestNameOverride??e.generatedRequestName),P&&(M["path-parameters"]=d),D&&(M["query-parameters"]=s),A&&(M.headers=b),Object.keys(M).length>0&&(l.request=M)}if(e.response!=null&&e.response._visit({json:P=>{let D=iO({schema:P.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:P.description??void 0,type:hq(D)},P.statusCode!=null&&(l.response["status-code"]=P.statusCode),P.responseProperty!=null&&(l.response.property=P.responseProperty)},streamingJson:P=>{let D=iO({schema:P.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:P.description??void 0,type:hq(D),format:"json"}},streamingSse:P=>{let D=iO({schema:P.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:P.description??void 0,type:hq(D),format:"sse"}},file:P=>{l.response={docs:P.description??void 0,type:"file","status-code":P.statusCode}},bytes:P=>{l.response={docs:P.description??void 0,type:"bytes","status-code":P.statusCode}},streamingText:P=>{l["response-stream"]={docs:P.description??void 0,type:"text"}},text:P=>{l.response={docs:P.description??void 0,type:"text","status-code":P.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let P=r.getDefaultServerName(),D=e.servers[0];D==null?P!=null&&(l.url=P):l.url=D.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=ER(e.availability)),Object.entries(e.errors).forEach(([P,D])=>{let A=D.generatedName,M=Dy.of(CS);r.builder.enableUniqueErrorsPerEndpoint&&(A=`${e.generatedRequestName}${D.generatedName}`,D.schema!=null&&(D.schema.type!=="reference"&&D.schema.type!=="oneOf"?D.schema.generatedName=`${e.generatedRequestName}${D.schema.generatedName}`:D.schema.type==="oneOf"&&(D.schema.value.generatedName=`${e.generatedRequestName}${D.schema.value.generatedName}`)));let E={"status-code":parseInt(P)},T=wP_({location:KP_,namespaceOverride:c});if(D.schema!=null){let I=iO({schema:D.schema,context:r,fileContainingReference:T,declarationFile:T,namespace:c,declarationDepth:0});E.type=hq(I),E.docs=D.description}r.builder.addError(T,{name:A,schema:r.isErrorUnknownSchema(parseInt(P))?{...E,type:"unknown"}:E}),l.errors==null&&(l.errors=[]);let z=r.builder.addImport({file:t,fileToImport:T});l.errors.push(z!=null?`${z}.${A}`:A),E.type!=null&&D.examples?.forEach(I=>{let N={value:LK(I.example),name:I.name,docs:I.description};r.builder.addErrorExample(T,{name:A,example:N})})}),e.examples.length>0&&(l.examples=tCE({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[F1c,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function tCE({endpointExamples:e,context:t}){return e.map(r=>{try{return $P_({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function rCE({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:u,queryParameters:c,nonRequestReferencedSchemas:d,headers:s,usedNames:o,namespace:l}){if(i.type==="json"||i.type==="formUrlEncoded"){let b=i.schema.type==="reference"?i.schema.schema:void 0,g=i.schema.type==="reference"?r.getSchema(i.schema.schema,l):i.schema;if(g?.type!=="object"||b!=null&&d.includes(b)){let A=iO({schema:i.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),M={schemaIdsToExclude:[],value:{body:A}},E=Object.keys(u??{}).length>0,T=Object.keys(c??{}).length>0,z=Object.keys(s??{}).length>0;return E&&(M.value["path-parameters"]=u),T&&(M.value["query-parameters"]=c),z&&(M.value.headers=s),(E||T||z)&&(M.value.name=n??a),i.contentType!=null&&(M.value["content-type"]=i.contentType),i.description!=null&&(M.value.docs=i.description),M}let O=Object.fromEntries(g.properties.filter(A=>A.readonly==null?!0:!(QP_(e.method)&&A.readonly)).map(A=>{let M=iO({schema:A.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:1}),E=A.nameOverride??A.key,T=ER(A.availability);if(!o.has(E)&&A.audiences.length<=0)return o.add(E),A.nameOverride!=null?[A.key,{type:hq(M),docs:vKn(M),name:A.nameOverride,availability:T}]:[A.key,T?{...typeof M=="string"?{type:M}:M,availability:T}:M];let z={type:hq(M),docs:vKn(M)};return o.has(E)&&(z.name=A.generatedName),A.audiences.length>0&&(z.audiences=A.audiences),T!=null&&(z.availability=T),o.add(E),[A.key,z]})),m=g.allOf.map(A=>{let M=iO({schema:wv.reference(A),fileContainingReference:t,context:r,namespace:l,declarationDepth:0});return hq(M)}).filter(A=>A!=="unknown"),P={properties:O};m.length>0&&(P.extends=m),i.additionalProperties&&(P["extra-properties"]=!0);let D={name:n??g.nameOverride??g.generatedName,"path-parameters":u,"query-parameters":c,headers:s,body:P};return i.contentType!=null&&(D["content-type"]=i.contentType),i.description!=null&&(D.docs=i.description),{schemaIdsToExclude:b!=null?[b]:[],value:D}}else{if(i.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":i.contentType??Uq.APPLICATION_OCTET_STREAM,"query-parameters":c,...i.description?{docs:i.description}:{}}};if(i.type==="multipart"){let b=Object.fromEntries(i.properties.map(g=>{if(g.schema.type==="file"){let O=g.schema.isArray?"list<file>":"file";if(O=g.schema.isOptional?`optional<${O}>`:O,g.description!=null||g.contentType!=null){let m={type:O};if(g.description!=null&&(m.docs=g.description),g.contentType!=null){let P=g.contentType.split(",")[0];m["content-type"]=P}return[g.key,m]}return[g.key,O]}else{let O=iO({schema:g.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(g.contentType||g.exploded||g.encoding){let m=typeof O=="string"?{type:O}:O;g.contentType!=null&&(m["content-type"]=g.contentType),g.encoding==="form"?m.style="form":g.encoding==="json"?m.style="json":g.exploded&&(m.style="exploded"),O=m}return[g.key,O]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":u,"query-parameters":c,headers:s,body:{properties:b},"content-type":Uq.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else Ao(i)}}function iCE({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:Ao(t)}}function nCE({location:e,namespaceOverride:t}){return t!=null?{...e,file:X3(Dy.of(t),e.file)}:e}function aCE(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:Dy.of(`${F_(r)}.yml`),endpointId:e.summary!=null?F_(e.summary):F_(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Dy.of(CS),endpointId:F_(e.summary)}:{file:Dy.of(CS),endpointId:F_(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Dy.of(CS),endpointId:i};let n=T5a(r),a=T5a(i);if(Y8(n,a))return{file:Dy.of("__package__.yml"),endpointId:r};let u=sCE({operationId:i,tag:r,path:e.path,method:e.method});if(u!=null)return u;let c=[];for(let d=0;d<n.length;++d){let s=n[d];if(s!=null&&s===a[d])c.push(s);else{let o=F_(r);return{file:Dy.of(`${o}.yml`),endpointId:i,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:Dy.of(F_(c.join("_"))+".yml"),endpointId:F_(a.slice(c.length).join("_")),tag:r}}function C5a(e){let t=e.tags[0];if(e.sdkName!=null){let r=j1c({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Dy.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return nCE({namespaceOverride:e.namespace,location:aCE(e)})}function T5a(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=MNe(t),t}var oCE=new RegExp("[^a-zA-Z0-9{}]+"),uCE=new RegExp("[{}]","g");function sCE({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(oCE).join("_").replaceAll(uCE,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:Dy.of(F_(t)+".yml"),endpointId:F_(e.slice(0,-1*a.length)),tag:t}}function YP_(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:u,file:c,tag:d}=C5a(a),s=c.split(".")[0];s!=null&&t.add(s);let o;if(a.sdkName!=null){let g=e.ir.groups;for(let O of a.sdkName.groupName){let m=typeof O=="string"?O:O.name,P=g[m];if(P==null)break;if(P.summary!=null||P.description!=null){o=g[m];break}}}let l=d==null?void 0:i.tagsById[d];e.setInState(j5.Endpoint),e.setEndpointMethod(a.method);let b=JP_({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(j5.Endpoint),n=[...n,...b.schemaIdsToExclude],e.builder.addEndpoint(c,{name:u,schema:b.value,source:a.source!=null?Wmi(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":o?.summary??l?.id,docs:o?.description??l?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function XP_(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?Hmi(r.groupName):void 0,n=iO({schema:wv.primitive(r),context:e,fileContainingReference:Dy.of(CS),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:hq(n),docs:r.description??void 0}})}}function ZP_(e){for(let t of e.ir.webhooks){let r=fCE({webhook:t,context:e});if(r==null)continue;let i=lau(t.sdkName,t.namespace),n={};for(let u of t.headers)n[u.name]=yor({header:u,context:e,fileContainingReference:r.file,namespace:i});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:n,payload:iO({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:LK(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function cCE({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:X3(Dy.of(t),e.file)}:e}function lCE({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:Dy.of(CS),endpointId:i};let n=T5a(r),a=T5a(i);if(Y8(n,a))return{file:Dy.of("__package__.yml"),endpointId:r};let u=[];for(let c=0;c<n.length;++c){let d=n[c];if(d!=null&&d===a[c])u.push(d);else{let s=F_(r);return{file:Dy.of(`${s}.yml`),endpointId:i,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:Dy.of(F_(u.join("_"))+".yml"),endpointId:F_(a.slice(u.length).join("_")),tag:r}}function fCE({webhook:e,context:t}){return e.sdkName!=null?{file:jP_({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:cCE({namespaceOverride:e.namespace,location:lCE({webhook:e,context:t})})}var dCE=Dy.of(CS);function ej_(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return kP_({namespace:e.namespace,groupName:e.groupName});case"oneOf":return kP_({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return dCE;default:Ao(e)}}function kP_({namespace:e,groupName:t}){return e!=null&&t!=null?TNi([{type:"namespace",name:e},...t]):e!=null?TNi([{type:"namespace",name:e}]):TNi(t)}var F1c="external",KP_=Dy.of(CS);function tj_({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let u=ej_(a),c=MP_({schema:a,context:i,declarationFile:u,namespace:r,declarationDepth:0});if(_zi(c.schema)){let d=hq(c.schema);if(d===(c.name??n)||d===`optional<${c.name??n}>`||d===`optional<nullable<${c.name??n}>>`)continue}i.builder.addType(u,{name:c.name??n,schema:c.schema})}}function rj_(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),NP_(e),FP_(e),LP_(e),BP_(e),XP_(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(F1c);let t=YP_(e),r=t.sdkGroups;e.setInState(j5.Webhook),ZP_(e),e.unsetInState(j5.Webhook),e.setInState(j5.Channel);for(let n of Object.values(e.ir.channels)){let a=TNi(n.groupName);RP_({channel:n,context:e,declarationFile:a})}e.unsetInState(j5.Channel);let i=pCE({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});tj_({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))tj_({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function pCE({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}var B5a=class{context;constructor(t){this.context=t}};var dau=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,c]of Object.entries(i.files)){let d=n!=null?Dy.of(`${n}${Q$t}${u}`):Dy.of(u);t[d]=c}let a=Object.keys(i.directories).sort();for(let u of a){let c=n!=null?`${n}${Q$t}${u}`:u,d=i.directories[u];r(d,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(Q$t))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Dy.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var Wnn=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new dau,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),i!=null&&(u.service["base-path"]=i),n!=null&&(u.service["display-name"]=n),a!=null&&(u.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return jir(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))ij_(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(ij_(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??F_((FNe(r)+"/"+iki(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Dy.of(lF))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=bBo(FNe(O5n.of(`/${t}`)),O5n.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=bBo(FNe(O5n.of(`/${t}`)),O5n.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===Dy.of(lF))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>Y8(c,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=X3(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:X3(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,u])=>[a,{...u,path:X3(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===CS?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 ij_(e){return e?.header!=null}var pau=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;useBytesForBinaryResponse;respectForwardCompatibleEnums;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=u,this.globalHeaderOverrides=a,this.detectGlobalHeaders=i?.detectGlobalHeaders??!0,this.objectQueryParameters=i?.objectQueryParameters??!1,this.respectReadonlySchemas=i?.respectReadonlySchemas??!1,this.respectNullableSchemas=i?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=i?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=i?.inlinePathParameters??!1,this.useBytesForBinaryResponse=i?.useBytesForBinaryResponse??!1,this.respectForwardCompatibleEnums=i?.respectForwardCompatibleEnums??!1,this.referencedSchemaIds=i?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=i?.enableUniqueErrorsPerEndpoint??!1,this.builder=new Wnn(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let d of r.endpoints)for(let[s,o]of Object.entries(d.errors)){let l=parseInt(s),b=c[l];b==null&&o.schema!=null?c[l]=o.schema:b!=null&&o.schema!=null&&Fue(b,o.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.onlyIncludeReferencedSchemas&&this.isInAnyState(j5.Channel,j5.Endpoint,j5.Webhook)}markSchemaAsReferenced(t,r){switch(t.type){case"primitive":return;case"object":this.markObjectSchemaAsReferenced(t,r);return;case"array":this.markSchemaAsReferenced(t.value,r);return;case"map":this.markSchemaAsReferenced(t.value,r);return;case"optional":this.markSchemaAsReferenced(t.value,r);return;case"reference":this.markSchemaIdAsReferenced(t.schema,r);return;case"oneOf":this.markOneofSchemaAsReferenced(t.value,r);return;case"nullable":this.markSchemaAsReferenced(t.value,r);return;case"enum":return;case"literal":return;case"unknown":return;default:Ao(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:Ao(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function L1c(e){let t=new pau(e);return rj_(t)}var _au=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=L1c({taskContext:t,ir:r,options:j5a({overrides:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.args.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.args.objectQueryParameters,useBytesForBinaryResponse:i?.useBytesForBinaryResponse??this.args.useBytesForBinaryResponse,respectForwardCompatibleEnums:i?.respectForwardCompatibleEnums??this.args.respectForwardCompatibleEnums}}),authOverrides:i?.auth!=null?{auth:i.auth}:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:Rd.dump(a.rootApiFile)},namedDefinitionFiles:{...Dd(a.definitionFiles,u=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Rd.dump(u),contents:u})),[Dy.of(CS)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Rd.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var I5a=class extends LQt{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;converter;constructor(t){super(t),this.inlinePathParameters=t.inlinePathParameters,this.objectQueryParameters=t.objectQueryParameters,this.onlyIncludeReferencedSchemas=t.onlyIncludeReferencedSchemas,this.respectReadonlySchemas=t.respectReadonlySchemas,this.respectNullableSchemas=t.respectNullableSchemas,this.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.inlineAllOfSchemas=t.inlineAllOfSchemas,this.converter=new _au(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new Tqe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion})}};var M$={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"};var bKn={of(e){return e}};var nj_={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},U1c={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:nj_,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},ad={SOURCE:bKn.of("source"),SDK_NAMESPACE:bKn.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:bKn.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:bKn.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:bKn.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",IS_DISCRIMINATED:"x-fern-discriminated"};var O7={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!0,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1};function HQt({options:e,overrides:t}){return{disableExamples:t?.disableExamples??O7.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??O7.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??O7.useTitlesAsName,audiences:t?.audiences??e?.audiences??O7.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??O7.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??O7.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??O7.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??O7.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??O7.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??O7.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??O7.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??O7.shouldUseUndiscriminatedUnionsWithLiterals,shouldUseIdiomaticRequestNames:t?.shouldUseIdiomaticRequestNames??e?.shouldUseIdiomaticRequestNames??O7.shouldUseIdiomaticRequestNames,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??O7.objectQueryParameters,filter:t?.filter??e?.filter??O7.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??O7.asyncApiNaming,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??O7.useBytesForBinaryResponse,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0,defaultFormParameterEncoding:t?.defaultFormParameterEncoding??e?.defaultFormParameterEncoding??void 0,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??O7.respectForwardCompatibleEnums,additionalPropertiesDefaultsTo:t?.additionalPropertiesDefaultsTo??e?.additionalPropertiesDefaultsTo??O7.additionalPropertiesDefaultsTo,typeDatesAsStrings:t?.typeDatesAsStrings??e?.typeDatesAsStrings??O7.typeDatesAsStrings,preserveSingleSchemaOneOf:t?.preserveSingleSchemaOneOf??e?.preserveSingleSchemaOneOf??O7.preserveSingleSchemaOneOf,inlineAllOfSchemas:t?.inlineAllOfSchemas??e?.inlineAllOfSchemas??O7.inlineAllOfSchemas}}var aj_={naming:"v1"};function hf(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function z5a(e,t,r,i,n=[]){try{let a=hf(e,t);if(a!=null)return r.parse(a)}catch{let u=MNe(n).join(" -> ");i.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}function Hnn(e){let t=hf(e,"examples");if(t!=null){if(Array.isArray(t))return t;if(typeof t=="object"&&t!==null)return Object.values(t).map(r=>typeof r=="object"&&r!==null&&"value"in r?r.value:r)}return[]}function oj_({schema:e,logger:t}){return hf(e,ad.ENCODING)??void 0}function uj_(e){return hf(e,ad.FERN_ENUM)}function sj_({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let u=hf(i,ad.SDK_NAMESPACE),c=hf(i,ad.SDK_GROUP_NAME),d=hf(i,ad.TYPE_DEFINITION);if(d!=null)return x5a({fernType:d,nameOverride:e,generatedName:t,title:r,description:n,availability:a,namespace:u,groupName:typeof c=="string"?[c]:c})}function x5a({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c}){return SF({type:e,_default:void 0,validation:void 0,visitor:{primitive:d=>{switch(d.v1){case"BASE_64":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.base64({example:void 0})});case"BOOLEAN":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.boolean({default:void 0,example:void 0})});case"DATE":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.date({example:void 0})});case"DATE_TIME":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.datetime({example:void 0})});case"FLOAT":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.float({example:void 0})});case"DOUBLE":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.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 Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.uint({default:void 0,example:void 0})});case"INTEGER":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.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 Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.uint64({default:void 0,example:void 0})});case"LONG":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Ao(d.v1)}},unknown:()=>Nl.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,namespace:u,groupName:c}),map:({keyType:d,valueType:s})=>d?.type==="primitive"&&s!=null?Nl.map({nameOverride:t,generatedName:r,title:i,key:d,value:s,description:n,availability:a,namespace:u,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:d=>d!=null?Nl.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:c,example:void 0,inline:void 0}):void 0,optional:d=>d!=null?Nl.optional({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:c,inline:void 0}):void 0,nullable:d=>d!=null?Nl.nullable({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:c,inline:void 0}):void 0,set:d=>d!=null?Nl.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:c,example:void 0,inline:void 0}):void 0,literal:d=>Nl.literal({nameOverride:t,generatedName:r,title:i,value:d._visit({string:s=>mx.string(s),boolean:s=>mx.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:u,groupName:c}),named:d=>Nl.reference({schema:d,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,source:RK.openapi({file:"<memory>"})})}})}function cj_(e){let t=hf(e,ad.SOURCE);if(t!=null)return t.endsWith(".proto")?RK.protobuf({file:t}):RK.openapi({file:t})}function $nn(e){if(e!=null&&typeof e=="boolean")return e}function tp(e){return e.$ref!=null}function lj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:u,wrapAsNullable:c,context:d,namespace:s,groupName:o,example:l,encoding:b,source:g}){return n===void 0&&(n=d.options.additionalPropertiesDefaultsTo),typeof n=="boolean"||gKn(n,d.options)?hau({nameOverride:e,generatedName:t,title:r,wrapAsNullable:c,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:bp.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:Nl.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:void 0,groupName:void 0}),namespace:s,groupName:o,example:l,encoding:b}):hau({nameOverride:e,generatedName:t,title:r,wrapAsNullable:c,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:bp.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:fj_(s0(n,d.options.optionalAdditionalProperties?c:!1,d,[...i,"Value"],g,s,void 0,void 0,void 0)),namespace:s,groupName:o,example:l,encoding:b})}function fj_(e){switch(e.type){case"array":case"enum":case"map":case"object":e.inline=!0;break;case"literal":case"primitive":case"reference":case"unknown":break;case"nullable":case"optional":e.inline=!0,e.value=fj_(e.value);break;case"oneOf":e.value.inline=!0;break;default:Ao(e)}return e}function hau({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsNullable:a,description:u,availability:c,namespace:d,groupName:s,example:o,encoding:l}){return a?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:i.availability,key:i,value:n,namespace:d,groupName:s,encoding:l,example:o,inline:void 0}),description:u,availability:c,namespace:d,groupName:s,inline:void 0}):Nl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:c,key:i,value:n,namespace:d,groupName:s,encoding:l,example:o,inline:void 0})}function gKn(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!tp(e)&&Object.keys(e).length===0}function dj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:u,wrapAsNullable:c,context:d,namespace:s,groupName:o,example:l,source:b}){let g=n==null?Nl.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:s,groupName:o}):s0(n,!1,d,[...i,"Item"],b,s);return _CE({nameOverride:e,generatedName:t,title:r,namespace:s,groupName:o,itemSchema:g,wrapAsNullable:c,description:a,availability:u,example:l})}function _CE({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsNullable:n,description:a,availability:u,namespace:c,groupName:d,example:s}){return n?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,namespace:c,groupName:d,example:s,inline:void 0}),description:a,availability:u,namespace:c,groupName:d,inline:void 0}):Nl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,namespace:c,groupName:d,example:s,inline:void 0})}function UK(e){switch(hf(e,ad.AVAILABILITY)){case"deprecated":return S$.Deprecated;case"beta":return S$.Beta;case"generally-available":return S$.GenerallyAvailable;default:break}if(!tp(e)&&e.deprecated)return S$.Deprecated}function V1c({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:c,wrapAsNullable:d,discriminator:s,context:o,namespace:l,groupName:b,encoding:g,source:O}){let m=s.propertyName,P=Object.fromEntries(Object.entries(s.mapping??{}).map(([A,M])=>{let E=Gmi({$ref:M},!1,o,[M],g,O,l);return o.markReferencedByDiscriminatedUnion({$ref:M},m,1),[A,E]})),D=Object.entries(n).filter(([A])=>A!==m).map(([A,M])=>{let E=c!=null&&c.includes(A),T=s0(M,!E,o,[...i,A],O,l);return{key:A,schema:T}});return pj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:D,description:a,availability:u,discriminant:m,subtypes:P,namespace:l,groupName:b,source:O})}function W1c({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:c,wrapAsNullable:d,discriminant:s,variants:o,context:l,namespace:b,groupName:g,encoding:O,source:m}){let P=Object.fromEntries(Object.entries(o).map(([A,M])=>{if(tp(M)){let E=Gmi(M,!1,l,[M.$ref],O,m,b);return l.markReferencedByDiscriminatedUnion(M,s,1),[A,E]}else{let E=OKn(M,!1,l,[...i,A],O,m,b,new Set([s]));return[A,E]}})),D=Object.entries(n).filter(([A])=>A!==s).map(([A,M])=>{let E=c!=null&&c.includes(A),T=s0(M,!E,l,[...i,A],m,b);return{key:A,schema:T}});return pj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:D,description:a,availability:u,discriminant:s,subtypes:P,namespace:b,groupName:g,source:m})}function pj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,availability:u,discriminant:c,subtypes:d,namespace:s,groupName:o,source:l}){return i?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.oneOf(xee.discriminated({description:a,availability:u,discriminantProperty:c,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,namespace:s,groupName:o,encoding:void 0,source:l,inline:void 0})),namespace:s,groupName:o,description:a,availability:u,inline:void 0}):Nl.oneOf(xee.discriminated({description:a,availability:u,discriminantProperty:c,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,namespace:s,groupName:o,encoding:void 0,source:l,inline:void 0}))}function _j_(e){if(e.proto!=null)return LJn.protobuf({typeName:e.proto.type})}function INi({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:u,description:c,availability:d,wrapAsNullable:s,namespace:o,groupName:l,context:b,source:g,inline:O}){let m=yCE(n??[]),P=new Set(a),D=Array.from(P).map((M,E)=>{let T=i?.[M],z=m[E],$=_Kn.test(M),I=T?.name??z,N=$?M:hKn(M);return I!=null&&!_Kn.test(I)&&(b?.logger.warn(`Enum name override ${I} is not a valid name. Falling back on ${N}.`),I=void 0),{nameOverride:I,generatedName:N,value:M,description:T?.description,availability:d,casing:{snake:T?.casing?.snake??void 0,pascal:T?.casing?.pascal??void 0,screamingSnake:T?.casing?.screamingSnake??void 0,camel:T?.casing?.camel??void 0}}}),A=u!=null?D.find(M=>M.value===u):void 0;return hCE({wrapAsNullable:s,nameOverride:e,generatedName:t,title:r,values:D,_default:A,description:c,availability:d,namespace:o,groupName:l,source:g,inline:O})}function hCE({wrapAsNullable:e,nameOverride:t,generatedName:r,title:i,values:n,_default:a,description:u,availability:c,namespace:d,groupName:s,source:o,inline:l}){return e?Nl.nullable({nameOverride:t,generatedName:r,title:i,value:Nl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,default:a,availability:c,example:void 0,namespace:d,groupName:s,source:o,inline:l}),description:u,availability:c,namespace:d,groupName:s,inline:l}):Nl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,availability:c,default:a,example:void 0,namespace:d,groupName:s,source:o,inline:l})}function yCE(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function hj_({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:o,availability:l,wrapAsNullable:b,example:g,namespace:O,groupName:m}){return i==="int64"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="uint32"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="uint64"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):w5({nameOverride:e,generatedName:t,title:r,primitive:bp.int({default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m})}function yj_(e){return typeof e=="string"?mx.string(e):typeof e=="boolean"?mx.boolean(e):mx.string(`${e}`)}function vj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,value:n,description:a,availability:u,namespace:c,groupName:d}){return i?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.literal({nameOverride:e,generatedName:t,title:r,value:yj_(n),description:a,availability:u,namespace:c,groupName:d}),description:a,availability:u,namespace:c,groupName:d,inline:void 0}):Nl.literal({nameOverride:e,generatedName:t,title:r,value:yj_(n),description:a,availability:u,namespace:c,groupName:d})}function H1c({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:o,availability:l,wrapAsNullable:b,example:g,namespace:O,groupName:m}){return i==null||i==="double"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.double({default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="float"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.float({example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="int32"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.int({default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="int64"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="uint32"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="uint64"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="time-delta"?w5({nameOverride:e,generatedName:t,title:r,primitive:bp.float({example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):w5({nameOverride:e,generatedName:t,title:r,primitive:bp.float({example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m})}var vCE={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},bCE={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}}},gCE={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}}},OCE={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},mCE={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},PCE={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},jCE={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},wCE={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function yau(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[vCE,bCE,gCE,OCE,mCE,PCE,jCE,wCE],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:c}=a.applyStrategy(t);t=u,r=[...r,...c]}}while(t.join("")!==n.join(""));return r}function S5(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:eI(F_(n))).join("");return/^\d/.test(i)?M5a(i)??i:i}function $1c(e){let t=e.join("_");return F_(t)}function DA(e){switch(e.type){case"object":return wv.object({allOf:e.allOf,properties:e.properties.map(t=>DCE(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:e.inline});case"array":return wv.array({description:e.description,availability:e.availability,value:DA(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return wv.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,source:e.source,inline:e.inline});case"literal":return wv.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"nullable":return wv.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:DA(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return wv.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:DA(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return wv.primitive({description:e.description,availability:e.availability,schema:bj_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return wv.map({description:e.description,availability:e.availability,key:wv.primitive({description:e.key.description,availability:e.key.availability,schema:bj_(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:DA(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return wv.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return wv.oneOf(SCE(e.value));case"unknown":return wv.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Ao(e)}}function SCE(e){switch(e.type){case"discriminated":return Vmi.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:DA(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,DA(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return Vmi.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>DA(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:Ao(e)}}function bj_(e){switch(e.type){case"string":return Ww.string(e);case"base64":return Ww.base64();case"boolean":return Ww.boolean(e);case"date":return Ww.date();case"datetime":return Ww.datetime();case"double":return Ww.double(e);case"float":return Ww.float();case"int":return Ww.int(e);case"int64":return Ww.int64(e);case"uint":return Ww.uint();case"uint64":return Ww.uint64();default:Ao(e)}}function DCE(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:DA(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function vau(e,t){return Fue(DA(e),DA(t))}function gj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:u,wrapAsNullable:c,allOf:d,context:s,propertiesToExclude:o,namespace:l,groupName:b,fullExamples:g,additionalProperties:O,availability:m,source:P}){let D=[...u??[]],A={...n},M=[],E=[];for(let N of d)if(!s.options.inlineAllOfSchemas&&tp(N)){let U=s.resolveSchemaReference(N);if(U.discriminator!=null&&U.discriminator.mapping!=null)continue;if(U.oneOf!=null||U.anyOf!=null){let J=U.oneOf??U.anyOf;if(J!=null){for(let X of J){let oe=tp(X)?s.resolveSchemaReference(X):X,pe=s0(oe,!1,s.DUMMY,i,P,l);pe.type==="object"&&M.push(...pe.properties.map(de=>de.schema.type!=="optional"&&de.schema.type!=="nullable"?{...de,schema:Nl.optional({nameOverride:void 0,generatedName:"",title:void 0,value:de.schema,description:void 0,availability:de.availability,namespace:void 0,groupName:void 0,inline:void 0})}:de))}continue}}let Y=zNi(N);if(Y==null)continue;E.push({schemaId:Y,convertedSchema:G1c(N,[Y],P,s.options.preserveSchemaIds),properties:Oj_({schema:N,context:s,breadcrumbs:i,source:P,namespace:l})}),s.markSchemaAsReferencedByNonRequest(Y)}else if(tp(N)){let U=s.resolveSchemaReference(N),Y=s0(U,!1,s,i,P,l);Y.type==="object"&&M.push(...Y.properties)}else{let U=N.required??[];M=M.map(J=>(J.schema.type==="optional"||J.schema.type==="nullable")&&U.includes(J.key)?{...J,schema:J.schema.value}:J);let Y=s0(N,!1,s,i,P,l);Y.type==="object"&&M.push(...Y.properties)}let T={};for(let N of E)for(let[U,Y]of Object.entries(N.properties)){let J=T[U];J!=null?(J.schemaIds.push(N.schemaId),J.schemas.some(oe=>vau(oe,Y))||J.schemas.push(Y)):T[U]={schemaIds:[N.schemaId],schemas:[Y]}}let z=[];for(let[N,U]of Object.entries(T))U.schemaIds.length>1&&z.push({propertyKey:N,allOfSchemaIds:U.schemaIds,conflictingTypeSignatures:U.schemas.length>1});let $=Object.fromEntries(Object.entries(A).filter(([N,U])=>!(!tp(U)&&U.type==="null"))),I=Object.entries($).map(([N,U])=>{let Y=hf(U,ad.AUDIENCES)??[],J=UK(U),X=tp(U)?!1:U.readOnly,oe=tp(U)?!1:U.writeOnly,pe=D.includes(N)&&!X,de=hf(U,ad.FERN_PROPERTY_NAME),me=[...i,N],Le=$1c(me),vt=pe?s0(U,!1,s,me,P,l):Nl.optional({nameOverride:e,generatedName:Le,title:r,description:void 0,availability:J,value:s0(U,!1,s,me,P,l),namespace:l,groupName:b,inline:void 0}),De={};for(let Ae of E){let Ct=Ae.properties[N];Ct!=null&&!vau(vt,Ct)?De[Ae.schemaId]={differentSchema:!0}:Ct!=null&&(De[Ae.schemaId]={differentSchema:!1})}return{key:N,schema:vt,nameOverride:de,audiences:Y,conflict:De,generatedName:$1c([...i,N]),availability:J,readonly:X,writeonly:oe}});return I.push(...M.map(N=>{let U=N.conflict;for(let Y of E){let J=Y.properties[N.key];J!=null&&!vau(N.schema,J)?U[Y.schemaId]={differentSchema:!0}:J!=null&&(U[Y.schemaId]={differentSchema:!1})}return{...N,conflict:U}})),ECE({nameOverride:e,generatedName:t,title:r,wrapAsNullable:c,properties:I.filter(N=>!o.has(N.key)),description:a,allOf:E.map(N=>N.convertedSchema),allOfPropertyConflicts:z,namespace:l,groupName:b,fullExamples:g,additionalProperties:O,availability:m,source:P,context:s})}function ECE({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,allOf:u,allOfPropertyConflicts:c,namespace:d,groupName:s,fullExamples:o,additionalProperties:l,availability:b,source:g,context:O}){return i?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:c,namespace:d,groupName:s,fullExamples:o,additionalProperties:gKn(l,O.options),availability:void 0,source:g,inline:void 0}),description:a,availability:b,namespace:d,groupName:s,inline:void 0}):Nl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:c,namespace:d,groupName:s,fullExamples:o,additionalProperties:gKn(l,O.options),availability:b,source:g,inline:void 0})}function Oj_({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[u,c]=tp(e)?[t.resolveSchemaReference(e),yau(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...Oj_({schema:d,context:t,breadcrumbs:c,source:i,namespace:n})};for(let[d,s]of Object.entries(u.properties??{})){let o=s0(s,!1,t,[...c,d],i,n);a[d]=o}return a}function xNi({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsNullable:u,context:c,subtypes:d,namespace:s,groupName:o,encoding:l,source:b,subtypePrefixOverrides:g}){let O=qCE({schemas:d}),m=d.flatMap((D,A)=>{if(!tp(D)&&D.enum!=null&&c.options.coerceEnumsToLiterals&&D.type==="string")return D.enum.map(E=>Nl.literal({nameOverride:void 0,generatedName:S5([t,E],c.options.preserveSchemaIds),title:void 0,value:mx.string(String(E)),namespace:s,groupName:void 0,description:void 0,availability:E.availability}));let M=O[A];if(g!=null){let E=g[A];E!=null&&"name"in E&&(M=E.name)}return[s0(D,!1,c,[...i,M??`${A}`],b,s)]}),P=MCE(m);return ACE({uniqueSubtypes:P,nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,namespace:s,groupName:o,context:c,encoding:l,source:b})}function MCE(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let u=e[a];if(i!=null&&u!=null&&Fue(i,u)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function ACE({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,namespace:c,groupName:d,context:s,encoding:o,source:l}){if(Object.entries(e).every(([g,O])=>O.type==="literal")){let g={},O=[];return Object.entries(e).forEach(([m,P])=>{P.type==="literal"&&P.value.type==="string"&&(O.push(P.value.value),P.description!=null&&(g[P.value.value]={description:P.description}))}),INi({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,fernEnum:g,enumVarNames:void 0,enumValues:O,_default:void 0,namespace:c,groupName:d,context:s,source:l,inline:void 0})}return e.length===1&&e[0]!=null&&!s.options.preserveSingleSchemaOneOf?e[0]:mj_({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,subtypes:e,namespace:c,groupName:d,encoding:o,source:l})}function Q1c({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsNullable:a,context:u,namespace:c,groupName:d,discriminator:s,encoding:o,source:l}){let b=Object.entries(s.mapping??{}).map(([m,P],D)=>{let A={$ref:P},M=Gmi(A,!1,u,[P],o,l,c);return u.markSchemaWithDiscriminantValue(A,s.propertyName,m),M.type==="object"&&(M.properties={[s.propertyName]:Nl.literal({nameOverride:void 0,generatedName:S5([t,m],u.options.preserveSchemaIds),title:void 0,value:mx.string(m),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...M.properties.filter(E=>E.key!==s.propertyName)}),M}),g=[];for(let m=0;m<b.length;++m){let P=b[m],D=!1;for(let A=m+1;A<b.length;++A){let M=b[A];if(P!=null&&M!=null&&Fue(P,M)){D=!0;break}}P!=null&&!D&&g.push(P)}if(Object.entries(g).every(([m,P])=>P.type==="literal")){let m={},P=[];return Object.entries(g).forEach(([D,A])=>{A.type==="literal"&&A.value.type==="string"&&(P.push(A.value.value),A.description!=null&&(m[A.value.value]={description:A.description}))}),INi({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,fernEnum:m,enumVarNames:void 0,enumValues:P,_default:void 0,namespace:c,groupName:d,context:u,source:l,inline:void 0})}return g.length===1&&g[0]!=null&&!u.options.preserveSingleSchemaOneOf?g[0]:mj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,subtypes:g,namespace:c,groupName:d,encoding:o,source:l})}function qCE({schemas:e}){let t={},r=0;for(let a of e){if(!tp(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),c={},d=u;for(let[s,o]of Object.entries(t)){let l=IAo(o,u);d=IAo(d,o),c[s]=l}c[r]=d,t=c}}r++}let i=[],n=0;for(let a of e){let u=t[n];if(u!=null&&u.length>0){let c=u.sort();if(c[0]!=null){i.push(c[0]),++n;continue}}tp(a)?i.push(qNi(n)??`${n}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?i.push(""):i.push(qNi(n)??`${n}`),++n}return i}function mj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,description:n,availability:a,subtypes:u,namespace:c,groupName:d,encoding:s,source:o}){return i?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.oneOf(xee.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,namespace:c,groupName:d,encoding:s,source:o,inline:void 0})),description:n,availability:a,namespace:c,groupName:d,inline:void 0}):Nl.oneOf(xee.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,namespace:c,groupName:d,encoding:s,source:o,inline:void 0}))}function mKn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function bau({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=Hnn(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function Pj_({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=Hnn(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function vor({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=Hnn(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function jj_({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=Hnn(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var Gnn="#/components/schemas/";function s0(e,t,r,i,n,a,u=!1,c=new Set,d){let s=cj_(e)??n,o=NCE({schema:e,logger:r.logger});if(tp(e)){let l=zNi(e);return l!=null?(u?r.markSchemaAsReferencedByRequest(l):r.markSchemaAsReferencedByNonRequest(l),Gmi(e,t,r,i,o,s,a)):OKn(r.resolveSchemaReference(e),t,r,yau(e.$ref),o,s,a,c,u,d)}return OKn(e,t,r,i,o,s,a,c,u,d)}function Gmi(e,t,r,i,n,a,u){let c=e.$ref.includes("properties")?OKn(r.resolveSchemaReference(e),t,r,i,n,a,u,new Set):Nl.reference(G1c(e,i,a,r.options.preserveSchemaIds));return t?Nl.nullable({title:void 0,nameOverride:void 0,generatedName:S5(i,r.options.preserveSchemaIds),value:c,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0}):c}function TCE(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function OKn(e,t,r,i,n,a,u,c=new Set,d=!1,s){typeof e=="string"&&(e={type:e});let o=hf(e,ad.TYPE_NAME)??(r.options.useTitlesAsName?TCE(e.title):void 0),l=hf(e,ad.SDK_GROUP_NAME)??hf(e,M$.TAGS)?.[0],b=(typeof l=="string"?[l]:l)??[];b=r.resolveGroupName(b);let g=S5(i,r.options.preserveSchemaIds),O=e.title,m=e.description,P=UK(e),D=[];e.example!=null&&D.push({name:void 0,value:e.example,description:void 0});let A=hf(e,M$.EXAMPLES);A!=null&&Object.keys(A).length>0&&D.push(...Object.entries(A).map(([T,z])=>({name:z?.summary??T,value:z.value,description:z.description})));let M=Hnn(e);M!=null&&Object.keys(M).length>0&&D.push(...M.map(T=>({name:void 0,value:T,description:void 0})));let E=sj_({schema:e,description:m,title:O,nameOverride:o,generatedName:g,availability:P});if(E!=null)return E;if(Array.isArray(e.type)){let T=e.type.indexOf("null"),z=T!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&z)e.type.splice(T,1),e.type=e.type[0],e.nullable=!0;else if(z&&(e.type.splice(T,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let $=new Set([...e.oneOf,...e.type]);e.oneOf=[...$]}}if(!t&&e.nullable===!0)return OKn(e,!0,r,i,n,a,u,c,d,s);if("const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(!mau(e.enum))return w5({nameOverride:o,generatedName:g,title:O,primitive:bp.string({default:mKn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:vor({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b,wrapAsNullable:t,description:m,availability:P});let T=uj_(e);return e.enum.length===1&&e.enum[0]!=null&&T==null?vj_({nameOverride:o,generatedName:g,title:O,wrapAsNullable:t,value:e.enum[0],description:m,availability:P,namespace:u,groupName:b}):INi({nameOverride:o,generatedName:g,title:O,fernEnum:T,enumVarNames:hf(e,[M$.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:m,availability:P,wrapAsNullable:t,namespace:u,groupName:b,context:r,source:a,inline:void 0})}if(mau(e.type)&&e.type.length>1){let T=e.type.includes("null"),z=e.type.filter($=>$!=="null").map($=>({type:$,nullable:T}));return xNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t,context:r,subtypes:z,namespace:u,groupName:b,encoding:n,source:a})}if(e.type==="boolean"){let T=hf(e,ad.BOOLEAN_LITERAL);return T!=null?wj_({nameOverride:o,generatedName:g,title:O,literal:mx.boolean(T),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b}):w5({nameOverride:o,generatedName:g,title:O,primitive:bp.boolean({default:CCE(e.default),example:Pj_({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b})}if(e.type==="number")return H1c({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:$nn(e.exclusiveMinimum),exclusiveMaximum:$nn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:bau({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="integer")return hj_({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:$nn(e.exclusiveMinimum),exclusiveMaximum:$nn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:bau({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="float")return H1c({nameOverride:o,generatedName:g,title:O,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:$nn(e.exclusiveMinimum),exclusiveMaximum:$nn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:bau({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="string"){if(e.format==="date-time")return w5({nameOverride:o,generatedName:g,title:O,primitive:bp.datetime({example:vor({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b});if(e.format==="date"&&r.options.typeDatesAsStrings===!1)return w5({nameOverride:o,generatedName:g,title:O,primitive:bp.date({example:vor({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b});if(e.format==="json-string")return Nl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:P,namespace:u,groupName:b,example:void 0});let T=Ej_(e,"const");return T!=null?wj_({nameOverride:o,generatedName:g,title:O,literal:mx.string(T),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b}):w5({nameOverride:o,generatedName:g,title:O,primitive:bp.string({default:mKn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:vor({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b,wrapAsNullable:t,description:m,availability:P})}if(e.type==="array")return dj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,item:e.items,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,example:jj_({schema:e,logger:r.logger,fallback:s}),source:a});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&gau(e))return lj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,additionalProperties:e.additionalProperties,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,example:e.example,source:a});if(e.oneOf!=null&&e.oneOf.length>0&&hf(e,ad.IS_DISCRIMINATED)===!1)return xNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t,context:r,subtypes:e.oneOf,namespace:u,groupName:b,encoding:n,source:a});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?Q1c({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,discriminator:e.discriminator,encoding:n,source:a}):V1c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,source:a});if(e.oneOf!=null&&e.oneOf.length>0){let T=hf(e,ad.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||T?Q1c({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,discriminator:e.discriminator,encoding:n,source:a}):V1c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,source:a});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(r.options.preserveSingleSchemaOneOf)return xNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t,context:r,subtypes:e.oneOf.filter($=>tp($)||$.type!=="null"),encoding:n,namespace:u,groupName:b,source:a});let z=s0(e.oneOf[0],t,r,i,a,u,d);return PKn(z,m,u,b)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let N=e.oneOf[0],U=e.oneOf[1];if(!tp(N)&&N.type==="null")return s0(U,!0,r,i,a,u);if(!tp(U)&&U.type==="null")return s0(N,!0,r,i,a,u)}let z=zCE({schemas:e.oneOf});if(z!=null)return INi({nameOverride:o,generatedName:g,title:O,fernEnum:void 0,enumVarNames:void 0,enumValues:z,_default:e.default,description:m,availability:P,wrapAsNullable:t,namespace:u,groupName:b,context:r,source:a,inline:void 0});let $=Sj_({schemas:e.oneOf,context:r});if($!=null&&!r.options.discriminatedUnionV2&&!T)return W1c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:P,wrapAsNullable:t,discriminant:$.discriminant,variants:$.schemas,context:r,namespace:u,groupName:b,encoding:n,source:a});let I=e.oneOf.filter(N=>!tp(N)&&N.type==="null").length>0;return xNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t||I,context:r,subtypes:e.oneOf.filter(N=>tp(N)||N.type!=="null"),encoding:n,namespace:u,groupName:b,source:a})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let $=s0(e.anyOf[0],t,r,i,a,u,d);return PKn($,m,u,b)}if(e.anyOf.length===2){let[$,I]=e.anyOf;if($!=null&&I!=null){if(!tp($)&&$.type==="null"){let N=s0(I,!0,r,i,a,u);return PKn(N,m,u,b)}else if(!tp(I)&&I.type==="null"){let N=s0($,!0,r,i,a,u);return PKn(N,m,u,b)}}}let T=Sj_({schemas:e.anyOf,context:r});if(T!=null&&!r.options.discriminatedUnionV2)return W1c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:P,wrapAsNullable:t,discriminant:T.discriminant,variants:T.schemas,context:r,namespace:u,groupName:b,encoding:n,source:a});let z=e.anyOf.filter($=>!tp($)&&$.type==="null").length>0;return xNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t||z,context:r,subtypes:e.anyOf.filter($=>tp($)||$.type!=="null"),encoding:n,namespace:u,groupName:b,source:a})}if(e.allOf!=null||e.properties!=null){let T=[];for(let $ of e.allOf??[])(tp($)||Object.keys($).length>0)&&T.push($);if((e.properties==null||gau(e))&&T.length===1&&T[0]!=null){let $=s0(T[0],t,r,i,a,u,d);return PKn($,m,u,b)}let z=T.filter($=>{let I=Oau($);return I||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify($)}`),I});if((e.properties==null||gau(e))&&z.length===1&&z[0]!=null){let $=s0(z[0],t,r,i,a,u,d);return PKn($,m,u,b)}return gj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},description:m,required:e.required,wrapAsNullable:t,allOf:z,context:r,propertiesToExclude:c,namespace:u,groupName:b,fullExamples:D,additionalProperties:e.additionalProperties,availability:P,encoding:n,source:a})}if(e.type==="object"&&BCE(e)&&ICE(e)&&gau(e))return hau({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${g}Key`,title:void 0,description:void 0,availability:void 0,schema:bp.string({default:mKn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:vor({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b},valueSchema:Nl.unknown({nameOverride:void 0,generatedName:`${g}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:b}),namespace:u,groupName:b,encoding:n,example:e.example});if(e.type==null){let T=e.example??e.default;return Nl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:P,namespace:u,groupName:b,example:T})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(i)} value=${JSON.stringify(e)}`)}function CCE(e){if(e!=null){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase();if(t==="true")return!0;if(t==="false")return!1}}}function zNi(e){if(e.$ref.startsWith(Gnn))return e.$ref.replace(Gnn,"")}function G1c(e,t,r,i){let n=hf(e,ad.TYPE_NAME),a=S5(t,i),u=e.description,c=UK(e),d=zNi(e);if(d==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return wv.reference({generatedName:a,nameOverride:n,title:void 0,schema:d,description:u??void 0,availability:c,namespace:void 0,groupName:void 0,source:r})}function BCE(e){return e.oneOf==null||e.oneOf.length===0}function ICE(e){return e.allOf==null||e.allOf.length===0}function gau(e){return e.properties==null||Vq(e.properties)===0}function mau(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function PKn(e,t,r,i){return e.type==="reference"?Nl.reference({...e,description:t,availability:e.availability,namespace:r,groupName:i}):e.type==="optional"?Nl.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0}):e.type==="nullable"?Nl.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0}):e}function Oau(e){return tp(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>Oau(t)):e.oneOf!=null?e.oneOf.every(t=>Oau(t)):e.anyOf!=null?e.anyOf.every(t=>Oau(t)):!1}function wj_({literal:e,wrapAsNullable:t,namespace:r,groupName:i,description:n,availability:a,nameOverride:u,generatedName:c,title:d}){return t?Nl.nullable({nameOverride:u,generatedName:c,title:d,value:Nl.literal({nameOverride:u,generatedName:c,title:d,value:e,description:n,availability:a,namespace:r,groupName:i}),namespace:r,groupName:i,description:n,availability:a,inline:void 0}):Nl.literal({nameOverride:u,generatedName:c,title:d,value:e,namespace:r,groupName:i,description:n,availability:a})}function w5({primitive:e,wrapAsNullable:t,namespace:r,groupName:i,description:n,availability:a,generatedName:u,nameOverride:c,title:d}){return i=typeof i=="string"?[i]:i,t?Nl.nullable({nameOverride:c,generatedName:u,title:d,value:Nl.primitive({nameOverride:c,generatedName:u,title:d,schema:e,description:n,availability:a,namespace:r,groupName:i}),namespace:r,groupName:i,description:n,availability:a,inline:void 0}):Nl.primitive({nameOverride:c,generatedName:u,title:d,schema:e,description:n,availability:a,namespace:r,groupName:i})}function zCE({schemas:e}){let t=new Set;for(let r of e){if(tp(r))return;if(r.enum!=null&&mau(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function Sj_({schemas:e,context:t}){let r={};for(let i of e){let n=Dj_({schema:i,context:t});for(let[a,u]of Object.entries(n)){let c=r[a];c!=null?c[u]=i:r[a]={[u]:i}}}for(let[i,n]of Object.entries(r))if(Object.keys(n).length===e.length)return{discriminant:i,schemas:n}}function Dj_({schema:e,context:t}){let r=tp(e)?t.resolveSchemaReference(e):e;return xCE({schema:r,context:t})}function xCE({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=Dj_({schema:i,context:t});for(let[a,u]of Object.entries(n??{}))r[a]=u}return r}for(let[i,n]of Object.entries(e.properties??{})){let a=tp(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&mau(a.enum)&&RCE(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let u=Ej_(a,"const");a.type==="string"&&u!=null&&(r[i]=u),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function RCE(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 Ej_(e,t){let r=e[t];if(r!=null)return r}function NCE({schema:e,logger:t}){let r=oj_({schema:e,logger:t});if(r!=null)return _j_(r)}var jKn=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:i,namespace:n}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=i,this.namespace=n}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 i=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};i.push(n)}return i.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(Gnn))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let i=t.$ref.substring(Gnn.length).split("/"),n=this.document.components;if(n==null||n.schemas==null)throw new Error("Document does not have components.schemas.");let[a,u,c]=i;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let d=n.schemas[a];if(d==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if(tp(d)&&(d=this.resolveSchemaReference(d)),u==="properties"&&c!=null){let s=d.properties?.[c];if(s==null)throw new Error(`Property "${c}" not found on "${a}". Full ref: ${t.$ref}`);tp(s)?d=this.resolveSchemaReference(s):d=s}return d}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,i){}markSchemaWithDiscriminantValue(t,r,i){}};var Pau=class extends jKn{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",i=this.document.components;if(i==null||i.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let n=t.$ref.substring(r.length),a=i.messages[n];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function wKn(e,t){let r={};if(e!=null)return{rootSchemas:r,namespacedSchemas:{[e]:t}};let i={};for(let[n,a]of Object.entries(t))switch(a.type){case"object":case"array":case"map":case"optional":case"enum":case"literal":case"reference":case"nullable":case"primitive":{if(a.namespace==null){r[n]=a;continue}let u=a.namespace;i[u]??={},i[u][n]=a;continue}case"oneOf":case"unknown":r[n]=a;continue;default:Ao(a)}return{rootSchemas:r,namespacedSchemas:i}}function RNi(e){if(typeof e=="string")return rO.primitive(M_.string(e));if(typeof e=="number")return Number.isInteger(e)?rO.primitive(M_.int(e)):rO.primitive(M_.double(e));if(typeof e=="boolean")return rO.primitive(M_.boolean(e));if(Array.isArray(e)){let t=e.map(r=>RNi(r));return t.length===0?void 0:rO.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,i]of Object.entries(e)){let n=RNi(i);n!=null&&t.push({key:M_.string(r),value:n})}return rO.map(t)}}function R5a(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function Mj_(e){if(e!=null&&Array.isArray(e))return e}var NNi=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,i){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=i}buildExample({schema:t,exampleId:r,example:i,options:n,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:i,options:{...n,maxCheckerDepth:n.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:i,depth:n,visitedSchemaIds:a,options:u,skipReadonly:c}){switch(i.type){case"enum":return typeof r=="string"&&Aj_({schema:i,value:r})?rO.enum(r):i.values[0]!=null?rO.enum(i.values[0]?.value):void 0;case"literal":return rO.literal(i.value);case"nullable":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u)))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:c});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"optional":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u))||Object.is(r,null))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:c});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"primitive":{let d=this.buildExampleFromPrimitive({schema:i.schema,example:r,options:u});return rO.primitive(d)}case"reference":{let d=this.schemas[i.schema];if(d!=null&&!a.has(i.schema)){a.add(i.schema);let s=d?.type==="object"&&!this.nonRequestReferencedSchemas.has(i.schema),o=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:n,options:u,skipReadonly:s||this.context.options.respectReadonlySchemas?c:!1});return a.delete(i.schema),o}return}case"oneOf":switch(i.value.type){case"discriminated":{let d={},s={},o={},l=R5a(r),b=l?.[i.value.discriminantProperty],g=i.value.schemas[b],O=[],m=this.getDiscriminatedUnionVariantSchema(i.value,l);m!=null&&O.push(m),O.push(...Object.entries(i.value.schemas));for(let P of O)if(b!=null&&g!=null&&g.type==="object"){s=this.getAllProperties(g),o=this.getAllRequiredProperties(g),d[i.value.discriminantProperty]=rO.primitive(M_.string(b));break}else{let D=this.buildExampleHelper({exampleId:t,schema:P[1],example:void 0,visitedSchemaIds:a,depth:n,options:u,skipReadonly:c});if(D!=null){this.mergeExampleWith(D,d),d[i.value.discriminantProperty]=rO.primitive(M_.string(P[0]));break}}for(let P of i.value.commonProperties){s[P.key]={schema:P.schema,readonly:!1};let D=this.getResolvedSchema(P.schema);D.type!=="optional"&&D.type!=="nullable"&&(o[P.key]=P.schema)}for(let[P,D]of Object.entries(s)){let A=P in o;if(A&&l?.[P]!=null){let M=this.buildExampleHelper({schema:D.schema,exampleId:t,example:l[P],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:c});if(M!=null)d[P]=M;else return}else{let M=this.buildExampleHelper({exampleId:t,schema:D.schema,example:l?.[P],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:c});if(M!=null)d[P]=M;else if(A)return}}return rO.oneOf(mNi.discriminated(d))}case"undiscriminated":{let d=this.getUnDiscriminatedUnionVariantSchema(i.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:n,options:u,skipReadonly:c});break}}return;case"unknown":if(r!=null){let d=RNi(r);if(d!=null)return rO.unknown(d)}return u.ignoreOptionals||this.exceedsMaxDepth(n,u)?void 0:u.isParameter?rO.primitive(M_.string(u.name??"string")):rO.map([{key:M_.string("key"),value:rO.primitive(M_.string("value"))}]);case"array":{let d=Mj_(r),s=[];if(d!=null&&d.length>0)for(let o of d){let l=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:c});l!=null&&s.push(l)}else if(i.example!=null&&i.example.length>0)for(let o of i.example){let l=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:c});l!=null&&s.push(l)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:c});o!=null&&s.push(o)}return rO.array(s)}case"map":{let d=R5a(r??i.example);if(d!=null&&Object.entries(d).length>0){let l=[];for(let[b,g]of Object.entries(d)){let O=this.buildExampleFromPrimitive({schema:i.key.schema,example:b,options:u}),m=this.buildExampleHelper({exampleId:t,example:g,schema:i.value,visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:c});m!=null&&l.push({key:O,value:m})}return rO.map(l)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return rO.map([{key:M_.string("key"),value:rO.unknown(rO.primitive(M_.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:i.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,visitedSchemaIds:a,depth:n+1,options:{...u,name:"value"},skipReadonly:c});return o!=null?rO.map([{key:s,value:o}]):rO.map([])}case"object":{let d={},s=i.fullExamples?.find(g=>g.name===t)??i.fullExamples?.find(g=>g.name==null)??i.fullExamples?.[0],o=R5a(r)??(s!=null?R5a(s.value):{})??{},l=this.getAllProperties(i),b=this.getAllRequiredProperties(i);for(let[g,O]of Object.entries(l)){if(c&&O.readonly||O.schema._visit({optional:A=>typeof A.availability=="string"&&A.availability==="Deprecated",primitive:()=>!1,object:()=>!1,array:()=>!1,map:()=>!1,enum:()=>!1,reference:()=>!1,literal:()=>!1,oneOf:()=>!1,nullable:()=>!1,unknown:()=>!1,_other:()=>!1}))continue;let m=g in b,P=Object.keys(o).includes(g),D=this.buildExampleHelper({schema:O.schema,exampleId:t,example:o[g],visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:c});if(m&&D!=null)d[g]=D;else{if(m)return;(P&&D!=null||!u.ignoreOptionals&&D!=null)&&(d[g]=D)}}if(i.additionalProperties){for(let[g,O]of Object.entries(o))if(!(g in d)){let m=this.buildExampleHelper({schema:Nl.unknown({example:O,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0}),exampleId:t,example:O,visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:c});m!=null&&(d[g]=m)}}return rO.object({properties:d})}default:Ao(i)}}mergeExampleWith(t,r){t._visit({array:Ko,enum:Ko,literal:Ko,map:i=>{for(let n of i){let a=n.key;a.type==="string"&&(r[a.value]=n.value)}},object:i=>{for(let[n,a]of Object.entries(i.properties))r[n]=a},oneOf:i=>{if(i.type==="discriminated")for(let[n,a]of Object.entries(i.value))r[n]=a;else this.mergeExampleWith(i.value,r)},primitive:Ko,unknown:Ko,_other:Ko})}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 i=r?.[t.discriminantProperty];if(i==null||typeof i!="string")return Object.entries(t.schemas)[0];let n=t.schemas[i];return n==null?Object.entries(t.schemas)[0]:[i,n]}getUnDiscriminatedUnionVariantSchema(t,r){return r==null?t.schemas[0]:t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,u)=>u.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return Aj_({schema:t,value:r})?5:0;case"object":{if(!Rw(r))return 0;let i=this.getAllProperties(t),n=0;for(let[a,u]of Object.entries(i))r[a]!=null?(n++,n+=this.calcExampleHeuristic(u.schema,r[a])):n--;return n}case"array":{if(!Array.isArray(r))return 0;let i=0;for(let n of r)i+=this.calcExampleHeuristic(t.value,n);return i}case"map":{if(!Rw(r))return 0;let i=0;for(let[,n]of Object.entries(r))i+=this.calcExampleHeuristic(t.value,n);return i}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let i=this.getResolvedSchema(t);return i==null?0:this.calcExampleHeuristic(i,r)}case"oneOf":return Object.values(t.value.schemas).map(n=>this.calcExampleHeuristic(n,r)).sort((n,a)=>a-n)[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,i=new Set,n){if(this.exceedsMaxCheckerDepth(r,n))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,i,n);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,i,n);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,i,n))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!i.has(t.schema)){i.add(t.schema);let u=this.hasExample(a,r,i,n);return i.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,i,n));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 i of t.properties)r[i.key]={schema:i.schema,readonly:i.readonly??!1};for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let i of t.properties){let n=this.getResolvedSchema(i.schema);n.type!=="optional"&&n.type!=="nullable"&&(r[i.key]=i.schema)}for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);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:i}){switch(r.type){case"string":return t!=null&&typeof t=="string"?M_.string(t):r.example!=null?M_.string(r.example):M_.string(i.name??Qh.STRING);case"base64":return t!=null&&typeof t=="string"?M_.base64(t):r.example!=null?M_.base64(r.example):M_.base64(Qh.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?M_.boolean(t):r.example!=null?M_.boolean(r.example):M_.boolean(Qh.BOOLEAN);case"date":return t!=null&&typeof t=="string"?M_.date(t):r.example!=null?M_.date(r.example):M_.date(Qh.DATE);case"datetime":return t!=null&&typeof t=="string"?M_.datetime(t):r.example!=null?M_.datetime(r.example):M_.datetime(Qh.DATE_TIME);case"double":return t!=null&&typeof t=="number"?M_.double(t):r.example!=null?M_.double(r.example):M_.double(Qh.DOUBLE);case"float":return t!=null&&typeof t=="number"?M_.float(t):r.example!=null?M_.float(r.example):M_.float(Qh.FLOAT);case"int":return t!=null&&typeof t=="number"?M_.int(t):r.example!=null?M_.int(r.example):M_.int(Qh.INT);case"int64":return t!=null&&typeof t=="number"?M_.int64(t):r.example!=null?M_.int64(r.example):M_.int64(Qh.INT64);case"uint":return t!=null&&typeof t=="number"?M_.uint(t):r.example!=null?M_.uint(r.example):M_.uint(Qh.UINT);case"uint64":return t!=null&&typeof t=="number"?M_.uint64(t):r.example!=null?M_.uint64(r.example):M_.uint64(Qh.UINT64);default:Ao(r)}}};function Aj_({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function $Qt(e){switch(e.type){case"object":return Nl.object({allOf:e.allOf,properties:e.properties.map(t=>LCE(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:void 0});case"array":return Nl.array({description:e.description,availability:e.availability,value:$Qt(e.value),generatedName:e.generatedName,title:e.title,namespace:e.namespace,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return Nl.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,example:void 0,source:e.source,inline:void 0});case"literal":return Nl.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName});case"nullable":return Nl.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:$Qt(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return Nl.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:$Qt(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return Nl.primitive({description:e.description,availability:e.availability,schema:qj_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Nl.map({description:e.description,availability:e.availability,key:Nl.primitive({description:e.key.description,availability:e.key.availability,schema:qj_(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:$Qt(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return Nl.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return Nl.oneOf(FCE(e.value));case"unknown":return Nl.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,namespace:void 0,groupName:void 0,description:void 0,availability:void 0});default:Ao(e)}}function FCE(e){switch(e.type){case"discriminated":return xee.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:$Qt(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,$Qt(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return xee.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>$Qt(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:Ao(e)}}function qj_(e){switch(e.type){case"string":return bp.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return bp.base64({example:void 0});case"boolean":return bp.boolean({default:e.default,example:void 0});case"date":return bp.date({example:void 0});case"datetime":return bp.datetime({example:void 0});case"double":return bp.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 bp.float({example:void 0});case"int":return bp.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 bp.int64({default:e.default,example:void 0});case"uint":return bp.uint({default:void 0,example:void 0});case"uint64":return bp.uint64({default:void 0,example:void 0});default:Ao(e)}}function LCE(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:$Qt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function jau(e){return e.type!=="optional"&&e.type!=="nullable"}function J1c(e){return e==="POST"||e==="PUT"||e==="PATCH"}function N5a(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 wau=class{schemas;context;globalHeaders;exampleTypeFactory;logger;constructor(t,r,i){this.schemas=t,this.context=r,this.globalHeaders=i,this.schemas=t,this.exampleTypeFactory=new NNi(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=VCE(t.request),i=WCE(t.response);if(r?.type==="unsupported"||i?.type==="unsupported")return[];let n=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:J1c(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});b!=null&&n.push([void 0,b])}else for(let{name:b,value:g}of r.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:J1c(t.method),schema:r.schema,exampleId:b,example:g,options:{isParameter:!1,ignoreOptionals:!0}});O!=null&&n.push([b,O])}if(l&&n.length===0)return this.logger.trace(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(i!=null&&i.type==="present"){let l=this.isSchemaRequired(i.schema);if(i.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:void 0,example:void 0,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});b!=null&&(t.response?.type==="json"?a.push([void 0,VQt.withoutStreaming(b)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,VQt.withStreaming({sse:t.response?.type==="streamingSse",events:[b]})]))}else for(let{name:b,value:g}of i.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:b,example:g,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});O!=null&&(t.response?.type==="json"?a.push([b,VQt.withoutStreaming(O)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,VQt.withStreaming({sse:t.response?.type==="streamingSse",events:[O]})]))}if(l&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let l of t.pathParameters){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!GQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&u.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:g})}let c=[];for(let l of t.queryParameters){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!GQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&c.push({name:l.name,value:g})}let d=[];for(let l of t.headers){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!GQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&d.push({name:l.name,value:g})}for(let l of this.globalHeaders){let b=l.schema!=null?$Qt(l.schema):Nl.primitive({nameOverride:void 0,generatedName:"",title:void 0,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,schema:bp.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})}),g=this.exampleTypeFactory.buildExample({schema:b,exampleId:void 0,example:void 0,options:{name:l.header,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!GQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for global header ${l.header} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),g==null)return[];g!=null&&d.push({name:l.header,value:g})}let s=[];t.request!=null&&t.response!=null?s=UCE(n,a):t.request!=null?s=n.map(([l,b])=>({id:l,request:b,response:void 0})):t.response!=null&&(s=a.map(([l,b])=>({id:l,request:void 0,response:b})));let o=t.examples.filter(l=>N5a(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let b=l.value["code-samples"];if(b!=null)return this.convertCodeSamples(b)}return}else return l.codeSamples}).filter(l=>bv(l));return s.length===0?[UQt.full({name:void 0,description:void 0,pathParameters:u,queryParameters:c,headers:d,request:void 0,response:void 0,codeSamples:o})]:s.map(({id:l,request:b,response:g})=>UQt.full({name:l,description:void 0,pathParameters:u,queryParameters:c,headers:d,request:b,response:g,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?Lmi.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):Lmi.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?D$.Csharp:r.sdk,code:r.code})).filter(bv)}isSchemaRequired(t){return jau(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function UCE(e,t){let r=[];if(e.length<=1){let[n,a]=e[0]??[];if(t.length===0)return r.push({id:n,request:a,response:void 0}),r;for(let[u,c]of t)r.push({id:u??n,request:a,response:c});return r}if(t.length<=1){let[n,a]=t[0]??[];if(t.length===0)return r.push({id:n,request:void 0,response:a}),r;for(let[u,c]of e)r.push({id:u??n,request:c,response:a});return r}let i=new Set;for(let[n,a]of e){let u=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(n==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let c=!1;for(let d=0;d<t.length;d++){let[s,o]=t[d];s==null||i.has(d)||n===s&&(r.push({id:n,request:a,response:o}),s!=null&&i.add(d),c=!0)}!c&&u!=null&&r.push({id:n,request:a,response:u})}for(let n=0;n<t.length;n++){if(i.has(n))continue;let[a,u]=t[n],c=e.find(([d])=>d==null)?.[1]??e[0]?.[1];c!=null&&r.push({id:a,request:c,response:u})}return r}function VCE(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:HCE(e),examples:[]}:e.type==="json"||e.type==="formUrlEncoded"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function WCE(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"&&e.type!=="streamingSse"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function GQt(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return GQt(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return GQt(e.value.value);default:return!1}default:Ao(e)}}function HCE(e){return Nl.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:$Qt(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,writeonly:void 0,inline:void 0}).filter(bv),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source,inline:void 0})}var SKn=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new NNi(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,handshake:i,source:n,namespace:a}){let u=[];for(let c of r){let d=[];for(let l of i.queryParameters){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.queryParameters?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});g!=null&&!GQt(g)&&(g=void 0),!(b&&g==null)&&g!=null&&d.push({name:l.name,value:g})}let s=[];for(let l of i.headers){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.headers?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});g!=null&&!GQt(g)&&(g=void 0),!(b&&g==null)&&g!=null&&s.push({name:l.name,value:g})}let o=[];for(let l of c.messages){let b=t.getExampleMessageReference(l),g=t.resolveMessageReference({$ref:b}),O=tp(g.payload)?t.resolveSchemaReference(g.payload):g.payload,m=this.exampleTypeFactory.buildExample({schema:s0(O,!1,t,[l.messageId],n,a),exampleId:void 0,example:l.value,options:{isParameter:!1,ignoreOptionals:!0}});m!=null&&o.push({messageType:l.type,payload:m,description:void 0})}u.push({name:c.summary,queryParameters:d,headers:s,description:c.description,messages:o})}return u}buildWebsocketSessionExample({handshake:t,messages:r}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},n=[];for(let u of t.queryParameters){let c=this.isSchemaRequired(u.schema),d=this.exampleTypeFactory.buildExample({schema:u.schema,exampleId:void 0,example:void 0,options:{name:u.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!GQt(d)&&(d=void 0),c&&d==null)return;d!=null&&n.push({name:u.name,value:d})}let a=[];for(let u of t.headers){let c=this.isSchemaRequired(u.schema),d=this.exampleTypeFactory.buildExample({schema:u.schema,exampleId:void 0,example:void 0,options:{name:u.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!GQt(d)&&(d=void 0),c&&d==null)return;d!=null&&a.push({name:u.name,value:d})}for(let u of r){let c=this.exampleTypeFactory.buildExample({schema:u.payload,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});c!=null&&i.messages.push({messageType:u.type,payload:c,description:void 0})}return i}isSchemaRequired(t){return jau(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 Fee={FERN_PARAMETER_OPTIONAL:"x-fern-optional",FERN_CHANNEL_ADDRESS:"x-fern-address",FERN_DISPLAY_NAME:"x-fern-display-name",FERN_SDK_GROUP_NAME:"x-fern-sdk-group-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",FERN_ENUM:"x-fern-enum",IGNORE:"x-fern-ignore"};function Sau(e){return hf(e,Fee.FERN_EXAMPLES)??[]}function Dau(e,t){return t.includes("://")?t:`${e}://${t}`}function Eau(e){return e.startsWith("/")?e:"/"+e}function Bj_({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={};for(let[s,o]of Object.entries(n.components?.schemas??{})){let l=s0(o,!1,e,[s],r,e.namespace);a[s]=l}let c=new SKn(a,e),d={};for(let[s,o]of Object.entries(n.servers??{}))d[s]={name:s,url:Dau(o.protocol,o.url)};for(let[s,o]of Object.entries(n.channels??{})){let l=hf(o,Fee.IGNORE);if(l!=null&&l){e.logger.debug(`Channel ${s} is marked with x-fern-ignore. Skipping.`);continue}let b=[];if(o.parameters!=null)for(let[D,A]of Object.entries(o.parameters??{}))b.push({name:D,description:A.description,parameterNameOverride:void 0,schema:A.schema!=null?s0(A.schema,!1,e,t,r,e.namespace):Nl.primitive({schema:bp.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,namespace:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:UK(A),source:r});let g=[],O=[];if(o.bindings?.ws!=null){if(o.bindings.ws.headers!=null){let D=o.bindings.ws.headers.required??[];for(let[A,M]of Object.entries(o.bindings.ws.headers.properties??{})){if(tp(M)){let E=e.resolveSchemaReference(M);g.push({name:A,schema:Gmi(M,!1,e,t,void 0,r,e.namespace),description:E.description,parameterNameOverride:void 0,env:void 0,availability:UK(E),source:r});continue}g.push({name:A,schema:s0(M,!D.includes(A),e,[...t,A],r,e.namespace),description:M.description,parameterNameOverride:void 0,env:void 0,availability:UK(M),source:r})}}if(o.bindings.ws.query!=null){let D=o.bindings.ws.query.required??[];for(let[A,M]of Object.entries(o.bindings.ws.query.properties??{})){if(tp(M)){let E=e.resolveSchemaReference(M);O.push({name:A,schema:Gmi(M,!1,e,t,void 0,r,e.namespace),description:E.description,parameterNameOverride:void 0,availability:UK(E),source:r});continue}O.push({name:A,schema:s0(M,!D.includes(A),e,[...t,A],r,e.namespace),description:M.description,parameterNameOverride:void 0,availability:UK(M),source:r})}}}let m;o.publish!=null&&("oneOf"in o.publish.message?m=Tj_({generatedName:o.publish.operationId??"PublishEvent",event:o.publish,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):m=Cj_({action:"Publish",channelPath:s,message:o.publish.message,context:e,source:r}));let P;if(o.subscribe!=null&&("oneOf"in o.subscribe.message?P=Tj_({generatedName:o.subscribe.operationId??"SubscribeEvent",event:o.subscribe,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):P=Cj_({action:"Subscribe",channelPath:s,message:o.subscribe.message,context:e,source:r})),g.length>0||O.length>0||m!=null||P!=null){let D=Sau(o),A=[];if(D.length>0)A=c.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:D,handshake:{headers:g,queryParameters:O},source:r,namespace:e.namespace});else{let z=[];m!=null&&z.push({type:"publish",payload:m}),P!=null&&z.push({type:"subscribe",payload:P});let $=c.buildWebsocketSessionExample({handshake:{headers:g,queryParameters:O},messages:z});$!=null&&A.push($)}let M=hf(o,Fee.FERN_CHANNEL_ADDRESS),E=M??Eau(s),T=[];m!=null&&T.push({origin:"client",name:"publish",body:DA(m)}),P!=null&&T.push({origin:"server",name:"subscribe",body:DA(P)}),u[s]={audiences:hf(o,ad.AUDIENCES)??[],handshake:{headers:g.map(z=>({...z,schema:DA(z.schema),env:z.env})),queryParameters:O.map(z=>({...z,schema:DA(z.schema)})),pathParameters:b.map(z=>({...z,parameterNameOverride:void 0,schema:DA(z.schema)}))},groupName:e.resolveGroupName([hf(o,Fee.FERN_SDK_GROUP_NAME)??s]),messages:T,servers:(o.servers?.map(z=>d[z])??Object.values(d)).filter(z=>z!=null),summary:hf(o,Fee.FERN_DISPLAY_NAME),path:E,description:o.description,examples:A,source:r}}}return{groupedSchemas:wKn(e.namespace,a),channels:u??void 0,servers:Object.values(d),basePath:hf(n,Fee.BASE_PATH)}}function Tj_({generatedName:e,event:t,context:r,breadcrumbs:i,source:n,options:a,asyncApiOptions:u}){if("oneOf"in t.message&&t.message.oneOf!=null){let c=[],d=[];for(let s of t.message.oneOf){let o,l={type:"notFound"};if(tp(s)){let b=r.resolveMessageReference(s);!tp(b.payload)&&u.naming==="v2"?(l=b.name?{type:"name",name:b.name}:l,o={...b.payload,title:b.name??b.payload.title,description:b.name??b.payload.description}):o=b.payload}else o=s;d.push(l),c.push(o)}return xNi({description:t.description??t.message.description,availability:UK(t.message),subtypes:c,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:i,context:r,encoding:void 0,source:n,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}function Cj_({action:e,channelPath:t,message:r,context:i,source:n}){if(r.payload!=null){let a=r.payload;return tp(r.payload)&&(a=i.resolveSchemaReference(r.payload)),s0(a,!1,i,[t,e],n,i.namespace)}}var Mau=class extends jKn{getExampleMessageReference(t){return`#/channels/${t.channelId}/messages/${t.messageId}`}resolveParameterReference(t){let r="#/components/parameters/";if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve ${t.$ref}`);let i=t.$ref.substring(r.length),n=this.document.components.parameters[i];if(n==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in n?this.resolveParameterReference(n):n}resolveMessageReference(t){let r="#/channels/",i="#/components/messages/";if(t.$ref.startsWith(r)){let c=t.$ref.split("/"),d=c[2],s=c[4];if(d==null||s==null||!this.document.channels?.[d])throw new Error(`Failed to resolve message reference ${t.$ref} in channel ${d}`);let l=this.document.channels[d].messages?.[s];if(l==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in l?this.resolveMessageReference(l):{name:s,...l}}let n=this.document.components;if(!t.$ref.startsWith(i)||!n?.messages)throw new Error(`Failed to resolve message reference: ${t.$ref} in v3 components`);let a=t.$ref.substring(i.length),u=n.messages[a];if(u==null)throw new Error(`${t.$ref} is undefined`);return{name:a,...u}}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}};var Ij_="#/channels/",zj_="#/servers/",K1c="$message.";function Rj_({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={},c={},d=[],s={};for(let[O,m]of Object.entries(n.components?.schemas??{}))a[O]=s0(m,!1,e,[O],r,e.namespace);for(let[O,m]of Object.entries(n.channels??{}))if(u[O]||(u[O]={}),m.messages){for(let[P,D]of Object.entries(m.messages))if(e.isReferenceObject(D)||e.isMessageWithPayload(D))if(c[P]||(c[P]=[]),e.isReferenceObject(D)){let A=e.resolveMessageReference(D);c[P].push({channelId:O,payload:A.payload})}else c[P].push({channelId:O,payload:D.payload})}for(let[O,m]of Object.entries(c))if(m.length===1){let P=m[0],D=P.channelId;u[D]=u[D]||{},u[D][O]=s0(P.payload,!1,e,[O],r,e.namespace)}else{d.push(O);for(let{channelId:P,payload:D}of m){let A=`${P}_${O}`;u[P]||(u[P]={}),u[P][A]=s0(D,!1,e,[A],r,e.namespace)}}let o=Object.values(u).reduce((O,m)=>({...O,...m}),{}),l=new SKn(o,e),b={};for(let[O,m]of Object.entries(n.servers??{}))b[O]={name:O,url:Dau(m.protocol,m.host)};let g={};for(let[O,m]of Object.entries(n.operations??{})){if(hf(m,Fee.IGNORE))continue;let P=$CE(m);if(g[P]||(g[P]={subscribe:[],publish:[],__parsedMessages:[]}),m.action==="receive")g[P].subscribe.push(...m.messages);else if(m.action==="send")g[P].publish.push(...m.messages);else throw new Error(`Operation ${O} has an invalid action: ${m.action}`)}for(let[O,m]of Object.entries(g)){let P=[];P.push(...xj_({messages:m.subscribe,channelPath:O,origin:"server",messageSchemas:u[O]??{},duplicatedMessageIds:d,context:e})),P.push(...xj_({messages:m.publish,channelPath:O,origin:"client",messageSchemas:u[O]??{},duplicatedMessageIds:d,context:e})),g[O]!=null&&(g[O].__parsedMessages=P)}for(let[O,m]of Object.entries(n.channels??{})){if(hf(m,Fee.IGNORE))continue;let P=[],D=[],A=[];if(m.parameters!=null)for(let[M,E]of Object.entries(m.parameters)){let T=e.isReferenceObject(E)?e.resolveParameterReference(E):E,{type:z,parameterKey:$}=T.location!=null?GCE(T.location):{type:m.address?.includes(`={${M}}`)?"query":"path",parameterKey:M},I=hf(T,Fee.FERN_PARAMETER_OPTIONAL),N=eI(F_(O))+eI(F_(M)),U={...T,type:"string",title:N,example:T.examples?.[0],default:T.default,enum:T.enum,required:void 0},Y=s0(U,!1,e,[$],r,e.namespace);I&&(Y=Nl.optional({value:Y,description:void 0,availability:void 0,generatedName:"",title:N,namespace:void 0,groupName:void 0,nameOverride:void 0,inline:void 0}));let J={name:$,description:T.description,parameterNameOverride:void 0,schema:Y,variableReference:void 0,availability:UK(E),source:r};z==="header"?P.push({...J,env:void 0}):z==="path"?D.push(J):(z==="payload"||z==="query")&&A.push(J)}if(P.length>0||A.length>0||g[O]!=null&&(g[O].publish!=null||g[O].subscribe!=null)){let M=Sau(m),E=g[O]?.__parsedMessages??[],T=[];if(M.length>0)T=l.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:M,handshake:{headers:P,queryParameters:A},source:r,namespace:e.namespace});else{let z=[],{examplePublishMessage:$,exampleSubscribeMessage:I}=JCE({messages:E,messageSchemas:u[O]??{}});$!=null&&z.push($),I!=null&&z.push(I);let N=l.buildWebsocketSessionExample({handshake:{headers:P,queryParameters:A},messages:z});N!=null&&T.push(N)}s[O]={audiences:hf(m,ad.AUDIENCES)??[],handshake:{headers:P.map(z=>({...z,schema:DA(z.schema),env:z.env})),queryParameters:A.map(z=>({...z,schema:DA(z.schema)})),pathParameters:D.map(z=>({...z,parameterNameOverride:void 0,schema:DA(z.schema)}))},groupName:e.resolveGroupName([hf(m,Fee.FERN_SDK_GROUP_NAME)??O]),messages:E,summary:hf(m,Fee.FERN_DISPLAY_NAME),servers:m.servers?.map(z=>QCE(b,z))??Object.values(b),path:m.address?.split("?")[0]??Eau(O),description:m.description,examples:T,source:r}}}return{groupedSchemas:wKn(e.namespace,a),channels:s,servers:Object.values(b),basePath:hf(n,Fee.BASE_PATH)}}function $CE(e){if(!e.channel.$ref.startsWith(Ij_))throw new Error(`Failed to resolve channel path from operation ${e.channel.$ref}`);return e.channel.$ref.substring(Ij_.length)}function GCE(e){try{let[t,r]=e.split("#/");if(t==null||r==null)throw new Error(`Invalid location format: ${e}; unable to parse message type and parameter key`);if(!t.startsWith(K1c))throw new Error(`Invalid location format: ${e}; expected ${K1c} prefix`);let i=t.substring(K1c.length);if(i!=="header"&&i!=="path"&&i!=="payload")throw new Error(`Invalid message type: ${i}. Must be one of: header, path, payload`);return{type:i,parameterKey:r}}catch{throw new Error(`Invalid location format: ${e}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`)}}function QCE(e,t){if(!t.$ref.startsWith(zj_))throw new Error(`Failed to resolve server name from server ref ${t.$ref}`);let r=t.$ref.substring(zj_.length),i=e[r];if(i==null)throw new Error(`Failed to find server with name ${r}`);return i}function xj_({messages:e,channelPath:t,origin:r,messageSchemas:i,duplicatedMessageIds:n,context:a}){let u=[];return e.forEach((c,d)=>{let o=a.resolveMessageReference(c).name;n.includes(o)&&(o=`${t}_${o}`);let l=i[o];l!=null&&u.push({origin:r,name:o??`${r}Message${d+1}`,body:DA(l)})}),u}function JCE({messages:e,messageSchemas:t}){let r=e.find(u=>u.origin==="client")?.name,i=e.find(u=>u.origin==="server")?.name,n=r!=null?t[r]:void 0,a=i!=null?t[i]:void 0;return{examplePublishMessage:n!=null&&r!=null?{type:r,payload:n}:void 0,exampleSubscribeMessage:a!=null&&i!=null?{type:i,payload:a}:void 0}}function Nj_({document:e,taskContext:t,options:r,source:i,asyncApiOptions:n,namespace:a}){let u=[];if(a!=null&&u.push(a),parseFloat(e.asyncapi)<3){let c=e;c.tags?.[0]!=null?u.push(c.tags[0].name):n.naming!=="v2"&&u.push("websocket");let d=new Pau({document:c,taskContext:t,options:r,namespace:a});return Bj_({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:c})}else{let c=e,d=new Mau({document:c,taskContext:t,options:r,namespace:a});return Rj_({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:c})}}function Fj_(e){return hf(e,ad.ASYNC_CONFIG)}var Lj_="$request.";function Uj_(e){let t=hf(e,ad.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",streamDescription:t["stream-description"],streamConditionProperty:KCE(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function KCE(e){return e.startsWith(Lj_)?e.slice(Lj_.length):e}function Vj_(e){let t=e;if(t.cursor!=null)return DFe.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});if("offset"in e){let r=e;return DFe.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}if("type"in e&&e.type==="custom"){let r=e;return DFe.custom({results:r.results})}throw new Error("Invalid pagination extension")}function Wj_(e,t){let r=hf(t,ad.PAGINATION);if(r!=null){if(typeof r=="boolean"){let i=hf(e,ad.PAGINATION);if(typeof i=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return i==null?void 0:Vj_(i)}return Vj_(r)}}function Hj_(e){let t=YCE(e),r={};return Y1c({obj:t,occurrences:r,breadcrumbs:[]}),r}function Y1c({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let i of e)Y1c({obj:i,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let i=e.$ref;t[i]==null?t[i]=1:t[i]+=1;return}for(let i in e)Y1c({obj:e[i],occurrences:t,breadcrumbs:[...r,i]})}}}function YCE(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?F5a(r.get):void 0,put:r?.put!=null?F5a(r.put):void 0,post:r?.post!=null?F5a(r.post):void 0,patch:r?.patch!=null?F5a(r.patch):void 0,delete:r?.delete!=null?F5a(r.delete):void 0}]))}}function F5a(e){return{...e,requestBody:e.requestBody!=null?tp(e.requestBody)?e.requestBody:XCE(e.requestBody):void 0}}function XCE(e){let t,r;for(let i in e.content){let n=Uq.parse(i);n!=null&&(n.isJSON()?t=e.content[i]:n.isMultipart()&&(r=e.content[i]))}return r!=null&&t!=null?{...e,content:{[Uq.MULTIPART_FORM_DATA]:r}}:e}var Aau=class{endpoints;parser=new Pen;constructor({context:t,options:r}){this.endpoints=r.filter?.endpoints?new Set(this.validateAndFilterEndpoints({context:t,endpoints:r.filter.endpoints})):void 0}skipEndpoint({method:t,path:r}){return this.endpoints!=null&&!this.endpoints.has(`${t} ${r}`)}hasEndpoints(){return this.endpoints!=null}validateAndFilterEndpoints({context:t,endpoints:r}){let i=[];for(let n of r){let a=this.parser.tryParse(n);if(a==null){t.logger.debug(`Ignoring configured filter endpoint "${n}"; expected format "POST /users/get"`);continue}i.push(`${a.method} ${a.path}`)}return i}};var $j_="#/components/parameters/",Gj_="#/components/responses/",Qj_="#/components/examples/",Jj_="#/components/requestBodies/",DKn=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=i,this.refOccurrences=Hj_(t),this.options=n,this.source=a,this.filter=new Aau({context:r,options:n}),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 i={type:"namespace",name:this.namespace};r.push(i)}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(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return{"x-fern-type":"unknown"};if(Array.isArray(i)){let a=parseInt(n,10);if(isNaN(a)||a<0||a>=i.length)return{"x-fern-type":"unknown"};i=i[a]}else i=i[n]}return i==null?(this.logger.warn(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):(tp(i)&&(i=this.resolveSchemaReference(i)),i)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith($j_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring($j_.length),i=this.document.components.parameters[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return tp(i)?this.resolveParameterReference(i):i}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(Jj_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(Jj_.length),i=this.document.components.requestBodies[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return tp(i)?this.resolveRequestBodyReference(i):i}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(Gj_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(Gj_.length),i=this.document.components.responses[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return tp(i)?this.resolveResponseReference(i):i}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(Qj_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(Qj_.length),i=this.document.components.examples[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return tp(i)?this.resolveExampleReference(i):i}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}};var Qnn=class extends DKn{constructor({document:t,taskContext:r,options:i,source:n,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:i,source:n,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,i){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,i){}getDiscriminatedUnionMetadata(t){}};var ZCE=ou.object({lang:ou.string(),label:ou.optional(ou.string()),source:ou.string()}),X1c=ou.array(ZCE);var Kj_={README_EXT:"x-readme"};function kCE(e){if(!Array.isArray(e))return!1;for(let t of e)if(!Rw(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function Yj_(e){let t=hf(e,Kj_.README_EXT);if(!Rw(t))return[];let r=t["code-samples"];if(!kCE(r))return[];let i=[];for(let n of r)i.push({name:n.name,language:n.language,code:n.code,install:n.install,docs:void 0});return i}function Xj_(e,t,r){let n=(hf(t,ad.EXAMPLES)??[]).filter(s=>{let o=i7.serialization.ExampleEndpointCallSchema.parse(s);return o.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),o.ok}),a=z5a(t,M$.REDOCLY_CODE_SAMPLES_KEBAB,X1c,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],c=[...z5a(t,M$.REDOCLY_CODE_SAMPLES_CAMEL,X1c,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];c.length>0&&n.push({"code-samples":c.map(s=>({name:s.label??s.lang,language:s.lang,code:s.source,install:void 0,docs:void 0}))});let d=Yj_(t);return d.length>0&&n.push({"code-samples":d}),n.map(UQt.unknown)}function Zj_(e){let t=hf(e,ad.AVAILABILITY);if(t==="ga"||t==="generally-available")return S$.GenerallyAvailable;if(t==="beta"||t==="pre-release")return S$.Beta;if(t==="deprecated")return S$.Deprecated;if(e.deprecated)return S$.Deprecated}function qau(e){return{url:eBE({url:e.url,variables:e.variables??{}}),description:e.description,name:tBE(e),audiences:hf(e,ad.AUDIENCES)}}function eBE({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,n.default]));for(let[i,n]of Object.entries(r))e=e.replace(`{${i}}`,encodeURIComponent(n));return e}function tBE(e){let t=hf(e,[ad.SERVER_NAME_V1,ad.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function kj_(e){return hf(e,ad.PARAMETER_NAME)}function ew_(e){return hf(e,ad.SDK_VARIABLE)}function Tau({path:e,httpMethod:t,parameters:r,context:i,requestBreadcrumbs:n,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let c of r){let d=hf(c,ad.IGNORE);if(d!=null&&d){i.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=tp(c)?i.resolveParameterReference(c):c,o=s.required??!1,l=UK(s),b=[...n,s.name],g=S5(b,i.options.preserveSchemaIds),O=s.schema!=null?s0(s.schema,!o,i,b,a,i.namespace,!1,new Set,vor({schema:s,logger:i.logger})):o?Nl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:bp.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:vor({schema:s,logger:i.logger})}),description:void 0,availability:l,namespace:void 0,groupName:void 0}):Nl.optional({nameOverride:void 0,generatedName:g,title:void 0,value:Nl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:bp.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:vor({schema:s,logger:i.logger})}),description:void 0,availability:void 0,namespace:void 0,groupName:void 0}),description:void 0,availability:l,namespace:void 0,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!tp(s.schema)&&s.schema.default!=null){let P=s.schema.default;typeof P=="string"&&P.length>0&&(O=Nl.literal({nameOverride:void 0,generatedName:g,title:void 0,value:mx.string(P),description:void 0,availability:l,namespace:void 0,groupName:void 0}))}let m={name:s.name,schema:O,description:s.description,parameterNameOverride:kj_(s),availability:l,source:a};s.in==="query"?u.queryParameters.push(m):s.in==="path"?u.pathParameters.push({...m,variableReference:ew_(s)}):s.in==="header"?!rBE.has(s.name.toLowerCase())&&!i.authHeaders.has(s.name)?u.headers.push({...m,env:void 0}):i.logger.debug(`Ignoring ${s.name} header, in ${t.toUpperCase()} ${e}`):i.logger.warn(`Skipping ${s.in} parameter, ${s.name}, in ${t.toUpperCase()} ${e}`)}return u}var rBE=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function tw_(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r,schema:n??{},examples:L5a(i,t)}}}function iBE(e){return e.includes("json")||e==="*/*"}function Z1c({content:e,context:t}){for(let[r,i]of Object.entries(e))if(Cau({mediaType:r,mediaTypeObject:i,context:t})!=null)return[r,i]}function Cau({mediaType:e,mediaTypeObject:t,context:r}){if(!iBE(e))return;let i=t.schema;return{contentType:e.includes("*")?void 0:e,schema:i??{},examples:L5a(t,r)}}function Bau({content:e,context:t}){let r=Z1c({content:e,context:t});if(!r)return;let[i,n]=r;return Cau({mediaType:i,mediaTypeObject:n,context:t})}function rw_(e,t){for(let r of Object.keys(e)){let i=e[r];if(i==null)continue;return{schema:i.schema??{},examples:L5a(i,t)}}}function L5a(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let i=hf(e,M$.EXAMPLES);return i!=null&&Object.keys(i).length>0&&r.push(...Object.entries(i).map(([n,a])=>({name:a.summary??n,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([n,a])=>{let u=tp(a)?t.resolveExampleReference(a):a;return{name:u.summary??n,value:u.value,description:u.description}})),r}function nBE({content:e,context:t}){for(let[r,i]of Object.entries(e))if(nw_({mediaType:r,mediaTypeObject:i,context:t}))return[r,i]}function nw_({mediaType:e,mediaTypeObject:t,context:r}){if(Uq.parse(e)?.isURLEncoded())return{schema:t.schema,contentType:e,examples:L5a(t,r)}}function aBE({content:e}){for(let[t,r]of Object.entries(e))if(aw_({mediaType:t,mediaTypeObject:r}))return[t,r]}function aw_({mediaType:e,mediaTypeObject:t}){if(Uq.parse(e)?.isMultipart())return{schema:t.schema,encoding:t.encoding}}function ow_({mediaType:e}){return Uq.parse(e)?.isBinary()??!1}function oBE({content:e}){for(let[t,r]of Object.entries(e))if(ow_({mediaType:t}))return[t,r]}function uBE(e,t){let r=tp(e)?k1c(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([i,n])=>!tp(n)&&n.type==="string"&&n.format==="binary")!=null}function zau({content:e,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u}){let c=oBE({content:e});if(c){let[b,g]=c;return bor({mediaType:b,mediaTypeObject:g,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u})}let d=aBE({content:e}),s=Z1c({content:e,context:i}),o=sBE({json:s,multipart:d,document:r,visitor:{json:([b,g])=>bor({mediaType:b,mediaTypeObject:g,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u}),multipart:([b,g])=>bor({mediaType:b,mediaTypeObject:g,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u}),neither:()=>{}}});if(o)return o;let l=nBE({content:e,context:i});if(l){let[b,g]=l;return bor({mediaType:b,mediaTypeObject:g,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u})}}function sBE({json:e,multipart:t,document:r,visitor:i}){if(!e&&!t)return i.neither();let[,n]=e??[void 0,void 0],[,a]=t??[void 0,void 0];return!n?.schema&&!a?.schema?i.neither():n?.schema&&a?.schema?n.schema&&uBE(n.schema,r)?i.multipart(t):i.json(e):n?.schema?i.json(e):a?.schema?i.multipart(t):i.neither()}function bor({mediaType:e,mediaTypeObject:t,description:r,document:i,context:n,requestBreadcrumbs:a,source:u,namespace:c}){let d=cBE({mediaTypeObject:t});if(ow_({mediaType:e}))return zee.octetStream({description:r,source:u,sdkMethodName:d,contentType:e});let s=aw_({mediaType:e,mediaTypeObject:t}),o=s?.schema,l=s?.encoding;if(o){let O=tp(o)?k1c(o,i):{id:void 0,schema:o},m=s0(O.schema,!1,n,a,u,c,!1),P=[];if(m.type==="object")for(let D of m.properties){let{isFile:A,isOptional:M,isArray:E,description:T}=Iau({schema:D.schema});if(A){let z=iw_(D.key,l);P.push({key:D.key,schema:Umi.file({isOptional:M,isArray:E,description:T}),description:T,contentType:z,exploded:!1,encoding:z==null?n.options.defaultFormParameterEncoding:void 0})}else{let z=iw_(D.key,l);P.push({key:D.key,schema:Umi.json(D.schema),description:void 0,contentType:z,exploded:l?.[D.key]?.explode,encoding:z==null?n.options.defaultFormParameterEncoding:fBE(z)})}}return zee.multipart({name:tp(o)&&n.getNumberOfOccurrencesForRef(o)===1?O.id:void 0,description:O.schema.description,properties:P,source:u,sdkMethodName:d})}let b=Cau({mediaType:e,mediaTypeObject:t,context:n});if(b){let O=s0(b.schema,!1,n,a,u,c,!0);return zee.json({description:void 0,schema:O,contentType:b.contentType,fullExamples:b.examples,additionalProperties:!tp(b.schema)&&gKn(b.schema.additionalProperties,n.options),source:u,sdkMethodName:d})}let g=nw_({mediaType:e,mediaTypeObject:t,context:n});if(g!=null&&g.schema!=null){let O=s0(g.schema,!1,n,a,u,c,!1);return zee.formUrlEncoded({schema:O,description:r,contentType:g.contentType,source:u,fullExamples:g.examples,additionalProperties:!1,sdkMethodName:d})}}function cBE({mediaTypeObject:e}){return hf(e,ad.SDK_METHOD_NAME)}var lBE={"application/json":"json"};function fBE(e){return e?lBE[e]:void 0}function k1c(e,t){if(!e.$ref.startsWith(Gnn))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=zNi(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let i=t.components?.schemas?.[r];if(i==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return tp(i)?k1c(i,t):{id:r,schema:i}}function Iau({schema:e,isOptional:t,isArray:r,description:i}){return pBE(e)?Iau({schema:e.value,isOptional:!0,isArray:r,description:e.description}):_BE(e)?Iau({schema:e.value,isOptional:t,isArray:r,description:e.description}):hBE(e)?Iau({schema:e.value,isOptional:t,isArray:!0,description:e.description}):dBE(e)?{isFile:!0,isOptional:t??!1,isArray:r??!1,description:i??e.description}:{isFile:!1,isOptional:t??!1,isArray:r??!1,description:void 0}}function dBE(e){return e.type==="primitive"&&e.schema.type==="string"&&e.schema.format==="binary"}function pBE(e){return e.type==="optional"}function _BE(e){return e.type==="nullable"}function hBE(e){return e.type==="array"}function iw_(e,t){return t?.[e]?.contentType}var eSc={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",498:"InvalidTokenError",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"},uw_=new Set(Object.values(eSc));var yBE=["200","201","202","204"];function cw_({operationContext:e,responses:t,context:r,responseBreadcrumbs:i,responseStatusCode:n,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let c=vBE({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,s;for(let o of n!=null?[n]:yBE){let l=t[o];l!=null&&(d=!0,s==null&&(s=sw_({operationContext:e,response:l,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace,statusCode:typeof o=="string"?parseInt(o):o})))}if(s==null&&!d&&t.default!=null&&(s=sw_({operationContext:e,response:t.default,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:c};case"streamingJson":case"streamingSse":return{value:s,errors:c};case"bytes":case"file":case"text":case"streamingText":return{value:s,errors:c};default:Ao(s)}return{value:void 0,errors:c}}function sw_({operationContext:e,streamFormat:t,response:r,context:i,responseBreadcrumbs:n,source:a,namespace:u,statusCode:c}){let d=tp(r)?i.resolveResponseReference(r):r;if(d.content!=null&&Object.entries(d.content).find(([b,g])=>{if(g.schema==null)return!1;let O=tp(g.schema)?i.resolveSchemaReference(g.schema):g.schema;return O.type==="string"&&O.format==="binary"}))return i.options.useBytesForBinaryResponse&&t==null?EB.bytes({description:d.description,source:a,statusCode:c}):EB.file({description:d.description,source:a,statusCode:c});let s=tw_(d.content??{},i);if(s!=null&&t!=null)switch(t){case"json":return EB.streamingJson({statusCode:c,description:d.description,responseProperty:hf(e.operation,ad.RESPONSE_PROPERTY),fullExamples:s.examples,schema:s0(s.schema,!1,i,n,a,u),source:a});case"sse":return EB.streamingSse({description:d.description,responseProperty:void 0,fullExamples:s.examples,schema:s0(s.schema,!1,i,n,a,u),source:a,statusCode:c})}let o=Bau({context:i,content:d.content??{}});if(o){if(t!=null)switch(t){case"json":return EB.streamingJson({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:s0(o.schema,!1,i,n,a,u),source:a,statusCode:c});case"sse":return EB.streamingSse({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:s0(o.schema,!1,i,n,a,u),source:a,statusCode:c})}return EB.json({description:d.description,schema:s0(o.schema,!1,i,n,a,u),responseProperty:hf(e.operation,ad.RESPONSE_PROPERTY),fullExamples:o.examples,source:a,statusCode:c})}for(let[l,b]of Object.entries(d.content??{})){let g=Uq.parse(l);if(g!=null){if(g.isOctetStream()||g.isPDF()||g.isAudio()||g.isImage()||g.isVideo()||g.isMultiPartMixed())return EB.file({description:d.description,source:a,statusCode:c});if(g.isPlainText()){let O=b.schema;if(O==null)return EB.text({description:d.description,source:a,statusCode:c});let m=tp(O)?i.resolveSchemaReference(O):O;return m.type==="string"&&m.format==="byte"?EB.file({description:d.description,source:a,statusCode:c}):EB.text({description:d.description,source:a,statusCode:c})}}}}function vBE({responses:e,context:t,source:r,namespace:i}){let n={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let c=parseInt(a);if(c<400||c>600)continue;let d=tp(u)?t.resolveResponseReference(u):u,s=rw_(d.content??{},t),o=eSc[c];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}n[c]={statusCode:c,nameOverride:void 0,generatedName:o,description:d.description,schema:s0(s?.schema??{},!1,t,[o,"Body"],r,i),fullExamples:s?.examples,source:r}}return n}function Qmi({operationContext:e,context:t,responseStatusCode:r,suffix:i,streamFormat:n,source:a}){let{document:u,operation:c,path:d,method:s,baseBreadcrumbs:o}=e,l=hf(c,ad.IDEMPOTENT),b=hf(c,[ad.REQUEST_NAME_V1,ad.REQUEST_NAME_V2]),g=[...o,"Request"],O=Tau({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:g,path:d,httpMethod:s,source:a}),m=/{([^}]+)}/g,D=[...d.matchAll(m)].map(I=>I[1]).filter(I=>!O.pathParameters.some(N=>N.name===I));if(D.length>0)for(let I of D)O.pathParameters.push({name:I??"",variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:Nl.primitive({schema:bp.string({default:void 0,example:void 0,format:void 0,maxLength:void 0,minLength:void 0,pattern:void 0}),description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0,availability:void 0,title:void 0}),description:void 0});let A=(()=>{if(e.method==="GET")return[void 0];if(!c.requestBody)return[void 0];let I=tp(c.requestBody)?t.resolveRequestBodyReference(c.requestBody):c.requestBody,N=Object.values(I.content).every(Y=>bBE({mediaTypeObject:Y})!=null),U=[];if(N)return U.push(...Object.entries(I.content).map(([Y,J])=>{let X=bor({mediaType:Y,mediaTypeObject:J,description:I.description,document:u,context:new Qnn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:g,source:a,namespace:t.namespace});return lw_({context:t,convertedParameters:O})&&X!=null&&(X.type==="json"||X.type==="formUrlEncoded")&&X.schema.type!=="object"&&c.requestBody!=null?X=bor({mediaType:Y,mediaTypeObject:J,description:I.description,document:u,context:t,requestBreadcrumbs:[...g,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(X=bor({mediaType:Y,mediaTypeObject:J,description:I.description,document:u,context:t,requestBreadcrumbs:[...g],source:a,namespace:t.namespace})),X}).filter(Y=>Y!=null)),U.length===0?[void 0]:U;{let Y=zau({content:I.content,description:I.description,document:u,context:new Qnn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:g,source:a,namespace:t.namespace});return lw_({context:t,convertedParameters:O})&&Y!=null&&(Y.type==="json"||Y.type==="formUrlEncoded")&&Y.schema.type!=="object"&&c.requestBody!=null?Y=zau({content:I.content,description:I.description,document:u,context:t,requestBreadcrumbs:[...g,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(Y=zau({content:I.content,description:I.description,document:u,context:t,requestBreadcrumbs:[...g],source:a,namespace:t.namespace})),[Y]}})(),M=[...o,"Response"],E=cw_({operationContext:e,streamFormat:n,responses:c.responses,context:t,responseBreadcrumbs:M,responseStatusCode:r,source:a}),T=Zj_(c),z=Xj_(e,c,t),$=hf(c,ad.SERVER_NAME_V2);return A.map(I=>({summary:c.summary,internal:hf(c,M$.INTERNAL),idempotent:l,audiences:hf(c,ad.AUDIENCES)??[],operationId:c.operationId!=null&&i!=null?c.operationId+"_"+i:c.operationId,tags:t.resolveTagsToTagIds(c.tags),namespace:t.namespace,sdkName:gBE({operationContext:e,request:I}),pathParameters:O.pathParameters,queryParameters:O.queryParameters,headers:O.headers,requestNameOverride:b??void 0,generatedRequestName:S5(g,t.options.preserveSchemaIds),request:I,response:E.value,errors:E.errors,servers:$!=null?[{name:$,url:void 0,audiences:void 0}]:(c.servers??[]).map(N=>qau(N)),description:c.description,authed:OBE(c,u),availability:T,method:s,path:d,examples:z,pagination:e.pagination,source:a}))}function bBE({mediaTypeObject:e}){return hf(e,ad.SDK_METHOD_NAME)}function gBE({operationContext:e,request:t}){return!t||!t.sdkMethodName?e.sdkMethodName:e.sdkMethodName?{groupName:[...e.sdkMethodName.groupName],methodName:t.sdkMethodName??e.sdkMethodName.methodName}:{groupName:[],methodName:t.sdkMethodName}}function OBE(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function lw_({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function dw_({operationContext:e,context:t,asyncExtension:r,source:i}){let{operation:n,pathItemParameters:a,operationParameters:u}=e,c=r.discriminant.name,d=r.discriminant.value,s=r["response-status-code"],o=fw_({context:t,headerToIgnore:c,parameters:a}),l=fw_({context:t,headerToIgnore:c,parameters:u}),b=Qmi({operationContext:{...e,pathItemParameters:o,operationParameters:l,operation:{...n,responses:Object.fromEntries(Object.entries(n.responses).filter(([O])=>parseInt(O)!==s))}},context:t,streamFormat:void 0,source:i}),g=Qmi({operationContext:{...e,pathItemParameters:o,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:i});return g.forEach(O=>{O.headers.push({name:c,schema:Nl.literal({nameOverride:void 0,generatedName:S5([c],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:mx.string(d),namespace:void 0,groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:i})}),{sync:b,async:g}}function fw_({context:e,headerToIgnore:t,parameters:r}){return r.filter(i=>{let n=tp(i)?e.resolveParameterReference(i):i;return!(n.in==="header"&&n.name===t)})}var tSc="stream";function yw_({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:Qmi({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:[]};case"streamCondition":{let i=pw_({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(i?.schemaReference!=null){let s=zNi(i.schemaReference);s!=null&&t.excludeSchema(s)}let n=_w_({operation:e.operation,response:r.responseStream}),a=Qmi({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+tSc}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:i?.requestBody,responses:n},baseBreadcrumbs:[...e.baseBreadcrumbs,tSc]},context:t,streamFormat:r.format,suffix:tSc,source:t.source});a.forEach(s=>{s.examples=s.examples.filter(o=>hw_(o,t)!==!1)});let u=pw_({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),c=_w_({operation:e.operation,response:r.response}),d=Qmi({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:c}},context:t,source:t.source});return d.forEach(s=>{s.examples=s.examples.filter(o=>hw_(o,t)!==!0)}),{streaming:a,nonStreaming:d}}default:Ao(r)}}function pw_({context:e,operation:t,streamingExtension:r,isStreaming:i}){if(t.requestBody==null)return;let n=tp(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=Bau({content:n.content,context:e});if(a==null)return;let u=tp(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let c=u.properties?.[r.streamConditionProperty];c!=null&&tp(c)&&(c=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":i,...c??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[Uq.APPLICATION_JSON]:{schema:d}}},schemaReference:tp(a.schema)?a.schema:void 0}}function _w_({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[Uq.APPLICATION_JSON]:{schema:t}}}}}function hw_(e,t){return e._visit({unknown:r=>{let i=i7.serialization.ExampleEndpointCallSchema.parse(r);if(i.ok&&i.value.response!=null)return i.value.response.stream!=null},full:()=>{},_other:()=>{}})}function vw_({context:e,operationContext:t,source:r}){let{document:i,operation:n,path:a,method:u,baseBreadcrumbs:c,sdkMethodName:d}=t,s=[...c,"Payload"],o=Tau({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:u,source:r});if(n.requestBody==null)return e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Missing a request body`),[];let l=n.operationId;if(l==null)return e.logger.error(`Skipping webhook ${a} because no operation id present`),[];if(u!=="POST"&&u!=="GET")return e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Not POST or GET`),[];let b=tp(n.requestBody)?e.resolveRequestBodyReference(n.requestBody):n.requestBody;return Object.entries(b.content).map(([g,O])=>bor({mediaType:g,mediaTypeObject:O,description:b.description,document:i,context:e,requestBreadcrumbs:[...c,"Payload"],source:r,namespace:e.namespace})).filter(g=>g!=null).map(g=>{if(g==null||g.type!=="json"&&g.type!=="formUrlEncoded"){e.logger.error(`Skipping webhook ${a} because non-json and non-formUrlEncoded request body`);return}return{summary:n.summary,audiences:hf(n,ad.AUDIENCES)??[],sdkName:d,namespace:e.namespace,method:u,operationId:l,tags:e.resolveTagsToTagIds(n.tags),headers:o.headers,generatedPayloadName:S5(s,e.options.preserveSchemaIds),payload:g.schema,description:n.description,examples:mBE(g.fullExamples),source:r}}).filter(g=>g!=null)}function mBE(e){if(e==null)return[];let t=[];for(let r of e){let i=RNi(r.value);i!=null&&t.push({description:r.description,name:r.name,payload:i})}return t}function rSc({context:e,pathItemContext:t,operation:r,convertToWebhook:i}){let n=hf(r,ad.IGNORE);if(n!=null&&n){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=PBE(r,e),u=Wj_(e.document,r),c={...t,sdkMethodName:a,baseBreadcrumbs:jBE({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path,shouldUseIdiomaticRequestNames:e.options.shouldUseIdiomaticRequestNames}),operation:r,operationParameters:r.parameters??[],pagination:u};if(i)return{type:"webhook",value:vw_({context:e,operationContext:c,source:e.source})};let d=Uj_(r);if(d!=null){let l=yw_({context:e,operationContext:c,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let s=Fj_(r);if(s!=null){let l=dw_({context:e,operationContext:c,asyncExtension:s,source:e.source});return{type:"async",async:l.async,sync:l.sync}}return{type:"http",value:Qmi({context:e,operationContext:c,streamFormat:void 0,source:e.source})}}function PBE(e,t){let r=hf(e,ad.SDK_METHOD_NAME),i=hf(e,ad.SDK_GROUP_NAME)??[];if(r!=null){let n=typeof i=="string"?[i]:i;return n=t.resolveGroupName(n),{groupName:n,methodName:r}}}function jBE({sdkMethodName:e,operation:t,httpMethod:r,path:i,shouldUseIdiomaticRequestNames:n}){let a=[];if(e!=null){if(n&&a.push(e.methodName),e.groupName.length>0){let u=e.groupName[e.groupName.length-1];u!=null&&a.push(typeof u=="string"?u:u.name)}n||a.push(e.methodName)}else t.operationId!=null?a.push(t.operationId):a.push(F_(`${r}_${i.split("/").join("_")}`));return a}function bw_(e,t,r,i){let n=[],a=Ow_(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(i.filter.skipEndpoint({method:c.method,path:e})){i.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=wBE({operation:c.operation}),s=rSc({context:i,pathItemContext:{...u,method:c.method},operation:c.operation,convertToWebhook:d});s&&n.push(s)}return n}function gw_(e,t,r,i){let n=[],a=Ow_(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(i.filter.skipEndpoint({method:c.method,path:e})){i.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=rSc({context:i,pathItemContext:{...u,method:c.method},operation:c.operation,convertToWebhook:!0});d&&n.push(d)}return n}function Ow_(e){let t=[];return e.get!=null&&t.push({method:E$.Get,operation:e.get}),e.post!=null&&t.push({method:E$.Post,operation:e.post}),e.put!=null&&t.push({method:E$.Put,operation:e.put}),e.delete!=null&&t.push({method:E$.Delete,operation:e.delete}),e.patch!=null&&t.push({method:E$.Patch,operation:e.patch}),e.head!=null&&t.push({method:E$.Head,operation:e.head}),t}function wBE({operation:e}){return hf(e,[ad.WEBHOOK])??!1}function mw_(e){let t=hf(e,ad.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=hf(e,ad.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function Pw_(e){return hf(e,ad.FERN_BASIC_AUTH)}function iSc(e,t){if(tp(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return SBE(e,t)}function SBE(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=hf(e,M$.BEARER_FORMAT),i=hf(e,ad.FERN_HEADER_AUTH);return AU.header({headerName:e.name,prefix:r!=null?"Bearer":i?.prefix,headerVariableName:i?.name??hf(e,ad.HEADER_VARIABLE_NAME),headerEnvVar:i?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="bearer"){let r=hf(e,ad.FERN_BEARER_TOKEN);return AU.bearer({tokenVariableName:r?.name??hf(e,ad.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="basic"){let r=Pw_(e),i=mw_(e);return AU.basic({usernameVariableName:r?.username?.name??i.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??i.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return AU.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return AU.oauth({scopesEnum:DBE(e,t)})}}function DBE(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let i=INi({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([a,u])=>[a,{description:u}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsNullable:!1,namespace:void 0,groupName:void 0,context:void 0,source:t,inline:void 0}),n=DA(i);if(n.type==="enum")return n}}function jw_(e){return hf(e,ad.BASE_PATH)}var EBE=ou.record(ou.string(),ou.object({summary:ou.string().optional(),description:ou.string().optional()}));function ww_({document:e,context:t}){return z5a(e,ad.GROUPS,EBE,t.logger)}function Sw_({context:e,document:t}){return hf(t,ad.FERN_VERSION)??void 0}function Dw_(e){let t=hf(e,ad.FERN_GLOBAL_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?x5a({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function Ew_(e){let t=hf(e,ad.FERN_IDEMPOTENCY_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?x5a({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function Mw_(e,t){let r=hf(e,ad.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([i,n])=>{if(n.type==="string")return[i,{nameOverride:void 0,generatedName:S5([i],t),title:n.title,schema:Ww.string({default:mKn(n),pattern:n.pattern,format:n.format,minLength:n.minLength,maxLength:n.maxLength}),description:n.description,availability:void 0,namespace:void 0,groupName:void 0}];throw new Error(`Variable ${i} has unsupported schema ${JSON.stringify(n)}`)}))}var MBE="webhooks";function Aw_(e){return hf(e,MBE)??{}}var xau=class extends DKn{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discriminatedUnionReferences={};discriminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u})}getDummy(){return new Qnn({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,i){let n=this.discriminatedUnionReferences[t.$ref];n!=null?(n.discriminants.add(r),n.numReferences+=i):this.discriminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:i}}getReferencesFromDiscriminatedUnion(t){return this.discriminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,i){let n=this.discriminatedUnionMetadata[t.$ref];n!=null?n.discriminants.set(r,i):this.discriminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,i]])}}getDiscriminatedUnionMetadata(t){return this.discriminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function qw_(e){return hf(e,ad.RESOLUTIONS)}function Tw_({openapi:e}){let t=qw_(e);if(t==null)return e;let r={};for(let i of t){let n=`#/components/schemas/${i.name}`;for(let a of i.resolutions)e=ABE({openapi:e,schemaReference:a,schemaName:i.name}),e=Cw_({openapi:e,replaceReference:a,schemaReference:n,replacedReferences:r}),r={...r,...Object.fromEntries(i.resolutions.map(u=>[n,u]))}}return e}function ABE({openapi:e,schemaReference:t,schemaName:r}){let i=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),n=e;for(let a of i){let u=n[a];if(u==null)return e;n=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=n,e}function Cw_({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:i}){let n=Object.keys(i).filter(d=>t.startsWith(d)).sort((d,s)=>s.length-d.length)[0];if(n!=null){let d=i[n];if(d!=null){let s=r.replace(n,d);return Cw_({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replaceAll("~1","/")),u=e;for(let d of a.slice(0,-1)){let s=u[d];if(s==null)return e;u=s}let c=a[a.length-1];return c==null||(u[c]={$ref:r}),e}function Iw_({openApi:e,taskContext:t,options:r,source:i,namespace:n}){e=Tw_({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([I,N])=>iSc(N,i)==null?[]:[I,iSc(N,i)])),u=new Set(...Object.entries(a).map(([I,N])=>N.type==="basic"||N.type==="bearer"?"Authorization":N.type==="header"?N.headerName:null)),c=Mw_(e,r.preserveSchemaIds),d=Dw_(e),s=Ew_(e),o=r.audiences??[],l=[],b=[],g=new xau({document:e,taskContext:t,authHeaders:u,options:r,source:i,namespace:n});g.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([I,N])=>{if(N==null)return;t.logger.debug(`Converting path ${I}`);let U=bw_(I,N,e,g);for(let Y of U){let J=Bw_({operation:Y});if(!(o.length>0&&!o.some(X=>J.includes(X))))switch(Y.type){case"async":l.push(...Y.sync),l.push(...Y.async);break;case"http":l.push(...Y.value);break;case"streaming":l.push(...Y.streaming),Y.nonStreaming&&l.push(...Y.nonStreaming);break;case"webhook":b.push(...Y.value);break;default:Ao(Y)}}}),Object.entries(Aw_(e)).forEach(([I,N])=>{if(N==null)return;t.logger.debug(`Converting path ${I}`);let U=gw_(I,N,e,g);for(let Y of U){let J=Bw_({operation:Y});o.length>0&&!o.some(X=>J.includes(X))||b.push(...Y.value)}});let O=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([I,N])=>{let U=hf(N,ad.SDK_NAMESPACE);if(!tp(N)){let Y=hf(N,ad.IGNORE);if(Y!=null&&Y)return[];if(uw_.has(I))return[I,s0({...N,"x-fern-type-name":`${I}Body`},!1,g,[I],i,U??n)]}return[I,s0(N,!1,g,[I],i,U??n)]}).filter(I=>I.length>0)),m=qBE(O,g,i),P=TBE(m,g),D={};for(let[I,N]of Object.entries(P)){let U=DA(N);g.isSchemaExcluded(I)||(D[I]=U,t.logger.debug(`Converted schema ${I}`))}let A=new NNi(P,g.nonRequestReferencedSchemas,g),M=b.map(I=>{let U=I.examples;if(!r.disableExamples&&U.length===0){let Y=A.buildExample({schema:I.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});Y!=null&&(U=[{name:void 0,description:void 0,payload:Y}])}return{...I,payload:DA(I.payload),examples:U}}),E=new wau(P,g,d),T=l.map(I=>{let N=I.examples,U=N;if(!r.disableExamples&&(N.length===0||N.every(N5a))){let X=E.buildEndpointExample(I);X.length>0&&(U=[...X,...N.filter(oe=>!N5a(oe))])}let Y=I.request,J=I.response;return{...I,request:Y?.type==="json"||Y?.type==="formUrlEncoded"?{...Y,schema:DA(Y.schema)}:Y,response:J?.type==="json"?{...J,schema:DA(J.schema)}:J,queryParameters:I.queryParameters.map(X=>({description:X.description,name:X.name,schema:DA(X.schema),parameterNameOverride:X.parameterNameOverride,availability:X.availability,source:X.source})),pathParameters:I.pathParameters.map(X=>({description:X.description,name:X.name,schema:DA(X.schema),parameterNameOverride:X.parameterNameOverride,variableReference:X.variableReference,availability:X.availability,source:X.source})),headers:I.headers.map(X=>({description:X.description,name:X.name,schema:DA(X.schema),parameterNameOverride:X.parameterNameOverride,env:X.env,availability:X.availability,source:X.source})),examples:U,errors:Dd(I.errors,X=>{let oe=X.fullExamples?.map(pe=>{let de=RNi(pe.value);if(de!=null)return{name:pe.name,description:pe.description,example:de}}).filter(bv);if(oe?.length===0){let pe=A.buildExample({schema:X.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});pe!=null&&oe.push({name:void 0,description:void 0,example:pe})}return{generatedName:X.generatedName,nameOverride:X.nameOverride,schema:DA(X.schema),description:X.description,source:X.source,examples:oe}})}}),z=ww_({document:e,context:g});return{apiVersion:Sw_({context:g,document:e}),basePath:jw_(e),title:e.info.title??"",description:e.info.description,groups:Object.fromEntries(Object.entries(z??{}).map(([I,N])=>[I,{summary:N.summary??void 0,description:N.description??void 0}])),servers:(e.servers??[]).map(I=>qau(I)),websocketServers:[],tags:{tagsById:Object.fromEntries((e.tags??[]).map(I=>[I.name,{id:I.name,description:I.description}])),orderedTagIds:e.tags?.map(I=>I.name)},endpoints:T,webhooks:M,channels:{},groupedSchemas:wKn(n,D),securitySchemes:a,hasEndpointsMarkedInternal:T.some(I=>I.internal),nonRequestReferencedSchemas:g.getReferencedSchemas(),variables:c,globalHeaders:d,idempotencyHeaders:s}}function qBE(e,t,r){let i={};for(let[n,a]of Object.entries(e)){if(a.type!=="object"){i[n]=a;continue}let u={$ref:`#/components/schemas/${n}`},c=t.getReferencesFromDiscriminatedUnion(u);if(c==null){i[n]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!c.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!c.discriminants.has(o.propertyKey)),source:r};i[n]=d;let s=zw_({schema:a,schemas:e});for(let o of[...new Set(s)]){let l=i[o]??e[o];l==null||l.type!=="object"||(i[o]={...l,type:"object",properties:l.properties.filter(b=>!c.discriminants.has(b.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(b=>!c.discriminants.has(b.propertyKey))})}}return i}function TBE(e,t){let r={};for(let[i,n]of Object.entries(e)){if(n.type!=="object"){r[i]=n;continue}let a={$ref:`#/components/schemas/${i}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[i]=n;continue}let c=[];for(let s of n.properties)if(u.discriminants.has(s.key)){let o=u.discriminants.get(s.key);o!=null&&c.push({...s,schema:Nl.literal({nameOverride:void 0,generatedName:S5([n.generatedName,o],t.options.preserveSchemaIds),title:void 0,value:mx.string(o),namespace:void 0,groupName:void 0,description:void 0,availability:n.availability})})}else c.push(s);let d={...n,type:"object",properties:c};r[i]=d}return r}function zw_({schema:e,schemas:t}){let r=[];for(let i of e.allOf){r.push(i.schema);let n=t[i.schema];n!=null&&n.type==="object"&&r.push(...zw_({schema:n,schemas:t}))}return r}function Rau(e){return[...new Set(e)]}function Bw_({operation:e}){let t=[];switch(e.type){case"async":t=Rau(e.async.flatMap(r=>r.audiences));break;case"http":t=Rau(e.value.flatMap(r=>r.audiences));break;case"streaming":t=Rau(e.streaming.flatMap(r=>r.audiences));break;case"webhook":t=Rau(e.value.flatMap(r=>r.audiences));break;default:Ao(e)}return t}function Jnn({context:e,documents:t,options:r}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],websocketServers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channels:{},groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let n of t){let a=n.source!=null?n.source:RK.openapi({file:"<memory>"});switch(n.type){case"openapi":{let u=Iw_({taskContext:e,openApi:n.value,options:HQt({options:n.settings,overrides:r}),source:a,namespace:n.namespace});i=BBE(i,u);break}case"asyncapi":{let u=Nj_({document:n.value,taskContext:e,options:HQt({options:n.settings,overrides:r}),source:a,asyncApiOptions:CBE({options:n.settings}),namespace:n.namespace});u.servers!=null&&(i.websocketServers=[...i.websocketServers,...u.servers.map(c=>({...c,audiences:void 0,description:void 0}))]),u.channels!=null&&(i.channels={...i.channels,...u.channels}),u.groupedSchemas!=null&&(i.groupedSchemas=xw_(i.groupedSchemas,u.groupedSchemas)),u.basePath!=null&&(i.basePath=u.basePath);break}default:Ao(n)}}return i}function CBE({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??aj_.naming}}function BBE(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],websocketServers:[...e.websocketServers,...t.websocketServers],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],channels:{...e.channels,...t.channels},groupedSchemas:xw_(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 xw_(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,i]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...i}:e.namespacedSchemas[r]=i;return e}var uB_=ci(Bcu(),1),Icu={config:new uB_.Config({apis:{},styleguide:{plugins:[U1c],rules:{struct:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};function jYn(e){if(e.settings==null&&e.raw?.api?.auth==null)return;let t={detectGlobalHeaders:!0};return e.settings?.unions==="v1"&&(t.discriminatedUnionV2=!0),e.raw?.api?.auth!=null&&(t.auth=e.raw?.api?.auth),t}function $9a(e){return e.swagger!=null}function yqc(e){return e.openapi!=null}function G9a({options:e,overrides:t}={}){return{...HQt({options:e,overrides:t}),...j5a({options:e,overrides:t})}}function d3i(e,t={}){return{...Object.fromEntries(sF(e.namedDefinitionFiles).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...sF(e.importedDefinitions).reduce((r,[i,n])=>({...r,...Sza(d3i(n.definition,{defaultURL:n.url}),(a,u)=>X3(i,Dy.of(u)))}),{})}}function Q9a(e,t={}){return{...Object.fromEntries(sF(e.packageMarkers).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...sF(e.importedDefinitions).reduce((r,[i,n])=>({...r,...Sza(Q9a(n.definition,{defaultURL:n.url}),(a,u)=>X3(i,Dy.of(u)))}),{})}}function fPi(e){return{...Q9a(e),...d3i(e)}}function Que(e,t){return fPi(e.definition)[t]?.contents}function KF(e,t){for(let[r,i]of sF(fPi(e.definition)))t(r,i.contents,{isPackageMarker:iki(r)===CS,defaultUrl:i.defaultUrl})}function Oan(e,t){for(let[r,i]of sF(Q9a(e.definition)))t(r,i.contents)}function NFe({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Bs.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Bs.dim(r)),i.join(`
|
|
1961
1961
|
`)}var sB_={None:"none",Header:"header"};var ilu={};xa(ilu,{ConjureAliasDeclaration:()=>Ucu,ConjureArgument:()=>elu,ConjureArgumentWithParamType:()=>kcu,ConjureAuthDefinition:()=>EYn,ConjureAuthDefinitionType:()=>Xcu,ConjureDefinitions:()=>Kcu,ConjureEndpointDefinition:()=>tlu,ConjureEnumDeclaration:()=>Qcu,ConjureEnumVariant:()=>Gcu,ConjureEnumWithDocs:()=>$cu,ConjureObjectDeclaration:()=>Hcu,ConjureParamType:()=>Zcu,ConjurePrimitive:()=>Lcu,ConjureService:()=>rlu,ConjureServiceName:()=>Fcu,ConjureType:()=>h3i,ConjureTypeDeclaration:()=>Jcu,ConjureTypeReference:()=>y3i,ConjureTypeWithDocs:()=>Vcu,ConjureTypes:()=>Ycu,ConjureUnionDeclaration:()=>Wcu,DefinitionFile:()=>xB_,WithDocs:()=>Mor,commons:()=>mqc,conjure:()=>Pqc,services:()=>jqc,types:()=>wqc});var mqc={};xa(mqc,{WithDocs:()=>Mor});var jp={};xa(jp,{JsonError:()=>wYn,ParseError:()=>SYn,any:()=>jB_,bigint:()=>lB_,boolean:()=>wB_,booleanLiteral:()=>PB_,date:()=>fB_,discriminant:()=>BB_,enum_:()=>xcu,getObjectLikeUtils:()=>tJt,getObjectUtils:()=>man,getSchemaUtils:()=>JT,isProperty:()=>_3i,lazy:()=>dB_,lazyObject:()=>gB_,list:()=>Ncu,number:()=>SB_,object:()=>Rcu,objectWithoutOptionalProperties:()=>bB_,optional:()=>vqc,property:()=>_B_,record:()=>AB_,set:()=>qB_,string:()=>DB_,stringLiteral:()=>mB_,transform:()=>bqc,undiscriminatedUnion:()=>CB_,union:()=>zB_,unknown:()=>EB_,withParsedProperties:()=>Oqc});var gw={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function yq(e,t){return`Expected ${t}. Received ${UKE(e)}.`}function UKE(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function BU(e){return{...e,json:cB_(e.json),parse:cB_(e.parse)}}function cB_(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1962
1962
|
`)),{ok:!0,value:t}):i}}function zcu(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var wYn=class e extends Error{errors;constructor(t){super(t.map(zcu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var SYn=class e extends Error{errors;constructor(t){super(t.map(zcu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function JT(e){return{optional:()=>vqc(e),transform:t=>bqc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new SYn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new wYn(i.errors)}}}function vqc(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>gw.OPTIONAL};return{...t,...JT(t)}}function bqc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...JT(r)}}function lB_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:yq(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:yq(t,"bigint")}]},getType:()=>gw.BIGINT};return{...BU(e),...JT(e)}}var VKE=/^([+-]?\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 fB_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:yq(t,"string")}]}:VKE.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:yq(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:yq(t,"Date object")}]},getType:()=>gw.DATE};return{...BU(e),...JT(e)}}function QK(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...BU(r),...JT(r)}}}function xcu(e){let t=new Set(e);return QK(gw.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:yq(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:yq(i,"enum")}]}:{ok:!0,value:i})()}function dB_(e){let t=gqc(e);return{...t,...JT(t)}}function gqc(e){return{parse:(t,r)=>DYn(e).parse(t,r),json:(t,r)=>DYn(e).json(t,r),getType:()=>DYn(e).getType()}}function DYn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function J9a(e){return Object.entries(e)}function K9a(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function p3i(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 Y9a(e){return Object.keys(e)}function pB_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function tJt(e){return{withParsedProperties:t=>Oqc(e,t)}}function Oqc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((c,[d,s])=>({...c,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!p3i(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:yq(i,"object")}]};let a=new Set(Object.keys(t)),u=K9a(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...JT(r),...tJt(r)}}function _B_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function _3i(e){return e.isProperty}function Rcu(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>_3i(i)?i.rawKey:r),_getParsedProperties:()=>Y9a(e),parse:(r,i)=>{let n={},a=[];for(let[u,c]of J9a(e)){let d=_3i(c)?c.rawKey:u,s=_3i(c)?c.valueSchema:c,o={rawKey:d,parsedKey:u,valueSchema:s};n[d]=o,vB_(s)&&a.push(d)}return hB_({value:r,requiredKeys:a,getProperty:u=>{let c=n[u];if(c!=null)return{transformedKey:c.parsedKey,transform:d=>c.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of J9a(e)){let c=_3i(u)?u.valueSchema:u;vB_(c)&&n.push(a)}return hB_({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return _3i(u)?{transformedKey:u.rawKey,transform:c=>u.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>u.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>gw.OBJECT};return{...BU(t),...JT(t),...tJt(t),...man(t)}}function hB_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!p3i(e))return{ok:!1,errors:[{path:a,message:yq(e,"object")}]};let u=new Set(t),c=[],d={};for(let[s,o]of Object.entries(e)){let l=r(s);if(l!=null){u.delete(s);let b=l.transform(o);b.ok?d[l.transformedKey]=b.value:(d[s]=o,c.push(...b.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=o;break}}return c.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:d}:{ok:!1,errors:c}}function man(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>yB_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>yB_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>gw.OBJECT};return{...r,...JT(r),...tJt(r),...man(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>gw.OBJECT};return{...t,...JT(t),...tJt(t),...man(t)}}}}function yB_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=pB_(Y9a(t),s=>n.has(s)),c=r(K9a(t,u)),d=i(K9a(t,a));return c.ok&&d.ok?{ok:!0,value:{...c.value,...d.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...d.ok?[]:d.errors]}}function vB_(e){return!WKE(e)}function WKE(e){switch(e.getType()){case gw.ANY:case gw.UNKNOWN:case gw.OPTIONAL:return!0;default:return!1}}function bB_(e){return Rcu(e)}function gB_(e){let t={...gqc(e),_getRawProperties:()=>DYn(e)._getRawProperties(),_getParsedProperties:()=>DYn(e)._getParsedProperties()};return{...t,...JT(t),...tJt(t),...man(t)}}function Ncu(e){let t={parse:(r,i)=>OB_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>OB_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>gw.LIST};return{...BU(t),...JT(t)}}function OB_(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:yq(e,"list"),path:[]}]}}function mB_(e){return QK(gw.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:yq(r,`"${e}"`)}]})()}function PB_(e){return QK(gw.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:yq(r,`${e.toString()}`)}]})()}var jB_=QK(gw.ANY,e=>({ok:!0,value:e}));var wB_=QK(gw.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:yq(e,"boolean")}]});var SB_=QK(gw.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:yq(e,"number")}]});var DB_=QK(gw.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:yq(e,"string")}]});var EB_=QK(gw.UNKNOWN,e=>({ok:!0,value:e}));function AB_(e,t){let r={parse:(i,n)=>MB_({value:i,isKeyNumeric:e.getType()===gw.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>MB_({value:i,isKeyNumeric:e.getType()===gw.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>gw.RECORD};return{...BU(r),...JT(r)}}function MB_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return p3i(e)?J9a(e).reduce((a,[u,c])=>{if(c==null)return a;let d=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),l=i(c,s);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let b=[];return d.ok||b.push(...d.errors),o.ok||b.push(...o.errors),l.ok||b.push(...l.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:yq(e,"object")}]}}function qB_(e){let t=Ncu(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:yq(i,"Set")}]},getType:()=>gw.SET};return{...BU(r),...JT(r)}}function CB_(e){let t={parse:(r,i)=>TB_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>TB_((n,a)=>n.json(r,a),e,i),getType:()=>gw.UNDISCRIMINATED_UNION};return{...BU(t),...JT(t)}}function TB_(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let c of u.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function BB_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function zB_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=xcu(Y9a(t)),a={parse:(u,c)=>IB_({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(u,c)=>IB_({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>gw.UNION};return{...BU(a),...JT(a),...tJt(a)}}function IB_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:c=[]}){if(!p3i(e))return{ok:!1,errors:[{path:c,message:yq(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let o=i(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=n(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let b=u(s,l);return b.ok?{ok:!0,value:{[r]:d,...b.value}}:b}var Mor=jp.objectWithoutOptionalProperties({docs:jp.string().optional()});var Pqc={};xa(Pqc,{ConjureServiceName:()=>Fcu,DefinitionFile:()=>xB_});var Fcu=jp.string();var Lcu=jp.enum_(["rid","string","safelong","integer","double","boolean"]);var h3i=jp.undiscriminatedUnion([Lcu,jp.string()]);var Ucu=jp.objectWithoutOptionalProperties({alias:h3i,docs:jp.string().optional()});var Vcu=jp.objectWithoutOptionalProperties({type:h3i,docs:jp.string().optional()});var y3i=jp.undiscriminatedUnion([h3i,Vcu]);var Wcu=jp.objectWithoutOptionalProperties({union:jp.record(jp.string(),y3i)});var Hcu=jp.objectWithoutOptionalProperties({fields:jp.record(jp.string(),y3i)});var $cu=jp.objectWithoutOptionalProperties({value:jp.string()}).extend(Mor);var Gcu=jp.undiscriminatedUnion([jp.string(),$cu]);var Qcu=jp.objectWithoutOptionalProperties({values:jp.list(Gcu)});var Jcu=jp.undiscriminatedUnion([Ucu,Wcu,Hcu,Qcu]);var Kcu=jp.objectWithoutOptionalProperties({objects:jp.record(jp.string(),Jcu).optional()});var Ycu=jp.objectWithoutOptionalProperties({conjureImports:jp.property("conjure-imports",jp.record(jp.string(),jp.string()).optional()),definitions:Kcu.optional()});var Xcu=jp.enum_(["none","header"]);var EYn=jp.undiscriminatedUnion([Xcu,jp.string()]);var Zcu=jp.enum_(["path","query","body"]);var kcu=jp.objectWithoutOptionalProperties({paramType:jp.property("param-type",Zcu),type:jp.string()}).extend(Mor);var elu=jp.undiscriminatedUnion([jp.string(),kcu]);var tlu=jp.objectWithoutOptionalProperties({http:jp.string(),auth:EYn.optional(),args:jp.record(jp.string(),elu).optional(),returns:y3i.optional()}).extend(Mor);var rlu=jp.objectWithoutOptionalProperties({name:jp.string().optional(),package:jp.string().optional(),basePath:jp.property("base-path",jp.string().optional()),defaultAuth:jp.property("default-auth",EYn.optional()),endpoints:jp.record(jp.string(),tlu).optional()}).extend(Mor);var xB_=jp.objectWithoutOptionalProperties({types:Ycu.optional(),services:jp.record(Fcu,rlu).optional()});var jqc={};xa(jqc,{ConjureArgument:()=>elu,ConjureArgumentWithParamType:()=>kcu,ConjureAuthDefinition:()=>EYn,ConjureAuthDefinitionType:()=>Xcu,ConjureEndpointDefinition:()=>tlu,ConjureParamType:()=>Zcu,ConjureService:()=>rlu});var wqc={};xa(wqc,{ConjureAliasDeclaration:()=>Ucu,ConjureDefinitions:()=>Kcu,ConjureEnumDeclaration:()=>Qcu,ConjureEnumVariant:()=>Gcu,ConjureEnumWithDocs:()=>$cu,ConjureObjectDeclaration:()=>Hcu,ConjurePrimitive:()=>Lcu,ConjureType:()=>h3i,ConjureTypeDeclaration:()=>Jcu,ConjureTypeReference:()=>y3i,ConjureTypeWithDocs:()=>Vcu,ConjureTypes:()=>Ycu,ConjureUnionDeclaration:()=>Wcu});var RB_=require("fs/promises");async function NB_(e,t){let r=[];for(let i of await Jae(e,t))r.push(await HKE({relativeFilepath:UT(e,i),absoluteFilepath:i}));return r}async function HKE({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,RB_.readFile)(t)).toString().replaceAll(/: rid(?:$|\s)/g,`: string
|
|
1963
1963
|
`).replaceAll("<rid>","<string>").replaceAll("rid>","string>").replaceAll(": safelong",": long").replaceAll("<safelong>","<long>").replaceAll("safelong>","long>").replaceAll(": any",": unknown").replaceAll("<any>","<unknown>").replaceAll("any>","unknown>");return{relativeFilepath:e,absoluteFilepath:t,fileContents:ilu.DefinitionFile.parseOrThrow(Rd.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}function FB_(e,t){if($KE(e))return t.alias(e);if(GKE(e))return t.enum(e);if(QKE(e))return t.object(e);if(JKE(e))return t.union(e);Ao(e)}function $KE(e){return e?.alias!=null}function GKE(e){return e?.values!=null}function QKE(e){return e?.fields!=null}function JKE(e){return e?.union!=null}var X9a=class extends B5a{fernDefinitionBuilder=new Wnn(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:i,globalHeaderOverrides:n}){if(r!=null){for(let[a,u]of Object.entries(r["auth-schemes"]??{}))this.fernDefinitionBuilder.addAuthScheme({name:a,schema:u});r.auth!=null&&this.fernDefinitionBuilder.setAuth(r.auth)}if(i!=null){for(let[a,u]of Object.entries(i.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:u});i["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(i["default-environment"]),i["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(i["default-url"])}return await LB_(t,(a,u,c)=>{for(let[o,l]of Object.entries(c.services??{})){let b=zAo({value:o,suffix:"Service"});this.conjureFilepathToFernFilepath[u]=za.of(`${b}/__package__.yml`);return}let s=gxa(u)?.split(".")[0];s!=null&&(this.conjureFilepathToFernFilepath[u]=za.of(`${s}/__package__.yml`))}),await LB_(t,(a,u,c)=>{if(c.services==null||Object.keys(c.services??{}).length===0){let d=this.conjureFilepathToFernFilepath[u];if(d==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${u}`);for(let[s,o]of Object.entries(c.types?.conjureImports??{})){let l=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:za.of(o)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:za.of(l),alias:s})}this.importAllTypes({conjureFile:c,fernFilePath:d});return}for(let[d,s]of Object.entries(c.services)){let o=zAo({value:d,suffix:"Service"}),l=za.of(`${o}/__package__.yml`),b={};s.basePath!=null&&(b["base-path"]=s.basePath),s.docs!=null&&(b.docs=s.docs),this.fernDefinitionBuilder.setServiceInfo(l,b),this.importAllTypes({conjureFile:c,fernFilePath:l});for(let[g,O]of Object.entries(c.types?.conjureImports??{})){let m=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:za.of(O)});this.fernDefinitionBuilder.addImport({file:l,fileToImport:za.of(m),alias:g})}for(let[g,O]of Object.entries(s.endpoints??{})){let m=CHs(O.http);if(m.type==="failure"){this.context?.logger.error(`Failed to parse ${O.http}. Skipping.`);continue}let D={auth:(O.auth??s.defaultAuth)!==sB_.None,path:m.path,method:m.method,response:O.returns==="binary"?"file":O.returns};O.docs!=null&&(D.docs=O.docs);let A={};if(O.args!=null)for(let M of m.pathParameters){let E=O.args[M];if(E==null)throw new Error(`Failed to find path parameter ${M} in ${O.http}`);A[M]=typeof E=="string"?E:{type:E.type}}Object.entries(A).length>0&&(D["path-parameters"]=A);for(let[M,E]of Object.entries(O.args??{}))if(A[M]==null)if(typeof E=="string")D.request?typeof D.request=="string"&&(D.request={body:D.request}):D.request={},D.request.body=E==="binary"?"bytes":E;else switch(E.paramType){case"body":D.request={body:E.type==="binary"?"bytes":E.type};break;case"query":D.request==null?D.request={"query-parameters":{[M]:E.type}}:typeof D.request!="string"&&D.request?.["query-parameters"]==null?D.request["query-parameters"]={[M]:E.type}:typeof D.request!="string"&&D.request?.["query-parameters"]!=null&&(D.request["query-parameters"][M]=E.type)}D.request!=null&&typeof D.request!="string"&&D.request?.["query-parameters"]!=null&&(D.request.name=`${g}Request`),this.fernDefinitionBuilder.addEndpoint(l,{name:g,schema:D,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[i,n]of Object.entries(t.types?.definitions?.objects??{}))FB_(n,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{union:Object.fromEntries(Object.entries(a.union).map(([u,c])=>[u,{type:typeof c=="string"?c:c.type,docs:typeof c=="string"?void 0:c.docs,key:u}]))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:i}){let n=Bu(xd(t),za.of(r)),a=Kae(i,n),u=this.conjureFilepathToFernFilepath[a];if(u==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return u}};async function LB_(e,t){for(let r of await NB_(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}function UB_(e,t){return Dd(e,t)}var nlu=class extends LQt{type="conjure";absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=Bu(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new Tqe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let n=await new X9a(t).import({absolutePathToConjureFolder:this.absolutePathToConjureFolder,authOverrides:this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0,environmentOverrides:this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:$c.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:n.rootApiFile["default-url"],contents:n.rootApiFile,rawContents:Rd.dump(n.rootApiFile)},namedDefinitionFiles:{...UB_(n.definitionFiles,a=>({absoluteFilepath:$c.of("/DUMMY_PATH"),rawContents:Rd.dump(a),contents:a})),[za.of(CS)]:{absoluteFilepath:$c.of("/DUMMY_PATH"),rawContents:Rd.dump(n.packageMarkerFile),contents:n.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};var aR_=ci(QB_(),1);var Pj;(function(e){e.FILE_READ="FILE_READ",e.FILE_PARSE="FILE_PARSE",e.FILE_MISSING="FILE_MISSING",e.STRUCTURE_VALIDATION="STRUCTURE_VALIDATION",e.JSONSCHEMA_VALIDATION="JSONSCHEMA_VALIDATION",e.DEPENDENCY_NOT_LISTED="DEPENDENCY_NOT_LISTED",e.FAILED_TO_LOAD_DEPENDENCY="FAILED_TO_LOAD_DEPENDENCY",e.EXPORTING_PACKAGE_MARKER_OTHER_KEYS="EXPORTING_PACKAGE_MARKER_OTHER_KEYS",e.EXPORT_PACKAGE_HAS_DEFINITIONS="EXPORT_PACKAGE_HAS_DEFINITIONS",e.MISCONFIGURED_DIRECTORY="MISCONFIGURED_DIRECTORY"})(Pj||(Pj={}));function alu(e,t){for(let[r,i]of sF(e))YKE({relativeFilepath:r,failure:i,logger:t})}function YKE({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Pj.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 Pj.FILE_READ:r.error("Failed to open file: "+e);break;case Pj.FILE_MISSING:r.error("Missing file: "+e);break;case Pj.FILE_PARSE:t.error instanceof Vxa?r.error(NFe({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Pj.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of XKE(i))r.error(NFe({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case Pj.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Pj.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${gqo}: `+t.dependencyName);break;case Pj.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Pj.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case Pj.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(NFe({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));for(let i of t.error.allErrors)i!==t.error.error&&r.debug(NFe({title:i.message??"Unknown error",breadcrumbs:[e,...i.instancePath.split("/").filter(n=>n!=="")]}));break;default:Ao(t)}}function XKE(e){switch(e.code){case Vl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Bs.underline(e.expected)} but received ${Bs.underline(e.received)}`}];case Vl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Bs.underline(t)}`}));case Vl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Bs.underline(t)).join(", ")}`}];case Vl.invalid_union:case Vl.invalid_arguments:case Vl.invalid_return_type:case Vl.invalid_date:case Vl.invalid_string:case Vl.too_small:case Vl.too_big:case Vl.invalid_intersection_types:case Vl.not_multiple_of:case Vl.custom:default:return[{title:e.message}]}}var JB_=require("fs/promises");async function KB_(e,t){let r=[];for(let i of await Jae(e,t))r.push(await ZKE({relativeFilepath:UT(e,i),absoluteFilepath:i}));return r}async function ZKE({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,JB_.readFile)(t)).toString()}}async function YB_(e){let t={},r={};function i(n){try{t[n.relativeFilepath]={defaultUrl:void 0,contents:Rd.load(n.fileContents,{schema:Rd.CORE_SCHEMA}),rawContents:n.fileContents}}catch(a){r[n.relativeFilepath]={type:Pj.FILE_PARSE,error:a}}}return await Promise.all(e.map(i)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}var _Cc=ci(xzi(),1);var Jx_=require("fs"),ZYn=require("fs/promises");var Kx_=require("os"),Yx_=ci(require("path"),1),Xx_=require("stream/promises"),Zx_=ci(dfu(),1),kx_=ci(Yk(),1);var MZE=wOi();async function eR_({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:i,cliVersion:n,settings:a,loadAPIWorkspace:u}){let c,d={type:Pj.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:Pj.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${zZE(s)}`},async o=>{switch(s.type){case"version":c=await BZE({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;case"local":c=await CZE({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;default:Ao(s)}}),c!=null?{didSucceed:!0,definition:c}:{didSucceed:!1,failure:d}}var tR_="dependencies";var AZE="metadata.json",qZE=".fern";function TZE(e){return Bu($c.of((0,Kx_.homedir)()),za.of(qZE),za.of(tR_),za.of(e.organization),za.of(e.apiName),za.of(e.version))}async function CZE({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){if(n==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await n({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!a.didSucceed){t.failWithoutThrowing("Failed to load api definition",a.failures);return}t.logger.info("Modifying source filepath ...");let u=await a.workspace.getDefinition({context:t,relativePathToDependency:za.of(e.path)},i);return t.logger.info("Loaded..."),u}async function BZE({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){let a=TZE(e),u=Bu(a,za.of(tR_)),c=Bu(a,za.of(AZE)),d;if(!await Cf(u)||!await Cf(c)){t.logger.info("Downloading manifest...");let l=await MZE.definitionRegistry.get(_Cc.FernFiddle.OrganizationId(e.organization),_Cc.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:m=>{t.failWithoutThrowing("Failed to download API manifest",m)}});return}let b=l.body.yamlSchemaVersion!=null?parseInt(l.body.yamlSchemaVersion):void 0,g=Mnn(r),O=Mnn(l.body.cliVersion);if(b!=null){if(b>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${l.body.cliVersion}`);return}else if(b<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(g.major!==O.major||g.minor!==O.minor){t.failWithoutThrowing(`CLI version is ${l.body.cliVersion}. Expected ${g.major}.${g.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+l.body.definitionS3DownloadUrl),await(0,ZYn.mkdir)(u,{recursive:!0});try{await IZE({s3PreSignedReadUrl:l.body.definitionS3DownloadUrl,absolutePathToLocalOutput:u})}catch(m){t.failWithoutThrowing("Failed to download API",m);return}d=l.body,await(0,ZYn.writeFile)(c,JSON.stringify(d))}else d=JSON.parse((await(0,ZYn.readFile)(c)).toString());if(t.logger.info("Parsing..."),n==null){t.failWithoutThrowing("Failed to load API");return}let s=await n({absolutePathToWorkspace:u,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!s.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",s.failures);return}if(s.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await s.workspace.getDefinition({context:t},i)}async function IZE({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await d7.get(e,{responseType:"stream"}),i=await kx_.default.dir(),n=Yx_.default.join(i.path,"api.tgz");await(0,Xx_.pipeline)(r.data,(0,Jx_.createWriteStream)(n)),await(0,Zx_.extract)({file:n,cwd:t})}function zZE(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:Ao(e)}}async function rR_({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:i,settings:n,loadAPIWorkspace:a}){let u={},c={},d={};return await Promise.all(sF(t.packageMarkers).map(async([s,o])=>{if(o.contents.export==null)u[s]=o;else{let{export:l,...b}=o.contents;if(Vq(b)>0)d[s]={type:Pj.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let g=xd(s);if(R$t(t.namedDefinitionFiles).some(m=>m!==s&&m.startsWith(g)))d[s]={type:Pj.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:g};else{let m=await eR_({dependencyName:typeof o.contents.export=="string"?o.contents.export:o.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:i,settings:n,loadAPIWorkspace:a});m.didSucceed?c[xd(s)]={definition:m.definition,url:typeof o.contents.export=="object"?o.contents.export.url:void 0}:d[s]=m.failure}}}})),Vq(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:u,importedDefinitions:c}}var iR_=ci(require("path"),1);var hCc={};xa(hCc,{additionalProperties:()=>FZE,default:()=>UZE,definitions:()=>LZE,properties:()=>RZE,required:()=>NZE,type:()=>xZE});var xZE="object",RZE={docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},"default-url":{oneOf:[{type:"string"},{type:"null"}]},"default-environment":{oneOf:[{type:"string"},{type:"null"}]},environments:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/environments.EnvironmentSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/auth.ApiAuthSchema"},{type:"null"}]},"auth-schemes":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/auth.AuthSchemeDeclarationSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},name:{type:"string"},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},"error-discrimination":{oneOf:[{$ref:"#/definitions/file.ErrorDiscriminationSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},errors:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"idempotency-headers":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},variables:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/variables.VariableDeclarationSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"null"}]},product:{oneOf:[{$ref:"#/definitions/products.ProductDeclarationSchema"},{type:"null"}]},version:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},NZE=["name"],FZE=!1,LZE={"environments.SingleBaseUrlEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},url:{type:"string"}},required:["url"],additionalProperties:!1},"environments.MultipleBaseUrlsEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},urls:{type:"object",additionalProperties:{type:"string"}}},required:["urls"],additionalProperties:!1},"environments.EnvironmentSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/environments.SingleBaseUrlEnvironmentSchema"},{$ref:"#/definitions/environments.MultipleBaseUrlsEnvironmentSchema"}]},"auth.AuthSchemeReferenceSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{type:"string"}},required:["scheme"],additionalProperties:!1},"auth.AnyAuthItem":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"}]},"auth.AnyAuthSchemesSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},any:{type:"array",items:{$ref:"#/definitions/auth.AnyAuthItem"}}},required:["any"],additionalProperties:!1},"auth.ApiAuthSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"},{$ref:"#/definitions/auth.AnyAuthSchemesSchema"}]},"auth.OAuthAccessTokenRequestPropertiesSchema":{type:"object",properties:{"client-id":{oneOf:[{type:"string"},{type:"null"}]},"client-secret":{oneOf:[{type:"string"},{type:"null"}]},scopes:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthAccessTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthGetTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthRefreshTokenRequestPropertiesSchema":{type:"object",properties:{"refresh-token":{type:"string"}},required:["refresh-token"],additionalProperties:!1},"auth.OAuthRefreshTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthRefreshTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"oauth"},type:{const:"client-credentials"},scopes:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"client-id-env":{oneOf:[{type:"string"},{type:"null"}]},"client-secret-env":{oneOf:[{type:"string"},{type:"null"}]},"token-prefix":{oneOf:[{type:"string"},{type:"null"}]},"token-header":{oneOf:[{type:"string"},{type:"null"}]},"get-token":{$ref:"#/definitions/auth.OAuthGetTokenEndpointSchema"},"refresh-token":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenEndpointSchema"},{type:"null"}]}},required:["scheme","type","get-token"],additionalProperties:!1},"auth.HeaderAuthSchemeSchema":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},header:{type:"string"},type:{oneOf:[{type:"string"},{type:"null"}]},prefix:{oneOf:[{type:"string"},{type:"null"}]}},required:["header"],additionalProperties:!1},"auth.AuthVariable":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.BasicAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"basic"},username:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]},password:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.TokenBearerAuthSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},token:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.InferredAuthenticatedRequestHeader":{type:"object",properties:{"response-property":{type:"string"},"header-name":{type:"string"},"value-prefix":{oneOf:[{type:"string"},{type:"null"}]}},required:["response-property","header-name"],additionalProperties:!1},"auth.InferredGetTokenEndpointSchemaObject":{type:"object",properties:{endpoint:{type:"string"},"expiry-response-property":{oneOf:[{type:"string"},{type:"null"}]},"authenticated-request-headers":{oneOf:[{type:"array",items:{$ref:"#/definitions/auth.InferredAuthenticatedRequestHeader"}},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.InferredGetTokenEndpointSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.InferredGetTokenEndpointSchemaObject"}]},"auth.InferredBearerAuthSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},"get-token":{$ref:"#/definitions/auth.InferredGetTokenEndpointSchema"}},required:["scheme","get-token"],additionalProperties:!1},"auth.BearerAuthSchemeSchema":{anyOf:[{$ref:"#/definitions/auth.TokenBearerAuthSchema"},{$ref:"#/definitions/auth.InferredBearerAuthSchema"}]},"auth.AuthSchemeDeclarationSchema":{anyOf:[{$ref:"#/definitions/auth.OAuthSchemeSchema"},{$ref:"#/definitions/auth.HeaderAuthSchemeSchema"},{$ref:"#/definitions/auth.BasicAuthSchemeSchema"},{$ref:"#/definitions/auth.BearerAuthSchemeSchema"}]},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"file.PropertyBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"property"},"property-name":{type:"string"}},required:["strategy","property-name"],additionalProperties:!1},"file.StatusCodeBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"status-code"}},required:["strategy"],additionalProperties:!1},"file.ErrorDiscriminationSchema":{anyOf:[{$ref:"#/definitions/file.PropertyBasedErrorDiscrimination"},{$ref:"#/definitions/file.StatusCodeBasedErrorDiscrimination"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"variables.VariableDeclarationDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"variables.VariableDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/variables.VariableDeclarationDetailed"}]},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"versioning.VersionValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionValue":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionValueDetailed"}]},"versioning.VersionDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionDeclarationHeaderObjectSchema"}]},"versioning.VersionDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/versioning.VersionValue"}},header:{$ref:"#/definitions/versioning.VersionDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1},"products.ProductValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},versions:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"products.ProductValue":{anyOf:[{type:"string"},{$ref:"#/definitions/products.ProductValueDetailed"}]},"products.ProductDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"products.ProductDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/products.ProductDeclarationHeaderObjectSchema"}]},"products.ProductDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/products.ProductValue"}},header:{$ref:"#/definitions/products.ProductDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1}},UZE={type:xZE,properties:RZE,required:NZE,additionalProperties:FZE,definitions:LZE};var yCc={};xa(yCc,{additionalProperties:()=>HZE,default:()=>GZE,definitions:()=>$ZE,properties:()=>WZE,type:()=>VZE});var VZE="object",WZE={docs:{oneOf:[{type:"string"},{type:"null"}]},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]}},HZE=!1,$ZE={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE","HEAD"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1}},GZE={type:VZE,properties:WZE,additionalProperties:HZE,definitions:$ZE};var vCc={};xa(vCc,{additionalProperties:()=>KZE,default:()=>XZE,definitions:()=>YZE,properties:()=>JZE,type:()=>QZE});var QZE="object",JZE={imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},navigation:{oneOf:[{$ref:"#/definitions/file.Navigation"},{type:"null"}]},export:{oneOf:[{$ref:"#/definitions/file.Export"},{type:"null"}]}},KZE=!1,YZE={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE","HEAD"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1},"file.Navigation":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"file.ExportDetailed":{type:"object",properties:{dependency:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]}},required:["dependency"],additionalProperties:!1},"file.Export":{anyOf:[{type:"string"},{$ref:"#/definitions/file.ExportDetailed"}]}},XZE={type:QZE,properties:JZE,additionalProperties:KZE,definitions:YZE};function nR_({files:e,absolutePathToDefinition:t}){let r,i={},n={},a={};for(let[u,c]of sF(e)){let d=c.contents,s=o=>{a[u]={type:Pj.JSONSCHEMA_VALIDATION,error:o}};if(u===lF){let o=V$t(d,hCc);if(o.success){let l=i7.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:l["default-url"],contents:l,rawContents:c.rawContents}}else s(o)}else if(iR_.default.basename(u)===CS){let o=V$t(d,vCc);if(o.success){let l=i7.serialization.PackageMarkerFileSchema.parseOrThrow(d);n[u]={defaultUrl:typeof l.export=="object"?l.export.url:void 0,contents:l,rawContents:c.rawContents}}else s(o)}else{let o=V$t(d,yCc);if(o.success){let l=i7.serialization.DefinitionFileSchema.parseOrThrow(d);i[u]={defaultUrl:void 0,contents:l,rawContents:c.rawContents,absoluteFilePath:Bu(t,u)}}else s(o)}}return r==null?{didSucceed:!1,failures:{[za.of(lF)]:{type:Pj.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:i,rootApiFile:r,packageMarkers:n}}var xor=class extends LQt{type="fern";context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...i}){super(i),this.context=t,this.loadAPIWorkspace=r}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let i=(0,aR_.default)(r??{}),n=this.fernWorkspaces[i];if(n==null){let a=t||this.context,u=Bu(this.absoluteFilePath,za.of(zL)),c=await uJs({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await KB_(u,"{yml,yaml}"),s=await YB_(d);if(!s.didSucceed)return alu(s.failures,a.logger),a.failAndThrow();let o=nR_({files:s.files,absolutePathToDefinition:u});if(!o.didSucceed)return alu(o.failures,a.logger),a.failAndThrow();let l=await rR_({dependenciesConfiguration:c,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!l.didSucceed)return alu(l.failures,a.logger),a.failAndThrow();let b={absoluteFilePath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:l.packageMarkers,importedDefinitions:l.importedDefinitions};r?.auth!=null&&(b={...b,rootApiFile:{...b.rootApiFile,contents:{...b.rootApiFile.contents,auth:r?.auth}}}),n=new Tqe({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:c,workspaceName:this.workspaceName,definition:b,cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[i]=n}return n}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var bF_=require("fs/promises");var _F_=ci(pF_(),1);async function dUa(e){return(await(0,_F_.convertObj)(e,{})).openapi}var yF_=require("fs/promises");var hF_=require("fs/promises");async function bXn({absoluteFilePathToOverrides:e,data:t,context:r,allowNullKeys:i}){let n=null;try{let a=(await(0,hF_.readFile)(e,"utf8")).toString();try{n=JSON.parse(a)}catch{n=Rd.load(a,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return THs({data:t,overrides:n,allowNullKeys:i})}async function OIc({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,yF_.readFile)(t)).toString(),n=await Rd.load(i);return r!=null?await bXn({absoluteFilePathToOverrides:r,context:e,data:n}):n}var _Ua=ci(Bcu(),1);var vF_=ci(Bcu(),1),mIc=ci(require("path"),1),pUa=class extends vF_.BaseResolver{absolutePathToOpenAPIOverrides;constructor(t){super(),this.absolutePathToOpenAPIOverrides=t}resolveExternalRef(t,r){let i=super.resolveExternalRef(t,r);return J$t($c.of(i))?i:this.absolutePathToOpenAPIOverrides!=null?mIc.default.resolve(mIc.default.dirname(this.absolutePathToOpenAPIOverrides),r):i}};async function PIc({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,parsed:r}){return(r!=null?await(0,_Ua.bundle)({...Icu,doc:{source:new _Ua.Source(e,"<openapi>"),parsed:r},externalRefResolver:new pUa(t)}):await(0,_Ua.bundle)({...Icu,ref:e,externalRefResolver:new pUa(t)})).bundle.parsed}var caM=["examples","example",ad.EXAMPLES,M$.REDOCLY_CODE_SAMPLES_CAMEL,M$.REDOCLY_CODE_SAMPLES_KEBAB];async function hUa({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r}){let i=await PIc({absolutePathToOpenAPI:t}),n;if(r!=null?n=r:typeof i=="object"&&i[ad.OPENAPI_OVERIDES_FILEPATH]!=null&&(n=Bu(xd(t),za.of(i[ad.OPENAPI_OVERIDES_FILEPATH]))),n!=null){let a=await bXn({absoluteFilePathToOverrides:n,context:e,data:i,allowNullKeys:caM});return await PIc({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,parsed:a})}return i}var oJt=class{absoluteFilePath;constructor(t){this.absoluteFilePath=t}async loadDocuments({context:t,specs:r}){let i=[];for(let n of r){let a=(await(0,bF_.readFile)(n.absoluteFilepath)).toString(),u=UT(this.absoluteFilePath,n.source.file);n.source.relativePathToDependency!=null&&(u=Bu(n.source.relativePathToDependency,u));let c=n.source.type==="protobuf"?RK.protobuf({file:u}):RK.openapi({file:u});if(a.includes("openapi")||a.includes("swagger")){let d=await hUa({absolutePathToOpenAPI:n.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:n.absoluteFilepathToOverrides});if(yqc(d)){i.push({type:"openapi",value:d,source:c,namespace:n.namespace,settings:HQt({options:n.settings})});continue}else if($9a(d)){(!d.schemes||d.schemes.length===0)&&(d.schemes=["https"]);let s=await dUa(d);i.push({type:"openapi",value:s,source:c,namespace:n.namespace,settings:HQt({options:n.settings})});continue}}if(a.includes("asyncapi")){let d=await OIc({context:t,absoluteFilePath:n.absoluteFilepath,absoluteFilePathToOverrides:n.absoluteFilepathToOverrides});i.push({type:"asyncapi",value:d,source:c,namespace:n.namespace,settings:HQt({options:n.settings})});continue}if(a.includes("openrpc")){let d=await OIc({context:t,absoluteFilePath:n.absoluteFilepath,absoluteFilePathToOverrides:n.absoluteFilepathToOverrides});i.push({type:"asyncapi",value:d,source:c,namespace:n.namespace,settings:HQt({options:n.settings})});continue}t.failAndThrow(`${n.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}};var laM=ou.object({type:ou.string(),channelId:ou.string().optional(),messageId:ou.string(),value:ou.any()}),faM=ou.object({summary:ou.string().optional(),description:ou.string().optional(),"query-parameters":ou.record(ou.string()).optional(),headers:ou.record(ou.string()).optional(),messages:ou.array(laM)}),gF_=ou.array(faM);var Odu=class extends yO{channel;key="x-fern-examples";constructor({breadcrumbs:t,channel:r,context:i}){super({breadcrumbs:t??[],context:i}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(t==null)return;let r=gF_.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-examples extension: ${r.error.message}`,path:this.breadcrumbs});return}return r.data.map(i=>({summary:i.summary,description:i.description,queryParameters:i["query-parameters"],headers:i.headers,messages:i.messages.map(n=>({type:n.type,channelId:n.channelId,messageId:n.messageId,value:n.value}))}))}};var gXn=class extends p_{channel;channelPath;inlinedTypes={};websocketGroup;constructor({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a}){super({context:t,breadcrumbs:r}),this.websocketGroup=i,this.channel=n,this.channelPath=a}convertExamples({fullPath:t,baseUrl:r,asyncApiVersion:i}){let a=new Odu({context:this.context,breadcrumbs:this.breadcrumbs,channel:this.channel}).convert();return a==null?{}:Object.fromEntries(a.map((u,c)=>[c.toString(),{channel:{method:"GET",path:t},baseUrl:t,environment:r,auth:void 0,pathParameters:{},queryParameters:u.queryParameters,headers:u.headers,messages:u.messages.map(d=>({type:i==="v2"?d.type:d.messageId,body:d.value}))}]))}transformToValidPath(t){return t.startsWith("/")?t:"/"+t}};var J3i=class extends wA.AbstractConverters.AbstractParameterConverter{parameterNamePrefix;constructor({context:t,breadcrumbs:r,parameter:i,parameterNamePrefix:n}){super({context:t,breadcrumbs:r,parameter:i}),this.parameterNamePrefix=n}convert(){let t,r={},n=new P$.FernOptionalExtension({breadcrumbs:this.breadcrumbs,parameter:this.parameter,context:this.context}).convert()??this.parameter.required===!1,a=this.parameter.schema??{...this.parameter,type:"string",enum:this.parameter.enum,default:this.parameter.default,example:this.parameter.example??this.parameter.name,examples:Object.values(this.parameter.examples??{}),deprecated:this.parameter.deprecated,required:void 0},c=new wA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,"schema"],schemaIdOverride:this.parameterNamePrefix?`${this.parameterNamePrefix}_${this.parameter.name}`:this.parameter.name,schemaOrReference:a,wrapAsOptional:n}).convert();return c!=null&&(t=c.type,r=c.inlinedTypes??{}),this.convertToOutput({schema:a,typeReference:t,inlinedTypes:r})}};var mdu=class extends yO{channel;key="x-fern-address";constructor({breadcrumbs:t,channel:r,context:i}){super({breadcrumbs:t,context:i}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(!(t==null||typeof t!="string"))return t}};var OXn=class extends yO{channel;key="x-fern-display-name";constructor({breadcrumbs:t,channel:r,context:i}){super({breadcrumbs:t,context:i}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(!(t==null||typeof t!="string"))return t}};var Pdu=class extends gXn{inlinedTypes={};constructor({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a}){super({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a})}convert(){let t=[],r=[],i=[],a=new OXn({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert()??this.websocketGroup?.join(".");this.channel.parameters&&this.convertPathParameters({context:this.context,pathParameters:t}),this.channel.bindings?.ws!=null&&(this.convertHeaders({context:this.context,headers:i}),this.convertBindingQueryParameters({context:this.context,queryParameters:r}));let u;this.channel.subscribe!=null&&(u=this.convertMessage({context:this.context,operation:this.channel.subscribe,origin:"server"}));let c;this.channel.publish!=null&&(c=this.convertMessage({context:this.context,operation:this.channel.publish,origin:"client"}));let d=[];u!=null&&d.push(u),c!=null&&d.push(c);let o=new mdu({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert(),l=this.transformToValidPath(o??this.channelPath),b=this.channel.servers?.[0]??Object.keys(this.context.spec.servers??{})[0],g=b7(l),O=F_(this.channelPath),m=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(O),displayName:a,baseUrl:b,path:g,auth:!1,headers:i,queryParameters:r,pathParameters:t,messages:d,availability:this.context.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs}),docs:this.channel.description,examples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples({fullPath:l,baseUrl:b,asyncApiVersion:"v2"})}},audiences:m,inlinedTypes:this.inlinedTypes}}convertMessage({context:t,operation:r,origin:i}){let n,a=i==="server"?"subscribe":"publish",u=[...this.breadcrumbs,a],c=t.resolveMaybeReference({schemaOrReference:r.message,breadcrumbs:u});c!=null&&(r.message=c);let d=SZi(F_(`${this.channelPath}_${a}`)).replace(/ /g,"");if("oneOf"in r.message){let o=new wA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:u,schemaOrReference:r.message,schemaIdOverride:d}).convert();o!=null&&o.schema!=null&&(n=o.schema,this.inlinedTypes={...this.inlinedTypes,...o.inlinedTypes})}else if(t.isMessageWithPayload(r.message)){let s=t.resolveMaybeReference({schemaOrReference:r.message.payload,breadcrumbs:u});if(s!=null){let l=new wA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:u,schemaOrReference:s,schemaIdOverride:d}).convert();l!=null&&l.schema!=null&&(n=l.schema,this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes})}}if(n!=null){let s=n,o=ol.named({fernFilepath:t.createFernFilepath(),name:s.typeDeclaration.name.name,typeId:s.typeDeclaration.name.typeId,displayName:void 0,default:void 0,inline:!1}),l=iU.reference({bodyType:o,docs:r.description}),b=i==="server"?"subscribe":"publish";return{type:b,displayName:b,origin:i,body:l,availability:t.getAvailability({node:r,breadcrumbs:this.breadcrumbs}),docs:r.description}}}convertPathParameters({context:t,pathParameters:r}){for(let[i,n]of Object.entries(this.channel.parameters??{})){let a=t.resolveMaybeReference({schemaOrReference:n,breadcrumbs:this.breadcrumbs});if(a==null)continue;let c=new J3i({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...a,name:i,in:"path",description:a.description,required:a.required??!0}}).convert();c!=null&&(this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},c.type==="path"&&r.push(c.parameter))}}convertHeaders({context:t,headers:r}){if(this.channel.bindings?.ws?.headers!=null){let i=this.channel.bindings.ws.headers.required??[];for(let[n,a]of Object.entries(this.channel.bindings.ws.headers.properties??{})){let u=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,n]});if(u==null)continue;let d=new J3i({context:this.context,breadcrumbs:[...this.breadcrumbs,n],parameter:{name:n,in:"header",required:i.includes(n),schema:u,description:"description"in u?u.description:void 0}}).convert();d!=null&&d.type==="header"&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},r.push(d.parameter))}}}convertBindingQueryParameters({context:t,queryParameters:r}){if(this.channel.bindings?.ws?.query!=null){let i=this.channel.bindings.ws.query.required??[];for(let[n,a]of Object.entries(this.channel.bindings.ws.query.properties??{})){let u=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,n]});if(u==null)continue;let d=new J3i({context:this.context,breadcrumbs:[...this.breadcrumbs,n],parameter:{name:n,in:"query",required:i.includes(n),schema:u,description:"description"in u?u.description:void 0,deprecated:u.deprecated??!1}}).convert();d!=null&&d.type==="query"&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},r.push(d.parameter))}}}};var mXn=class extends p_{servers;constructor({context:t,breadcrumbs:r,servers:i}){super({context:t,breadcrumbs:r}),this.servers=i}convert(){if(this.servers==null||Object.keys(this.servers).length===0)return;let t=[],r;for(let[i,n]of Object.entries(this.servers)){let a=this.buildSingleBaseUrlEnvironment(this.context,i,n);t.push(a),r==null&&(r=a.id)}return{defaultEnvironment:r,environments:vR.singleBaseUrl({environments:t})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var jdu=class extends mXn{constructor({context:t,breadcrumbs:r,servers:i}){super({context:t,breadcrumbs:r,servers:i})}buildSingleBaseUrlEnvironment(t,r,i){return{id:r,name:t.casingsGenerator.generateName(r),url:this.constructServerUrl(i.protocol,i.url),docs:void 0}}};var jIc="$message.",OF_="#/channels/",mF_="#/servers/",wdu=class extends gXn{operations;inlinedTypes={};constructor({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a,operations:u}){super({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a}),this.operations=u}convert(){let t=[],r=[],i=[],a=new OXn({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert()??this.websocketGroup?.join(".")??this.channelPath;this.channel.parameters&&this.convertChannelParameters({pathParameters:t,queryParameters:r,headers:i,channelPath:this.channelPath});let u=Object.entries(this.operations).reduce((b,[g,O])=>{try{this.getChannelPathFromOperation(O)===this.channelPath&&(b[g]=O)}catch{}return b},{}),c=[];for(let[b,g]of Object.entries(u))for(let O of g.messages){let m=this.context.convertReferenceToTypeReference({reference:O});if(m.ok){let P=iU.reference({bodyType:m.reference,docs:g.description});c.push({type:b,displayName:b,origin:g.action==="send"?"client":"server",body:P,availability:this.context.getAvailability({node:g,breadcrumbs:this.breadcrumbs}),docs:g.description})}}let d=this.resolveChannelServersFromReference(this.channel.servers??[])??Object.keys(this.context.spec.servers??{})[0],s=this.transformToValidPath(this.channel.address??this.channelPath),o=b7(s),l=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(a),displayName:a,baseUrl:d,path:o,auth:!1,headers:i,queryParameters:r,pathParameters:t,messages:c,availability:this.context.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs}),docs:this.channel.description,examples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples({fullPath:s,baseUrl:d,asyncApiVersion:"v3"})}},audiences:l,inlinedTypes:this.inlinedTypes}}convertChannelParameters({pathParameters:t,queryParameters:r,headers:i,channelPath:n}){for(let a of Object.values(this.channel.parameters??{})){let u=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,"parameters"]});if(u==null)continue;let c=this.convertChannelParameterLocation(u.location);if(c==null)continue;let{type:d,parameterKey:s}=c,l=new J3i({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...u,name:s,in:d},parameterNamePrefix:this.channelPath}).convert();if(l!=null)switch(this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes},l.type){case"path":t.push(l.parameter);break;case"query":r.push(l.parameter);break;case"header":i.push(l.parameter);break}}}convertChannelParameterLocation(t){try{let[r,i]=t.split("#/");if(r==null||i==null){this.context.errorCollector.collect({message:`Invalid location format: ${t}; unable to parse message type and parameter key`,path:this.breadcrumbs});return}if(!r.startsWith(jIc)){this.context.errorCollector.collect({message:`Invalid location format: ${t}; expected ${jIc} prefix`,path:this.breadcrumbs});return}let n=r.substring(jIc.length);if(n!=="header"&&n!=="path"&&n!=="payload"){this.context.errorCollector.collect({message:`Invalid message type: ${n}. Must be one of: header, path, payload`,path:this.breadcrumbs});return}return n==="payload"?{type:"query",parameterKey:i}:{type:n,parameterKey:i}}catch{this.context.errorCollector.collect({message:`Invalid location format: ${t}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`,path:this.breadcrumbs});return}}resolveChannelServersFromReference(t){if(t==null||t.length===0||t[0]==null)return;let r=t[0];if(!r.$ref.startsWith(mF_)){this.context.errorCollector.collect({message:`Failed to resolve server name from server ref ${r.$ref}`,path:this.breadcrumbs});return}let i=r.$ref.substring(mF_.length);if(i==null){this.context.errorCollector.collect({message:`Failed to find server with name ${i}`,path:this.breadcrumbs});return}return i}getChannelPathFromOperation(t){if(!t.channel.$ref.startsWith(OF_))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring(OF_.length)}};var Sdu=class extends mXn{constructor({context:t,breadcrumbs:r,servers:i}){super({context:t,breadcrumbs:r,servers:i})}buildSingleBaseUrlEnvironment(t,r,i){return{id:r,name:t.casingsGenerator.generateName(r),url:this.constructServerUrl(i.protocol,i.host),docs:void 0}}};var yUa=class extends IQt{constructor({context:t,breadcrumbs:r,audiences:i}){super({context:t,breadcrumbs:r,audiences:i})}async convert(){return this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.context.spec=await this.resolveAllExternalRefs({spec:this.context.spec}),this.isAsyncAPIV3(this.context)?this.convertChannelMessages():this.convertComponentMessages(),this.convertSchemas(),this.convertServers(),this.convertChannels(),this.finalizeIr()}isAsyncAPIV3(t){return parseFloat(t.spec.asyncapi)>=3}convertChannelMessages(){let t=this.context.spec;for(let[r,i]of Object.entries(t.channels??{}))for(let[n,a]of Object.entries(i.messages??{})){if(!this.context.isMessageWithPayload(a)&&!this.context.isReferenceObject(a))continue;let u=["channels",r,"messages",n],c=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:u});if(!this.context.isMessageWithPayload(c))continue;let d=this.context.resolveMaybeReference({schemaOrReference:c.payload,breadcrumbs:u});if(d==null)continue;let s=`${r}_${n}`;this.convertSchema({id:s,breadcrumbs:u,schema:d})}}convertComponentMessages(){for(let[t,r]of Object.entries(this.context.spec.components?.messages??{})){if(r.payload==null)continue;let i=["components","messages",t],n=this.context.resolveMaybeReference({schemaOrReference:r.payload,breadcrumbs:i});n!=null&&this.convertSchema({id:t,breadcrumbs:i,schema:n})}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{}))this.convertSchema({id:t,breadcrumbs:["components","schemas",t],schema:r})}convertSchema({id:t,breadcrumbs:r,schema:i}){let a=new wA.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:r,schema:i}).convert();a!=null&&(this.addTypeToRootPackage(t),this.addTypesToIr({...a.inlinedTypes,[t]:a.convertedSchema}))}convertServers(){let t;if(this.isAsyncAPIV3(this.context)){let r=this.context.spec.servers;t=new Sdu({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}else{let r=this.context.spec.servers;t=new jdu({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}this.addEnvironmentsToIr({environmentConfig:t})}convertChannels(){for(let[t,r]of Object.entries(this.context.spec.channels??{})){let n=new P$.SdkGroupNameExtension({breadcrumbs:["channels",t],operation:r,context:this.context}).convert()?.groups,a;if(this.isAsyncAPIV3(this.context)){let c=this.context.spec.operations??{};a=new wdu({context:this.context,breadcrumbs:["channels",t],websocketGroup:n,channel:r,channelPath:t,operations:c}).convert()}else a=new Pdu({context:this.context,breadcrumbs:["channels",t],websocketGroup:n,channel:r,channelPath:t}).convert();a!=null&&(this.addWebsocketChannelToIr({websocketChannel:a.channel,channelPath:t,audiences:a.audiences,websocketGroup:n}),this.addTypesToIr(a.inlinedTypes))}}};var vUa=class extends UF{isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}getTypeIdFromMessageReference(t){let r=t.$ref.match(/\/messages\/(.+)$/);if(!(!r||!r[1]))return r[1]}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n}){let a,u=t.$ref.match(/^.*\/schemas\/(.+)$/),c=t.$ref.match(/^.*\/channels\/([^/]+)\/messages\/(.+)$/),d=t.$ref.match(/^.*\/messages\/(.+)$/);if(u&&u[1])return a=u[1],this.convertSchemaReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a});if(c&&c[2]){let s=c[1],o=c[2];return a=`${s}_${o}`,this.convertV3MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a})}else return d&&d[1]?(a=d[1],this.convertV2MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a})):{ok:!1}}convertSchemaReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let c;return n==="reference_identifier"?c=i??u.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(c=u.value.title??i),{ok:!0,reference:ol.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}convertV3MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let c;return n==="reference_identifier"?c=i??u.value.name:(n==="discriminator_key"||n==="schema_identifier")&&(c=u.value.name??i),{ok:!0,reference:ol.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}convertV2MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let c;return n==="reference_identifier"?c=i??u.value.messageId??u.value.name:(n==="discriminator_key"||n==="schema_identifier")&&(c=u.value.messageId??u.value.name??i),{ok:!0,reference:ol.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var DF_=ci(Ddu(),1);var Edu=class extends yO{document;key="x-fern-global-headers";constructor({breadcrumbs:t,document:r,context:i}){super({breadcrumbs:t,context:i}),this.document=r}convert(){let t=this.getExtensionValue(this.document);if(t!=null){if(!Array.isArray(t)){this.context.errorCollector.collect({message:"Received unexpected non-array value for x-fern-global-headers",path:this.breadcrumbs});return}return t}}};function PF_({globalHeaders:e,context:t}){return e.map(r=>({name:t.casingsGenerator.generateNameAndWireValue({name:r.name??"",wireValue:r.header}),valueType:r.optional?p_.OPTIONAL_STRING:p_.STRING,env:r.env,v2Examples:r.optional?void 0:_aM({header:r,context:t}),availability:void 0,docs:void 0}))}function _aM({header:e,context:t}){let r=new vFe({breadcrumbs:[],context:t,schema:{type:"string"},example:e.header}),{validExample:i}=r.convert();return{userSpecifiedExamples:{},autogeneratedExamples:{globalHeaderExample:i}}}var Mdu=class extends wA.AbstractConverters.AbstractParameterConverter{constructor({context:t,breadcrumbs:r,parameter:i}){super({context:t,breadcrumbs:r,parameter:i})}convert(){let t,r={};if(this.parameter.schema!=null){let i=this.context.convertBreadcrumbsToName([...this.breadcrumbs,this.parameter.name]),a=new wA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,this.parameter.name,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required,schemaIdOverride:i}).convert();a!=null&&(t=a.type,r=a.inlinedTypes??{})}return this.convertToOutput({schema:this.parameter.schema??{type:"string"},typeReference:t,inlinedTypes:r})}};var Adu=class extends wA.AbstractConverters.AbstractMediaTypeObjectConverter{contentType;mediaType;description;required;schemaId;streamingExtension;constructor({context:t,breadcrumbs:r,contentType:i,mediaType:n,description:a,required:u,group:c,method:d,streamingExtension:s}){super({context:t,breadcrumbs:r,group:c,method:d}),this.contentType=i,this.mediaType=n,this.description=a,this.required=u,this.schemaId=[...this.group,this.method,"Request"].join("_"),this.streamingExtension=s}convert(){return this.streamingExtension?.type=="streamCondition"?this.convertStreamConditionRequestBody():this.convertNonStreamConditionRequestBody()}convertStreamConditionRequestBody(){if(this.isOrderedJsonOrFormContentType())return this.handleStreamConditionJsonOrFormContent({contentType:this.contentType})}convertNonStreamConditionRequestBody(){if(this.isOrderedJsonOrFormContentType())return this.handleJsonOrFormContent({contentType:this.contentType});if(Uq.parse(this.contentType)?.isMultipart())return this.handleMultipartContent({contentType:this.contentType});if(this.isBinaryContentType())return this.handleBinaryContent({contentType:this.contentType})}isOrderedJsonOrFormContentType(){let t=Uq.parse(this.contentType);return t?t.isJSON()||t.isURLEncoded()||t.isPlainText()||t.isCSV()||t.isHTML()||t.isXML()||t.isDNS()||t.isApplicationText():!1}isBinaryContentType(){let t=Uq.parse(this.contentType);return t?t.isBinary():!1}handleJsonOrFormContent({contentType:t}){let r=this.mediaType;if(r==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});if(i==null)return;let n=i.schema?.typeDeclaration.shape;return n?.type==="object"?{requestBody:nq.inlinedRequestBody({contentType:t,docs:this.description,name:this.context.casingsGenerator.generateName(this.schemaId),extendedProperties:n.extendedProperties,extends:n.extends,properties:n.properties,extraProperties:n.extraProperties,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:i.inlinedTypes})}:{requestBody:nq.reference({contentType:t,docs:this.description,requestBodyType:i.type,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i.inlinedTypes??{}}}handleMultipartContent({contentType:t}){let r=this.mediaType;if(r==null||r.schema==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,resolveSchema:!0,contentType:t});if(i==null)return;let n=i.schema?.typeDeclaration.shape;if(n?.type==="object")return{requestBody:nq.fileUpload({contentType:t,docs:this.description,name:this.context.casingsGenerator.generateName(this.schemaId),properties:n.properties.map(a=>{let u=r.encoding?.[a.name.wireValue];return this.convertRequestBodyProperty({property:a,contentType:t,encoding:u})}),v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:i.inlinedTypes}),examples:i.examples}}handleBinaryContent({contentType:t}){let r=this.mediaType;if(r==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});return{requestBody:nq.bytes({contentType:t,isOptional:this.required===!1,docs:this.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i?.inlinedTypes??{}}}convertRequestBodyProperty({property:t,contentType:r,encoding:i}){let{isFile:n,isOptional:a,isArray:u}=this.recursivelyCheckTypeReferenceIsFile({typeReference:t.valueType});return n?u?X4.file(xoe.fileArray({key:t.name,isOptional:a,contentType:r,docs:t.docs})):X4.file(xoe.file({key:t.name,isOptional:a,contentType:r,docs:t.docs})):X4.bodyProperty({...t,contentType:i?.contentType??r,style:yaM({encoding:i}),name:t.name})}handleStreamConditionJsonOrFormContent({contentType:t}){if(this.streamingExtension?.type!=="streamCondition")return;let r=this.mediaType;if(r==null||r.schema==null)return;let i=this.context.resolveMaybeReference({schemaOrReference:r.schema,breadcrumbs:[...this.breadcrumbs,"content",t,"schema"]});if(i==null)return;let n=i.properties?.[this.streamingExtension.streamConditionProperty];if(n==null||this.context.isReferenceObject(n))return;let a=this.buildStreamConditionInlinedRequestBody({streamConditionProperty:n,resolvedMediaTypeSchema:i,isStreaming:!0,contentType:t,mediaTypeObject:r}),u=this.buildStreamConditionInlinedRequestBody({streamConditionProperty:n,resolvedMediaTypeSchema:i,isStreaming:!1,contentType:t,mediaTypeObject:r});if(!(a==null||u==null))return{requestBody:u.requestBody,streamRequestBody:a.requestBody,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:{...a.inlinedTypes,...u.inlinedTypes}})}}buildStreamConditionInlinedRequestBody({streamConditionProperty:t,resolvedMediaTypeSchema:r,isStreaming:i,contentType:n,mediaTypeObject:a}){if(this.streamingExtension==null||this.streamingExtension.type!=="streamCondition")return;let u={...r,properties:{...r.properties,[this.streamingExtension.streamConditionProperty]:{type:"boolean",const:i,...t}},required:[...r.required??[],this.streamingExtension.streamConditionProperty]},c={...a,schema:u},d=this.parseMediaTypeObject({mediaTypeObject:c,schemaId:this.schemaId,contentType:n});if(d==null)return;let s=d.schema?.typeDeclaration.shape;if(s?.type==="object")return{requestBody:nq.inlinedRequestBody({contentType:n,docs:void 0,name:this.context.casingsGenerator.generateName(i?`${this.schemaId}_streaming`:this.schemaId),extendedProperties:s.extendedProperties,extends:s.extends,properties:s.properties,extraProperties:s.extraProperties,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:c,exampleGenerationStrategy:"request"})}),inlinedTypes:d.inlinedTypes}}recursivelyCheckTypeReferenceIsFile({typeReference:t,isOptional:r,isArray:i}){return this.context.isList(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.list,isOptional:r,isArray:!0}):this.context.isOptional(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.optional,isOptional:!0,isArray:i}):this.context.isNullable(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.nullable,isOptional:r,isArray:i}):{isFile:this.context.isFile(t),isOptional:r??!1,isArray:i??!1}}},haM={"application/json":"json"};function yaM({encoding:e}){if(e){if(e.explode)return"exploded";if(e.style==="form")return"form";if(e.contentType)return haM[e.contentType]}}var vaM=/{([^}]+)}/g,baM=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]),PXn=class extends p_{operation;method;path;inlinedTypes={};constructor({context:t,breadcrumbs:r,operation:i,method:n,path:a}){super({context:t,breadcrumbs:r}),this.operation=i,this.method=n,this.path=a}convertHttpMethod(){switch(this.method){case"get":return uI.Get;case"post":return uI.Post;case"put":return uI.Put;case"delete":return uI.Delete;case"patch":return uI.Patch;case"head":return uI.Head;default:return}}convertParameters({breadcrumbs:t}){let r=[],i=[],n=[];if(!this.operation.parameters)return this.checkMissingPathParameters(r),{pathParameters:r,queryParameters:i,headers:n};for(let a of this.operation.parameters){let u=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:t});if(u==null)continue;let d=new Mdu({context:this.context,breadcrumbs:t,parameter:u}).convert();if(d!=null)switch(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},d.type){case"path":r.push(d.parameter);break;case"query":i.push(d.parameter);break;case"header":{let s=d.parameter.name.name.originalName,o=d.parameter.name.wireValue,l=!1,b=this.context.authOverrides?.["auth-schemes"];if(b!=null){for(let O of Object.values(b))if(PaM(O)&&O.header.toLowerCase()===o.toLowerCase()){l=!0;break}}let g=this.context.globalHeaderNames;if(g!=null){for(let O of g)if(O.toLowerCase()===o.toLowerCase()){l=!0;break}}!baM.has(s.toLowerCase())&&!l&&n.push(d.parameter);break}}}return this.checkMissingPathParameters(r),{pathParameters:r,queryParameters:i,headers:n}}checkMissingPathParameters(t){let i=[...this.path.matchAll(vaM)].map(n=>n[1]).filter(n=>!t.some(a=>a.name.originalName===n));for(let n of i){if(n==null)continue;let a=`${n}_example`;t.push({name:this.context.casingsGenerator.generateName(n),valueType:p_.STRING,docs:void 0,location:"ENDPOINT",variable:void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{[a]:this.generateStringParameterExample({example:n})}}})}}convertRequestBody({breadcrumbs:t,group:r,method:i,streamingExtension:n}){if(this.operation.requestBody==null)return;let a=this.context.resolveMaybeReference({schemaOrReference:this.operation.requestBody,breadcrumbs:t});if(a==null)return null;let u=[];for(let[c,d]of Object.entries(a.content)){let o=new Adu({context:this.context,breadcrumbs:t,contentType:c,mediaType:d,description:a.description,required:a.required,group:r??[],method:i,streamingExtension:n}).convert();o!=null&&(this.inlinedTypes={...this.inlinedTypes,...o.inlinedTypes},u.push({requestBody:o.requestBody,streamRequestBody:o.streamRequestBody,examples:o.examples}))}return u}computeGroupNameAndLocationFromExtensions(){let r=new P$.SdkMethodNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.methodName,n=new P$.SdkGroupNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.groups??[];if(r!=null)return{group:n,method:r}}evaluateMethodNameFromOperation(){let t=this.operation.operationId;return t??(this.operation.summary!=null?F_(this.operation.summary):F_(`${this.method}_${this.path.split("/").join("_")}`))}computeGroupNameFromTagAndOperationId(){let t=this.operation.tags?.[0],r=this.evaluateMethodNameFromOperation();if(t==null)return{method:r};let i=jF_(t),n=jF_(r);return Y8(i,n)?{method:t}:this.computeGroupAndMethodFromTokens({tag:t,tagTokens:i,methodName:r,methodNameTokens:n})}computeGroupAndMethodFromTokens({tag:t,tagTokens:r,methodName:i,methodNameTokens:n}){if(r.some((c,d)=>c!==n[d]))return{group:[t],method:i};let u=n.slice(r.length);return{group:[t],method:F_(u.join("_"))}}generateStringParameterExample({example:t}){let r=new wA.ExampleConverter({breadcrumbs:this.breadcrumbs,context:this.context,schema:{type:"string"},example:t}),{validExample:i}=r.convert();return i}};function jF_(e){let t=gaM(e)?OaM(e):maM(e);return t=t.map(r=>r.toLowerCase()),t=MNe(t),t}function gaM(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function OaM(e){return e.split(/(?=[A-Z])/)}function maM(e){return e.split(/[^a-zA-Z0-9]+/)}function PaM(e){return e?.header!=null}var jXn=class extends PXn{constructor({context:t,breadcrumbs:r,operation:i,method:n,path:a}){super({context:t,breadcrumbs:r,operation:i,method:n,path:a})}convert(){if(this.operation.requestBody==null){this.context.errorCollector.collect({message:"Skipping webhook because no request body present",path:this.breadcrumbs});return}let t=this.convertHttpMethod();if(t==null)return;if(t!=="POST"&&t!=="GET"){this.context.errorCollector.collect({message:"Skipping webhook because non-POST or GET method",path:this.breadcrumbs});return}let{group:r,method:i}=this.computeGroupNameAndLocationFromExtensions()??this.computeGroupNameFromTagAndOperationId(),n=[...this.breadcrumbs,"Payload"],{headers:a}=this.convertParameters({breadcrumbs:n}),u=this.convertRequestBody({breadcrumbs:n,group:r,method:i,streamingExtension:void 0});if(u==null)return;let c=u[0]?.requestBody;if(c==null)return;let d;if(c.type==="inlinedRequestBody")d=XH.inlinedPayload({name:c.name,extends:c.extends,properties:c.properties});else if(c.type==="reference")d=XH.reference({payloadType:c.requestBodyType,docs:c.docs});else return;return{audiences:this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],group:r,webhook:{id:`${r?.join(".")??""}.${i}`,name:this.context.casingsGenerator.generateName(i),displayName:this.operation.summary,method:t,headers:a,payload:d,examples:[],availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),docs:this.operation.description,v2Examples:{autogeneratedExamples:this.getWebhookV2ExamplesFromRequestBodyV2Examples(c.v2Examples?.autogeneratedExamples??{}),userSpecifiedExamples:this.getWebhookV2ExamplesFromRequestBodyV2Examples(c.v2Examples?.userSpecifiedExamples??{})}},inlinedTypes:this.inlinedTypes}}getWebhookV2ExamplesFromRequestBodyV2Examples(t){return Object.fromEntries(Object.entries(t).map(([r,i])=>[r,{name:r,payload:i}]))}};var DIc=ci(Ddu(),1);var wF_=["get","post","put","delete","patch","head"];var qdu=class extends yO{operation;key="x-fern-idempotent";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-idempotent",path:this.breadcrumbs});return}return t}}};var jaM=ou.object({cursor:ou.string(),next_cursor:ou.string(),results:ou.string()}),waM=ou.object({offset:ou.string(),results:ou.string(),step:ou.string().optional(),"has-next-page":ou.string().optional()}),wIc=ou.union([ou.boolean(),jaM,waM]);var SIc="$request.",Tdu="$response.",Cdu=class extends yO{operation;document;key="x-fern-pagination";constructor({breadcrumbs:t,operation:r,document:i,context:n}){super({breadcrumbs:t,context:n}),this.operation=r,this.document=i}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=wIc.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-pagination extension: ${r.error.message}`,path:this.breadcrumbs});return}if(typeof r.data=="boolean"){let i=this.getExtensionValue(this.document);if(i==null)return;if(typeof i=="boolean"){this.context.errorCollector.collect({message:"Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.",path:this.breadcrumbs});return}let n=wIc.safeParse(i);if(!n.success){this.context.errorCollector.collect({message:`Invalid x-fern-pagination extension: ${n.error.message}`,path:this.breadcrumbs});return}if(typeof n.data=="boolean"){this.context.errorCollector.collect({message:"Global pagination extension is a boolean, expected an object.",path:this.breadcrumbs});return}return this.convertPaginationConfig({config:n.data})}if(typeof r.data=="boolean"){this.context.errorCollector.collect({message:"Pagination extension is a boolean with no global configuration.",path:this.breadcrumbs});return}return this.convertPaginationConfig({config:r.data})}convertPaginationConfig({config:t}){let r=t;if("cursor"in r)return{type:"cursor",cursor:UF.maybeTrimPrefix(r.cursor,SIc),nextCursor:UF.maybeTrimPrefix(r.next_cursor,Tdu),results:UF.maybeTrimPrefix(r.results,Tdu)};let i=t;return{type:"offset",offset:UF.maybeTrimPrefix(i.offset,SIc),results:UF.maybeTrimPrefix(i.results,Tdu),step:i.step!=null?UF.maybeTrimPrefix(i.step,SIc):void 0,hasNextPage:i["has-next-page"]!=null?UF.maybeTrimPrefix(i["has-next-page"],Tdu):void 0}}};var SaM="$request.",DaM=ou.object({"stream-condition":ou.string().optional(),format:ou.enum(["sse","json"]).optional(),"stream-description":ou.string().optional(),"response-stream":ou.any(),response:ou.any()}),EaM=ou.union([ou.boolean(),DaM]),Bdu=class extends yO{operation;key="x-fern-streaming";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=EaM.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-streaming extension: ${r.error.message}`,path:this.breadcrumbs});return}if(typeof r.data=="boolean")return r.data?{type:"stream",format:"json"}:void 0;if(r.data["stream-condition"]==null&&r.data.format!=null)return{type:"stream",format:r.data.format};if(r.data["stream-condition"]==null){this.context.errorCollector.collect({message:"Missing stream-condition property without specified format.",path:this.breadcrumbs});return}return{type:"streamCondition",format:r.data.format??"json",streamDescription:r.data["stream-description"],streamConditionProperty:UF.maybeTrimPrefix(r.data["stream-condition"],SaM),responseStream:r.data["response-stream"],response:r.data.response}}};var Idu=class extends yO{operation;key="x-fern-webhook";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-webhook",path:this.breadcrumbs});return}return t}}};var zdu=class extends yO{operation;key="x-fern-examples";constructor({context:t,breadcrumbs:r,operation:i}){super({breadcrumbs:r,context:t}),this.operation=i}convert(){let t=this.getExtensionValue(this.operation);return t==null?void 0:(Array.isArray(t)?t:[]).filter(n=>{let a=i7.serialization.ExampleEndpointCallSchema.parse(n);return a.ok||this.context.errorCollector.collect({message:`Failed to parse x-fern-example in ${this.breadcrumbs.join(".")}`,path:this.breadcrumbs}),a.ok})}};var xdu=class extends wA.AbstractConverters.AbstractMediaTypeObjectConverter{responseBody;statusCode;streamingExtension;constructor({context:t,breadcrumbs:r,responseBody:i,group:n,method:a,statusCode:u,streamingExtension:c}){super({context:t,breadcrumbs:r,group:n,method:a}),this.responseBody=i,this.statusCode=u,this.streamingExtension=c}convert(){return this.shouldConvertAsStreaming()?this.convertStreamingResponseBody():this.convertNonStreamingResponseBody()}convertStreamingResponseBody(){if(this.streamingExtension!=null){if(this.streamingExtension.type=="streamCondition"){let t=this.streamingExtension.responseStream,r=this.streamingExtension.response,i=[...this.group,this.method,"Response",this.statusCode].join("_"),n=`${i}_streaming`,a=this.parseMediaTypeSchemaOrReference({schemaOrReference:t,schemaId:n}),u=this.parseMediaTypeSchemaOrReference({schemaOrReference:r,schemaId:i});return this.convertStreamConditionResponse({convertedStreamingSchema:a,convertedNonStreamingSchema:u})}if(this.streamingExtension.type==="stream"){let t=[...this.group,this.method,"Response",this.statusCode].join("_"),r=Object.keys(this.responseBody.content??{});for(let i of r){let n=this.responseBody.content?.[i];if(n==null)continue;let a=this.parseMediaTypeObject({mediaTypeObject:n,schemaId:t,contentType:this.streamingExtension.format});if(a!=null)return this.convertStreamingResponse({mediaTypeObject:n,convertedSchema:a})}}}}convertNonStreamingResponseBody(){let t=[...this.group,this.method,"Response",this.statusCode].join("_"),r=Object.keys(this.responseBody.content??{}).filter(a=>a.includes("json"));for(let a of r){let u=this.responseBody.content?.[a];if(u==null)continue;let c=this.parseMediaTypeObject({mediaTypeObject:u,schemaId:t,contentType:a});if(c!=null&&this.shouldReturnJsonResponse(a))return this.returnJsonResponse({mediaTypeObject:u,convertedSchema:c})}let i=Object.keys(this.responseBody.content??{}).filter(a=>!a.includes("json"));for(let a of i){let u=this.responseBody.content?.[a];if(u==null)continue;let c=this.parseMediaTypeObject({mediaTypeObject:u,schemaId:t,contentType:a});if(c!=null){if(this.isBinarySchema(c))return this.shouldReturnBytesResponse()?this.returnBytesResponse({mediaTypeObject:u}):this.returnFileDownloadResponse({mediaTypeObject:u});if(this.shouldReturnTextResponse(a))return this.returnTextResponse({mediaTypeObject:u})}}let n=parseInt(this.statusCode);if(!isNaN(n)&&n>=200&&n<300){let a={schema:{type:"object",description:"Empty response body"}},u=this.parseMediaTypeObject({mediaTypeObject:a,schemaId:t,contentType:"application/json",resolveSchema:!0});if(u!=null)return this.returnJsonResponse({mediaTypeObject:a,convertedSchema:u})}}convertStreamConditionResponse({convertedStreamingSchema:t,convertedNonStreamingSchema:r}){if(!(t==null||r==null))return{responseBody:q1.json(kL.response({responseBodyType:r.type,docs:this.responseBody.description,v2Examples:r.schema?.typeDeclaration.v2Examples})),streamResponseBody:q1.streaming(eU.json({docs:this.responseBody.description,payload:t.type,terminator:void 0,v2Examples:t.schema?.typeDeclaration.v2Examples})),inlinedTypes:{...t.inlinedTypes,...r.inlinedTypes}}}convertStreamingResponse({mediaTypeObject:t,convertedSchema:r}){if(this.streamingExtension==null)return;switch(this.streamingExtension.format){case"json":return{responseBody:q1.streaming(eU.json({docs:this.responseBody.description,payload:r.type,terminator:void 0,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples};case"sse":return{responseBody:q1.streaming(eU.sse({docs:this.responseBody.description,payload:r.type,terminator:void 0,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples};default:return}}returnJsonResponse({mediaTypeObject:t,convertedSchema:r}){return{responseBody:q1.json(kL.response({responseBodyType:r.type,docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples}}returnBytesResponse({mediaTypeObject:t}){return{responseBody:q1.bytes({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}returnFileDownloadResponse({mediaTypeObject:t}){return{responseBody:q1.fileDownload({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}returnTextResponse({mediaTypeObject:t}){return{responseBody:q1.text({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}isBinarySchema(t){let r=t.type;switch(r.type){case"container":case"named":case"unknown":return!1;case"primitive":return r.primitive.v2==null?!1:r.primitive.v2.type==="string"&&r.primitive.v2.validation?.format==="binary";default:return!1}}shouldConvertAsStreaming(){return this.streamingExtension!=null}shouldReturnJsonResponse(t){return t.includes("json")}shouldReturnBytesResponse(){return this.context.settings.useBytesForBinaryResponse&&this.streamingExtension==null}shouldReturnTextResponse(t){return Uq.parse(t)?.isText()??!1}};var Rdu=class extends wA.AbstractConverters.AbstractMediaTypeObjectConverter{responseError;statusCode;methodName;constructor({context:t,breadcrumbs:r,responseError:i,group:n,method:a,methodName:u,statusCode:c}){super({context:t,breadcrumbs:r,group:n,method:a}),this.responseError=i,this.statusCode=c,this.methodName=u}convert(){if(!this.responseError.content){let i=Q8a[this.statusCode];if(i==null){this.context.logger.warn(`No error name found for status code ${this.statusCode}`);return}let n=this.getErrorIdFromErrorName(i);return{error:{error:{name:this.context.casingsGenerator.generateName(n),fernFilepath:{allParts:[],packagePath:[],file:void 0},errorId:n},docs:this.responseError.description},errorType:ol.unknown(),displayName:i,statusCode:this.statusCode,inlinedTypes:{},examples:{}}}let t=Object.keys(this.responseError.content).filter(i=>i.includes("json")),r=Q8a[this.statusCode];if(r==null){this.context.logger.warn(`No error name found for status code ${this.statusCode}`);return}for(let i of[...t]){let n=this.responseError.content?.[i];if(n==null)continue;let a=this.parseMediaTypeObject({mediaTypeObject:n,schemaId:SF_(`${this.methodName}Request${r}`),contentType:i});if(a==null)continue;let u=this.getErrorIdFromErrorName(r);if(a.schema!=null)return this.constructErrorConverterOutput({errorName:r,errorId:u,fernFilepath:a.schema.typeDeclaration.name.fernFilepath,convertedSchema:a});if(a.type.type==="named")return this.constructErrorConverterOutput({errorName:r,errorId:u,fernFilepath:a.type.fernFilepath,convertedSchema:a})}}constructErrorConverterOutput({errorName:t,errorId:r,fernFilepath:i,convertedSchema:n}){return{error:{error:{name:this.context.casingsGenerator.generateName(r),fernFilepath:i,errorId:r},docs:this.responseError.description},errorType:n.type,displayName:t,statusCode:this.statusCode,inlinedTypes:n.inlinedTypes,examples:n.examples}}getErrorIdFromErrorName(t){return this.context.enableUniqueErrorsPerEndpoint?SF_(`${this.methodName}Request${t}`):t}};function SF_(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var Ndu=class e extends PXn{idempotent;idToAuthScheme;topLevelServers;streamingExtension;static AUTHORIZATION_HEADER="Authorization";constructor({context:t,breadcrumbs:r,operation:i,method:n,path:a,idempotent:u,idToAuthScheme:c,topLevelServers:d,streamingExtension:s}){super({context:t,breadcrumbs:r,operation:i,method:n,path:a}),this.idempotent=u,this.idToAuthScheme=c,this.topLevelServers=d,this.streamingExtension=s}convert(){let t=this.convertHttpMethod();if(t==null)return;let{group:r,method:i}=this.computeGroupNameAndLocationFromExtensions()??this.computeGroupNameFromTagAndOperationId(),n=this.getGroupDisplayName(r),{headers:a,pathParameters:u,queryParameters:c}=this.convertParameters({breadcrumbs:[...this.breadcrumbs,"parameters"]}),d=this.convertRequestBody({breadcrumbs:[...this.breadcrumbs,"requestBody"],group:r,method:i,streamingExtension:this.streamingExtension}),s=d?.[0]?.requestBody,o=d?.[0]?.streamRequestBody,l={requestBodies:d?.map(J=>J.requestBody)},b=this.convertResponseBody({breadcrumbs:[...this.breadcrumbs,"responses"],group:r,method:i,streamingExtension:this.streamingExtension}),g=b?.response,O=b?.streamResponse,m=b!=null?b.errors:[],P={},D=m.map(J=>J.error),A=b7(this.path),M=this.getEndpointBaseUrl(),E=this.getEndpointBaseUrls(),T=this.convertExamples({httpPath:A,httpMethod:t,baseUrl:M}),z=new Set(this.operation.security?.flatMap(J=>Object.keys(J))??[]),$=this.authSchemeToHeaders(Array.from(z));$.length>0&&a.push(...$);for(let J of m){let X=J.error,oe=J.errorType,pe=X.error.errorId,de=J.examples;P[pe]={name:X.error,displayName:J.displayName,discriminantValue:{name:X.error.name,wireValue:pe},type:oe,statusCode:J.statusCode,docs:X.docs,examples:[],v2Examples:{userSpecifiedExamples:de??{},autogeneratedExamples:{}}}}let I=this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],N={displayName:this.operation.summary,method:t,baseUrl:M,v2BaseUrls:E,path:A,pathParameters:u,queryParameters:c,headers:a.filter((J,X,oe)=>X===oe.findIndex(pe=>pe.name.wireValue===J.name.wireValue)),sdkRequest:void 0,errors:D,auth:this.operation.security!=null||this.context.spec.security!=null,availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:this.idempotent??!1,basePath:void 0,fullPath:A,allPathParameters:u,pagination:void 0,transport:void 0,source:oK.openapi(),audiences:I},U=this.context.namespace!=null?[this.context.namespace]:[],Y=r?.map(J=>F_(J));return U.push(...Y??[]),{audiences:I,group:r,groupDisplayName:n,errors:P,endpoint:{...N,id:`endpoint_${U.join("/")}.${i}`,name:this.context.casingsGenerator.generateName(i),requestBody:s,v2RequestBodies:l,response:g,docs:this.operation.description,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:T.examples},v2Responses:{responses:b?.v2Responses}},streamEndpoint:O!=null&&O.body!=null?{...N,id:`endpoint_${U.join("/")}.${i}_stream`,name:this.context.casingsGenerator.generateName(`${i}_stream`),requestBody:o,v2RequestBodies:void 0,response:O,docs:this.streamingExtension?.type==="streamCondition"?this.streamingExtension.streamDescription??this.operation.description:this.operation.description,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:T.streamExamples},v2Responses:{responses:b?.v2Responses}}:void 0,inlinedTypes:this.inlinedTypes,servers:this.filterOutTopLevelServers(this.operation.servers??[])}}convertResponseBody({breadcrumbs:t,group:r,method:i,streamingExtension:n}){if(this.operation.responses==null)return;let a,u=!1;for(let[c,d]of Object.entries(this.operation.responses)){let s=parseInt(c);if(!(isNaN(s)||s<200||s>=300&&s<400)){if(a==null&&(a={response:void 0,v2Responses:void 0,streamResponse:void 0,errors:[],examples:{}}),s>=200&&s<300){let o=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,c]});if(o==null)continue;let b=new xdu({context:this.context,breadcrumbs:[...t,c],responseBody:o,group:r??[],method:i,statusCode:c,streamingExtension:n}).convert();b!=null&&(this.inlinedTypes={...this.inlinedTypes,...b.inlinedTypes},u||(u=!0,a.response={statusCode:s,body:b.responseBody},a.streamResponse={statusCode:s,body:b.streamResponseBody}),a.v2Responses=[...a.v2Responses??[],{statusCode:s,body:b.responseBody}])}if(s>=400&&s<600){let o=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,c]});if(o==null)continue;let b=new Rdu({context:this.context,breadcrumbs:[...t,c],responseError:o,group:r??[],method:i,methodName:this.evaluateMethodNameFromOperation(),statusCode:s}).convert();b!=null&&(this.inlinedTypes={...this.inlinedTypes,...b.inlinedTypes},a.errors.push(b))}}}return a}authSchemeToHeaders(t){let r=[];for(let i of t){let n=this.idToAuthScheme?.[i];if(n==null)continue;let a={valueType:p_.STRING,availability:void 0,docs:void 0,env:void 0,v2Examples:void 0};switch(n.type){case"bearer":r.push({name:{name:this.context.casingsGenerator.generateName(e.AUTHORIZATION_HEADER),wireValue:e.AUTHORIZATION_HEADER},...a});break;case"basic":r.push({name:{name:this.context.casingsGenerator.generateName(e.AUTHORIZATION_HEADER),wireValue:e.AUTHORIZATION_HEADER},...a});break;case"header":r.push({name:n.name,...a});break}}return r}convertExamples({httpPath:t,httpMethod:r,baseUrl:i}){let a=new zdu({context:this.context,breadcrumbs:this.breadcrumbs,operation:this.operation}).convert();return a==null?{examples:{},streamExamples:{}}:this.streamingExtension?.type==="streamCondition"?this.convertStreamConditionExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:a}):{examples:this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:a}),streamExamples:{}}}convertStreamConditionExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:n}){let a=n.filter(s=>!(s.response!=null&&"stream"in s.response)),u=n.filter(s=>s.response!=null&&"stream"in s.response),c=this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:a}),d=this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:u});return{examples:c,streamExamples:d}}convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:n}){return Object.fromEntries(n.map((a,u)=>[this.getExampleName({example:a,exampleIndex:u}),{displayName:void 0,request:a.request!=null?{docs:void 0,endpoint:{method:r,path:this.buildExamplePath(t,a["path-parameters"]??{})},baseUrl:void 0,environment:i,auth:void 0,pathParameters:a["path-parameters"]??{},queryParameters:a["query-parameters"]??{},headers:a.headers??{},requestBody:a.request}:void 0,response:a.response!=null?{docs:void 0,statusCode:void 0,body:this.getExampleResponseBody({example:a})}:void 0,codeSamples:a["code-samples"]?.map(c=>{let d=("language"in c?c.language:c.sdk)??void 0;return{name:c.name,docs:void 0,language:d,code:c.code}})}]))}getExampleName({example:t,exampleIndex:r}){return t.name??t["code-samples"]?.[0]?.name??`Example_${r}`}getExampleResponseBody({example:t}){if(t.response!=null){if("stream"in t.response)return Js.V2HttpEndpointResponseBody.stream(t.response.stream);if("body"in t.response)return Js.V2HttpEndpointResponseBody.json(t.response.body)}}getEndpointBaseUrl(){let t=this.operation.servers?.[0];if(t==null)return;let i=this.topLevelServers?.find(n=>n.url===t.url)??t;return Dqe.getServerName({server:i,context:this.context})}getEndpointBaseUrls(){let t=this.operation.servers;return t?.map(i=>{let a=this.topLevelServers?.find(u=>u.url===i.url)??i;return Dqe.getServerName({server:a,context:this.context})})}buildExamplePath(t,r){return t.head+t.parts.map(i=>`${r[i.pathParameter]?.toString()??i.pathParameter}${i.tail}`).join("")}filterOutTopLevelServers(t){return t.filter(r=>!this.topLevelServers?.some(i=>i.url===r.url))}getGroupDisplayName(t){let r=this.operation.tags?.[0];r!=null&&(r=this.context.getDisplayNameForTag(r));let i=t?.[t.length-1];if(i!=null&&r!=null)return r.toLowerCase().replaceAll(" ","")===i?r:void 0}};var Fdu=class extends p_{pathItem;path;idToAuthScheme;topLevelServers;constructor({context:t,breadcrumbs:r,pathItem:i,path:n,idToAuthScheme:a,topLevelServers:u}){super({context:t,breadcrumbs:r}),this.pathItem=i,this.path=n,this.idToAuthScheme=a,this.topLevelServers=u}convert(){let t=[],r=[],i={};for(let n of wF_){let a=this.pathItem[n];if(a==null)continue;let u=[...this.breadcrumbs,n],c=this.tryParseAsWebhook({operationBreadcrumbs:u,operation:a,method:n,context:this.context});if(c!=null){r.push(c),Object.assign(i,c.inlinedTypes);continue}let s=new Bdu({breadcrumbs:u,operation:a,context:this.context}).convert(),o=this.tryParseAsHttpEndpoint({operationBreadcrumbs:u,operation:a,method:n,streamingExtension:s});o!=null&&(t.push(o),Object.assign(i,o.inlinedTypes))}return{endpoints:t,webhooks:r,inlinedTypes:i}}tryParseAsWebhook({operation:t,method:r,operationBreadcrumbs:i,context:n}){return new Idu({breadcrumbs:i,operation:t,context:n}).convert()?new jXn({context:this.context,breadcrumbs:i,operation:t,method:DIc.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert():void 0}tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:i,streamingExtension:n}){new Cdu({breadcrumbs:i,operation:t,document:this.context.spec,context:this.context}).convert()!=null;let d=new qdu({breadcrumbs:i,operation:t,context:this.context}).convert();return new Ndu({context:this.context,breadcrumbs:i,operation:t,method:DIc.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:d,idToAuthScheme:this.idToAuthScheme,topLevelServers:this.topLevelServers,streamingExtension:n}).convert()}};var Ldu=class extends p_{securityScheme;constructor({context:t,breadcrumbs:r,securityScheme:i}){super({context:t,breadcrumbs:r}),this.securityScheme=i}convert(){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme==="bearer")return iq.bearer({token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description});if(this.securityScheme.scheme==="basic")return iq.basic({username:this.context.casingsGenerator.generateName("username"),password:this.context.casingsGenerator.generateName("password"),usernameEnvVar:void 0,passwordEnvVar:void 0,docs:this.securityScheme.description});break}case"apiKey":{if(this.securityScheme.in==="header")return iq.header({name:{name:this.context.casingsGenerator.generateName("apiKey"),wireValue:this.securityScheme.name},valueType:p_.OPTIONAL_STRING,prefix:void 0,headerEnvVar:void 0,docs:this.securityScheme.description});break}case"oauth2":return iq.bearer({token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var bUa=class extends IQt{constructor({breadcrumbs:t,context:r,audiences:i}){super({breadcrumbs:t,context:r,audiences:i})}async convert(){this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.context.spec=await this.resolveAllExternalRefs({spec:this.context.spec});let t=this.convertSecuritySchemes();this.convertGlobalHeaders(),this.convertSchemas(),this.convertWebhooks();let{endpointLevelServers:r,errors:i}=this.convertPaths({idToAuthScheme:t});this.addErrorsToIr(i);let{defaultUrl:n}=this.convertServers({endpointLevelServers:r});return this.updateEndpointsWithDefaultUrl(n),this.finalizeIr()}convertGlobalHeaders(){this.context.globalHeaderOverrides;let r=new Edu({breadcrumbs:["x-fern-global-headers"],document:this.context.spec,context:this.context}).convert();if(r!=null){let i=PF_({globalHeaders:r,context:this.context});this.addGlobalHeadersToIr(i),this.context.setGlobalHeaders(i)}}convertSecuritySchemes(){if(this.context.authOverrides)return this.addAuthToIR(Ejc({rawApiFileSchema:this.context.authOverrides,casingsGenerator:this.context.casingsGenerator})),{};let t={},r=[];for(let[i,n]of Object.entries(this.context.spec.components?.securitySchemes??{})){let a=this.context.resolveMaybeReference({schemaOrReference:n,breadcrumbs:["components","securitySchemes",i]});if(a==null)continue;let c=new Ldu({context:this.context,breadcrumbs:["components","securitySchemes",i],securityScheme:a}).convert();c!=null&&(this.shouldAddAuthSchemeToIr({authScheme:c,schemeId:i,currentSecuritySchemes:r})?r.push(c):t[i]=c)}return r.length>0&&this.addAuthToIR({requirement:r.length===1?"ALL":"ANY",schemes:r,docs:void 0}),t}convertServers({endpointLevelServers:t}){if(this.context.environmentOverrides){let n=R8a({rawApiFileSchema:this.context.environmentOverrides,casingsGenerator:this.context.casingsGenerator});return n!=null&&this.addEnvironmentsToIr({environmentConfig:n.environmentsConfig,audiences:n.audiences}),{defaultUrl:this.context.environmentOverrides["default-url"]}}let i=new Dqe({context:this.context,breadcrumbs:["servers"],servers:this.context.spec.servers,endpointLevelServers:t}).convert();return this.addEnvironmentsToIr({environmentConfig:i?.value}),{defaultUrl:i?.defaultUrl}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{})){let n=new wA.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();n!=null&&(this.addTypeToPackage(t),this.addTypesToIr({...n.inlinedTypes,[t]:n.convertedSchema}))}}convertWebhooks(){for(let[,t]of Object.entries(this.context.spec.webhooks??{})){if(t==null){this.context.errorCollector.collect({message:"Skipping empty webhook",path:this.breadcrumbs});continue}if(!("post"in t)){this.context.errorCollector.collect({message:"Skipping webhook as it is not a POST method",path:this.breadcrumbs});continue}if(t.post?.operationId==null){this.context.errorCollector.collect({message:"Skipping webhook as no operationId is present",path:this.breadcrumbs});continue}let r=t.post.operationId,n=new jXn({context:this.context,breadcrumbs:["webhooks",r],operation:t.post,method:DF_.OpenAPIV3.HttpMethods.POST,path:r}).convert();n!=null&&(this.addWebhookToIr({webhook:n.webhook,operationId:r,audiences:n.audiences,group:n.group}),this.addTypesToIr(n.inlinedTypes))}}convertPaths({idToAuthScheme:t}){let r=[],i={};for(let[n,a]of Object.entries(this.context.spec.paths??{})){if(a==null)continue;let c=new Fdu({context:this.context,breadcrumbs:["paths",n],topLevelServers:this.context.spec.servers,pathItem:a,path:n}).convert();if(c!=null){for(let d of c.endpoints){if(d.streamEndpoint!=null&&this.addEndpointToIr({endpoint:d.streamEndpoint,audiences:d.audiences,endpointGroup:d.group,endpointGroupDisplayName:d.groupDisplayName}),this.addEndpointToIr({endpoint:d.endpoint,audiences:d.audiences,endpointGroup:d.group,endpointGroupDisplayName:d.groupDisplayName}),d.servers)for(let s of d.servers)this.shouldAddServerToCollectedServers({server:s,currentServers:r})&&r.push(s);if(d.errors)for(let[s,o]of Object.entries(d.errors))i[s]=o}for(let d of c.webhooks){let s=this.context.getGroup({groupParts:d.group,namespace:this.context.namespace});this.addWebhookToIr({webhook:d.webhook,operationId:s.join("."),group:s,audiences:d.audiences})}this.addTypesToIr(c.inlinedTypes)}}return{endpointLevelServers:r,errors:i}}shouldAddAuthSchemeToIr({authScheme:t,schemeId:r,currentSecuritySchemes:i}){let n=i.some(u=>u.type===t.type&&u.type==="bearer"&&t.type==="bearer"?u.token===t.token:!1),a=new Set(this.context.spec.security?.flatMap(u=>Object.keys(u))??[]);return(a.size===0||a.has(r))&&!n}};var Udu=class extends yO{tag;key="x-displayName";constructor({breadcrumbs:t,tag:r,context:i}){super({breadcrumbs:t,context:i}),this.tag=r}convert(){if(typeof this.tag!="object"||this.tag==null)return;let t=this.tag[this.key];if(t!=null){if(typeof t!="string"){this.context.errorCollector.collect({message:"x-displayName extension must be a string",path:this.breadcrumbs});return}if(t.trim().length!==0)return{displayName:t}}}};var gUa=class extends UF{globalHeaderNames;tagToDisplayName={};isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n}){let a=this.getTypeIdFromSchemaReference(t);if(a==null)return{ok:!1};let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let c;n==="reference_identifier"?c=i??u.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(c=u.value.title??i);let d;if(a.includes("/")){let o=new wA.SchemaConverters.SchemaConverter({context:this,breadcrumbs:r??[],schema:u.value,id:a}).convert();o!=null&&(d={[a]:o.convertedSchema})}return{ok:!0,reference:ol.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,default:void 0,inline:!1,displayName:c}),inlinedTypes:d}}setGlobalHeaders(t){this.globalHeaderNames=t.map(r=>r.name.wireValue)}getDisplayNameForTag(t){if(Object.keys(this.tagToDisplayName).length===0)for(let r of this.spec.tags??[]){let n=new Udu({breadcrumbs:["tags",r.name],tag:r,context:this}).convert()?.displayName??r.name;this.tagToDisplayName[r.name]=n}return this.tagToDisplayName[t]??t}};var MaM=ou.object({description:ou.string().optional(),required:ou.boolean().optional(),deprecated:ou.boolean().optional(),allowEmptyValue:ou.boolean().optional(),style:ou.string().optional(),explode:ou.boolean().optional(),allowReserved:ou.boolean().optional(),schema:ou.any().optional(),example:ou.any().optional(),examples:ou.record(ou.string(),ou.any()).optional(),content:ou.record(ou.string(),ou.any()).optional()}),AaM=MaM.extend({name:ou.string(),in:ou.string()}),qaM=ou.array(AaM),Vdu=class extends yO{operation;key="x-fern-parameters";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null)try{return qaM.parse(t)}catch(r){this.context.errorCollector.collect({message:`Failed to parse x-fern-parameters extension: ${r instanceof Error?r.message:String(r)}`,path:this.breadcrumbs});return}}};var Wdu=class extends p_{method;pathParameters;queryParameters;headers;topLevelServers;constructor({context:t,breadcrumbs:r,method:i,pathParameters:n=[],queryParameters:a=[],headers:u=[],topLevelServers:c=[]}){super({context:t,breadcrumbs:r}),this.method=i,this.pathParameters=n,this.queryParameters=a,this.headers=u,this.topLevelServers=c}convert(){let t={},r="";for(let s of this.pathParameters)r+=`/{${s.name.originalName}}`;let i=b7(r),n=[];for(let[s,o]of this.method.params.entries()){let l;if(this.context.isReferenceObject(o)){let m=this.context.resolveReference({reference:o});if(m.resolved)l=m.value;else continue}else l=o;let b=[this.method.name,"Param",l.name].join("_"),O=new wA.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"Param",l.name],schemaIdOverride:b,context:this.context,schemaOrReference:l.schema,wrapAsOptional:!l.required}).convert();O!=null&&(n.push({docs:l.description,availability:this.context.getAvailability({node:o,breadcrumbs:[...this.breadcrumbs,"parameters"]}),name:this.context.casingsGenerator.generateNameAndWireValue({name:l.name,wireValue:l.name}),valueType:O.type,v2Examples:O.schema?.typeDeclaration.v2Examples,propertyAccess:void 0}),t={...O.inlinedTypes,...t,...O.schema!=null?{[b]:O.schema}:{}})}let a;if(this.method.result!=null){let s=this.context.resolveMaybeReference({schemaOrReference:this.method.result,breadcrumbs:[...this.breadcrumbs,"result"]});if(s!=null){let o=new wA.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"result"],context:this.context,schemaOrReference:s.schema}),l=[this.method.name,"Result"].join("_"),b=o.convert();b!=null&&(a={docs:s.description,v2Examples:b.schema?.typeDeclaration.v2Examples,responseBodyType:b.type},t={...b.inlinedTypes,...t,...b.schema!=null?{[l]:b.schema}:{}})}}let u=this.getEndpointBaseUrls(),c=this.context.getAudiences({operation:this.method,breadcrumbs:this.breadcrumbs})??[];return{endpoint:{baseUrl:void 0,v2BaseUrls:u,basePath:void 0,auth:!1,method:"POST",id:this.method.name,docs:this.method.description,name:this.context.casingsGenerator.generateName(this.method.name),headers:this.headers,displayName:this.method.name,pathParameters:this.pathParameters,queryParameters:this.queryParameters,allPathParameters:this.pathParameters,path:i,fullPath:i,requestBody:n.length>0?nq.inlinedRequestBody({name:this.context.casingsGenerator.generateName([this.method.name,"Request"].join("_")),docs:void 0,properties:n,extends:[],extendedProperties:[],contentType:"application/json",extraProperties:!1,v2Examples:void 0}):void 0,v2RequestBodies:void 0,sdkRequest:void 0,response:a!=null?{body:q1.json(kL.response(a)),statusCode:void 0}:void 0,v2Responses:void 0,errors:[],idempotent:!1,pagination:void 0,userSpecifiedExamples:[],autogeneratedExamples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples()},transport:void 0,availability:void 0,source:oK.openrpc(),audiences:c},audiences:c,inlinedTypes:t,servers:this.filterOutTopLevelServers(this.method.servers??[])}}filterOutTopLevelServers(t){return t.filter(r=>!this.topLevelServers.some(i=>i.url===r.url))}getEndpointBaseUrls(){let t=this.method.servers;return t?.map(i=>{if(this.topLevelServers.find(c=>c.name===i.name&&c.url!==i.url)!=null)return i.url;let u=this.topLevelServers.find(c=>c.url===i.url)??i;return Dqe.getServerName({server:u,context:this.context})})}convertExamples(){let t={},r=0;if(this.method.examples&&this.method.examples.length>0){for(let i of this.method.examples??[]){let n;if(this.context.isReferenceObject(i)){let d=this.context.resolveReference({reference:i});if(d.resolved)n=d.value;else continue}else n=i;let a;if(n.result)if(this.context.isReferenceObject(n.result)){let d=this.context.resolveReference({reference:n.result});d.resolved&&(a=d.value)}else a=n.result;let u=n.name??`Example ${r+1}`,c=[];if(n.params&&Array.isArray(n.params)){c=[];for(let d of n.params)if(this.context.isReferenceObject(d)){let s=this.context.resolveReference({reference:d});if(s.resolved)c.push(s.value);else continue}else c.push(d)}t[u]={displayName:void 0,request:{docs:void 0,endpoint:{method:"POST",path:"/{apiKey}"},baseUrl:void 0,environment:void 0,auth:void 0,pathParameters:{},queryParameters:{},headers:{},requestBody:c.map(d=>d.value)??void 0},response:{docs:void 0,statusCode:void 0,body:a?.value?Js.V2HttpEndpointResponseBody.json({jsonrpc:"2.0",id:n.examplePairedRequest?.id||"1",result:a.value}):void 0},codeSamples:[]}}++r}return t}};var Hdu=class extends wA.AbstractConverters.AbstractParameterConverter{constructor({context:t,breadcrumbs:r,parameter:i}){super({context:t,breadcrumbs:r,parameter:i})}convert(){let t,r={};if(this.parameter.schema!=null){let n=new wA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert();n!=null&&(t=n.type,r=n.inlinedTypes??{})}return this.convertToOutput({schema:this.parameter.schema??{type:"string"},typeReference:t,inlinedTypes:r})}};var OUa=class extends IQt{constructor({context:t,breadcrumbs:r,audiences:i}){super({context:t,breadcrumbs:r,audiences:i})}async convert(){this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.convertSchemas();let{endpointLevelServers:t}=this.convertMethods(),{defaultUrl:r}=this.convertServers({endpointLevelServers:t});return this.updateEndpointsWithDefaultUrl(r),this.finalizeIr()}convertServers({endpointLevelServers:t}){let i=new Dqe({context:this.context,breadcrumbs:["servers"],servers:this.context.spec.servers,endpointLevelServers:t}).convert();return this.addEnvironmentsToIr({environmentConfig:i?.value}),{defaultUrl:i?.defaultUrl}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{})){let n=new wA.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();n!=null&&(this.addTypeToPackage(t),this.addTypesToIr({...n.inlinedTypes,[t]:n.convertedSchema}))}}convertMethods(){let t=[],i=new Vdu({context:this.context,breadcrumbs:["methods"],operation:this.context.spec}).convert(),n=[],a=[],u=[];if(i&&i.length>0)for(let[d,s]of i.entries()){let l=new Hdu({context:this.context,breadcrumbs:[...this.breadcrumbs,`x-fern-parameters[${d}]`],parameter:s}).convert();if(l!=null)switch(l.type){case"path":{n.push(l.parameter);break}case"query":{a.push(l.parameter);break}case"header":{u.push(l.parameter);break}}}let c=this.context.getGroup({groupParts:[],namespace:this.context.namespace});for(let d of this.context.spec.methods??[]){let s=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:["methods"]});if(s==null)continue;let l=new Wdu({context:this.context,breadcrumbs:["methods"],method:s,pathParameters:n,queryParameters:a,headers:u,topLevelServers:this.context.spec.servers}).convert();if(l!=null&&(this.addEndpointToIr({endpoint:l.endpoint,audiences:l.audiences,endpointGroup:c,serviceName:"service_root"}),this.addTypesToIr(l.inlinedTypes),l.servers))for(let b of l.servers)this.shouldAddServerToCollectedServers({server:b,currentServers:t,specType:"openrpc"})&&t.push(this.maybeDeduplicateServerName(b))}return{endpointLevelServers:t}}maybeDeduplicateServerName(t){return this.context.spec.servers?.find(i=>i.name===t.name&&i.url!==t.url)?{...t,name:t.url}:t}};var mUa=class extends UF{isReferenceObject(t){return t!=null&&"$ref"in t}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n}){let a=this.getTypeIdFromSchemaReference(t);if(a==null)return{ok:!1};let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let c;return n==="reference_identifier"?c=i??u.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(c=u.value.title??i),{ok:!0,reference:ol.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var h4_=require("fs/promises");var EF_={[Jh.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,eI(e)])),[Jh.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[Jh.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[Jh.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all","kwargs"]),[Jh.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","vendor","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[Jh.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime"]),[Jh.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[Jh.GenerationLanguage.RUST]:new Set(["as","async","await","break","const","continue","crate","dyn","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","union","unsafe","use","where","while","abstract","become","box","do","final","macro","override","priv","try","typeof","unsized","virtual","yield","bool","char","f32","f64","i8","i16","i32","i64","i128","isize","str","u8","u16","u32","u64","u128","usize","String","Vec","Option","Result","Box","Rc","Arc","Cell","RefCell","HashMap","HashSet","BTreeMap","BTreeSet"]),[Jh.GenerationLanguage.SWIFT]:new Set([])};var TaM=["go","ruby"];function Qdu({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let u=l=>({unsafeName:l,safeName:CaM({name:l,keywords:BaM({generationLanguage:e,keywords:t})})}),c=F_(n),d=eI(c),s=wZi(n),o=OZi(c);return r&&(!xaM(o)&&(e==null||TaM.includes(e))&&(c=o.map((l,b)=>{if(b>0){let g=$du(l);if(g!=null)return g;if(Gdu(l))return l.toUpperCase()}return l}).join(""),d=eI(o.map((l,b)=>{let g=$du(l);return g??(Gdu(l)?l.toUpperCase():b===0?eI(l):l)}).join(""))),s=n.split(" ").map(l=>l.split(/(\d+)/).map(wZi).join("")).join("_")),{originalName:n,camelCase:u(a?.casingOverrides?.camel??c),snakeCase:u(a?.casingOverrides?.snake??s),screamingSnakeCase:u(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:u(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:n,wireValue:a,opts:u})=>({name:i.generateName(n,u),wireValue:a})};return i}function CaM({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":zaM(e)?"_"+e:e}function BaM({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return EF_[e]}var IaM=/^[0-9]/;function zaM(e){return IaM.test(e)}function xaM(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=$du(i)!=null||Gdu(i),a=$du(t)!=null||Gdu(t);return n&&a})}function $du(e){return NaM.get(e.toUpperCase())}function Gdu(e){return RaM.has(e.toUpperCase())}var RaM=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),NaM=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var MF_=require("fs/promises");async function EIc({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,MF_.readFile)(t)).toString(),n;try{n=JSON.parse(i)}catch{n=Rd.load(i)}return r!=null?await bXn({absoluteFilePathToOverrides:r,context:e,data:n}):n}var r4_=ci(t4_(),1);function Y3i(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...u}={}){let c=n.reduce((s,o)=>({...s,[o]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[s,o]of Object.entries(c))d=d.replaceAll(s,o);return e?.debug(`+ ${d}`),(0,r4_.default)(t,r,u)}async function jx(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...u}={}){let c=Y3i(e,t,r,{doNotPipeOutput:i,secrets:n,substitutions:a,...u});i||(c.stdout?.pipe(process.stdout),c.stderr?.pipe(process.stderr));let d=await c;return d.stdout==null&&(d.stdout=""),d.stderr==null&&(d.stderr=""),d}function X3i(e,{logger:t,...r}={}){return(i,n)=>jx(t,e,i,{...r,...n})}var Wqe=require("fs/promises"),f4_=ci(require("path"),1),HIc=ci(Yk(),1);var i4_="buf.gen.yaml",TuM="output",n4_=`${TuM}/ir.json`,a4_="protoc-gen-fern",o4_=`version: v1
|