fern-api 0.45.0-rc46 → 0.45.0-rc47
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
|
@@ -1785,7 +1785,7 @@ ${l.indent}`:""}${uVc(o)}:${f.indent?" ":""}`;return u=!1,c=!0,f.objectItem=void
|
|
|
1785
1785
|
`}),r.replaceAll(/\n$/g,"")}function Nfj(e){return e?qc.green(SNr.radioOn):SNr.radioOff}var fha=Jo(fwe(),1);function Lsf(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var Dpi=class extends p8{_run(t){this.done=t;let r=uW(this.rl),n=r.line.pipe((0,fha.map)(this.filterInput.bind(this))),i=this.handleSubmitEvents(n);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,fha.takeUntil)(i.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),n="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(n=`
|
|
1786
1786
|
`+qc.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?qc.cyan(Lsf(t,this.opt.mask)):qc.italic.dim("[hidden]"):this.opt.mask?Lsf(t,this.opt.mask):qc.italic.dim("[input is hidden] ")}getSpinningValue(t){return this.getMaskedValue(t)}filterInput(t){return t||(this.opt.default==null?"":this.opt.default)}onEnd(t){this.status="answered",this.answer=t.value,this.render(),this.screen.done(),this.done(t.value)}onError(t){this.render(t.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}};var dlf=Jo(flf(),1),plf=Jo(fwe(),1);var Ipi=class extends p8{_run(t){this.done=t,this.editorResult=new plf.Subject;let r=uW(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let n=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,i=this.handleSubmitEvents(this.editorResult);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,n?this.render():this.startExternalEditor(),this}render(t){let r="",n=this.getQuestion();n+=this.status==="answered"?qc.dim("Received"):qc.dim("Press <enter> to launch your preferred editor."),t&&(r=qc.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),(0,dlf.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 Olf=Jo(ylf(),1);var glf=Jo(require("readline"),1),mlf=Jo(blf(),1),fkr=class{constructor(t){this.rl||=glf.default.createInterface(Edj(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 Edj(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let i=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw i.isTtyError=!0,i}let r=new mlf.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var zpi=class extends fkr{constructor(t={}){super(t),this.log=(0,Olf.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return vpi(this.rl,this.bottomBar.split(`
|
|
1787
1787
|
`).length),this}updateBottomBar(t){return vpi(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+`
|
|
1788
|
-
`}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&&uha(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var xlf=Jo(wlf(),1),qlf=Jo(luu(),1),Clf=Jo(Mlf(),1),Qx=Jo(fwe(),1),Blf=Jo(Ddi(),1);var xha=Jo(fwe(),1),Tlf=Jo(Ddi(),1),qha=function(e,t,r){return typeof e[t]!="function"?(0,xha.of)(e):(0,xha.from)((0,Tlf.default)(e[t])(r).then(n=>(e[t]=n,e)))};var Npi={isPlainObject:xlf.default,set:Clf.default,get:qlf.default},DBn=class extends fkr{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=Npi.isPlainObject(r)?{...r}:{},Npi.isPlainObject(t)&&(t=Object.values(t).every(i=>Npi.isPlainObject(i)&&i.name===void 0)?Object.entries(t).map(([i,a])=>({name:i,...a})):[t]);let n=Array.isArray(t)?(0,Qx.from)(t):t;return this.process=n.pipe((0,Qx.concatMap)(this.processQuestion.bind(this)),(0,Qx.publish)()),this.process.connect(),this.process.pipe((0,Qx.reduce)((i,a)=>(Npi.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,Qx.defer)(()=>(0,Qx.of)(t).pipe((0,Qx.concatMap)(this.setDefaultType.bind(this)),(0,Qx.concatMap)(this.filterIfRunnable.bind(this)),(0,Qx.concatMap)(()=>qha(t,"message",this.answers)),(0,Qx.concatMap)(()=>qha(t,"default",this.answers)),(0,Qx.concatMap)(()=>qha(t,"choices",this.answers)),(0,Qx.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,Qx.defer)(()=>(0,Qx.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,Qx.defer)(()=>(0,Qx.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&Npi.get(this.answers,t.name)!==void 0)return(0,Qx.empty)();if(t.when===!1)return(0,Qx.empty)();if(typeof t.when!="function")return(0,Qx.of)(t);let{answers:r}=this;return(0,Qx.defer)(()=>(0,Qx.from)((0,Blf.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,Qx.filter)(n=>n!=null)))}};function Ilf(e){let t=function(r,n){let i;try{i=new DBn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",gpi),this.registerPrompt("input",nkr),this.registerPrompt("number",mpi),this.registerPrompt("confirm",Opi),this.registerPrompt("rawlist",Ppi),this.registerPrompt("expand",jpi),this.registerPrompt("checkbox",wpi),this.registerPrompt("password",Dpi),this.registerPrompt("editor",Ipi)},t.restoreDefaultPrompts(),t}var ucu=Ilf();function Jdj(e,t){ucu.registerPrompt(e,t)}function Qdj(){ucu.restoreDefaultPrompts()}var Gdj={prompt:ucu,ui:{BottomBar:zpi,Prompt:DBn},createPromptModule:Ilf,registerPrompt:Jdj,restoreDefaultPrompts:Qdj,Separator:_ne},Cha=Gdj;var Jff=Jo(zlf()),vhj="4.2.1",e2t;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay"})(e2t||(e2t={}));function bhj(e,t){if(!e)throw new Error(t)}function ghj(e){return e?.replace(/\/+$/,"")}async function mhj(e,t){let r=null;for(let n=0;n<t.retryCount+1;n++){n>0&&await new Promise(i=>setTimeout(i,t.retryDelay));try{return await e()}catch(i){if(r=i,!t.retryCheck(i))throw i}}throw r}function Ohj(){return new Date().getTime()}function Nff(){return new Date().toISOString()}function Qff(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var $pi=String.fromCharCode,Fff="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Qha={};function Phj(e,t){if(!Qha[e]){Qha[e]={};for(let r=0;r<e.length;r++)Qha[e][e.charAt(r)]=r}return Qha[e][t]}var Kpi={compressToBase64:function(e){if(e==null)return"";let t=Kpi._compress(e,6,function(r){return Fff.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:Kpi._decompress(e.length,32,function(t){return Phj(Fff,e.charAt(t))})},compress:function(e){return Kpi._compress(e,16,function(t){return $pi(t)})},_compress:function(e,t,r){if(e==null)return"";let n={},i={},a=[],u,f,d="",c="",o="",l=2,m=3,O=2,j=0,A=0,T;for(T=0;T<e.length;T+=1)if(d=e.charAt(T),Object.prototype.hasOwnProperty.call(n,d)||(n[d]=m++,i[d]=!0),c=o+d,Object.prototype.hasOwnProperty.call(n,c))o=c;else{if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,A==t-1?(A=0,a.push(r(j)),j=0):A++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++),n[c]=m++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,A==t-1?(A=0,a.push(r(j)),j=0):A++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++)}for(f=2,u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;for(;;)if(j=j<<1,A==t-1){a.push(r(j));break}else A++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:Kpi._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let n=[],i=[],a={val:r(0),position:t,index:1},u=4,f=4,d=3,c="",o,l,m,O,j,A,T;for(o=0;o<3;o+=1)n[o]=o;for(m=0,j=Math.pow(2,2),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;switch(m){case 0:for(m=0,j=Math.pow(2,8),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;T=$pi(m);break;case 1:for(m=0,j=Math.pow(2,16),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;T=$pi(m);break;case 2:return""}for(n[3]=T,l=T,i.push(T);;){if(a.index>e)return"";for(m=0,j=Math.pow(2,d),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;switch(T=m){case 0:for(m=0,j=Math.pow(2,8),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;n[f++]=$pi(m),T=f-1,u--;break;case 1:for(m=0,j=Math.pow(2,16),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;n[f++]=$pi(m),T=f-1,u--;break;case 2:return i.join("")}if(u==0&&(u=Math.pow(2,d),d++),n[T])c=n[T];else if(T===f)c=l+l.charAt(0);else return null;i.push(c),n[f++]=l+c.charAt(0),u--,l=c,u==0&&(u=Math.pow(2,d),d++)}}},$cu=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(n=>n!==r)}}emit(t,r){for(let n of this.events[t]||[])n(r);for(let n of this.events["*"]||[])n(t,r)}};var Gha="0123456789abcdef",$ha=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,n,i){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(n)||!Number.isInteger(i)||t<0||r<0||n<0||i<0||t>0xffffffffffff||r>4095||n>1073741823||i>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|n>>>24,a[9]=n>>>16,a[10]=n>>>8,a[11]=n,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,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 n=new Uint8Array(16);for(let i=0;i<16;i+=4){let a=parseInt(r.substring(2*i,2*i+8),16);n[i+0]=a>>>24,n[i+1]=a>>>16,n[i+2]=a>>>8,n[i+3]=a}return new e(n)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=Gha.charAt(this.bytes[r]>>>4),t+=Gha.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+=Gha.charAt(this.bytes[r]>>>4),t+=Gha.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 n=this.bytes[r]-t.bytes[r];if(n!==0)return Math.sign(n)}return 0}},Kcu=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??jhj()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let n=this.generateOrAbortCore(t,r);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(t,r)),n}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 $ha.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,$ha.ofInner(t)}},jhj=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Rff,Lff=()=>whj().toString(),whj=()=>(Rff||(Rff=new Kcu)).generate(),Kha=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},Ypi=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function Uff(e){return typeof e=="object"&&(e instanceof Kha||e instanceof Ypi)}var Ycu=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new $cu,this._isInitialized=!1,bhj(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=ghj(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:Uff},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(e2t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(e2t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(e2t.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(n,i)=>console.log("PostHog Debug",n,i));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=Lff();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,n){this.wrap(()=>{let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",i,n)})}captureStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:n});this.enqueue("capture",a,i)})}aliasStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});this.enqueue("alias",a,i)})}groupIdentifyStateless(t,r,n,i,a,u){this.wrap(()=>{let f=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:n||{},...u||{}}});this.enqueue("capture",f,i)})}async getDecide(t,r={},n={},i={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i,...a})};return this.fetchWithRetry(u,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(d=>d.json()).catch(d=>{this._events.emit("error",d)})}async getFeatureFlagStateless(t,r,n={},i={},a={},u){await this._initPromise;let f=await this.getFeatureFlagsStateless(r,n,i,a,u);if(!f)return;let d=f[t];return d===void 0&&(d=!1),d}async getFeatureFlagPayloadStateless(t,r,n={},i={},a={},u){await this._initPromise;let f=await this.getFeatureFlagPayloadsStateless(r,n,i,a,u);if(!f)return;let d=f[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},n={},i={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},n={},i={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},n={},i={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let f=await this.getDecide(t,r,n,i,u),d=f?.featureFlags,c=f?.featureFlagPayloads,o=c;return c&&(o=Object.fromEntries(Object.entries(c).map(([l,m])=>[l,this._parsePayload(m)]))),{flags:d,payloads:o}}enqueue(t,r,n){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:Nff(),uuid:n?.uuid?n.uuid:Lff()};(n?.disableGeoip??this.disableGeoip)&&(i.properties||(i.properties={}),i.properties.$geoip_disable=!0),i.distinctId&&(i.distinct_id=i.distinctId,delete i.distinctId);let u=this.getPersistedProperty(e2t.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:i}),this.setPersistedProperty(e2t.Queue,u),this._events.emit(t,i),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Qff(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(e2t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),n=r.map(c=>c.message),i=()=>{let c=this.getPersistedProperty(e2t.Queue)||[];this.setPersistedProperty(e2t.Queue,c.slice(r.length))},a={api_key:this.apiKey,batch:n,sent_at:Nff()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),f=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${Ohj()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,d=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(Kpi.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(f,d)}catch(c){throw c instanceof Ypi||i(),this._events.emit("error",c),c}return i(),this._events.emit("flush",n),n}async fetchWithRetry(t,r,n,i){var a;return(a=AbortSignal).timeout??(a.timeout=function(f){let d=new AbortController;return setTimeout(()=>d.abort(),f),d.signal}),await mhj(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(d){throw new Ypi(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new Kha(u);return u},{...this._retryOptions,...n})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(e2t.Queue)||[]).length!==0;){await this.flush();let i=Date.now();if(r<i)break}}catch(r){if(!Uff(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},Xcu=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},Zcu=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!Zcu){let e=zff();Zcu=async(t,r)=>{let n=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:n.status,text:async()=>n.data,json:async()=>n.data}}}var Gff=Zcu,Dhj=1152921504606847e3,Shj=["is_not"],Yha=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},_8=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},kcu=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:a,customHeaders:u,...f}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=i,this.projectApiKey=n,this.host=a,this.poller=void 0,this.fetch=f.fetch||Gff,this.onError=f.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,n={},i={},a={}){await this.loadFeatureFlags();let u,f;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){f=d;break}if(f!==void 0)try{u=this.computeFlagLocally(f,r,n,i,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof _8?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 n;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),n==null)return null;try{return JSON.parse(n)}catch{return n}}}async getAllFlagsAndPayloads(t,r={},n={},i={}){await this.loadFeatureFlags();let a={},u={},f=this.featureFlags.length==0;return this.featureFlags.map(async d=>{try{let c=this.computeFlagLocally(d,t,r,n,i);a[d.key]=c;let o=await this.computeFeatureFlagPayloadLocally(d.key,c);o&&(u[d.key]=o)}catch(c){c instanceof _8||c instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${c}`)),f=!0}}),{response:a,payloads:u,fallbackToDecide:f}}computeFlagLocally(t,r,n={},i={},a={}){if(t.ensure_experience_continuity)throw new _8("Flag has experience continuity enabled");if(!t.active)return!1;let f=(t.filters||{}).aggregation_group_type_index;if(f!=null){let d=this.groupTypeMapping[String(f)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${f} for feature flag ${t.key}`)),new _8("Flag has unknown group type index");if(!(d in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let c=a[d];return this.matchFeatureFlagProperties(t,n[d],c)}else return this.matchFeatureFlagProperties(t,r,i)}matchFeatureFlagProperties(t,r,n){let i=t.filters||{},a=i.groups||[],u=!1,f,d=[...a].sort((c,o)=>{let l=!!c.variant,m=!!o.variant;return l&&m?0:l?-1:m?1:0});for(let c of d)try{if(this.isConditionMatch(t,r,c,n)){let o=c.variant,l=i.multivariate?.variants||[];o&&l.some(m=>m.key===o)?f=o:f=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof _8)u=!0;else throw o}if(f!==void 0)return f;if(u)throw new _8("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,n,i){let a=n.rollout_percentage,u=f=>{this.logMsgIfDebug(()=>console.warn(f))};if((n.properties||[]).length>0){for(let f of n.properties){let d=f.type,c=!1;if(d==="cohort"?c=Kff(f,i,this.cohorts,this.debugMode):c=$ff(f,i,u),!c)return!1}if(a==null)return!0}return!(a!=null&&Vff(t.key,r)>a/100)}getMatchingVariant(t,r){let n=Vff(t.key,r,"variant"),i=this.variantLookupTable(t).find(a=>n>=a.valueMin&&n<a.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(f=>{i=n+f.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:f.key}),n=i}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new Yha("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce((n,i)=>(n[i.key]=i,n),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof Yha&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=Qff(()=>{i.abort()},this.timeout),r.signal=i.signal}try{return await this.fetch(t,r)}finally{clearTimeout(n)}}stopPoller(){clearTimeout(this.poller)}};function Vff(e,t,r=""){let n=(0,Jff.createHash)();return n.update(`${e}.${t}${r}`),parseInt(n.digest("hex").slice(0,15),16)/Dhj}function $ff(e,t,r){let n=e.key,i=e.value,a=e.operator||"exact";if(n in t){if(a==="is_not_set")throw new _8("Operator is_not_set is not supported")}else throw new _8(`Property ${n} not found in propertyValues`);let u=t[n];if(u==null&&!Shj.includes(a))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${a} operator`),!1;function f(c,o){return Array.isArray(c)?c.map(l=>String(l).toLowerCase()).includes(String(o).toLowerCase()):String(c).toLowerCase()===String(o).toLowerCase()}function d(c,o,l){if(l==="gt")return c>o;if(l==="gte")return c>=o;if(l==="lt")return c<o;if(l==="lte")return c<=o;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return f(i,u);case"is_not":return!f(i,u);case"is_set":return n in t;case"icontains":return String(u).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(i).toLowerCase());case"regex":return Wff(String(i))&&String(u).match(String(i))!==null;case"not_regex":return Wff(String(i))&&String(u).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let c=typeof i=="number"?i:null;if(typeof i=="string")try{c=parseFloat(i)}catch{}return c!=null&&u!=null?typeof u=="string"?d(u,String(i),a):d(u,c,a):d(String(u),String(i),a)}case"is_date_after":case"is_date_before":{let c=Ehj(String(i));if(c==null&&(c=Hff(i)),c==null)throw new _8(`Invalid date: ${i}`);let o=Hff(u);return["is_date_before"].includes(a)?o<c:o>c}default:throw new _8(`Unknown operator: ${a}`)}}function Kff(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new _8("can't match cohort without a given cohort property value");let a=r[i];return Yff(a,t,r,n)}function Yff(e,t,r,n=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let f of a)try{let d=Yff(f,t,r,n);if(i==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof _8)n&&console.debug(`Failed to compute property ${f} locally: ${d}`),u=!0;else throw d}if(u)throw new _8("Can't match cohort without a given cohort property value");return i==="AND"}else{for(let f of a)try{let d;f.type==="cohort"?d=Kff(f,t,r,n):d=$ff(f,t);let c=f.negation||!1;if(i==="AND"){if(!d&&!c||d&&c)return!1}else if(d&&!c||!d&&c)return!0}catch(d){if(d instanceof _8)n&&console.debug(`Failed to compute property ${f} locally: ${d}`),u=!0;else throw d}if(u)throw new _8("can't match cohort without a given cohort property value");return i==="AND"}}function Wff(e){try{return new RegExp(e),!0}catch{return!1}}function Hff(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 _8(`${e} is in an invalid date format`)}else throw new _8(`The date provided ${e} must be a string, number, or date object`)}function Ehj(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let a=r.groups.interval;if(a=="h")n.setUTCHours(n.getUTCHours()-i);else if(a=="d")n.setUTCDate(n.getUTCDate()-i);else if(a=="w")n.setUTCDate(n.getUTCDate()-i*7);else if(a=="m")n.setUTCMonth(n.getUTCMonth()-i);else if(a=="y")n.setUTCFullYear(n.getUTCFullYear()-i);else return null;return n}else return null}var Ahj=30*1e3,Mhj=50*1e3,qBn=class extends Ycu{constructor(t,r={}){super(t,r),this._memoryStorage=new Xcu,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new kcu({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:Ahj,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||Mhj}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):Gff(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return vhj}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture({distinctId:t,event:r,properties:n,groups:i,sendFeatureFlags:a,timestamp:u,disableGeoip:f,uuid:d}){let c=m=>{super.captureStateless(t,r,m,{timestamp:u,disableGeoip:f,uuid:d})},o=(m,O,j)=>super.getFeatureFlagsStateless(m,O,void 0,void 0,j),l=Promise.resolve().then(async()=>{if(a)return await o(t,i,f);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let m={};for(let[O,j]of Object.entries(i||{}))m[O]=String(j);return await this.getAllFlags(t,{groups:m,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(m=>{let O={};if(m)for(let[A,T]of Object.entries(m))O[`$feature/${A}`]=T;let j=Object.keys(m||{}).filter(A=>m?.[A]!==!1);return j.length>0&&(O.$active_feature_flags=j),O}).catch(()=>({})).then(m=>{c({...m,...n,$groups:i})});this.addPendingPromise(l)}identify({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set||r;super.identifyStateless(t,{$set:i},{disableGeoip:n})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,n){let{groups:i,disableGeoip:a}=n||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:f,personProperties:d,groupProperties:c}=n||{},o=this.addLocalPersonAndGroupProperties(r,i,d,c);d=o.allPersonProperties,c=o.allGroupProperties,u==null&&(u=!1),f==null&&(f=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,i,d,c),m=l!==void 0;!m&&!u&&(l=await super.getFeatureFlagStateless(t,r,i,d,c,a));let O=`${t}_${l}`;return f&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(O))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(O):this.distinctIdHasSentFlagCalls[r]=[O],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,locally_evaluated:m,[`$feature/${t}`]:l},groups:i,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,n,i){let{groups:a,disableGeoip:u}=i||{},{onlyEvaluateLocally:f,sendFeatureFlagEvents:d,personProperties:c,groupProperties:o}=i||{},l=this.addLocalPersonAndGroupProperties(r,a,c,o);c=l.allPersonProperties,o=l.allGroupProperties;let m;return n||(n=await this.getFeatureFlag(t,r,{...i,onlyEvaluateLocally:!0})),n&&(m=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,n)),f==null&&(f=!1),d==null&&(d=!0),f==null&&(f=!1),!(m!==void 0)&&!f&&(m=await super.getFeatureFlagPayloadStateless(t,r,a,c,o,u)),m}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:n,disableGeoip:i}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:f}=r||{},d=this.addLocalPersonAndGroupProperties(t,n,u,f);u=d.allPersonProperties,f=d.allGroupProperties,a==null&&(a=!1);let c=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,u,f),o={},l={},m=!0;if(c&&(o=c.response,l=c.payloads,m=c.fallbackToDecide),m&&!a){let O=await super.getFeatureFlagsAndPayloadsStateless(t,n,u,f,i);o={...o,...O.flags||{}},l={...l,...O.payloads||{}}}return{featureFlags:o,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:a}){super.groupIdentifyStateless(t,r,n,{disableGeoip:a},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,n,i){let a={distinct_id:t,...n||{}},u={};if(r)for(let f of Object.keys(r))u[f]={$group_key:r[f],...i?.[f]||{}};return{allPersonProperties:a,allGroupProperties:u}}},elu=class e{constructor(t,r,n,i){this.posthog=t,this.posthogHost=r,this.organization=n,this.prefix=i,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(n=>{if(n.exception?.values===void 0||n.exception.values.length===0)return n;n.tags||(n.tags={});let i=r(),a=n.tags[e.POSTHOG_ID_TAG];if(a===void 0)return n;n.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:n.exception.values[0]?.value,$exception_type:n.exception.values[0]?.type,$exception_personURL:n.tags["PostHog Person URL"],$sentry_event_id:n.event_id,$sentry_exception:n.exception,$sentry_exception_message:n.exception.values[0]?.value,$sentry_exception_type:n.exception.values[0]?.type,$sentry_tags:n.tags},f=i.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&f!==void 0&&n.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${f}&query=${n.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),n})}};elu.POSTHOG_ID_TAG="posthog_distinct_id";var Xha=class{posthog;constructor({posthogApiKey:t}){this.posthog=new qBn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.45.0-rc46",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var Xpi=class{async sendEvent(){}async identify(){}async flush(){}};var CBn=require("fs/promises"),edf=require("os"),tdf=require("path");var Xff=Jo(require("crypto")),kha=new Uint8Array(256),Zha=kha.length;function tlu(){return Zha>kha.length-16&&(Xff.default.randomFillSync(kha),Zha=0),kha.slice(Zha,Zha+=16)}var lW=[];for(let e=0;e<256;++e)lW.push((e+256).toString(16).slice(1));function Zff(e,t=0){return lW[e[t+0]]+lW[e[t+1]]+lW[e[t+2]]+lW[e[t+3]]+"-"+lW[e[t+4]]+lW[e[t+5]]+"-"+lW[e[t+6]]+lW[e[t+7]]+"-"+lW[e[t+8]]+lW[e[t+9]]+"-"+lW[e[t+10]]+lW[e[t+11]]+lW[e[t+12]]+lW[e[t+13]]+lW[e[t+14]]+lW[e[t+15]]}var kff=Jo(require("crypto")),rlu={randomUUID:kff.default.randomUUID};function Thj(e,t,r){if(rlu.randomUUID&&!t&&!e)return rlu.randomUUID();e=e||{};let n=e.random||(e.rng||tlu)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Zff(n)}var d6r=Thj;var xhj="id",qhj=".fern",Zpi=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new qBn(r),this.userId=t==null?void 0:bru(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.45.0-rc46",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Wl(Hp.of((0,edf.homedir)()),ls.of(qhj),ls.of(xhj));await _h(t)||(await(0,CBn.mkdir)((0,tdf.dirname)(t),{recursive:!0}),await(0,CBn.writeFile)(t,d6r())),this.persistedDistinctId=(await(0,CBn.readFile)(t)).toString()}return this.persistedDistinctId}};var nlu;async function BBn(){return nlu==null&&(nlu=await Chj()),nlu}async function Chj(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Xpi;let r=await uca();return r!=null?new Zpi({token:r,posthogApiKey:e}):await oca()!=null?new Xha({posthogApiKey:e}):new Zpi({token:void 0,posthogApiKey:e})}catch{return new Xpi}}function kpi(e,t){return function(){return e.apply(t,arguments)}}var{toString:Bhj}=Object.prototype,{getPrototypeOf:olu}=Object,tya=(e=>t=>{let r=Bhj.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),t2t=e=>(e=e.toLowerCase(),t=>tya(t)===e),rya=e=>t=>typeof t===e,{isArray:IBn}=Array,e_i=rya("undefined");function Ihj(e){return e!==null&&!e_i(e)&&e.constructor!==null&&!e_i(e.constructor)&&pwe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var idf=t2t("ArrayBuffer");function zhj(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&idf(e.buffer),t}var Nhj=rya("string"),pwe=rya("function"),adf=rya("number"),nya=e=>e!==null&&typeof e=="object",Fhj=e=>e===!0||e===!1,eya=e=>{if(tya(e)!=="object")return!1;let t=olu(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Rhj=t2t("Date"),Lhj=t2t("File"),Uhj=t2t("Blob"),Vhj=t2t("FileList"),Whj=e=>nya(e)&&pwe(e.pipe),Hhj=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||pwe(e.append)&&((t=tya(e))==="formdata"||t==="object"&&pwe(e.toString)&&e.toString()==="[object FormData]"))},Jhj=t2t("URLSearchParams"),[Qhj,Ghj,$hj,Khj]=["ReadableStream","Request","Response","Headers"].map(t2t),Yhj=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function t_i(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),IBn(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,f;for(n=0;n<u;n++)f=a[n],t.call(null,e[f],f,e)}}function odf(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var hkr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,udf=e=>!e_i(e)&&e!==hkr;function alu(){let{caseless:e}=udf(this)&&this||{},t={},r=(n,i)=>{let a=e&&odf(t,i)||i;eya(t[a])&&eya(n)?t[a]=alu(t[a],n):eya(n)?t[a]=alu({},n):IBn(n)?t[a]=n.slice():t[a]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&t_i(arguments[n],r);return t}var Xhj=(e,t,r,{allOwnKeys:n}={})=>(t_i(t,(i,a)=>{r&&pwe(i)?e[a]=kpi(i,r):e[a]=i},{allOwnKeys:n}),e),Zhj=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),khj=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},eyj=(e,t,r,n)=>{let i,a,u,f={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)u=i[a],(!n||n(u,e,t))&&!f[u]&&(t[u]=e[u],f[u]=!0);e=r!==!1&&olu(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},tyj=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},ryj=e=>{if(!e)return null;if(IBn(e))return e;let t=e.length;if(!adf(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},nyj=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&olu(Uint8Array)),iyj=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},ayj=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},oyj=t2t("HTMLFormElement"),uyj=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),rdf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),syj=t2t("RegExp"),sdf=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};t_i(r,(i,a)=>{let u;(u=t(i,a,e))!==!1&&(n[a]=u||i)}),Object.defineProperties(e,n)},cyj=e=>{sdf(e,(t,r)=>{if(pwe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(pwe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},lyj=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return IBn(e)?n(e):n(String(e).split(t)),r},fyj=()=>{},dyj=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,ilu="abcdefghijklmnopqrstuvwxyz",ndf="0123456789",cdf={DIGIT:ndf,ALPHA:ilu,ALPHA_DIGIT:ilu+ilu.toUpperCase()+ndf},pyj=(e=16,t=cdf.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function _yj(e){return!!(e&&pwe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var hyj=e=>{let t=new Array(10),r=(n,i)=>{if(nya(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;let a=IBn(n)?[]:{};return t_i(n,(u,f)=>{let d=r(u,i+1);!e_i(d)&&(a[f]=d)}),t[i]=void 0,a}}return n};return r(e,0)},yyj=t2t("AsyncFunction"),vyj=e=>e&&(nya(e)||pwe(e))&&pwe(e.then)&&pwe(e.catch),ldf=((e,t)=>e?setImmediate:t?((r,n)=>(hkr.addEventListener("message",({source:i,data:a})=>{i===hkr&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),hkr.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",pwe(hkr.postMessage)),byj=typeof queueMicrotask<"u"?queueMicrotask.bind(hkr):typeof process<"u"&&process.nextTick||ldf,Ol={isArray:IBn,isArrayBuffer:idf,isBuffer:Ihj,isFormData:Hhj,isArrayBufferView:zhj,isString:Nhj,isNumber:adf,isBoolean:Fhj,isObject:nya,isPlainObject:eya,isReadableStream:Qhj,isRequest:Ghj,isResponse:$hj,isHeaders:Khj,isUndefined:e_i,isDate:Rhj,isFile:Lhj,isBlob:Uhj,isRegExp:syj,isFunction:pwe,isStream:Whj,isURLSearchParams:Jhj,isTypedArray:nyj,isFileList:Vhj,forEach:t_i,merge:alu,extend:Xhj,trim:Yhj,stripBOM:Zhj,inherits:khj,toFlatObject:eyj,kindOf:tya,kindOfTest:t2t,endsWith:tyj,toArray:ryj,forEachEntry:iyj,matchAll:ayj,isHTMLForm:oyj,hasOwnProperty:rdf,hasOwnProp:rdf,reduceDescriptors:sdf,freezeMethods:cyj,toObjectSet:lyj,toCamelCase:uyj,noop:fyj,toFiniteNumber:dyj,findKey:odf,global:hkr,isContextDefined:udf,ALPHABET:cdf,generateString:pyj,isSpecCompliantForm:_yj,toJSONObject:hyj,isAsyncFn:yyj,isThenable:vyj,setImmediate:ldf,asap:byj};function zBn(e,t,r,n,i){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),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Ol.inherits(zBn,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:Ol.toJSONObject(this.config),code:this.code,status:this.status}}});var fdf=zBn.prototype,ddf={};["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=>{ddf[e]={value:e}});Object.defineProperties(zBn,ddf);Object.defineProperty(fdf,"isAxiosError",{value:!0});zBn.from=(e,t,r,n,i,a)=>{let u=Object.create(fdf);return Ol.toFlatObject(e,u,function(d){return d!==Error.prototype},f=>f!=="isAxiosError"),zBn.call(u,e.message,t,r,n,i),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var sy=zBn;var pdf=Jo(uzr(),1),iya=pdf.default;function ulu(e){return Ol.isPlainObject(e)||Ol.isArray(e)}function hdf(e){return Ol.endsWith(e,"[]")?e.slice(0,-2):e}function _df(e,t,r){return e?e.concat(t).map(function(i,a){return i=hdf(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function gyj(e){return Ol.isArray(e)&&!e.some(ulu)}var myj=Ol.toFlatObject(Ol,{},null,function(t){return/^is[A-Z]/.test(t)});function Oyj(e,t,r){if(!Ol.isObject(e))throw new TypeError("target must be an object");t=t||new(iya||FormData),r=Ol.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,T){return!Ol.isUndefined(T[A])});let n=r.metaTokens,i=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&Ol.isSpecCompliantForm(t);if(!Ol.isFunction(i))throw new TypeError("visitor must be a function");function c(j){if(j===null)return"";if(Ol.isDate(j))return j.toISOString();if(!d&&Ol.isBlob(j))throw new sy("Blob is not supported. Use a Buffer instead.");return Ol.isArrayBuffer(j)||Ol.isTypedArray(j)?d&&typeof Blob=="function"?new Blob([j]):Buffer.from(j):j}function o(j,A,T){let B=j;if(j&&!T&&typeof j=="object"){if(Ol.endsWith(A,"{}"))A=n?A:A.slice(0,-2),j=JSON.stringify(j);else if(Ol.isArray(j)&&gyj(j)||(Ol.isFileList(j)||Ol.endsWith(A,"[]"))&&(B=Ol.toArray(j)))return A=hdf(A),B.forEach(function(C,N){!(Ol.isUndefined(C)||C===null)&&t.append(u===!0?_df([A],N,a):u===null?A:A+"[]",c(C))}),!1}return ulu(j)?!0:(t.append(_df(T,A,a),c(j)),!1)}let l=[],m=Object.assign(myj,{defaultVisitor:o,convertValue:c,isVisitable:ulu});function O(j,A){if(!Ol.isUndefined(j)){if(l.indexOf(j)!==-1)throw Error("Circular reference detected in "+A.join("."));l.push(j),Ol.forEach(j,function(B,F){(!(Ol.isUndefined(B)||B===null)&&i.call(t,B,Ol.isString(F)?F.trim():F,A,m))===!0&&O(B,A?A.concat(F):[F])}),l.pop()}}if(!Ol.isObject(e))throw new TypeError("data must be an object");return O(e),t}var p6r=Oyj;function ydf(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function vdf(e,t){this._pairs=[],e&&p6r(e,this,t)}var bdf=vdf.prototype;bdf.append=function(t,r){this._pairs.push([t,r])};bdf.toString=function(t){let r=t?function(n){return t.call(this,n,ydf)}:ydf;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var gdf=vdf;function Pyj(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ykr(e,t,r){if(!t)return e;let n=r&&r.encode||Pyj,i=r&&r.serialize,a;if(i?a=i(t,r):a=Ol.isURLSearchParams(t)?t.toString():new gdf(t,r).toString(n),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var slu=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Ol.forEach(this.handlers,function(n){n!==null&&t(n)})}},clu=slu;var NBn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var mdf=Jo(require("url"),1),Odf=mdf.default.URLSearchParams;var Pdf={isNode:!0,classes:{URLSearchParams:Odf,FormData:iya,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var dlu={};Dc(dlu,{hasBrowserEnv:()=>flu,hasStandardBrowserEnv:()=>jyj,hasStandardBrowserWebWorkerEnv:()=>wyj,navigator:()=>llu,origin:()=>Dyj});var flu=typeof window<"u"&&typeof document<"u",llu=typeof navigator=="object"&&navigator||void 0,jyj=flu&&(!llu||["ReactNative","NativeScript","NS"].indexOf(llu.product)<0),wyj=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Dyj=flu&&window.location.href||"http://localhost";var _2={...dlu,...Pdf};function plu(e,t){return p6r(e,new _2.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,a){return _2.isNode&&Ol.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function Syj(e){return Ol.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Eyj(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function Ayj(e){function t(r,n,i,a){let u=r[a++];if(u==="__proto__")return!0;let f=Number.isFinite(+u),d=a>=r.length;return u=!u&&Ol.isArray(i)?i.length:u,d?(Ol.hasOwnProp(i,u)?i[u]=[i[u],n]:i[u]=n,!f):((!i[u]||!Ol.isObject(i[u]))&&(i[u]=[]),t(r,n,i[u],a)&&Ol.isArray(i[u])&&(i[u]=Eyj(i[u])),!f)}if(Ol.isFormData(e)&&Ol.isFunction(e.entries)){let r={};return Ol.forEachEntry(e,(n,i)=>{t(Syj(n),i,r,0)}),r}return null}var aya=Ayj;function Myj(e,t,r){if(Ol.isString(e))try{return(t||JSON.parse)(e),Ol.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var _lu={transitional:NBn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Ol.isObject(t);if(a&&Ol.isHTMLForm(t)&&(t=new FormData(t)),Ol.isFormData(t))return i?JSON.stringify(aya(t)):t;if(Ol.isArrayBuffer(t)||Ol.isBuffer(t)||Ol.isStream(t)||Ol.isFile(t)||Ol.isBlob(t)||Ol.isReadableStream(t))return t;if(Ol.isArrayBufferView(t))return t.buffer;if(Ol.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let f;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return plu(t,this.formSerializer).toString();if((f=Ol.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return p6r(f?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),Myj(t)):t}],transformResponse:[function(t){let r=this.transitional||_lu.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Ol.isResponse(t)||Ol.isReadableStream(t))return t;if(t&&Ol.isString(t)&&(n&&!this.responseType||i)){let u=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(f){if(u)throw f.name==="SyntaxError"?sy.from(f,sy.ERR_BAD_RESPONSE,this,null,this.response):f}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_2.classes.FormData,Blob:_2.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ol.forEach(["delete","get","head","post","put","patch"],e=>{_lu.headers[e]={}});var FBn=_lu;var Tyj=Ol.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"]),jdf=e=>{let t={},r,n,i;return e&&e.split(`
|
|
1788
|
+
`}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&&uha(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var xlf=Jo(wlf(),1),qlf=Jo(luu(),1),Clf=Jo(Mlf(),1),Qx=Jo(fwe(),1),Blf=Jo(Ddi(),1);var xha=Jo(fwe(),1),Tlf=Jo(Ddi(),1),qha=function(e,t,r){return typeof e[t]!="function"?(0,xha.of)(e):(0,xha.from)((0,Tlf.default)(e[t])(r).then(n=>(e[t]=n,e)))};var Npi={isPlainObject:xlf.default,set:Clf.default,get:qlf.default},DBn=class extends fkr{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=Npi.isPlainObject(r)?{...r}:{},Npi.isPlainObject(t)&&(t=Object.values(t).every(i=>Npi.isPlainObject(i)&&i.name===void 0)?Object.entries(t).map(([i,a])=>({name:i,...a})):[t]);let n=Array.isArray(t)?(0,Qx.from)(t):t;return this.process=n.pipe((0,Qx.concatMap)(this.processQuestion.bind(this)),(0,Qx.publish)()),this.process.connect(),this.process.pipe((0,Qx.reduce)((i,a)=>(Npi.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,Qx.defer)(()=>(0,Qx.of)(t).pipe((0,Qx.concatMap)(this.setDefaultType.bind(this)),(0,Qx.concatMap)(this.filterIfRunnable.bind(this)),(0,Qx.concatMap)(()=>qha(t,"message",this.answers)),(0,Qx.concatMap)(()=>qha(t,"default",this.answers)),(0,Qx.concatMap)(()=>qha(t,"choices",this.answers)),(0,Qx.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,Qx.defer)(()=>(0,Qx.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,Qx.defer)(()=>(0,Qx.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&Npi.get(this.answers,t.name)!==void 0)return(0,Qx.empty)();if(t.when===!1)return(0,Qx.empty)();if(typeof t.when!="function")return(0,Qx.of)(t);let{answers:r}=this;return(0,Qx.defer)(()=>(0,Qx.from)((0,Blf.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,Qx.filter)(n=>n!=null)))}};function Ilf(e){let t=function(r,n){let i;try{i=new DBn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",gpi),this.registerPrompt("input",nkr),this.registerPrompt("number",mpi),this.registerPrompt("confirm",Opi),this.registerPrompt("rawlist",Ppi),this.registerPrompt("expand",jpi),this.registerPrompt("checkbox",wpi),this.registerPrompt("password",Dpi),this.registerPrompt("editor",Ipi)},t.restoreDefaultPrompts(),t}var ucu=Ilf();function Jdj(e,t){ucu.registerPrompt(e,t)}function Qdj(){ucu.restoreDefaultPrompts()}var Gdj={prompt:ucu,ui:{BottomBar:zpi,Prompt:DBn},createPromptModule:Ilf,registerPrompt:Jdj,restoreDefaultPrompts:Qdj,Separator:_ne},Cha=Gdj;var Jff=Jo(zlf()),vhj="4.2.1",e2t;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay"})(e2t||(e2t={}));function bhj(e,t){if(!e)throw new Error(t)}function ghj(e){return e?.replace(/\/+$/,"")}async function mhj(e,t){let r=null;for(let n=0;n<t.retryCount+1;n++){n>0&&await new Promise(i=>setTimeout(i,t.retryDelay));try{return await e()}catch(i){if(r=i,!t.retryCheck(i))throw i}}throw r}function Ohj(){return new Date().getTime()}function Nff(){return new Date().toISOString()}function Qff(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var $pi=String.fromCharCode,Fff="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Qha={};function Phj(e,t){if(!Qha[e]){Qha[e]={};for(let r=0;r<e.length;r++)Qha[e][e.charAt(r)]=r}return Qha[e][t]}var Kpi={compressToBase64:function(e){if(e==null)return"";let t=Kpi._compress(e,6,function(r){return Fff.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:Kpi._decompress(e.length,32,function(t){return Phj(Fff,e.charAt(t))})},compress:function(e){return Kpi._compress(e,16,function(t){return $pi(t)})},_compress:function(e,t,r){if(e==null)return"";let n={},i={},a=[],u,f,d="",c="",o="",l=2,m=3,O=2,j=0,A=0,T;for(T=0;T<e.length;T+=1)if(d=e.charAt(T),Object.prototype.hasOwnProperty.call(n,d)||(n[d]=m++,i[d]=!0),c=o+d,Object.prototype.hasOwnProperty.call(n,c))o=c;else{if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,A==t-1?(A=0,a.push(r(j)),j=0):A++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++),n[c]=m++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)j=j<<1,A==t-1?(A=0,a.push(r(j)),j=0):A++;for(f=o.charCodeAt(0),u=0;u<8;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}else{for(f=1,u=0;u<O;u++)j=j<<1|f,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++)}for(f=2,u=0;u<O;u++)j=j<<1|f&1,A==t-1?(A=0,a.push(r(j)),j=0):A++,f=f>>1;for(;;)if(j=j<<1,A==t-1){a.push(r(j));break}else A++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:Kpi._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let n=[],i=[],a={val:r(0),position:t,index:1},u=4,f=4,d=3,c="",o,l,m,O,j,A,T;for(o=0;o<3;o+=1)n[o]=o;for(m=0,j=Math.pow(2,2),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;switch(m){case 0:for(m=0,j=Math.pow(2,8),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;T=$pi(m);break;case 1:for(m=0,j=Math.pow(2,16),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;T=$pi(m);break;case 2:return""}for(n[3]=T,l=T,i.push(T);;){if(a.index>e)return"";for(m=0,j=Math.pow(2,d),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;switch(T=m){case 0:for(m=0,j=Math.pow(2,8),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;n[f++]=$pi(m),T=f-1,u--;break;case 1:for(m=0,j=Math.pow(2,16),A=1;A!=j;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*A,A<<=1;n[f++]=$pi(m),T=f-1,u--;break;case 2:return i.join("")}if(u==0&&(u=Math.pow(2,d),d++),n[T])c=n[T];else if(T===f)c=l+l.charAt(0);else return null;i.push(c),n[f++]=l+c.charAt(0),u--,l=c,u==0&&(u=Math.pow(2,d),d++)}}},$cu=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(n=>n!==r)}}emit(t,r){for(let n of this.events[t]||[])n(r);for(let n of this.events["*"]||[])n(t,r)}};var Gha="0123456789abcdef",$ha=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,n,i){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(n)||!Number.isInteger(i)||t<0||r<0||n<0||i<0||t>0xffffffffffff||r>4095||n>1073741823||i>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|n>>>24,a[9]=n>>>16,a[10]=n>>>8,a[11]=n,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,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 n=new Uint8Array(16);for(let i=0;i<16;i+=4){let a=parseInt(r.substring(2*i,2*i+8),16);n[i+0]=a>>>24,n[i+1]=a>>>16,n[i+2]=a>>>8,n[i+3]=a}return new e(n)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=Gha.charAt(this.bytes[r]>>>4),t+=Gha.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+=Gha.charAt(this.bytes[r]>>>4),t+=Gha.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 n=this.bytes[r]-t.bytes[r];if(n!==0)return Math.sign(n)}return 0}},Kcu=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??jhj()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let n=this.generateOrAbortCore(t,r);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(t,r)),n}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 $ha.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,$ha.ofInner(t)}},jhj=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Rff,Lff=()=>whj().toString(),whj=()=>(Rff||(Rff=new Kcu)).generate(),Kha=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},Ypi=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function Uff(e){return typeof e=="object"&&(e instanceof Kha||e instanceof Ypi)}var Ycu=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new $cu,this._isInitialized=!1,bhj(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=ghj(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:Uff},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(e2t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(e2t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(e2t.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(n,i)=>console.log("PostHog Debug",n,i));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=Lff();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,n){this.wrap(()=>{let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",i,n)})}captureStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:n});this.enqueue("capture",a,i)})}aliasStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});this.enqueue("alias",a,i)})}groupIdentifyStateless(t,r,n,i,a,u){this.wrap(()=>{let f=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:n||{},...u||{}}});this.enqueue("capture",f,i)})}async getDecide(t,r={},n={},i={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i,...a})};return this.fetchWithRetry(u,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(d=>d.json()).catch(d=>{this._events.emit("error",d)})}async getFeatureFlagStateless(t,r,n={},i={},a={},u){await this._initPromise;let f=await this.getFeatureFlagsStateless(r,n,i,a,u);if(!f)return;let d=f[t];return d===void 0&&(d=!1),d}async getFeatureFlagPayloadStateless(t,r,n={},i={},a={},u){await this._initPromise;let f=await this.getFeatureFlagPayloadsStateless(r,n,i,a,u);if(!f)return;let d=f[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},n={},i={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},n={},i={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},n={},i={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let f=await this.getDecide(t,r,n,i,u),d=f?.featureFlags,c=f?.featureFlagPayloads,o=c;return c&&(o=Object.fromEntries(Object.entries(c).map(([l,m])=>[l,this._parsePayload(m)]))),{flags:d,payloads:o}}enqueue(t,r,n){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:Nff(),uuid:n?.uuid?n.uuid:Lff()};(n?.disableGeoip??this.disableGeoip)&&(i.properties||(i.properties={}),i.properties.$geoip_disable=!0),i.distinctId&&(i.distinct_id=i.distinctId,delete i.distinctId);let u=this.getPersistedProperty(e2t.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:i}),this.setPersistedProperty(e2t.Queue,u),this._events.emit(t,i),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Qff(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(e2t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),n=r.map(c=>c.message),i=()=>{let c=this.getPersistedProperty(e2t.Queue)||[];this.setPersistedProperty(e2t.Queue,c.slice(r.length))},a={api_key:this.apiKey,batch:n,sent_at:Nff()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),f=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${Ohj()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,d=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(Kpi.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(f,d)}catch(c){throw c instanceof Ypi||i(),this._events.emit("error",c),c}return i(),this._events.emit("flush",n),n}async fetchWithRetry(t,r,n,i){var a;return(a=AbortSignal).timeout??(a.timeout=function(f){let d=new AbortController;return setTimeout(()=>d.abort(),f),d.signal}),await mhj(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(d){throw new Ypi(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new Kha(u);return u},{...this._retryOptions,...n})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(e2t.Queue)||[]).length!==0;){await this.flush();let i=Date.now();if(r<i)break}}catch(r){if(!Uff(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},Xcu=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},Zcu=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!Zcu){let e=zff();Zcu=async(t,r)=>{let n=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:n.status,text:async()=>n.data,json:async()=>n.data}}}var Gff=Zcu,Dhj=1152921504606847e3,Shj=["is_not"],Yha=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},_8=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},kcu=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:a,customHeaders:u,...f}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=i,this.projectApiKey=n,this.host=a,this.poller=void 0,this.fetch=f.fetch||Gff,this.onError=f.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,n={},i={},a={}){await this.loadFeatureFlags();let u,f;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){f=d;break}if(f!==void 0)try{u=this.computeFlagLocally(f,r,n,i,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof _8?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 n;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),n==null)return null;try{return JSON.parse(n)}catch{return n}}}async getAllFlagsAndPayloads(t,r={},n={},i={}){await this.loadFeatureFlags();let a={},u={},f=this.featureFlags.length==0;return this.featureFlags.map(async d=>{try{let c=this.computeFlagLocally(d,t,r,n,i);a[d.key]=c;let o=await this.computeFeatureFlagPayloadLocally(d.key,c);o&&(u[d.key]=o)}catch(c){c instanceof _8||c instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${c}`)),f=!0}}),{response:a,payloads:u,fallbackToDecide:f}}computeFlagLocally(t,r,n={},i={},a={}){if(t.ensure_experience_continuity)throw new _8("Flag has experience continuity enabled");if(!t.active)return!1;let f=(t.filters||{}).aggregation_group_type_index;if(f!=null){let d=this.groupTypeMapping[String(f)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${f} for feature flag ${t.key}`)),new _8("Flag has unknown group type index");if(!(d in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let c=a[d];return this.matchFeatureFlagProperties(t,n[d],c)}else return this.matchFeatureFlagProperties(t,r,i)}matchFeatureFlagProperties(t,r,n){let i=t.filters||{},a=i.groups||[],u=!1,f,d=[...a].sort((c,o)=>{let l=!!c.variant,m=!!o.variant;return l&&m?0:l?-1:m?1:0});for(let c of d)try{if(this.isConditionMatch(t,r,c,n)){let o=c.variant,l=i.multivariate?.variants||[];o&&l.some(m=>m.key===o)?f=o:f=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof _8)u=!0;else throw o}if(f!==void 0)return f;if(u)throw new _8("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,n,i){let a=n.rollout_percentage,u=f=>{this.logMsgIfDebug(()=>console.warn(f))};if((n.properties||[]).length>0){for(let f of n.properties){let d=f.type,c=!1;if(d==="cohort"?c=Kff(f,i,this.cohorts,this.debugMode):c=$ff(f,i,u),!c)return!1}if(a==null)return!0}return!(a!=null&&Vff(t.key,r)>a/100)}getMatchingVariant(t,r){let n=Vff(t.key,r,"variant"),i=this.variantLookupTable(t).find(a=>n>=a.valueMin&&n<a.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(f=>{i=n+f.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:f.key}),n=i}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new Yha("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce((n,i)=>(n[i.key]=i,n),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof Yha&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=Qff(()=>{i.abort()},this.timeout),r.signal=i.signal}try{return await this.fetch(t,r)}finally{clearTimeout(n)}}stopPoller(){clearTimeout(this.poller)}};function Vff(e,t,r=""){let n=(0,Jff.createHash)();return n.update(`${e}.${t}${r}`),parseInt(n.digest("hex").slice(0,15),16)/Dhj}function $ff(e,t,r){let n=e.key,i=e.value,a=e.operator||"exact";if(n in t){if(a==="is_not_set")throw new _8("Operator is_not_set is not supported")}else throw new _8(`Property ${n} not found in propertyValues`);let u=t[n];if(u==null&&!Shj.includes(a))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${a} operator`),!1;function f(c,o){return Array.isArray(c)?c.map(l=>String(l).toLowerCase()).includes(String(o).toLowerCase()):String(c).toLowerCase()===String(o).toLowerCase()}function d(c,o,l){if(l==="gt")return c>o;if(l==="gte")return c>=o;if(l==="lt")return c<o;if(l==="lte")return c<=o;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return f(i,u);case"is_not":return!f(i,u);case"is_set":return n in t;case"icontains":return String(u).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(i).toLowerCase());case"regex":return Wff(String(i))&&String(u).match(String(i))!==null;case"not_regex":return Wff(String(i))&&String(u).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let c=typeof i=="number"?i:null;if(typeof i=="string")try{c=parseFloat(i)}catch{}return c!=null&&u!=null?typeof u=="string"?d(u,String(i),a):d(u,c,a):d(String(u),String(i),a)}case"is_date_after":case"is_date_before":{let c=Ehj(String(i));if(c==null&&(c=Hff(i)),c==null)throw new _8(`Invalid date: ${i}`);let o=Hff(u);return["is_date_before"].includes(a)?o<c:o>c}default:throw new _8(`Unknown operator: ${a}`)}}function Kff(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new _8("can't match cohort without a given cohort property value");let a=r[i];return Yff(a,t,r,n)}function Yff(e,t,r,n=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let f of a)try{let d=Yff(f,t,r,n);if(i==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof _8)n&&console.debug(`Failed to compute property ${f} locally: ${d}`),u=!0;else throw d}if(u)throw new _8("Can't match cohort without a given cohort property value");return i==="AND"}else{for(let f of a)try{let d;f.type==="cohort"?d=Kff(f,t,r,n):d=$ff(f,t);let c=f.negation||!1;if(i==="AND"){if(!d&&!c||d&&c)return!1}else if(d&&!c||!d&&c)return!0}catch(d){if(d instanceof _8)n&&console.debug(`Failed to compute property ${f} locally: ${d}`),u=!0;else throw d}if(u)throw new _8("can't match cohort without a given cohort property value");return i==="AND"}}function Wff(e){try{return new RegExp(e),!0}catch{return!1}}function Hff(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 _8(`${e} is in an invalid date format`)}else throw new _8(`The date provided ${e} must be a string, number, or date object`)}function Ehj(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let a=r.groups.interval;if(a=="h")n.setUTCHours(n.getUTCHours()-i);else if(a=="d")n.setUTCDate(n.getUTCDate()-i);else if(a=="w")n.setUTCDate(n.getUTCDate()-i*7);else if(a=="m")n.setUTCMonth(n.getUTCMonth()-i);else if(a=="y")n.setUTCFullYear(n.getUTCFullYear()-i);else return null;return n}else return null}var Ahj=30*1e3,Mhj=50*1e3,qBn=class extends Ycu{constructor(t,r={}){super(t,r),this._memoryStorage=new Xcu,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new kcu({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:Ahj,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||Mhj}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):Gff(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return vhj}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture({distinctId:t,event:r,properties:n,groups:i,sendFeatureFlags:a,timestamp:u,disableGeoip:f,uuid:d}){let c=m=>{super.captureStateless(t,r,m,{timestamp:u,disableGeoip:f,uuid:d})},o=(m,O,j)=>super.getFeatureFlagsStateless(m,O,void 0,void 0,j),l=Promise.resolve().then(async()=>{if(a)return await o(t,i,f);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let m={};for(let[O,j]of Object.entries(i||{}))m[O]=String(j);return await this.getAllFlags(t,{groups:m,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(m=>{let O={};if(m)for(let[A,T]of Object.entries(m))O[`$feature/${A}`]=T;let j=Object.keys(m||{}).filter(A=>m?.[A]!==!1);return j.length>0&&(O.$active_feature_flags=j),O}).catch(()=>({})).then(m=>{c({...m,...n,$groups:i})});this.addPendingPromise(l)}identify({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set||r;super.identifyStateless(t,{$set:i},{disableGeoip:n})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,n){let{groups:i,disableGeoip:a}=n||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:f,personProperties:d,groupProperties:c}=n||{},o=this.addLocalPersonAndGroupProperties(r,i,d,c);d=o.allPersonProperties,c=o.allGroupProperties,u==null&&(u=!1),f==null&&(f=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,i,d,c),m=l!==void 0;!m&&!u&&(l=await super.getFeatureFlagStateless(t,r,i,d,c,a));let O=`${t}_${l}`;return f&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(O))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(O):this.distinctIdHasSentFlagCalls[r]=[O],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,locally_evaluated:m,[`$feature/${t}`]:l},groups:i,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,n,i){let{groups:a,disableGeoip:u}=i||{},{onlyEvaluateLocally:f,sendFeatureFlagEvents:d,personProperties:c,groupProperties:o}=i||{},l=this.addLocalPersonAndGroupProperties(r,a,c,o);c=l.allPersonProperties,o=l.allGroupProperties;let m;return n||(n=await this.getFeatureFlag(t,r,{...i,onlyEvaluateLocally:!0})),n&&(m=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,n)),f==null&&(f=!1),d==null&&(d=!0),f==null&&(f=!1),!(m!==void 0)&&!f&&(m=await super.getFeatureFlagPayloadStateless(t,r,a,c,o,u)),m}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:n,disableGeoip:i}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:f}=r||{},d=this.addLocalPersonAndGroupProperties(t,n,u,f);u=d.allPersonProperties,f=d.allGroupProperties,a==null&&(a=!1);let c=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,u,f),o={},l={},m=!0;if(c&&(o=c.response,l=c.payloads,m=c.fallbackToDecide),m&&!a){let O=await super.getFeatureFlagsAndPayloadsStateless(t,n,u,f,i);o={...o,...O.flags||{}},l={...l,...O.payloads||{}}}return{featureFlags:o,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:a}){super.groupIdentifyStateless(t,r,n,{disableGeoip:a},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,n,i){let a={distinct_id:t,...n||{}},u={};if(r)for(let f of Object.keys(r))u[f]={$group_key:r[f],...i?.[f]||{}};return{allPersonProperties:a,allGroupProperties:u}}},elu=class e{constructor(t,r,n,i){this.posthog=t,this.posthogHost=r,this.organization=n,this.prefix=i,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(n=>{if(n.exception?.values===void 0||n.exception.values.length===0)return n;n.tags||(n.tags={});let i=r(),a=n.tags[e.POSTHOG_ID_TAG];if(a===void 0)return n;n.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:n.exception.values[0]?.value,$exception_type:n.exception.values[0]?.type,$exception_personURL:n.tags["PostHog Person URL"],$sentry_event_id:n.event_id,$sentry_exception:n.exception,$sentry_exception_message:n.exception.values[0]?.value,$sentry_exception_type:n.exception.values[0]?.type,$sentry_tags:n.tags},f=i.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&f!==void 0&&n.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${f}&query=${n.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),n})}};elu.POSTHOG_ID_TAG="posthog_distinct_id";var Xha=class{posthog;constructor({posthogApiKey:t}){this.posthog=new qBn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.45.0-rc47",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var Xpi=class{async sendEvent(){}async identify(){}async flush(){}};var CBn=require("fs/promises"),edf=require("os"),tdf=require("path");var Xff=Jo(require("crypto")),kha=new Uint8Array(256),Zha=kha.length;function tlu(){return Zha>kha.length-16&&(Xff.default.randomFillSync(kha),Zha=0),kha.slice(Zha,Zha+=16)}var lW=[];for(let e=0;e<256;++e)lW.push((e+256).toString(16).slice(1));function Zff(e,t=0){return lW[e[t+0]]+lW[e[t+1]]+lW[e[t+2]]+lW[e[t+3]]+"-"+lW[e[t+4]]+lW[e[t+5]]+"-"+lW[e[t+6]]+lW[e[t+7]]+"-"+lW[e[t+8]]+lW[e[t+9]]+"-"+lW[e[t+10]]+lW[e[t+11]]+lW[e[t+12]]+lW[e[t+13]]+lW[e[t+14]]+lW[e[t+15]]}var kff=Jo(require("crypto")),rlu={randomUUID:kff.default.randomUUID};function Thj(e,t,r){if(rlu.randomUUID&&!t&&!e)return rlu.randomUUID();e=e||{};let n=e.random||(e.rng||tlu)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Zff(n)}var d6r=Thj;var xhj="id",qhj=".fern",Zpi=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new qBn(r),this.userId=t==null?void 0:bru(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.45.0-rc47",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Wl(Hp.of((0,edf.homedir)()),ls.of(qhj),ls.of(xhj));await _h(t)||(await(0,CBn.mkdir)((0,tdf.dirname)(t),{recursive:!0}),await(0,CBn.writeFile)(t,d6r())),this.persistedDistinctId=(await(0,CBn.readFile)(t)).toString()}return this.persistedDistinctId}};var nlu;async function BBn(){return nlu==null&&(nlu=await Chj()),nlu}async function Chj(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Xpi;let r=await uca();return r!=null?new Zpi({token:r,posthogApiKey:e}):await oca()!=null?new Xha({posthogApiKey:e}):new Zpi({token:void 0,posthogApiKey:e})}catch{return new Xpi}}function kpi(e,t){return function(){return e.apply(t,arguments)}}var{toString:Bhj}=Object.prototype,{getPrototypeOf:olu}=Object,tya=(e=>t=>{let r=Bhj.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),t2t=e=>(e=e.toLowerCase(),t=>tya(t)===e),rya=e=>t=>typeof t===e,{isArray:IBn}=Array,e_i=rya("undefined");function Ihj(e){return e!==null&&!e_i(e)&&e.constructor!==null&&!e_i(e.constructor)&&pwe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var idf=t2t("ArrayBuffer");function zhj(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&idf(e.buffer),t}var Nhj=rya("string"),pwe=rya("function"),adf=rya("number"),nya=e=>e!==null&&typeof e=="object",Fhj=e=>e===!0||e===!1,eya=e=>{if(tya(e)!=="object")return!1;let t=olu(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Rhj=t2t("Date"),Lhj=t2t("File"),Uhj=t2t("Blob"),Vhj=t2t("FileList"),Whj=e=>nya(e)&&pwe(e.pipe),Hhj=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||pwe(e.append)&&((t=tya(e))==="formdata"||t==="object"&&pwe(e.toString)&&e.toString()==="[object FormData]"))},Jhj=t2t("URLSearchParams"),[Qhj,Ghj,$hj,Khj]=["ReadableStream","Request","Response","Headers"].map(t2t),Yhj=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function t_i(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),IBn(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,f;for(n=0;n<u;n++)f=a[n],t.call(null,e[f],f,e)}}function odf(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var hkr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,udf=e=>!e_i(e)&&e!==hkr;function alu(){let{caseless:e}=udf(this)&&this||{},t={},r=(n,i)=>{let a=e&&odf(t,i)||i;eya(t[a])&&eya(n)?t[a]=alu(t[a],n):eya(n)?t[a]=alu({},n):IBn(n)?t[a]=n.slice():t[a]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&t_i(arguments[n],r);return t}var Xhj=(e,t,r,{allOwnKeys:n}={})=>(t_i(t,(i,a)=>{r&&pwe(i)?e[a]=kpi(i,r):e[a]=i},{allOwnKeys:n}),e),Zhj=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),khj=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},eyj=(e,t,r,n)=>{let i,a,u,f={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)u=i[a],(!n||n(u,e,t))&&!f[u]&&(t[u]=e[u],f[u]=!0);e=r!==!1&&olu(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},tyj=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},ryj=e=>{if(!e)return null;if(IBn(e))return e;let t=e.length;if(!adf(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},nyj=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&olu(Uint8Array)),iyj=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},ayj=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},oyj=t2t("HTMLFormElement"),uyj=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),rdf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),syj=t2t("RegExp"),sdf=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};t_i(r,(i,a)=>{let u;(u=t(i,a,e))!==!1&&(n[a]=u||i)}),Object.defineProperties(e,n)},cyj=e=>{sdf(e,(t,r)=>{if(pwe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(pwe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},lyj=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return IBn(e)?n(e):n(String(e).split(t)),r},fyj=()=>{},dyj=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,ilu="abcdefghijklmnopqrstuvwxyz",ndf="0123456789",cdf={DIGIT:ndf,ALPHA:ilu,ALPHA_DIGIT:ilu+ilu.toUpperCase()+ndf},pyj=(e=16,t=cdf.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function _yj(e){return!!(e&&pwe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var hyj=e=>{let t=new Array(10),r=(n,i)=>{if(nya(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;let a=IBn(n)?[]:{};return t_i(n,(u,f)=>{let d=r(u,i+1);!e_i(d)&&(a[f]=d)}),t[i]=void 0,a}}return n};return r(e,0)},yyj=t2t("AsyncFunction"),vyj=e=>e&&(nya(e)||pwe(e))&&pwe(e.then)&&pwe(e.catch),ldf=((e,t)=>e?setImmediate:t?((r,n)=>(hkr.addEventListener("message",({source:i,data:a})=>{i===hkr&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),hkr.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",pwe(hkr.postMessage)),byj=typeof queueMicrotask<"u"?queueMicrotask.bind(hkr):typeof process<"u"&&process.nextTick||ldf,Ol={isArray:IBn,isArrayBuffer:idf,isBuffer:Ihj,isFormData:Hhj,isArrayBufferView:zhj,isString:Nhj,isNumber:adf,isBoolean:Fhj,isObject:nya,isPlainObject:eya,isReadableStream:Qhj,isRequest:Ghj,isResponse:$hj,isHeaders:Khj,isUndefined:e_i,isDate:Rhj,isFile:Lhj,isBlob:Uhj,isRegExp:syj,isFunction:pwe,isStream:Whj,isURLSearchParams:Jhj,isTypedArray:nyj,isFileList:Vhj,forEach:t_i,merge:alu,extend:Xhj,trim:Yhj,stripBOM:Zhj,inherits:khj,toFlatObject:eyj,kindOf:tya,kindOfTest:t2t,endsWith:tyj,toArray:ryj,forEachEntry:iyj,matchAll:ayj,isHTMLForm:oyj,hasOwnProperty:rdf,hasOwnProp:rdf,reduceDescriptors:sdf,freezeMethods:cyj,toObjectSet:lyj,toCamelCase:uyj,noop:fyj,toFiniteNumber:dyj,findKey:odf,global:hkr,isContextDefined:udf,ALPHABET:cdf,generateString:pyj,isSpecCompliantForm:_yj,toJSONObject:hyj,isAsyncFn:yyj,isThenable:vyj,setImmediate:ldf,asap:byj};function zBn(e,t,r,n,i){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),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Ol.inherits(zBn,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:Ol.toJSONObject(this.config),code:this.code,status:this.status}}});var fdf=zBn.prototype,ddf={};["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=>{ddf[e]={value:e}});Object.defineProperties(zBn,ddf);Object.defineProperty(fdf,"isAxiosError",{value:!0});zBn.from=(e,t,r,n,i,a)=>{let u=Object.create(fdf);return Ol.toFlatObject(e,u,function(d){return d!==Error.prototype},f=>f!=="isAxiosError"),zBn.call(u,e.message,t,r,n,i),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var sy=zBn;var pdf=Jo(uzr(),1),iya=pdf.default;function ulu(e){return Ol.isPlainObject(e)||Ol.isArray(e)}function hdf(e){return Ol.endsWith(e,"[]")?e.slice(0,-2):e}function _df(e,t,r){return e?e.concat(t).map(function(i,a){return i=hdf(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function gyj(e){return Ol.isArray(e)&&!e.some(ulu)}var myj=Ol.toFlatObject(Ol,{},null,function(t){return/^is[A-Z]/.test(t)});function Oyj(e,t,r){if(!Ol.isObject(e))throw new TypeError("target must be an object");t=t||new(iya||FormData),r=Ol.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,T){return!Ol.isUndefined(T[A])});let n=r.metaTokens,i=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&Ol.isSpecCompliantForm(t);if(!Ol.isFunction(i))throw new TypeError("visitor must be a function");function c(j){if(j===null)return"";if(Ol.isDate(j))return j.toISOString();if(!d&&Ol.isBlob(j))throw new sy("Blob is not supported. Use a Buffer instead.");return Ol.isArrayBuffer(j)||Ol.isTypedArray(j)?d&&typeof Blob=="function"?new Blob([j]):Buffer.from(j):j}function o(j,A,T){let B=j;if(j&&!T&&typeof j=="object"){if(Ol.endsWith(A,"{}"))A=n?A:A.slice(0,-2),j=JSON.stringify(j);else if(Ol.isArray(j)&&gyj(j)||(Ol.isFileList(j)||Ol.endsWith(A,"[]"))&&(B=Ol.toArray(j)))return A=hdf(A),B.forEach(function(C,N){!(Ol.isUndefined(C)||C===null)&&t.append(u===!0?_df([A],N,a):u===null?A:A+"[]",c(C))}),!1}return ulu(j)?!0:(t.append(_df(T,A,a),c(j)),!1)}let l=[],m=Object.assign(myj,{defaultVisitor:o,convertValue:c,isVisitable:ulu});function O(j,A){if(!Ol.isUndefined(j)){if(l.indexOf(j)!==-1)throw Error("Circular reference detected in "+A.join("."));l.push(j),Ol.forEach(j,function(B,F){(!(Ol.isUndefined(B)||B===null)&&i.call(t,B,Ol.isString(F)?F.trim():F,A,m))===!0&&O(B,A?A.concat(F):[F])}),l.pop()}}if(!Ol.isObject(e))throw new TypeError("data must be an object");return O(e),t}var p6r=Oyj;function ydf(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function vdf(e,t){this._pairs=[],e&&p6r(e,this,t)}var bdf=vdf.prototype;bdf.append=function(t,r){this._pairs.push([t,r])};bdf.toString=function(t){let r=t?function(n){return t.call(this,n,ydf)}:ydf;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var gdf=vdf;function Pyj(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ykr(e,t,r){if(!t)return e;let n=r&&r.encode||Pyj,i=r&&r.serialize,a;if(i?a=i(t,r):a=Ol.isURLSearchParams(t)?t.toString():new gdf(t,r).toString(n),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var slu=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Ol.forEach(this.handlers,function(n){n!==null&&t(n)})}},clu=slu;var NBn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var mdf=Jo(require("url"),1),Odf=mdf.default.URLSearchParams;var Pdf={isNode:!0,classes:{URLSearchParams:Odf,FormData:iya,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var dlu={};Dc(dlu,{hasBrowserEnv:()=>flu,hasStandardBrowserEnv:()=>jyj,hasStandardBrowserWebWorkerEnv:()=>wyj,navigator:()=>llu,origin:()=>Dyj});var flu=typeof window<"u"&&typeof document<"u",llu=typeof navigator=="object"&&navigator||void 0,jyj=flu&&(!llu||["ReactNative","NativeScript","NS"].indexOf(llu.product)<0),wyj=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Dyj=flu&&window.location.href||"http://localhost";var _2={...dlu,...Pdf};function plu(e,t){return p6r(e,new _2.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,a){return _2.isNode&&Ol.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function Syj(e){return Ol.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Eyj(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function Ayj(e){function t(r,n,i,a){let u=r[a++];if(u==="__proto__")return!0;let f=Number.isFinite(+u),d=a>=r.length;return u=!u&&Ol.isArray(i)?i.length:u,d?(Ol.hasOwnProp(i,u)?i[u]=[i[u],n]:i[u]=n,!f):((!i[u]||!Ol.isObject(i[u]))&&(i[u]=[]),t(r,n,i[u],a)&&Ol.isArray(i[u])&&(i[u]=Eyj(i[u])),!f)}if(Ol.isFormData(e)&&Ol.isFunction(e.entries)){let r={};return Ol.forEachEntry(e,(n,i)=>{t(Syj(n),i,r,0)}),r}return null}var aya=Ayj;function Myj(e,t,r){if(Ol.isString(e))try{return(t||JSON.parse)(e),Ol.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var _lu={transitional:NBn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Ol.isObject(t);if(a&&Ol.isHTMLForm(t)&&(t=new FormData(t)),Ol.isFormData(t))return i?JSON.stringify(aya(t)):t;if(Ol.isArrayBuffer(t)||Ol.isBuffer(t)||Ol.isStream(t)||Ol.isFile(t)||Ol.isBlob(t)||Ol.isReadableStream(t))return t;if(Ol.isArrayBufferView(t))return t.buffer;if(Ol.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let f;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return plu(t,this.formSerializer).toString();if((f=Ol.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return p6r(f?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),Myj(t)):t}],transformResponse:[function(t){let r=this.transitional||_lu.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Ol.isResponse(t)||Ol.isReadableStream(t))return t;if(t&&Ol.isString(t)&&(n&&!this.responseType||i)){let u=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(f){if(u)throw f.name==="SyntaxError"?sy.from(f,sy.ERR_BAD_RESPONSE,this,null,this.response):f}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_2.classes.FormData,Blob:_2.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ol.forEach(["delete","get","head","post","put","patch"],e=>{_lu.headers[e]={}});var FBn=_lu;var Tyj=Ol.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"]),jdf=e=>{let t={},r,n,i;return e&&e.split(`
|
|
1789
1789
|
`).forEach(function(u){i=u.indexOf(":"),r=u.substring(0,i).trim().toLowerCase(),n=u.substring(i+1).trim(),!(!r||t[r]&&Tyj[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var wdf=Symbol("internals");function r_i(e){return e&&String(e).trim().toLowerCase()}function oya(e){return e===!1||e==null?e:Ol.isArray(e)?e.map(oya):String(e)}function xyj(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var qyj=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function hlu(e,t,r,n,i){if(Ol.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!Ol.isString(t)){if(Ol.isString(n))return t.indexOf(n)!==-1;if(Ol.isRegExp(n))return n.test(t)}}function Cyj(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function Byj(e,t){let r=Ol.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,a,u){return this[n].call(this,t,i,a,u)},configurable:!0})})}var RBn=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(f,d,c){let o=r_i(d);if(!o)throw new Error("header name must be a non-empty string");let l=Ol.findKey(i,o);(!l||i[l]===void 0||c===!0||c===void 0&&i[l]!==!1)&&(i[l||d]=oya(f))}let u=(f,d)=>Ol.forEach(f,(c,o)=>a(c,o,d));if(Ol.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(Ol.isString(t)&&(t=t.trim())&&!qyj(t))u(jdf(t),r);else if(Ol.isHeaders(t))for(let[f,d]of t.entries())a(d,f,n);else t!=null&&a(r,t,n);return this}get(t,r){if(t=r_i(t),t){let n=Ol.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return xyj(i);if(Ol.isFunction(r))return r.call(this,i,n);if(Ol.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=r_i(t),t){let n=Ol.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||hlu(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(u){if(u=r_i(u),u){let f=Ol.findKey(n,u);f&&(!r||hlu(n,n[f],f,r))&&(delete n[f],i=!0)}}return Ol.isArray(t)?t.forEach(a):a(t),i}clear(t){let r=Object.keys(this),n=r.length,i=!1;for(;n--;){let a=r[n];(!t||hlu(this,this[a],a,t,!0))&&(delete this[a],i=!0)}return i}normalize(t){let r=this,n={};return Ol.forEach(this,(i,a)=>{let u=Ol.findKey(n,a);if(u){r[u]=oya(i),delete r[a];return}let f=t?Cyj(a):String(a).trim();f!==a&&delete r[a],r[f]=oya(i),n[f]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Ol.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&Ol.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
1790
1790
|
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){let n=(this[wdf]=this[wdf]={accessors:{}}).accessors,i=this.prototype;function a(u){let f=r_i(u);n[f]||(Byj(i,u),n[f]=!0)}return Ol.isArray(t)?t.forEach(a):a(t),this}};RBn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Ol.reduceDescriptors(RBn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Ol.freezeMethods(RBn);var vz=RBn;function n_i(e,t){let r=this||FBn,n=t||r,i=vz.from(n.headers),a=n.data;return Ol.forEach(e,function(f){a=f.call(r,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function i_i(e){return!!(e&&e.__CANCEL__)}function Ddf(e,t,r){sy.call(this,e??"canceled",sy.ERR_CANCELED,t,r),this.name="CanceledError"}Ol.inherits(Ddf,sy,{__CANCEL__:!0});var _we=Ddf;function kRt(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new sy("Request failed with status code "+r.status,[sy.ERR_BAD_REQUEST,sy.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function ylu(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function vlu(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function vkr(e,t){return e&&!ylu(t)?vlu(e,t):t}var Udf=Jo(ccu(),1),Vdf=Jo(require("http"),1),Wdf=Jo(require("https"),1),Hdf=Jo(require("util"),1),Jdf=Jo(Pcu(),1),RDr=Jo(require("zlib"),1);var bkr="1.7.7";function a_i(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var Iyj=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function blu(e,t,r){let n=r&&r.Blob||_2.classes.Blob,i=a_i(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=Iyj.exec(e);if(!a)throw new sy("Invalid URL",sy.ERR_INVALID_URL);let u=a[1],f=a[2],d=a[3],c=Buffer.from(decodeURIComponent(d),f?"base64":"utf8");if(t){if(!n)throw new sy("Blob is not supported",sy.ERR_NOT_SUPPORT);return new n([c],{type:u})}return c}throw new sy("Unsupported protocol "+i,sy.ERR_NOT_SUPPORT)}var gkr=Jo(require("stream"),1);var Sdf=Jo(require("stream"),1);var glu=Symbol("internals"),mlu=class extends Sdf.default.Transform{constructor(t){t=Ol.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!Ol.isUndefined(i[n])),super({readableHighWaterMark:t.chunkSize});let r=this[glu]={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",n=>{n==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[glu];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[glu],a=i.maxRate,u=this.readableHighWaterMark,f=i.timeWindow,d=1e3/f,c=a/d,o=i.minChunkSize!==!1?Math.max(i.minChunkSize,c*.01):0,l=(O,j)=>{let A=Buffer.byteLength(O);i.bytesSeen+=A,i.bytes+=A,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(O)?process.nextTick(j):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(j)}},m=(O,j)=>{let A=Buffer.byteLength(O),T=null,B=u,F,C=0;if(a){let N=Date.now();(!i.ts||(C=N-i.ts)>=f)&&(i.ts=N,F=c-i.bytes,i.bytes=F<0?-F:0,C=0),F=c-i.bytes}if(a){if(F<=0)return setTimeout(()=>{j(null,O)},f-C);F<B&&(B=F)}B&&A>B&&A-B>o&&(T=O.subarray(B),O=O.subarray(0,B)),l(O,T?()=>{process.nextTick(j,null,T)}:j)};m(t,function O(j,A){if(j)return n(j);A?m(A,O):n(null)})}},Olu=mlu;var Qdf=require("events");var Adf=require("util"),Mdf=require("stream");var{asyncIterator:Edf}=Symbol,zyj=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[Edf]?yield*e[Edf]():yield e},uya=zyj;var Nyj=Ol.ALPHABET.ALPHA_DIGIT+"-_",o_i=new Adf.TextEncoder,_6r=`\r
|
|
1791
1791
|
`,Fyj=o_i.encode(_6r),Ryj=2,Plu=class{constructor(t,r){let{escapeName:n}=this.constructor,i=Ol.isString(r),a=`Content-Disposition: form-data; name="${n(t)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${_6r}`;i?r=o_i.encode(String(r).replace(/\r?\n|\r\n?/g,_6r)):a+=`Content-Type: ${r.type||"application/octet-stream"}${_6r}`,this.headers=o_i.encode(a+_6r),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+Ryj,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Ol.isTypedArray(t)?yield t:yield*uya(t),yield Fyj}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},Lyj=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+Ol.generateString(i,Nyj)}=r||{};if(!Ol.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=o_i.encode("--"+a+_6r),f=o_i.encode("--"+a+"--"+_6r+_6r),d=f.byteLength,c=Array.from(e.entries()).map(([l,m])=>{let O=new Plu(l,m);return d+=O.size,O});d+=u.byteLength*c.length,d=Ol.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),Mdf.Readable.from(async function*(){for(let l of c)yield u,yield*l.encode();yield f}())},Tdf=Lyj;var xdf=Jo(require("stream"),1),jlu=class extends xdf.default.Transform{__transform(t,r,n){this.push(t),n()}_transform(t,r,n){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let i=Buffer.alloc(2);i[0]=120,i[1]=156,this.push(i,r)}this.__transform(t,r,n)}},qdf=jlu;var Uyj=(e,t)=>Ol.isAsyncFn(e)?function(...r){let n=r.pop();e.apply(this,r).then(i=>{try{t?n(null,...t(i)):n(null,i)}catch(a){n(a)}},n)}:e,Cdf=Uyj;function Vyj(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,a=0,u;return t=t!==void 0?t:1e3,function(d){let c=Date.now(),o=n[a];u||(u=c),r[i]=d,n[i]=c;let l=a,m=0;for(;l!==i;)m+=r[l++],l=l%e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-u<t)return;let O=o&&c-o;return O?Math.round(m*1e3/O):void 0}}var Bdf=Vyj;function Wyj(e,t){let r=0,n=1e3/t,i,a,u=(c,o=Date.now())=>{r=o,i=null,a&&(clearTimeout(a),a=null),e.apply(null,c)};return[(...c)=>{let o=Date.now(),l=o-r;l>=n?u(c,o):(i=c,a||(a=setTimeout(()=>{a=null,u(i)},n-l)))},()=>i&&u(i)]}var Idf=Wyj;var FDr=(e,t,r=3)=>{let n=0,i=Bdf(50,250);return Idf(a=>{let u=a.loaded,f=a.lengthComputable?a.total:void 0,d=u-n,c=i(d),o=u<=f;n=u;let l={loaded:u,total:f,progress:f?u/f:void 0,bytes:d,rate:c||void 0,estimated:c&&f&&o?(f-u)/c:void 0,event:a,lengthComputable:f!=null,[t?"download":"upload"]:!0};e(l)},r)},LBn=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},UBn=e=>(...t)=>Ol.asap(()=>e(...t));var zdf={flush:RDr.default.constants.Z_SYNC_FLUSH,finishFlush:RDr.default.constants.Z_SYNC_FLUSH},Hyj={flush:RDr.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:RDr.default.constants.BROTLI_OPERATION_FLUSH},Ndf=Ol.isFunction(RDr.default.createBrotliDecompress),{http:Jyj,https:Qyj}=Jdf.default,Gyj=/https:?/,Fdf=_2.protocols.map(e=>e+":"),Rdf=(e,[t,r])=>(e.on("end",r).on("error",r),t);function $yj(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function Gdf(e,t,r){let n=t;if(!n&&n!==!1){let i=(0,Udf.getProxyForUrl)(r);i&&(n=new URL(i))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){(n.auth.username||n.auth.password)&&(n.auth=(n.auth.username||"")+":"+(n.auth.password||""));let a=Buffer.from(n.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let i=n.hostname||n.host;e.hostname=i,e.host=i,e.port=n.port,e.path=r,n.protocol&&(e.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}e.beforeRedirects.proxy=function(a){Gdf(a,t,a.href)}}var Kyj=typeof process<"u"&&Ol.kindOf(process)==="process",Yyj=e=>new Promise((t,r)=>{let n,i,a=(d,c)=>{i||(i=!0,n&&n(d,c))},u=d=>{a(d),t(d)},f=d=>{a(d,!0),r(d)};e(u,f,d=>n=d).catch(f)}),Xyj=({address:e,family:t})=>{if(!Ol.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},Ldf=(e,t)=>Xyj(Ol.isObject(e)?e:{address:e,family:t}),$df=Kyj&&function(t){return Yyj(async function(n,i,a){let{data:u,lookup:f,family:d}=t,{responseType:c,responseEncoding:o}=t,l=t.method.toUpperCase(),m,O=!1,j;if(f){let cr=Cdf(f,Wr=>Ol.isArray(Wr)?Wr:[Wr]);f=(Wr,gn,Kt)=>{cr(Wr,gn,(Mr,Mn,ar)=>{if(Mr)return Kt(Mr);let mn=Ol.isArray(Mn)?Mn.map(On=>Ldf(On)):[Ldf(Mn,ar)];gn.all?Kt(Mr,mn):Kt(Mr,mn[0].address,mn[0].family)})}}let A=new Qdf.EventEmitter,T=()=>{t.cancelToken&&t.cancelToken.unsubscribe(B),t.signal&&t.signal.removeEventListener("abort",B),A.removeAllListeners()};a((cr,Wr)=>{m=!0,Wr&&(O=!0,T())});function B(cr){A.emit("abort",!cr||cr.type?new _we(null,t,j):cr)}A.once("abort",i),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(B),t.signal&&(t.signal.aborted?B():t.signal.addEventListener("abort",B)));let F=vkr(t.baseURL,t.url),C=new URL(F,_2.hasBrowserEnv?_2.origin:void 0),N=C.protocol||Fdf[0];if(N==="data:"){let cr;if(l!=="GET")return kRt(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{cr=blu(t.url,c==="blob",{Blob:t.env&&t.env.Blob})}catch(Wr){throw sy.from(Wr,sy.ERR_BAD_REQUEST,t)}return c==="text"?(cr=cr.toString(o),(!o||o==="utf8")&&(cr=Ol.stripBOM(cr))):c==="stream"&&(cr=gkr.default.Readable.from(cr)),kRt(n,i,{data:cr,status:200,statusText:"OK",headers:new vz,config:t})}if(Fdf.indexOf(N)===-1)return i(new sy("Unsupported protocol "+N,sy.ERR_BAD_REQUEST,t));let U=vz.from(t.headers).normalize();U.set("User-Agent","axios/"+bkr,!1);let{onUploadProgress:ne,onDownloadProgress:ge}=t,X=t.maxRate,k,xe;if(Ol.isSpecCompliantForm(u)){let cr=U.getContentType(/boundary=([-_\w\d]{10,70})/i);u=Tdf(u,Wr=>{U.set(Wr)},{tag:`axios-${bkr}-boundary`,boundary:cr&&cr[1]||void 0})}else if(Ol.isFormData(u)&&Ol.isFunction(u.getHeaders)){if(U.set(u.getHeaders()),!U.hasContentLength())try{let cr=await Hdf.default.promisify(u.getLength).call(u);Number.isFinite(cr)&&cr>=0&&U.setContentLength(cr)}catch{}}else if(Ol.isBlob(u))u.size&&U.setContentType(u.type||"application/octet-stream"),U.setContentLength(u.size||0),u=gkr.default.Readable.from(uya(u));else if(u&&!Ol.isStream(u)){if(!Buffer.isBuffer(u))if(Ol.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(Ol.isString(u))u=Buffer.from(u,"utf-8");else return i(new sy("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",sy.ERR_BAD_REQUEST,t));if(U.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return i(new sy("Request body larger than maxBodyLength limit",sy.ERR_BAD_REQUEST,t))}let vt=Ol.toFiniteNumber(U.getContentLength());Ol.isArray(X)?(k=X[0],xe=X[1]):k=xe=X,u&&(ne||k)&&(Ol.isStream(u)||(u=gkr.default.Readable.from(u,{objectMode:!1})),u=gkr.default.pipeline([u,new Olu({maxRate:Ol.toFiniteNumber(k)})],Ol.noop),ne&&u.on("progress",Rdf(u,LBn(vt,FDr(UBn(ne),!1,3)))));let yt;if(t.auth){let cr=t.auth.username||"",Wr=t.auth.password||"";yt=cr+":"+Wr}if(!yt&&C.username){let cr=C.username,Wr=C.password;yt=cr+":"+Wr}yt&&U.delete("authorization");let St;try{St=ykr(C.pathname+C.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(cr){let Wr=new Error(cr.message);return Wr.config=t,Wr.url=t.url,Wr.exists=!0,i(Wr)}U.set("Accept-Encoding","gzip, compress, deflate"+(Ndf?", br":""),!1);let Ft={path:St,method:l,headers:U.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:yt,protocol:N,family:d,beforeRedirect:$yj,beforeRedirects:{}};!Ol.isUndefined(f)&&(Ft.lookup=f),t.socketPath?Ft.socketPath=t.socketPath:(Ft.hostname=C.hostname.startsWith("[")?C.hostname.slice(1,-1):C.hostname,Ft.port=C.port,Gdf(Ft,t.proxy,N+"//"+C.hostname+(C.port?":"+C.port:"")+Ft.path));let Zt,Vt=Gyj.test(Ft.protocol);if(Ft.agent=Vt?t.httpsAgent:t.httpAgent,t.transport?Zt=t.transport:t.maxRedirects===0?Zt=Vt?Wdf.default:Vdf.default:(t.maxRedirects&&(Ft.maxRedirects=t.maxRedirects),t.beforeRedirect&&(Ft.beforeRedirects.config=t.beforeRedirect),Zt=Vt?Qyj:Jyj),t.maxBodyLength>-1?Ft.maxBodyLength=t.maxBodyLength:Ft.maxBodyLength=1/0,t.insecureHTTPParser&&(Ft.insecureHTTPParser=t.insecureHTTPParser),j=Zt.request(Ft,function(Wr){if(j.destroyed)return;let gn=[Wr],Kt=+Wr.headers["content-length"];if(ge||xe){let On=new Olu({maxRate:Ol.toFiniteNumber(xe)});ge&&On.on("progress",Rdf(On,LBn(Kt,FDr(UBn(ge),!0,3)))),gn.push(On)}let Mr=Wr,Mn=Wr.req||j;if(t.decompress!==!1&&Wr.headers["content-encoding"])switch((l==="HEAD"||Wr.statusCode===204)&&delete Wr.headers["content-encoding"],(Wr.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":gn.push(RDr.default.createUnzip(zdf)),delete Wr.headers["content-encoding"];break;case"deflate":gn.push(new qdf),gn.push(RDr.default.createUnzip(zdf)),delete Wr.headers["content-encoding"];break;case"br":Ndf&&(gn.push(RDr.default.createBrotliDecompress(Hyj)),delete Wr.headers["content-encoding"])}Mr=gn.length>1?gkr.default.pipeline(gn,Ol.noop):gn[0];let ar=gkr.default.finished(Mr,()=>{ar(),T()}),mn={status:Wr.statusCode,statusText:Wr.statusMessage,headers:new vz(Wr.headers),config:t,request:Mn};if(c==="stream")mn.data=Mr,kRt(n,i,mn);else{let On=[],Ut=0;Mr.on("data",function(Yr){On.push(Yr),Ut+=Yr.length,t.maxContentLength>-1&&Ut>t.maxContentLength&&(O=!0,Mr.destroy(),i(new sy("maxContentLength size of "+t.maxContentLength+" exceeded",sy.ERR_BAD_RESPONSE,t,Mn)))}),Mr.on("aborted",function(){if(O)return;let Yr=new sy("maxContentLength size of "+t.maxContentLength+" exceeded",sy.ERR_BAD_RESPONSE,t,Mn);Mr.destroy(Yr),i(Yr)}),Mr.on("error",function(Yr){j.destroyed||i(sy.from(Yr,null,t,Mn))}),Mr.on("end",function(){try{let Yr=On.length===1?On[0]:Buffer.concat(On);c!=="arraybuffer"&&(Yr=Yr.toString(o),(!o||o==="utf8")&&(Yr=Ol.stripBOM(Yr))),mn.data=Yr}catch(Yr){return i(sy.from(Yr,null,t,mn.request,mn))}kRt(n,i,mn)})}A.once("abort",On=>{Mr.destroyed||(Mr.emit("error",On),Mr.destroy())})}),A.once("abort",cr=>{i(cr),j.destroy(cr)}),j.on("error",function(Wr){i(sy.from(Wr,null,t,j))}),j.on("socket",function(Wr){Wr.setKeepAlive(!0,1e3*60)}),t.timeout){let cr=parseInt(t.timeout,10);if(Number.isNaN(cr)){i(new sy("error trying to parse `config.timeout` to int",sy.ERR_BAD_OPTION_VALUE,t,j));return}j.setTimeout(cr,function(){if(m)return;let gn=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",Kt=t.transitional||NBn;t.timeoutErrorMessage&&(gn=t.timeoutErrorMessage),i(new sy(gn,Kt.clarifyTimeoutError?sy.ETIMEDOUT:sy.ECONNABORTED,t,j)),B()})}if(Ol.isStream(u)){let cr=!1,Wr=!1;u.on("end",()=>{cr=!0}),u.once("error",gn=>{Wr=!0,j.destroy(gn)}),u.on("close",()=>{!cr&&!Wr&&B(new _we("Request stream has been aborted",t,j))}),u.pipe(j)}else j.end(u)})};var Kdf=_2.hasStandardBrowserEnv?function(){let t=_2.navigator&&/(msie|trident)/i.test(_2.navigator.userAgent),r=document.createElement("a"),n;function i(a){let u=a;return t&&(r.setAttribute("href",u),u=r.href),r.setAttribute("href",u),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=i(window.location.href),function(u){let f=Ol.isString(u)?i(u):u;return f.protocol===n.protocol&&f.host===n.host}}():function(){return function(){return!0}}();var Ydf=_2.hasStandardBrowserEnv?{write(e,t,r,n,i,a){let u=[e+"="+encodeURIComponent(t)];Ol.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),Ol.isString(n)&&u.push("path="+n),Ol.isString(i)&&u.push("domain="+i),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 Xdf=e=>e instanceof vz?{...e}:e;function r2t(e,t){t=t||{};let r={};function n(c,o,l){return Ol.isPlainObject(c)&&Ol.isPlainObject(o)?Ol.merge.call({caseless:l},c,o):Ol.isPlainObject(o)?Ol.merge({},o):Ol.isArray(o)?o.slice():o}function i(c,o,l){if(Ol.isUndefined(o)){if(!Ol.isUndefined(c))return n(void 0,c,l)}else return n(c,o,l)}function a(c,o){if(!Ol.isUndefined(o))return n(void 0,o)}function u(c,o){if(Ol.isUndefined(o)){if(!Ol.isUndefined(c))return n(void 0,c)}else return n(void 0,o)}function f(c,o,l){if(l in t)return n(c,o);if(l in e)return n(void 0,c)}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:f,headers:(c,o)=>i(Xdf(c),Xdf(o),!0)};return Ol.forEach(Object.keys(Object.assign({},e,t)),function(o){let l=d[o]||i,m=l(e[o],t[o],o);Ol.isUndefined(m)&&l!==f||(r[o]=m)}),r}var sya=e=>{let t=r2t({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:u,auth:f}=t;t.headers=u=vz.from(u),t.url=ykr(vkr(t.baseURL,t.url),e.params,e.paramsSerializer),f&&u.set("Authorization","Basic "+btoa((f.username||"")+":"+(f.password?unescape(encodeURIComponent(f.password)):"")));let d;if(Ol.isFormData(r)){if(_2.hasStandardBrowserEnv||_2.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((d=u.getContentType())!==!1){let[c,...o]=d?d.split(";").map(l=>l.trim()).filter(Boolean):[];u.setContentType([c||"multipart/form-data",...o].join("; "))}}if(_2.hasStandardBrowserEnv&&(n&&Ol.isFunction(n)&&(n=n(t)),n||n!==!1&&Kdf(t.url))){let c=i&&a&&Ydf.read(a);c&&u.set(i,c)}return t};var Zyj=typeof XMLHttpRequest<"u",Zdf=Zyj&&function(e){return new Promise(function(r,n){let i=sya(e),a=i.data,u=vz.from(i.headers).normalize(),{responseType:f,onUploadProgress:d,onDownloadProgress:c}=i,o,l,m,O,j;function A(){O&&O(),j&&j(),i.cancelToken&&i.cancelToken.unsubscribe(o),i.signal&&i.signal.removeEventListener("abort",o)}let T=new XMLHttpRequest;T.open(i.method.toUpperCase(),i.url,!0),T.timeout=i.timeout;function B(){if(!T)return;let C=vz.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),U={data:!f||f==="text"||f==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:C,config:e,request:T};kRt(function(ge){r(ge),A()},function(ge){n(ge),A()},U),T=null}"onloadend"in T?T.onloadend=B:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(B)},T.onabort=function(){T&&(n(new sy("Request aborted",sy.ECONNABORTED,e,T)),T=null)},T.onerror=function(){n(new sy("Network Error",sy.ERR_NETWORK,e,T)),T=null},T.ontimeout=function(){let N=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",U=i.transitional||NBn;i.timeoutErrorMessage&&(N=i.timeoutErrorMessage),n(new sy(N,U.clarifyTimeoutError?sy.ETIMEDOUT:sy.ECONNABORTED,e,T)),T=null},a===void 0&&u.setContentType(null),"setRequestHeader"in T&&Ol.forEach(u.toJSON(),function(N,U){T.setRequestHeader(U,N)}),Ol.isUndefined(i.withCredentials)||(T.withCredentials=!!i.withCredentials),f&&f!=="json"&&(T.responseType=i.responseType),c&&([m,j]=FDr(c,!0),T.addEventListener("progress",m)),d&&T.upload&&([l,O]=FDr(d),T.upload.addEventListener("progress",l),T.upload.addEventListener("loadend",O)),(i.cancelToken||i.signal)&&(o=C=>{T&&(n(!C||C.type?new _we(null,e,T):C),T.abort(),T=null)},i.cancelToken&&i.cancelToken.subscribe(o),i.signal&&(i.signal.aborted?o():i.signal.addEventListener("abort",o)));let F=a_i(i.url);if(F&&_2.protocols.indexOf(F)===-1){n(new sy("Unsupported protocol "+F+":",sy.ERR_BAD_REQUEST,e));return}T.send(a||null)})};var kyj=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,a=function(c){if(!i){i=!0,f();let o=c instanceof Error?c:this.reason;n.abort(o instanceof sy?o:new _we(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new sy(`timeout ${t} of ms exceeded`,sy.ETIMEDOUT))},t),f=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(a):c.removeEventListener("abort",a)}),e=null)};e.forEach(c=>c.addEventListener("abort",a));let{signal:d}=n;return d.unsubscribe=()=>Ol.asap(f),d}},kdf=kyj;var evj=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},tvj=async function*(e,t){for await(let r of rvj(e))yield*evj(r,t)},rvj=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},wlu=(e,t,r,n)=>{let i=tvj(e,t),a=0,u,f=d=>{u||(u=!0,n&&n(d))};return new ReadableStream({async pull(d){try{let{done:c,value:o}=await i.next();if(c){f(),d.close();return}let l=o.byteLength;if(r){let m=a+=l;r(m)}d.enqueue(new Uint8Array(o))}catch(c){throw f(c),c}},cancel(d){return f(d),i.return()}},{highWaterMark:2})};var lya=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",tpf=lya&&typeof ReadableStream=="function",nvj=lya&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),rpf=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ivj=tpf&&rpf(()=>{let e=!1,t=new Request(_2.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),epf=64*1024,Dlu=tpf&&rpf(()=>Ol.isReadableStream(new Response("").body)),cya={stream:Dlu&&(e=>e.body)};lya&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!cya[t]&&(cya[t]=Ol.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new sy(`Response type '${t}' is not supported`,sy.ERR_NOT_SUPPORT,n)})})})(new Response);var avj=async e=>{if(e==null)return 0;if(Ol.isBlob(e))return e.size;if(Ol.isSpecCompliantForm(e))return(await new Request(_2.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(Ol.isArrayBufferView(e)||Ol.isArrayBuffer(e))return e.byteLength;if(Ol.isURLSearchParams(e)&&(e=e+""),Ol.isString(e))return(await nvj(e)).byteLength},ovj=async(e,t)=>{let r=Ol.toFiniteNumber(e.getContentLength());return r??avj(t)},npf=lya&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:a,timeout:u,onDownloadProgress:f,onUploadProgress:d,responseType:c,headers:o,withCredentials:l="same-origin",fetchOptions:m}=sya(e);c=c?(c+"").toLowerCase():"text";let O=kdf([i,a&&a.toAbortSignal()],u),j,A=O&&O.unsubscribe&&(()=>{O.unsubscribe()}),T;try{if(d&&ivj&&r!=="get"&&r!=="head"&&(T=await ovj(o,n))!==0){let U=new Request(t,{method:"POST",body:n,duplex:"half"}),ne;if(Ol.isFormData(n)&&(ne=U.headers.get("content-type"))&&o.setContentType(ne),U.body){let[ge,X]=LBn(T,FDr(UBn(d)));n=wlu(U.body,epf,ge,X)}}Ol.isString(l)||(l=l?"include":"omit");let B="credentials"in Request.prototype;j=new Request(t,{...m,signal:O,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:n,duplex:"half",credentials:B?l:void 0});let F=await fetch(j),C=Dlu&&(c==="stream"||c==="response");if(Dlu&&(f||C&&A)){let U={};["status","statusText","headers"].forEach(k=>{U[k]=F[k]});let ne=Ol.toFiniteNumber(F.headers.get("content-length")),[ge,X]=f&&LBn(ne,FDr(UBn(f),!0))||[];F=new Response(wlu(F.body,epf,ge,()=>{X&&X(),A&&A()}),U)}c=c||"text";let N=await cya[Ol.findKey(cya,c)||"text"](F,e);return!C&&A&&A(),await new Promise((U,ne)=>{kRt(U,ne,{data:N,headers:vz.from(F.headers),status:F.status,statusText:F.statusText,config:e,request:j})})}catch(B){throw A&&A(),B&&B.name==="TypeError"&&/fetch/i.test(B.message)?Object.assign(new sy("Network Error",sy.ERR_NETWORK,e,j),{cause:B.cause||B}):sy.from(B,B&&B.code,e,j)}});var Slu={http:$df,xhr:Zdf,fetch:npf};Ol.forEach(Slu,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var ipf=e=>`- ${e}`,uvj=e=>Ol.isFunction(e)||e===null||e===!1,fya={getAdapter:e=>{e=Ol.isArray(e)?e:[e];let{length:t}=e,r,n,i={};for(let a=0;a<t;a++){r=e[a];let u;if(n=r,!uvj(r)&&(n=Slu[(u=String(r)).toLowerCase()],n===void 0))throw new sy(`Unknown adapter '${u}'`);if(n)break;i[u||"#"+a]=n}if(!n){let a=Object.entries(i).map(([f,d])=>`adapter ${f} `+(d===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
|
|
@@ -1908,7 +1908,7 @@ errors:
|
|
|
1908
1908
|
Run ${qc.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
|
|
1909
1909
|
Run ${qc.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),WBn(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function Dpu({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!W0f(e))return;let i=t??"",a=e.filter(f=>f.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((f,d)=>f.generatorName.localeCompare(d.generatorName)||f.currentVersion.localeCompare(d.currentVersion));for(let f of u)i+=`
|
|
1910
1910
|
${await SDj(f.generatorName)} (${f.apiName!=null?"API: "+f.apiName+", ":""}Group: ${f.generatorGroup}) `+qc.dim(f.currentVersion)+qc.reset(" \u2192 ")+qc.green(f.latestVersion);return i+=`
|
|
1911
|
-
`,n?WBn(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function SDj(e){let r=await new V0f.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 EDj({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await J0f({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,c,o,l)=>{f.versions[c]==null&&(f.versions[c]={});let m=yO.getGeneratorNameOrThrow(o.name,l),O=await yO.getLatestGeneratorVersion({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});O!=null&&(f.versions[c][o.name]={previousVersion:o.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),f}let u={type:"multiApi",versions:{}};return await J0f({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,d,c,o)=>{if(f==null)return;u.versions[f]==null&&(u.versions[f]={}),u.versions[f][d]==null&&(u.versions[f][d]={});let l=yO.getGeneratorNameOrThrow(c.name,o),m=await yO.getLatestGeneratorVersion({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:a,context:o});m!=null&&(u.versions[f][d][c.name]={previousVersion:c.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),u}async function J0f({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let f=await yO.loadGeneratorsConfiguration({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(f==null||f.groups==null)){for(let d of f.groups)if(!(i!=null&&d.groupName!==i))for(let c of d.generators)n!=null&&c.name!==n||await r(a.workspaceName,d.groupName,c,u)}})}))}function Q0f(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,f]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let d=gne(f.latestVersion,f.previousVersion);r.debug(`Latest version: ${f.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:f.previousVersion,latestVersion:f.latestVersion})}return n}async function Ova({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await EDj({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(f.type==="multiApi")for(let[d,c]of Object.entries(f.versions))u.push(...Q0f(c,d,t.logger));else u.push(...Q0f(f.versions,void 0,t.logger))}return u}var J_i=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${i} ${a}`.trim(),f=u?`status code ${u}`:"an unknown error";super(`Request failed with ${f}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var vIn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var bIn=e=>e!==null&&typeof e=="object";var Q_i=(...e)=>{for(let t of e)if((!bIn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Apu({},...e)},Spu=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,u]of i.entries())n&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function Pva(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Apu(e[r]??[],t[r]??[])}var Epu=(e={},t={})=>({beforeRequest:Pva(e,t,"beforeRequest"),beforeRetry:Pva(e,t,"beforeRetry"),afterResponse:Pva(e,t,"afterResponse"),beforeError:Pva(e,t,"beforeError")}),Apu=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(bIn(i)){for(let[a,u]of Object.entries(i))bIn(u)&&a in t&&(u=Apu(t[a],u)),t={...t,[a]:u};bIn(i.hooks)&&(n=Epu(n,i.hooks),t.hooks=n),bIn(i.headers)&&(r=Spu(r,i.headers),t.headers=r)}return t};var G0f=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)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(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),$0f=typeof globalThis.AbortController=="function",K0f=typeof globalThis.ReadableStream=="function",Y0f=typeof globalThis.FormData=="function",jva=["get","post","put","patch","head","delete"],ADj=()=>{};ADj();var X0f={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},wva=2147483647,Dva=Symbol("stop"),Z0f={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},k0f={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 tbf=e=>jva.includes(e)?e.toUpperCase():e,MDj=["get","put","head","delete","options","trace"],TDj=[408,413,429,500,502,503,504],xDj=[413,429,503],ebf={limit:2,methods:MDj,statusCodes:TDj,afterStatusCodes:xDj,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},rbf=(e={})=>{if(typeof e=="number")return{...ebf,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{...ebf,...e}};async function Mpu(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new vIn(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function Tpu(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var nbf=(e,t)=>{let r={};for(let n in t)!(n in k0f)&&!(n in Z0f)&&!(n in e)&&(r[n]=t[n]);return r};var G_i=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>wva)throw new RangeError(`The \`timeout\` option cannot be greater than ${wva}`);await Promise.resolve();let f=await n._fetch();for(let d of n._options.hooks.afterResponse){let c=await d(n.request,n._options,n._decorateResponse(f.clone()));c instanceof globalThis.Response&&(f=c)}if(n._decorateResponse(f),!f.ok&&n._options.throwHttpErrors){let d=new J_i(f,n.request,n._options);for(let c of n._options.hooks.beforeError)d=await c(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!K0f)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(f.clone(),n._options.onDownloadProgress)}return f},u=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[f,d]of Object.entries(X0f))u[f]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let o=(await u).clone();if(f==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[f]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Spu(this._input.headers,r.headers),hooks:Epu({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:tbf(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:rbf(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($0f){this.abortController=new globalThis.AbortController;let n=this._options.signal??this._input.signal;n?.addEventListener("abort",()=>{this.abortController.abort(n.reason)}),this._options.signal=this.abortController.signal}if(G0f&&(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 i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(Y0f&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof vIn)throw t;if(t instanceof J_i){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=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(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i: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 n=Math.min(this._calculateRetryDelay(r),wva);if(this._retryCount<1)throw r;await Tpu(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===Dva)return;return this._retry(t)}}async _fetch(){for(let n of this._options.hooks.beforeRequest){let i=await n(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=nbf(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):Mpu(r,t,this.abortController,this._options)}_stream(t,r){let n=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function f(){let{done:d,value:c}=await u.read();if(d){a.close();return}if(r){i+=c.byteLength;let o=n===0?0:i/n;r({percent:o,transferredBytes:i,totalBytes:n},c)}a.enqueue(c),await f()}await f()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var xpu=e=>{let t=(r,n)=>G_i.create(r,Q_i(e,n));for(let r of jva)t[r]=(n,i)=>G_i.create(n,Q_i(e,i,{method:r}));return t.create=r=>xpu(Q_i(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),xpu(Q_i(e,r))),t.stop=Dva,t},qDj=xpu(),ibf=qDj;var Ebf=Jo(Sbf(),1);function zpu(e){let t=(0,Ebf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var dOf=Jo(mgf(),1),pOf=Jo(fOf(),1),__u=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},h_u=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function y_u(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??zpu(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,dOf.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,f&&(d.authorization=`${f.type} ${f.token}`);let c;try{c=await ibf(u,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new __u(e):l}if(t.allVersions)return c;let o=new h_u(e,r);if(c["dist-tags"][r]){let{time:l}=c;c=c.versions[c["dist-tags"][r]],c.time=l}else if(r){let l=!!c.versions[r];if(n&&!l)for(let[O,j]of Object.entries(c.versions))j.deprecated&&delete c.versions[O];if(!l){let O=Object.keys(c.versions);if(r=pOf.default.maxSatisfying(O,r),!r)throw o}let{time:m}=c;if(c=c.versions[r],c.time=m,!c)throw o}return c}async function ohi(e,t){let{version:r}=await y_u(e.toLowerCase(),t);return r}async function EIn({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:ohi(e.packageName,{version:t?"prerelease":"latest"})}var _Of=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Gva=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=tA.Info;constructor(t){this.ttyAwareLogger=new mva(t);let r=this.getPackageName(),n=this.getPackageVersion(),i=this.getCliName();(r==null||n==null||i==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:n,cliName:i}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.45.0-rc46"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${qc.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new ZAe}failWithoutThrowing(t,r){this.didSucceed=!1,yva({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),await(await BBn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await H0f({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1911
|
+
`,n?WBn(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function SDj(e){let r=await new V0f.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 EDj({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await J0f({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,c,o,l)=>{f.versions[c]==null&&(f.versions[c]={});let m=yO.getGeneratorNameOrThrow(o.name,l),O=await yO.getLatestGeneratorVersion({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});O!=null&&(f.versions[c][o.name]={previousVersion:o.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),f}let u={type:"multiApi",versions:{}};return await J0f({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,d,c,o)=>{if(f==null)return;u.versions[f]==null&&(u.versions[f]={}),u.versions[f][d]==null&&(u.versions[f][d]={});let l=yO.getGeneratorNameOrThrow(c.name,o),m=await yO.getLatestGeneratorVersion({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:a,context:o});m!=null&&(u.versions[f][d][c.name]={previousVersion:c.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),u}async function J0f({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let f=await yO.loadGeneratorsConfiguration({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(f==null||f.groups==null)){for(let d of f.groups)if(!(i!=null&&d.groupName!==i))for(let c of d.generators)n!=null&&c.name!==n||await r(a.workspaceName,d.groupName,c,u)}})}))}function Q0f(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,f]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let d=gne(f.latestVersion,f.previousVersion);r.debug(`Latest version: ${f.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:f.previousVersion,latestVersion:f.latestVersion})}return n}async function Ova({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await EDj({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(f.type==="multiApi")for(let[d,c]of Object.entries(f.versions))u.push(...Q0f(c,d,t.logger));else u.push(...Q0f(f.versions,void 0,t.logger))}return u}var J_i=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${i} ${a}`.trim(),f=u?`status code ${u}`:"an unknown error";super(`Request failed with ${f}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var vIn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var bIn=e=>e!==null&&typeof e=="object";var Q_i=(...e)=>{for(let t of e)if((!bIn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Apu({},...e)},Spu=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,u]of i.entries())n&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function Pva(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Apu(e[r]??[],t[r]??[])}var Epu=(e={},t={})=>({beforeRequest:Pva(e,t,"beforeRequest"),beforeRetry:Pva(e,t,"beforeRetry"),afterResponse:Pva(e,t,"afterResponse"),beforeError:Pva(e,t,"beforeError")}),Apu=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(bIn(i)){for(let[a,u]of Object.entries(i))bIn(u)&&a in t&&(u=Apu(t[a],u)),t={...t,[a]:u};bIn(i.hooks)&&(n=Epu(n,i.hooks),t.hooks=n),bIn(i.headers)&&(r=Spu(r,i.headers),t.headers=r)}return t};var G0f=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)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(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),$0f=typeof globalThis.AbortController=="function",K0f=typeof globalThis.ReadableStream=="function",Y0f=typeof globalThis.FormData=="function",jva=["get","post","put","patch","head","delete"],ADj=()=>{};ADj();var X0f={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},wva=2147483647,Dva=Symbol("stop"),Z0f={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},k0f={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 tbf=e=>jva.includes(e)?e.toUpperCase():e,MDj=["get","put","head","delete","options","trace"],TDj=[408,413,429,500,502,503,504],xDj=[413,429,503],ebf={limit:2,methods:MDj,statusCodes:TDj,afterStatusCodes:xDj,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},rbf=(e={})=>{if(typeof e=="number")return{...ebf,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{...ebf,...e}};async function Mpu(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new vIn(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function Tpu(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var nbf=(e,t)=>{let r={};for(let n in t)!(n in k0f)&&!(n in Z0f)&&!(n in e)&&(r[n]=t[n]);return r};var G_i=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>wva)throw new RangeError(`The \`timeout\` option cannot be greater than ${wva}`);await Promise.resolve();let f=await n._fetch();for(let d of n._options.hooks.afterResponse){let c=await d(n.request,n._options,n._decorateResponse(f.clone()));c instanceof globalThis.Response&&(f=c)}if(n._decorateResponse(f),!f.ok&&n._options.throwHttpErrors){let d=new J_i(f,n.request,n._options);for(let c of n._options.hooks.beforeError)d=await c(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!K0f)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(f.clone(),n._options.onDownloadProgress)}return f},u=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[f,d]of Object.entries(X0f))u[f]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let o=(await u).clone();if(f==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[f]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Spu(this._input.headers,r.headers),hooks:Epu({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:tbf(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:rbf(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($0f){this.abortController=new globalThis.AbortController;let n=this._options.signal??this._input.signal;n?.addEventListener("abort",()=>{this.abortController.abort(n.reason)}),this._options.signal=this.abortController.signal}if(G0f&&(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 i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(Y0f&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof vIn)throw t;if(t instanceof J_i){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=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(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i: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 n=Math.min(this._calculateRetryDelay(r),wva);if(this._retryCount<1)throw r;await Tpu(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===Dva)return;return this._retry(t)}}async _fetch(){for(let n of this._options.hooks.beforeRequest){let i=await n(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=nbf(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):Mpu(r,t,this.abortController,this._options)}_stream(t,r){let n=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function f(){let{done:d,value:c}=await u.read();if(d){a.close();return}if(r){i+=c.byteLength;let o=n===0?0:i/n;r({percent:o,transferredBytes:i,totalBytes:n},c)}a.enqueue(c),await f()}await f()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var xpu=e=>{let t=(r,n)=>G_i.create(r,Q_i(e,n));for(let r of jva)t[r]=(n,i)=>G_i.create(n,Q_i(e,i,{method:r}));return t.create=r=>xpu(Q_i(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),xpu(Q_i(e,r))),t.stop=Dva,t},qDj=xpu(),ibf=qDj;var Ebf=Jo(Sbf(),1);function zpu(e){let t=(0,Ebf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var dOf=Jo(mgf(),1),pOf=Jo(fOf(),1),__u=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},h_u=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function y_u(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??zpu(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,dOf.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,f&&(d.authorization=`${f.type} ${f.token}`);let c;try{c=await ibf(u,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new __u(e):l}if(t.allVersions)return c;let o=new h_u(e,r);if(c["dist-tags"][r]){let{time:l}=c;c=c.versions[c["dist-tags"][r]],c.time=l}else if(r){let l=!!c.versions[r];if(n&&!l)for(let[O,j]of Object.entries(c.versions))j.deprecated&&delete c.versions[O];if(!l){let O=Object.keys(c.versions);if(r=pOf.default.maxSatisfying(O,r),!r)throw o}let{time:m}=c;if(c=c.versions[r],c.time=m,!c)throw o}return c}async function ohi(e,t){let{version:r}=await y_u(e.toLowerCase(),t);return r}async function EIn({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:ohi(e.packageName,{version:t?"prerelease":"latest"})}var _Of=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Gva=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=tA.Info;constructor(t){this.ttyAwareLogger=new mva(t);let r=this.getPackageName(),n=this.getPackageVersion(),i=this.getCliName();(r==null||n==null||i==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:n,cliName:i}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.45.0-rc47"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${qc.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new ZAe}failWithoutThrowing(t,r){this.didSucceed=!1,yva({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),await(await BBn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await H0f({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1912
1912
|
`)||(r+=`
|
|
1913
1913
|
`),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=oUo(t.map(n=>n.type==="docs"?"docs":n.workspaceName??"api"),n=>n.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new F_i(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 n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(a){throw a.message.includes("globalThis")?(n.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),n.failWithoutThrowing()):n.failWithoutThrowing(void 0,a),new ZAe}finally{n.finish()}return i}async instrumentPostHogEvent(t){(await BBn()).sendEvent(t)}logger=oci(this.log.bind(this));constructTaskInitForWorkspace(t){let r=hOf(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?hOf(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=_Of[this.numTasks++%_Of.length],u=qc.hex(a)(i);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===_7.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logImmediately(t){let r=t.filter(n=>qIr.indexOf(n.level)>=qIr.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===tA.Debug})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await EIn({cliEnvironment:this.environment,includePreReleases:t}),n=gne(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await Ova({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}};function hOf(e){return`[${e}]:`}var WPf=Jo(VPf(),1);async function kQ(e,t,r=[],{doNotPipeOutput:n=!1,secrets:i=[],substitutions:a={},...u}={}){let f=i.reduce((o,l)=>({...o,[l]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[o,l]of Object.entries(f))d=d.replaceAll(o,l);e?.debug(`+ ${d}`);let c=(0,WPf.default)(t,r,u);return n||(c.stdout?.pipe(process.stdout),c.stderr?.pipe(process.stderr)),c}function t0a(e,{logger:t,...r}={}){return(n,i)=>kQ(t,e,n,{...r,...i})}var n0a=require("fs/promises"),HPf=Jo(Qte(),1),jxj="buf.gen.yaml",JPf="output",wxj=`${JPf}/openapi.yaml`,Dxj=`
|
|
1914
1914
|
version: v1
|
|
@@ -1920,7 +1920,7 @@ plugins:
|
|
|
1920
1920
|
- enum_type=string
|
|
1921
1921
|
- default_response=false
|
|
1922
1922
|
`,r0a=class{context;constructor({context:t}){this.context=t}async generate({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,local:n}){return n?this.generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r}):this.generateRemote()}async generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r}){let n=await this.setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t}),i=mC(t,r);return this.doGenerateLocal({cwd:n,target:i})}async setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t}){let r=Hp.of((await HPf.default.dir()).path);return await(0,n0a.cp)(t,r,{recursive:!0}),await(0,n0a.writeFile)(Wl(r,ls.of(jxj)),Dxj),r}async doGenerateLocal({cwd:t,target:r}){let n=t0a("which",{cwd:t,logger:this.context.logger});try{await n(["buf"])}catch{this.context.failAndThrow("Missing required dependency; please install 'buf' to continue (e.g. 'brew install buf').")}try{await n(["protoc-gen-openapi"])}catch{this.context.failAndThrow("Missing required dependency; please install 'protoc-gen-openapi' to continue (e.g. 'brew install go && go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest').")}let i=t0a("buf",{cwd:t,logger:this.context.logger});return await i(["config","init"]),await i(["generate",r]),Wl(t,ls.of(wxj))}async generateRemote(){this.context.failAndThrow("Remote Protobuf generation is unimplemented.")}};async function Gkr({context:e,specs:t,relativePathToDependency:r}){let n=new r0a({context:e}),i=t.filter(f=>f.type==="openapi").map(f=>({...f,relativePathToDependency:r})),a=t.filter(f=>f.type==="protobuf"),u=await Promise.all(a.map(async f=>Sxj({generator:n,protobufSpec:f,relativePathToDependency:r})));return[...i,...u]}async function Sxj({generator:e,protobufSpec:t,relativePathToDependency:r}){return{type:"openapi",absoluteFilepath:await e.generate({absoluteFilepathToProtobufRoot:t.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:t.absoluteFilepathToProtobufTarget,local:t.generateLocally}),absoluteFilepathToOverrides:t.absoluteFilepathToOverrides,settings:t.settings,source:{type:"protobuf",relativePathToDependency:r,root:t.absoluteFilepathToProtobufRoot,file:t.absoluteFilepathToProtobufTarget}}}var myu=Jo(tZr(),1);var W1f=require("fs"),r7n=require("fs/promises");var H1f=require("os"),J1f=Jo(require("path"),1),Q1f=require("stream/promises"),G1f=Jo(lba(),1),$1f=Jo(Qte(),1);var Iw;(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"})(Iw||(Iw={}));var r2j=dDr();async function K1f({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:n,cliVersion:i,settings:a,loadAPIWorkspace:u}){let f,d={type:Iw.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},c=t.dependencies[e];return c==null?d={type:Iw.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${c2j(c)}`},async o=>{switch(c.type){case"version":f=await u2j({context:o,dependency:c,cliVersion:i,settings:a,loadAPIWorkspace:u});return;case"local":f=await o2j({context:o,dependency:c,cliVersion:i,settings:a,loadAPIWorkspace:u});return;default:sc(c)}}),f!=null?{didSucceed:!0,definition:f}:{didSucceed:!1,failure:d}}var Y1f="dependencies";var n2j="metadata.json",i2j=".fern";function a2j(e){return Wl(Hp.of((0,H1f.homedir)()),ls.of(i2j),ls.of(Y1f),ls.of(e.organization),ls.of(e.apiName),ls.of(e.version))}async function o2j({dependency:e,context:t,cliVersion:r,settings:n,loadAPIWorkspace:i}){if(i==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await i({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!a.didSucceed){t.failWithoutThrowing("Failed to load api definition",a.failures);return}t.logger.info("Modifying source filepath ...");let u=await a.workspace.getDefinition({context:t,relativePathToDependency:ls.of(e.path)},n);return t.logger.info("Loaded..."),u}async function u2j({dependency:e,context:t,cliVersion:r,settings:n,loadAPIWorkspace:i}){let a=a2j(e),u=Wl(a,ls.of(Y1f)),f=Wl(a,ls.of(n2j)),d;if(!await _h(u)||!await _h(f)){t.logger.info("Downloading manifest...");let l=await r2j.definitionRegistry.get(myu.FernFiddle.OrganizationId(e.organization),myu.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:A=>{t.failWithoutThrowing("Failed to download API manifest",A)}});return}let m=l.body.yamlSchemaVersion!=null?parseInt(l.body.yamlSchemaVersion):void 0,O=Nkr(r),j=Nkr(l.body.cliVersion);if(m!=null){if(m>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(m<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(O.major!==j.major||O.minor!==j.minor){t.failWithoutThrowing(`CLI version is ${l.body.cliVersion}. Expected ${O.major}.${O.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+l.body.definitionS3DownloadUrl),await(0,r7n.mkdir)(u,{recursive:!0});try{await s2j({s3PreSignedReadUrl:l.body.definitionS3DownloadUrl,absolutePathToLocalOutput:u})}catch(A){t.failWithoutThrowing("Failed to download API",A);return}d=l.body,await(0,r7n.writeFile)(f,JSON.stringify(d))}else d=JSON.parse((await(0,r7n.readFile)(f)).toString());if(t.logger.info("Parsing..."),i==null){t.failWithoutThrowing("Failed to load API");return}let c=await i({absolutePathToWorkspace:u,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!c.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",c.failures);return}if(c.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await c.workspace.getDefinition({context:t},n)}async function s2j({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await YN.get(e,{responseType:"stream"}),n=await $1f.default.dir(),i=J1f.default.join(n.path,"api.tgz");await(0,Q1f.pipeline)(r.data,(0,W1f.createWriteStream)(i)),await(0,G1f.extract)({file:i,cwd:t})}function c2j(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:sc(e)}}var cDf=Jo(jyu(),1);function fba(e,t){for(let[r,n]of X6(e))f2j({relativeFilepath:r,failure:n,logger:t})}function f2j({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Iw.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 Iw.FILE_READ:r.error("Failed to open file: "+e);break;case Iw.FILE_MISSING:r.error("Missing file: "+e);break;case Iw.FILE_PARSE:t.error instanceof _ci?r.error(Kqt({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Iw.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of d2j(n))r.error(Kqt({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case Iw.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Iw.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${iQi}: `+t.dependencyName);break;case Iw.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Iw.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case Iw.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(Kqt({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(n=>n!=="")]}));break;default:sc(t)}}function d2j(e){switch(e.code){case Tp.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${qc.underline(e.expected)} but received ${qc.underline(e.received)}`}];case Tp.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${qc.underline(t)}`}));case Tp.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>qc.underline(t)).join(", ")}`}];case Tp.invalid_union:case Tp.invalid_arguments:case Tp.invalid_return_type:case Tp.invalid_date:case Tp.invalid_string:case Tp.too_small:case Tp.too_big:case Tp.invalid_intersection_types:case Tp.not_multiple_of:case Tp.custom:default:return[{title:e.message}]}}var rDf=require("fs/promises");async function nDf(e,t){let r=[];for(let n of await YAe(e,t))r.push(await p2j({relativeFilepath:mC(e,n),absoluteFilepath:n}));return r}async function p2j({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,rDf.readFile)(t)).toString()}}async function iDf(e){let t={},r={};function n(i){try{t[i.relativeFilepath]={defaultUrl:void 0,contents:Fy.load(i.fileContents,{schema:Fy.CORE_SCHEMA}),rawContents:i.fileContents}}catch(a){r[i.relativeFilepath]={type:Iw.FILE_PARSE,error:a}}}return await Promise.all(e.map(n)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}async function aDf({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:n,settings:i,loadAPIWorkspace:a}){let u={},f={},d={};return await Promise.all(X6(t.packageMarkers).map(async([c,o])=>{if(o.contents.export==null)u[c]=o;else{let{export:l,...m}=o.contents;if(P6t(m)>0)d[c]={type:Iw.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:c};else{let O=B0(c);if(h6t(t.namedDefinitionFiles).some(A=>A!==c&&A.startsWith(O)))d[c]={type:Iw.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:O};else{let A=await K1f({dependencyName:typeof o.contents.export=="string"?o.contents.export:o.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:n,settings:i,loadAPIWorkspace:a});A.didSucceed?f[B0(c)]={definition:A.definition,url:typeof o.contents.export=="object"?o.contents.export.url:void 0}:d[c]=A.failure}}}})),P6t(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:u,importedDefinitions:f}}var oDf=Jo(require("path"),1);var wyu={};Dc(wyu,{additionalProperties:()=>y2j,default:()=>b2j,definitions:()=>v2j,properties:()=>h2j,type:()=>_2j});var _2j="object",h2j={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"}]}},y2j=!1,v2j={"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.TypeReferenceDeclarationWithName":{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.TypeReferenceDeclarationWithNameSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDeclarationWithName"}]},"types.ObjectPropertySchema":{$ref:"#/definitions/types.TypeReferenceDeclarationWithNameSchema"},"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"}]},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"}]},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"}]},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"}]},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"}]},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"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithContentTypeSchema":{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"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithContentTypeSchema"}]},"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"}]},"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:{type:"string"},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},required:["type"],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.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"}]},"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"}]}},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:{type:"string"}},{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"},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}},b2j={type:_2j,properties:h2j,additionalProperties:y2j,definitions:v2j};var Dyu={};Dc(Dyu,{additionalProperties:()=>P2j,default:()=>w2j,definitions:()=>j2j,properties:()=>m2j,required:()=>O2j,type:()=>g2j});var g2j="object",m2j={docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},"default-url":{oneOf:[{type:"string"},{type:"null"}]},"default-environment":{oneOf:[{type:"string"},{type:"null"}]},environments:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/environments.EnvironmentSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/auth.ApiAuthSchema"},{type:"null"}]},"auth-schemes":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/auth.AuthSchemeDeclarationSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},name:{type:"string"},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},"error-discrimination":{oneOf:[{$ref:"#/definitions/file.ErrorDiscriminationSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},errors:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"idempotency-headers":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},variables:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/variables.VariableDeclarationSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"null"}]},version:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},O2j=["name"],P2j=!1,j2j={"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"}]},"get-token":{$ref:"#/definitions/auth.OAuthGetTokenEndpointSchema"},"refresh-token":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenEndpointSchema"},{type:"null"}]}},required:["scheme","type","get-token"],additionalProperties:!1},"auth.HeaderAuthSchemeSchema":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},header:{type:"string"},type:{oneOf:[{type:"string"},{type:"null"}]},prefix:{oneOf:[{type:"string"},{type:"null"}]}},required:["header"],additionalProperties:!1},"auth.AuthVariable":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.BasicAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"basic"},username:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]},password:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.BearerAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},token:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.AuthSchemeDeclarationSchema":{anyOf:[{$ref:"#/definitions/auth.OAuthSchemeSchema"},{$ref:"#/definitions/auth.HeaderAuthSchemeSchema"},{$ref:"#/definitions/auth.BasicAuthSchemeSchema"},{$ref:"#/definitions/auth.BearerAuthSchemeSchema"}]},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"file.PropertyBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"property"},"property-name":{type:"string"}},required:["strategy","property-name"],additionalProperties:!1},"file.StatusCodeBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"status-code"}},required:["strategy"],additionalProperties:!1},"file.ErrorDiscriminationSchema":{anyOf:[{$ref:"#/definitions/file.PropertyBasedErrorDiscrimination"},{$ref:"#/definitions/file.StatusCodeBasedErrorDiscrimination"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"variables.VariableDeclarationDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"variables.VariableDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/variables.VariableDeclarationDetailed"}]},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"}]},"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}},w2j={type:g2j,properties:m2j,required:O2j,additionalProperties:P2j,definitions:j2j};var Syu={};Dc(Syu,{additionalProperties:()=>E2j,default:()=>M2j,definitions:()=>A2j,properties:()=>S2j,type:()=>D2j});var D2j="object",S2j={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"}]}},E2j=!1,A2j={"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.TypeReferenceDeclarationWithName":{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.TypeReferenceDeclarationWithNameSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDeclarationWithName"}]},"types.ObjectPropertySchema":{$ref:"#/definitions/types.TypeReferenceDeclarationWithNameSchema"},"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"}]},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"}]},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"}]},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"}]},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"}]},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"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithContentTypeSchema":{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"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithContentTypeSchema"}]},"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"}]},"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:{type:"string"},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},required:["type"],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.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"}]},"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"}]}},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:{type:"string"}},{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"},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"}]}},M2j={type:D2j,properties:S2j,additionalProperties:E2j,definitions:A2j};function uDf({files:e,absolutePathToDefinition:t}){let r,n={},i={},a={};for(let[u,f]of X6(e)){let d=f.contents,c=o=>{a[u]={type:Iw.JSONSCHEMA_VALIDATION,error:o}};if(u===eF){let o=Bsi(d,Dyu);if(o.success){let l=UQ.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:l["default-url"],contents:l,rawContents:f.rawContents}}else c(o)}else if(oDf.default.basename(u)===mD){let o=Bsi(d,Syu);if(o.success){let l=UQ.serialization.PackageMarkerFileSchema.parseOrThrow(d);i[u]={defaultUrl:typeof l.export=="object"?l.export.url:void 0,contents:l,rawContents:f.rawContents}}else c(o)}else{let o=Bsi(d,wyu);if(o.success){let l=UQ.serialization.DefinitionFileSchema.parseOrThrow(d);n[u]={defaultUrl:void 0,contents:l,rawContents:f.rawContents,absoluteFilePath:Wl(t,u)}}else c(o)}}return r==null?{didSucceed:!1,failures:{[ls.of(eF)]:{type:Iw.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:n,rootApiFile:r,packageMarkers:i}}var p2t=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;type="api";constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:n,absoluteFilePath:i,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=n,this.absoluteFilePath=i,this.changelog=a}};var _2t=class extends p2t{definition;sources;constructor({definition:t,sources:r,...n}){super(n),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};function V6r(e,t={}){return{...Object.fromEntries(X6(e.namedDefinitionFiles).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...X6(e.importedDefinitions).reduce((r,[n,i])=>({...r,...isi(V6r(i.definition,{defaultURL:i.url}),(a,u)=>Wl(n,ls.of(u)))}),{})}}function Bhi(e,t={}){return{...Object.fromEntries(X6(e.packageMarkers).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...X6(e.importedDefinitions).reduce((r,[n,i])=>({...r,...isi(Bhi(i.definition,{defaultURL:i.url}),(a,u)=>Wl(n,ls.of(u)))}),{})}}function aSr(e){return{...Bhi(e),...V6r(e)}}function wne(e,t){return aSr(e.definition)[t]?.contents}var sDf=Jo(require("path"),1);async function D3(e,t){for(let[r,n]of X6(aSr(e.definition)))await t(r,n.contents,{isPackageMarker:sDf.default.basename(r)===mD,defaultUrl:n.defaultUrl})}async function oen(e,t){for(let[r,n]of X6(Bhi(e.definition)))await t(r,n.contents)}var a7n=class extends p2t{context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...n}){super(n),this.context=t,this.loadAPIWorkspace=r}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let n=(0,cDf.default)(r??{}),i=this.fernWorkspaces[n];if(i==null){let a=t||this.context,u=Wl(this.absoluteFilePath,ls.of(g9)),f=await aGi.loadDependenciesConfiguration({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await nDf(u,"{yml,yaml}"),c=await iDf(d);if(!c.didSucceed)return fba(c.failures,a.logger),a.failAndThrow();let o=uDf({files:c.files,absolutePathToDefinition:u});if(!o.didSucceed)return fba(o.failures,a.logger),a.failAndThrow();let l=await aDf({dependenciesConfiguration:f,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!l.didSucceed)return fba(l.failures,a.logger),a.failAndThrow();i=new _2t({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:f,workspaceName:this.workspaceName,definition:{absoluteFilePath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:l.packageMarkers,importedDefinitions:l.importedDefinitions},cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[n]=i}return i}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var oSr={openapi:e=>({...e,type:"openapi",_visit:function(t){return oSr._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return oSr._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 o7n={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return o7n._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var Y9={basic:e=>({...e,type:"basic",_visit:function(t){return Y9._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Y9._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Y9._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return Y9._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Y9._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 OP={primitive:e=>({value:e,type:"primitive",_visit:function(t){return OP._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return OP._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return OP._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return OP._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return OP._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return OP._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return OP._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return OP._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 Uy={int:e=>({value:e,type:"int",_visit:function(t){return Uy._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return Uy._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return Uy._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return Uy._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return Uy._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return Uy._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Uy._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return Uy._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return Uy._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return Uy._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return Uy._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 u7n={boolean:e=>({value:e,type:"boolean",_visit:function(t){return u7n._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return u7n._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 W6r={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return W6r._visit(this,t)}}),undisciminated:e=>({value:e,type:"undisciminated",_visit:function(t){return W6r._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undisciminated":return t.undisciminated(e.value);default:return t._other(e)}}};var _W={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case _W.GenerallyAvailable:return t.generallyAvailable();case _W.Beta:return t.beta();case _W.Deprecated:return t.deprecated();default:return t._other()}}};var uSr={cursor:e=>({...e,type:"cursor",_visit:function(t){return uSr._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return uSr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);default:return t._other(e)}}};var sSr={language:e=>({...e,type:"language",_visit:function(t){return sSr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return sSr._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 hW={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 hW.Curl:return t.curl();case hW.Python:return t.python();case hW.Javascript:return t.javascript();case hW.Typescript:return t.typescript();case hW.Go:return t.go();case hW.Ruby:return t.ruby();case hW.Csharp:return t.csharp();case hW.Java:return t.java();case hW.Js:return t.js();case hW.Node:return t.node();case hW.Ts:return t.ts();case hW.Nodets:return t.nodets();case hW.Golang:return t.golang();case hW.Dotnet:return t.dotnet();case hW.Jvm:return t.jvm();default:return t._other()}}};var h2t={unknown:e=>({value:e,type:"unknown",_visit:function(t){return h2t._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return h2t._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 y2t={withStreaming:e=>({value:e,type:"withStreaming",_visit:function(t){return y2t._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return y2t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e.value);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var nG={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case nG.Get:return t.get();case nG.Post:return t.post();case nG.Put:return t.put();case nG.Patch:return t.patch();case nG.Delete:return t.delete();case nG.Head:return t.head();case nG.Options:return t.options();case nG.Trace:return t.trace();default:return t._other()}}};var H6r={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return H6r._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return H6r._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return H6r._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);default:return t._other(e)}}};var Pxe={file:e=>({...e,type:"file",_visit:function(t){return Pxe._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return Pxe._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 Dne={file:e=>({...e,type:"file",_visit:function(t){return Dne._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Dne._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Dne._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Dne._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Dne._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Dne._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var J0={primitive:e=>({...e,type:"primitive",_visit:function(t){return J0._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return J0._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return J0._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return J0._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return J0._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return J0._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return J0._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return J0._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return J0._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return J0._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return J0._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 q1={int:e=>({...e,type:"int",_visit:function(t){return q1._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return q1._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return q1._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return q1._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return q1._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return q1._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return q1._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return q1._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return q1._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return q1._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return q1._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 _I={boolean:e=>({value:e,type:"boolean",_visit:function(t){return _I._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return _I._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 cSr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return cSr._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return cSr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undisciminated":return t.undisciminated(e);default:return t._other(e)}}};var Swe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return Swe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return Swe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Swe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);default:return t._other(e)}}};var hI={file:e=>({...e,type:"file",_visit:function(t){return hI._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return hI._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return hI._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return hI._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return hI._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return hI._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Op={primitive:e=>({...e,type:"primitive",_visit:function(t){return Op._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Op._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Op._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Op._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Op._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Op._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Op._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Op._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Op._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Op._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Op._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 SX={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return SX._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return SX._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undisciminated":return t.undisciminated(e);default:return t._other(e)}}};var ty={int:e=>({...e,type:"int",_visit:function(t){return ty._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return ty._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return ty._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return ty._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return ty._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return ty._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return ty._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return ty._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return ty._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return ty._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return ty._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 Kb={};Dc(Kb,{AllOfPropertyConflict:()=>M7n,ArraySchema:()=>Pga,ArraySchemaWithExample:()=>Yga,Availability:()=>Oba,Base64WithExample:()=>Jga,BasicSecurityScheme:()=>wba,BearerSecurityScheme:()=>Dba,BooleanSchema:()=>yga,BooleanWithExample:()=>Qga,CasingOverrides:()=>Aba,CommonProperty:()=>Tga,CommonPropertyWithExample:()=>ama,CursorPagination:()=>nga,CustomCodeSample:()=>tga,CustomCodeSampleLanguage:()=>Zba,CustomCodeSampleSdk:()=>ega,DateWithExample:()=>Hga,DatetimeWithExample:()=>Wga,DiscriminatedOneOfSchema:()=>Aga,DiscriminatedOneOfSchemaWithExample:()=>nma,DoubleSchema:()=>_ga,DoubleWithExample:()=>Uga,Encoding:()=>mba,Endpoint:()=>aga,EndpointExample:()=>w7n,EndpointResponseExample:()=>Xba,EndpointSdkName:()=>h8t,EndpointWithExample:()=>FDf,EnumSchema:()=>d7n,EnumSchemaWithExample:()=>$ga,EnumValue:()=>G6r,ErrorExample:()=>Gba,FernExample:()=>Kba,FileResponse:()=>m7n,FileSchema:()=>Uba,FloatWithExample:()=>Lga,FullEndpointExample:()=>rga,FullExample:()=>$q,FullObjectExample:()=>zba,FullOneOfExample:()=>Fba,GlobalHeader:()=>bga,Header:()=>Y6r,HeaderExample:()=>j7n,HeaderSecurityScheme:()=>Sba,HeaderWithExample:()=>e3r,HttpEndpointServer:()=>O7n,HttpError:()=>$ba,HttpErrorWithExample:()=>Iga,HttpMethod:()=>h7n,IdempotencyHeader:()=>gga,Int64WithExample:()=>Nga,IntSchema:()=>dga,IntWithExample:()=>zga,JsonRequest:()=>Hba,JsonRequestWithExample:()=>qga,JsonResponse:()=>X6r,JsonResponseWithExample:()=>Fhi,KeyValuePair:()=>Nba,LiteralExample:()=>Iba,LiteralSchema:()=>A7n,LiteralSchemaValue:()=>mga,LongSchema:()=>pga,MapSchema:()=>jga,MapSchemaWithExample:()=>Xga,MultipartRequest:()=>g7n,MultipartRequestProperty:()=>Wba,MultipartSchema:()=>Vba,NamedFullExample:()=>v8t,Namespace:()=>Mba,NamespaceId:()=>Bba,NullableSchema:()=>Dga,NullableSchemaWithExample:()=>kga,OauthSecurityScheme:()=>xba,ObjectProperty:()=>Ega,ObjectPropertyConflictInfo:()=>T7n,ObjectPropertyWithExample:()=>rma,ObjectSchema:()=>Oga,ObjectSchemaWithExample:()=>ema,OctetStreamRequest:()=>b7n,OffsetPagination:()=>iga,OneOfSchema:()=>Sga,OneOfSchemaWithExample:()=>tma,OpenApiIntermediateRepresentation:()=>zDf,OpenApiSource:()=>yba,OptionalSchema:()=>wga,OptionalSchemaWithExample:()=>Zga,Pagination:()=>D7n,PathParameter:()=>y7n,PathParameterExample:()=>Yba,PathParameterWithExample:()=>xga,PrimitiveExample:()=>_7n,PrimitiveSchema:()=>k6r,PrimitiveSchemaValue:()=>vga,PrimitiveSchemaValueWithExample:()=>Gga,PrimitiveSchemaWithExample:()=>q7n,PropertyKey:()=>p7n,ProtobufEncoding:()=>gba,ProtobufSource:()=>vba,QueryParameter:()=>v7n,QueryParameterExample:()=>P7n,QueryParameterWithExample:()=>x7n,QuerySecurityScheme:()=>Eba,ReferencedSchema:()=>y8t,Request:()=>Jba,RequestWithExample:()=>Cga,Response:()=>Qba,ResponseWithExample:()=>Bga,Schema:()=>fj,SchemaId:()=>EX,SchemaWithExample:()=>VT,Schemas:()=>fga,SdkGroup:()=>Tba,SdkGroupInfo:()=>Rba,SdkGroupName:()=>$6r,SecurityScheme:()=>qba,SecuritySchemeId:()=>jba,Server:()=>Cba,Source:()=>bba,StatusCode:()=>K6r,StringSchema:()=>hga,StringSchemaWithExample:()=>Vga,SupportedSdkLanguage:()=>kba,Tag:()=>Pba,TagId:()=>AX,Tags:()=>Lba,TextResponse:()=>Z6r,Uint64WithExample:()=>Rga,UintWithExample:()=>Fga,UnDiscriminatedOneOfSchema:()=>Mga,UnDiscriminatedOneOfSchemaWithExample:()=>ima,UnknownSchemaWithExample:()=>Kga,Webhook:()=>oga,WebhookExampleCall:()=>E7n,WebhookHttpMethod:()=>S7n,WebhookWithExample:()=>RDf,WebsocketChannel:()=>lga,WebsocketHandshake:()=>uga,WebsocketHandshakeWithExample:()=>NDf,WebsocketMessageExample:()=>sga,WebsocketSessionExample:()=>cga,WithAvailability:()=>Uv,WithDescription:()=>kp,WithEncoding:()=>Sne,WithName:()=>Am,WithNamespace:()=>_8t,WithSdkGroupName:()=>lj,WithSource:()=>z0,WithTitle:()=>cj,commons:()=>xyu,example:()=>qyu,finalIr:()=>Cyu,parseIr:()=>Byu});var xyu={};Dc(xyu,{BasicSecurityScheme:()=>wba,BearerSecurityScheme:()=>Dba,Encoding:()=>mba,HeaderSecurityScheme:()=>Sba,Namespace:()=>Mba,NamespaceId:()=>Bba,OauthSecurityScheme:()=>xba,OpenApiSource:()=>yba,ProtobufEncoding:()=>gba,ProtobufSource:()=>vba,QuerySecurityScheme:()=>Eba,SchemaId:()=>EX,SdkGroup:()=>Tba,SdkGroupName:()=>$6r,SecurityScheme:()=>qba,SecuritySchemeId:()=>jba,Server:()=>Cba,Source:()=>bba,StatusCode:()=>K6r,Tag:()=>Pba,TagId:()=>AX,WithAvailability:()=>Uv,WithDescription:()=>kp,WithEncoding:()=>Sne,WithName:()=>Am,WithNamespace:()=>_8t,WithSdkGroupName:()=>lj,WithSource:()=>z0,WithTitle:()=>cj});var jn={};Dc(jn,{JsonError:()=>s7n,ParseError:()=>c7n,any:()=>jDf,boolean:()=>wDf,booleanLiteral:()=>PDf,date:()=>fDf,discriminant:()=>CDf,enum_:()=>pba,getObjectLikeUtils:()=>p8t,getObjectUtils:()=>f7n,getSchemaUtils:()=>h2,isProperty:()=>Q6r,lazy:()=>dDf,lazyObject:()=>gDf,list:()=>hba,number:()=>DDf,object:()=>_ba,objectWithoutOptionalProperties:()=>bDf,optional:()=>Eyu,property:()=>_Df,record:()=>MDf,set:()=>TDf,string:()=>SDf,stringLiteral:()=>ODf,transform:()=>Ayu,undiscriminatedUnion:()=>qDf,union:()=>IDf,unknown:()=>EDf,withParsedProperties:()=>Tyu});var DS={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 Gq(e,t){return`Expected ${t}. Received ${T2j(e)}.`}function T2j(e){if(Array.isArray(e))return"list";if(e===null)return"null";switch(typeof e){case"string":return`"${e}"`;case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function iG(e){return{...e,json:lDf(e.json),parse:lDf(e.parse)}}function lDf(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1923
|
-
`)),{ok:!0,value:t}):n}}function dba(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var s7n=class e extends Error{errors;constructor(t){super(t.map(dba).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var c7n=class e extends Error{errors;constructor(t){super(t.map(dba).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function h2(e){return{optional:()=>Eyu(e),transform:t=>Ayu(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new c7n(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new s7n(n.errors)}}}function Eyu(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>DS.OPTIONAL};return{...t,...h2(t)}}function Ayu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...h2(r)}}var x2j=/^([+-]?\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 fDf(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:Gq(t,"string")}]}:x2j.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:Gq(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:Gq(t,"Date object")}]},getType:()=>DS.DATE};return{...iG(e),...h2(e)}}function aG(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...iG(r),...h2(r)}}}function pba(e){let t=new Set(e);return aG(DS.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:Gq(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:Gq(n,"enum")}]}:{ok:!0,value:n})()}function dDf(e){let t=Myu(e);return{...t,...h2(t)}}function Myu(e){return{parse:(t,r)=>l7n(e).parse(t,r),json:(t,r)=>l7n(e).json(t,r),getType:()=>l7n(e).getType()}}function l7n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Ihi(e){return Object.entries(e)}function zhi(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function J6r(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 Nhi(e){return Object.keys(e)}function pDf(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function p8t(e){return{withParsedProperties:t=>Tyu(e,t)}}function Tyu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((f,[d,c])=>({...f,[d]:typeof c=="function"?c(a.value):c}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!J6r(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Gq(n,"object")}]};let a=new Set(Object.keys(t)),u=zhi(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...h2(r),...p8t(r)}}function _Df(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function Q6r(e){return e.isProperty}function _ba(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>Q6r(n)?n.rawKey:r),_getParsedProperties:()=>Nhi(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of Ihi(e)){let d=Q6r(f)?f.rawKey:u,c=Q6r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,vDf(c)&&a.push(d)}return hDf({value:r,requiredKeys:a,getProperty:u=>{let f=i[u];if(f!=null)return{transformedKey:f.parsedKey,transform:d=>f.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,u]of Ihi(e)){let f=Q6r(u)?u.valueSchema:u;vDf(f)&&i.push(a)}return hDf({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return Q6r(u)?{transformedKey:u.rawKey,transform:f=>u.valueSchema.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:f=>u.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>DS.OBJECT};return{...iG(t),...h2(t),...p8t(t),...f7n(t)}}function hDf({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!J6r(e))return{ok:!1,errors:[{path:a,message:Gq(e,"object")}]};let u=new Set(t),f=[],d={};for(let[c,o]of Object.entries(e)){let l=r(c);if(l!=null){u.delete(c);let m=l.transform(o);m.ok?d[l.transformedKey]=m.value:(d[c]=o,f.push(...m.errors))}else switch(n){case"fail":f.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":d[c]=o;break}}return f.push(...t.filter(c=>u.has(c)).map(c=>({path:a,message:`Missing required key "${c}"`}))),f.length===0||i?{ok:!0,value:d}:{ok:!1,errors:f}}function f7n(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>yDf({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>yDf({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>DS.OBJECT};return{...r,...h2(r),...p8t(r),...f7n(r)}}}}function yDf({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=pDf(Nhi(t),c=>i.has(c)),f=r(zhi(t,u)),d=n(zhi(t,a));return f.ok&&d.ok?{ok:!0,value:{...f.value,...d.value}}:{ok:!1,errors:[...f.ok?[]:f.errors,...d.ok?[]:d.errors]}}function vDf(e){return!q2j(e)}function q2j(e){switch(e.getType()){case DS.ANY:case DS.UNKNOWN:case DS.OPTIONAL:return!0;default:return!1}}function bDf(e){return _ba(e)}function gDf(e){let t={...Myu(e),_getRawProperties:()=>l7n(e)._getRawProperties(),_getParsedProperties:()=>l7n(e)._getParsedProperties()};return{...t,...h2(t),...p8t(t),...f7n(t)}}function hba(e){let t={parse:(r,n)=>mDf(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>mDf(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>DS.LIST};return{...iG(t),...h2(t)}}function mDf(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:Gq(e,"list"),path:[]}]}}function ODf(e){return aG(DS.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Gq(r,`"${e}"`)}]})()}function PDf(e){return aG(DS.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Gq(r,`${e.toString()}`)}]})()}var jDf=aG(DS.ANY,e=>({ok:!0,value:e}));var wDf=aG(DS.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Gq(e,"boolean")}]});var DDf=aG(DS.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Gq(e,"number")}]});var SDf=aG(DS.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Gq(e,"string")}]});var EDf=aG(DS.UNKNOWN,e=>({ok:!0,value:e}));function MDf(e,t){let r={parse:(n,i)=>ADf({value:n,isKeyNumeric:e.getType()===DS.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>ADf({value:n,isKeyNumeric:e.getType()===DS.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>DS.RECORD};return{...iG(r),...h2(r)}}function ADf({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return J6r(e)?Ihi(e).reduce((a,[u,f])=>{if(f==null)return a;let d=a,c=u;if(t){let O=u.length>0?Number(u):NaN;isNaN(O)||(c=O)}let o=r(c),l=n(f,c);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let m=[];return d.ok||m.push(...d.errors),o.ok||m.push(...o.errors),l.ok||m.push(...l.errors),{ok:!1,errors:m}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:Gq(e,"object")}]}}function TDf(e){let t=hba(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Gq(n,"Set")}]},getType:()=>DS.SET};return{...iG(r),...h2(r)}}function qDf(e){let t={parse:(r,n)=>xDf((i,a)=>i.parse(r,a),e,n),json:(r,n)=>xDf((i,a)=>i.json(r,a),e,n),getType:()=>DS.UNDISCRIMINATED_UNION};return{...iG(t),...h2(t)}}function xDf(e,t,r){let n=[];for(let[i,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let f of u.errors)n.push({path:f.path,message:`[Variant ${i}] ${f.message}`})}return{ok:!1,errors:n}}function CDf(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function IDf(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=pba(Nhi(t)),a={parse:(u,f)=>BDf({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.parse(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),json:(u,f)=>BDf({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.json(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),getType:()=>DS.UNION};return{...iG(a),...h2(a),...p8t(a)}}function BDf({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!J6r(e))return{ok:!1,errors:[{path:f,message:Gq(e,"object")}]};let{[t]:d,...c}=e;if(d==null)return{ok:!1,errors:[{path:f,message:`Missing discriminant ("${t}")`}]};let o=n(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=i(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...c}}:{ok:!1,errors:[{path:[...f,t],message:"Unexpected discriminant value"}]};let m=u(c,l);return m.ok?{ok:!0,value:{[r]:d,...m.value}}:m}var cj=jn.objectWithoutOptionalProperties({title:jn.string().optional()});var yba=jn.objectWithoutOptionalProperties({file:jn.string()});var vba=jn.objectWithoutOptionalProperties({file:jn.string()});var bba=jn.union("type",{openapi:yba,protobuf:vba}).transform({transform:e=>{switch(e.type){case"openapi":return oSr.openapi(e);case"protobuf":return oSr.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var z0=jn.objectWithoutOptionalProperties({source:bba.optional()});var gba=jn.objectWithoutOptionalProperties({typeName:jn.string()});var mba=jn.union("type",{protobuf:gba}).transform({transform:e=>{switch(e.type){case"protobuf":return o7n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Sne=jn.objectWithoutOptionalProperties({encoding:mba.optional()});var kp=jn.objectWithoutOptionalProperties({description:jn.string().optional()});var Oba=jn.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Uv=jn.objectWithoutOptionalProperties({availability:Oba.optional()});var Am=jn.objectWithoutOptionalProperties({nameOverride:jn.string().optional(),generatedName:jn.string()});var EX=jn.string();var AX=jn.string();var Pba=jn.objectWithoutOptionalProperties({id:AX}).extend(kp);var jba=jn.string();var wba=jn.objectWithoutOptionalProperties({usernameVariableName:jn.string().optional(),usernameEnvVar:jn.string().optional(),passwordVariableName:jn.string().optional(),passwordEnvVar:jn.string().optional()});var Dba=jn.objectWithoutOptionalProperties({tokenVariableName:jn.string().optional(),tokenEnvVar:jn.string().optional()});var Sba=jn.objectWithoutOptionalProperties({headerName:jn.string(),prefix:jn.string().optional(),headerVariableName:jn.string().optional(),headerEnvVar:jn.string().optional()});var Eba=jn.objectWithoutOptionalProperties({queryParameterName:jn.string()});var Aba=jn.objectWithoutOptionalProperties({snake:jn.string().optional(),camel:jn.string().optional(),screamingSnake:jn.string().optional(),pascal:jn.string().optional()});var G6r=jn.objectWithoutOptionalProperties({nameOverride:jn.string().optional(),generatedName:jn.string(),value:jn.string(),casing:Aba.optional()}).extend(kp).extend(Uv);var Mba=jn.objectWithoutOptionalProperties({type:jn.stringLiteral("namespace"),name:jn.string()});var Tba=jn.undiscriminatedUnion([jn.string(),Mba]);var $6r=jn.list(Tba);var lj=jn.objectWithoutOptionalProperties({groupName:$6r.optional()});var d7n=jn.objectWithoutOptionalProperties({default:G6r.optional(),values:jn.list(G6r)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var xba=jn.objectWithoutOptionalProperties({scopesEnum:d7n.optional()});var qba=jn.union("type",{basic:wba,bearer:Dba,header:Sba,query:Eba,oauth:xba}).transform({transform:e=>{switch(e.type){case"basic":return Y9.basic(e);case"bearer":return Y9.bearer(e);case"header":return Y9.header(e);case"query":return Y9.query(e);case"oauth":return Y9.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var K6r=jn.number();var Cba=jn.objectWithoutOptionalProperties({name:jn.string().optional(),url:jn.string(),audiences:jn.list(jn.string()).optional()}).extend(kp);var Bba=jn.string();var _8t=jn.objectWithoutOptionalProperties({namespace:jn.string().optional()});var qyu={};Dc(qyu,{FullExample:()=>$q,FullObjectExample:()=>zba,FullOneOfExample:()=>Fba,KeyValuePair:()=>Nba,LiteralExample:()=>Iba,PrimitiveExample:()=>_7n,PropertyKey:()=>p7n});var p7n=jn.string();var _7n=jn.union("type",{int:jn.object({value:jn.number()}),int64:jn.object({value:jn.number()}),uint:jn.object({value:jn.number()}),uint64:jn.object({value:jn.number()}),float:jn.object({value:jn.number()}),double:jn.object({value:jn.number()}),string:jn.object({value:jn.string()}),datetime:jn.object({value:jn.string()}),date:jn.object({value:jn.string()}),base64:jn.object({value:jn.string()}),boolean:jn.object({value:jn.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return Uy.int(e.value);case"int64":return Uy.int64(e.value);case"uint":return Uy.uint(e.value);case"uint64":return Uy.uint64(e.value);case"float":return Uy.float(e.value);case"double":return Uy.double(e.value);case"string":return Uy.string(e.value);case"datetime":return Uy.datetime(e.value);case"date":return Uy.date(e.value);case"base64":return Uy.base64(e.value);case"boolean":return Uy.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Iba=jn.union("type",{boolean:jn.object({value:jn.boolean()}),string:jn.object({value:jn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return u7n.boolean(e.value);case"string":return u7n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var $q=jn.union("type",{primitive:jn.object({value:_7n}),object:jn.lazyObject(()=>zba),array:jn.object({value:jn.list(jn.lazy(()=>$q))}),map:jn.object({value:jn.list(jn.lazyObject(()=>Nba))}),enum:jn.object({value:jn.string()}),literal:jn.object({value:Iba}),oneOf:jn.object({value:jn.lazy(()=>Fba)}),unknown:jn.object({value:jn.lazy(()=>$q)})}).transform({transform:e=>{switch(e.type){case"primitive":return OP.primitive(e.value);case"object":return OP.object(e);case"array":return OP.array(e.value);case"map":return OP.map(e.value);case"enum":return OP.enum(e.value);case"literal":return OP.literal(e.value);case"oneOf":return OP.oneOf(e.value);case"unknown":return OP.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var zba=jn.objectWithoutOptionalProperties({properties:jn.record(p7n,jn.lazy(()=>$q))});var Nba=jn.objectWithoutOptionalProperties({key:_7n,value:jn.lazy(()=>$q)});var Fba=jn.union("type",{discriminated:jn.object({value:jn.record(p7n,jn.lazy(()=>$q))}),undisciminated:jn.object({value:jn.lazy(()=>$q)})}).transform({transform:e=>{switch(e.type){case"discriminated":return W6r.discriminated(e.value);case"undisciminated":return W6r.undisciminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Cyu={};Dc(Cyu,{AllOfPropertyConflict:()=>M7n,ArraySchema:()=>Pga,Availability:()=>Oba,BooleanSchema:()=>yga,CasingOverrides:()=>Aba,CommonProperty:()=>Tga,CursorPagination:()=>nga,CustomCodeSample:()=>tga,CustomCodeSampleLanguage:()=>Zba,CustomCodeSampleSdk:()=>ega,DiscriminatedOneOfSchema:()=>Aga,DoubleSchema:()=>_ga,Endpoint:()=>aga,EndpointExample:()=>w7n,EndpointResponseExample:()=>Xba,EndpointSdkName:()=>h8t,EnumSchema:()=>d7n,EnumValue:()=>G6r,ErrorExample:()=>Gba,FernExample:()=>Kba,FileResponse:()=>m7n,FileSchema:()=>Uba,FullEndpointExample:()=>rga,GlobalHeader:()=>bga,Header:()=>Y6r,HeaderExample:()=>j7n,HttpEndpointServer:()=>O7n,HttpError:()=>$ba,HttpMethod:()=>h7n,IdempotencyHeader:()=>gga,IntSchema:()=>dga,JsonRequest:()=>Hba,JsonResponse:()=>X6r,LiteralSchema:()=>A7n,LiteralSchemaValue:()=>mga,LongSchema:()=>pga,MapSchema:()=>jga,MultipartRequest:()=>g7n,MultipartRequestProperty:()=>Wba,MultipartSchema:()=>Vba,NullableSchema:()=>Dga,ObjectProperty:()=>Ega,ObjectPropertyConflictInfo:()=>T7n,ObjectSchema:()=>Oga,OctetStreamRequest:()=>b7n,OffsetPagination:()=>iga,OneOfSchema:()=>Sga,OpenApiIntermediateRepresentation:()=>zDf,OptionalSchema:()=>wga,Pagination:()=>D7n,PathParameter:()=>y7n,PathParameterExample:()=>Yba,PrimitiveSchema:()=>k6r,PrimitiveSchemaValue:()=>vga,QueryParameter:()=>v7n,QueryParameterExample:()=>P7n,ReferencedSchema:()=>y8t,Request:()=>Jba,Response:()=>Qba,Schema:()=>fj,Schemas:()=>fga,SdkGroupInfo:()=>Rba,StringSchema:()=>hga,SupportedSdkLanguage:()=>kba,Tags:()=>Lba,TextResponse:()=>Z6r,UnDiscriminatedOneOfSchema:()=>Mga,Webhook:()=>oga,WebhookExampleCall:()=>E7n,WebhookHttpMethod:()=>S7n,WebsocketChannel:()=>lga,WebsocketHandshake:()=>uga,WebsocketMessageExample:()=>sga,WebsocketSessionExample:()=>cga});var Rba=jn.objectWithoutOptionalProperties({summary:jn.string().optional(),description:jn.string().optional()});var Lba=jn.objectWithoutOptionalProperties({tagsById:jn.record(AX,Pba),orderedTagIds:jn.list(AX).optional()});var h7n=jn.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var y7n=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>fj),variableReference:jn.string().optional(),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var v7n=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>fj),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var Y6r=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>fj),env:jn.string().optional(),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var h8t=jn.objectWithoutOptionalProperties({groupName:$6r,methodName:jn.string()});var b7n=jn.objectWithoutOptionalProperties({}).extend(kp).extend(z0);var Uba=jn.objectWithoutOptionalProperties({isOptional:jn.boolean(),isArray:jn.boolean()});var Vba=jn.union("type",{file:Uba,json:jn.object({value:jn.lazy(()=>fj)})}).transform({transform:e=>{switch(e.type){case"file":return Pxe.file(e);case"json":return Pxe.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Wba=jn.objectWithoutOptionalProperties({key:jn.string(),schema:Vba,contentType:jn.string().optional()}).extend(kp);var g7n=jn.objectWithoutOptionalProperties({name:jn.string().optional(),properties:jn.list(Wba)}).extend(kp).extend(z0);var Hba=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>fj),contentType:jn.string().optional(),additionalProperties:jn.boolean()}).extend(kp).extend(z0);var Jba=jn.union("type",{octetStream:b7n,multipart:g7n,json:Hba}).transform({transform:e=>{switch(e.type){case"octetStream":return H6r.octetStream(e);case"multipart":return H6r.multipart(e);case"json":return H6r.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var m7n=jn.objectWithoutOptionalProperties({}).extend(kp).extend(z0);var X6r=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>fj),responseProperty:jn.string().optional()}).extend(kp).extend(z0);var Z6r=jn.objectWithoutOptionalProperties({}).extend(kp).extend(z0);var Qba=jn.union("type",{file:m7n,json:X6r,text:Z6r,streamingSse:X6r,streamingText:Z6r,streamingJson:X6r}).transform({transform:e=>{switch(e.type){case"file":return Dne.file(e);case"json":return Dne.json(e);case"text":return Dne.text(e);case"streamingSse":return Dne.streamingSse(e);case"streamingText":return Dne.streamingText(e);case"streamingJson":return Dne.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Gba=jn.objectWithoutOptionalProperties({name:jn.string().optional(),description:jn.string().optional(),example:jn.lazy(()=>$q)});var $ba=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>fj).optional(),examples:jn.list(Gba).optional()}).extend(kp).extend(Am).extend(z0);var O7n=jn.objectWithoutOptionalProperties({name:jn.string().optional(),url:jn.string().optional(),audiences:jn.list(jn.string()).optional()});var Kba=jn.unknown();var Yba=jn.objectWithoutOptionalProperties({name:jn.string(),parameterNameOverride:jn.string().optional(),value:jn.lazy(()=>$q)});var P7n=jn.objectWithoutOptionalProperties({name:jn.string(),value:jn.lazy(()=>$q)});var j7n=jn.objectWithoutOptionalProperties({name:jn.string(),value:jn.lazy(()=>$q)});var Xba=jn.union("type",{withStreaming:jn.object({value:jn.list(jn.lazy(()=>$q))}),withoutStreaming:jn.object({value:jn.lazy(()=>$q)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return y2t.withStreaming(e.value);case"withoutStreaming":return y2t.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Zba=jn.objectWithoutOptionalProperties({name:jn.string().optional(),language:jn.string(),code:jn.string(),install:jn.string().optional()}).extend(kp);var kba=jn.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var ega=jn.objectWithoutOptionalProperties({name:jn.string().optional(),sdk:kba,code:jn.string()}).extend(kp);var tga=jn.union("type",{language:Zba,sdk:ega}).transform({transform:e=>{switch(e.type){case"language":return sSr.language(e);case"sdk":return sSr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var rga=jn.objectWithoutOptionalProperties({name:jn.string().optional(),pathParameters:jn.list(Yba).optional(),queryParameters:jn.list(P7n).optional(),headers:jn.list(j7n).optional(),request:jn.lazy(()=>$q).optional(),response:Xba.optional(),codeSamples:jn.list(tga)}).extend(kp);var w7n=jn.union("type",{unknown:jn.object({value:Kba}),full:rga}).transform({transform:e=>{switch(e.type){case"unknown":return h2t.unknown(e.value);case"full":return h2t.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var nga=jn.objectWithoutOptionalProperties({cursor:jn.string(),nextCursor:jn.property("next_cursor",jn.string()),results:jn.string()});var iga=jn.objectWithoutOptionalProperties({offset:jn.string(),results:jn.string(),step:jn.string().optional(),hasNextPage:jn.string().optional()});var D7n=jn.union("type",{cursor:nga,offset:iga}).transform({transform:e=>{switch(e.type){case"cursor":return uSr.cursor(e);case"offset":return uSr.offset(e);default:return e}},untransform:({_visit:e,...t})=>t});var aga=jn.objectWithoutOptionalProperties({authed:jn.boolean(),internal:jn.boolean().optional(),idempotent:jn.boolean().optional(),method:h7n,audiences:jn.list(jn.string()),path:jn.string(),summary:jn.string().optional(),operationId:jn.string().optional(),tags:jn.list(AX),pathParameters:jn.list(y7n),queryParameters:jn.list(v7n),headers:jn.list(Y6r),sdkName:h8t.optional(),generatedRequestName:jn.string(),requestNameOverride:jn.string().optional(),request:Jba.optional(),response:Qba.optional(),errors:jn.record(K6r,$ba),server:jn.list(O7n),examples:jn.list(w7n),pagination:D7n.optional()}).extend(kp).extend(Uv).extend(z0).extend(_8t);var S7n=jn.enum_(["GET","POST"]);var E7n=jn.objectWithoutOptionalProperties({name:jn.string().optional(),payload:jn.lazy(()=>$q)}).extend(kp);var oga=jn.objectWithoutOptionalProperties({sdkName:h8t.optional(),method:S7n,summary:jn.string().optional(),operationId:jn.string(),tags:jn.list(AX),headers:jn.list(Y6r),generatedPayloadName:jn.string(),payload:jn.lazy(()=>fj),examples:jn.list(E7n)}).extend(kp).extend(z0).extend(_8t);var uga=jn.objectWithoutOptionalProperties({queryParameters:jn.list(v7n),headers:jn.list(Y6r),pathParameters:jn.list(y7n)});var sga=jn.objectWithoutOptionalProperties({messageType:jn.string(),payload:jn.lazy(()=>$q)}).extend(kp);var cga=jn.objectWithoutOptionalProperties({name:jn.string().optional(),queryParameters:jn.list(P7n).optional(),headers:jn.list(j7n).optional(),messages:jn.list(sga)}).extend(kp);var lga=jn.objectWithoutOptionalProperties({path:jn.string(),groupName:$6r,summary:jn.string().optional(),handshake:uga,publish:jn.lazy(()=>fj).optional(),subscribe:jn.lazy(()=>fj).optional(),examples:jn.list(cga)}).extend(kp).extend(z0);var fga=jn.objectWithoutOptionalProperties({rootSchemas:jn.record(EX,jn.lazy(()=>fj)),namespacedSchemas:jn.record(Bba,jn.record(EX,jn.lazy(()=>fj)))});var dga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),minimum:jn.number().optional(),maximum:jn.number().optional(),exclusiveMinimum:jn.boolean().optional(),exclusiveMaximum:jn.boolean().optional(),multipleOf:jn.number().optional()});var pga=jn.objectWithoutOptionalProperties({default:jn.number().optional()});var _ga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),minimum:jn.number().optional(),maximum:jn.number().optional(),exclusiveMinimum:jn.boolean().optional(),exclusiveMaximum:jn.boolean().optional(),multipleOf:jn.number().optional()});var hga=jn.objectWithoutOptionalProperties({default:jn.string().optional(),pattern:jn.string().optional(),format:jn.string().optional(),minLength:jn.number().optional(),maxLength:jn.number().optional()});var yga=jn.objectWithoutOptionalProperties({default:jn.boolean().optional()});var vga=jn.union("type",{int:dga,int64:pga,uint:jn.object({}),uint64:jn.object({}),float:jn.object({}),double:_ga,string:hga,datetime:jn.object({}),date:jn.object({}),base64:jn.object({}),boolean:yga}).transform({transform:e=>{switch(e.type){case"int":return q1.int(e);case"int64":return q1.int64(e);case"uint":return q1.uint();case"uint64":return q1.uint64();case"float":return q1.float();case"double":return q1.double(e);case"string":return q1.string(e);case"datetime":return q1.datetime();case"date":return q1.date();case"base64":return q1.base64();case"boolean":return q1.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var k6r=jn.objectWithoutOptionalProperties({schema:vga}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var bga=jn.objectWithoutOptionalProperties({header:jn.string(),name:jn.string().optional(),optional:jn.boolean().optional(),env:jn.string().optional(),schema:jn.lazy(()=>fj).optional()});var gga=jn.objectWithoutOptionalProperties({header:jn.string(),name:jn.string().optional(),env:jn.string().optional(),schema:jn.lazy(()=>fj).optional()});var zDf=jn.objectWithoutOptionalProperties({apiVersion:jn.unknown().optional(),title:jn.string().optional(),description:jn.string().optional(),basePath:jn.string().optional(),servers:jn.list(Cba),groups:jn.record(jn.string(),Rba),tags:Lba,hasEndpointsMarkedInternal:jn.boolean(),endpoints:jn.list(aga),webhooks:jn.list(oga),channel:jn.list(lga),groupedSchemas:fga,variables:jn.record(jn.string(),k6r),nonRequestReferencedSchemas:jn.set(EX),securitySchemes:jn.record(jba,qba),globalHeaders:jn.list(bga).optional(),idempotencyHeaders:jn.list(gga).optional()});var y8t=jn.objectWithoutOptionalProperties({schema:EX}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var mga=jn.union("type",{boolean:jn.object({value:jn.boolean()}),string:jn.object({value:jn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return _I.boolean(e.value);case"string":return _I.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var A7n=jn.objectWithoutOptionalProperties({value:mga}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var fj=jn.union("type",{primitive:k6r,object:jn.lazyObject(()=>Oga),array:jn.lazyObject(()=>Pga),map:jn.lazyObject(()=>jga),optional:jn.lazyObject(()=>wga),enum:d7n,reference:y8t,literal:A7n,oneOf:jn.object({value:jn.lazy(()=>Sga)}),nullable:jn.lazyObject(()=>Dga),unknown:Am}).transform({transform:e=>{switch(e.type){case"primitive":return J0.primitive(e);case"object":return J0.object(e);case"array":return J0.array(e);case"map":return J0.map(e);case"optional":return J0.optional(e);case"enum":return J0.enum(e);case"reference":return J0.reference(e);case"literal":return J0.literal(e);case"oneOf":return J0.oneOf(e.value);case"nullable":return J0.nullable(e);case"unknown":return J0.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var M7n=jn.objectWithoutOptionalProperties({propertyKey:jn.string(),allOfSchemaIds:jn.list(EX),conflictingTypeSignatures:jn.boolean()});var Oga=jn.objectWithoutOptionalProperties({allOf:jn.list(y8t),properties:jn.list(jn.lazyObject(()=>Ega)),allOfPropertyConflicts:jn.list(M7n),additionalProperties:jn.boolean()}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var T7n=jn.objectWithoutOptionalProperties({differentSchema:jn.boolean()});var Ega=jn.objectWithoutOptionalProperties({key:jn.string(),schema:jn.lazy(()=>fj),readonly:jn.boolean().optional(),conflict:jn.record(EX,T7n),generatedName:jn.string(),nameOverride:jn.string().optional(),audiences:jn.list(jn.string())}).extend(Uv);var Pga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>fj)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var jga=jn.objectWithoutOptionalProperties({key:k6r,value:jn.lazy(()=>fj)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Sne).extend(cj);var wga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>fj)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var Dga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>fj)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var Sga=jn.union("type",{discriminated:jn.lazyObject(()=>Aga),undisciminated:jn.lazyObject(()=>Mga)}).transform({transform:e=>{switch(e.type){case"discriminated":return cSr.discriminated(e);case"undisciminated":return cSr.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Aga=jn.objectWithoutOptionalProperties({discriminantProperty:jn.string(),commonProperties:jn.list(jn.lazyObject(()=>Tga)),schemas:jn.record(jn.string(),jn.lazy(()=>fj))}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Sne).extend(z0).extend(cj);var Tga=jn.objectWithoutOptionalProperties({key:jn.string(),schema:jn.lazy(()=>fj)});var Mga=jn.objectWithoutOptionalProperties({schemas:jn.list(jn.lazy(()=>fj))}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Sne).extend(z0).extend(cj);var Byu={};Dc(Byu,{ArraySchemaWithExample:()=>Yga,Base64WithExample:()=>Jga,BooleanWithExample:()=>Qga,CommonPropertyWithExample:()=>ama,DateWithExample:()=>Hga,DatetimeWithExample:()=>Wga,DiscriminatedOneOfSchemaWithExample:()=>nma,DoubleWithExample:()=>Uga,EndpointWithExample:()=>FDf,EnumSchemaWithExample:()=>$ga,FloatWithExample:()=>Lga,HeaderWithExample:()=>e3r,HttpErrorWithExample:()=>Iga,Int64WithExample:()=>Nga,IntWithExample:()=>zga,JsonRequestWithExample:()=>qga,JsonResponseWithExample:()=>Fhi,MapSchemaWithExample:()=>Xga,NamedFullExample:()=>v8t,NullableSchemaWithExample:()=>kga,ObjectPropertyWithExample:()=>rma,ObjectSchemaWithExample:()=>ema,OneOfSchemaWithExample:()=>tma,OptionalSchemaWithExample:()=>Zga,PathParameterWithExample:()=>xga,PrimitiveSchemaValueWithExample:()=>Gga,PrimitiveSchemaWithExample:()=>q7n,QueryParameterWithExample:()=>x7n,RequestWithExample:()=>Cga,ResponseWithExample:()=>Bga,SchemaWithExample:()=>VT,StringSchemaWithExample:()=>Vga,Uint64WithExample:()=>Rga,UintWithExample:()=>Fga,UnDiscriminatedOneOfSchemaWithExample:()=>ima,UnknownSchemaWithExample:()=>Kga,WebhookWithExample:()=>RDf,WebsocketHandshakeWithExample:()=>NDf});var v8t=jn.objectWithoutOptionalProperties({name:jn.string().optional(),value:jn.unknown()}).extend(kp);var x7n=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>VT),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var e3r=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>VT),env:jn.string().optional(),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var NDf=jn.objectWithoutOptionalProperties({queryParameters:jn.list(x7n),headers:jn.list(e3r)});var xga=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>VT),variableReference:jn.string().optional(),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var qga=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>VT),contentType:jn.string().optional(),fullExamples:jn.list(v8t).optional(),additionalProperties:jn.boolean()}).extend(kp).extend(z0);var Cga=jn.union("type",{octetStream:b7n,multipart:g7n,json:qga}).transform({transform:e=>{switch(e.type){case"octetStream":return Swe.octetStream(e);case"multipart":return Swe.multipart(e);case"json":return Swe.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var Fhi=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>VT),responseProperty:jn.string().optional(),fullExamples:jn.list(v8t).optional()}).extend(kp).extend(z0);var Bga=jn.union("type",{file:m7n,json:Fhi,text:Z6r,streamingSse:X6r,streamingText:Z6r,streamingJson:Fhi}).transform({transform:e=>{switch(e.type){case"file":return hI.file(e);case"json":return hI.json(e);case"text":return hI.text(e);case"streamingSse":return hI.streamingSse(e);case"streamingText":return hI.streamingText(e);case"streamingJson":return hI.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Iga=jn.objectWithoutOptionalProperties({statusCode:K6r,schema:jn.lazy(()=>VT),fullExamples:jn.list(v8t).optional()}).extend(kp).extend(Am).extend(z0);var FDf=jn.objectWithoutOptionalProperties({authed:jn.boolean(),internal:jn.boolean().optional(),idempotent:jn.boolean().optional(),method:h7n,audiences:jn.list(jn.string()),path:jn.string(),summary:jn.string().optional(),operationId:jn.string().optional(),tags:jn.list(AX),pathParameters:jn.list(xga),queryParameters:jn.list(x7n),headers:jn.list(e3r),sdkName:h8t.optional(),generatedRequestName:jn.string(),requestNameOverride:jn.string().optional(),request:Cga.optional(),response:Bga.optional(),errors:jn.record(K6r,Iga),server:jn.list(O7n),examples:jn.list(w7n),pagination:D7n.optional()}).extend(kp).extend(Uv).extend(z0).extend(_8t);var RDf=jn.objectWithoutOptionalProperties({sdkName:h8t.optional(),method:S7n,summary:jn.string().optional(),operationId:jn.string(),tags:jn.list(AX),headers:jn.list(e3r),generatedPayloadName:jn.string(),payload:jn.lazy(()=>VT),examples:jn.list(E7n)}).extend(kp).extend(z0).extend(_8t);var zga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),minimum:jn.number().optional(),maximum:jn.number().optional(),exclusiveMinimum:jn.boolean().optional(),exclusiveMaximum:jn.boolean().optional(),multipleOf:jn.number().optional(),example:jn.number().optional()});var Nga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),example:jn.number().optional()});var Fga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),example:jn.number().optional()});var Rga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),example:jn.number().optional()});var Lga=jn.objectWithoutOptionalProperties({example:jn.number().optional()});var Uga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),minimum:jn.number().optional(),maximum:jn.number().optional(),exclusiveMinimum:jn.boolean().optional(),exclusiveMaximum:jn.boolean().optional(),multipleOf:jn.number().optional(),example:jn.number().optional()});var Vga=jn.objectWithoutOptionalProperties({default:jn.string().optional(),pattern:jn.string().optional(),format:jn.string().optional(),minLength:jn.number().optional(),maxLength:jn.number().optional(),example:jn.string().optional()});var Wga=jn.objectWithoutOptionalProperties({example:jn.string().optional()});var Hga=jn.objectWithoutOptionalProperties({example:jn.string().optional()});var Jga=jn.objectWithoutOptionalProperties({example:jn.string().optional()});var Qga=jn.objectWithoutOptionalProperties({default:jn.boolean().optional(),example:jn.boolean().optional()});var Gga=jn.union("type",{int:zga,int64:Nga,uint:Fga,uint64:Rga,float:Lga,double:Uga,string:Vga,datetime:Wga,date:Hga,base64:Jga,boolean:Qga}).transform({transform:e=>{switch(e.type){case"int":return ty.int(e);case"int64":return ty.int64(e);case"uint":return ty.uint(e);case"uint64":return ty.uint64(e);case"float":return ty.float(e);case"double":return ty.double(e);case"string":return ty.string(e);case"datetime":return ty.datetime(e);case"date":return ty.date(e);case"base64":return ty.base64(e);case"boolean":return ty.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var q7n=jn.objectWithoutOptionalProperties({schema:Gga}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var $ga=jn.objectWithoutOptionalProperties({default:G6r.optional(),values:jn.list(G6r),example:jn.string().optional()}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var Kga=jn.objectWithoutOptionalProperties({example:jn.unknown()}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(cj);var VT=jn.union("type",{primitive:q7n,object:jn.lazyObject(()=>ema),array:jn.lazyObject(()=>Yga),map:jn.lazyObject(()=>Xga),optional:jn.lazyObject(()=>Zga),enum:$ga,reference:y8t,literal:A7n,oneOf:jn.object({value:jn.lazy(()=>tma)}),nullable:jn.lazyObject(()=>kga),unknown:Kga}).transform({transform:e=>{switch(e.type){case"primitive":return Op.primitive(e);case"object":return Op.object(e);case"array":return Op.array(e);case"map":return Op.map(e);case"optional":return Op.optional(e);case"enum":return Op.enum(e);case"reference":return Op.reference(e);case"literal":return Op.literal(e);case"oneOf":return Op.oneOf(e.value);case"nullable":return Op.nullable(e);case"unknown":return Op.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var Yga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>VT),example:jn.list(jn.unknown()).optional()}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(cj);var Xga=jn.objectWithoutOptionalProperties({key:q7n,value:jn.lazy(()=>VT),example:jn.unknown().optional()}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(Sne).extend(cj);var Zga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>VT)}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(cj);var kga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>VT)}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(cj);var ema=jn.objectWithoutOptionalProperties({allOf:jn.list(y8t),properties:jn.list(jn.lazyObject(()=>rma)),allOfPropertyConflicts:jn.list(M7n),fullExamples:jn.list(v8t).optional(),additionalProperties:jn.boolean()}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var rma=jn.objectWithoutOptionalProperties({key:jn.string(),schema:jn.lazy(()=>VT),readonly:jn.boolean().optional(),audiences:jn.list(jn.string()),conflict:jn.record(EX,T7n),nameOverride:jn.string().optional(),generatedName:jn.string()}).extend(Uv);var tma=jn.union("type",{discriminated:jn.lazyObject(()=>nma),undisciminated:jn.lazyObject(()=>ima)}).transform({transform:e=>{switch(e.type){case"discriminated":return SX.discriminated(e);case"undisciminated":return SX.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var nma=jn.objectWithoutOptionalProperties({discriminantProperty:jn.string(),commonProperties:jn.list(jn.lazyObject(()=>ama)),schemas:jn.record(jn.string(),jn.lazy(()=>VT))}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Sne).extend(z0).extend(cj);var ama=jn.objectWithoutOptionalProperties({key:jn.string(),schema:jn.lazy(()=>VT)});var ima=jn.objectWithoutOptionalProperties({schemas:jn.list(jn.lazy(()=>VT))}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Sne).extend(z0).extend(cj);function oma(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:sc(e.type)}}function C7n(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:sc(e)}}function gx(e){return typeof e=="string"?e:e.type}function Rhi(e){if(typeof e!="string")return e.docs}function LDf(e){if(typeof e!="string")return e.default}function UDf(e){if(typeof e!="string")return e.validation}function C2j(e){let t=e.find(n=>typeof n=="object"&&n.type==="namespace"),r=e.filter(n=>typeof n=="string"||n.type!=="namespace");return t?[t,...r]:r}function VDf(e){let t=e?C2j(e):void 0;if(t==null||t.length===0)return Isi;let r=[];for(let[n,i]of t.entries())if(typeof i=="string")r.push(mE(i));else if(typeof i=="object")switch(i.type){case"namespace":{n<t.length-1?r.push(mE(i.name)):r.push(i.name,Isi);break}default:sc(i.type)}else sc(i);return r.join("/")}function B7n(e){return ls.of(`${VDf(e)}.yml`)}function Iyu({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Isi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,VDf(r))}function WDf({sdkName:e,namespaceOverride:t}){return ls.of(`${Iyu({sdkName:e,namespaceOverride:t})}.yml`)}function HDf({location:e,namespaceOverride:t}){return t!=null?Wl(ls.of(t),e):e}function gz(e){switch(e){case _W.Deprecated:return"deprecated";case _W.Beta:return"pre-release";case _W.GenerallyAvailable:return"generally-available";default:return}}var B2j=-2147483648,I2j=2147483647,z2j=-17976931348623157e292,N2j=17976931348623157e292;function qO({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i}){switch(n.shouldMarkSchemaAsReferenced()&&n.markSchemaAsReferenced(e,i),e.type){case"primitive":return uma(e);case"array":return Fyu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"map":return Ryu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"reference":return Nyu({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return Uyu();case"optional":case"nullable":return Lyu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"enum":return Q2j({schema:e,fileContainingReference:t,context:n,declarationFile:r});case"literal":return e.value,Vyu(e);case"object":return G2j({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"oneOf":return $2j({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i});default:sc(e)}}function uma(e){switch(e.schema.type){case"string":return L2j({description:e.description,schema:e.schema});case"int":return U2j({description:e.description,schema:e.schema});case"float":return V2j({description:e.description,schema:e.schema});case"double":return W2j({description:e.description,schema:e.schema});case"boolean":return F2j({description:e.description,schema:e.schema});case"int64":return R2j({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:gz(e.availability)}:{}}}function F2j({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function R2j({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function L2j({description:e,schema:t}){let r="string",n=H2j(t);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function U2j({description:e,schema:t}){let r="integer",n=JDf(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function V2j({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function W2j({description:e,schema:t}){let r="double",n=JDf(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function H2j(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=J2j(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function J2j(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 JDf(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=zyu(r,t),n=zyu(n,t),i=zyu(i,t),!(r==null&&n==null&&a==null&&u==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:u,multipleOf:i}}function zyu(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[B2j,I2j]:[z2j,N2j];return e<r||e>n?void 0:e}function Nyu({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=K2j(i)??e.schema,u=C7n(i),f=Y2j(i),d=sma({context:r,fileContainingReference:t,declarationFile:B7n(u),type:a}),c=i.type==="nullable"?`optional<${d}>`:d;return e.description==null&&f==null?c:{type:i.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function Fyu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=qO({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=`list<${gx(a)}>`;return e.description==null&&e.title==null?u:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{},type:u}}function Ryu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=uma(e.key),u=qO({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),f=e.encoding!=null?oma(e.encoding):void 0,d=`map<${gx(a)}, ${gx(u)}>`;if(e.description==null&&f==null&&e.title==null)return d;let c={type:d};return e.description!=null&&(c.docs=e.description),e.encoding!=null&&(c.encoding=f),e.availability!=null&&(c.availability=gz(e.availability)),c}function Lyu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=qO({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=gx(a),f=Rhi(a),d=LDf(a),c=UDf(a),o=u.startsWith("optional<")?u:`optional<${u}>`;if(e.availability==null&&e.description==null&&f==null&&d==null&&c==null&&e.title==null)return o;let l={type:o};return(e.description!=null||f!=null)&&(l.docs=e.description??f),d!=null&&(l.default=d),c!=null&&(l.validation=c),e.availability!=null&&(l.availability=gz(e.availability)),l}function Uyu(){return"unknown"}function Vyu(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:sc(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function Q2j({schema:e,fileContainingReference:t,declarationFile:r,context:n}){let i=Lhi(e),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:i.schema});let u=sma({type:a,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return u;let f={type:u};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.availability!=null&&(f.availability=gz(e.availability)),f}function G2j({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Wyu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=sma({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function $2j({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Hyu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=sma({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{...e.title!=null?{"display-name":e.title}:{},type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function sma({type:e,fileContainingReference:t,declarationFile:r,context:n}){if(r===t)return e;let i=n.builder.addImport({file:t,fileToImport:r});return i!=null?`${i}.${e}`:e}function K2j(e){return J0._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 Y2j(e){return J0._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 lSr(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:sc(e)}}var v8;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(v8||(v8={}));function GDf({schema:e,context:t,declarationFile:r,namespace:n}){switch(e.type){case"primitive":return k2j(e);case"array":return X2j({schema:e,context:t,declarationFile:r,namespace:n});case"map":return Z2j({schema:e,context:t,declarationFile:r,namespace:n});case"reference":return eBj({schema:e,context:t,declarationFile:r,namespace:n});case"unknown":return rBj(e.nameOverride,e.generatedName);case"optional":case"nullable":return tBj({schema:e,context:t,declarationFile:r,namespace:n});case"enum":return Lhi(e);case"literal":return nBj(e,e.nameOverride,e.generatedName);case"object":return Wyu({schema:e,context:t,declarationFile:r,namespace:n});case"oneOf":return Hyu({schema:e.value,context:t,declarationFile:r,namespace:n});default:sc(e)}}function Wyu({schema:e,context:t,declarationFile:r,namespace:n}){let i=t.isInState(v8.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),a=!1,u={},f=new Set;for(let m of e.properties){if(m.readonly&&(a=!0),i&&m.readonly)continue;if(Object.keys(m.conflict).length>0){if(Object.entries(m.conflict).every(([F,C])=>!C.differentSchema))continue;Object.entries(m.conflict).forEach(([F])=>{Jyu({property:m.key,schemaId:F,context:t,namespace:n}).forEach(N=>{f.add(N)})})}let O=qO({schema:m.schema,context:t,fileContainingReference:r,namespace:n}),j=m.audiences,A=m.nameOverride,T=gz(m.availability);u[m.key]=oBj(O,j,A,T)}let d=new Set;for(let m of e.allOfPropertyConflicts)m.allOfSchemaIds.forEach(O=>f.add(O)),m.conflictingTypeSignatures&&d.add(m.propertyKey);let c=[];for(let m of e.allOf){let O=$Df({schema:m.schema,context:t,namespace:n});if(O==null||f.has(m.schema)||f.has(O))continue;let j=qO({schema:J0.reference(m),context:t,fileContainingReference:r,namespace:n});c.push(gx(j))}for(let m of f){let O=Qyu(t,m,n);for(let j of O.properties)u[j.key]==null&&(d.has(j.key)&&(u[j.key]="unknown"),u[j.key]=qO({schema:j.schema,context:t,fileContainingReference:r,namespace:n}));for(let j of O.allOf){if(f.has(j.schema))continue;let A=qO({schema:J0.reference(j),context:t,fileContainingReference:r,namespace:n});c.push(gx(A))}}let o={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(u).map(([m,O])=>aBj(m)?[m,typeof O=="string"?{type:O,name:`_${m}`}:{...O,name:`_${m}`}]:[m,O]))};c.length>0&&(o.extends=c),e.additionalProperties&&(o["extra-properties"]=!0),e.availability!=null&&(o.availability=gz(e.availability)),e.source!=null&&(o.source=lSr(e.source));let l=e.nameOverride??e.generatedName;return{name:a&&t.respectReadonlySchemas&&!i?`${l}Read`:l,schema:o}}function Jyu({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return Jyu({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:u}=Qyu(r,t,n),f=a.some(c=>c.key===e),d=[...u.flatMap(c=>Jyu({property:e,context:r,schemaId:c.schema,namespace:n}))];if(f||d.length>0)return[t,...d]}return[]}function Qyu(e,t,r){let n=e.getSchema(t,r);if(n==null)return{properties:[],allOf:[]};if(n.type==="object")return{properties:n.properties,allOf:n.allOf};if(n.type==="reference")return Qyu(e,n.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${n.type}`)}function X2j({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Fyu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function Z2j({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Ryu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function k2j(e){let t=uma(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...n}=t;return{name:e.nameOverride??e.generatedName,schema:{...n}}}function QDf(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function Lhi(e){let t={enum:e.values.map(i=>{let a=i.nameOverride??i.generatedName,u=i.value;if(a===u&&i.description==null&&(i.casing==null||QDf(i.casing)))return a;let f={value:i.value};if(a!==u&&(f.name=a),i.description!=null&&(f.docs=i.description),i.casing!=null&&!QDf(i.casing)){let d={},c=!1;i.casing.camel!=null&&(d.camel=i.casing.camel,c=!0),i.casing.screamingSnake!=null&&(d["screaming-snake"]=i.casing.screamingSnake,c=!0),i.casing.snake!=null&&(d.snake=i.casing.snake,c=!0),i.casing.pascal!=null&&(d.pascal=i.casing.pascal,c=!0),c&&(f.casing=d)}return f})};e.description!=null&&(t.docs=e.description),e.default!=null&&(t.default=e.default.value);let r=new Set,n={...t,enum:[],source:e.source!=null?lSr(e.source):void 0};for(let i of t.enum){let a=typeof i=="string"?i:i.name??i.value;r.has(a.toLowerCase())||(n.enum.push(i),r.add(a.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function eBj({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Nyu({schema:e,context:t,fileContainingReference:r,namespace:n})}}function tBj({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Lyu({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n})}}function rBj(e,t){return{name:e??t,schema:Uyu()}}function nBj(e,t,r){return{name:t??r,schema:Vyu(e)}}function Hyu({schema:e,context:t,declarationFile:r,namespace:n}){let i=e.encoding!=null?oma(e.encoding):void 0;if(e.type==="discriminated"){let u={};for(let d of e.commonProperties)u[d.key]=qO({schema:d.schema,fileContainingReference:r,context:t,namespace:n});let f={};for(let[d,c]of Object.entries(e.schemas))f[d]=qO({schema:c,context:t,fileContainingReference:r,namespace:n});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":u,docs:e.description??void 0,availability:e.availability!=null?gz(e.availability):void 0,union:f,encoding:i,source:e.source!=null?lSr(e.source):void 0}}}let a=[];for(let u of e.schemas)a.push(qO({schema:u,fileContainingReference:r,context:t,namespace:n}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:a,encoding:i,source:e.source!=null?lSr(e.source):void 0}}}var iBj=/^[0-9]/;function aBj(e){return iBj.test(e)}function $Df({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?$Df({context:t,schema:n.schema,namespace:r}):e}function oBj(e,t,r,n){return t.length===0&&r==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{}}}function KDf(e){let t=e.replace(/^x-|^X-/,"");return mE(t)}var YDf="BasicAuthScheme",cma="BearerAuthScheme";function XDf(e){if(e.authOverrides!=null){for(let[r,n]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:n});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,n]of Object.entries(e.ir.securitySchemes))if(n.type==="basic"){let i={scheme:"basic"};n.usernameVariableName!=null&&(i.username===void 0?i.username={name:n.usernameVariableName}:i.username.name=n.usernameVariableName),n.usernameEnvVar!=null&&(i.username===void 0?i.username={env:n.usernameEnvVar}:i.username.env=n.usernameEnvVar),n.passwordVariableName!=null&&(i.password===void 0?i.password={name:n.passwordVariableName}:i.password.name=n.passwordVariableName),n.passwordEnvVar!=null&&(i.password===void 0?i.password={env:n.passwordEnvVar}:i.password.env=n.passwordEnvVar),e.builder.addAuthScheme({name:YDf,schema:i}),t||(e.builder.setAuth(YDf),t=!0)}else if(n.type==="bearer"){let i={scheme:"bearer"};n.tokenVariableName!=null&&(i.token===void 0?i.token={name:n.tokenVariableName}:i.token.name=n.tokenVariableName),n.tokenEnvVar!=null&&(i.token===void 0?i.token={env:n.tokenEnvVar}:i.token.env=n.tokenEnvVar),e.builder.addAuthScheme({name:cma,schema:i}),t||(e.builder.setAuth(cma),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??KDf(n.headerName),env:n.headerEnvVar}});else{let i={header:n.headerName,name:n.headerVariableName??"apiKey",type:"string"};n.headerEnvVar!=null&&(i.env=n.headerEnvVar),n.prefix!=null&&(i.prefix=n.prefix),e.builder.addAuthScheme({name:r,schema:i}),e.builder.setAuth(r),t=!0}else if(n.type==="oauth"){let i={scheme:"bearer"};e.builder.addAuthScheme({name:cma,schema:i}),t||(e.builder.setAuth(cma),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(ls.of("__package__.yml"),{name:"OauthScope",schema:Lhi(n.scopesEnum).schema})}}function b8t({header:e,context:t,fileContainingReference:r,namespace:n}){let i=qO({schema:e.schema,context:t,fileContainingReference:r,namespace:n}),a=gx(i),u=e.name.replace(/^x-|^X-/,""),f=e.parameterNameOverride!=null?e.parameterNameOverride:mE(u);if(e.description==null&&e.name===f&&e.env==null&&e.availability==null)return a;let d={type:a};return f!==e.name&&(d.name=f),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=gz(e.availability)),d}function lma({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=qO({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(e.variableReference==null&&e.description==null&&e.availability==null)return gx(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:gx(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=gz(e.availability)),a}var zju=require("fs/promises");var ZDf={naming:"v1"};function B_(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function Uhi(e,t,r,n,i=[]){try{let a=B_(e,t);if(a!=null)return r.parse(a)}catch{let u=m6t(i).join(" -> ");n.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}var fma={of(e){return e}};var wh={SDK_METHOD_NAME:fma.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:fma.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:fma.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport"};function Kh(e){return e.$ref!=null}function jxe(e){switch(B_(e,wh.AVAILABILITY)){case"deprecated":return _W.Deprecated;case"beta":return _W.Beta;case"generally-available":return _W.GenerallyAvailable;default:break}if(!Kh(e)&&e.deprecated)return _W.Deprecated}var Ewe={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};function uen(e){let t=B_(e,"examples");return t!=null&&Array.isArray(t)?t:[]}function kDf({schema:e,logger:t}){return B_(e,wh.ENCODING)??void 0}function eSf(e){return B_(e,wh.FERN_ENUM)}function tSf({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:a}){let u=B_(n,wh.SDK_GROUP_NAME),f=B_(n,wh.TYPE_DEFINITION);if(f!=null)return Vhi({fernType:f,nameOverride:e,generatedName:t,title:r,description:i,availability:a,groupName:typeof u=="string"?[u]:u})}function Vhi({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u}){return QQ({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.base64({example:void 0})});case"BOOLEAN":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.boolean({default:void 0,example:void 0})});case"DATE":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.date({example:void 0})});case"DATE_TIME":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.datetime({example:void 0})});case"FLOAT":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.float({example:void 0})});case"DOUBLE":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.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 Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.uint({default:void 0,example:void 0})});case"INTEGER":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.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 Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.uint64({default:void 0,example:void 0})});case"LONG":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:sc(f.v1)}},unknown:()=>Op.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:a,groupName:u}),map:({keyType:f,valueType:d})=>f?.type==="primitive"&&d!=null?Op.map({nameOverride:t,generatedName:r,title:n,key:f,value:d,description:i,availability:a,groupName:u,encoding:void 0,example:void 0}):void 0,list:f=>f!=null?Op.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,optional:f=>f!=null?Op.optional({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u}):void 0,set:f=>f!=null?Op.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,literal:f=>Op.literal({nameOverride:t,generatedName:r,title:n,value:f._visit({string:d=>_I.string(d),boolean:d=>_I.boolean(d),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:a,groupName:u}),named:()=>{}}})}function sen(e){if(e!=null&&typeof e=="boolean")return e}function rSf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,encoding:l,source:m,namespace:O}){return typeof i=="boolean"||I7n(i)?dma({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:ty.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Op.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:void 0}),groupName:c,example:o,encoding:l}):dma({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:ty.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:aP(i,d.options.optionalAdditionalProperties?f:!1,d,[...n,"Value"],m,O),groupName:c,example:o,encoding:l})}function dma({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsNullable:a,description:u,availability:f,groupName:d,example:c,encoding:o}){return a?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.map({nameOverride:e,generatedName:t,title:r,description:u,availability:n.availability,key:n,value:i,groupName:d,encoding:o,example:c}),description:u,availability:f,groupName:d}):Op.map({nameOverride:e,generatedName:t,title:r,description:u,availability:f,key:n,value:i,groupName:d,encoding:o,example:c})}function I7n(e){return e==null?!1:typeof e=="boolean"?e:!Kh(e)&&Object.keys(e).length===0}function nSf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,source:l,namespace:m}){let O=i==null?Op.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,groupName:c}):aP(i,!1,d,[...n,"Item"],l,m);return uBj({nameOverride:e,generatedName:t,title:r,groupName:c,itemSchema:O,wrapAsNullable:f,description:a,availability:u,example:o})}function uBj({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsNullable:i,description:a,availability:u,groupName:f,example:d}){return i?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d}),description:a,availability:u,groupName:f}):Op.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d})}function Gyu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminator:c,context:o,groupName:l,encoding:m,source:O,namespace:j}){let A=c.propertyName,T=Object.fromEntries(Object.entries(c.mapping??{}).map(([F,C])=>{let N=z7n({$ref:C},!1,o,[C],m,O,j);return o.markReferencedByDiscriminatedUnion({$ref:C},A,1),[F,N]})),B=Object.entries(i).filter(([F])=>F!==A).map(([F,C])=>{let N=f!=null&&f.includes(F),U=aP(C,!N,o,[...n,F],O,j);return{key:F,schema:U}});return iSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:B,description:a,availability:u,discriminant:A,subtypes:T,groupName:l,source:O})}function $yu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminant:c,variants:o,context:l,groupName:m,encoding:O,source:j,namespace:A}){let T=Object.fromEntries(Object.entries(o).map(([F,C])=>{if(Kh(C)){let N=z7n(C,!1,l,[C.$ref],O,j,A);return l.markReferencedByDiscriminatedUnion(C,c,1),[F,N]}else{let N=t3r(C,!1,l,[...n,F],O,j,A,new Set([c]));return[F,N]}})),B=Object.entries(i).filter(([F])=>F!==c).map(([F,C])=>{let N=f!=null&&f.includes(F),U=aP(C,!N,l,[...n,F],j,A);return{key:F,schema:U}});return iSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:B,description:a,availability:u,discriminant:c,subtypes:T,groupName:m,source:j})}function iSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,availability:u,discriminant:f,subtypes:d,groupName:c,source:o}){return n?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.oneOf(SX.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o})),groupName:c,description:a,availability:u}):Op.oneOf(SX.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o}))}function aSf(e){if(e.proto!=null)return o7n.protobuf({typeName:e.proto.type})}var sBj=/^(\d+)/;function pma(e){let t=e.match(sBj);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=N7n(i);return n.length>0?`${a}_${n}`:a}}}function N7n(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),f=e%10;return f===0?n[u]:`${n[u]}_${t[f]}`}if(e<1e3){let u=Math.floor(e/100),f=e%100;return f===0?`${t[u]}_hundred`:`${t[u]}_hundred_${N7n(f)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${N7n(a)}`}var F7n=/^[a-zA-Z][a-zA-Z0-9_]*$/;function r3r({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:a,_default:u,description:f,availability:d,wrapAsNullable:c,groupName:o,context:l,source:m}){let O=fBj(i??[]),j=new Set(a),A=Array.from(j).map((B,F)=>{let C=n?.[B],N=O[F],U=F7n.test(B),ne=C?.name??N,ge=U?B:Whi(B);return ne!=null&&!F7n.test(ne)&&(l?.logger.warn(`Enum name override ${ne} is not a valid name. Falling back on ${ge}.`),ne=void 0),{nameOverride:ne,generatedName:ge,value:B,description:C?.description,availability:d,casing:{snake:C?.casing?.snake??void 0,pascal:C?.casing?.pascal??void 0,screamingSnake:C?.casing?.screamingSnake??void 0,camel:C?.casing?.camel??void 0}}}),T=u!=null?A.find(B=>B.value===u):void 0;return cBj({wrapAsNullable:c,nameOverride:e,generatedName:t,title:r,values:A,_default:T,description:f,availability:d,groupName:o,source:m})}function cBj({wrapAsNullable:e,nameOverride:t,generatedName:r,title:n,values:i,_default:a,description:u,availability:f,groupName:d,source:c}){return e?Op.nullable({nameOverride:t,generatedName:r,title:n,value:Op.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,default:a,availability:f,example:void 0,groupName:d,source:c}),description:u,availability:f,groupName:d}):Op.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,availability:f,default:a,example:void 0,groupName:d,source:c})}var lBj={"<":"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 Whi(e){let t=pma(e),r=lBj[e];return t!=null?wV(mE(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":wV(mE(e)))}function fBj(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(n=>n[r]===t[r]);)r++;return e.map(n=>n.substring(r))}function oSf({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:m,example:O,groupName:j}){return n==="int64"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.int64({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="uint32"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.uint({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="uint64"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.uint64({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):X9({nameOverride:e,generatedName:t,title:r,primitive:ty.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j})}function uSf(e){return typeof e=="string"?_I.string(e):typeof e=="boolean"?_I.boolean(e):_I.string(`${e}`)}function sSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,value:i,description:a,availability:u,groupName:f}){return n?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.literal({nameOverride:e,generatedName:t,title:r,value:uSf(i),description:a,availability:u,groupName:f}),description:a,availability:u,groupName:f}):Op.literal({nameOverride:e,generatedName:t,title:r,value:uSf(i),description:a,availability:u,groupName:f})}function Kyu({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:m,example:O,groupName:j}){return n==null||n==="double"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.double({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="float"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.float({example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="int32"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="int64"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.int64({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="uint32"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.uint({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="uint64"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.uint64({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="time-delta"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.float({example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):X9({nameOverride:e,generatedName:t,title:r,primitive:ty.float({example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j})}var dBj={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},pBj={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}}},_Bj={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}}},hBj={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},yBj={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},vBj={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},bBj={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},gBj={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function _ma(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[dBj,pBj,_Bj,hBj,yBj,vBj,bBj,gBj],i;do{i=t;for(let a of n)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:f}=a.applyStrategy(t);t=u,r=[...r,...f]}}while(t.join("")!==i.join(""));return r}function b8(e){let t=e.join("_"),r=wV(mE(t));return/^\d/.test(r)?pma(r)??r:r}function Yyu(e){let t=e.join("_");return mE(t)}function mx(e){switch(e.type){case"object":return J0.object({allOf:e.allOf,properties:e.properties.map(t=>OBj(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return J0.array({description:e.description,availability:e.availability,value:mx(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"enum":return J0.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,groupName:e.groupName,source:e.source});case"literal":return J0.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"nullable":return J0.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:mx(e.value),groupName:e.groupName});case"optional":return J0.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:mx(e.value),groupName:e.groupName});case"primitive":return J0.primitive({description:e.description,availability:e.availability,schema:cSf(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return J0.map({description:e.description,availability:e.availability,key:J0.primitive({description:e.key.description,availability:e.key.availability,schema:cSf(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:mx(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,encoding:e.encoding});case"reference":return J0.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,groupName:e.groupName,source:e.source});case"oneOf":return J0.oneOf(mBj(e.value));case"unknown":return J0.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:sc(e)}}function mBj(e){switch(e.type){case"discriminated":return cSr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:mx(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,mx(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return cSr.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>mx(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:sc(e)}}function cSf(e){switch(e.type){case"string":return q1.string(e);case"base64":return q1.base64();case"boolean":return q1.boolean(e);case"date":return q1.date();case"datetime":return q1.datetime();case"double":return q1.double(e);case"float":return q1.float();case"int":return q1.int(e);case"int64":return q1.int64(e);case"uint":return q1.uint();case"uint64":return q1.uint64();default:sc(e)}}function OBj(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:mx(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly}}function hma(e,t){return Awe(mx(e),mx(t))}function Awe(e,t){return e.type==="primitive"&&t.type==="primitive"?lSf(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?PBj(e.values,t.values):e.type==="array"&&t.type==="array"?Awe(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"?Awe(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?jBj(e.value,t.value):e.type==="object"&&t.type==="object"?wBj(e,t):e.type==="map"&&t.type==="map"?lSf(e.key.schema,t.key.schema)&&Awe(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function lSf(e,t){return e.type===t.type}function PBj(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return zqt(r,n)}function jBj(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,n])=>{let i=t.schemas[r];return i==null?!1:Awe(n,i)}):e.type==="undisciminated"&&t.type==="undisciminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:Awe(r,i)}):!1}function wBj(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(n=>[n.key,n.schema]));return Object.entries(t.properties).every(([n,i])=>{let a=r[n];return a==null?!1:Awe(a,i.schema)})}function fSf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,required:u,wrapAsNullable:f,allOf:d,context:c,propertiesToExclude:o,groupName:l,fullExamples:m,additionalProperties:O,availability:j,encoding:A,source:T,namespace:B}){let F=[...u??[]],C={...i},N=[],U=[];for(let k of d)if(Kh(k)){let xe=c.resolveSchemaReference(k);if(xe.discriminator!=null&&xe.discriminator.mapping!=null)continue;if(xe.oneOf!=null){for(let yt of xe.oneOf){let St=Kh(yt)?c.resolveSchemaReference(yt):yt,Ft=aP(St,!1,c.DUMMY,n,T,B);Ft.type==="object"&&N.push(...Ft.properties.map(Zt=>Zt.schema.type!=="optional"&&Zt.schema.type!=="nullable"?{...Zt,schema:Op.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Zt.schema,description:void 0,availability:Zt.availability,groupName:void 0})}:Zt))}continue}let vt=n3r(k);if(vt==null)continue;U.push({schemaId:vt,convertedSchema:Xyu(k,[vt],T),properties:dSf({schema:k,context:c,breadcrumbs:n,source:T,namespace:B})}),c.markSchemaAsReferencedByNonRequest(vt)}else{let xe=aP(k,!1,c,n,T,B);xe.type==="object"&&N.push(...xe.properties)}let ne={};for(let k of U)for(let[xe,vt]of Object.entries(k.properties)){let yt=ne[xe];yt!=null?(yt.schemaIds.push(k.schemaId),yt.schemas.some(Ft=>hma(Ft,vt))||yt.schemas.push(vt)):ne[xe]={schemaIds:[k.schemaId],schemas:[vt]}}let ge=[];for(let[k,xe]of Object.entries(ne))xe.schemaIds.length>1&&ge.push({propertyKey:k,allOfSchemaIds:xe.schemaIds,conflictingTypeSignatures:xe.schemas.length>1});let X=Object.entries(C).map(([k,xe])=>{let vt=F.includes(k),yt=B_(xe,wh.AUDIENCES)??[],St=jxe(xe),Ft=Kh(xe)?!1:xe.readOnly,Zt=B_(xe,wh.FERN_PROPERTY_NAME),Vt=[...n,k],cr=Yyu(Vt),Wr=vt?aP(xe,!1,c,Vt,T,B):Op.optional({nameOverride:e,generatedName:cr,title:r,description:void 0,availability:St,value:aP(xe,!1,c,Vt,T,B),groupName:l}),gn={};for(let Kt of U){let Mr=Kt.properties[k];Mr!=null&&!hma(Wr,Mr)?gn[Kt.schemaId]={differentSchema:!0}:Mr!=null&&(gn[Kt.schemaId]={differentSchema:!1})}return{key:k,schema:Wr,nameOverride:Zt,audiences:yt,conflict:gn,generatedName:Yyu([...n,k]),availability:St,readonly:Ft}});return X.push(...N.map(k=>{let xe=k.conflict;for(let vt of U){let yt=vt.properties[k.key];yt!=null&&!hma(k.schema,yt)?xe[vt.schemaId]={differentSchema:!0}:yt!=null&&(xe[vt.schemaId]={differentSchema:!1})}return{...k,conflict:xe}})),DBj({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,properties:X.filter(k=>!o.has(k.key)),description:a,allOf:U.map(k=>k.convertedSchema),allOfPropertyConflicts:ge,groupName:l,fullExamples:m,additionalProperties:O,availability:j,source:T})}function DBj({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:o,availability:l,source:m}){return n?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:I7n(o),availability:void 0,source:m}),description:a,availability:l,groupName:d}):Op.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:I7n(o),availability:l,source:m})}function dSf({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[u,f]=Kh(e)?[t.resolveSchemaReference(e),_ma(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...dSf({schema:d,context:t,breadcrumbs:f,source:n,namespace:i})};for(let[d,c]of Object.entries(u.properties??{})){let o=aP(c,!1,t,[...f,d],n,i);a[d]=o}return a}function R7n({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:a,wrapAsNullable:u,context:f,subtypes:d,groupName:c,encoding:o,source:l,subtypePrefixOverrides:m,namespace:O}){let j=SBj({schemas:d}),A=d.flatMap((F,C)=>{if(!Kh(F)&&F.enum!=null&&f.options.cooerceEnumsToLiterals)return F.enum.map(U=>Op.literal({nameOverride:void 0,generatedName:b8([t,U]),title:void 0,value:_I.string(U),groupName:void 0,description:void 0,availability:U.availability}));let N=j[C];if(m!=null){let U=m[C];U!=null&&"name"in U&&(N=U.name)}return[aP(F,!1,f,[...n,N??`${C}`],l,O)]}),T=[];for(let F=0;F<A.length;++F){let C=A[F],N=!1;for(let U=F+1;U<A.length;++U){let ne=A[U];if(C!=null&&ne!=null&&Awe(C,ne)){N=!0;break}}C!=null&&!N&&T.push(C)}if(Object.entries(T).every(([F,C])=>C.type==="literal")){let F={},C=[];return Object.entries(T).forEach(([N,U])=>{U.type==="literal"&&U.value.type==="string"&&(C.push(U.value.value),U.description!=null&&(F[U.value.value]={description:U.description}))}),r3r({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,fernEnum:F,enumVarNames:void 0,enumValues:C,_default:void 0,groupName:c,context:f,source:l})}return T.length===1&&T[0]!=null?T[0]:pSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,subtypes:T,groupName:c,encoding:o,source:l})}function Zyu({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsNullable:a,context:u,groupName:f,discriminator:d,encoding:c,source:o,namespace:l}){let m=Object.entries(d.mapping??{}).map(([A,T],B)=>{let F={$ref:T},C=z7n(F,!1,u,[T],c,o,l);return u.markSchemaWithDiscriminantValue(F,d.propertyName,A),C.type==="object"&&(C.properties={[d.propertyName]:Op.literal({nameOverride:void 0,generatedName:b8([t,A]),title:void 0,value:_I.string(A),groupName:void 0,description:void 0,availability:void 0}),...C.properties.filter(N=>N.key!==d.propertyName)}),C}),O=[];for(let A=0;A<m.length;++A){let T=m[A],B=!1;for(let F=A+1;F<m.length;++F){let C=m[F];if(T!=null&&C!=null&&Awe(T,C)){B=!0;break}}T!=null&&!B&&O.push(T)}if(Object.entries(O).every(([A,T])=>T.type==="literal")){let A={},T=[];return Object.entries(O).forEach(([B,F])=>{F.type==="literal"&&F.value.type==="string"&&(T.push(F.value.value),F.description!=null&&(A[F.value.value]={description:F.description}))}),r3r({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,fernEnum:A,enumVarNames:void 0,enumValues:T,_default:void 0,groupName:f,context:u,source:o})}return O.length===1&&O[0]!=null?O[0]:pSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,subtypes:O,groupName:f,encoding:c,source:o})}function SBj({schemas:e}){let t={},r=0;for(let a of e){if(!Kh(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),f={},d=u;for(let[c,o]of Object.entries(t)){let l=gJi(o,u);d=gJi(d,o),f[c]=l}f[r]=d,t=f}}r++}let n=[],i=0;for(let a of e){let u=t[i];if(u!=null&&u.length>0){let f=u.sort();if(f[0]!=null){n.push(f[0]),++i;continue}}Kh(a)?n.push(N7n(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(N7n(i)??`${i}`),++i}return n}function pSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,description:i,availability:a,subtypes:u,groupName:f,encoding:d,source:c}){return n?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.oneOf(SX.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c})),description:i,availability:a,groupName:f}):Op.oneOf(SX.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c}))}function L7n(e){if(e.default!=null&&typeof e.default=="string")return e.default}function yma({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let n=uen(e);for(let i of n??[])if(typeof i=="number")return i;if(r&&typeof r=="number")return r}function _Sf({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let n=uen(e);for(let i of n??[])if(typeof i=="boolean")return i;if(r&&typeof r=="boolean")return r}function fSr({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let n=uen(e);for(let i of n??[])if(typeof i=="string")return i;if(r&&typeof r=="string")return r}function hSf({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let n=uen(e);for(let i of n??[])if(Array.isArray(i))return i;if(r&&Array.isArray(r))return r}var cen="#/components/schemas/";function aP(e,t,r,n,i,a,u=!1,f=new Set,d){let c=CBj({schema:e,logger:r.logger});if(Kh(e)){let o=n3r(e);return o!=null?(u?r.markSchemaAsReferencedByRequest(o):r.markSchemaAsReferencedByNonRequest(o),z7n(e,t,r,n,c,i,a)):t3r(r.resolveSchemaReference(e),t,r,_ma(e.$ref),c,i,a,f,u,d)}return t3r(e,t,r,n,c,i,a,f,u,d)}function z7n(e,t,r,n,i,a,u){let f=e.$ref.includes("properties")?t3r(r.resolveSchemaReference(e),t,r,n,i,a,u,new Set):Op.reference(Xyu(e,n,a));return t?Op.nullable({title:void 0,nameOverride:void 0,generatedName:b8(n),value:f,description:void 0,availability:void 0,groupName:void 0}):f}function EBj(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function t3r(e,t,r,n,i,a,u,f=new Set,d=!1,c){let o=B_(e,wh.TYPE_NAME)??(r.options.useTitlesAsName?EBj(e.title):void 0),l=B_(e,wh.SDK_GROUP_NAME)??B_(e,Ewe.TAGS)?.[0],m=(typeof l=="string"?[l]:l)??[];m=r.resolveGroupName(m);let O=b8(n),j=e.title,A=e.description,T=jxe(e),B=[];e.example!=null&&B.push({name:void 0,value:e.example,description:void 0});let F=B_(e,Ewe.EXAMPLES);F!=null&&Object.keys(F).length>0&&B.push(...Object.entries(F).map(([U,ne])=>({name:ne?.summary??U,value:ne.value,description:ne.description})));let C=uen(e);C!=null&&Object.keys(C).length>0&&B.push(...C.map(U=>({name:void 0,value:U,description:void 0})));let N=tSf({schema:e,description:A,title:j,nameOverride:o,generatedName:O,availability:T});if(N!=null)return N;if(!t&&e.nullable===!0)return t3r(e,!0,r,n,i,a,u,f,d,c);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!Hhi(e.enum))return X9({nameOverride:o,generatedName:O,title:j,primitive:ty.string({default:L7n(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:fSr({schema:e,logger:r.logger,fallback:c})}),groupName:m,wrapAsNullable:t,description:A,availability:T});let U=eSf(e);return e.enum.length===1&&e.enum[0]!=null&&U==null?sSf({nameOverride:o,generatedName:O,title:j,wrapAsNullable:t,value:e.enum[0],description:A,availability:T,groupName:m}):r3r({nameOverride:o,generatedName:O,title:j,fernEnum:U,enumVarNames:B_(e,[Ewe.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:A,availability:T,wrapAsNullable:t,groupName:m,context:r,source:a})}if(Hhi(e.type)&&e.type[1]!=null&&e.type[0]!=null){let U=e.type[0],ne=e.type[1];if(U==="null")return Op.nullable({nameOverride:o,generatedName:O,title:j,value:t3r({...e,type:ne},t,r,n,i,a,u,f,d,c),groupName:m,description:e.description,availability:T});if(ne==="null")return Op.nullable({nameOverride:o,generatedName:O,title:j,value:t3r({...e,type:U},t,r,n,i,a,u,f,d,c),groupName:m,description:e.description,availability:T})}if(Hhi(e.type)&&e.type.length>1){let U=e.type.includes("null"),ne=e.type.filter(ge=>ge!=="null").map(ge=>({type:ge,nullable:U}));return R7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,wrapAsNullable:t,context:r,subtypes:ne,groupName:m,encoding:i,source:a,namespace:u})}if(e==="boolean"||e.type==="boolean"){let U=B_(e,wh.BOOLEAN_LITERAL);return U!=null?vSf({nameOverride:o,generatedName:O,title:j,literal:_I.boolean(U),wrapAsNullable:t,description:A,availability:T,groupName:m}):X9({nameOverride:o,generatedName:O,title:j,primitive:ty.boolean({default:e.default,example:_Sf({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:A,availability:T,groupName:m})}if(e==="number"||e.type==="number")return Kyu({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:sen(e.exclusiveMinimum),exclusiveMaximum:sen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:T,wrapAsNullable:t,example:yma({schema:e,logger:r.logger,fallback:c}),groupName:m});if(e==="integer"||e.type==="integer")return oSf({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:sen(e.exclusiveMinimum),exclusiveMaximum:sen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:T,wrapAsNullable:t,example:yma({schema:e,logger:r.logger,fallback:c}),groupName:m});if(e==="float")return Kyu({nameOverride:o,generatedName:O,title:j,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:sen(e.exclusiveMinimum),exclusiveMaximum:sen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:T,wrapAsNullable:t,example:yma({schema:e,logger:r.logger,fallback:c}),groupName:m});if(e==="string"||e.type==="string"){if(e.format==="date-time")return X9({nameOverride:o,generatedName:O,title:j,primitive:ty.datetime({example:fSr({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:A,availability:T,groupName:m});if(e.format==="json-string")return Op.unknown({nameOverride:o,generatedName:O,title:j,description:A,availability:T,groupName:m,example:void 0});let U=mSf(e,"const");return U!=null?vSf({nameOverride:o,generatedName:O,title:j,literal:_I.string(U),wrapAsNullable:t,description:A,availability:T,groupName:m}):X9({nameOverride:o,generatedName:O,title:j,primitive:ty.string({default:L7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:fSr({schema:e,logger:r.logger,fallback:c})}),groupName:m,wrapAsNullable:t,description:A,availability:T})}if(e.type==="array")return nSf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,item:e.items,description:A,availability:T,wrapAsNullable:t,context:r,groupName:m,example:hSf({schema:e,logger:r.logger,fallback:c}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&ySf(e))return rSf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,additionalProperties:e.additionalProperties,description:A,availability:T,wrapAsNullable:t,context:r,groupName:m,encoding:i,example:e.example,source:a,namespace:u});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?Zyu({nameOverride:o,generatedName:O,title:j,description:A,availability:T,wrapAsNullable:t,context:r,groupName:m,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):Gyu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:m,encoding:i,source:a,namespace:u});if(Array.isArray(e.type)&&(e.oneOf==null?e.oneOf=e.type:e.oneOf.push(...e.type)),e.oneOf!=null&&e.oneOf.length>0){let U=B_(e,wh.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||U?Zyu({nameOverride:o,generatedName:O,title:j,description:A,availability:T,wrapAsNullable:t,context:r,groupName:m,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):Gyu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:m,encoding:i,source:a,namespace:u});if(e.oneOf.length===1&&e.oneOf[0]!=null){let ne=aP(e.oneOf[0],t,r,n,a,u,d);return U7n(ne,A,m)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let k=e.oneOf[0],xe=e.oneOf[1];if(!Kh(k)&&k.type==="null")return aP(xe,!0,r,n,a,u);if(!Kh(xe)&&xe.type==="null")return aP(k,!0,r,n,a,u)}let ne=TBj({schemas:e.oneOf});if(ne!=null)return r3r({nameOverride:o,generatedName:O,title:j,fernEnum:void 0,enumVarNames:void 0,enumValues:ne,_default:e.default,description:A,availability:T,wrapAsNullable:t,groupName:m,context:r,source:a});let ge=bSf({schemas:e.oneOf,context:r});if(ge!=null&&!r.options.discriminatedUnionV2&&!U)return $yu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},required:e.required,description:A,availability:T,wrapAsNullable:t,discriminant:ge.discriminant,variants:ge.schemas,context:r,groupName:m,encoding:i,source:a,namespace:u});let X=e.oneOf.filter(k=>!Kh(k)&&k.type==="null").length>0;return R7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,wrapAsNullable:t||X,context:r,subtypes:e.oneOf.filter(k=>Kh(k)||k.type!=="null"),encoding:i,groupName:m,source:a,namespace:u})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let ge=aP(e.anyOf[0],t,r,n,a,u,d);return U7n(ge,A,m)}if(e.anyOf.length===2){let[ge,X]=e.anyOf;if(ge!=null&&X!=null){if(!Kh(ge)&&ge.type==="null"){let k=aP(X,!0,r,n,a,u);return U7n(k,A,m)}else if(!Kh(X)&&X.type==="null"){let k=aP(ge,!0,r,n,a,u);return U7n(k,A,m)}}}let U=bSf({schemas:e.anyOf,context:r});if(U!=null&&!r.options.discriminatedUnionV2)return $yu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},required:e.required,description:A,availability:T,wrapAsNullable:t,discriminant:U.discriminant,variants:U.schemas,context:r,groupName:m,encoding:i,source:a,namespace:u});let ne=e.anyOf.filter(ge=>!Kh(ge)&&ge.type==="null").length>0;return R7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,wrapAsNullable:t||ne,context:r,subtypes:e.anyOf.filter(ge=>Kh(ge)||ge.type!=="null"),encoding:i,groupName:m,source:a,namespace:u})}if(e.allOf!=null||e.properties!=null){let U=[];for(let ge of e.allOf??[])(Kh(ge)||Object.keys(ge).length>0)&&U.push(ge);if((e.properties==null||e.properties.length===0)&&U.length===1&&U[0]!=null){let ge=aP(U[0],t,r,n,a,u,d);return U7n(ge,A,m)}let ne=U.filter(ge=>{let X=vma(ge);return X||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify(ge)}`),X});if((e.properties==null||e.properties.length===0)&&ne.length===1&&ne[0]!=null){let ge=aP(ne[0],t,r,n,a,u,d);return U7n(ge,A,m)}return fSf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},description:A,required:e.required,wrapAsNullable:t,allOf:ne,context:r,propertiesToExclude:f,groupName:m,fullExamples:B,additionalProperties:e.additionalProperties,availability:T,encoding:i,source:a,namespace:u})}if(e.type==="object"&&ABj(e)&&MBj(e)&&ySf(e))return dma({nameOverride:o,generatedName:O,title:j,description:A,availability:T,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${O}Key`,title:void 0,description:void 0,availability:void 0,schema:ty.string({default:L7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:fSr({schema:e,logger:r.logger,fallback:c})}),groupName:m},valueSchema:Op.unknown({nameOverride:void 0,generatedName:`${O}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:m}),groupName:m,encoding:i,example:e.example});if(e.type==null){let U=e.example??e.default;return Op.unknown({nameOverride:o,generatedName:O,title:j,description:A,availability:T,groupName:m,example:U})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(n)} value=${JSON.stringify(e)}`)}function n3r(e){if(e.$ref.startsWith(cen))return e.$ref.replace(cen,"")}function Xyu(e,t,r){let n=B_(e,wh.TYPE_NAME),i=b8(t),a=e.description,u=jxe(e),f=n3r(e);if(f==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return J0.reference({generatedName:i,nameOverride:n,title:void 0,schema:f,description:a??void 0,availability:u,groupName:void 0,source:r})}function ABj(e){return e.oneOf==null||e.oneOf.length===0}function MBj(e){return e.allOf==null||e.allOf.length===0}function ySf(e){return e.properties==null||Object.keys(e.properties).length===0}function Hhi(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function U7n(e,t,r){return e.type==="reference"?Op.reference({...e,description:t,availability:e.availability,groupName:r}):e.type==="optional"?Op.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e.type==="nullable"?Op.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e}function vma(e){return Kh(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>vma(t)):e.oneOf!=null?e.oneOf.every(t=>vma(t)):e.anyOf!=null?e.anyOf.every(t=>vma(t)):!1}function vSf({literal:e,wrapAsNullable:t,groupName:r,description:n,availability:i,nameOverride:a,generatedName:u,title:f}){return t?Op.nullable({nameOverride:a,generatedName:u,title:f,value:Op.literal({nameOverride:a,generatedName:u,title:f,value:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Op.literal({nameOverride:a,generatedName:u,title:f,value:e,groupName:r,description:n,availability:i})}function X9({primitive:e,wrapAsNullable:t,groupName:r,description:n,availability:i,generatedName:a,nameOverride:u,title:f}){return r=typeof r=="string"?[r]:r,t?Op.nullable({nameOverride:u,generatedName:a,title:f,value:Op.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Op.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r})}function TBj({schemas:e}){let t=new Set;for(let r of e){if(Kh(r))return;if(r.enum!=null&&Hhi(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function bSf({schemas:e,context:t}){let r={};for(let n of e){let i=gSf({schema:n,context:t});for(let[a,u]of Object.entries(i)){let f=r[a];f!=null?f[u]=n:r[a]={[u]:n}}}for(let[n,i]of Object.entries(r))if(Object.keys(i).length===e.length)return{discriminant:n,schemas:i}}function gSf({schema:e,context:t}){let r=Kh(e)?t.resolveSchemaReference(e):e;return xBj({schema:r,context:t})}function xBj({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=gSf({schema:n,context:t});for(let[a,u]of Object.entries(i??{}))r[a]=u}return r}for(let[n,i]of Object.entries(e.properties??{})){let a=Kh(i)?t.resolveSchemaReference(i):i;a.type==="string"&&a.enum!=null&&Hhi(a.enum)&&qBj(a.enum).length===1&&a.enum[0]!=null&&(r[n]=a.enum[0]);let u=mSf(a,"const");a.type==="string"&&u!=null&&(r[n]=u),n==="type"&&a.example!=null&&(r[n]=a.example)}return r}function qBj(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 mSf(e,t){let r=e[t];if(r!=null)return r}function CBj({schema:e,logger:t}){let r=kDf({schema:e,logger:t});if(r!=null)return aSf(r)}function bma(e,t){let r={},n={};return e==null?r=t:n={[e]:t},{rootSchemas:r,namespacedSchemas:n}}var OSf="#/components/messages/",kyu=class{logger;document;taskContext;DUMMY;options;namespace;constructor({document:t,taskContext:r,options:n,namespace:i}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=n,this.namespace=i}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let n=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};n.push(i)}return n.concat(t??[])}resolveSchemaReference(t){if(this.document.components==null||this.document.components.schemas==null||!t.$ref.startsWith(cen))throw new Error(`Failed to resolve ${t.$ref}`);let n=t.$ref.substring(cen.length).split("/");if(n[0]==null)throw new Error(`${t.$ref} is undefined`);let i=this.document.components.schemas[n[0]];if(i==null)throw new Error(`${n[0]} is undefined`);if(Kh(i)&&(i=this.resolveSchemaReference(i)),n[1]==="properties"&&n[2]!=null){let a=i.properties?.[n[2]];if(a==null)throw new Error(`${t.$ref} is undefiened. Property does not exist on object.`);Kh(a)?i=this.resolveSchemaReference(a):i=a}return i}resolveMessageReference(t){if(this.document.components==null||this.document.components.messages==null||!t.$ref.startsWith(OSf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(OSf.length),n=this.document.components.messages[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}},gma=class extends kyu{constructor({document:t,taskContext:r,options:n,namespace:i}){super({document:t,taskContext:r,options:n,namespace:i})}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,n){}markSchemaWithDiscriminantValue(t,r,n){}};function i3r(e){if(typeof e=="string")return OP.primitive(Uy.string(e));if(typeof e=="number")return Number.isInteger(e)?OP.primitive(Uy.int(e)):OP.primitive(Uy.double(e));if(typeof e=="boolean")return OP.primitive(Uy.boolean(e));if(Array.isArray(e)){let t=e.map(r=>i3r(r));return t.length===0?void 0:OP.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,n]of Object.entries(e)){let i=i3r(n);i!=null&&t.push({key:Uy.string(r),value:i})}return OP.map(t)}}function Jhi(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function PSf(e){if(e!=null&&Array.isArray(e))return e}var a3r=class{schemas;context;constructor(t,r){this.schemas=t,this.context=r}buildExample({schema:t,exampleId:r,example:n,options:i,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:n,options:{...i,maxCheckerDepth:i.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:n,depth:i,visitedSchemaIds:a,options:u,skipReadonly:f}){switch(n.type){case"enum":return typeof r=="string"&&jSf({schema:n,value:r})?OP.enum(r):n.values[0]!=null?OP.enum(n.values[0]?.value):void 0;case"literal":return OP.literal(n.value);case"nullable":{if(r==null&&!this.hasExample(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});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(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});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:n.schema,example:r,options:u});return OP.primitive(d)}case"reference":{let d=this.schemas[n.schema];if(d!=null&&!a.has(n.schema)){a.add(n.schema);let c=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:i,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});return a.delete(n.schema),c}return}case"oneOf":switch(n.value.type){case"discriminated":{let d={},c={},o={},l=Jhi(r),m=l?.[n.value.discriminantProperty],O=n.value.schemas[m],j=[],A=this.getDiscriminatedUnionVariantSchema(n.value,l);A!=null&&j.push(A),j.push(...Object.entries(n.value.schemas));for(let T of j)if(m!=null&&O!=null&&O.type==="object"){c=this.getAllProperties(O),o=this.getAllRequiredProperties(O),d[n.value.discriminantProperty]=OP.primitive(Uy.string(m));break}else{let B=this.getObjectSchema(T[1]);if(B==null)continue;c=this.getAllProperties(B),o=this.getAllRequiredProperties(B),d[n.value.discriminantProperty]=OP.primitive(Uy.string(T[0]))}for(let T of n.value.commonProperties){c[T.key]={schema:T.schema,readonly:!1};let B=this.getResolvedSchema(T.schema);B.type!=="optional"&&B.type!=="nullable"&&(o[T.key]=T.schema)}for(let[T,B]of Object.entries(c)){let F=T in o;if(F&&l?.[T]!=null){let C=this.buildExampleHelper({schema:B.schema,exampleId:t,example:l[T],visitedSchemaIds:a,depth:i+1,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});if(C!=null)d[T]=C;else return}else{let C=this.buildExampleHelper({exampleId:t,schema:B.schema,example:l?.[T],visitedSchemaIds:a,depth:i+1,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});if(C!=null)d[T]=C;else if(F)return}}return OP.oneOf(W6r.discriminated(d))}case"undisciminated":{let d=this.getUnDiscriminatedUnionVariantSchema(n.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:i,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});break}}return;case"unknown":if(r!=null){let d=i3r(r);if(d!=null)return OP.unknown(d)}return u.ignoreOptionals||this.exceedsMaxDepth(i,u)?void 0:u.isParameter?OP.primitive(Uy.string(u.name??"string")):OP.map([{key:Uy.string("key"),value:OP.primitive(Uy.string("value"))}]);case"array":{let d=PSf(r),c=[];if(d!=null&&d.length>0)for(let o of d){let l=this.buildExampleHelper({exampleId:t,example:o,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});l!=null&&c.push(l)}else if(n.example!=null&&n.example.length>0)for(let o of n.example){let l=this.buildExampleHelper({exampleId:t,example:o,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});l!=null&&c.push(l)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});o!=null&&c.push(o)}return OP.array(c)}case"map":{let d=Jhi(r??n.example);if(d!=null&&Object.entries(d).length>0){let l=[];for(let[m,O]of Object.entries(d)){let j=this.buildExampleFromPrimitive({schema:n.key.schema,example:m,options:u}),A=this.buildExampleHelper({exampleId:t,example:O,schema:n.value,visitedSchemaIds:a,depth:i+1,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});A!=null&&l.push({key:j,value:A})}return OP.map(l)}if(n.key.schema.type==="string"&&n.value.type==="unknown")return OP.map([{key:Uy.string("key"),value:OP.unknown(OP.primitive(Uy.string("value")))}]);let c=this.buildExampleFromPrimitive({schema:n.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,visitedSchemaIds:a,depth:i+1,options:{...u,name:"value"},skipReadonly:f&&this.context.options.respectReadonlySchemas});return o!=null?OP.map([{key:c,value:o}]):OP.map([])}case"object":{let d={},c=n.fullExamples?.find(O=>O.name===t)??n.fullExamples?.find(O=>O.name==null)??n.fullExamples?.[0],o=Jhi(r)??(c!=null?Jhi(c.value):{})??{},l=this.getAllProperties(n),m=this.getAllRequiredProperties(n);for(let[O,j]of Object.entries(l)){if(f&&j.readonly)continue;let A=O in m,T=Object.keys(o).includes(O),B=this.buildExampleHelper({schema:j.schema,exampleId:t,example:o[O],visitedSchemaIds:a,depth:i+1,options:{...u,name:O},skipReadonly:f&&this.context.options.respectReadonlySchemas});if(A&&B!=null)d[O]=B;else{if(A)return;(T&&B!=null||!u.ignoreOptionals&&B!=null)&&(d[O]=B)}}return OP.object({properties:d})}default:sc(n)}}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let n=r?.[t.discriminantProperty];if(n==null||typeof n!="string")return Object.entries(t.schemas)[0];let i=t.schemas[n];return i==null?Object.entries(t.schemas)[0]:[n,i]}getUnDiscriminatedUnionVariantSchema(t,r){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 jSf({schema:t,value:r})?5:0;case"object":{if(!bD(r))return 0;let n=this.getAllProperties(t),i=0;for(let[a,u]of Object.entries(n))r[a]!=null?(i++,i+=this.calcExampleHeuristic(u.schema,r[a])):i--;return i}case"array":{if(!Array.isArray(r))return 0;let n=0;for(let i of r)n+=this.calcExampleHeuristic(t.value,i);return n}case"map":{if(!bD(r))return 0;let n=0;for(let[,i]of Object.entries(r))n+=this.calcExampleHeuristic(t.value,i);return n}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let n=this.getResolvedSchema(t);return n==null?0:this.calcExampleHeuristic(n,r)}case"oneOf":return Object.values(t.value.schemas).map(i=>this.calcExampleHeuristic(i,r)).sort((i,a)=>a-i)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,n=new Set,i){if(this.exceedsMaxCheckerDepth(r,i))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,n,i);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,n,i);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let u of t.properties)if(this.hasExample(u.schema,r+1,n,i))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!n.has(t.schema)){n.add(t.schema);let u=this.hasExample(a,r,n,i);return n.delete(t.schema),u}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,n,i));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let n of t.properties)r[n.key]={schema:n.schema,readonly:n.readonly??!1};for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let n of t.properties){let i=this.getResolvedSchema(n.schema);i.type!=="optional"&&i.type!=="nullable"&&(r[n.key]=n.schema)}for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:n}){switch(r.type){case"string":return t!=null&&typeof t=="string"?Uy.string(t):r.example!=null?Uy.string(r.example):Uy.string(n.name??_1.STRING);case"base64":return t!=null&&typeof t=="string"?Uy.base64(t):r.example!=null?Uy.base64(r.example):Uy.base64(_1.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?Uy.boolean(t):r.example!=null?Uy.boolean(r.example):Uy.boolean(_1.BOOLEAN);case"date":return t!=null&&typeof t=="string"?Uy.date(t):r.example!=null?Uy.date(r.example):Uy.date(_1.DATE);case"datetime":return t!=null&&typeof t=="string"?Uy.datetime(t):r.example!=null?Uy.datetime(r.example):Uy.datetime(_1.DATE_TIME);case"double":return t!=null&&typeof t=="number"?Uy.double(t):r.example!=null?Uy.double(r.example):Uy.double(_1.DOUBLE);case"float":return t!=null&&typeof t=="number"?Uy.float(t):r.example!=null?Uy.float(r.example):Uy.float(_1.FLOAT);case"int":return t!=null&&typeof t=="number"?Uy.int(t):r.example!=null?Uy.int(r.example):Uy.int(_1.INT);case"int64":return t!=null&&typeof t=="number"?Uy.int64(t):r.example!=null?Uy.int64(r.example):Uy.int64(_1.INT64);case"uint":return t!=null&&typeof t=="number"?Uy.uint(t):r.example!=null?Uy.uint(r.example):Uy.uint(_1.UINT);case"uint64":return t!=null&&typeof t=="number"?Uy.uint64(t):r.example!=null?Uy.uint64(r.example):Uy.uint64(_1.UINT64);default:sc(r)}}};function jSf({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function g8t(e){switch(e.type){case"object":return Op.object({allOf:e.allOf,properties:e.properties.map(t=>IBj(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return Op.array({description:e.description,availability:e.availability,value:g8t(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0});case"enum":return Op.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,groupName:e.groupName,example:void 0,source:e.source});case"literal":return Op.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName});case"nullable":return Op.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:g8t(e.value),groupName:e.groupName});case"optional":return Op.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:g8t(e.value),groupName:e.groupName});case"primitive":return Op.primitive({description:e.description,availability:e.availability,schema:wSf(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return Op.map({description:e.description,availability:e.availability,key:Op.primitive({description:e.key.description,availability:e.key.availability,schema:wSf(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:g8t(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,encoding:e.encoding,example:void 0});case"reference":return Op.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,groupName:e.groupName,source:e.source});case"oneOf":return Op.oneOf(BBj(e.value));case"unknown":return Op.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,groupName:void 0,description:void 0,availability:void 0});default:sc(e)}}function BBj(e){switch(e.type){case"discriminated":return SX.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:g8t(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,g8t(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return SX.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>g8t(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:sc(e)}}function wSf(e){switch(e.type){case"string":return ty.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return ty.base64({example:void 0});case"boolean":return ty.boolean({default:e.default,example:void 0});case"date":return ty.date({example:void 0});case"datetime":return ty.datetime({example:void 0});case"double":return ty.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 ty.float({example:void 0});case"int":return ty.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 ty.int64({default:e.default,example:void 0});case"uint":return ty.uint({default:void 0,example:void 0});case"uint64":return ty.uint64({default:void 0,example:void 0});default:sc(e)}}function IBj(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:g8t(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly}}function mma(e){return e.type!=="optional"&&e.type!=="nullable"}function Qhi(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 Oma=class{exampleTypeFactory;logger;schemas;constructor(t,r){this.schemas=t,this.exampleTypeFactory=new a3r(t,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=NBj(t.request),n=FBj(t.response);if(r?.type==="unsupported"||n?.type==="unsupported")return[];let i=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let m=this.exampleTypeFactory.buildExample({skipReadonly:t.method==="POST"||t.method==="PUT",schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});m!=null&&i.push([void 0,m])}else for(let{name:m,value:O}of r.examples){let j=this.exampleTypeFactory.buildExample({skipReadonly:t.method==="POST"||t.method==="PUT",schema:r.schema,exampleId:m,example:O,options:{isParameter:!1,ignoreOptionals:!0}});j!=null&&i.push([m,j])}if(l&&i.length===0)return this.logger.warn(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(n!=null&&n.type==="present"){let l=this.isSchemaRequired(n.schema);if(n.examples.length===0){let m=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:void 0,example:void 0,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});m!=null&&(t.response?.type==="json"?a.push([void 0,y2t.withoutStreaming(m)]):t.response?.type==="streamingJson"&&a.push([void 0,y2t.withStreaming([m])]))}else for(let{name:m,value:O}of n.examples){let j=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:m,example:O,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});j!=null&&(t.response?.type==="json"?a.push([m,y2t.withoutStreaming(j)]):t.response?.type==="streamingJson"&&a.push([m,y2t.withStreaming([j])]))}if(l&&a.length===0)return this.logger.warn(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let l of t.pathParameters){let m=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!m8t(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),m&&O==null)return[];O!=null&&u.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:O})}let f=[];for(let l of t.queryParameters){let m=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!m8t(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),m&&O==null)return[];O!=null&&f.push({name:l.name,value:O})}let d=[];for(let l of t.headers){let m=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!m8t(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),m&&O==null)return[];O!=null&&d.push({name:l.name,value:O})}let c=[];t.request!=null&&t.response!=null?c=zBj(i,a):t.request!=null?c=i.map(([l,m])=>({id:l,request:m,response:void 0})):t.response!=null&&(c=a.map(([l,m])=>({id:l,request:void 0,response:m})));let o=t.examples.filter(l=>Qhi(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let m=l.value["code-samples"];if(m!=null)return this.convertCodeSamples(m)}return}else return l.codeSamples}).filter(l=>YA(l));return c.length===0?[h2t.full({name:void 0,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:void 0,response:void 0,codeSamples:o})]:c.map(({id:l,request:m,response:O})=>h2t.full({name:l,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:m,response:O,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?sSr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):sSr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?hW.Csharp:r.sdk,code:r.code})).filter(YA)}isSchemaRequired(t){return mma(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function zBj(e,t){let r=[];if(e.length<=1){let[i,a]=e[0]??[];if(t.length===0)return r.push({id:i,request:a,response:void 0}),r;for(let[u,f]of t)r.push({id:u??i,request:a,response:f});return r}if(t.length<=1){let[i,a]=t[0]??[];if(t.length===0)return r.push({id:i,request:void 0,response:a}),r;for(let[u,f]of e)r.push({id:u??i,request:f,response:a});return r}let n=new Set;for(let[i,a]of e){let u=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(i==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let f=!1;for(let d=0;d<t.length;d++){let[c,o]=t[d];c==null||n.has(d)||i===c&&(r.push({id:i,request:a,response:o}),c!=null&&n.add(d),f=!0)}!f&&u!=null&&r.push({id:i,request:a,response:u})}for(let i=0;i<t.length;i++){if(n.has(i))continue;let[a,u]=t[i],f=e.find(([d])=>d==null)?.[1]??e[0]?.[1];f!=null&&r.push({id:a,request:f,response:u})}return r}function NBj(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:RBj(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function FBj(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function m8t(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return m8t(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undisciminated":return m8t(e.value.value);default:return!1}default:sc(e)}}function RBj(e){return Op.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:g8t(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0}).filter(YA),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source})}var Pma=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new a3r(t,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,publish:n,subscribe:i,handshake:a,source:u,namespace:f}){let d=[];for(let c of r){let o=[];for(let O of a.queryParameters){let j=this.isSchemaRequired(O.schema),A=this.exampleTypeFactory.buildExample({schema:O.schema,exampleId:void 0,example:c.queryParameters?.[O.name],options:{name:O.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!m8t(A)&&(A=void 0),!(j&&A==null)&&A!=null&&o.push({name:O.name,value:A})}let l=[];for(let O of a.headers){let j=this.isSchemaRequired(O.schema),A=this.exampleTypeFactory.buildExample({schema:O.schema,exampleId:void 0,example:c.headers?.[O.name],options:{name:O.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!m8t(A)&&(A=void 0),!(j&&A==null)&&A!=null&&l.push({name:O.name,value:A})}let m=[];for(let O of c.messages){let j=t.resolveMessageReference({$ref:`#/components/messages/${O.messageId}`}),A=Kh(j.payload)?t.resolveSchemaReference(j.payload):j.payload,T=this.exampleTypeFactory.buildExample({schema:aP(A,!1,t,[O.messageId],u,f),exampleId:void 0,example:O.value,options:{isParameter:!1,ignoreOptionals:!0}});T!=null&&m.push({messageType:O.type,payload:T,description:void 0})}d.push({name:c.summary,queryParameters:o,headers:l,description:c.description,messages:m})}return d}buildWebsocketSessionExample({publish:t,subscribe:r,handshake:n}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},a=[];for(let f of n.queryParameters){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!m8t(c)&&(c=void 0),d&&c==null)return;c!=null&&a.push({name:f.name,value:c})}let u=[];for(let f of n.headers){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!m8t(c)&&(c=void 0),d&&c==null)return;c!=null&&u.push({name:f.name,value:c})}if(t!=null){let f=this.exampleTypeFactory.buildExample({schema:t,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"publish",payload:f,description:void 0})}if(r!=null){let f=this.exampleTypeFactory.buildExample({schema:r,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"subscribe",payload:f,description:void 0})}return i}isSchemaRequired(t){return mma(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 Ghi={FERN_DISPLAY_NAME:"x-fern-display-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path"};function DSf(e){return B_(e,Ghi.FERN_EXAMPLES)??[]}function ESf({document:e,taskContext:t,options:r,source:n,asyncApiOptions:i,namespace:a}){let u=[];a!=null&&u.push(a),e.tags?.[0]!=null?u.push(e.tags[0].name):i.naming!=="v2"&&u.push("websocket");let f=new gma({document:e,taskContext:t,options:r,namespace:a}),d={},c;for(let[l,m]of Object.entries(e.components?.schemas??{})){let O=aP(m,!1,f,[l],n,a);d[l]=O}let o=new Pma(d,f);for(let[l,m]of Object.entries(e.channels??{})){if(m.bindings?.ws==null){f.logger.error(`Channel ${l} does not have websocket bindings. Skipping.`);continue}let O=[];if(m.parameters!=null)for(let[F,C]of Object.entries(m.parameters??{}))O.push({name:F,description:C.description,parameterNameOverride:void 0,schema:C.schema!=null?aP(C.schema,!1,f,u,n,a):Op.primitive({schema:ty.string({default:void 0,pattern:void 0,format:void 0,maxLength:void 0,minLength:void 0,example:void 0}),description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:jxe(C),source:n});let j=[];if(m.bindings.ws.headers!=null){let F=m.bindings.ws.headers.required??[];for(let[C,N]of Object.entries(m.bindings.ws.headers.properties??{})){let U=Kh(N)?f.resolveSchemaReference(N):N;j.push({name:C,schema:aP(U,!F.includes(C),f,u,n,a),description:U.description,parameterNameOverride:void 0,env:void 0,availability:jxe(U),source:n})}}let A=[];if(m.bindings.ws.query!=null){let F=m.bindings.ws.query.required??[];for(let[C,N]of Object.entries(m.bindings.ws.query.properties??{})){let U=Kh(N)?f.resolveSchemaReference(N):N;A.push({name:C,schema:aP(U,!F.includes(C),f,u,n,a),description:U.description,parameterNameOverride:void 0,availability:jxe(U),source:n})}}let T;m.publish!=null&&(T=SSf({generatedName:m.publish.operationId??"PublishEvent",event:m.publish,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i}));let B;if(m.subscribe!=null&&(B=SSf({generatedName:m.subscribe.operationId??"SubscribeEvent",event:m.subscribe,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i})),j.length>0||A.length>0||T!=null||B!=null){let F=DSf(m),C=[];if(F.length>0)C=o.buildWebsocketSessionExamplesForExtension({context:f,extensionExamples:F,handshake:{headers:j,queryParameters:A},publish:T,subscribe:B,source:n,namespace:a});else{let U=o.buildWebsocketSessionExample({handshake:{headers:j,queryParameters:A},publish:T,subscribe:B});U!=null&&C.push(U)}let N=e.tags?.[0]?.name!=null?[e.tags?.[0].name]:void 0;c={handshake:{headers:j.map(U=>({...U,schema:mx(U.schema),env:U.env})),queryParameters:A.map(U=>({...U,schema:mx(U.schema)})),pathParameters:O.map(U=>({...U,parameterNameOverride:void 0,schema:mx(U.schema)}))},groupName:f.resolveTags(N,"Websocket"),publish:T!=null?mx(T):T,subscribe:B!=null?mx(B):B,summary:B_(m,Ghi.FERN_DISPLAY_NAME),path:l,description:void 0,examples:C,source:n};break}}return{groupedSchemas:bma(a,d),channel:c,basePath:B_(e,Ghi.BASE_PATH)}}function SSf({generatedName:e,event:t,context:r,breadcrumbs:n,source:i,options:a,asyncApiOptions:u}){if(t.message.oneOf!=null){let f=[],d=[];for(let c of t.message.oneOf){let o,l={type:"notFound"};if(Kh(c)){let m=r.resolveMessageReference(c);!Kh(m.payload)&&u.naming==="v2"?(l=m.name?{type:"name",name:m.name}:l,o={...m.payload,title:m.name??m.payload.title,description:m.name??m.payload.description}):o=m.payload}else o=c;d.push(l),f.push(o)}return R7n({description:t.description??t.message.description,availability:jxe(t.message),subtypes:f,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:n,context:r,encoding:void 0,source:i,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}var Wen=Jo(pIf(),1);var _If=require("fs/promises");async function xja({absoluteFilepathToOverrides:e,data:t,context:r}){let n=null;try{let i=(await(0,_If.readFile)(e,"utf8")).toString();try{n=JSON.parse(i)}catch{n=Fy.load(i,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return fUo({data:t,overrides:n})}var YXj={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},XXj={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:YXj,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}};async function yIf({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,context:r}){let n=await hIf({absolutePathToOpenAPI:e}),i;if(t!=null?i=t:typeof n=="object"&&n[wh.OPENAPI_OVERIDES_FILEPATH]!=null&&(i=Wl(B0(e),ls.of(n[wh.OPENAPI_OVERIDES_FILEPATH]))),i!=null){let a=await xja({absoluteFilepathToOverrides:i,context:r,data:n});return await hIf({absolutePathToOpenAPI:e,parsed:a})}return n}async function hIf({absolutePathToOpenAPI:e,parsed:t}){let r={config:new Wen.Config({apis:{},styleguide:{plugins:[XXj],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};return(t!=null?await(0,Wen.bundle)({...r,doc:{source:new Wen.Source(e,"<openapi>"),parsed:t}}):await(0,Wen.bundle)({...r,ref:e})).bundle.parsed}var A3f=Jo(w6f(),1);function D6f(e){return B_(e,wh.ASYNC_CONFIG)}var S6f="$request.";function E6f(e){let t=B_(e,wh.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:liw(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function liw(e){return e.startsWith(S6f)?e.slice(S6f.length):e}function A6f(e){let t=e;if(t.cursor!=null)return uSr.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});let r=e;return uSr.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}function M6f(e,t){let r=B_(t,wh.PAGINATION);if(r!=null){if(typeof r=="boolean"){let n=B_(e,wh.PAGINATION);if(typeof n=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return n==null?void 0:A6f(n)}return A6f(r)}}function T6f(e){let t=fiw(e),r={};return jju({obj:t,occurrences:r,breadcrumbs:[]}),r}function jju({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let n of e)jju({obj:n,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let n=e.$ref;t[n]==null?t[n]=1:t[n]+=1;return}for(let n in e)jju({obj:e[n],occurrences:t,breadcrumbs:[...r,n]})}}}function fiw(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?Qvi(r.get):void 0,put:r?.put!=null?Qvi(r.put):void 0,post:r?.post!=null?Qvi(r.post):void 0,patch:r?.patch!=null?Qvi(r.patch):void 0,delete:r?.delete!=null?Qvi(r.delete):void 0}]))}}function Qvi(e){return{...e,requestBody:e.requestBody!=null?Kh(e.requestBody)?e.requestBody:diw(e.requestBody):void 0}}function diw(e){let t,r;for(let n in e.content){let i=eI.parse(n);i!=null&&(i.isJSON()?t=e.content[n]:i.isMultipart()&&(r=e.content[n]))}return r!=null&&t!=null?{...e,content:{[eI.MULTIPART_FORM_DATA]:r}}:e}var x6f="#/components/parameters/",q6f="#/components/responses/",C6f="#/components/examples/",B6f="#/components/requestBodies/",rNn=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;namespace;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=n,this.refOccurrences=T6f(t),this.options=i,this.source=a,this.DUMMY=this.getDummy(),this.namespace=u}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};r.push(n)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return{"x-fern-type":"unknown",additionalProperties:!0};n=n[i]}return n==null?{"x-fern-type":"unknown",additionalProperties:!0}:(Kh(n)&&(n=this.resolveSchemaReference(n)),n)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(x6f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(x6f.length),n=this.document.components.parameters[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Kh(n)?this.resolveParameterReference(n):n}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(B6f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(B6f.length),n=this.document.components.requestBodies[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Kh(n)?this.resolveRequestBodyReference(n):n}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(q6f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(q6f.length),n=this.document.components.responses[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Kh(n)?this.resolveResponseReference(n):n}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(C6f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(C6f.length),n=this.document.components.examples[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Kh(n)?this.resolveExampleReference(n):n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}};var nNn=class extends rNn{constructor({document:t,taskContext:r,options:n,source:i,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:n,source:i,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,n){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,n){}getDiscriminatedUnionMetadata(t){}};var MM;(function(e){e.assertEqual=i=>i;function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let a={};for(let u of i)a[u]=u;return a},e.getValidEnumValues=i=>{let a=e.objectKeys(i).filter(f=>typeof i[i[f]]!="number"),u={};for(let f of a)u[f]=i[f];return e.objectValues(u)},e.objectValues=i=>e.objectKeys(i).map(function(a){return i[a]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let u in i)Object.prototype.hasOwnProperty.call(i,u)&&a.push(u);return a},e.find=(i,a)=>{for(let u of i)if(a(u))return u},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(u=>typeof u=="string"?`'${u}'`:u).join(a)}e.joinValues=n,e.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(MM||(MM={}));var Dju;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Dju||(Dju={}));var av=MM.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),K3r=e=>{switch(typeof e){case"undefined":return av.undefined;case"string":return av.string;case"number":return isNaN(e)?av.nan:av.number;case"boolean":return av.boolean;case"function":return av.function;case"bigint":return av.bigint;case"symbol":return av.symbol;case"object":return Array.isArray(e)?av.array:e===null?av.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?av.promise:typeof Map<"u"&&e instanceof Map?av.map:typeof Set<"u"&&e instanceof Set?av.set:typeof Date<"u"&&e instanceof Date?av.date:av.object;default:return av.unknown}},W_=MM.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),piw=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Iwe=class e extends Error{constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){let r=t||function(a){return a.message},n={_errors:[]},i=a=>{for(let u of a.issues)if(u.code==="invalid_union")u.unionErrors.map(i);else if(u.code==="invalid_return_type")i(u.returnTypeError);else if(u.code==="invalid_arguments")i(u.argumentsError);else if(u.path.length===0)n._errors.push(r(u));else{let f=n,d=0;for(;d<u.path.length;){let c=u.path[d];d===u.path.length-1?(f[c]=f[c]||{_errors:[]},f[c]._errors.push(r(u))):f[c]=f[c]||{_errors:[]},f=f[c],d++}}};return i(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,MM.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Iwe.create=e=>new Iwe(e);var oNn=(e,t)=>{let r;switch(e.code){case W_.invalid_type:e.received===av.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case W_.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,MM.jsonStringifyReplacer)}`;break;case W_.unrecognized_keys:r=`Unrecognized key(s) in object: ${MM.joinValues(e.keys,", ")}`;break;case W_.invalid_union:r="Invalid input";break;case W_.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${MM.joinValues(e.options)}`;break;case W_.invalid_enum_value:r=`Invalid enum value. Expected ${MM.joinValues(e.options)}, received '${e.received}'`;break;case W_.invalid_arguments:r="Invalid function arguments";break;case W_.invalid_return_type:r="Invalid function return type";break;case W_.invalid_date:r="Invalid date";break;case W_.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:MM.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case W_.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case W_.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case W_.custom:r="Invalid input";break;case W_.invalid_intersection_types:r="Intersection results could not be merged";break;case W_.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case W_.not_finite:r="Number must be finite";break;default:r=t.defaultError,MM.assertNever(e)}return{message:r}},N6f=oNn;function _iw(e){N6f=e}function Rwa(){return N6f}var Lwa=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,a=[...r,...i.path||[]],u={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let f="",d=n.filter(c=>!!c).slice().reverse();for(let c of d)f=c(u,{data:t,defaultError:f}).message;return{...i,path:a,message:f}},hiw=[];function qy(e,t){let r=Rwa(),n=Lwa({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===oNn?void 0:oNn].filter(i=>!!i)});e.common.issues.push(n)}var hG=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return bO;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let a=await i.key,u=await i.value;n.push({key:a,value:u})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:a,value:u}=i;if(a.status==="aborted"||u.status==="aborted")return bO;a.status==="dirty"&&t.dirty(),u.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof u.value<"u"||i.alwaysSet)&&(n[a.value]=u.value)}return{status:t.value,value:n}}},bO=Object.freeze({status:"aborted"}),aNn=e=>({status:"dirty",value:e}),VX=e=>({status:"valid",value:e}),Sju=e=>e.status==="aborted",Eju=e=>e.status==="dirty",Kvi=e=>e.status==="valid",Yvi=e=>typeof Promise<"u"&&e instanceof Promise;function Uwa(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)}function F6f(e,t,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r}var Yb;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(Yb||(Yb={}));var Gvi,$vi,Nxe=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},I6f=(e,t)=>{if(Kvi(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Iwe(e.common.issues);return this._error=r,this._error}}};function Nw(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(u,f)=>{var d,c;let{message:o}=e;return u.code==="invalid_enum_value"?{message:o??f.defaultError}:typeof f.data>"u"?{message:(d=o??n)!==null&&d!==void 0?d:f.defaultError}:u.code!=="invalid_type"?{message:f.defaultError}:{message:(c=o??r)!==null&&c!==void 0?c:f.defaultError}},description:i}}var Fw=class{constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(t){return K3r(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:K3r(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new hG,ctx:{common:t.parent.common,data:t.data,parsedType:K3r(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Yvi(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){var n;let i={common:{issues:[],async:(n=r?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:K3r(t)},a=this._parseSync({data:t,path:i.path,parent:i});return I6f(i,a)}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:K3r(t)},i=this._parse({data:t,path:n.path,parent:n}),a=await(Yvi(i)?i:Promise.resolve(i));return I6f(n,a)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{let u=t(i),f=()=>a.addIssue({code:W_.custom,...n(i)});return typeof Promise<"u"&&u instanceof Promise?u.then(d=>d?!0:(f(),!1)):u?!0:(f(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new zwe({schema:this,typeName:Gm.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return zxe.create(this,this._def)}nullable(){return F8t.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return TSr.create(this,this._def)}promise(){return Z3r.create(this,this._def)}or(t){return utn.create([this,t],this._def)}and(t){return stn.create(this,t,this._def)}transform(t){return new zwe({...Nw(this._def),schema:this,typeName:Gm.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new ptn({...Nw(this._def),innerType:this,defaultValue:r,typeName:Gm.ZodDefault})}brand(){return new Xvi({typeName:Gm.ZodBranded,type:this,...Nw(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new _tn({...Nw(this._def),innerType:this,catchValue:r,typeName:Gm.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Zvi.create(this,t)}readonly(){return htn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},yiw=/^c[^\s-]{8,}$/i,viw=/^[0-9a-z]+$/,biw=/^[0-9A-HJKMNP-TV-Z]{26}$/,giw=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,miw=/^[a-z0-9_-]{21}$/i,Oiw=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Piw=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jiw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",wju,wiw=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Diw=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Siw=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,R6f="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Eiw=new RegExp(`^${R6f}$`);function L6f(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function Aiw(e){return new RegExp(`^${L6f(e)}$`)}function U6f(e){let t=`${R6f}T${L6f(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Miw(e,t){return!!((t==="v4"||!t)&&wiw.test(e)||(t==="v6"||!t)&&Diw.test(e))}var Y3r=class e extends Fw{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==av.string){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_type,expected:av.string,received:a.parsedType}),bO}let n=new hG,i;for(let a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")t.data.length>a.value&&(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let u=t.data.length>a.value,f=t.data.length<a.value;(u||f)&&(i=this._getOrReturnCtx(t,i),u?qy(i,{code:W_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):f&&qy(i,{code:W_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Piw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"email",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")wju||(wju=new RegExp(jiw,"u")),wju.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"emoji",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")giw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"uuid",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")miw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"nanoid",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")yiw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"cuid",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")viw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"cuid2",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")biw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"ulid",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),qy(i,{validation:"url",code:W_.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"regex",code:W_.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?U6f(a).test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Eiw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Aiw(a).test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?Oiw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"duration",code:W_.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Miw(t.data,a.version)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"ip",code:W_.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Siw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"base64",code:W_.invalid_string,message:a.message}),n.dirty()):MM.assertNever(a);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:W_.invalid_string,...Yb.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Yb.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Yb.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Yb.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Yb.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Yb.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Yb.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Yb.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Yb.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Yb.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Yb.errToObj(t)})}datetime(t){var r,n;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(r=t?.offset)!==null&&r!==void 0?r:!1,local:(n=t?.local)!==null&&n!==void 0?n:!1,...Yb.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...Yb.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...Yb.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Yb.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...Yb.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Yb.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Yb.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Yb.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Yb.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Yb.errToObj(r)})}nonempty(t){return this.min(1,Yb.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Y3r.create=e=>{var t;return new Y3r({checks:[],typeName:Gm.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Nw(e)})};function Tiw(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(e.toFixed(i).replace(".","")),u=parseInt(t.toFixed(i).replace(".",""));return a%u/Math.pow(10,i)}var ttn=class e extends Fw{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==av.number){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_type,expected:av.number,received:a.parsedType}),bO}let n,i=new hG;for(let a of this._def.checks)a.kind==="int"?MM.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?Tiw(t.data,a.value)!==0&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.not_finite,message:a.message}),i.dirty()):MM.assertNever(a);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Yb.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Yb.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Yb.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Yb.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Yb.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Yb.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Yb.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Yb.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Yb.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Yb.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Yb.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Yb.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Yb.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Yb.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&MM.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};ttn.create=e=>new ttn({checks:[],typeName:Gm.ZodNumber,coerce:e?.coerce||!1,...Nw(e)});var rtn=class e extends Fw{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==av.bigint){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_type,expected:av.bigint,received:a.parsedType}),bO}let n,i=new hG;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):MM.assertNever(a);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Yb.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Yb.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Yb.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Yb.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Yb.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Yb.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Yb.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Yb.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Yb.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Yb.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};rtn.create=e=>{var t;return new rtn({checks:[],typeName:Gm.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Nw(e)})};var ntn=class extends Fw{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==av.boolean){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.boolean,received:n.parsedType}),bO}return VX(t.data)}};ntn.create=e=>new ntn({typeName:Gm.ZodBoolean,coerce:e?.coerce||!1,...Nw(e)});var itn=class e extends Fw{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==av.date){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_type,expected:av.date,received:a.parsedType}),bO}if(isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_date}),bO}let n=new hG,i;for(let a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):MM.assertNever(a);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Yb.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Yb.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};itn.create=e=>new itn({checks:[],coerce:e?.coerce||!1,typeName:Gm.ZodDate,...Nw(e)});var uNn=class extends Fw{_parse(t){if(this._getType(t)!==av.symbol){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.symbol,received:n.parsedType}),bO}return VX(t.data)}};uNn.create=e=>new uNn({typeName:Gm.ZodSymbol,...Nw(e)});var atn=class extends Fw{_parse(t){if(this._getType(t)!==av.undefined){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.undefined,received:n.parsedType}),bO}return VX(t.data)}};atn.create=e=>new atn({typeName:Gm.ZodUndefined,...Nw(e)});var otn=class extends Fw{_parse(t){if(this._getType(t)!==av.null){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.null,received:n.parsedType}),bO}return VX(t.data)}};otn.create=e=>new otn({typeName:Gm.ZodNull,...Nw(e)});var X3r=class extends Fw{constructor(){super(...arguments),this._any=!0}_parse(t){return VX(t.data)}};X3r.create=e=>new X3r({typeName:Gm.ZodAny,...Nw(e)});var MSr=class extends Fw{constructor(){super(...arguments),this._unknown=!0}_parse(t){return VX(t.data)}};MSr.create=e=>new MSr({typeName:Gm.ZodUnknown,...Nw(e)});var M2t=class extends Fw{_parse(t){let r=this._getOrReturnCtx(t);return qy(r,{code:W_.invalid_type,expected:av.never,received:r.parsedType}),bO}};M2t.create=e=>new M2t({typeName:Gm.ZodNever,...Nw(e)});var sNn=class extends Fw{_parse(t){if(this._getType(t)!==av.undefined){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.void,received:n.parsedType}),bO}return VX(t.data)}};sNn.create=e=>new sNn({typeName:Gm.ZodVoid,...Nw(e)});var TSr=class e extends Fw{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==av.array)return qy(r,{code:W_.invalid_type,expected:av.array,received:r.parsedType}),bO;if(i.exactLength!==null){let u=r.data.length>i.exactLength.value,f=r.data.length<i.exactLength.value;(u||f)&&(qy(r,{code:u?W_.too_big:W_.too_small,minimum:f?i.exactLength.value:void 0,maximum:u?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(qy(r,{code:W_.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(qy(r,{code:W_.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((u,f)=>i.type._parseAsync(new Nxe(r,u,r.path,f)))).then(u=>hG.mergeArray(n,u));let a=[...r.data].map((u,f)=>i.type._parseSync(new Nxe(r,u,r.path,f)));return hG.mergeArray(n,a)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:Yb.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:Yb.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:Yb.toString(r)}})}nonempty(t){return this.min(1,t)}};TSr.create=(e,t)=>new TSr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Gm.ZodArray,...Nw(t)});function iNn(e){if(e instanceof zne){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=zxe.create(iNn(n))}return new zne({...e._def,shape:()=>t})}else return e instanceof TSr?new TSr({...e._def,type:iNn(e.element)}):e instanceof zxe?zxe.create(iNn(e.unwrap())):e instanceof F8t?F8t.create(iNn(e.unwrap())):e instanceof N8t?N8t.create(e.items.map(t=>iNn(t))):e}var zne=class e extends Fw{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=MM.objectKeys(t);return this._cached={shape:t,keys:r}}_parse(t){if(this._getType(t)!==av.object){let c=this._getOrReturnCtx(t);return qy(c,{code:W_.invalid_type,expected:av.object,received:c.parsedType}),bO}let{status:n,ctx:i}=this._processInputParams(t),{shape:a,keys:u}=this._getCached(),f=[];if(!(this._def.catchall instanceof M2t&&this._def.unknownKeys==="strip"))for(let c in i.data)u.includes(c)||f.push(c);let d=[];for(let c of u){let o=a[c],l=i.data[c];d.push({key:{status:"valid",value:c},value:o._parse(new Nxe(i,l,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof M2t){let c=this._def.unknownKeys;if(c==="passthrough")for(let o of f)d.push({key:{status:"valid",value:o},value:{status:"valid",value:i.data[o]}});else if(c==="strict")f.length>0&&(qy(i,{code:W_.unrecognized_keys,keys:f}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let o of f){let l=i.data[o];d.push({key:{status:"valid",value:o},value:c._parse(new Nxe(i,l,i.path,o)),alwaysSet:o in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let o of d){let l=await o.key,m=await o.value;c.push({key:l,value:m,alwaysSet:o.alwaysSet})}return c}).then(c=>hG.mergeObjectSync(n,c)):hG.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(t){return Yb.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{var i,a,u,f;let d=(u=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&u!==void 0?u:n.defaultError;return r.code==="unrecognized_keys"?{message:(f=Yb.errToObj(t).message)!==null&&f!==void 0?f:d}:{message:d}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Gm.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};return MM.objectKeys(t).forEach(n=>{t[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new e({...this._def,shape:()=>r})}omit(t){let r={};return MM.objectKeys(this.shape).forEach(n=>{t[n]||(r[n]=this.shape[n])}),new e({...this._def,shape:()=>r})}deepPartial(){return iNn(this)}partial(t){let r={};return MM.objectKeys(this.shape).forEach(n=>{let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}),new e({...this._def,shape:()=>r})}required(t){let r={};return MM.objectKeys(this.shape).forEach(n=>{if(t&&!t[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof zxe;)a=a._def.innerType;r[n]=a}}),new e({...this._def,shape:()=>r})}keyof(){return V6f(MM.objectKeys(this.shape))}};zne.create=(e,t)=>new zne({shape:()=>e,unknownKeys:"strip",catchall:M2t.create(),typeName:Gm.ZodObject,...Nw(t)});zne.strictCreate=(e,t)=>new zne({shape:()=>e,unknownKeys:"strict",catchall:M2t.create(),typeName:Gm.ZodObject,...Nw(t)});zne.lazycreate=(e,t)=>new zne({shape:e,unknownKeys:"strip",catchall:M2t.create(),typeName:Gm.ZodObject,...Nw(t)});var utn=class extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(a){for(let f of a)if(f.result.status==="valid")return f.result;for(let f of a)if(f.result.status==="dirty")return r.common.issues.push(...f.ctx.common.issues),f.result;let u=a.map(f=>new Iwe(f.ctx.common.issues));return qy(r,{code:W_.invalid_union,unionErrors:u}),bO}if(r.common.async)return Promise.all(n.map(async a=>{let u={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:u}),ctx:u}})).then(i);{let a,u=[];for(let d of n){let c={...r,common:{...r.common,issues:[]},parent:null},o=d._parseSync({data:r.data,path:r.path,parent:c});if(o.status==="valid")return o;o.status==="dirty"&&!a&&(a={result:o,ctx:c}),c.common.issues.length&&u.push(c.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let f=u.map(d=>new Iwe(d));return qy(r,{code:W_.invalid_union,unionErrors:f}),bO}}get options(){return this._def.options}};utn.create=(e,t)=>new utn({options:e,typeName:Gm.ZodUnion,...Nw(t)});var ASr=e=>e instanceof ctn?ASr(e.schema):e instanceof zwe?ASr(e.innerType()):e instanceof ltn?[e.value]:e instanceof ftn?e.options:e instanceof dtn?MM.objectValues(e.enum):e instanceof ptn?ASr(e._def.innerType):e instanceof atn?[void 0]:e instanceof otn?[null]:e instanceof zxe?[void 0,...ASr(e.unwrap())]:e instanceof F8t?[null,...ASr(e.unwrap())]:e instanceof Xvi||e instanceof htn?ASr(e.unwrap()):e instanceof _tn?ASr(e._def.innerType):[],Vwa=class e extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==av.object)return qy(r,{code:W_.invalid_type,expected:av.object,received:r.parsedType}),bO;let n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(qy(r,{code:W_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),bO)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let a of r){let u=ASr(a.shape[t]);if(!u.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let f of u){if(i.has(f))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(f)}`);i.set(f,a)}}return new e({typeName:Gm.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...Nw(n)})}};function Aju(e,t){let r=K3r(e),n=K3r(t);if(e===t)return{valid:!0,data:e};if(r===av.object&&n===av.object){let i=MM.objectKeys(t),a=MM.objectKeys(e).filter(f=>i.indexOf(f)!==-1),u={...e,...t};for(let f of a){let d=Aju(e[f],t[f]);if(!d.valid)return{valid:!1};u[f]=d.data}return{valid:!0,data:u}}else if(r===av.array&&n===av.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let a=0;a<e.length;a++){let u=e[a],f=t[a],d=Aju(u,f);if(!d.valid)return{valid:!1};i.push(d.data)}return{valid:!0,data:i}}else return r===av.date&&n===av.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var stn=class extends Fw{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(a,u)=>{if(Sju(a)||Sju(u))return bO;let f=Aju(a.value,u.value);return f.valid?((Eju(a)||Eju(u))&&r.dirty(),{status:r.value,value:f.data}):(qy(n,{code:W_.invalid_intersection_types}),bO)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,u])=>i(a,u)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};stn.create=(e,t,r)=>new stn({left:e,right:t,typeName:Gm.ZodIntersection,...Nw(r)});var N8t=class e extends Fw{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==av.array)return qy(n,{code:W_.invalid_type,expected:av.array,received:n.parsedType}),bO;if(n.data.length<this._def.items.length)return qy(n,{code:W_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),bO;!this._def.rest&&n.data.length>this._def.items.length&&(qy(n,{code:W_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((u,f)=>{let d=this._def.items[f]||this._def.rest;return d?d._parse(new Nxe(n,u,n.path,f)):null}).filter(u=>!!u);return n.common.async?Promise.all(a).then(u=>hG.mergeArray(r,u)):hG.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};N8t.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new N8t({items:e,typeName:Gm.ZodTuple,rest:null,...Nw(t)})};var Wwa=class e extends Fw{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==av.object)return qy(n,{code:W_.invalid_type,expected:av.object,received:n.parsedType}),bO;let i=[],a=this._def.keyType,u=this._def.valueType;for(let f in n.data)i.push({key:a._parse(new Nxe(n,f,n.path,f)),value:u._parse(new Nxe(n,n.data[f],n.path,f)),alwaysSet:f in n.data});return n.common.async?hG.mergeObjectAsync(r,i):hG.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof Fw?new e({keyType:t,valueType:r,typeName:Gm.ZodRecord,...Nw(n)}):new e({keyType:Y3r.create(),valueType:t,typeName:Gm.ZodRecord,...Nw(r)})}},cNn=class extends Fw{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==av.map)return qy(n,{code:W_.invalid_type,expected:av.map,received:n.parsedType}),bO;let i=this._def.keyType,a=this._def.valueType,u=[...n.data.entries()].map(([f,d],c)=>({key:i._parse(new Nxe(n,f,n.path,[c,"key"])),value:a._parse(new Nxe(n,d,n.path,[c,"value"]))}));if(n.common.async){let f=new Map;return Promise.resolve().then(async()=>{for(let d of u){let c=await d.key,o=await d.value;if(c.status==="aborted"||o.status==="aborted")return bO;(c.status==="dirty"||o.status==="dirty")&&r.dirty(),f.set(c.value,o.value)}return{status:r.value,value:f}})}else{let f=new Map;for(let d of u){let c=d.key,o=d.value;if(c.status==="aborted"||o.status==="aborted")return bO;(c.status==="dirty"||o.status==="dirty")&&r.dirty(),f.set(c.value,o.value)}return{status:r.value,value:f}}}};cNn.create=(e,t,r)=>new cNn({valueType:t,keyType:e,typeName:Gm.ZodMap,...Nw(r)});var lNn=class e extends Fw{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==av.set)return qy(n,{code:W_.invalid_type,expected:av.set,received:n.parsedType}),bO;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(qy(n,{code:W_.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(qy(n,{code:W_.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let a=this._def.valueType;function u(d){let c=new Set;for(let o of d){if(o.status==="aborted")return bO;o.status==="dirty"&&r.dirty(),c.add(o.value)}return{status:r.value,value:c}}let f=[...n.data.values()].map((d,c)=>a._parse(new Nxe(n,d,n.path,c)));return n.common.async?Promise.all(f).then(d=>u(d)):u(f)}min(t,r){return new e({...this._def,minSize:{value:t,message:Yb.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:Yb.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};lNn.create=(e,t)=>new lNn({valueType:e,minSize:null,maxSize:null,typeName:Gm.ZodSet,...Nw(t)});var Hwa=class e extends Fw{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==av.function)return qy(r,{code:W_.invalid_type,expected:av.function,received:r.parsedType}),bO;function n(f,d){return Lwa({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Rwa(),oNn].filter(c=>!!c),issueData:{code:W_.invalid_arguments,argumentsError:d}})}function i(f,d){return Lwa({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Rwa(),oNn].filter(c=>!!c),issueData:{code:W_.invalid_return_type,returnTypeError:d}})}let a={errorMap:r.common.contextualErrorMap},u=r.data;if(this._def.returns instanceof Z3r){let f=this;return VX(async function(...d){let c=new Iwe([]),o=await f._def.args.parseAsync(d,a).catch(O=>{throw c.addIssue(n(d,O)),c}),l=await Reflect.apply(u,this,o);return await f._def.returns._def.type.parseAsync(l,a).catch(O=>{throw c.addIssue(i(l,O)),c})})}else{let f=this;return VX(function(...d){let c=f._def.args.safeParse(d,a);if(!c.success)throw new Iwe([n(d,c.error)]);let o=Reflect.apply(u,this,c.data),l=f._def.returns.safeParse(o,a);if(!l.success)throw new Iwe([i(o,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:N8t.create(t).rest(MSr.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||N8t.create([]).rest(MSr.create()),returns:r||MSr.create(),typeName:Gm.ZodFunction,...Nw(n)})}},ctn=class extends Fw{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};ctn.create=(e,t)=>new ctn({getter:e,typeName:Gm.ZodLazy,...Nw(t)});var ltn=class extends Fw{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return qy(r,{received:r.data,code:W_.invalid_literal,expected:this._def.value}),bO}return{status:"valid",value:t.data}}get value(){return this._def.value}};ltn.create=(e,t)=>new ltn({value:e,typeName:Gm.ZodLiteral,...Nw(t)});function V6f(e,t){return new ftn({values:e,typeName:Gm.ZodEnum,...Nw(t)})}var ftn=class e extends Fw{constructor(){super(...arguments),Gvi.set(this,void 0)}_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return qy(r,{expected:MM.joinValues(n),received:r.parsedType,code:W_.invalid_type}),bO}if(Uwa(this,Gvi,"f")||F6f(this,Gvi,new Set(this._def.values),"f"),!Uwa(this,Gvi,"f").has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return qy(r,{received:r.data,code:W_.invalid_enum_value,options:n}),bO}return VX(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};Gvi=new WeakMap;ftn.create=V6f;var dtn=class extends Fw{constructor(){super(...arguments),$vi.set(this,void 0)}_parse(t){let r=MM.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==av.string&&n.parsedType!==av.number){let i=MM.objectValues(r);return qy(n,{expected:MM.joinValues(i),received:n.parsedType,code:W_.invalid_type}),bO}if(Uwa(this,$vi,"f")||F6f(this,$vi,new Set(MM.getValidEnumValues(this._def.values)),"f"),!Uwa(this,$vi,"f").has(t.data)){let i=MM.objectValues(r);return qy(n,{received:n.data,code:W_.invalid_enum_value,options:i}),bO}return VX(t.data)}get enum(){return this._def.values}};$vi=new WeakMap;dtn.create=(e,t)=>new dtn({values:e,typeName:Gm.ZodNativeEnum,...Nw(t)});var Z3r=class extends Fw{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==av.promise&&r.common.async===!1)return qy(r,{code:W_.invalid_type,expected:av.promise,received:r.parsedType}),bO;let n=r.parsedType===av.promise?r.data:Promise.resolve(r.data);return VX(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Z3r.create=(e,t)=>new Z3r({type:e,typeName:Gm.ZodPromise,...Nw(t)});var zwe=class extends Fw{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Gm.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:u=>{qy(n,u),u.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){let u=i.transform(n.data,a);if(n.common.async)return Promise.resolve(u).then(async f=>{if(r.value==="aborted")return bO;let d=await this._def.schema._parseAsync({data:f,path:n.path,parent:n});return d.status==="aborted"?bO:d.status==="dirty"||r.value==="dirty"?aNn(d.value):d});{if(r.value==="aborted")return bO;let f=this._def.schema._parseSync({data:u,path:n.path,parent:n});return f.status==="aborted"?bO:f.status==="dirty"||r.value==="dirty"?aNn(f.value):f}}if(i.type==="refinement"){let u=f=>{let d=i.refinement(f,a);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(n.common.async===!1){let f=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return f.status==="aborted"?bO:(f.status==="dirty"&&r.dirty(),u(f.value),{status:r.value,value:f.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(f=>f.status==="aborted"?bO:(f.status==="dirty"&&r.dirty(),u(f.value).then(()=>({status:r.value,value:f.value}))))}if(i.type==="transform")if(n.common.async===!1){let u=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Kvi(u))return u;let f=i.transform(u.value,a);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:f}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>Kvi(u)?Promise.resolve(i.transform(u.value,a)).then(f=>({status:r.value,value:f})):u);MM.assertNever(i)}};zwe.create=(e,t,r)=>new zwe({schema:e,typeName:Gm.ZodEffects,effect:t,...Nw(r)});zwe.createWithPreprocess=(e,t,r)=>new zwe({schema:t,effect:{type:"preprocess",transform:e},typeName:Gm.ZodEffects,...Nw(r)});var zxe=class extends Fw{_parse(t){return this._getType(t)===av.undefined?VX(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};zxe.create=(e,t)=>new zxe({innerType:e,typeName:Gm.ZodOptional,...Nw(t)});var F8t=class extends Fw{_parse(t){return this._getType(t)===av.null?VX(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};F8t.create=(e,t)=>new F8t({innerType:e,typeName:Gm.ZodNullable,...Nw(t)});var ptn=class extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===av.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ptn.create=(e,t)=>new ptn({innerType:e,typeName:Gm.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Nw(t)});var _tn=class extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Yvi(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Iwe(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Iwe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};_tn.create=(e,t)=>new _tn({innerType:e,typeName:Gm.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Nw(t)});var fNn=class extends Fw{_parse(t){if(this._getType(t)!==av.nan){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.nan,received:n.parsedType}),bO}return{status:"valid",value:t.data}}};fNn.create=e=>new fNn({typeName:Gm.ZodNaN,...Nw(e)});var xiw=Symbol("zod_brand"),Xvi=class extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Zvi=class e extends Fw{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?bO:a.status==="dirty"?(r.dirty(),aNn(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?bO:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:Gm.ZodPipeline})}},htn=class extends Fw{_parse(t){let r=this._def.innerType._parse(t),n=i=>(Kvi(i)&&(i.value=Object.freeze(i.value)),i);return Yvi(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};htn.create=(e,t)=>new htn({innerType:e,typeName:Gm.ZodReadonly,...Nw(t)});function W6f(e,t={},r){return e?X3r.create().superRefine((n,i)=>{var a,u;if(!e(n)){let f=typeof t=="function"?t(n):typeof t=="string"?{message:t}:t,d=(u=(a=f.fatal)!==null&&a!==void 0?a:r)!==null&&u!==void 0?u:!0,c=typeof f=="string"?{message:f}:f;i.addIssue({code:"custom",...c,fatal:d})}}):X3r.create()}var qiw={object:zne.lazycreate},Gm;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Gm||(Gm={}));var Ciw=(e,t={message:`Input not instance of ${e.name}`})=>W6f(r=>r instanceof e,t),H6f=Y3r.create,J6f=ttn.create,Biw=fNn.create,Iiw=rtn.create,Q6f=ntn.create,ziw=itn.create,Niw=uNn.create,Fiw=atn.create,Riw=otn.create,Liw=X3r.create,Uiw=MSr.create,Viw=M2t.create,Wiw=sNn.create,Hiw=TSr.create,Jiw=zne.create,Qiw=zne.strictCreate,Giw=utn.create,$iw=Vwa.create,Kiw=stn.create,Yiw=N8t.create,Xiw=Wwa.create,Ziw=cNn.create,kiw=lNn.create,eaw=Hwa.create,taw=ctn.create,raw=ltn.create,naw=ftn.create,iaw=dtn.create,aaw=Z3r.create,z6f=zwe.create,oaw=zxe.create,uaw=F8t.create,saw=zwe.createWithPreprocess,caw=Zvi.create,law=()=>H6f().optional(),faw=()=>J6f().optional(),daw=()=>Q6f().optional(),paw={string:e=>Y3r.create({...e,coerce:!0}),number:e=>ttn.create({...e,coerce:!0}),boolean:e=>ntn.create({...e,coerce:!0}),bigint:e=>rtn.create({...e,coerce:!0}),date:e=>itn.create({...e,coerce:!0})},_aw=bO,Nwe=Object.freeze({__proto__:null,defaultErrorMap:oNn,setErrorMap:_iw,getErrorMap:Rwa,makeIssue:Lwa,EMPTY_PATH:hiw,addIssueToContext:qy,ParseStatus:hG,INVALID:bO,DIRTY:aNn,OK:VX,isAborted:Sju,isDirty:Eju,isValid:Kvi,isAsync:Yvi,get util(){return MM},get objectUtil(){return Dju},ZodParsedType:av,getParsedType:K3r,ZodType:Fw,datetimeRegex:U6f,ZodString:Y3r,ZodNumber:ttn,ZodBigInt:rtn,ZodBoolean:ntn,ZodDate:itn,ZodSymbol:uNn,ZodUndefined:atn,ZodNull:otn,ZodAny:X3r,ZodUnknown:MSr,ZodNever:M2t,ZodVoid:sNn,ZodArray:TSr,ZodObject:zne,ZodUnion:utn,ZodDiscriminatedUnion:Vwa,ZodIntersection:stn,ZodTuple:N8t,ZodRecord:Wwa,ZodMap:cNn,ZodSet:lNn,ZodFunction:Hwa,ZodLazy:ctn,ZodLiteral:ltn,ZodEnum:ftn,ZodNativeEnum:dtn,ZodPromise:Z3r,ZodEffects:zwe,ZodTransformer:zwe,ZodOptional:zxe,ZodNullable:F8t,ZodDefault:ptn,ZodCatch:_tn,ZodNaN:fNn,BRAND:xiw,ZodBranded:Xvi,ZodPipeline:Zvi,ZodReadonly:htn,custom:W6f,Schema:Fw,ZodSchema:Fw,late:qiw,get ZodFirstPartyTypeKind(){return Gm},coerce:paw,any:Liw,array:Hiw,bigint:Iiw,boolean:Q6f,date:ziw,discriminatedUnion:$iw,effect:z6f,enum:naw,function:eaw,instanceof:Ciw,intersection:Kiw,lazy:taw,literal:raw,map:Ziw,nan:Biw,nativeEnum:iaw,never:Viw,null:Riw,nullable:uaw,number:J6f,object:Jiw,oboolean:daw,onumber:faw,optional:oaw,ostring:law,pipeline:caw,preprocess:saw,promise:aaw,record:Xiw,set:kiw,strictObject:Qiw,string:H6f,symbol:Niw,transformer:z6f,tuple:Yiw,undefined:Fiw,union:Giw,unknown:Uiw,void:Wiw,NEVER:_aw,ZodIssueCode:W_,quotelessJson:piw,ZodError:Iwe});var haw=Nwe.object({lang:Nwe.string(),label:Nwe.optional(Nwe.string()),source:Nwe.string()}),Mju=Nwe.array(haw);var G6f={README_EXT:"x-readme"};function yaw(e){if(!Array.isArray(e))return!1;for(let t of e)if(!bD(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function $6f(e){let t=B_(e,G6f.README_EXT);if(!bD(t))return[];let r=t["code-samples"];if(!yaw(r))return[];let n=[];for(let i of r)n.push({name:i.name,language:i.language,code:i.code,install:i.install,docs:void 0});return n}function K6f(e,t,r){let i=(B_(t,wh.EXAMPLES)??[]).filter(c=>{let o=UQ.serialization.ExampleEndpointCallSchema.parse(c);return o.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),o.ok}),a=Uhi(t,Ewe.REDOCLY_CODE_SAMPLES_KEBAB,Mju,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],f=[...Uhi(t,Ewe.REDOCLY_CODE_SAMPLES_CAMEL,Mju,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];f.length>0&&i.push({"code-samples":f.map(c=>({name:c.label??c.lang,language:c.lang,code:c.source,install:void 0,docs:void 0}))});let d=$6f(t);return d.length>0&&i.push({"code-samples":d}),i.map(h2t.unknown)}function Y6f(e){let t=B_(e,wh.AVAILABILITY);if(t==="ga"||t==="generally-available")return _W.GenerallyAvailable;if(t==="beta"||t==="pre-release")return _W.Beta;if(t==="deprecated")return _W.Deprecated;if(e.deprecated)return _W.Deprecated}function Jwa(e){return{url:vaw({url:e.url,variables:e.variables??{}}),description:e.description,name:baw(e),audiences:B_(e,wh.AUDIENCES)}}function vaw({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([n,i])=>[n,i.default]));for(let[n,i]of Object.entries(r))e=e.replace(`{${n}}`,i);return e}function baw(e){let t=B_(e,[wh.SERVER_NAME_V1,wh.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function X6f(e){return B_(e,wh.PARAMETER_NAME)}function Z6f(e){return B_(e,wh.SDK_VARIABLE)}function Qwa({path:e,httpMethod:t,parameters:r,context:n,requestBreadcrumbs:i,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let f of r){let d=B_(f,wh.IGNORE);if(d!=null&&d){n.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let c=Kh(f)?n.resolveParameterReference(f):f,o=c.required??!1,l=jxe(c),m=[...i,c.name],O=b8(m),j=c.schema!=null?aP(c.schema,!o,n,m,a,n.namespace,!1,new Set,fSr({schema:c,logger:n.logger})):o?Op.primitive({nameOverride:void 0,generatedName:O,title:void 0,schema:ty.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:fSr({schema:c,logger:n.logger})}),description:void 0,availability:l,groupName:void 0}):Op.optional({nameOverride:void 0,generatedName:O,title:void 0,value:Op.primitive({nameOverride:void 0,generatedName:O,title:void 0,schema:ty.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:fSr({schema:c,logger:n.logger})}),description:void 0,availability:void 0,groupName:void 0}),description:void 0,availability:l,groupName:void 0});if(c.in==="header"&&c.schema!=null&&!Kh(c.schema)&&c.schema.default!=null){let T=c.schema.default;typeof T=="string"&&T.length>0&&(j=Op.literal({nameOverride:void 0,generatedName:O,title:void 0,value:_I.string(T),description:void 0,availability:l,groupName:void 0}))}let A={name:c.name,schema:j,description:c.description,parameterNameOverride:X6f(c),availability:l,source:a};c.in==="query"?u.queryParameters.push(A):c.in==="path"?u.pathParameters.push({...A,variableReference:Z6f(c)}):c.in==="header"?!gaw.has(c.name.toLowerCase())&&!n.authHeaders.has(c.name)?u.headers.push({...A,env:void 0}):n.logger.debug(`Ignoring ${c.name} header, in ${t.toUpperCase()} ${e}`):n.logger.warn(`Skipping ${c.in} parameter, ${c.name}, in ${t.toUpperCase()} ${e}`)}return u}var gaw=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function k6f(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let n=e[r];if(n==null)continue;let i=n.schema;return{contentType:r,schema:i??{},examples:kvi(n,t)}}}function dNn(e,t){for(let r of Object.keys(e))if(r.includes("json")||r==="*/*"){let n=e[r];if(n==null)continue;let i=n.schema;return{contentType:r.includes("*")?void 0:r,schema:i??{},examples:kvi(n,t)}}}function e3f(e,t){for(let r of Object.keys(e)){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:kvi(n,t)}}}function kvi(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let n=B_(e,Ewe.EXAMPLES);return n!=null&&Object.keys(n).length>0&&r.push(...Object.entries(n).map(([i,a])=>({name:a.summary??i,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([i,a])=>{let u=Kh(a)?t.resolveExampleReference(a):a;return{name:u.summary??i,value:u.value,description:u.description}})),r}function maw(e,t){for(let[r,n]of Object.entries(e.content))if(eI.parse(r)?.isURLEncoded())return{schema:n.schema,contentType:r,examples:kvi(n,t)}}function Oaw(e){for(let[t,r]of Object.entries(e.content))if(eI.parse(t)?.isMultipart())return{schema:r.schema,encoding:r.encoding}}function Paw(e){for(let t in e.content)if(eI.parse(t)?.isOctetStream())return!0;return!1}function jaw(e,t){let r=Kh(e)?Tju(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([n,i])=>!Kh(i)&&i.type==="string"&&i.format==="binary")!=null}function pNn({requestBody:e,document:t,context:r,requestBreadcrumbs:n,source:i,namespace:a}){let u=Kh(e)?r.resolveRequestBodyReference(e):e,f=Oaw(u),d=f?.schema,c=f?.encoding,o=maw(u,r),l=dNn(u.content,r);if(o!=null&&o.schema!=null){let O=aP(o.schema,!1,r,n,i,a);return Swe.json({schema:O,description:u.description,contentType:o.contentType,source:i,fullExamples:o.examples,additionalProperties:!1})}if(Paw(u))return Swe.octetStream({description:u.description,source:i});if(d!=null&&l==null||d!=null&&jaw(d,t)){let O=Kh(d)?Tju(d,t):{id:void 0,schema:d},j=aP(O.schema,!1,r,n,i,a),A=[];if(j.type==="object")for(let T of j.properties){if(T.schema.type==="primitive"&&T.schema.schema.type==="string"&&T.schema.schema.format==="binary"){A.push({key:T.key,schema:Pxe.file({isOptional:!1,isArray:!1}),description:T.schema.description,contentType:c?.[T.key]?.contentType});continue}if(T.schema.type==="optional"&&T.schema.value.type==="primitive"&&T.schema.value.schema.type==="string"&&T.schema.value.schema.format==="binary"){A.push({key:T.key,schema:Pxe.file({isOptional:!0,isArray:!1}),description:T.schema.description,contentType:c?.[T.key]?.contentType});continue}if(T.schema.type==="array"&&T.schema.value.type==="primitive"&&T.schema.value.schema.type==="string"&&T.schema.value.schema.format==="binary"){A.push({key:T.key,schema:Pxe.file({isOptional:!1,isArray:!0}),description:T.schema.description,contentType:c?.[T.key]?.contentType});continue}if(T.schema.type==="optional"&&T.schema.value.type==="array"&&T.schema.value.value.type==="primitive"&&T.schema.value.value.schema.type==="string"&&T.schema.value.value.schema.format==="binary"){A.push({key:T.key,schema:Pxe.file({isOptional:!0,isArray:!0}),description:T.schema.description,contentType:c?.[T.key]?.contentType});continue}A.push({key:T.key,schema:Pxe.json(T.schema),description:void 0,contentType:c?.[T.key]?.contentType})}return Swe.multipart({name:Kh(d)&&r.getNumberOfOccurrencesForRef(d)===1?O.id:void 0,description:O.schema.description,properties:A,source:i})}if(l==null)return;let m=aP(l.schema,!1,r,n,i,a,!0);return Swe.json({description:void 0,schema:m,contentType:l.contentType,fullExamples:l.examples,additionalProperties:!Kh(l.schema)&&I7n(l.schema.additionalProperties),source:i})}function Tju(e,t){if(!e.$ref.startsWith(cen))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=n3r(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let n=t.components?.schemas?.[r];if(n==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return Kh(n)?Tju(n,t):{id:r,schema:n}}var xju={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"},t3f=new Set(Object.values(xju));var waw=["200","201","202","204"];function n3f({operationContext:e,responses:t,context:r,responseBreadcrumbs:n,responseStatusCode:i,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let f=Daw({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,c;for(let o of i!=null?[i]:waw){let l=t[o];l!=null&&(d=!0,c==null&&(c=r3f({operationContext:e,response:l,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})))}if(c==null&&!d&&t.default!=null&&(c=r3f({operationContext:e,response:t.default,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})),c!=null)switch(c.type){case"json":return{value:c,errors:f};case"streamingJson":case"streamingSse":return{value:c,errors:f};case"file":case"text":case"streamingText":return{value:c,errors:f};default:sc(c)}return{value:void 0,errors:f}}function r3f({operationContext:e,streamFormat:t,response:r,context:n,responseBreadcrumbs:i,source:a,namespace:u}){let f=Kh(r)?n.resolveResponseReference(r):r;if(f.content!=null&&Object.entries(f.content).find(([l,m])=>{if(m.schema==null)return!1;let O=Kh(m.schema)?n.resolveSchemaReference(m.schema):m.schema;return O.type==="string"&&O.format==="binary"}))return hI.file({description:f.description,source:a});let d=k6f(f.content??{},n);if(d!=null&&t!=null)switch(t){case"json":return hI.streamingJson({description:f.description,responseProperty:B_(e.operation,wh.RESPONSE_PROPERTY),fullExamples:d.examples,schema:aP(d.schema,!1,n,i,a,u),source:a});case"sse":return hI.streamingSse({description:f.description,responseProperty:void 0,schema:mx(aP(d.schema,!1,n,i,a,u)),source:a})}let c=dNn(f.content??{},n);if(c!=null){if(t!=null)switch(t){case"json":return hI.streamingJson({description:f.description,responseProperty:void 0,fullExamples:c.examples,schema:aP(c.schema,!1,n,i,a,u),source:a});case"sse":return hI.streamingSse({description:f.description,responseProperty:void 0,schema:mx(aP(c.schema,!1,n,i,a,u)),source:a})}return hI.json({description:f.description,schema:aP(c.schema,!1,n,i,a,u),responseProperty:B_(e.operation,wh.RESPONSE_PROPERTY),fullExamples:c.examples,source:a})}for(let[o,l]of Object.entries(f.content??{})){let m=eI.parse(o);if(m!=null){if(m.isOctetStream()||m.isPDF()||m.isAudio()||m.isImage()||m.isVideo())return hI.file({description:f.description,source:a});if(m.isPlainText()){let O=l.schema;if(O==null)return hI.text({description:f.description,source:a});let j=Kh(O)?n.resolveSchemaReference(O):O;return j.type==="string"&&j.format==="byte"?hI.file({description:f.description,source:a}):hI.text({description:f.description,source:a})}}}}function Daw({responses:e,context:t,source:r,namespace:n}){let i={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let f=parseInt(a);if(f<400||f>600)continue;let d=Kh(u)?t.resolveResponseReference(u):u,c=e3f(d.content??{},t),o=xju[f];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}i[f]={statusCode:f,nameOverride:void 0,generatedName:o,description:d.description,schema:aP(c?.schema??{},!1,t,[o,"Body"],r,n),fullExamples:c?.examples,source:r}}return i}function xSr({operationContext:e,context:t,responseStatusCode:r,suffix:n,streamFormat:i,source:a}){let{document:u,operation:f,path:d,method:c,baseBreadcrumbs:o,sdkMethodName:l}=e,m=B_(f,wh.IDEMPOTENT),O=B_(f,[wh.REQUEST_NAME_V1,wh.REQUEST_NAME_V2]),j=[...o,"Request"],A=Qwa({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:j,path:d,httpMethod:c,source:a}),T=f.requestBody!=null?pNn({requestBody:f.requestBody,document:u,context:new nNn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:j,source:a,namespace:t.namespace}):void 0;(A.queryParameters.length>0||A.headers.length>0)&&T!=null&&T.type==="json"&&T.schema.type!=="object"&&f.requestBody!=null?T=pNn({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j,"Body"],source:a,namespace:t.namespace}):f.requestBody!=null&&(T=pNn({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j],source:a,namespace:t.namespace}));let B=[...o,"Response"],F=n3f({operationContext:e,streamFormat:i,responses:f.responses,context:t,responseBreadcrumbs:B,responseStatusCode:r,source:a}),C=Y6f(f),N=K6f(e,f,t),U=B_(f,wh.SERVER_NAME_V2);return{summary:f.summary,internal:B_(f,Ewe.INTERNAL),idempotent:m,audiences:B_(f,wh.AUDIENCES)??[],operationId:f.operationId!=null&&n!=null?f.operationId+"_"+n:f.operationId,tags:t.resolveTagsToTagIds(f.tags),namespace:t.namespace,sdkName:l,pathParameters:A.pathParameters,queryParameters:A.queryParameters,headers:A.headers,requestNameOverride:O??void 0,generatedRequestName:b8(j),request:T,response:F.value,errors:F.errors,server:U!=null?[{name:U,url:void 0,audiences:void 0}]:(f.servers??[]).map(ne=>Jwa(ne)),description:f.description,authed:Saw(f,u),availability:C,method:c,path:d,examples:N,pagination:e.pagination,source:a}}function Saw(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function a3f({operationContext:e,context:t,asyncExtension:r,source:n}){let{operation:i,pathItemParameters:a,operationParameters:u}=e,f=r.discriminant.name,d=r.discriminant.value,c=r["response-status-code"],o=i3f({context:t,headerToIgnore:f,parameters:a}),l=i3f({context:t,headerToIgnore:f,parameters:u}),m=xSr({operationContext:{...e,pathItemParameters:o,operationParameters:l,operation:{...i,responses:Object.fromEntries(Object.entries(i.responses).filter(([j])=>parseInt(j)!==c))}},context:t,streamFormat:void 0,source:n}),O=xSr({operationContext:{...e,pathItemParameters:o,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:c,streamFormat:void 0,source:n});return O.headers.push({name:f,schema:Op.literal({nameOverride:void 0,generatedName:b8([f]),title:void 0,description:void 0,availability:void 0,value:_I.string(d),groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:n}),{sync:m,async:O}}function i3f({context:e,headerToIgnore:t,parameters:r}){return r.filter(n=>{let i=Kh(n)?e.resolveParameterReference(n):n;return!(i.in==="header"&&i.name===t)})}var qju="stream";function c3f({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:xSr({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let n=o3f({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(n?.schemaReference!=null){let c=n3r(n.schemaReference);c!=null&&t.excludeSchema(c)}let i=u3f({operation:e.operation,response:r.responseStream}),a=xSr({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+qju}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:n?.requestBody,responses:i},baseBreadcrumbs:[...e.baseBreadcrumbs,qju]},context:t,streamFormat:r.format,suffix:qju,source:t.source});a.examples=a.examples.filter(c=>s3f(c,t)!==!1);let u=o3f({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),f=u3f({operation:e.operation,response:r.response}),d=xSr({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:f}},context:t,source:t.source});return d.examples=d.examples.filter(c=>s3f(c,t)!==!0),{streaming:a,nonStreaming:d}}default:sc(r)}}function o3f({context:e,operation:t,streamingExtension:r,isStreaming:n}){if(t.requestBody==null)return;let i=Kh(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=dNn(i.content,e);if(a==null)return;let u=Kh(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let f=u.properties?.[r.streamConditionProperty];f!=null&&Kh(f)&&(f=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":n,...f??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[eI.APPLICATION_JSON]:{schema:d}}},schemaReference:Kh(a.schema)?a.schema:void 0}}function u3f({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[eI.APPLICATION_JSON]:{schema:t}}}}}function s3f(e,t){return e._visit({unknown:r=>{let n=UQ.serialization.ExampleEndpointCallSchema.parse(r);if(n.ok&&n.value.response!=null)return n.value.response.stream!=null},full:()=>{},_other:()=>{}})}function l3f({context:e,operationContext:t,source:r}){let{document:n,operation:i,path:a,method:u,baseBreadcrumbs:f,sdkMethodName:d}=t,c=[...f,"Payload"],o=Qwa({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:c,path:a,httpMethod:u,source:r});if(i.requestBody==null){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Missing a request body`);return}if(u!=="POST"&&u!=="GET"){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Not POST or GET`);return}let l=pNn({requestBody:i.requestBody,document:n,context:e,requestBreadcrumbs:[...f,"Payload"],source:r,namespace:e.namespace});if(l==null||l.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(i.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:i.summary,sdkName:d,namespace:e.namespace,method:u,operationId:i.operationId,tags:e.resolveTagsToTagIds(i.tags),headers:o.headers,generatedPayloadName:b8(c),payload:l.schema,description:i.description,examples:Eaw(l.fullExamples),source:r}}function Eaw(e){if(e==null)return[];let t=[];for(let r of e){let n=i3r(r.value);n!=null&&t.push({description:r.description,name:r.name,payload:n})}return t}function Cju({context:e,pathItemContext:t,operation:r,convertToWebhook:n}){let i=B_(r,wh.IGNORE);if(i!=null&&i){e.logger.info(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=Aaw(r,e),u=M6f(e.document,r),f={...t,sdkMethodName:a,baseBreadcrumbs:Maw({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path}),operation:r,operationParameters:r.parameters??[],pagination:u};if(n){let l=l3f({context:e,operationContext:f,source:e.source});return l!=null?{type:"webhook",value:l}:void 0}let d=E6f(r);if(d!=null){let l=c3f({context:e,operationContext:f,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let c=D6f(r);if(c!=null){let l=a3f({context:e,operationContext:f,asyncExtension:c,source:e.source});return{type:"async",async:l.async,sync:l.sync}}return{type:"http",value:xSr({context:e,operationContext:f,streamFormat:void 0,source:e.source})}}function Aaw(e,t){let r=B_(e,wh.SDK_METHOD_NAME),n=B_(e,wh.SDK_GROUP_NAME)??[];if(r!=null){let i=typeof n=="string"?[n]:n;return i=t.resolveGroupName(i),{groupName:i,methodName:r}}}function Maw({sdkMethodName:e,operation:t,httpMethod:r,path:n}){let i=[];if(e!=null){if(e.groupName.length>0){let a=e.groupName[e.groupName.length-1];a!=null&&i.push(typeof a=="string"?a:a.name)}i.push(e.methodName)}else t.operationId!=null?i.push(t.operationId):i.push(mE(`${r}_${n.split("/").join("_")}`));return i}function f3f(e,t,r,n){let i=[],a=p3f(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=Taw({operation:f.operation}),c=Cju({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:d});c!=null&&i.push(c)}return i}function d3f(e,t,r,n){let i=[],a=p3f(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=Cju({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:!0});d!=null&&i.push(d)}return i}function p3f(e){let t=[];return e.get!=null&&t.push({method:nG.Get,operation:e.get}),e.post!=null&&t.push({method:nG.Post,operation:e.post}),e.put!=null&&t.push({method:nG.Put,operation:e.put}),e.delete!=null&&t.push({method:nG.Delete,operation:e.delete}),e.patch!=null&&t.push({method:nG.Patch,operation:e.patch}),t}function Taw({operation:e}){return B_(e,[wh.WEBHOOK])??!1}function _3f(e){let t=B_(e,wh.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=B_(e,wh.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function h3f(e){return B_(e,wh.FERN_BASIC_AUTH)}function Bju(e,t){if(Kh(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return xaw(e,t)}function xaw(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=B_(e,Ewe.BEARER_FORMAT),n=B_(e,wh.FERN_HEADER_AUTH);return Y9.header({headerName:e.name,prefix:r!=null?"Bearer":n?.prefix,headerVariableName:n?.name??B_(e,wh.HEADER_VARIABLE_NAME),headerEnvVar:n?.env})}else if(e.type==="http"&&e.scheme==="bearer"){let r=B_(e,wh.FERN_BEARER_TOKEN);return Y9.bearer({tokenVariableName:r?.name??B_(e,wh.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme==="basic"){let r=h3f(e),n=_3f(e);return Y9.basic({usernameVariableName:r?.username?.name??n.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??n.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return Y9.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return Y9.oauth({scopesEnum:qaw(e,t)})}throw new Error(`Failed to convert security scheme ${JSON.stringify(e)}`)}function qaw(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let n=r3r({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,groupName:void 0,context:void 0,source:t}),i=mx(n);if(i.type==="enum")return i}}function y3f(e){return B_(e,wh.BASE_PATH)}var Caw=Nwe.record(Nwe.string(),Nwe.object({summary:Nwe.string().optional(),description:Nwe.string().optional()}));function v3f({document:e,context:t}){return Uhi(e,wh.GROUPS,Caw,t.logger)}function b3f({context:e,document:t}){return B_(t,wh.FERN_VERSION)??void 0}function g3f(e){let t=B_(e,wh.FERN_GLOBAL_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?Vhi({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function m3f(e){let t=B_(e,wh.FERN_IDEMPOTENCY_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?Vhi({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function O3f(e){let t=B_(e,wh.SDK_VARIABLES);return t==null?{}:Object.fromEntries(Object.entries(t).map(([r,n])=>{if(n.type==="string")return[r,{nameOverride:void 0,generatedName:b8([r]),title:n.title,schema:q1.string({default:L7n(n),pattern:n.pattern,format:n.format,minLength:n.minLength,maxLength:n.maxLength}),description:n.description,availability:void 0,groupName:void 0}];throw new Error(`Variable ${r} has unsupported schema ${JSON.stringify(n)}`)}))}var Baw="webhooks";function P3f(e){return B_(e,Baw)??{}}var Gwa=class extends rNn{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discrminatedUnionReferences={};discrminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u})}getDummy(){return new nNn({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,n){let i=this.discrminatedUnionReferences[t.$ref];i!=null?(i.discriminants.add(r),i.numReferences+=n):this.discrminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:n}}getReferencesFromDiscriminatedUnion(t){return this.discrminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,n){let i=this.discrminatedUnionMetadata[t.$ref];i!=null?i.discriminants.set(r,n):this.discrminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,n]])}}getDiscriminatedUnionMetadata(t){return this.discrminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function j3f(e){return B_(e,wh.RESOLUTIONS)}function w3f({openapi:e}){let t=j3f(e);if(t==null)return e;let r={};for(let n of t){let i=`#/components/schemas/${n.name}`;for(let a of n.resolutions)e=Iaw({openapi:e,schemaReference:a,schemaName:n.name}),e=D3f({openapi:e,replaceReference:a,schemaReference:i,replacedReferences:r}),r={...r,...Object.fromEntries(n.resolutions.map(u=>[i,u]))}}return e}function Iaw({openapi:e,schemaReference:t,schemaName:r}){let n=t.replace("#/","").split("/").map(a=>a.replace("~1","/")),i=e;for(let a of n){let u=i[a];if(u==null)return e;i=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=i,e}function D3f({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:n}){let i=Object.keys(n).filter(d=>t.startsWith(d)).sort((d,c)=>c.length-d.length)[0];if(i!=null){let d=n[i];if(d!=null){let c=r.replace(i,d);return D3f({openapi:e,replaceReference:t,schemaReference:c,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replace("~1","/")),u=e;for(let d of a.slice(0,-1)){let c=u[d];if(c==null)return e;u=c}let f=a[a.length-1];return f==null||(u[f]={$ref:r}),e}function $wa({openApi:e,taskContext:t,options:r,source:n,namespace:i}){e=w3f({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([X,k])=>Bju(k,n)==null?[]:[X,Bju(k,n)])),u=new Set(...Object.entries(a).map(([X,k])=>k.type==="basic"||k.type==="bearer"?"Authorization":k.type==="header"?k.headerName:null)),f=new Gwa({document:e,taskContext:t,authHeaders:u,options:r,source:n,namespace:i}),d=O3f(e),c=g3f(e),o=m3f(e),l=r.audiences??[],m=[],O=[];Object.entries(e.paths??{}).forEach(([X,k])=>{if(k==null)return;t.logger.debug(`Converting path ${X}`);let xe=f3f(X,k,e,f);for(let vt of xe){let yt=S3f({operation:vt});if(!(l.length>0&&!l.some(St=>yt.includes(St))))switch(vt.type){case"async":m.push(vt.sync),m.push(vt.async);break;case"http":m.push(vt.value);break;case"streaming":m.push(vt.streaming),vt.nonStreaming&&m.push(vt.nonStreaming);break;case"webhook":O.push(vt.value);break;default:sc(vt)}}}),Object.entries(P3f(e)).forEach(([X,k])=>{if(k==null)return;t.logger.debug(`Converting path ${X}`);let xe=d3f(X,k,e,f);for(let vt of xe){let yt=S3f({operation:vt});l.length>0&&!l.some(St=>yt.includes(St))||O.push(vt.value)}});let j=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([X,k])=>{if(!Kh(k)){let xe=B_(k,wh.IGNORE);if(xe!=null&&xe)return[];if(t3f.has(X))return[X,aP({...k,"x-fern-type-name":`${X}Body`},!1,f,[X],n,i)]}return[X,aP(k,!1,f,[X],n,i)]}).filter(X=>X.length>0)),A=zaw(j,f,n),T=Naw(A,f),B={};for(let[X,k]of Object.entries(T)){let xe=mx(k);f.isSchemaExcluded(X)||(B[X]=xe,t.logger.debug(`Converted schema ${X}`))}let F=new a3r(T,f),C=O.map(X=>{let xe=X.examples;if(!r.disableExamples&&xe.length===0){let vt=F.buildExample({schema:X.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});vt!=null&&(xe=[{name:void 0,description:void 0,payload:vt}])}return{...X,payload:mx(X.payload),examples:xe}}),N=new Oma(T,f),U=m.map(X=>{let k=X.examples,xe=k;if(!r.disableExamples&&(k.length===0||k.every(Qhi))){let St=N.buildEndpointExample(X);St.length>0&&(xe=[...St,...k.filter(Ft=>!Qhi(Ft))])}let vt=X.request,yt=X.response;return{...X,request:vt?.type==="json"?{...vt,schema:mx(vt.schema)}:vt,response:yt?.type==="json"?{...yt,schema:mx(yt.schema)}:yt,queryParameters:X.queryParameters.map(St=>({description:St.description,name:St.name,schema:mx(St.schema),parameterNameOverride:St.parameterNameOverride,availability:St.availability,source:St.source})),pathParameters:X.pathParameters.map(St=>({description:St.description,name:St.name,schema:mx(St.schema),parameterNameOverride:St.parameterNameOverride,variableReference:St.variableReference,availability:St.availability,source:St.source})),headers:X.headers.map(St=>({description:St.description,name:St.name,schema:mx(St.schema),parameterNameOverride:St.parameterNameOverride,env:St.env,availability:St.availability,source:St.source})),examples:xe,errors:Vh(X.errors,St=>{let Ft=St.fullExamples?.map(Zt=>{let Vt=i3r(Zt.value);if(Vt!=null)return{name:Zt.name,description:Zt.description,example:Vt}}).filter(YA);if(Ft?.length===0){let Zt=F.buildExample({schema:St.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});Zt!=null&&Ft.push({name:void 0,description:void 0,example:Zt})}return{generatedName:St.generatedName,nameOverride:St.nameOverride,schema:mx(St.schema),description:St.description,source:St.source,examples:Ft}})}}),ne=v3f({document:e,context:f});return{apiVersion:b3f({context:f,document:e}),basePath:y3f(e),title:e.info.title,description:e.info.description,groups:Object.fromEntries(Object.entries(ne??{}).map(([X,k])=>[X,{summary:k.summary??void 0,description:k.description??void 0}])),servers:(e.servers??[]).map(X=>Jwa(X)),tags:{tagsById:Object.fromEntries((e.tags??[]).map(X=>[X.name,{id:X.name,description:X.description}])),orderedTagIds:e.tags?.map(X=>X.name)},endpoints:U,webhooks:C,channel:[],groupedSchemas:bma(i,B),securitySchemes:a,hasEndpointsMarkedInternal:U.some(X=>X.internal),nonRequestReferencedSchemas:f.getReferencedSchemas(),variables:d,globalHeaders:c,idempotencyHeaders:o}}function zaw(e,t,r){let n={};for(let[i,a]of Object.entries(e)){if(a.type!=="object"){n[i]=a;continue}let u={$ref:`#/components/schemas/${i}`},f=t.getReferencesFromDiscriminatedUnion(u);if(f==null){n[i]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!f.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!f.discriminants.has(o.propertyKey)),source:r};n[i]=d;let c=E3f({schema:a,schemas:e});for(let o of[...new Set(c)]){let l=n[o]??e[o];l==null||l.type!=="object"||(n[o]={...l,type:"object",properties:l.properties.filter(m=>!f.discriminants.has(m.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(m=>!f.discriminants.has(m.propertyKey))})}}return n}function Naw(e,t){let r={};for(let[n,i]of Object.entries(e)){if(i.type!=="object"){r[n]=i;continue}let a={$ref:`#/components/schemas/${n}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[n]=i;continue}let f=[];for(let c of i.properties)if(u.discriminants.has(c.key)){let o=u.discriminants.get(c.key);o!=null&&f.push({...c,schema:Op.literal({nameOverride:void 0,generatedName:b8([i.generatedName,o]),title:void 0,value:_I.string(o),groupName:void 0,description:void 0,availability:i.availability})})}else f.push(c);let d={...i,type:"object",properties:f};r[n]=d}return r}function E3f({schema:e,schemas:t}){let r=[];for(let n of e.allOf){r.push(n.schema);let i=t[n.schema];i!=null&&i.type==="object"&&r.push(...E3f({schema:i,schemas:t}))}return r}function S3f({operation:e}){let t=[];switch(e.type){case"async":t=e.async.audiences;break;case"http":t=e.value.audiences;break;case"streaming":t=e.streaming.audiences;break;case"webhook":break;default:sc(e)}return t}async function M3f({openApi:e,taskContext:t,options:r,source:n,namespace:i}){let a=await(0,A3f.convertObj)(e,{});return $wa({openApi:a.openapi,taskContext:t,options:r,source:n,namespace:i})}var qSr={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,cooerceEnumsToLiterals:!0,respectReadonlySchemas:!1,onlyIncludeReferencedSchemas:!1};async function ytn({absoluteFilePathToWorkspace:e,specs:t,taskContext:r,optionOverrides:n}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channel:[],groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let a of t){let u=(await(0,zju.readFile)(a.absoluteFilepath)).toString(),f=mC(e,a.source.file);a.source.relativePathToDependency!=null&&(f=Wl(a.source.relativePathToDependency,f));let d=a.source.type==="protobuf"?oSr.protobuf({file:f}):oSr.openapi({file:f});if(u.includes("openapi")||u.includes("swagger")){let c=await yIf({absolutePathToOpenAPI:a.absoluteFilepath,context:r,absolutePathToOpenAPIOverrides:a.absoluteFilepathToOverrides});if(Law(c)){let o=$wa({openApi:c,taskContext:r,options:Iju({specSettings:a.settings,overrides:n}),source:d,namespace:a.namespace});i=T3f(i,o)}else if(Uaw(c)){let o=await M3f({openApi:c,taskContext:r,options:Iju({specSettings:a.settings}),source:d,namespace:a.namespace});i=T3f(i,o)}}else if(u.includes("asyncapi")){let c=await Raw({absoluteFilePathToAsyncAPI:a.absoluteFilepath,context:r,absoluteFilePathToAsyncAPIOverrides:a.absoluteFilepathToOverrides}),o=ESf({document:c,taskContext:r,options:Iju({specSettings:a.settings}),source:d,asyncApiOptions:Faw({specSettings:a.settings}),namespace:a.namespace});o.channel!=null&&i.channel.push(o.channel),o.groupedSchemas!=null&&(i.groupedSchemas=x3f(i.groupedSchemas,o.groupedSchemas)),o.basePath!=null&&(i.basePath=o.basePath)}else r.failAndThrow(`${a.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}function Iju({specSettings:e,overrides:t}){return{disableExamples:t?.disableExamples??qSr.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.shouldUseUndiscriminatedUnionsWithLiterals??qSr.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.shouldUseTitleAsName??qSr.useTitlesAsName,audiences:t?.audiences??e?.audiences??qSr.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??qSr.optionalAdditionalProperties,cooerceEnumsToLiterals:t?.cooerceEnumsToLiterals??e?.cooerceEnumsToLiterals??qSr.cooerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??qSr.respectReadonlySchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??qSr.onlyIncludeReferencedSchemas}}function Faw({specSettings:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??ZDf.naming}}function T3f(e,t){return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channel:[...e.channel,...t.channel],groupedSchemas:x3f(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 x3f(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,n]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...n}:e.namespacedSchemas[r]=n;return e}async function Raw({absoluteFilePathToAsyncAPI:e,absoluteFilePathToAsyncAPIOverrides:t,context:r}){let n=(await(0,zju.readFile)(e)).toString(),i=await Fy.load(n);return t!=null?await xja({absoluteFilepathToOverrides:t,context:r,data:i}):i}function Law(e){return e.openapi!=null}function Uaw(e){return e.swagger!=null}function Ywa({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=Nju({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=gx(i.value);if(a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>"),e.description==null&&!i.allowMultiple&&e.parameterNameOverride==null&&e.availability==null)return a;let u={type:a};return i.allowMultiple&&(u["allow-multiple"]=!0),e.description!=null&&(u.docs=e.description),e.parameterNameOverride!=null&&(u.name=e.parameterNameOverride),e.availability!=null&&(u.availability=gz(e.availability)),Vaw(i.value)&&i.value.validation!==void 0&&(u.validation=i.value.validation),u}function Nju({schema:e,context:t,fileContainingReference:r,namespace:n}){if(e.type==="reference"){let i=t.getSchema(e.schema,n);if(i==null)return;if(i.type==="array")return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,declarationFile:ls.of(mD),fileContainingReference:r,namespace:n}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undisciminated"){let a=[];for(let[u,f]of Object.entries(i.value.schemas))f.type==="literal"&&f.value.type==="string"&&(F7n.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:Whi(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[u,f]=i.value.schemas;if(u!=null&&f!=null&&Kwa({array:u,primitive:f}))return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(u!=null&&f!=null&&Kwa({array:u,primitive:f}))return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[u,f]of Object.entries(i.value.schemas))return Nju({schema:f,context:t,fileContainingReference:r,namespace:n})}else if(t.objectQueryParameters)return{value:qO({schema:e,context:t,fileContainingReference:r,declarationFile:ls.of(mD),namespace:n}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let i=t.getSchema(e.value.schema,n);if(i==null)return;if(i.type==="array")return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,declarationFile:ls.of(mD),namespace:n}),allowMultiple:!0};if(t.objectQueryParameters)return{value:qO({schema:e,context:t,fileContainingReference:r,declarationFile:ls.of(mD),namespace:n}),allowMultiple:!1}}if(e.value.type==="array")return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undisciminated"){let i=[];for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="literal"&&u.value.type==="string"&&(F7n.test(u.value.value)?i.push(u.value.value):i.push({value:u.value.value,name:Whi(u.value.value)}));if(i.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:i}}),{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[a,u]=e.value.value.schemas;if(a!=null&&u!=null&&Kwa({array:a,primitive:u}))return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(a!=null&&u!=null&&Kwa({array:u,primitive:a}))return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[a,u]of Object.entries(e.value.value.schemas))return Nju({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return t.objectQueryParameters?{value:qO({schema:e,context:t,fileContainingReference:r,declarationFile:ls.of(mD),namespace:n}),allowMultiple:!1}:void 0;return{value:qO({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}return e.type==="array"?{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}:{value:qO({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}function Kwa({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function Vaw(e){return e.type!=null}function q3f({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"]=Waw(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=Haw({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=k3r(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function Waw(e){let t={};return e.forEach(r=>{let n=k3r(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function Haw({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=k3r(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function k3r(e){switch(e.type){case"primitive":return C3f(e.value);case"object":return B3f(e.properties);case"array":return Jaw(e.value);case"map":return Qaw(e.value);case"oneOf":return Gaw(e.value);case"enum":return e.value;case"literal":return $aw(e.value);case"unknown":return k3r(e.value);default:sc(e)}}function C3f(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:sc(e)}}function B3f(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,k3r(r)]))}function Jaw(e){return e.map(t=>k3r(t))}function Qaw(e){return Object.fromEntries(e.map(t=>[C3f(t.key),k3r(t.value)]))}function Gaw(e){return e.type==="discriminated"?B3f(e.value):k3r(e.value)}function $aw(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:sc(e)}}function CSr(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function Xwa(e,t){return t??(e?.groupName!=null?CSr(e.groupName):void 0)}function I3f({channel:e,context:t,declarationFile:r}){let n={path:e.path,auth:!1};e.summary!=null&&(n["display-name"]=e.summary);let i=CSr(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=lma({pathParameter:d,context:t,fileContainingReference:r,namespace:i});Object.keys(a).length>0&&(n["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let c=Ywa({queryParameter:d,context:t,fileContainingReference:r,namespace:i});c!=null&&(u[d.name]=c)}Object.keys(u).length>0&&(n["query-parameters"]=u);let f={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let c=b8t({header:d,context:t,fileContainingReference:r,namespace:i});f[d.name]=c}Object.keys(f).length>0&&(n.headers=f),t.builder.addChannel(r,{channel:n}),e.subscribe!=null&&t.builder.addChannelMessage(r,{messageId:"subscribe",message:{origin:"server",body:qO({schema:e.subscribe,context:t,fileContainingReference:r,namespace:i})}}),e.publish!=null&&t.builder.addChannelMessage(r,{messageId:"publish",message:{origin:"client",body:qO({schema:e.publish,context:t,fileContainingReference:r,namespace:i})}});for(let d of e.examples){let c=q3f({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:c})}}var z3f="Production",N3f="Default";function F3f(e){return Object.entries(e).reduce((t,[r,n])=>(Kqn(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function R3f(e){if(e.environmentOverrides!=null){for(let[f,d]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:f,schema:d});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 f of e.ir.servers){let d=f.audiences?{url:f.url,audiences:f.audiences}:f.url;if(f.name==null){r.push(d);continue}t[f.name]=d}let n={},i=[];for(let f of e.ir.endpoints)for(let d of f.server){if(d.url==null)continue;let c=d.audiences?{url:d.url,audiences:d.audiences}:d.url;if(d.name==null){i.push(c);continue}n[d.name]=c}let a=Object.keys(t).length,u=Object.keys(n).length;if(a===0&&u===0){let f=e.ir.servers[0]?.url,d=e.ir.servers[0]?.audiences;f!=null&&(e.builder.addEnvironment({name:N3f,schema:d?{url:f,audiences:d}:f}),e.builder.setDefaultEnvironment(N3f))}else if(a>0&&u===0){let f=0;r.length>0&&e.logger.error(`Skipping servers ${r.map(d=>typeof d=="string"?d:d.url).join(", ")} because x-fern-server-name was not provided.`);for(let[d,c]of Object.entries(t))f===0&&e.builder.setDefaultEnvironment(d),e.builder.addEnvironment({name:d,schema:c}),f+=1}else if(u>0){(r.length>0||i.length>0)&&e.logger.error(`Skipping servers ${[...r,...i].map(d=>typeof d=="string"?d:d.url).join(", ")} because x-fern-server-name was not provided.`);let f=Object.entries(t)[0];if(f!=null){let[d,c]=f;e.setDefaultServerName(d)}e.builder.addEnvironment({name:z3f,schema:{urls:{...F3f(t),...F3f(n)}}}),e.builder.setDefaultEnvironment(z3f)}}function Zwa(e){return gx(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var Fju=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},Kaw=.75,Yaw=new Set("authorization");function L3f(e){if(e.globalHeaderOverrides!=null){for(let[r,n]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:n});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,n]of Object.entries(t)){let i="optional<string>";if(n.name==null&&n.env==null&&typeof n.schema=="string")i=n.schema;else if(n!=null){let a=n.schema?C7n(n.schema):void 0,u=a!=null?CSr(a):void 0,f=ls.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?gx(qO({schema:n.schema,context:e,fileContainingReference:u?Wl(ls.of(mE(u)),f):f,namespace:u}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:i})}if(e.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let a of i.headers){if(Yaw.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let f=t[a.name],d=b8t({header:{...a,schema:f?.schema??a.schema,name:f?.name??a.name},fileContainingReference:ls.of(eF),context:e,namespace:void 0});u=new Fju(d),r[a.name]=u}u.increment()}let n=e.ir.endpoints.length*Kaw;for(let[i,a]of Object.entries(r)){let u=t[i],f=a.count===e.ir.endpoints.length,d=a.count>=n;u==null&&(f?e.builder.addGlobalHeader({name:i,schema:a.schema}):d&&e.builder.addGlobalHeader({name:i,schema:Zwa(a.schema)}))}}}function U3f(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?C7n(t.schema):void 0,n=r!=null?CSr(r):void 0,i=b8t({header:{...t,schema:t.schema??J0.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:q1.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:ls.of(eF),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:Zwa(i)})}}function WX(e){switch(e.type){case"primitive":return W3f(e.value);case"object":return H3f(e.properties);case"array":return J3f(e.value);case"map":return Xaw(e.value);case"oneOf":return Zaw(e.value);case"enum":return e.value;case"literal":return kaw(e.value);case"unknown":return WX(e.value);default:sc(e)}}function V3f(e){switch(e.type){case"withStreaming":return{stream:J3f(e.value)};case"withoutStreaming":return{body:WX(e.value)};default:sc(e)}}function W3f(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:sc(e)}}function H3f(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,WX(r)]))}function J3f(e){return e.map(t=>WX(t))}function Xaw(e){return Object.fromEntries(e.map(t=>[W3f(t.key),WX(t.value)]))}function Zaw(e){return e.type==="discriminated"?H3f(e.value):WX(e.value)}function kaw(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:sc(e)}}function Q3f({endpointExample:e,context:t}){let r={};return e.type!=="full"?e.value:(e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=eow(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=tow(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=row({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=WX(e.request)),e.response!=null&&(r.response=V3f(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(n=>n.type==="language"?{name:n.name??void 0,docs:n.description??void 0,language:n.language,code:n.code,install:n.install??void 0}:{name:n.name??void 0,docs:n.description??void 0,sdk:n.sdk,code:n.code}).filter(YA)),r)}function eow(e){let t={};return e.forEach(r=>{let n=WX(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function tow(e){let t={};return e.forEach(r=>{let n=WX(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function row({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=WX(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function G3f(e){return nG._visit(e,{get:()=>UQ.HttpMethodSchema.Get,post:()=>UQ.HttpMethodSchema.Post,put:()=>UQ.HttpMethodSchema.Put,patch:()=>UQ.HttpMethodSchema.Patch,delete:()=>UQ.HttpMethodSchema.Delete,head:()=>{throw new Error("HEAD is unsupported")},options:()=>{throw new Error("HEAD is unsupported")},trace:()=>{throw new Error("HEAD is unsupported")},_other:()=>{throw new Error("Unkown http method is unsupported")}})}function $3f({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,u=e.path,f=Xwa(e.sdkName,e.namespace),d={};for(let A of e.pathParameters)A.parameterNameOverride&&(u=u.replace(A.name,A.parameterNameOverride)),d[A.parameterNameOverride??A.name]=lma({pathParameter:A,context:r,fileContainingReference:t,namespace:f}),a.add(A.name);let c={};for(let A of e.queryParameters){let T=Ywa({queryParameter:A,context:r,fileContainingReference:t,namespace:f});T!=null&&(c[A.name]=T,a.add(A.name))}let o;e.pagination!=null&&(e.pagination.type==="cursor"?o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results}:o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage});let l={path:u,method:G3f(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?lSr(e.source):void 0};Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let m={},O=r.builder.getGlobalHeaderNames(),j=e.headers.filter(A=>!O.has(A.name));for(let A of j){let T=b8t({header:A,context:r,fileContainingReference:t,namespace:f});m[A.name]=T,a.add(typeof T=="string"?A.name:T.name??A.name)}if(e.request!=null){r.setInState(v8.Request);let A=iow({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,queryParameters:Object.keys(c).length>0?c:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(m).length>0?m:void 0,usedNames:a,namespace:f});l.request=A.value,i=[...i,...A.schemaIdsToExclude??[]],r.unsetInState(v8.Request)}else{let A=Object.keys(c).length>0,T=Object.keys(m).length>0,B={};(A||T)&&(B.name=e.requestNameOverride??e.generatedRequestName),A&&(B["query-parameters"]=c),T&&(B.headers=m),Object.keys(B).length>0&&(l.request=B)}if(e.response!=null&&e.response._visit({json:A=>{let T=qO({schema:A.schema,context:r,fileContainingReference:t,namespace:f});l.response={docs:A.description??void 0,type:gx(T)},A.responseProperty!=null&&(l.response.property=A.responseProperty)},streamingJson:A=>{let T=qO({schema:A.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:A.description??void 0,type:gx(T),format:"json"}},streamingSse:A=>{let T=qO({schema:A.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:A.description??void 0,type:gx(T),format:"sse"}},file:A=>{l.response={docs:A.description??void 0,type:"file"}},streamingText:A=>{l["response-stream"]={docs:A.description??void 0,type:"text"}},text:A=>{l.response={docs:A.description??void 0,type:"text"}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let A=r.getDefaultServerName(),T=e.server[0];T==null?A!=null&&(l.url=A):l.url=T.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=gz(e.availability)),Object.entries(e.errors).forEach(([A,T])=>{let B=T.generatedName,F=ls.of(mD);r.builder.enableUniqueErrorsPerEndpoint&&(B=`${e.generatedRequestName}${T.generatedName}`,T.schema!=null&&(T.schema.type!=="reference"&&T.schema.type!=="oneOf"?T.schema.generatedName=`${e.generatedRequestName}${T.schema.generatedName}`:T.schema.type==="oneOf"&&(T.schema.value.generatedName=`${e.generatedRequestName}${T.schema.value.generatedName}`)));let C={"status-code":parseInt(A)},N=HDf({location:K3f,namespaceOverride:f});if(T.schema!=null){let ge=qO({schema:T.schema,context:r,fileContainingReference:N,declarationFile:N,namespace:f});C.type=gx(ge),C.docs=T.description}r.builder.addError(N,{name:B,schema:r.isErrorUnknownSchema(parseInt(A))?{...C,type:"unknown"}:C}),l.errors==null&&(l.errors=[]);let U=r.builder.addImport({file:t,fileToImport:N});l.errors.push(U!=null?`${U}.${B}`:B),C.type!=null&&T.examples?.forEach(ge=>{let X={value:WX(ge.example),name:ge.name,docs:ge.description};r.builder.addErrorExample(N,{name:B,example:X})})}),e.examples.length>0&&(l.examples=now({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[Rju,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function now({endpointExamples:e,context:t}){return e.map(r=>{try{return Q3f({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function iow({endpoint:e,declarationFile:t,context:r,request:n,requestNameOverride:i,generatedRequestName:a,queryParameters:u,nonRequestReferencedSchemas:f,headers:d,usedNames:c,namespace:o}){if(n.type==="json"){let l=n.schema.type==="reference"?n.schema.schema:void 0,m=n.schema.type==="reference"?r.getSchema(n.schema.schema,o):n.schema;if(m?.type!=="object"||l!=null&&f.includes(l)){let B=qO({schema:n.schema,fileContainingReference:t,context:r,namespace:o}),F={schemaIdsToExclude:[],value:{body:B}},C=Object.keys(u??{}).length>0,N=Object.keys(d??{}).length>0;return C&&(F.value["query-parameters"]=u),N&&(F.value.headers=d),(C||N)&&(F.value.name=i??a),n.contentType!=null&&(F.value["content-type"]=n.contentType),n.description!=null&&(F.value.docs=n.description),F}let O=Object.fromEntries(m.properties.filter(B=>B.readonly==null?!0:!((e.method==="POST"||e.method==="PUT")&&B.readonly)).map(B=>{let F=qO({schema:B.schema,fileContainingReference:t,context:r,namespace:o}),C=B.nameOverride??B.key,N=gz(B.availability);if(!c.has(C)&&B.audiences.length<=0)return c.add(C),B.nameOverride!=null?[B.key,{type:gx(F),docs:Rhi(F),name:B.nameOverride,availability:N}]:[B.key,N?{...typeof F=="string"?{type:F}:F,availability:N}:F];let U={type:gx(F),docs:Rhi(F)};return c.has(C)&&(U.name=B.generatedName),B.audiences.length>0&&(U.audiences=B.audiences),N!=null&&(U.availability=N),c.add(C),[B.key,U]})),j=m.allOf.map(B=>{let F=qO({schema:J0.reference(B),fileContainingReference:t,context:r,namespace:o});return gx(F)}),A={properties:O};j.length>0&&(A.extends=j),n.additionalProperties&&(A["extra-properties"]=!0);let T={name:i??m.nameOverride??m.generatedName,"query-parameters":u,headers:d,body:A};return n.contentType!=null&&(T["content-type"]=n.contentType),n.description!=null&&(T.docs=n.description),{schemaIdsToExclude:l!=null?[l]:[],value:T}}else{if(n.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":eI.APPLICATION_OCTET_STREAM,...n.description?{docs:n.description}:{}}};if(n.type==="multipart"){let l=Object.fromEntries(n.properties.map(m=>{if(m.schema.type==="file"){let O=m.schema.isArray?"list<file>":"file";if(O=m.schema.isOptional?`optional<${O}>`:O,m.description!=null||m.contentType!=null){let j={type:O};return m.description!=null&&(j.docs=m.description),m.contentType!=null&&(j["content-type"]=m.contentType),[m.key,j]}return[m.key,O]}else{let O=qO({schema:m.schema.value,fileContainingReference:t,context:r,namespace:o});return m.contentType!=null&&(typeof O=="string"?O={type:O,"content-type":m.contentType}:O["content-type"]=m.contentType),[m.key,O]}}));return{schemaIdsToExclude:n.name==null?[]:[n.name],value:{name:i??n.name??a,"query-parameters":u,headers:d,body:{properties:l},"content-type":eI.MULTIPART_FORM_DATA,...n.description?{docs:n.description}:{}}}}else sc(n)}}function aow({location:e,namespaceOverride:t}){return t!=null?{...e,file:Wl(ls.of(t),e.file)}:e}function oow(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:ls.of(`${mE(r)}.yml`),endpointId:e.summary!=null?mE(e.summary):mE(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:ls.of(mD),endpointId:mE(e.summary)}:{file:ls.of(mD),endpointId:mE(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:ls.of(mD),endpointId:n};let i=e0i(r),a=e0i(n);if(zqt(i,a))return{file:ls.of("__package__.yml"),endpointId:r};let u=cow({operationId:n,tag:r,path:e.path,method:e.method});if(u!=null)return u;let f=[];for(let d=0;d<i.length;++d){let c=i[d];if(c!=null&&c===a[d])f.push(c);else{let o=mE(r);return{file:ls.of(`${o}.yml`),endpointId:n,tag:r}}}if(f.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:ls.of(mE(f.join("_"))+".yml"),endpointId:mE(a.slice(f.length).join("_")),tag:r}}function t0i(e){let t=e.tags[0];if(e.sdkName!=null){let r=Iyu({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:ls.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return aow({namespaceOverride:e.namespace,location:oow(e)})}function e0i(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=m6t(t),t}var uow=new RegExp("[^a-zA-Z0-9{}]+"),sow=new RegExp("[{}]","g");function cow({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(uow).join("_").replaceAll(sow,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:ls.of(mE(t)+".yml"),endpointId:mE(e.slice(0,-1*a.length)),tag:t}}function Y3f(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:u,file:f,tag:d}=t0i(a),c=f.split(".")[0];c!=null&&t.add(c);let o;if(a.sdkName!=null){let O=e.ir.groups;for(let j of a.sdkName.groupName){let A=typeof j=="string"?j:j.name,T=O[A];if(T==null)break;if(T.summary!=null||T.description!=null){o=O[A];break}}}let l=d==null?void 0:n.tagsById[d];e.setInState(v8.Endpoint),e.setEndpointMethod(a.method);let m=$3f({context:e,endpoint:a,declarationFile:f});e.unsetEndpointMethod(),e.unsetInState(v8.Endpoint),i=[...i,...m.schemaIdsToExclude],e.builder.addEndpoint(f,{name:u,schema:m.value,source:a.source!=null?lSr(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(f,{"display-name":o?.summary??l?.id,docs:o?.description??l?.description??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}function X3f(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?CSr(r.groupName):void 0,i=qO({schema:J0.primitive(r),context:e,fileContainingReference:ls.of(mD),namespace:n});e.builder.addVariable({name:t,schema:{type:gx(i),docs:r.description??void 0}})}}function Z3f(e){for(let t of e.ir.webhooks){let r=dow({webhook:t,context:e});if(r==null)continue;let n=Xwa(t.sdkName,t.namespace),i={};for(let u of t.headers)i[u.name]=b8t({header:u,context:e,fileContainingReference:r.file,namespace:n});let a={method:t.method,"display-name":t.summary??void 0,headers:i,payload:qO({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:WX(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function low({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:Wl(ls.of(t),e.file)}:e}function fow({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:ls.of(mD),endpointId:n};let i=e0i(r),a=e0i(n);if(zqt(i,a))return{file:ls.of("__package__.yml"),endpointId:r};let u=[];for(let f=0;f<i.length;++f){let d=i[f];if(d!=null&&d===a[f])u.push(d);else{let c=mE(r);return{file:ls.of(`${c}.yml`),endpointId:n,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:ls.of(mE(u.join("_"))+".yml"),endpointId:mE(a.slice(u.length).join("_")),tag:r}}function dow({webhook:e,context:t}){return e.sdkName!=null?{file:WDf({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:low({namespaceOverride:e.namespace,location:fow({webhook:e,context:t})})}var pow=ls.of(mD);function k3f(e){switch(e.type){case"object":return R8t(e.groupName);case"enum":return R8t(e.groupName);case"oneOf":return R8t(e.value.groupName);case"array":return R8t(e.groupName);case"map":return R8t(e.groupName);case"reference":return R8t(e.groupName);case"literal":return R8t(e.groupName);case"optional":return R8t(e.groupName);case"nullable":return R8t(e.groupName);case"primitive":return R8t(e.groupName);case"unknown":return pow;default:sc(e)}}function R8t(e){return B7n(e)}var Rju="external",K3f=ls.of(mD);function e4f({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let u=k3f(a),f=GDf({schema:a,context:n,declarationFile:u,namespace:r});if(Wzr(f.schema)){let d=gx(f.schema);if(d===(f.name??i)||d===`optional<${f.name??i}>`)continue}n.builder.addType(u,{name:f.name??i,schema:f.schema})}}function t4f(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),R3f(e),L3f(e),U3f(e),XDf(e),X3f(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(Rju);let t=Y3f(e),r=t.sdkGroups;e.setInState(v8.Webhook),Z3f(e),e.unsetInState(v8.Webhook),e.setInState(v8.Channel);for(let i of e.ir.channel){let a=B7n(i.groupName);I3f({channel:i,context:e,declarationFile:a})}e.unsetInState(v8.Channel);let n=_ow({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});e4f({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:n,namespace:void 0,context:e});for(let[i,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))e4f({schemas:a,schemaIdsToExclude:n,namespace:i,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 _ow({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let n=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),i=new Set(t);for(let a of n)r.includes(a)||i.add(a);return Array.from(i)}var r0i=class{context;constructor(t){this.context=t}};var e4r=Jo(require("path"),1);var kwa=Jo(require("path"),1),e1a=class e{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[u,f]of Object.entries(n.files)){let d=i!=null?ls.of(`${i}${kwa.default.sep}${u}`):ls.of(u);t[d]=f}let a=Object.keys(n.directories).sort();for(let u of a){let f=i!=null?`${i}${kwa.default.sep}${u}`:u,d=n.directories[u];r(d,f)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(kwa.default.sep))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[ls.of(t[0])]??={};let[r,...n]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(n)}};var vtn=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new e1a,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":n,"display-name":i,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),n!=null&&(u.service["base-path"]=n),i!=null&&(u.service["display-name"]=i),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 iDr(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{}),r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}addGlobalHeader({name:t,schema:r}){let n=this.getVersionHeader();n!=null&&n===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:n}){if(t===r)return;let i=n??mE((B0(r)+"/"+(0,e4r.basename)(r,(0,e4r.extname)(r))).replaceAll("__package__","root"));if(t===ls.of(eF))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[i]=mC(B0(Hp.of(`/${t}`)),Hp.of(`/${r}`)),i;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[i]=mC(B0(Hp.of(`/${t}`)),Hp.of(`/${r}`)),i}addType(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.types==null&&(i.types={}),i.types[r]=n}addTypeExample(t,r,n){let i=this.getOrCreateFile(t);i.types==null&&(i.types={});let a=i.types[r];a!=null&&(typeof a=="string"?i.types[r]={type:a,examples:[n]}:(a.examples==null&&(a.examples=[]),a.examples.push(n)))}addError(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.errors==null&&(i.errors={}),i.errors[r]==null?i.errors[r]=n:i.errors[r]?.type!==n.type&&(i.errors[r]={"status-code":n["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:n}){let i=this.getOrCreateFile(t);if(i.errors==null)return;let a=i.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(f=>zqt(f,n))??!1)||a.examples?.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(a.service.source=i),a.service.endpoints[r]=n}addWebhook(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.webhooks==null&&(i.webhooks={}),i.webhooks[r]=n}addChannel(t,{channel:r}){let n=this.getOrCreateFile(t);n.channel=r;let i=this.basePath;i!=null&&(n.channel.path=e4r.default.join(i,r.path))}addChannelExample(t,{example:r}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.examples==null&&(n.channel.examples=[]),n.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:n}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.messages[r]=n}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([i,a])=>[i,{...a,path:e4r.default.join(r,a.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([a,u])=>[a,{...u,path:e4r.default.join(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===mD?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}};var t1a=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;onlyIncludeReferencedSchemas;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,enableUniqueErrorsPerEndpoint:n,detectGlobalHeaders:i,environmentOverrides:a,globalHeaderOverrides:u,authOverrides:f,objectQueryParameters:d,respectReadonlySchemas:c,onlyIncludeReferencedSchemas:o}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.enableUniqueErrorsPerEndpoint=n,this.builder=new vtn(n),r.title!=null&&this.builder.setDisplayName({displayName:r.title}),this.detectGlobalHeaders=i,this.environmentOverrides=a,this.authOverrides=f,this.globalHeaderOverrides=u,this.objectQueryParameters=d,this.respectReadonlySchemas=c,this.onlyIncludeReferencedSchemas=o,this.referencedSchemaIds=o?new Set:void 0;let l={};if(!this.enableUniqueErrorsPerEndpoint)for(let m of r.endpoints)for(let[O,j]of Object.entries(m.errors)){let A=parseInt(O),T=l[A];T==null&&j.schema!=null?l[A]=j.schema:T!=null&&j.schema!=null&&Awe(T,j.schema)||this.unknownSchema.add(A)}}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(v8.Channel,v8.Endpoint,v8.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:sc(t)}}markObjectSchemaAsReferenced(t,r){for(let n of t.allOf)this.markSchemaIdAsReferenced(n.schema,r);for(let n of t.properties)this.markSchemaAsReferenced(n.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let n of Object.values(t.schemas))this.markSchemaAsReferenced(n,r);return;case"undisciminated":for(let n of t.schemas)this.markSchemaAsReferenced(n,r);return;default:sc(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let n=this.getSchema(t,r);n!=null&&this.markSchemaAsReferenced(n,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function Lju(e){let t=new t1a(e);return t4f(t)}function r1a(e,t){return Vh(e,t)}var Fxe=class extends p2t{specs;sources;respectReadonlySchemas;onlyIncludeReferencedSchemas;constructor({specs:t,...r}){super(r),this.specs=t,this.sources=this.convertSpecsToIdentifiableSources(t),this.respectReadonlySchemas=this.specs.every(n=>n.settings?.respectReadonlySchemas??!1),this.onlyIncludeReferencedSchemas=this.specs.every(n=>n.settings?.onlyIncludeReferencedSchemas??!1)}async getOpenAPIIr({context:t,relativePathToDependency:r},n){let i=await Gkr({context:t,specs:this.specs,relativePathToDependency:r}),a=how(n);return await ytn({absoluteFilePathToWorkspace:this.absoluteFilePath,specs:i,taskContext:t,optionOverrides:{...a,respectReadonlySchemas:this.respectReadonlySchemas,onlyIncludeReferencedSchemas:this.onlyIncludeReferencedSchemas}})}async getDefinition({context:t,relativePathToDependency:r},n){let i=await this.getOpenAPIIr({context:t,relativePathToDependency:r},n),a=this.specs.every(f=>f.settings?.objectQueryParameters),u=Lju({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,taskContext:t,ir:i,enableUniqueErrorsPerEndpoint:n?.enableUniqueErrorsPerEndpoint??!1,detectGlobalHeaders:n?.detectGlobalHeaders??!0,objectQueryParameters:a,respectReadonlySchemas:this.respectReadonlySchemas,onlyIncludeReferencedSchemas:this.onlyIncludeReferencedSchemas});return{absoluteFilePath:Hp.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:u.rootApiFile["default-url"],contents:u.rootApiFile,rawContents:Fy.dump(u.rootApiFile)},namedDefinitionFiles:{...r1a(u.definitionFiles,f=>({absoluteFilepath:Hp.of("/DUMMY_PATH"),rawContents:Fy.dump(f),contents:f})),[ls.of(mD)]:{absoluteFilepath:Hp.of("/DUMMY_PATH"),rawContents:Fy.dump(u.packageMarkerFile),contents:u.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new _2t({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(YA)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,n=[];return t.reduce((i,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),i.push({type:a.type,id:d6r(),absoluteFilePath:u})),i},n)}};function n0i(e){if(e.settings==null)return;let t={detectGlobalHeaders:!0};return e.settings.unions==="v1"&&(t.enableDiscriminatedUnionV2=!0),t}function how(e){if(e==null)return;let t={};return e.enableDiscriminatedUnionV2&&(t.discriminatedUnionV2=!0),e.optionalAdditionalProperties&&(t.optionalAdditionalProperties=!0),e.cooerceEnumsToLiterals&&(t.cooerceEnumsToLiterals=!0),t}function r4f(e,t){if(yow(e))return t.alias(e);if(vow(e))return t.enum(e);if(bow(e))return t.object(e);if(gow(e))return t.union(e);sc(e)}function yow(e){return e?.alias!=null}function vow(e){return e?.values!=null}function bow(e){return e?.fields!=null}function gow(e){return e?.union!=null}var w1a={};Dc(w1a,{ConjureAliasDeclaration:()=>c1a,ConjureArgument:()=>O1a,ConjureArgumentWithParamType:()=>m1a,ConjureDefinitions:()=>v1a,ConjureEndpoint:()=>P1a,ConjureEnumDeclaration:()=>h1a,ConjureEnumVariant:()=>_1a,ConjureEnumWithDocs:()=>p1a,ConjureObjectDeclaration:()=>d1a,ConjureParamType:()=>g1a,ConjurePrimitive:()=>s1a,ConjureService:()=>j1a,ConjureServiceName:()=>u1a,ConjureType:()=>n4r,ConjureTypeDeclaration:()=>y1a,ConjureTypeReference:()=>i4r,ConjureTypeWithDocs:()=>l1a,ConjureTypes:()=>b1a,ConjureUnionDeclaration:()=>f1a,DefinitionFile:()=>M4f,WithDocs:()=>U8t,commons:()=>Jju,conjure:()=>Qju,services:()=>Gju,types:()=>$ju});var Jju={};Dc(Jju,{WithDocs:()=>U8t});var _y={};Dc(_y,{JsonError:()=>_Nn,ParseError:()=>hNn,any:()=>y4f,boolean:()=>v4f,booleanLiteral:()=>h4f,date:()=>i4f,discriminant:()=>S4f,enum_:()=>i1a,getObjectLikeUtils:()=>L8t,getObjectUtils:()=>vNn,getSchemaUtils:()=>v2,isProperty:()=>r4r,lazy:()=>a4f,lazyObject:()=>d4f,list:()=>o1a,number:()=>b4f,object:()=>a1a,objectWithoutOptionalProperties:()=>f4f,optional:()=>Uju,property:()=>u4f,record:()=>P4f,set:()=>j4f,string:()=>g4f,stringLiteral:()=>_4f,transform:()=>Vju,undiscriminatedUnion:()=>D4f,union:()=>A4f,unknown:()=>m4f,withParsedProperties:()=>Hju});var ES={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 ${mow(e)}.`}function mow(e){if(Array.isArray(e))return"list";if(e===null)return"null";switch(typeof e){case"string":return`"${e}"`;case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function yG(e){return{...e,json:n4f(e.json),parse:n4f(e.parse)}}function n4f(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1923
|
+
`)),{ok:!0,value:t}):n}}function dba(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var s7n=class e extends Error{errors;constructor(t){super(t.map(dba).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var c7n=class e extends Error{errors;constructor(t){super(t.map(dba).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function h2(e){return{optional:()=>Eyu(e),transform:t=>Ayu(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new c7n(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new s7n(n.errors)}}}function Eyu(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>DS.OPTIONAL};return{...t,...h2(t)}}function Ayu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...h2(r)}}var x2j=/^([+-]?\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 fDf(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:Gq(t,"string")}]}:x2j.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:Gq(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:Gq(t,"Date object")}]},getType:()=>DS.DATE};return{...iG(e),...h2(e)}}function aG(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...iG(r),...h2(r)}}}function pba(e){let t=new Set(e);return aG(DS.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:Gq(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:Gq(n,"enum")}]}:{ok:!0,value:n})()}function dDf(e){let t=Myu(e);return{...t,...h2(t)}}function Myu(e){return{parse:(t,r)=>l7n(e).parse(t,r),json:(t,r)=>l7n(e).json(t,r),getType:()=>l7n(e).getType()}}function l7n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Ihi(e){return Object.entries(e)}function zhi(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function J6r(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 Nhi(e){return Object.keys(e)}function pDf(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function p8t(e){return{withParsedProperties:t=>Tyu(e,t)}}function Tyu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((f,[d,c])=>({...f,[d]:typeof c=="function"?c(a.value):c}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!J6r(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Gq(n,"object")}]};let a=new Set(Object.keys(t)),u=zhi(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...h2(r),...p8t(r)}}function _Df(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function Q6r(e){return e.isProperty}function _ba(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>Q6r(n)?n.rawKey:r),_getParsedProperties:()=>Nhi(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of Ihi(e)){let d=Q6r(f)?f.rawKey:u,c=Q6r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,vDf(c)&&a.push(d)}return hDf({value:r,requiredKeys:a,getProperty:u=>{let f=i[u];if(f!=null)return{transformedKey:f.parsedKey,transform:d=>f.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,u]of Ihi(e)){let f=Q6r(u)?u.valueSchema:u;vDf(f)&&i.push(a)}return hDf({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return Q6r(u)?{transformedKey:u.rawKey,transform:f=>u.valueSchema.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:f=>u.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>DS.OBJECT};return{...iG(t),...h2(t),...p8t(t),...f7n(t)}}function hDf({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!J6r(e))return{ok:!1,errors:[{path:a,message:Gq(e,"object")}]};let u=new Set(t),f=[],d={};for(let[c,o]of Object.entries(e)){let l=r(c);if(l!=null){u.delete(c);let m=l.transform(o);m.ok?d[l.transformedKey]=m.value:(d[c]=o,f.push(...m.errors))}else switch(n){case"fail":f.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":d[c]=o;break}}return f.push(...t.filter(c=>u.has(c)).map(c=>({path:a,message:`Missing required key "${c}"`}))),f.length===0||i?{ok:!0,value:d}:{ok:!1,errors:f}}function f7n(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>yDf({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>yDf({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>DS.OBJECT};return{...r,...h2(r),...p8t(r),...f7n(r)}}}}function yDf({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=pDf(Nhi(t),c=>i.has(c)),f=r(zhi(t,u)),d=n(zhi(t,a));return f.ok&&d.ok?{ok:!0,value:{...f.value,...d.value}}:{ok:!1,errors:[...f.ok?[]:f.errors,...d.ok?[]:d.errors]}}function vDf(e){return!q2j(e)}function q2j(e){switch(e.getType()){case DS.ANY:case DS.UNKNOWN:case DS.OPTIONAL:return!0;default:return!1}}function bDf(e){return _ba(e)}function gDf(e){let t={...Myu(e),_getRawProperties:()=>l7n(e)._getRawProperties(),_getParsedProperties:()=>l7n(e)._getParsedProperties()};return{...t,...h2(t),...p8t(t),...f7n(t)}}function hba(e){let t={parse:(r,n)=>mDf(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>mDf(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>DS.LIST};return{...iG(t),...h2(t)}}function mDf(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:Gq(e,"list"),path:[]}]}}function ODf(e){return aG(DS.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Gq(r,`"${e}"`)}]})()}function PDf(e){return aG(DS.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Gq(r,`${e.toString()}`)}]})()}var jDf=aG(DS.ANY,e=>({ok:!0,value:e}));var wDf=aG(DS.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Gq(e,"boolean")}]});var DDf=aG(DS.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Gq(e,"number")}]});var SDf=aG(DS.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Gq(e,"string")}]});var EDf=aG(DS.UNKNOWN,e=>({ok:!0,value:e}));function MDf(e,t){let r={parse:(n,i)=>ADf({value:n,isKeyNumeric:e.getType()===DS.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>ADf({value:n,isKeyNumeric:e.getType()===DS.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>DS.RECORD};return{...iG(r),...h2(r)}}function ADf({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return J6r(e)?Ihi(e).reduce((a,[u,f])=>{if(f==null)return a;let d=a,c=u;if(t){let O=u.length>0?Number(u):NaN;isNaN(O)||(c=O)}let o=r(c),l=n(f,c);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let m=[];return d.ok||m.push(...d.errors),o.ok||m.push(...o.errors),l.ok||m.push(...l.errors),{ok:!1,errors:m}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:Gq(e,"object")}]}}function TDf(e){let t=hba(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Gq(n,"Set")}]},getType:()=>DS.SET};return{...iG(r),...h2(r)}}function qDf(e){let t={parse:(r,n)=>xDf((i,a)=>i.parse(r,a),e,n),json:(r,n)=>xDf((i,a)=>i.json(r,a),e,n),getType:()=>DS.UNDISCRIMINATED_UNION};return{...iG(t),...h2(t)}}function xDf(e,t,r){let n=[];for(let[i,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let f of u.errors)n.push({path:f.path,message:`[Variant ${i}] ${f.message}`})}return{ok:!1,errors:n}}function CDf(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function IDf(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=pba(Nhi(t)),a={parse:(u,f)=>BDf({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.parse(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),json:(u,f)=>BDf({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.json(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),getType:()=>DS.UNION};return{...iG(a),...h2(a),...p8t(a)}}function BDf({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!J6r(e))return{ok:!1,errors:[{path:f,message:Gq(e,"object")}]};let{[t]:d,...c}=e;if(d==null)return{ok:!1,errors:[{path:f,message:`Missing discriminant ("${t}")`}]};let o=n(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=i(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...c}}:{ok:!1,errors:[{path:[...f,t],message:"Unexpected discriminant value"}]};let m=u(c,l);return m.ok?{ok:!0,value:{[r]:d,...m.value}}:m}var cj=jn.objectWithoutOptionalProperties({title:jn.string().optional()});var yba=jn.objectWithoutOptionalProperties({file:jn.string()});var vba=jn.objectWithoutOptionalProperties({file:jn.string()});var bba=jn.union("type",{openapi:yba,protobuf:vba}).transform({transform:e=>{switch(e.type){case"openapi":return oSr.openapi(e);case"protobuf":return oSr.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var z0=jn.objectWithoutOptionalProperties({source:bba.optional()});var gba=jn.objectWithoutOptionalProperties({typeName:jn.string()});var mba=jn.union("type",{protobuf:gba}).transform({transform:e=>{switch(e.type){case"protobuf":return o7n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Sne=jn.objectWithoutOptionalProperties({encoding:mba.optional()});var kp=jn.objectWithoutOptionalProperties({description:jn.string().optional()});var Oba=jn.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Uv=jn.objectWithoutOptionalProperties({availability:Oba.optional()});var Am=jn.objectWithoutOptionalProperties({nameOverride:jn.string().optional(),generatedName:jn.string()});var EX=jn.string();var AX=jn.string();var Pba=jn.objectWithoutOptionalProperties({id:AX}).extend(kp);var jba=jn.string();var wba=jn.objectWithoutOptionalProperties({usernameVariableName:jn.string().optional(),usernameEnvVar:jn.string().optional(),passwordVariableName:jn.string().optional(),passwordEnvVar:jn.string().optional()});var Dba=jn.objectWithoutOptionalProperties({tokenVariableName:jn.string().optional(),tokenEnvVar:jn.string().optional()});var Sba=jn.objectWithoutOptionalProperties({headerName:jn.string(),prefix:jn.string().optional(),headerVariableName:jn.string().optional(),headerEnvVar:jn.string().optional()});var Eba=jn.objectWithoutOptionalProperties({queryParameterName:jn.string()});var Aba=jn.objectWithoutOptionalProperties({snake:jn.string().optional(),camel:jn.string().optional(),screamingSnake:jn.string().optional(),pascal:jn.string().optional()});var G6r=jn.objectWithoutOptionalProperties({nameOverride:jn.string().optional(),generatedName:jn.string(),value:jn.string(),casing:Aba.optional()}).extend(kp).extend(Uv);var Mba=jn.objectWithoutOptionalProperties({type:jn.stringLiteral("namespace"),name:jn.string()});var Tba=jn.undiscriminatedUnion([jn.string(),Mba]);var $6r=jn.list(Tba);var lj=jn.objectWithoutOptionalProperties({groupName:$6r.optional()});var d7n=jn.objectWithoutOptionalProperties({default:G6r.optional(),values:jn.list(G6r)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var xba=jn.objectWithoutOptionalProperties({scopesEnum:d7n.optional()});var qba=jn.union("type",{basic:wba,bearer:Dba,header:Sba,query:Eba,oauth:xba}).transform({transform:e=>{switch(e.type){case"basic":return Y9.basic(e);case"bearer":return Y9.bearer(e);case"header":return Y9.header(e);case"query":return Y9.query(e);case"oauth":return Y9.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var K6r=jn.number();var Cba=jn.objectWithoutOptionalProperties({name:jn.string().optional(),url:jn.string(),audiences:jn.list(jn.string()).optional()}).extend(kp);var Bba=jn.string();var _8t=jn.objectWithoutOptionalProperties({namespace:jn.string().optional()});var qyu={};Dc(qyu,{FullExample:()=>$q,FullObjectExample:()=>zba,FullOneOfExample:()=>Fba,KeyValuePair:()=>Nba,LiteralExample:()=>Iba,PrimitiveExample:()=>_7n,PropertyKey:()=>p7n});var p7n=jn.string();var _7n=jn.union("type",{int:jn.object({value:jn.number()}),int64:jn.object({value:jn.number()}),uint:jn.object({value:jn.number()}),uint64:jn.object({value:jn.number()}),float:jn.object({value:jn.number()}),double:jn.object({value:jn.number()}),string:jn.object({value:jn.string()}),datetime:jn.object({value:jn.string()}),date:jn.object({value:jn.string()}),base64:jn.object({value:jn.string()}),boolean:jn.object({value:jn.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return Uy.int(e.value);case"int64":return Uy.int64(e.value);case"uint":return Uy.uint(e.value);case"uint64":return Uy.uint64(e.value);case"float":return Uy.float(e.value);case"double":return Uy.double(e.value);case"string":return Uy.string(e.value);case"datetime":return Uy.datetime(e.value);case"date":return Uy.date(e.value);case"base64":return Uy.base64(e.value);case"boolean":return Uy.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Iba=jn.union("type",{boolean:jn.object({value:jn.boolean()}),string:jn.object({value:jn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return u7n.boolean(e.value);case"string":return u7n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var $q=jn.union("type",{primitive:jn.object({value:_7n}),object:jn.lazyObject(()=>zba),array:jn.object({value:jn.list(jn.lazy(()=>$q))}),map:jn.object({value:jn.list(jn.lazyObject(()=>Nba))}),enum:jn.object({value:jn.string()}),literal:jn.object({value:Iba}),oneOf:jn.object({value:jn.lazy(()=>Fba)}),unknown:jn.object({value:jn.lazy(()=>$q)})}).transform({transform:e=>{switch(e.type){case"primitive":return OP.primitive(e.value);case"object":return OP.object(e);case"array":return OP.array(e.value);case"map":return OP.map(e.value);case"enum":return OP.enum(e.value);case"literal":return OP.literal(e.value);case"oneOf":return OP.oneOf(e.value);case"unknown":return OP.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var zba=jn.objectWithoutOptionalProperties({properties:jn.record(p7n,jn.lazy(()=>$q))});var Nba=jn.objectWithoutOptionalProperties({key:_7n,value:jn.lazy(()=>$q)});var Fba=jn.union("type",{discriminated:jn.object({value:jn.record(p7n,jn.lazy(()=>$q))}),undisciminated:jn.object({value:jn.lazy(()=>$q)})}).transform({transform:e=>{switch(e.type){case"discriminated":return W6r.discriminated(e.value);case"undisciminated":return W6r.undisciminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Cyu={};Dc(Cyu,{AllOfPropertyConflict:()=>M7n,ArraySchema:()=>Pga,Availability:()=>Oba,BooleanSchema:()=>yga,CasingOverrides:()=>Aba,CommonProperty:()=>Tga,CursorPagination:()=>nga,CustomCodeSample:()=>tga,CustomCodeSampleLanguage:()=>Zba,CustomCodeSampleSdk:()=>ega,DiscriminatedOneOfSchema:()=>Aga,DoubleSchema:()=>_ga,Endpoint:()=>aga,EndpointExample:()=>w7n,EndpointResponseExample:()=>Xba,EndpointSdkName:()=>h8t,EnumSchema:()=>d7n,EnumValue:()=>G6r,ErrorExample:()=>Gba,FernExample:()=>Kba,FileResponse:()=>m7n,FileSchema:()=>Uba,FullEndpointExample:()=>rga,GlobalHeader:()=>bga,Header:()=>Y6r,HeaderExample:()=>j7n,HttpEndpointServer:()=>O7n,HttpError:()=>$ba,HttpMethod:()=>h7n,IdempotencyHeader:()=>gga,IntSchema:()=>dga,JsonRequest:()=>Hba,JsonResponse:()=>X6r,LiteralSchema:()=>A7n,LiteralSchemaValue:()=>mga,LongSchema:()=>pga,MapSchema:()=>jga,MultipartRequest:()=>g7n,MultipartRequestProperty:()=>Wba,MultipartSchema:()=>Vba,NullableSchema:()=>Dga,ObjectProperty:()=>Ega,ObjectPropertyConflictInfo:()=>T7n,ObjectSchema:()=>Oga,OctetStreamRequest:()=>b7n,OffsetPagination:()=>iga,OneOfSchema:()=>Sga,OpenApiIntermediateRepresentation:()=>zDf,OptionalSchema:()=>wga,Pagination:()=>D7n,PathParameter:()=>y7n,PathParameterExample:()=>Yba,PrimitiveSchema:()=>k6r,PrimitiveSchemaValue:()=>vga,QueryParameter:()=>v7n,QueryParameterExample:()=>P7n,ReferencedSchema:()=>y8t,Request:()=>Jba,Response:()=>Qba,Schema:()=>fj,Schemas:()=>fga,SdkGroupInfo:()=>Rba,StringSchema:()=>hga,SupportedSdkLanguage:()=>kba,Tags:()=>Lba,TextResponse:()=>Z6r,UnDiscriminatedOneOfSchema:()=>Mga,Webhook:()=>oga,WebhookExampleCall:()=>E7n,WebhookHttpMethod:()=>S7n,WebsocketChannel:()=>lga,WebsocketHandshake:()=>uga,WebsocketMessageExample:()=>sga,WebsocketSessionExample:()=>cga});var Rba=jn.objectWithoutOptionalProperties({summary:jn.string().optional(),description:jn.string().optional()});var Lba=jn.objectWithoutOptionalProperties({tagsById:jn.record(AX,Pba),orderedTagIds:jn.list(AX).optional()});var h7n=jn.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var y7n=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>fj),variableReference:jn.string().optional(),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var v7n=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>fj),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var Y6r=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>fj),env:jn.string().optional(),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var h8t=jn.objectWithoutOptionalProperties({groupName:$6r,methodName:jn.string()});var b7n=jn.objectWithoutOptionalProperties({}).extend(kp).extend(z0);var Uba=jn.objectWithoutOptionalProperties({isOptional:jn.boolean(),isArray:jn.boolean()});var Vba=jn.union("type",{file:Uba,json:jn.object({value:jn.lazy(()=>fj)})}).transform({transform:e=>{switch(e.type){case"file":return Pxe.file(e);case"json":return Pxe.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Wba=jn.objectWithoutOptionalProperties({key:jn.string(),schema:Vba,contentType:jn.string().optional()}).extend(kp);var g7n=jn.objectWithoutOptionalProperties({name:jn.string().optional(),properties:jn.list(Wba)}).extend(kp).extend(z0);var Hba=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>fj),contentType:jn.string().optional(),additionalProperties:jn.boolean()}).extend(kp).extend(z0);var Jba=jn.union("type",{octetStream:b7n,multipart:g7n,json:Hba}).transform({transform:e=>{switch(e.type){case"octetStream":return H6r.octetStream(e);case"multipart":return H6r.multipart(e);case"json":return H6r.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var m7n=jn.objectWithoutOptionalProperties({}).extend(kp).extend(z0);var X6r=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>fj),responseProperty:jn.string().optional()}).extend(kp).extend(z0);var Z6r=jn.objectWithoutOptionalProperties({}).extend(kp).extend(z0);var Qba=jn.union("type",{file:m7n,json:X6r,text:Z6r,streamingSse:X6r,streamingText:Z6r,streamingJson:X6r}).transform({transform:e=>{switch(e.type){case"file":return Dne.file(e);case"json":return Dne.json(e);case"text":return Dne.text(e);case"streamingSse":return Dne.streamingSse(e);case"streamingText":return Dne.streamingText(e);case"streamingJson":return Dne.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Gba=jn.objectWithoutOptionalProperties({name:jn.string().optional(),description:jn.string().optional(),example:jn.lazy(()=>$q)});var $ba=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>fj).optional(),examples:jn.list(Gba).optional()}).extend(kp).extend(Am).extend(z0);var O7n=jn.objectWithoutOptionalProperties({name:jn.string().optional(),url:jn.string().optional(),audiences:jn.list(jn.string()).optional()});var Kba=jn.unknown();var Yba=jn.objectWithoutOptionalProperties({name:jn.string(),parameterNameOverride:jn.string().optional(),value:jn.lazy(()=>$q)});var P7n=jn.objectWithoutOptionalProperties({name:jn.string(),value:jn.lazy(()=>$q)});var j7n=jn.objectWithoutOptionalProperties({name:jn.string(),value:jn.lazy(()=>$q)});var Xba=jn.union("type",{withStreaming:jn.object({value:jn.list(jn.lazy(()=>$q))}),withoutStreaming:jn.object({value:jn.lazy(()=>$q)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return y2t.withStreaming(e.value);case"withoutStreaming":return y2t.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Zba=jn.objectWithoutOptionalProperties({name:jn.string().optional(),language:jn.string(),code:jn.string(),install:jn.string().optional()}).extend(kp);var kba=jn.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var ega=jn.objectWithoutOptionalProperties({name:jn.string().optional(),sdk:kba,code:jn.string()}).extend(kp);var tga=jn.union("type",{language:Zba,sdk:ega}).transform({transform:e=>{switch(e.type){case"language":return sSr.language(e);case"sdk":return sSr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var rga=jn.objectWithoutOptionalProperties({name:jn.string().optional(),pathParameters:jn.list(Yba).optional(),queryParameters:jn.list(P7n).optional(),headers:jn.list(j7n).optional(),request:jn.lazy(()=>$q).optional(),response:Xba.optional(),codeSamples:jn.list(tga)}).extend(kp);var w7n=jn.union("type",{unknown:jn.object({value:Kba}),full:rga}).transform({transform:e=>{switch(e.type){case"unknown":return h2t.unknown(e.value);case"full":return h2t.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var nga=jn.objectWithoutOptionalProperties({cursor:jn.string(),nextCursor:jn.property("next_cursor",jn.string()),results:jn.string()});var iga=jn.objectWithoutOptionalProperties({offset:jn.string(),results:jn.string(),step:jn.string().optional(),hasNextPage:jn.string().optional()});var D7n=jn.union("type",{cursor:nga,offset:iga}).transform({transform:e=>{switch(e.type){case"cursor":return uSr.cursor(e);case"offset":return uSr.offset(e);default:return e}},untransform:({_visit:e,...t})=>t});var aga=jn.objectWithoutOptionalProperties({authed:jn.boolean(),internal:jn.boolean().optional(),idempotent:jn.boolean().optional(),method:h7n,audiences:jn.list(jn.string()),path:jn.string(),summary:jn.string().optional(),operationId:jn.string().optional(),tags:jn.list(AX),pathParameters:jn.list(y7n),queryParameters:jn.list(v7n),headers:jn.list(Y6r),sdkName:h8t.optional(),generatedRequestName:jn.string(),requestNameOverride:jn.string().optional(),request:Jba.optional(),response:Qba.optional(),errors:jn.record(K6r,$ba),server:jn.list(O7n),examples:jn.list(w7n),pagination:D7n.optional()}).extend(kp).extend(Uv).extend(z0).extend(_8t);var S7n=jn.enum_(["GET","POST"]);var E7n=jn.objectWithoutOptionalProperties({name:jn.string().optional(),payload:jn.lazy(()=>$q)}).extend(kp);var oga=jn.objectWithoutOptionalProperties({sdkName:h8t.optional(),method:S7n,summary:jn.string().optional(),operationId:jn.string(),tags:jn.list(AX),headers:jn.list(Y6r),generatedPayloadName:jn.string(),payload:jn.lazy(()=>fj),examples:jn.list(E7n)}).extend(kp).extend(z0).extend(_8t);var uga=jn.objectWithoutOptionalProperties({queryParameters:jn.list(v7n),headers:jn.list(Y6r),pathParameters:jn.list(y7n)});var sga=jn.objectWithoutOptionalProperties({messageType:jn.string(),payload:jn.lazy(()=>$q)}).extend(kp);var cga=jn.objectWithoutOptionalProperties({name:jn.string().optional(),queryParameters:jn.list(P7n).optional(),headers:jn.list(j7n).optional(),messages:jn.list(sga)}).extend(kp);var lga=jn.objectWithoutOptionalProperties({path:jn.string(),groupName:$6r,summary:jn.string().optional(),handshake:uga,publish:jn.lazy(()=>fj).optional(),subscribe:jn.lazy(()=>fj).optional(),examples:jn.list(cga)}).extend(kp).extend(z0);var fga=jn.objectWithoutOptionalProperties({rootSchemas:jn.record(EX,jn.lazy(()=>fj)),namespacedSchemas:jn.record(Bba,jn.record(EX,jn.lazy(()=>fj)))});var dga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),minimum:jn.number().optional(),maximum:jn.number().optional(),exclusiveMinimum:jn.boolean().optional(),exclusiveMaximum:jn.boolean().optional(),multipleOf:jn.number().optional()});var pga=jn.objectWithoutOptionalProperties({default:jn.number().optional()});var _ga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),minimum:jn.number().optional(),maximum:jn.number().optional(),exclusiveMinimum:jn.boolean().optional(),exclusiveMaximum:jn.boolean().optional(),multipleOf:jn.number().optional()});var hga=jn.objectWithoutOptionalProperties({default:jn.string().optional(),pattern:jn.string().optional(),format:jn.string().optional(),minLength:jn.number().optional(),maxLength:jn.number().optional()});var yga=jn.objectWithoutOptionalProperties({default:jn.boolean().optional()});var vga=jn.union("type",{int:dga,int64:pga,uint:jn.object({}),uint64:jn.object({}),float:jn.object({}),double:_ga,string:hga,datetime:jn.object({}),date:jn.object({}),base64:jn.object({}),boolean:yga}).transform({transform:e=>{switch(e.type){case"int":return q1.int(e);case"int64":return q1.int64(e);case"uint":return q1.uint();case"uint64":return q1.uint64();case"float":return q1.float();case"double":return q1.double(e);case"string":return q1.string(e);case"datetime":return q1.datetime();case"date":return q1.date();case"base64":return q1.base64();case"boolean":return q1.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var k6r=jn.objectWithoutOptionalProperties({schema:vga}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var bga=jn.objectWithoutOptionalProperties({header:jn.string(),name:jn.string().optional(),optional:jn.boolean().optional(),env:jn.string().optional(),schema:jn.lazy(()=>fj).optional()});var gga=jn.objectWithoutOptionalProperties({header:jn.string(),name:jn.string().optional(),env:jn.string().optional(),schema:jn.lazy(()=>fj).optional()});var zDf=jn.objectWithoutOptionalProperties({apiVersion:jn.unknown().optional(),title:jn.string().optional(),description:jn.string().optional(),basePath:jn.string().optional(),servers:jn.list(Cba),groups:jn.record(jn.string(),Rba),tags:Lba,hasEndpointsMarkedInternal:jn.boolean(),endpoints:jn.list(aga),webhooks:jn.list(oga),channel:jn.list(lga),groupedSchemas:fga,variables:jn.record(jn.string(),k6r),nonRequestReferencedSchemas:jn.set(EX),securitySchemes:jn.record(jba,qba),globalHeaders:jn.list(bga).optional(),idempotencyHeaders:jn.list(gga).optional()});var y8t=jn.objectWithoutOptionalProperties({schema:EX}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var mga=jn.union("type",{boolean:jn.object({value:jn.boolean()}),string:jn.object({value:jn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return _I.boolean(e.value);case"string":return _I.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var A7n=jn.objectWithoutOptionalProperties({value:mga}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var fj=jn.union("type",{primitive:k6r,object:jn.lazyObject(()=>Oga),array:jn.lazyObject(()=>Pga),map:jn.lazyObject(()=>jga),optional:jn.lazyObject(()=>wga),enum:d7n,reference:y8t,literal:A7n,oneOf:jn.object({value:jn.lazy(()=>Sga)}),nullable:jn.lazyObject(()=>Dga),unknown:Am}).transform({transform:e=>{switch(e.type){case"primitive":return J0.primitive(e);case"object":return J0.object(e);case"array":return J0.array(e);case"map":return J0.map(e);case"optional":return J0.optional(e);case"enum":return J0.enum(e);case"reference":return J0.reference(e);case"literal":return J0.literal(e);case"oneOf":return J0.oneOf(e.value);case"nullable":return J0.nullable(e);case"unknown":return J0.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var M7n=jn.objectWithoutOptionalProperties({propertyKey:jn.string(),allOfSchemaIds:jn.list(EX),conflictingTypeSignatures:jn.boolean()});var Oga=jn.objectWithoutOptionalProperties({allOf:jn.list(y8t),properties:jn.list(jn.lazyObject(()=>Ega)),allOfPropertyConflicts:jn.list(M7n),additionalProperties:jn.boolean()}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var T7n=jn.objectWithoutOptionalProperties({differentSchema:jn.boolean()});var Ega=jn.objectWithoutOptionalProperties({key:jn.string(),schema:jn.lazy(()=>fj),readonly:jn.boolean().optional(),conflict:jn.record(EX,T7n),generatedName:jn.string(),nameOverride:jn.string().optional(),audiences:jn.list(jn.string())}).extend(Uv);var Pga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>fj)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var jga=jn.objectWithoutOptionalProperties({key:k6r,value:jn.lazy(()=>fj)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Sne).extend(cj);var wga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>fj)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var Dga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>fj)}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var Sga=jn.union("type",{discriminated:jn.lazyObject(()=>Aga),undisciminated:jn.lazyObject(()=>Mga)}).transform({transform:e=>{switch(e.type){case"discriminated":return cSr.discriminated(e);case"undisciminated":return cSr.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Aga=jn.objectWithoutOptionalProperties({discriminantProperty:jn.string(),commonProperties:jn.list(jn.lazyObject(()=>Tga)),schemas:jn.record(jn.string(),jn.lazy(()=>fj))}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Sne).extend(z0).extend(cj);var Tga=jn.objectWithoutOptionalProperties({key:jn.string(),schema:jn.lazy(()=>fj)});var Mga=jn.objectWithoutOptionalProperties({schemas:jn.list(jn.lazy(()=>fj))}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Sne).extend(z0).extend(cj);var Byu={};Dc(Byu,{ArraySchemaWithExample:()=>Yga,Base64WithExample:()=>Jga,BooleanWithExample:()=>Qga,CommonPropertyWithExample:()=>ama,DateWithExample:()=>Hga,DatetimeWithExample:()=>Wga,DiscriminatedOneOfSchemaWithExample:()=>nma,DoubleWithExample:()=>Uga,EndpointWithExample:()=>FDf,EnumSchemaWithExample:()=>$ga,FloatWithExample:()=>Lga,HeaderWithExample:()=>e3r,HttpErrorWithExample:()=>Iga,Int64WithExample:()=>Nga,IntWithExample:()=>zga,JsonRequestWithExample:()=>qga,JsonResponseWithExample:()=>Fhi,MapSchemaWithExample:()=>Xga,NamedFullExample:()=>v8t,NullableSchemaWithExample:()=>kga,ObjectPropertyWithExample:()=>rma,ObjectSchemaWithExample:()=>ema,OneOfSchemaWithExample:()=>tma,OptionalSchemaWithExample:()=>Zga,PathParameterWithExample:()=>xga,PrimitiveSchemaValueWithExample:()=>Gga,PrimitiveSchemaWithExample:()=>q7n,QueryParameterWithExample:()=>x7n,RequestWithExample:()=>Cga,ResponseWithExample:()=>Bga,SchemaWithExample:()=>VT,StringSchemaWithExample:()=>Vga,Uint64WithExample:()=>Rga,UintWithExample:()=>Fga,UnDiscriminatedOneOfSchemaWithExample:()=>ima,UnknownSchemaWithExample:()=>Kga,WebhookWithExample:()=>RDf,WebsocketHandshakeWithExample:()=>NDf});var v8t=jn.objectWithoutOptionalProperties({name:jn.string().optional(),value:jn.unknown()}).extend(kp);var x7n=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>VT),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var e3r=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>VT),env:jn.string().optional(),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var NDf=jn.objectWithoutOptionalProperties({queryParameters:jn.list(x7n),headers:jn.list(e3r)});var xga=jn.objectWithoutOptionalProperties({name:jn.string(),schema:jn.lazy(()=>VT),variableReference:jn.string().optional(),parameterNameOverride:jn.string().optional()}).extend(kp).extend(Uv).extend(z0);var qga=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>VT),contentType:jn.string().optional(),fullExamples:jn.list(v8t).optional(),additionalProperties:jn.boolean()}).extend(kp).extend(z0);var Cga=jn.union("type",{octetStream:b7n,multipart:g7n,json:qga}).transform({transform:e=>{switch(e.type){case"octetStream":return Swe.octetStream(e);case"multipart":return Swe.multipart(e);case"json":return Swe.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var Fhi=jn.objectWithoutOptionalProperties({schema:jn.lazy(()=>VT),responseProperty:jn.string().optional(),fullExamples:jn.list(v8t).optional()}).extend(kp).extend(z0);var Bga=jn.union("type",{file:m7n,json:Fhi,text:Z6r,streamingSse:X6r,streamingText:Z6r,streamingJson:Fhi}).transform({transform:e=>{switch(e.type){case"file":return hI.file(e);case"json":return hI.json(e);case"text":return hI.text(e);case"streamingSse":return hI.streamingSse(e);case"streamingText":return hI.streamingText(e);case"streamingJson":return hI.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Iga=jn.objectWithoutOptionalProperties({statusCode:K6r,schema:jn.lazy(()=>VT),fullExamples:jn.list(v8t).optional()}).extend(kp).extend(Am).extend(z0);var FDf=jn.objectWithoutOptionalProperties({authed:jn.boolean(),internal:jn.boolean().optional(),idempotent:jn.boolean().optional(),method:h7n,audiences:jn.list(jn.string()),path:jn.string(),summary:jn.string().optional(),operationId:jn.string().optional(),tags:jn.list(AX),pathParameters:jn.list(xga),queryParameters:jn.list(x7n),headers:jn.list(e3r),sdkName:h8t.optional(),generatedRequestName:jn.string(),requestNameOverride:jn.string().optional(),request:Cga.optional(),response:Bga.optional(),errors:jn.record(K6r,Iga),server:jn.list(O7n),examples:jn.list(w7n),pagination:D7n.optional()}).extend(kp).extend(Uv).extend(z0).extend(_8t);var RDf=jn.objectWithoutOptionalProperties({sdkName:h8t.optional(),method:S7n,summary:jn.string().optional(),operationId:jn.string(),tags:jn.list(AX),headers:jn.list(e3r),generatedPayloadName:jn.string(),payload:jn.lazy(()=>VT),examples:jn.list(E7n)}).extend(kp).extend(z0).extend(_8t);var zga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),minimum:jn.number().optional(),maximum:jn.number().optional(),exclusiveMinimum:jn.boolean().optional(),exclusiveMaximum:jn.boolean().optional(),multipleOf:jn.number().optional(),example:jn.number().optional()});var Nga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),example:jn.number().optional()});var Fga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),example:jn.number().optional()});var Rga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),example:jn.number().optional()});var Lga=jn.objectWithoutOptionalProperties({example:jn.number().optional()});var Uga=jn.objectWithoutOptionalProperties({default:jn.number().optional(),minimum:jn.number().optional(),maximum:jn.number().optional(),exclusiveMinimum:jn.boolean().optional(),exclusiveMaximum:jn.boolean().optional(),multipleOf:jn.number().optional(),example:jn.number().optional()});var Vga=jn.objectWithoutOptionalProperties({default:jn.string().optional(),pattern:jn.string().optional(),format:jn.string().optional(),minLength:jn.number().optional(),maxLength:jn.number().optional(),example:jn.string().optional()});var Wga=jn.objectWithoutOptionalProperties({example:jn.string().optional()});var Hga=jn.objectWithoutOptionalProperties({example:jn.string().optional()});var Jga=jn.objectWithoutOptionalProperties({example:jn.string().optional()});var Qga=jn.objectWithoutOptionalProperties({default:jn.boolean().optional(),example:jn.boolean().optional()});var Gga=jn.union("type",{int:zga,int64:Nga,uint:Fga,uint64:Rga,float:Lga,double:Uga,string:Vga,datetime:Wga,date:Hga,base64:Jga,boolean:Qga}).transform({transform:e=>{switch(e.type){case"int":return ty.int(e);case"int64":return ty.int64(e);case"uint":return ty.uint(e);case"uint64":return ty.uint64(e);case"float":return ty.float(e);case"double":return ty.double(e);case"string":return ty.string(e);case"datetime":return ty.datetime(e);case"date":return ty.date(e);case"base64":return ty.base64(e);case"boolean":return ty.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var q7n=jn.objectWithoutOptionalProperties({schema:Gga}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(cj);var $ga=jn.objectWithoutOptionalProperties({default:G6r.optional(),values:jn.list(G6r),example:jn.string().optional()}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var Kga=jn.objectWithoutOptionalProperties({example:jn.unknown()}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(cj);var VT=jn.union("type",{primitive:q7n,object:jn.lazyObject(()=>ema),array:jn.lazyObject(()=>Yga),map:jn.lazyObject(()=>Xga),optional:jn.lazyObject(()=>Zga),enum:$ga,reference:y8t,literal:A7n,oneOf:jn.object({value:jn.lazy(()=>tma)}),nullable:jn.lazyObject(()=>kga),unknown:Kga}).transform({transform:e=>{switch(e.type){case"primitive":return Op.primitive(e);case"object":return Op.object(e);case"array":return Op.array(e);case"map":return Op.map(e);case"optional":return Op.optional(e);case"enum":return Op.enum(e);case"reference":return Op.reference(e);case"literal":return Op.literal(e);case"oneOf":return Op.oneOf(e.value);case"nullable":return Op.nullable(e);case"unknown":return Op.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var Yga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>VT),example:jn.list(jn.unknown()).optional()}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(cj);var Xga=jn.objectWithoutOptionalProperties({key:q7n,value:jn.lazy(()=>VT),example:jn.unknown().optional()}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(Sne).extend(cj);var Zga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>VT)}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(cj);var kga=jn.objectWithoutOptionalProperties({value:jn.lazy(()=>VT)}).extend(lj).extend(Am).extend(kp).extend(Uv).extend(cj);var ema=jn.objectWithoutOptionalProperties({allOf:jn.list(y8t),properties:jn.list(jn.lazyObject(()=>rma)),allOfPropertyConflicts:jn.list(M7n),fullExamples:jn.list(v8t).optional(),additionalProperties:jn.boolean()}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(z0).extend(cj);var rma=jn.objectWithoutOptionalProperties({key:jn.string(),schema:jn.lazy(()=>VT),readonly:jn.boolean().optional(),audiences:jn.list(jn.string()),conflict:jn.record(EX,T7n),nameOverride:jn.string().optional(),generatedName:jn.string()}).extend(Uv);var tma=jn.union("type",{discriminated:jn.lazyObject(()=>nma),undisciminated:jn.lazyObject(()=>ima)}).transform({transform:e=>{switch(e.type){case"discriminated":return SX.discriminated(e);case"undisciminated":return SX.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var nma=jn.objectWithoutOptionalProperties({discriminantProperty:jn.string(),commonProperties:jn.list(jn.lazyObject(()=>ama)),schemas:jn.record(jn.string(),jn.lazy(()=>VT))}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Sne).extend(z0).extend(cj);var ama=jn.objectWithoutOptionalProperties({key:jn.string(),schema:jn.lazy(()=>VT)});var ima=jn.objectWithoutOptionalProperties({schemas:jn.list(jn.lazy(()=>VT))}).extend(kp).extend(Am).extend(lj).extend(Uv).extend(Sne).extend(z0).extend(cj);function oma(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:sc(e.type)}}function C7n(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:sc(e)}}function gx(e){return typeof e=="string"?e:e.type}function Rhi(e){if(typeof e!="string")return e.docs}function LDf(e){if(typeof e!="string")return e.default}function UDf(e){if(typeof e!="string")return e.validation}function C2j(e){let t=e.find(n=>typeof n=="object"&&n.type==="namespace"),r=e.filter(n=>typeof n=="string"||n.type!=="namespace");return t?[t,...r]:r}function VDf(e){let t=e?C2j(e):void 0;if(t==null||t.length===0)return Isi;let r=[];for(let[n,i]of t.entries())if(typeof i=="string")r.push(mE(i));else if(typeof i=="object")switch(i.type){case"namespace":{n<t.length-1?r.push(mE(i.name)):r.push(i.name,Isi);break}default:sc(i.type)}else sc(i);return r.join("/")}function B7n(e){return ls.of(`${VDf(e)}.yml`)}function Iyu({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Isi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,VDf(r))}function WDf({sdkName:e,namespaceOverride:t}){return ls.of(`${Iyu({sdkName:e,namespaceOverride:t})}.yml`)}function HDf({location:e,namespaceOverride:t}){return t!=null?Wl(ls.of(t),e):e}function gz(e){switch(e){case _W.Deprecated:return"deprecated";case _W.Beta:return"pre-release";case _W.GenerallyAvailable:return"generally-available";default:return}}var B2j=-2147483648,I2j=2147483647,z2j=-17976931348623157e292,N2j=17976931348623157e292;function qO({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i}){switch(n.shouldMarkSchemaAsReferenced()&&n.markSchemaAsReferenced(e,i),e.type){case"primitive":return uma(e);case"array":return Fyu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"map":return Ryu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"reference":return Nyu({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return Uyu();case"optional":case"nullable":return Lyu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"enum":return Q2j({schema:e,fileContainingReference:t,context:n,declarationFile:r});case"literal":return e.value,Vyu(e);case"object":return G2j({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"oneOf":return $2j({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i});default:sc(e)}}function uma(e){switch(e.schema.type){case"string":return L2j({description:e.description,schema:e.schema});case"int":return U2j({description:e.description,schema:e.schema});case"float":return V2j({description:e.description,schema:e.schema});case"double":return W2j({description:e.description,schema:e.schema});case"boolean":return F2j({description:e.description,schema:e.schema});case"int64":return R2j({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:gz(e.availability)}:{}}}function F2j({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function R2j({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function L2j({description:e,schema:t}){let r="string",n=H2j(t);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function U2j({description:e,schema:t}){let r="integer",n=JDf(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function V2j({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function W2j({description:e,schema:t}){let r="double",n=JDf(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function H2j(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=J2j(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function J2j(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 JDf(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=zyu(r,t),n=zyu(n,t),i=zyu(i,t),!(r==null&&n==null&&a==null&&u==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:u,multipleOf:i}}function zyu(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[B2j,I2j]:[z2j,N2j];return e<r||e>n?void 0:e}function Nyu({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=K2j(i)??e.schema,u=C7n(i),f=Y2j(i),d=sma({context:r,fileContainingReference:t,declarationFile:B7n(u),type:a}),c=i.type==="nullable"?`optional<${d}>`:d;return e.description==null&&f==null?c:{type:i.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function Fyu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=qO({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=`list<${gx(a)}>`;return e.description==null&&e.title==null?u:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{},type:u}}function Ryu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=uma(e.key),u=qO({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),f=e.encoding!=null?oma(e.encoding):void 0,d=`map<${gx(a)}, ${gx(u)}>`;if(e.description==null&&f==null&&e.title==null)return d;let c={type:d};return e.description!=null&&(c.docs=e.description),e.encoding!=null&&(c.encoding=f),e.availability!=null&&(c.availability=gz(e.availability)),c}function Lyu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=qO({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=gx(a),f=Rhi(a),d=LDf(a),c=UDf(a),o=u.startsWith("optional<")?u:`optional<${u}>`;if(e.availability==null&&e.description==null&&f==null&&d==null&&c==null&&e.title==null)return o;let l={type:o};return(e.description!=null||f!=null)&&(l.docs=e.description??f),d!=null&&(l.default=d),c!=null&&(l.validation=c),e.availability!=null&&(l.availability=gz(e.availability)),l}function Uyu(){return"unknown"}function Vyu(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:sc(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function Q2j({schema:e,fileContainingReference:t,declarationFile:r,context:n}){let i=Lhi(e),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:i.schema});let u=sma({type:a,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return u;let f={type:u};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.availability!=null&&(f.availability=gz(e.availability)),f}function G2j({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Wyu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=sma({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function $2j({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Hyu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=sma({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{...e.title!=null?{"display-name":e.title}:{},type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gz(e.availability)}:{}}}function sma({type:e,fileContainingReference:t,declarationFile:r,context:n}){if(r===t)return e;let i=n.builder.addImport({file:t,fileToImport:r});return i!=null?`${i}.${e}`:e}function K2j(e){return J0._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 Y2j(e){return J0._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 lSr(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:sc(e)}}var v8;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(v8||(v8={}));function GDf({schema:e,context:t,declarationFile:r,namespace:n}){switch(e.type){case"primitive":return k2j(e);case"array":return X2j({schema:e,context:t,declarationFile:r,namespace:n});case"map":return Z2j({schema:e,context:t,declarationFile:r,namespace:n});case"reference":return eBj({schema:e,context:t,declarationFile:r,namespace:n});case"unknown":return rBj(e.nameOverride,e.generatedName);case"optional":case"nullable":return tBj({schema:e,context:t,declarationFile:r,namespace:n});case"enum":return Lhi(e);case"literal":return nBj(e,e.nameOverride,e.generatedName);case"object":return Wyu({schema:e,context:t,declarationFile:r,namespace:n});case"oneOf":return Hyu({schema:e.value,context:t,declarationFile:r,namespace:n});default:sc(e)}}function Wyu({schema:e,context:t,declarationFile:r,namespace:n}){let i=t.isInState(v8.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),a=!1,u={},f=new Set;for(let m of e.properties){if(m.readonly&&(a=!0),i&&m.readonly)continue;if(Object.keys(m.conflict).length>0){if(Object.entries(m.conflict).every(([F,C])=>!C.differentSchema))continue;Object.entries(m.conflict).forEach(([F])=>{Jyu({property:m.key,schemaId:F,context:t,namespace:n}).forEach(N=>{f.add(N)})})}let O=qO({schema:m.schema,context:t,fileContainingReference:r,namespace:n}),j=m.audiences,A=m.nameOverride,T=gz(m.availability);u[m.key]=oBj(O,j,A,T)}let d=new Set;for(let m of e.allOfPropertyConflicts)m.allOfSchemaIds.forEach(O=>f.add(O)),m.conflictingTypeSignatures&&d.add(m.propertyKey);let c=[];for(let m of e.allOf){let O=$Df({schema:m.schema,context:t,namespace:n});if(O==null||f.has(m.schema)||f.has(O))continue;let j=qO({schema:J0.reference(m),context:t,fileContainingReference:r,namespace:n});c.push(gx(j))}for(let m of f){let O=Qyu(t,m,n);for(let j of O.properties)u[j.key]==null&&(d.has(j.key)&&(u[j.key]="unknown"),u[j.key]=qO({schema:j.schema,context:t,fileContainingReference:r,namespace:n}));for(let j of O.allOf){if(f.has(j.schema))continue;let A=qO({schema:J0.reference(j),context:t,fileContainingReference:r,namespace:n});c.push(gx(A))}}let o={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(u).map(([m,O])=>aBj(m)?[m,typeof O=="string"?{type:O,name:`_${m}`}:{...O,name:`_${m}`}]:[m,O]))};c.length>0&&(o.extends=c),e.additionalProperties&&(o["extra-properties"]=!0),e.availability!=null&&(o.availability=gz(e.availability)),e.source!=null&&(o.source=lSr(e.source));let l=e.nameOverride??e.generatedName;return{name:a&&t.respectReadonlySchemas&&!i?`${l}Read`:l,schema:o}}function Jyu({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return Jyu({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:u}=Qyu(r,t,n),f=a.some(c=>c.key===e),d=[...u.flatMap(c=>Jyu({property:e,context:r,schemaId:c.schema,namespace:n}))];if(f||d.length>0)return[t,...d]}return[]}function Qyu(e,t,r){let n=e.getSchema(t,r);if(n==null)return{properties:[],allOf:[]};if(n.type==="object")return{properties:n.properties,allOf:n.allOf};if(n.type==="reference")return Qyu(e,n.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${n.type}`)}function X2j({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Fyu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function Z2j({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Ryu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function k2j(e){let t=uma(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...n}=t;return{name:e.nameOverride??e.generatedName,schema:{...n}}}function QDf(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function Lhi(e){let t={enum:e.values.map(i=>{let a=i.nameOverride??i.generatedName,u=i.value;if(a===u&&i.description==null&&(i.casing==null||QDf(i.casing)))return a;let f={value:i.value};if(a!==u&&(f.name=a),i.description!=null&&(f.docs=i.description),i.casing!=null&&!QDf(i.casing)){let d={},c=!1;i.casing.camel!=null&&(d.camel=i.casing.camel,c=!0),i.casing.screamingSnake!=null&&(d["screaming-snake"]=i.casing.screamingSnake,c=!0),i.casing.snake!=null&&(d.snake=i.casing.snake,c=!0),i.casing.pascal!=null&&(d.pascal=i.casing.pascal,c=!0),c&&(f.casing=d)}return f})};e.description!=null&&(t.docs=e.description),e.default!=null&&(t.default=e.default.value);let r=new Set,n={...t,enum:[],source:e.source!=null?lSr(e.source):void 0};for(let i of t.enum){let a=typeof i=="string"?i:i.name??i.value;r.has(a.toLowerCase())||(n.enum.push(i),r.add(a.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function eBj({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Nyu({schema:e,context:t,fileContainingReference:r,namespace:n})}}function tBj({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Lyu({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n})}}function rBj(e,t){return{name:e??t,schema:Uyu()}}function nBj(e,t,r){return{name:t??r,schema:Vyu(e)}}function Hyu({schema:e,context:t,declarationFile:r,namespace:n}){let i=e.encoding!=null?oma(e.encoding):void 0;if(e.type==="discriminated"){let u={};for(let d of e.commonProperties)u[d.key]=qO({schema:d.schema,fileContainingReference:r,context:t,namespace:n});let f={};for(let[d,c]of Object.entries(e.schemas))f[d]=qO({schema:c,context:t,fileContainingReference:r,namespace:n});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":u,docs:e.description??void 0,availability:e.availability!=null?gz(e.availability):void 0,union:f,encoding:i,source:e.source!=null?lSr(e.source):void 0}}}let a=[];for(let u of e.schemas)a.push(qO({schema:u,fileContainingReference:r,context:t,namespace:n}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:a,encoding:i,source:e.source!=null?lSr(e.source):void 0}}}var iBj=/^[0-9]/;function aBj(e){return iBj.test(e)}function $Df({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?$Df({context:t,schema:n.schema,namespace:r}):e}function oBj(e,t,r,n){return t.length===0&&r==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{}}}function KDf(e){let t=e.replace(/^x-|^X-/,"");return mE(t)}var YDf="BasicAuthScheme",cma="BearerAuthScheme";function XDf(e){if(e.authOverrides!=null){for(let[r,n]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:n});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,n]of Object.entries(e.ir.securitySchemes))if(n.type==="basic"){let i={scheme:"basic"};n.usernameVariableName!=null&&(i.username===void 0?i.username={name:n.usernameVariableName}:i.username.name=n.usernameVariableName),n.usernameEnvVar!=null&&(i.username===void 0?i.username={env:n.usernameEnvVar}:i.username.env=n.usernameEnvVar),n.passwordVariableName!=null&&(i.password===void 0?i.password={name:n.passwordVariableName}:i.password.name=n.passwordVariableName),n.passwordEnvVar!=null&&(i.password===void 0?i.password={env:n.passwordEnvVar}:i.password.env=n.passwordEnvVar),e.builder.addAuthScheme({name:YDf,schema:i}),t||(e.builder.setAuth(YDf),t=!0)}else if(n.type==="bearer"){let i={scheme:"bearer"};n.tokenVariableName!=null&&(i.token===void 0?i.token={name:n.tokenVariableName}:i.token.name=n.tokenVariableName),n.tokenEnvVar!=null&&(i.token===void 0?i.token={env:n.tokenEnvVar}:i.token.env=n.tokenEnvVar),e.builder.addAuthScheme({name:cma,schema:i}),t||(e.builder.setAuth(cma),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??KDf(n.headerName),env:n.headerEnvVar}});else{let i={header:n.headerName,name:n.headerVariableName??"apiKey",type:"string"};n.headerEnvVar!=null&&(i.env=n.headerEnvVar),n.prefix!=null&&(i.prefix=n.prefix),e.builder.addAuthScheme({name:r,schema:i}),e.builder.setAuth(r),t=!0}else if(n.type==="oauth"){let i={scheme:"bearer"};e.builder.addAuthScheme({name:cma,schema:i}),t||(e.builder.setAuth(cma),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(ls.of("__package__.yml"),{name:"OauthScope",schema:Lhi(n.scopesEnum).schema})}}function b8t({header:e,context:t,fileContainingReference:r,namespace:n}){let i=qO({schema:e.schema,context:t,fileContainingReference:r,namespace:n}),a=gx(i),u=e.name.replace(/^x-|^X-/,""),f=e.parameterNameOverride!=null?e.parameterNameOverride:mE(u);if(e.description==null&&e.name===f&&e.env==null&&e.availability==null)return a;let d={type:a};return f!==e.name&&(d.name=f),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=gz(e.availability)),d}function lma({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=qO({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(e.variableReference==null&&e.description==null&&e.availability==null)return gx(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:gx(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=gz(e.availability)),a}var zju=require("fs/promises");var ZDf={naming:"v1"};function B_(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function Uhi(e,t,r,n,i=[]){try{let a=B_(e,t);if(a!=null)return r.parse(a)}catch{let u=m6t(i).join(" -> ");n.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}var fma={of(e){return e}};var wh={SDK_METHOD_NAME:fma.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:fma.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:fma.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport"};function Kh(e){return e.$ref!=null}function jxe(e){switch(B_(e,wh.AVAILABILITY)){case"deprecated":return _W.Deprecated;case"beta":return _W.Beta;case"generally-available":return _W.GenerallyAvailable;default:break}if(!Kh(e)&&e.deprecated)return _W.Deprecated}var Ewe={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};function uen(e){let t=B_(e,"examples");return t!=null&&Array.isArray(t)?t:[]}function kDf({schema:e,logger:t}){return B_(e,wh.ENCODING)??void 0}function eSf(e){return B_(e,wh.FERN_ENUM)}function tSf({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:a}){let u=B_(n,wh.SDK_GROUP_NAME),f=B_(n,wh.TYPE_DEFINITION);if(f!=null)return Vhi({fernType:f,nameOverride:e,generatedName:t,title:r,description:i,availability:a,groupName:typeof u=="string"?[u]:u})}function Vhi({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u}){return QQ({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.base64({example:void 0})});case"BOOLEAN":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.boolean({default:void 0,example:void 0})});case"DATE":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.date({example:void 0})});case"DATE_TIME":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.datetime({example:void 0})});case"FLOAT":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.float({example:void 0})});case"DOUBLE":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.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 Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.uint({default:void 0,example:void 0})});case"INTEGER":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.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 Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.uint64({default:void 0,example:void 0})});case"LONG":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Op.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:ty.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:sc(f.v1)}},unknown:()=>Op.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:a,groupName:u}),map:({keyType:f,valueType:d})=>f?.type==="primitive"&&d!=null?Op.map({nameOverride:t,generatedName:r,title:n,key:f,value:d,description:i,availability:a,groupName:u,encoding:void 0,example:void 0}):void 0,list:f=>f!=null?Op.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,optional:f=>f!=null?Op.optional({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u}):void 0,set:f=>f!=null?Op.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,literal:f=>Op.literal({nameOverride:t,generatedName:r,title:n,value:f._visit({string:d=>_I.string(d),boolean:d=>_I.boolean(d),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:a,groupName:u}),named:()=>{}}})}function sen(e){if(e!=null&&typeof e=="boolean")return e}function rSf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,encoding:l,source:m,namespace:O}){return typeof i=="boolean"||I7n(i)?dma({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:ty.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Op.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:void 0}),groupName:c,example:o,encoding:l}):dma({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:ty.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:aP(i,d.options.optionalAdditionalProperties?f:!1,d,[...n,"Value"],m,O),groupName:c,example:o,encoding:l})}function dma({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsNullable:a,description:u,availability:f,groupName:d,example:c,encoding:o}){return a?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.map({nameOverride:e,generatedName:t,title:r,description:u,availability:n.availability,key:n,value:i,groupName:d,encoding:o,example:c}),description:u,availability:f,groupName:d}):Op.map({nameOverride:e,generatedName:t,title:r,description:u,availability:f,key:n,value:i,groupName:d,encoding:o,example:c})}function I7n(e){return e==null?!1:typeof e=="boolean"?e:!Kh(e)&&Object.keys(e).length===0}function nSf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,source:l,namespace:m}){let O=i==null?Op.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,groupName:c}):aP(i,!1,d,[...n,"Item"],l,m);return uBj({nameOverride:e,generatedName:t,title:r,groupName:c,itemSchema:O,wrapAsNullable:f,description:a,availability:u,example:o})}function uBj({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsNullable:i,description:a,availability:u,groupName:f,example:d}){return i?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d}),description:a,availability:u,groupName:f}):Op.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d})}function Gyu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminator:c,context:o,groupName:l,encoding:m,source:O,namespace:j}){let A=c.propertyName,T=Object.fromEntries(Object.entries(c.mapping??{}).map(([F,C])=>{let N=z7n({$ref:C},!1,o,[C],m,O,j);return o.markReferencedByDiscriminatedUnion({$ref:C},A,1),[F,N]})),B=Object.entries(i).filter(([F])=>F!==A).map(([F,C])=>{let N=f!=null&&f.includes(F),U=aP(C,!N,o,[...n,F],O,j);return{key:F,schema:U}});return iSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:B,description:a,availability:u,discriminant:A,subtypes:T,groupName:l,source:O})}function $yu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminant:c,variants:o,context:l,groupName:m,encoding:O,source:j,namespace:A}){let T=Object.fromEntries(Object.entries(o).map(([F,C])=>{if(Kh(C)){let N=z7n(C,!1,l,[C.$ref],O,j,A);return l.markReferencedByDiscriminatedUnion(C,c,1),[F,N]}else{let N=t3r(C,!1,l,[...n,F],O,j,A,new Set([c]));return[F,N]}})),B=Object.entries(i).filter(([F])=>F!==c).map(([F,C])=>{let N=f!=null&&f.includes(F),U=aP(C,!N,l,[...n,F],j,A);return{key:F,schema:U}});return iSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:B,description:a,availability:u,discriminant:c,subtypes:T,groupName:m,source:j})}function iSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,availability:u,discriminant:f,subtypes:d,groupName:c,source:o}){return n?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.oneOf(SX.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o})),groupName:c,description:a,availability:u}):Op.oneOf(SX.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o}))}function aSf(e){if(e.proto!=null)return o7n.protobuf({typeName:e.proto.type})}var sBj=/^(\d+)/;function pma(e){let t=e.match(sBj);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=N7n(i);return n.length>0?`${a}_${n}`:a}}}function N7n(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),f=e%10;return f===0?n[u]:`${n[u]}_${t[f]}`}if(e<1e3){let u=Math.floor(e/100),f=e%100;return f===0?`${t[u]}_hundred`:`${t[u]}_hundred_${N7n(f)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${N7n(a)}`}var F7n=/^[a-zA-Z][a-zA-Z0-9_]*$/;function r3r({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:a,_default:u,description:f,availability:d,wrapAsNullable:c,groupName:o,context:l,source:m}){let O=fBj(i??[]),j=new Set(a),A=Array.from(j).map((B,F)=>{let C=n?.[B],N=O[F],U=F7n.test(B),ne=C?.name??N,ge=U?B:Whi(B);return ne!=null&&!F7n.test(ne)&&(l?.logger.warn(`Enum name override ${ne} is not a valid name. Falling back on ${ge}.`),ne=void 0),{nameOverride:ne,generatedName:ge,value:B,description:C?.description,availability:d,casing:{snake:C?.casing?.snake??void 0,pascal:C?.casing?.pascal??void 0,screamingSnake:C?.casing?.screamingSnake??void 0,camel:C?.casing?.camel??void 0}}}),T=u!=null?A.find(B=>B.value===u):void 0;return cBj({wrapAsNullable:c,nameOverride:e,generatedName:t,title:r,values:A,_default:T,description:f,availability:d,groupName:o,source:m})}function cBj({wrapAsNullable:e,nameOverride:t,generatedName:r,title:n,values:i,_default:a,description:u,availability:f,groupName:d,source:c}){return e?Op.nullable({nameOverride:t,generatedName:r,title:n,value:Op.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,default:a,availability:f,example:void 0,groupName:d,source:c}),description:u,availability:f,groupName:d}):Op.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,availability:f,default:a,example:void 0,groupName:d,source:c})}var lBj={"<":"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 Whi(e){let t=pma(e),r=lBj[e];return t!=null?wV(mE(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":wV(mE(e)))}function fBj(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(n=>n[r]===t[r]);)r++;return e.map(n=>n.substring(r))}function oSf({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:m,example:O,groupName:j}){return n==="int64"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.int64({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="uint32"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.uint({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="uint64"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.uint64({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):X9({nameOverride:e,generatedName:t,title:r,primitive:ty.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j})}function uSf(e){return typeof e=="string"?_I.string(e):typeof e=="boolean"?_I.boolean(e):_I.string(`${e}`)}function sSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,value:i,description:a,availability:u,groupName:f}){return n?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.literal({nameOverride:e,generatedName:t,title:r,value:uSf(i),description:a,availability:u,groupName:f}),description:a,availability:u,groupName:f}):Op.literal({nameOverride:e,generatedName:t,title:r,value:uSf(i),description:a,availability:u,groupName:f})}function Kyu({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:m,example:O,groupName:j}){return n==null||n==="double"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.double({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="float"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.float({example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="int32"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="int64"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.int64({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="uint32"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.uint({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="uint64"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.uint64({default:i,example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):n==="time-delta"?X9({nameOverride:e,generatedName:t,title:r,primitive:ty.float({example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j}):X9({nameOverride:e,generatedName:t,title:r,primitive:ty.float({example:O}),wrapAsNullable:m,description:o,availability:l,groupName:j})}var dBj={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},pBj={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}}},_Bj={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}}},hBj={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},yBj={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},vBj={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},bBj={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},gBj={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function _ma(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[dBj,pBj,_Bj,hBj,yBj,vBj,bBj,gBj],i;do{i=t;for(let a of n)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:f}=a.applyStrategy(t);t=u,r=[...r,...f]}}while(t.join("")!==i.join(""));return r}function b8(e){let t=e.join("_"),r=wV(mE(t));return/^\d/.test(r)?pma(r)??r:r}function Yyu(e){let t=e.join("_");return mE(t)}function mx(e){switch(e.type){case"object":return J0.object({allOf:e.allOf,properties:e.properties.map(t=>OBj(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return J0.array({description:e.description,availability:e.availability,value:mx(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"enum":return J0.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,groupName:e.groupName,source:e.source});case"literal":return J0.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"nullable":return J0.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:mx(e.value),groupName:e.groupName});case"optional":return J0.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:mx(e.value),groupName:e.groupName});case"primitive":return J0.primitive({description:e.description,availability:e.availability,schema:cSf(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return J0.map({description:e.description,availability:e.availability,key:J0.primitive({description:e.key.description,availability:e.key.availability,schema:cSf(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:mx(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,encoding:e.encoding});case"reference":return J0.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,groupName:e.groupName,source:e.source});case"oneOf":return J0.oneOf(mBj(e.value));case"unknown":return J0.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:sc(e)}}function mBj(e){switch(e.type){case"discriminated":return cSr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:mx(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,mx(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return cSr.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>mx(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:sc(e)}}function cSf(e){switch(e.type){case"string":return q1.string(e);case"base64":return q1.base64();case"boolean":return q1.boolean(e);case"date":return q1.date();case"datetime":return q1.datetime();case"double":return q1.double(e);case"float":return q1.float();case"int":return q1.int(e);case"int64":return q1.int64(e);case"uint":return q1.uint();case"uint64":return q1.uint64();default:sc(e)}}function OBj(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:mx(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly}}function hma(e,t){return Awe(mx(e),mx(t))}function Awe(e,t){return e.type==="primitive"&&t.type==="primitive"?lSf(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?PBj(e.values,t.values):e.type==="array"&&t.type==="array"?Awe(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"?Awe(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?jBj(e.value,t.value):e.type==="object"&&t.type==="object"?wBj(e,t):e.type==="map"&&t.type==="map"?lSf(e.key.schema,t.key.schema)&&Awe(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function lSf(e,t){return e.type===t.type}function PBj(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return zqt(r,n)}function jBj(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,n])=>{let i=t.schemas[r];return i==null?!1:Awe(n,i)}):e.type==="undisciminated"&&t.type==="undisciminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:Awe(r,i)}):!1}function wBj(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(n=>[n.key,n.schema]));return Object.entries(t.properties).every(([n,i])=>{let a=r[n];return a==null?!1:Awe(a,i.schema)})}function fSf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,required:u,wrapAsNullable:f,allOf:d,context:c,propertiesToExclude:o,groupName:l,fullExamples:m,additionalProperties:O,availability:j,encoding:A,source:T,namespace:B}){let F=[...u??[]],C={...i},N=[],U=[];for(let k of d)if(Kh(k)){let xe=c.resolveSchemaReference(k);if(xe.discriminator!=null&&xe.discriminator.mapping!=null)continue;if(xe.oneOf!=null){for(let yt of xe.oneOf){let St=Kh(yt)?c.resolveSchemaReference(yt):yt,Ft=aP(St,!1,c.DUMMY,n,T,B);Ft.type==="object"&&N.push(...Ft.properties.map(Zt=>Zt.schema.type!=="optional"&&Zt.schema.type!=="nullable"?{...Zt,schema:Op.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Zt.schema,description:void 0,availability:Zt.availability,groupName:void 0})}:Zt))}continue}let vt=n3r(k);if(vt==null)continue;U.push({schemaId:vt,convertedSchema:Xyu(k,[vt],T),properties:dSf({schema:k,context:c,breadcrumbs:n,source:T,namespace:B})}),c.markSchemaAsReferencedByNonRequest(vt)}else{let xe=aP(k,!1,c,n,T,B);xe.type==="object"&&N.push(...xe.properties)}let ne={};for(let k of U)for(let[xe,vt]of Object.entries(k.properties)){let yt=ne[xe];yt!=null?(yt.schemaIds.push(k.schemaId),yt.schemas.some(Ft=>hma(Ft,vt))||yt.schemas.push(vt)):ne[xe]={schemaIds:[k.schemaId],schemas:[vt]}}let ge=[];for(let[k,xe]of Object.entries(ne))xe.schemaIds.length>1&&ge.push({propertyKey:k,allOfSchemaIds:xe.schemaIds,conflictingTypeSignatures:xe.schemas.length>1});let X=Object.entries(C).map(([k,xe])=>{let vt=F.includes(k),yt=B_(xe,wh.AUDIENCES)??[],St=jxe(xe),Ft=Kh(xe)?!1:xe.readOnly,Zt=B_(xe,wh.FERN_PROPERTY_NAME),Vt=[...n,k],cr=Yyu(Vt),Wr=vt?aP(xe,!1,c,Vt,T,B):Op.optional({nameOverride:e,generatedName:cr,title:r,description:void 0,availability:St,value:aP(xe,!1,c,Vt,T,B),groupName:l}),gn={};for(let Kt of U){let Mr=Kt.properties[k];Mr!=null&&!hma(Wr,Mr)?gn[Kt.schemaId]={differentSchema:!0}:Mr!=null&&(gn[Kt.schemaId]={differentSchema:!1})}return{key:k,schema:Wr,nameOverride:Zt,audiences:yt,conflict:gn,generatedName:Yyu([...n,k]),availability:St,readonly:Ft}});return X.push(...N.map(k=>{let xe=k.conflict;for(let vt of U){let yt=vt.properties[k.key];yt!=null&&!hma(k.schema,yt)?xe[vt.schemaId]={differentSchema:!0}:yt!=null&&(xe[vt.schemaId]={differentSchema:!1})}return{...k,conflict:xe}})),DBj({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,properties:X.filter(k=>!o.has(k.key)),description:a,allOf:U.map(k=>k.convertedSchema),allOfPropertyConflicts:ge,groupName:l,fullExamples:m,additionalProperties:O,availability:j,source:T})}function DBj({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:o,availability:l,source:m}){return n?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:I7n(o),availability:void 0,source:m}),description:a,availability:l,groupName:d}):Op.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:I7n(o),availability:l,source:m})}function dSf({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[u,f]=Kh(e)?[t.resolveSchemaReference(e),_ma(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...dSf({schema:d,context:t,breadcrumbs:f,source:n,namespace:i})};for(let[d,c]of Object.entries(u.properties??{})){let o=aP(c,!1,t,[...f,d],n,i);a[d]=o}return a}function R7n({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:a,wrapAsNullable:u,context:f,subtypes:d,groupName:c,encoding:o,source:l,subtypePrefixOverrides:m,namespace:O}){let j=SBj({schemas:d}),A=d.flatMap((F,C)=>{if(!Kh(F)&&F.enum!=null&&f.options.cooerceEnumsToLiterals)return F.enum.map(U=>Op.literal({nameOverride:void 0,generatedName:b8([t,U]),title:void 0,value:_I.string(U),groupName:void 0,description:void 0,availability:U.availability}));let N=j[C];if(m!=null){let U=m[C];U!=null&&"name"in U&&(N=U.name)}return[aP(F,!1,f,[...n,N??`${C}`],l,O)]}),T=[];for(let F=0;F<A.length;++F){let C=A[F],N=!1;for(let U=F+1;U<A.length;++U){let ne=A[U];if(C!=null&&ne!=null&&Awe(C,ne)){N=!0;break}}C!=null&&!N&&T.push(C)}if(Object.entries(T).every(([F,C])=>C.type==="literal")){let F={},C=[];return Object.entries(T).forEach(([N,U])=>{U.type==="literal"&&U.value.type==="string"&&(C.push(U.value.value),U.description!=null&&(F[U.value.value]={description:U.description}))}),r3r({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,fernEnum:F,enumVarNames:void 0,enumValues:C,_default:void 0,groupName:c,context:f,source:l})}return T.length===1&&T[0]!=null?T[0]:pSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,subtypes:T,groupName:c,encoding:o,source:l})}function Zyu({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsNullable:a,context:u,groupName:f,discriminator:d,encoding:c,source:o,namespace:l}){let m=Object.entries(d.mapping??{}).map(([A,T],B)=>{let F={$ref:T},C=z7n(F,!1,u,[T],c,o,l);return u.markSchemaWithDiscriminantValue(F,d.propertyName,A),C.type==="object"&&(C.properties={[d.propertyName]:Op.literal({nameOverride:void 0,generatedName:b8([t,A]),title:void 0,value:_I.string(A),groupName:void 0,description:void 0,availability:void 0}),...C.properties.filter(N=>N.key!==d.propertyName)}),C}),O=[];for(let A=0;A<m.length;++A){let T=m[A],B=!1;for(let F=A+1;F<m.length;++F){let C=m[F];if(T!=null&&C!=null&&Awe(T,C)){B=!0;break}}T!=null&&!B&&O.push(T)}if(Object.entries(O).every(([A,T])=>T.type==="literal")){let A={},T=[];return Object.entries(O).forEach(([B,F])=>{F.type==="literal"&&F.value.type==="string"&&(T.push(F.value.value),F.description!=null&&(A[F.value.value]={description:F.description}))}),r3r({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,fernEnum:A,enumVarNames:void 0,enumValues:T,_default:void 0,groupName:f,context:u,source:o})}return O.length===1&&O[0]!=null?O[0]:pSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,subtypes:O,groupName:f,encoding:c,source:o})}function SBj({schemas:e}){let t={},r=0;for(let a of e){if(!Kh(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),f={},d=u;for(let[c,o]of Object.entries(t)){let l=gJi(o,u);d=gJi(d,o),f[c]=l}f[r]=d,t=f}}r++}let n=[],i=0;for(let a of e){let u=t[i];if(u!=null&&u.length>0){let f=u.sort();if(f[0]!=null){n.push(f[0]),++i;continue}}Kh(a)?n.push(N7n(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(N7n(i)??`${i}`),++i}return n}function pSf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,description:i,availability:a,subtypes:u,groupName:f,encoding:d,source:c}){return n?Op.nullable({nameOverride:e,generatedName:t,title:r,value:Op.oneOf(SX.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c})),description:i,availability:a,groupName:f}):Op.oneOf(SX.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c}))}function L7n(e){if(e.default!=null&&typeof e.default=="string")return e.default}function yma({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let n=uen(e);for(let i of n??[])if(typeof i=="number")return i;if(r&&typeof r=="number")return r}function _Sf({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let n=uen(e);for(let i of n??[])if(typeof i=="boolean")return i;if(r&&typeof r=="boolean")return r}function fSr({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let n=uen(e);for(let i of n??[])if(typeof i=="string")return i;if(r&&typeof r=="string")return r}function hSf({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let n=uen(e);for(let i of n??[])if(Array.isArray(i))return i;if(r&&Array.isArray(r))return r}var cen="#/components/schemas/";function aP(e,t,r,n,i,a,u=!1,f=new Set,d){let c=CBj({schema:e,logger:r.logger});if(Kh(e)){let o=n3r(e);return o!=null?(u?r.markSchemaAsReferencedByRequest(o):r.markSchemaAsReferencedByNonRequest(o),z7n(e,t,r,n,c,i,a)):t3r(r.resolveSchemaReference(e),t,r,_ma(e.$ref),c,i,a,f,u,d)}return t3r(e,t,r,n,c,i,a,f,u,d)}function z7n(e,t,r,n,i,a,u){let f=e.$ref.includes("properties")?t3r(r.resolveSchemaReference(e),t,r,n,i,a,u,new Set):Op.reference(Xyu(e,n,a));return t?Op.nullable({title:void 0,nameOverride:void 0,generatedName:b8(n),value:f,description:void 0,availability:void 0,groupName:void 0}):f}function EBj(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function t3r(e,t,r,n,i,a,u,f=new Set,d=!1,c){let o=B_(e,wh.TYPE_NAME)??(r.options.useTitlesAsName?EBj(e.title):void 0),l=B_(e,wh.SDK_GROUP_NAME)??B_(e,Ewe.TAGS)?.[0],m=(typeof l=="string"?[l]:l)??[];m=r.resolveGroupName(m);let O=b8(n),j=e.title,A=e.description,T=jxe(e),B=[];e.example!=null&&B.push({name:void 0,value:e.example,description:void 0});let F=B_(e,Ewe.EXAMPLES);F!=null&&Object.keys(F).length>0&&B.push(...Object.entries(F).map(([U,ne])=>({name:ne?.summary??U,value:ne.value,description:ne.description})));let C=uen(e);C!=null&&Object.keys(C).length>0&&B.push(...C.map(U=>({name:void 0,value:U,description:void 0})));let N=tSf({schema:e,description:A,title:j,nameOverride:o,generatedName:O,availability:T});if(N!=null)return N;if(!t&&e.nullable===!0)return t3r(e,!0,r,n,i,a,u,f,d,c);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!Hhi(e.enum))return X9({nameOverride:o,generatedName:O,title:j,primitive:ty.string({default:L7n(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:fSr({schema:e,logger:r.logger,fallback:c})}),groupName:m,wrapAsNullable:t,description:A,availability:T});let U=eSf(e);return e.enum.length===1&&e.enum[0]!=null&&U==null?sSf({nameOverride:o,generatedName:O,title:j,wrapAsNullable:t,value:e.enum[0],description:A,availability:T,groupName:m}):r3r({nameOverride:o,generatedName:O,title:j,fernEnum:U,enumVarNames:B_(e,[Ewe.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:A,availability:T,wrapAsNullable:t,groupName:m,context:r,source:a})}if(Hhi(e.type)&&e.type[1]!=null&&e.type[0]!=null){let U=e.type[0],ne=e.type[1];if(U==="null")return Op.nullable({nameOverride:o,generatedName:O,title:j,value:t3r({...e,type:ne},t,r,n,i,a,u,f,d,c),groupName:m,description:e.description,availability:T});if(ne==="null")return Op.nullable({nameOverride:o,generatedName:O,title:j,value:t3r({...e,type:U},t,r,n,i,a,u,f,d,c),groupName:m,description:e.description,availability:T})}if(Hhi(e.type)&&e.type.length>1){let U=e.type.includes("null"),ne=e.type.filter(ge=>ge!=="null").map(ge=>({type:ge,nullable:U}));return R7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,wrapAsNullable:t,context:r,subtypes:ne,groupName:m,encoding:i,source:a,namespace:u})}if(e==="boolean"||e.type==="boolean"){let U=B_(e,wh.BOOLEAN_LITERAL);return U!=null?vSf({nameOverride:o,generatedName:O,title:j,literal:_I.boolean(U),wrapAsNullable:t,description:A,availability:T,groupName:m}):X9({nameOverride:o,generatedName:O,title:j,primitive:ty.boolean({default:e.default,example:_Sf({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:A,availability:T,groupName:m})}if(e==="number"||e.type==="number")return Kyu({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:sen(e.exclusiveMinimum),exclusiveMaximum:sen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:T,wrapAsNullable:t,example:yma({schema:e,logger:r.logger,fallback:c}),groupName:m});if(e==="integer"||e.type==="integer")return oSf({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:sen(e.exclusiveMinimum),exclusiveMaximum:sen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:T,wrapAsNullable:t,example:yma({schema:e,logger:r.logger,fallback:c}),groupName:m});if(e==="float")return Kyu({nameOverride:o,generatedName:O,title:j,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:sen(e.exclusiveMinimum),exclusiveMaximum:sen(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:T,wrapAsNullable:t,example:yma({schema:e,logger:r.logger,fallback:c}),groupName:m});if(e==="string"||e.type==="string"){if(e.format==="date-time")return X9({nameOverride:o,generatedName:O,title:j,primitive:ty.datetime({example:fSr({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:A,availability:T,groupName:m});if(e.format==="json-string")return Op.unknown({nameOverride:o,generatedName:O,title:j,description:A,availability:T,groupName:m,example:void 0});let U=mSf(e,"const");return U!=null?vSf({nameOverride:o,generatedName:O,title:j,literal:_I.string(U),wrapAsNullable:t,description:A,availability:T,groupName:m}):X9({nameOverride:o,generatedName:O,title:j,primitive:ty.string({default:L7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:fSr({schema:e,logger:r.logger,fallback:c})}),groupName:m,wrapAsNullable:t,description:A,availability:T})}if(e.type==="array")return nSf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,item:e.items,description:A,availability:T,wrapAsNullable:t,context:r,groupName:m,example:hSf({schema:e,logger:r.logger,fallback:c}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&ySf(e))return rSf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,additionalProperties:e.additionalProperties,description:A,availability:T,wrapAsNullable:t,context:r,groupName:m,encoding:i,example:e.example,source:a,namespace:u});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?Zyu({nameOverride:o,generatedName:O,title:j,description:A,availability:T,wrapAsNullable:t,context:r,groupName:m,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):Gyu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:m,encoding:i,source:a,namespace:u});if(Array.isArray(e.type)&&(e.oneOf==null?e.oneOf=e.type:e.oneOf.push(...e.type)),e.oneOf!=null&&e.oneOf.length>0){let U=B_(e,wh.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||U?Zyu({nameOverride:o,generatedName:O,title:j,description:A,availability:T,wrapAsNullable:t,context:r,groupName:m,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):Gyu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:m,encoding:i,source:a,namespace:u});if(e.oneOf.length===1&&e.oneOf[0]!=null){let ne=aP(e.oneOf[0],t,r,n,a,u,d);return U7n(ne,A,m)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let k=e.oneOf[0],xe=e.oneOf[1];if(!Kh(k)&&k.type==="null")return aP(xe,!0,r,n,a,u);if(!Kh(xe)&&xe.type==="null")return aP(k,!0,r,n,a,u)}let ne=TBj({schemas:e.oneOf});if(ne!=null)return r3r({nameOverride:o,generatedName:O,title:j,fernEnum:void 0,enumVarNames:void 0,enumValues:ne,_default:e.default,description:A,availability:T,wrapAsNullable:t,groupName:m,context:r,source:a});let ge=bSf({schemas:e.oneOf,context:r});if(ge!=null&&!r.options.discriminatedUnionV2&&!U)return $yu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},required:e.required,description:A,availability:T,wrapAsNullable:t,discriminant:ge.discriminant,variants:ge.schemas,context:r,groupName:m,encoding:i,source:a,namespace:u});let X=e.oneOf.filter(k=>!Kh(k)&&k.type==="null").length>0;return R7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,wrapAsNullable:t||X,context:r,subtypes:e.oneOf.filter(k=>Kh(k)||k.type!=="null"),encoding:i,groupName:m,source:a,namespace:u})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let ge=aP(e.anyOf[0],t,r,n,a,u,d);return U7n(ge,A,m)}if(e.anyOf.length===2){let[ge,X]=e.anyOf;if(ge!=null&&X!=null){if(!Kh(ge)&&ge.type==="null"){let k=aP(X,!0,r,n,a,u);return U7n(k,A,m)}else if(!Kh(X)&&X.type==="null"){let k=aP(ge,!0,r,n,a,u);return U7n(k,A,m)}}}let U=bSf({schemas:e.anyOf,context:r});if(U!=null&&!r.options.discriminatedUnionV2)return $yu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},required:e.required,description:A,availability:T,wrapAsNullable:t,discriminant:U.discriminant,variants:U.schemas,context:r,groupName:m,encoding:i,source:a,namespace:u});let ne=e.anyOf.filter(ge=>!Kh(ge)&&ge.type==="null").length>0;return R7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:A,availability:T,wrapAsNullable:t||ne,context:r,subtypes:e.anyOf.filter(ge=>Kh(ge)||ge.type!=="null"),encoding:i,groupName:m,source:a,namespace:u})}if(e.allOf!=null||e.properties!=null){let U=[];for(let ge of e.allOf??[])(Kh(ge)||Object.keys(ge).length>0)&&U.push(ge);if((e.properties==null||e.properties.length===0)&&U.length===1&&U[0]!=null){let ge=aP(U[0],t,r,n,a,u,d);return U7n(ge,A,m)}let ne=U.filter(ge=>{let X=vma(ge);return X||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify(ge)}`),X});if((e.properties==null||e.properties.length===0)&&ne.length===1&&ne[0]!=null){let ge=aP(ne[0],t,r,n,a,u,d);return U7n(ge,A,m)}return fSf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},description:A,required:e.required,wrapAsNullable:t,allOf:ne,context:r,propertiesToExclude:f,groupName:m,fullExamples:B,additionalProperties:e.additionalProperties,availability:T,encoding:i,source:a,namespace:u})}if(e.type==="object"&&ABj(e)&&MBj(e)&&ySf(e))return dma({nameOverride:o,generatedName:O,title:j,description:A,availability:T,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${O}Key`,title:void 0,description:void 0,availability:void 0,schema:ty.string({default:L7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:fSr({schema:e,logger:r.logger,fallback:c})}),groupName:m},valueSchema:Op.unknown({nameOverride:void 0,generatedName:`${O}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:m}),groupName:m,encoding:i,example:e.example});if(e.type==null){let U=e.example??e.default;return Op.unknown({nameOverride:o,generatedName:O,title:j,description:A,availability:T,groupName:m,example:U})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(n)} value=${JSON.stringify(e)}`)}function n3r(e){if(e.$ref.startsWith(cen))return e.$ref.replace(cen,"")}function Xyu(e,t,r){let n=B_(e,wh.TYPE_NAME),i=b8(t),a=e.description,u=jxe(e),f=n3r(e);if(f==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return J0.reference({generatedName:i,nameOverride:n,title:void 0,schema:f,description:a??void 0,availability:u,groupName:void 0,source:r})}function ABj(e){return e.oneOf==null||e.oneOf.length===0}function MBj(e){return e.allOf==null||e.allOf.length===0}function ySf(e){return e.properties==null||Object.keys(e.properties).length===0}function Hhi(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function U7n(e,t,r){return e.type==="reference"?Op.reference({...e,description:t,availability:e.availability,groupName:r}):e.type==="optional"?Op.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e.type==="nullable"?Op.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e}function vma(e){return Kh(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>vma(t)):e.oneOf!=null?e.oneOf.every(t=>vma(t)):e.anyOf!=null?e.anyOf.every(t=>vma(t)):!1}function vSf({literal:e,wrapAsNullable:t,groupName:r,description:n,availability:i,nameOverride:a,generatedName:u,title:f}){return t?Op.nullable({nameOverride:a,generatedName:u,title:f,value:Op.literal({nameOverride:a,generatedName:u,title:f,value:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Op.literal({nameOverride:a,generatedName:u,title:f,value:e,groupName:r,description:n,availability:i})}function X9({primitive:e,wrapAsNullable:t,groupName:r,description:n,availability:i,generatedName:a,nameOverride:u,title:f}){return r=typeof r=="string"?[r]:r,t?Op.nullable({nameOverride:u,generatedName:a,title:f,value:Op.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Op.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r})}function TBj({schemas:e}){let t=new Set;for(let r of e){if(Kh(r))return;if(r.enum!=null&&Hhi(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function bSf({schemas:e,context:t}){let r={};for(let n of e){let i=gSf({schema:n,context:t});for(let[a,u]of Object.entries(i)){let f=r[a];f!=null?f[u]=n:r[a]={[u]:n}}}for(let[n,i]of Object.entries(r))if(Object.keys(i).length===e.length)return{discriminant:n,schemas:i}}function gSf({schema:e,context:t}){let r=Kh(e)?t.resolveSchemaReference(e):e;return xBj({schema:r,context:t})}function xBj({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=gSf({schema:n,context:t});for(let[a,u]of Object.entries(i??{}))r[a]=u}return r}for(let[n,i]of Object.entries(e.properties??{})){let a=Kh(i)?t.resolveSchemaReference(i):i;a.type==="string"&&a.enum!=null&&Hhi(a.enum)&&qBj(a.enum).length===1&&a.enum[0]!=null&&(r[n]=a.enum[0]);let u=mSf(a,"const");a.type==="string"&&u!=null&&(r[n]=u),n==="type"&&a.example!=null&&(r[n]=a.example)}return r}function qBj(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 mSf(e,t){let r=e[t];if(r!=null)return r}function CBj({schema:e,logger:t}){let r=kDf({schema:e,logger:t});if(r!=null)return aSf(r)}function bma(e,t){let r={},n={};return e==null?r=t:n={[e]:t},{rootSchemas:r,namespacedSchemas:n}}var OSf="#/components/messages/",kyu=class{logger;document;taskContext;DUMMY;options;namespace;constructor({document:t,taskContext:r,options:n,namespace:i}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=n,this.namespace=i}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let n=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};n.push(i)}return n.concat(t??[])}resolveSchemaReference(t){if(this.document.components==null||this.document.components.schemas==null||!t.$ref.startsWith(cen))throw new Error(`Failed to resolve ${t.$ref}`);let n=t.$ref.substring(cen.length).split("/");if(n[0]==null)throw new Error(`${t.$ref} is undefined`);let i=this.document.components.schemas[n[0]];if(i==null)throw new Error(`${n[0]} is undefined`);if(Kh(i)&&(i=this.resolveSchemaReference(i)),n[1]==="properties"&&n[2]!=null){let a=i.properties?.[n[2]];if(a==null)throw new Error(`${t.$ref} is undefiened. Property does not exist on object.`);Kh(a)?i=this.resolveSchemaReference(a):i=a}return i}resolveMessageReference(t){if(this.document.components==null||this.document.components.messages==null||!t.$ref.startsWith(OSf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(OSf.length),n=this.document.components.messages[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}},gma=class extends kyu{constructor({document:t,taskContext:r,options:n,namespace:i}){super({document:t,taskContext:r,options:n,namespace:i})}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,n){}markSchemaWithDiscriminantValue(t,r,n){}};function i3r(e){if(typeof e=="string")return OP.primitive(Uy.string(e));if(typeof e=="number")return Number.isInteger(e)?OP.primitive(Uy.int(e)):OP.primitive(Uy.double(e));if(typeof e=="boolean")return OP.primitive(Uy.boolean(e));if(Array.isArray(e)){let t=e.map(r=>i3r(r));return t.length===0?void 0:OP.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,n]of Object.entries(e)){let i=i3r(n);i!=null&&t.push({key:Uy.string(r),value:i})}return OP.map(t)}}function Jhi(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function PSf(e){if(e!=null&&Array.isArray(e))return e}var a3r=class{schemas;context;constructor(t,r){this.schemas=t,this.context=r}buildExample({schema:t,exampleId:r,example:n,options:i,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:n,options:{...i,maxCheckerDepth:i.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:n,depth:i,visitedSchemaIds:a,options:u,skipReadonly:f}){switch(n.type){case"enum":return typeof r=="string"&&jSf({schema:n,value:r})?OP.enum(r):n.values[0]!=null?OP.enum(n.values[0]?.value):void 0;case"literal":return OP.literal(n.value);case"nullable":{if(r==null&&!this.hasExample(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});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(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});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:n.schema,example:r,options:u});return OP.primitive(d)}case"reference":{let d=this.schemas[n.schema];if(d!=null&&!a.has(n.schema)){a.add(n.schema);let c=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:i,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});return a.delete(n.schema),c}return}case"oneOf":switch(n.value.type){case"discriminated":{let d={},c={},o={},l=Jhi(r),m=l?.[n.value.discriminantProperty],O=n.value.schemas[m],j=[],A=this.getDiscriminatedUnionVariantSchema(n.value,l);A!=null&&j.push(A),j.push(...Object.entries(n.value.schemas));for(let T of j)if(m!=null&&O!=null&&O.type==="object"){c=this.getAllProperties(O),o=this.getAllRequiredProperties(O),d[n.value.discriminantProperty]=OP.primitive(Uy.string(m));break}else{let B=this.getObjectSchema(T[1]);if(B==null)continue;c=this.getAllProperties(B),o=this.getAllRequiredProperties(B),d[n.value.discriminantProperty]=OP.primitive(Uy.string(T[0]))}for(let T of n.value.commonProperties){c[T.key]={schema:T.schema,readonly:!1};let B=this.getResolvedSchema(T.schema);B.type!=="optional"&&B.type!=="nullable"&&(o[T.key]=T.schema)}for(let[T,B]of Object.entries(c)){let F=T in o;if(F&&l?.[T]!=null){let C=this.buildExampleHelper({schema:B.schema,exampleId:t,example:l[T],visitedSchemaIds:a,depth:i+1,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});if(C!=null)d[T]=C;else return}else{let C=this.buildExampleHelper({exampleId:t,schema:B.schema,example:l?.[T],visitedSchemaIds:a,depth:i+1,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});if(C!=null)d[T]=C;else if(F)return}}return OP.oneOf(W6r.discriminated(d))}case"undisciminated":{let d=this.getUnDiscriminatedUnionVariantSchema(n.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:i,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});break}}return;case"unknown":if(r!=null){let d=i3r(r);if(d!=null)return OP.unknown(d)}return u.ignoreOptionals||this.exceedsMaxDepth(i,u)?void 0:u.isParameter?OP.primitive(Uy.string(u.name??"string")):OP.map([{key:Uy.string("key"),value:OP.primitive(Uy.string("value"))}]);case"array":{let d=PSf(r),c=[];if(d!=null&&d.length>0)for(let o of d){let l=this.buildExampleHelper({exampleId:t,example:o,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});l!=null&&c.push(l)}else if(n.example!=null&&n.example.length>0)for(let o of n.example){let l=this.buildExampleHelper({exampleId:t,example:o,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});l!=null&&c.push(l)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});o!=null&&c.push(o)}return OP.array(c)}case"map":{let d=Jhi(r??n.example);if(d!=null&&Object.entries(d).length>0){let l=[];for(let[m,O]of Object.entries(d)){let j=this.buildExampleFromPrimitive({schema:n.key.schema,example:m,options:u}),A=this.buildExampleHelper({exampleId:t,example:O,schema:n.value,visitedSchemaIds:a,depth:i+1,options:u,skipReadonly:f&&this.context.options.respectReadonlySchemas});A!=null&&l.push({key:j,value:A})}return OP.map(l)}if(n.key.schema.type==="string"&&n.value.type==="unknown")return OP.map([{key:Uy.string("key"),value:OP.unknown(OP.primitive(Uy.string("value")))}]);let c=this.buildExampleFromPrimitive({schema:n.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,visitedSchemaIds:a,depth:i+1,options:{...u,name:"value"},skipReadonly:f&&this.context.options.respectReadonlySchemas});return o!=null?OP.map([{key:c,value:o}]):OP.map([])}case"object":{let d={},c=n.fullExamples?.find(O=>O.name===t)??n.fullExamples?.find(O=>O.name==null)??n.fullExamples?.[0],o=Jhi(r)??(c!=null?Jhi(c.value):{})??{},l=this.getAllProperties(n),m=this.getAllRequiredProperties(n);for(let[O,j]of Object.entries(l)){if(f&&j.readonly)continue;let A=O in m,T=Object.keys(o).includes(O),B=this.buildExampleHelper({schema:j.schema,exampleId:t,example:o[O],visitedSchemaIds:a,depth:i+1,options:{...u,name:O},skipReadonly:f&&this.context.options.respectReadonlySchemas});if(A&&B!=null)d[O]=B;else{if(A)return;(T&&B!=null||!u.ignoreOptionals&&B!=null)&&(d[O]=B)}}return OP.object({properties:d})}default:sc(n)}}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let n=r?.[t.discriminantProperty];if(n==null||typeof n!="string")return Object.entries(t.schemas)[0];let i=t.schemas[n];return i==null?Object.entries(t.schemas)[0]:[n,i]}getUnDiscriminatedUnionVariantSchema(t,r){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 jSf({schema:t,value:r})?5:0;case"object":{if(!bD(r))return 0;let n=this.getAllProperties(t),i=0;for(let[a,u]of Object.entries(n))r[a]!=null?(i++,i+=this.calcExampleHeuristic(u.schema,r[a])):i--;return i}case"array":{if(!Array.isArray(r))return 0;let n=0;for(let i of r)n+=this.calcExampleHeuristic(t.value,i);return n}case"map":{if(!bD(r))return 0;let n=0;for(let[,i]of Object.entries(r))n+=this.calcExampleHeuristic(t.value,i);return n}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let n=this.getResolvedSchema(t);return n==null?0:this.calcExampleHeuristic(n,r)}case"oneOf":return Object.values(t.value.schemas).map(i=>this.calcExampleHeuristic(i,r)).sort((i,a)=>a-i)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,n=new Set,i){if(this.exceedsMaxCheckerDepth(r,i))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,n,i);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,n,i);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let u of t.properties)if(this.hasExample(u.schema,r+1,n,i))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!n.has(t.schema)){n.add(t.schema);let u=this.hasExample(a,r,n,i);return n.delete(t.schema),u}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,n,i));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let n of t.properties)r[n.key]={schema:n.schema,readonly:n.readonly??!1};for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let n of t.properties){let i=this.getResolvedSchema(n.schema);i.type!=="optional"&&i.type!=="nullable"&&(r[n.key]=n.schema)}for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:n}){switch(r.type){case"string":return t!=null&&typeof t=="string"?Uy.string(t):r.example!=null?Uy.string(r.example):Uy.string(n.name??_1.STRING);case"base64":return t!=null&&typeof t=="string"?Uy.base64(t):r.example!=null?Uy.base64(r.example):Uy.base64(_1.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?Uy.boolean(t):r.example!=null?Uy.boolean(r.example):Uy.boolean(_1.BOOLEAN);case"date":return t!=null&&typeof t=="string"?Uy.date(t):r.example!=null?Uy.date(r.example):Uy.date(_1.DATE);case"datetime":return t!=null&&typeof t=="string"?Uy.datetime(t):r.example!=null?Uy.datetime(r.example):Uy.datetime(_1.DATE_TIME);case"double":return t!=null&&typeof t=="number"?Uy.double(t):r.example!=null?Uy.double(r.example):Uy.double(_1.DOUBLE);case"float":return t!=null&&typeof t=="number"?Uy.float(t):r.example!=null?Uy.float(r.example):Uy.float(_1.FLOAT);case"int":return t!=null&&typeof t=="number"?Uy.int(t):r.example!=null?Uy.int(r.example):Uy.int(_1.INT);case"int64":return t!=null&&typeof t=="number"?Uy.int64(t):r.example!=null?Uy.int64(r.example):Uy.int64(_1.INT64);case"uint":return t!=null&&typeof t=="number"?Uy.uint(t):r.example!=null?Uy.uint(r.example):Uy.uint(_1.UINT);case"uint64":return t!=null&&typeof t=="number"?Uy.uint64(t):r.example!=null?Uy.uint64(r.example):Uy.uint64(_1.UINT64);default:sc(r)}}};function jSf({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function g8t(e){switch(e.type){case"object":return Op.object({allOf:e.allOf,properties:e.properties.map(t=>IBj(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return Op.array({description:e.description,availability:e.availability,value:g8t(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0});case"enum":return Op.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,groupName:e.groupName,example:void 0,source:e.source});case"literal":return Op.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName});case"nullable":return Op.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:g8t(e.value),groupName:e.groupName});case"optional":return Op.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:g8t(e.value),groupName:e.groupName});case"primitive":return Op.primitive({description:e.description,availability:e.availability,schema:wSf(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return Op.map({description:e.description,availability:e.availability,key:Op.primitive({description:e.key.description,availability:e.key.availability,schema:wSf(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:g8t(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,encoding:e.encoding,example:void 0});case"reference":return Op.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,groupName:e.groupName,source:e.source});case"oneOf":return Op.oneOf(BBj(e.value));case"unknown":return Op.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,groupName:void 0,description:void 0,availability:void 0});default:sc(e)}}function BBj(e){switch(e.type){case"discriminated":return SX.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:g8t(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,g8t(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return SX.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>g8t(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:sc(e)}}function wSf(e){switch(e.type){case"string":return ty.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return ty.base64({example:void 0});case"boolean":return ty.boolean({default:e.default,example:void 0});case"date":return ty.date({example:void 0});case"datetime":return ty.datetime({example:void 0});case"double":return ty.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 ty.float({example:void 0});case"int":return ty.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 ty.int64({default:e.default,example:void 0});case"uint":return ty.uint({default:void 0,example:void 0});case"uint64":return ty.uint64({default:void 0,example:void 0});default:sc(e)}}function IBj(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:g8t(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly}}function mma(e){return e.type!=="optional"&&e.type!=="nullable"}function Qhi(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 Oma=class{exampleTypeFactory;logger;schemas;constructor(t,r){this.schemas=t,this.exampleTypeFactory=new a3r(t,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=NBj(t.request),n=FBj(t.response);if(r?.type==="unsupported"||n?.type==="unsupported")return[];let i=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let m=this.exampleTypeFactory.buildExample({skipReadonly:t.method==="POST"||t.method==="PUT",schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});m!=null&&i.push([void 0,m])}else for(let{name:m,value:O}of r.examples){let j=this.exampleTypeFactory.buildExample({skipReadonly:t.method==="POST"||t.method==="PUT",schema:r.schema,exampleId:m,example:O,options:{isParameter:!1,ignoreOptionals:!0}});j!=null&&i.push([m,j])}if(l&&i.length===0)return this.logger.warn(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(n!=null&&n.type==="present"){let l=this.isSchemaRequired(n.schema);if(n.examples.length===0){let m=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:void 0,example:void 0,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});m!=null&&(t.response?.type==="json"?a.push([void 0,y2t.withoutStreaming(m)]):t.response?.type==="streamingJson"&&a.push([void 0,y2t.withStreaming([m])]))}else for(let{name:m,value:O}of n.examples){let j=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:m,example:O,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});j!=null&&(t.response?.type==="json"?a.push([m,y2t.withoutStreaming(j)]):t.response?.type==="streamingJson"&&a.push([m,y2t.withStreaming([j])]))}if(l&&a.length===0)return this.logger.warn(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let l of t.pathParameters){let m=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!m8t(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),m&&O==null)return[];O!=null&&u.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:O})}let f=[];for(let l of t.queryParameters){let m=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!m8t(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),m&&O==null)return[];O!=null&&f.push({name:l.name,value:O})}let d=[];for(let l of t.headers){let m=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!m8t(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),m&&O==null)return[];O!=null&&d.push({name:l.name,value:O})}let c=[];t.request!=null&&t.response!=null?c=zBj(i,a):t.request!=null?c=i.map(([l,m])=>({id:l,request:m,response:void 0})):t.response!=null&&(c=a.map(([l,m])=>({id:l,request:void 0,response:m})));let o=t.examples.filter(l=>Qhi(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let m=l.value["code-samples"];if(m!=null)return this.convertCodeSamples(m)}return}else return l.codeSamples}).filter(l=>YA(l));return c.length===0?[h2t.full({name:void 0,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:void 0,response:void 0,codeSamples:o})]:c.map(({id:l,request:m,response:O})=>h2t.full({name:l,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:m,response:O,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?sSr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):sSr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?hW.Csharp:r.sdk,code:r.code})).filter(YA)}isSchemaRequired(t){return mma(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function zBj(e,t){let r=[];if(e.length<=1){let[i,a]=e[0]??[];if(t.length===0)return r.push({id:i,request:a,response:void 0}),r;for(let[u,f]of t)r.push({id:u??i,request:a,response:f});return r}if(t.length<=1){let[i,a]=t[0]??[];if(t.length===0)return r.push({id:i,request:void 0,response:a}),r;for(let[u,f]of e)r.push({id:u??i,request:f,response:a});return r}let n=new Set;for(let[i,a]of e){let u=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(i==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let f=!1;for(let d=0;d<t.length;d++){let[c,o]=t[d];c==null||n.has(d)||i===c&&(r.push({id:i,request:a,response:o}),c!=null&&n.add(d),f=!0)}!f&&u!=null&&r.push({id:i,request:a,response:u})}for(let i=0;i<t.length;i++){if(n.has(i))continue;let[a,u]=t[i],f=e.find(([d])=>d==null)?.[1]??e[0]?.[1];f!=null&&r.push({id:a,request:f,response:u})}return r}function NBj(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:RBj(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function FBj(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function m8t(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return m8t(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undisciminated":return m8t(e.value.value);default:return!1}default:sc(e)}}function RBj(e){return Op.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:g8t(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0}).filter(YA),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source})}var Pma=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new a3r(t,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,publish:n,subscribe:i,handshake:a,source:u,namespace:f}){let d=[];for(let c of r){let o=[];for(let O of a.queryParameters){let j=this.isSchemaRequired(O.schema),A=this.exampleTypeFactory.buildExample({schema:O.schema,exampleId:void 0,example:c.queryParameters?.[O.name],options:{name:O.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!m8t(A)&&(A=void 0),!(j&&A==null)&&A!=null&&o.push({name:O.name,value:A})}let l=[];for(let O of a.headers){let j=this.isSchemaRequired(O.schema),A=this.exampleTypeFactory.buildExample({schema:O.schema,exampleId:void 0,example:c.headers?.[O.name],options:{name:O.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!m8t(A)&&(A=void 0),!(j&&A==null)&&A!=null&&l.push({name:O.name,value:A})}let m=[];for(let O of c.messages){let j=t.resolveMessageReference({$ref:`#/components/messages/${O.messageId}`}),A=Kh(j.payload)?t.resolveSchemaReference(j.payload):j.payload,T=this.exampleTypeFactory.buildExample({schema:aP(A,!1,t,[O.messageId],u,f),exampleId:void 0,example:O.value,options:{isParameter:!1,ignoreOptionals:!0}});T!=null&&m.push({messageType:O.type,payload:T,description:void 0})}d.push({name:c.summary,queryParameters:o,headers:l,description:c.description,messages:m})}return d}buildWebsocketSessionExample({publish:t,subscribe:r,handshake:n}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},a=[];for(let f of n.queryParameters){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!m8t(c)&&(c=void 0),d&&c==null)return;c!=null&&a.push({name:f.name,value:c})}let u=[];for(let f of n.headers){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!m8t(c)&&(c=void 0),d&&c==null)return;c!=null&&u.push({name:f.name,value:c})}if(t!=null){let f=this.exampleTypeFactory.buildExample({schema:t,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"publish",payload:f,description:void 0})}if(r!=null){let f=this.exampleTypeFactory.buildExample({schema:r,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"subscribe",payload:f,description:void 0})}return i}isSchemaRequired(t){return mma(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 Ghi={FERN_DISPLAY_NAME:"x-fern-display-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path"};function DSf(e){return B_(e,Ghi.FERN_EXAMPLES)??[]}function ESf({document:e,taskContext:t,options:r,source:n,asyncApiOptions:i,namespace:a}){let u=[];a!=null&&u.push(a),e.tags?.[0]!=null?u.push(e.tags[0].name):i.naming!=="v2"&&u.push("websocket");let f=new gma({document:e,taskContext:t,options:r,namespace:a}),d={},c;for(let[l,m]of Object.entries(e.components?.schemas??{})){let O=aP(m,!1,f,[l],n,a);d[l]=O}let o=new Pma(d,f);for(let[l,m]of Object.entries(e.channels??{})){if(m.bindings?.ws==null){f.logger.error(`Channel ${l} does not have websocket bindings. Skipping.`);continue}let O=[];if(m.parameters!=null)for(let[F,C]of Object.entries(m.parameters??{}))O.push({name:F,description:C.description,parameterNameOverride:void 0,schema:C.schema!=null?aP(C.schema,!1,f,u,n,a):Op.primitive({schema:ty.string({default:void 0,pattern:void 0,format:void 0,maxLength:void 0,minLength:void 0,example:void 0}),description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:jxe(C),source:n});let j=[];if(m.bindings.ws.headers!=null){let F=m.bindings.ws.headers.required??[];for(let[C,N]of Object.entries(m.bindings.ws.headers.properties??{})){let U=Kh(N)?f.resolveSchemaReference(N):N;j.push({name:C,schema:aP(U,!F.includes(C),f,u,n,a),description:U.description,parameterNameOverride:void 0,env:void 0,availability:jxe(U),source:n})}}let A=[];if(m.bindings.ws.query!=null){let F=m.bindings.ws.query.required??[];for(let[C,N]of Object.entries(m.bindings.ws.query.properties??{})){let U=Kh(N)?f.resolveSchemaReference(N):N;A.push({name:C,schema:aP(U,!F.includes(C),f,u,n,a),description:U.description,parameterNameOverride:void 0,availability:jxe(U),source:n})}}let T;m.publish!=null&&(T=SSf({generatedName:m.publish.operationId??"PublishEvent",event:m.publish,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i}));let B;if(m.subscribe!=null&&(B=SSf({generatedName:m.subscribe.operationId??"SubscribeEvent",event:m.subscribe,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i})),j.length>0||A.length>0||T!=null||B!=null){let F=DSf(m),C=[];if(F.length>0)C=o.buildWebsocketSessionExamplesForExtension({context:f,extensionExamples:F,handshake:{headers:j,queryParameters:A},publish:T,subscribe:B,source:n,namespace:a});else{let U=o.buildWebsocketSessionExample({handshake:{headers:j,queryParameters:A},publish:T,subscribe:B});U!=null&&C.push(U)}let N=e.tags?.[0]?.name!=null?[e.tags?.[0].name]:void 0;c={handshake:{headers:j.map(U=>({...U,schema:mx(U.schema),env:U.env})),queryParameters:A.map(U=>({...U,schema:mx(U.schema)})),pathParameters:O.map(U=>({...U,parameterNameOverride:void 0,schema:mx(U.schema)}))},groupName:f.resolveTags(N,"Websocket"),publish:T!=null?mx(T):T,subscribe:B!=null?mx(B):B,summary:B_(m,Ghi.FERN_DISPLAY_NAME),path:l,description:void 0,examples:C,source:n};break}}return{groupedSchemas:bma(a,d),channel:c,basePath:B_(e,Ghi.BASE_PATH)}}function SSf({generatedName:e,event:t,context:r,breadcrumbs:n,source:i,options:a,asyncApiOptions:u}){if(t.message.oneOf!=null){let f=[],d=[];for(let c of t.message.oneOf){let o,l={type:"notFound"};if(Kh(c)){let m=r.resolveMessageReference(c);!Kh(m.payload)&&u.naming==="v2"?(l=m.name?{type:"name",name:m.name}:l,o={...m.payload,title:m.name??m.payload.title,description:m.name??m.payload.description}):o=m.payload}else o=c;d.push(l),f.push(o)}return R7n({description:t.description??t.message.description,availability:jxe(t.message),subtypes:f,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:n,context:r,encoding:void 0,source:i,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}var Wen=Jo(pIf(),1);var _If=require("fs/promises");async function xja({absoluteFilepathToOverrides:e,data:t,context:r}){let n=null;try{let i=(await(0,_If.readFile)(e,"utf8")).toString();try{n=JSON.parse(i)}catch{n=Fy.load(i,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return fUo({data:t,overrides:n})}var YXj={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},XXj={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:YXj,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}};async function yIf({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,context:r}){let n=await hIf({absolutePathToOpenAPI:e}),i;if(t!=null?i=t:typeof n=="object"&&n[wh.OPENAPI_OVERIDES_FILEPATH]!=null&&(i=Wl(B0(e),ls.of(n[wh.OPENAPI_OVERIDES_FILEPATH]))),i!=null){let a=await xja({absoluteFilepathToOverrides:i,context:r,data:n});return await hIf({absolutePathToOpenAPI:e,parsed:a})}return n}async function hIf({absolutePathToOpenAPI:e,parsed:t}){let r={config:new Wen.Config({apis:{},styleguide:{plugins:[XXj],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};return(t!=null?await(0,Wen.bundle)({...r,doc:{source:new Wen.Source(e,"<openapi>"),parsed:t}}):await(0,Wen.bundle)({...r,ref:e})).bundle.parsed}var A3f=Jo(w6f(),1);function D6f(e){return B_(e,wh.ASYNC_CONFIG)}var S6f="$request.";function E6f(e){let t=B_(e,wh.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:liw(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function liw(e){return e.startsWith(S6f)?e.slice(S6f.length):e}function A6f(e){let t=e;if(t.cursor!=null)return uSr.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});let r=e;return uSr.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}function M6f(e,t){let r=B_(t,wh.PAGINATION);if(r!=null){if(typeof r=="boolean"){let n=B_(e,wh.PAGINATION);if(typeof n=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return n==null?void 0:A6f(n)}return A6f(r)}}function T6f(e){let t=fiw(e),r={};return jju({obj:t,occurrences:r,breadcrumbs:[]}),r}function jju({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let n of e)jju({obj:n,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let n=e.$ref;t[n]==null?t[n]=1:t[n]+=1;return}for(let n in e)jju({obj:e[n],occurrences:t,breadcrumbs:[...r,n]})}}}function fiw(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?Qvi(r.get):void 0,put:r?.put!=null?Qvi(r.put):void 0,post:r?.post!=null?Qvi(r.post):void 0,patch:r?.patch!=null?Qvi(r.patch):void 0,delete:r?.delete!=null?Qvi(r.delete):void 0}]))}}function Qvi(e){return{...e,requestBody:e.requestBody!=null?Kh(e.requestBody)?e.requestBody:diw(e.requestBody):void 0}}function diw(e){let t,r;for(let n in e.content){let i=eI.parse(n);i!=null&&(i.isJSON()?t=e.content[n]:i.isMultipart()&&(r=e.content[n]))}return r!=null&&t!=null?{...e,content:{[eI.MULTIPART_FORM_DATA]:r}}:e}var x6f="#/components/parameters/",q6f="#/components/responses/",C6f="#/components/examples/",B6f="#/components/requestBodies/",rNn=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;namespace;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=n,this.refOccurrences=T6f(t),this.options=i,this.source=a,this.DUMMY=this.getDummy(),this.namespace=u}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};r.push(n)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return{"x-fern-type":"unknown",additionalProperties:!0};n=n[i]}return n==null?{"x-fern-type":"unknown",additionalProperties:!0}:(Kh(n)&&(n=this.resolveSchemaReference(n)),n)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(x6f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(x6f.length),n=this.document.components.parameters[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Kh(n)?this.resolveParameterReference(n):n}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(B6f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(B6f.length),n=this.document.components.requestBodies[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Kh(n)?this.resolveRequestBodyReference(n):n}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(q6f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(q6f.length),n=this.document.components.responses[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Kh(n)?this.resolveResponseReference(n):n}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(C6f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(C6f.length),n=this.document.components.examples[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Kh(n)?this.resolveExampleReference(n):n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}};var nNn=class extends rNn{constructor({document:t,taskContext:r,options:n,source:i,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:n,source:i,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,n){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,n){}getDiscriminatedUnionMetadata(t){}};var MM;(function(e){e.assertEqual=i=>i;function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let a={};for(let u of i)a[u]=u;return a},e.getValidEnumValues=i=>{let a=e.objectKeys(i).filter(f=>typeof i[i[f]]!="number"),u={};for(let f of a)u[f]=i[f];return e.objectValues(u)},e.objectValues=i=>e.objectKeys(i).map(function(a){return i[a]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let u in i)Object.prototype.hasOwnProperty.call(i,u)&&a.push(u);return a},e.find=(i,a)=>{for(let u of i)if(a(u))return u},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(u=>typeof u=="string"?`'${u}'`:u).join(a)}e.joinValues=n,e.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(MM||(MM={}));var Dju;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Dju||(Dju={}));var av=MM.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),K3r=e=>{switch(typeof e){case"undefined":return av.undefined;case"string":return av.string;case"number":return isNaN(e)?av.nan:av.number;case"boolean":return av.boolean;case"function":return av.function;case"bigint":return av.bigint;case"symbol":return av.symbol;case"object":return Array.isArray(e)?av.array:e===null?av.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?av.promise:typeof Map<"u"&&e instanceof Map?av.map:typeof Set<"u"&&e instanceof Set?av.set:typeof Date<"u"&&e instanceof Date?av.date:av.object;default:return av.unknown}},W_=MM.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),piw=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Iwe=class e extends Error{constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){let r=t||function(a){return a.message},n={_errors:[]},i=a=>{for(let u of a.issues)if(u.code==="invalid_union")u.unionErrors.map(i);else if(u.code==="invalid_return_type")i(u.returnTypeError);else if(u.code==="invalid_arguments")i(u.argumentsError);else if(u.path.length===0)n._errors.push(r(u));else{let f=n,d=0;for(;d<u.path.length;){let c=u.path[d];d===u.path.length-1?(f[c]=f[c]||{_errors:[]},f[c]._errors.push(r(u))):f[c]=f[c]||{_errors:[]},f=f[c],d++}}};return i(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,MM.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Iwe.create=e=>new Iwe(e);var oNn=(e,t)=>{let r;switch(e.code){case W_.invalid_type:e.received===av.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case W_.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,MM.jsonStringifyReplacer)}`;break;case W_.unrecognized_keys:r=`Unrecognized key(s) in object: ${MM.joinValues(e.keys,", ")}`;break;case W_.invalid_union:r="Invalid input";break;case W_.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${MM.joinValues(e.options)}`;break;case W_.invalid_enum_value:r=`Invalid enum value. Expected ${MM.joinValues(e.options)}, received '${e.received}'`;break;case W_.invalid_arguments:r="Invalid function arguments";break;case W_.invalid_return_type:r="Invalid function return type";break;case W_.invalid_date:r="Invalid date";break;case W_.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:MM.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case W_.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case W_.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case W_.custom:r="Invalid input";break;case W_.invalid_intersection_types:r="Intersection results could not be merged";break;case W_.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case W_.not_finite:r="Number must be finite";break;default:r=t.defaultError,MM.assertNever(e)}return{message:r}},N6f=oNn;function _iw(e){N6f=e}function Rwa(){return N6f}var Lwa=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,a=[...r,...i.path||[]],u={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let f="",d=n.filter(c=>!!c).slice().reverse();for(let c of d)f=c(u,{data:t,defaultError:f}).message;return{...i,path:a,message:f}},hiw=[];function qy(e,t){let r=Rwa(),n=Lwa({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===oNn?void 0:oNn].filter(i=>!!i)});e.common.issues.push(n)}var hG=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return bO;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let a=await i.key,u=await i.value;n.push({key:a,value:u})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:a,value:u}=i;if(a.status==="aborted"||u.status==="aborted")return bO;a.status==="dirty"&&t.dirty(),u.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof u.value<"u"||i.alwaysSet)&&(n[a.value]=u.value)}return{status:t.value,value:n}}},bO=Object.freeze({status:"aborted"}),aNn=e=>({status:"dirty",value:e}),VX=e=>({status:"valid",value:e}),Sju=e=>e.status==="aborted",Eju=e=>e.status==="dirty",Kvi=e=>e.status==="valid",Yvi=e=>typeof Promise<"u"&&e instanceof Promise;function Uwa(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)}function F6f(e,t,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r}var Yb;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(Yb||(Yb={}));var Gvi,$vi,Nxe=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},I6f=(e,t)=>{if(Kvi(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Iwe(e.common.issues);return this._error=r,this._error}}};function Nw(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(u,f)=>{var d,c;let{message:o}=e;return u.code==="invalid_enum_value"?{message:o??f.defaultError}:typeof f.data>"u"?{message:(d=o??n)!==null&&d!==void 0?d:f.defaultError}:u.code!=="invalid_type"?{message:f.defaultError}:{message:(c=o??r)!==null&&c!==void 0?c:f.defaultError}},description:i}}var Fw=class{constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(t){return K3r(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:K3r(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new hG,ctx:{common:t.parent.common,data:t.data,parsedType:K3r(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Yvi(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){var n;let i={common:{issues:[],async:(n=r?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:K3r(t)},a=this._parseSync({data:t,path:i.path,parent:i});return I6f(i,a)}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:K3r(t)},i=this._parse({data:t,path:n.path,parent:n}),a=await(Yvi(i)?i:Promise.resolve(i));return I6f(n,a)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{let u=t(i),f=()=>a.addIssue({code:W_.custom,...n(i)});return typeof Promise<"u"&&u instanceof Promise?u.then(d=>d?!0:(f(),!1)):u?!0:(f(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new zwe({schema:this,typeName:Gm.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return zxe.create(this,this._def)}nullable(){return F8t.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return TSr.create(this,this._def)}promise(){return Z3r.create(this,this._def)}or(t){return utn.create([this,t],this._def)}and(t){return stn.create(this,t,this._def)}transform(t){return new zwe({...Nw(this._def),schema:this,typeName:Gm.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new ptn({...Nw(this._def),innerType:this,defaultValue:r,typeName:Gm.ZodDefault})}brand(){return new Xvi({typeName:Gm.ZodBranded,type:this,...Nw(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new _tn({...Nw(this._def),innerType:this,catchValue:r,typeName:Gm.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Zvi.create(this,t)}readonly(){return htn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},yiw=/^c[^\s-]{8,}$/i,viw=/^[0-9a-z]+$/,biw=/^[0-9A-HJKMNP-TV-Z]{26}$/,giw=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,miw=/^[a-z0-9_-]{21}$/i,Oiw=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Piw=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jiw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",wju,wiw=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Diw=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Siw=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,R6f="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Eiw=new RegExp(`^${R6f}$`);function L6f(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function Aiw(e){return new RegExp(`^${L6f(e)}$`)}function U6f(e){let t=`${R6f}T${L6f(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Miw(e,t){return!!((t==="v4"||!t)&&wiw.test(e)||(t==="v6"||!t)&&Diw.test(e))}var Y3r=class e extends Fw{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==av.string){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_type,expected:av.string,received:a.parsedType}),bO}let n=new hG,i;for(let a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")t.data.length>a.value&&(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let u=t.data.length>a.value,f=t.data.length<a.value;(u||f)&&(i=this._getOrReturnCtx(t,i),u?qy(i,{code:W_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):f&&qy(i,{code:W_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Piw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"email",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")wju||(wju=new RegExp(jiw,"u")),wju.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"emoji",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")giw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"uuid",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")miw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"nanoid",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")yiw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"cuid",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")viw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"cuid2",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")biw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"ulid",code:W_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),qy(i,{validation:"url",code:W_.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"regex",code:W_.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?U6f(a).test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Eiw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Aiw(a).test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?Oiw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"duration",code:W_.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Miw(t.data,a.version)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"ip",code:W_.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Siw.test(t.data)||(i=this._getOrReturnCtx(t,i),qy(i,{validation:"base64",code:W_.invalid_string,message:a.message}),n.dirty()):MM.assertNever(a);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:W_.invalid_string,...Yb.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Yb.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Yb.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Yb.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Yb.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Yb.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Yb.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Yb.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Yb.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Yb.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Yb.errToObj(t)})}datetime(t){var r,n;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(r=t?.offset)!==null&&r!==void 0?r:!1,local:(n=t?.local)!==null&&n!==void 0?n:!1,...Yb.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...Yb.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...Yb.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Yb.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...Yb.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Yb.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Yb.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Yb.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Yb.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Yb.errToObj(r)})}nonempty(t){return this.min(1,Yb.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Y3r.create=e=>{var t;return new Y3r({checks:[],typeName:Gm.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Nw(e)})};function Tiw(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(e.toFixed(i).replace(".","")),u=parseInt(t.toFixed(i).replace(".",""));return a%u/Math.pow(10,i)}var ttn=class e extends Fw{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==av.number){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_type,expected:av.number,received:a.parsedType}),bO}let n,i=new hG;for(let a of this._def.checks)a.kind==="int"?MM.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?Tiw(t.data,a.value)!==0&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.not_finite,message:a.message}),i.dirty()):MM.assertNever(a);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Yb.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Yb.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Yb.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Yb.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Yb.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Yb.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Yb.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Yb.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Yb.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Yb.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Yb.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Yb.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Yb.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Yb.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&MM.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};ttn.create=e=>new ttn({checks:[],typeName:Gm.ZodNumber,coerce:e?.coerce||!1,...Nw(e)});var rtn=class e extends Fw{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==av.bigint){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_type,expected:av.bigint,received:a.parsedType}),bO}let n,i=new hG;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),qy(n,{code:W_.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):MM.assertNever(a);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Yb.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Yb.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Yb.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Yb.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Yb.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Yb.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Yb.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Yb.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Yb.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Yb.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};rtn.create=e=>{var t;return new rtn({checks:[],typeName:Gm.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Nw(e)})};var ntn=class extends Fw{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==av.boolean){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.boolean,received:n.parsedType}),bO}return VX(t.data)}};ntn.create=e=>new ntn({typeName:Gm.ZodBoolean,coerce:e?.coerce||!1,...Nw(e)});var itn=class e extends Fw{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==av.date){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_type,expected:av.date,received:a.parsedType}),bO}if(isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return qy(a,{code:W_.invalid_date}),bO}let n=new hG,i;for(let a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(i=this._getOrReturnCtx(t,i),qy(i,{code:W_.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):MM.assertNever(a);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Yb.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Yb.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};itn.create=e=>new itn({checks:[],coerce:e?.coerce||!1,typeName:Gm.ZodDate,...Nw(e)});var uNn=class extends Fw{_parse(t){if(this._getType(t)!==av.symbol){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.symbol,received:n.parsedType}),bO}return VX(t.data)}};uNn.create=e=>new uNn({typeName:Gm.ZodSymbol,...Nw(e)});var atn=class extends Fw{_parse(t){if(this._getType(t)!==av.undefined){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.undefined,received:n.parsedType}),bO}return VX(t.data)}};atn.create=e=>new atn({typeName:Gm.ZodUndefined,...Nw(e)});var otn=class extends Fw{_parse(t){if(this._getType(t)!==av.null){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.null,received:n.parsedType}),bO}return VX(t.data)}};otn.create=e=>new otn({typeName:Gm.ZodNull,...Nw(e)});var X3r=class extends Fw{constructor(){super(...arguments),this._any=!0}_parse(t){return VX(t.data)}};X3r.create=e=>new X3r({typeName:Gm.ZodAny,...Nw(e)});var MSr=class extends Fw{constructor(){super(...arguments),this._unknown=!0}_parse(t){return VX(t.data)}};MSr.create=e=>new MSr({typeName:Gm.ZodUnknown,...Nw(e)});var M2t=class extends Fw{_parse(t){let r=this._getOrReturnCtx(t);return qy(r,{code:W_.invalid_type,expected:av.never,received:r.parsedType}),bO}};M2t.create=e=>new M2t({typeName:Gm.ZodNever,...Nw(e)});var sNn=class extends Fw{_parse(t){if(this._getType(t)!==av.undefined){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.void,received:n.parsedType}),bO}return VX(t.data)}};sNn.create=e=>new sNn({typeName:Gm.ZodVoid,...Nw(e)});var TSr=class e extends Fw{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==av.array)return qy(r,{code:W_.invalid_type,expected:av.array,received:r.parsedType}),bO;if(i.exactLength!==null){let u=r.data.length>i.exactLength.value,f=r.data.length<i.exactLength.value;(u||f)&&(qy(r,{code:u?W_.too_big:W_.too_small,minimum:f?i.exactLength.value:void 0,maximum:u?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(qy(r,{code:W_.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(qy(r,{code:W_.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((u,f)=>i.type._parseAsync(new Nxe(r,u,r.path,f)))).then(u=>hG.mergeArray(n,u));let a=[...r.data].map((u,f)=>i.type._parseSync(new Nxe(r,u,r.path,f)));return hG.mergeArray(n,a)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:Yb.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:Yb.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:Yb.toString(r)}})}nonempty(t){return this.min(1,t)}};TSr.create=(e,t)=>new TSr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Gm.ZodArray,...Nw(t)});function iNn(e){if(e instanceof zne){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=zxe.create(iNn(n))}return new zne({...e._def,shape:()=>t})}else return e instanceof TSr?new TSr({...e._def,type:iNn(e.element)}):e instanceof zxe?zxe.create(iNn(e.unwrap())):e instanceof F8t?F8t.create(iNn(e.unwrap())):e instanceof N8t?N8t.create(e.items.map(t=>iNn(t))):e}var zne=class e extends Fw{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=MM.objectKeys(t);return this._cached={shape:t,keys:r}}_parse(t){if(this._getType(t)!==av.object){let c=this._getOrReturnCtx(t);return qy(c,{code:W_.invalid_type,expected:av.object,received:c.parsedType}),bO}let{status:n,ctx:i}=this._processInputParams(t),{shape:a,keys:u}=this._getCached(),f=[];if(!(this._def.catchall instanceof M2t&&this._def.unknownKeys==="strip"))for(let c in i.data)u.includes(c)||f.push(c);let d=[];for(let c of u){let o=a[c],l=i.data[c];d.push({key:{status:"valid",value:c},value:o._parse(new Nxe(i,l,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof M2t){let c=this._def.unknownKeys;if(c==="passthrough")for(let o of f)d.push({key:{status:"valid",value:o},value:{status:"valid",value:i.data[o]}});else if(c==="strict")f.length>0&&(qy(i,{code:W_.unrecognized_keys,keys:f}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let o of f){let l=i.data[o];d.push({key:{status:"valid",value:o},value:c._parse(new Nxe(i,l,i.path,o)),alwaysSet:o in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let o of d){let l=await o.key,m=await o.value;c.push({key:l,value:m,alwaysSet:o.alwaysSet})}return c}).then(c=>hG.mergeObjectSync(n,c)):hG.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(t){return Yb.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{var i,a,u,f;let d=(u=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&u!==void 0?u:n.defaultError;return r.code==="unrecognized_keys"?{message:(f=Yb.errToObj(t).message)!==null&&f!==void 0?f:d}:{message:d}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Gm.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};return MM.objectKeys(t).forEach(n=>{t[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new e({...this._def,shape:()=>r})}omit(t){let r={};return MM.objectKeys(this.shape).forEach(n=>{t[n]||(r[n]=this.shape[n])}),new e({...this._def,shape:()=>r})}deepPartial(){return iNn(this)}partial(t){let r={};return MM.objectKeys(this.shape).forEach(n=>{let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}),new e({...this._def,shape:()=>r})}required(t){let r={};return MM.objectKeys(this.shape).forEach(n=>{if(t&&!t[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof zxe;)a=a._def.innerType;r[n]=a}}),new e({...this._def,shape:()=>r})}keyof(){return V6f(MM.objectKeys(this.shape))}};zne.create=(e,t)=>new zne({shape:()=>e,unknownKeys:"strip",catchall:M2t.create(),typeName:Gm.ZodObject,...Nw(t)});zne.strictCreate=(e,t)=>new zne({shape:()=>e,unknownKeys:"strict",catchall:M2t.create(),typeName:Gm.ZodObject,...Nw(t)});zne.lazycreate=(e,t)=>new zne({shape:e,unknownKeys:"strip",catchall:M2t.create(),typeName:Gm.ZodObject,...Nw(t)});var utn=class extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(a){for(let f of a)if(f.result.status==="valid")return f.result;for(let f of a)if(f.result.status==="dirty")return r.common.issues.push(...f.ctx.common.issues),f.result;let u=a.map(f=>new Iwe(f.ctx.common.issues));return qy(r,{code:W_.invalid_union,unionErrors:u}),bO}if(r.common.async)return Promise.all(n.map(async a=>{let u={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:u}),ctx:u}})).then(i);{let a,u=[];for(let d of n){let c={...r,common:{...r.common,issues:[]},parent:null},o=d._parseSync({data:r.data,path:r.path,parent:c});if(o.status==="valid")return o;o.status==="dirty"&&!a&&(a={result:o,ctx:c}),c.common.issues.length&&u.push(c.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let f=u.map(d=>new Iwe(d));return qy(r,{code:W_.invalid_union,unionErrors:f}),bO}}get options(){return this._def.options}};utn.create=(e,t)=>new utn({options:e,typeName:Gm.ZodUnion,...Nw(t)});var ASr=e=>e instanceof ctn?ASr(e.schema):e instanceof zwe?ASr(e.innerType()):e instanceof ltn?[e.value]:e instanceof ftn?e.options:e instanceof dtn?MM.objectValues(e.enum):e instanceof ptn?ASr(e._def.innerType):e instanceof atn?[void 0]:e instanceof otn?[null]:e instanceof zxe?[void 0,...ASr(e.unwrap())]:e instanceof F8t?[null,...ASr(e.unwrap())]:e instanceof Xvi||e instanceof htn?ASr(e.unwrap()):e instanceof _tn?ASr(e._def.innerType):[],Vwa=class e extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==av.object)return qy(r,{code:W_.invalid_type,expected:av.object,received:r.parsedType}),bO;let n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(qy(r,{code:W_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),bO)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let a of r){let u=ASr(a.shape[t]);if(!u.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let f of u){if(i.has(f))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(f)}`);i.set(f,a)}}return new e({typeName:Gm.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...Nw(n)})}};function Aju(e,t){let r=K3r(e),n=K3r(t);if(e===t)return{valid:!0,data:e};if(r===av.object&&n===av.object){let i=MM.objectKeys(t),a=MM.objectKeys(e).filter(f=>i.indexOf(f)!==-1),u={...e,...t};for(let f of a){let d=Aju(e[f],t[f]);if(!d.valid)return{valid:!1};u[f]=d.data}return{valid:!0,data:u}}else if(r===av.array&&n===av.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let a=0;a<e.length;a++){let u=e[a],f=t[a],d=Aju(u,f);if(!d.valid)return{valid:!1};i.push(d.data)}return{valid:!0,data:i}}else return r===av.date&&n===av.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var stn=class extends Fw{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(a,u)=>{if(Sju(a)||Sju(u))return bO;let f=Aju(a.value,u.value);return f.valid?((Eju(a)||Eju(u))&&r.dirty(),{status:r.value,value:f.data}):(qy(n,{code:W_.invalid_intersection_types}),bO)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,u])=>i(a,u)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};stn.create=(e,t,r)=>new stn({left:e,right:t,typeName:Gm.ZodIntersection,...Nw(r)});var N8t=class e extends Fw{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==av.array)return qy(n,{code:W_.invalid_type,expected:av.array,received:n.parsedType}),bO;if(n.data.length<this._def.items.length)return qy(n,{code:W_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),bO;!this._def.rest&&n.data.length>this._def.items.length&&(qy(n,{code:W_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((u,f)=>{let d=this._def.items[f]||this._def.rest;return d?d._parse(new Nxe(n,u,n.path,f)):null}).filter(u=>!!u);return n.common.async?Promise.all(a).then(u=>hG.mergeArray(r,u)):hG.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};N8t.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new N8t({items:e,typeName:Gm.ZodTuple,rest:null,...Nw(t)})};var Wwa=class e extends Fw{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==av.object)return qy(n,{code:W_.invalid_type,expected:av.object,received:n.parsedType}),bO;let i=[],a=this._def.keyType,u=this._def.valueType;for(let f in n.data)i.push({key:a._parse(new Nxe(n,f,n.path,f)),value:u._parse(new Nxe(n,n.data[f],n.path,f)),alwaysSet:f in n.data});return n.common.async?hG.mergeObjectAsync(r,i):hG.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof Fw?new e({keyType:t,valueType:r,typeName:Gm.ZodRecord,...Nw(n)}):new e({keyType:Y3r.create(),valueType:t,typeName:Gm.ZodRecord,...Nw(r)})}},cNn=class extends Fw{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==av.map)return qy(n,{code:W_.invalid_type,expected:av.map,received:n.parsedType}),bO;let i=this._def.keyType,a=this._def.valueType,u=[...n.data.entries()].map(([f,d],c)=>({key:i._parse(new Nxe(n,f,n.path,[c,"key"])),value:a._parse(new Nxe(n,d,n.path,[c,"value"]))}));if(n.common.async){let f=new Map;return Promise.resolve().then(async()=>{for(let d of u){let c=await d.key,o=await d.value;if(c.status==="aborted"||o.status==="aborted")return bO;(c.status==="dirty"||o.status==="dirty")&&r.dirty(),f.set(c.value,o.value)}return{status:r.value,value:f}})}else{let f=new Map;for(let d of u){let c=d.key,o=d.value;if(c.status==="aborted"||o.status==="aborted")return bO;(c.status==="dirty"||o.status==="dirty")&&r.dirty(),f.set(c.value,o.value)}return{status:r.value,value:f}}}};cNn.create=(e,t,r)=>new cNn({valueType:t,keyType:e,typeName:Gm.ZodMap,...Nw(r)});var lNn=class e extends Fw{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==av.set)return qy(n,{code:W_.invalid_type,expected:av.set,received:n.parsedType}),bO;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(qy(n,{code:W_.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(qy(n,{code:W_.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let a=this._def.valueType;function u(d){let c=new Set;for(let o of d){if(o.status==="aborted")return bO;o.status==="dirty"&&r.dirty(),c.add(o.value)}return{status:r.value,value:c}}let f=[...n.data.values()].map((d,c)=>a._parse(new Nxe(n,d,n.path,c)));return n.common.async?Promise.all(f).then(d=>u(d)):u(f)}min(t,r){return new e({...this._def,minSize:{value:t,message:Yb.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:Yb.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};lNn.create=(e,t)=>new lNn({valueType:e,minSize:null,maxSize:null,typeName:Gm.ZodSet,...Nw(t)});var Hwa=class e extends Fw{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==av.function)return qy(r,{code:W_.invalid_type,expected:av.function,received:r.parsedType}),bO;function n(f,d){return Lwa({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Rwa(),oNn].filter(c=>!!c),issueData:{code:W_.invalid_arguments,argumentsError:d}})}function i(f,d){return Lwa({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Rwa(),oNn].filter(c=>!!c),issueData:{code:W_.invalid_return_type,returnTypeError:d}})}let a={errorMap:r.common.contextualErrorMap},u=r.data;if(this._def.returns instanceof Z3r){let f=this;return VX(async function(...d){let c=new Iwe([]),o=await f._def.args.parseAsync(d,a).catch(O=>{throw c.addIssue(n(d,O)),c}),l=await Reflect.apply(u,this,o);return await f._def.returns._def.type.parseAsync(l,a).catch(O=>{throw c.addIssue(i(l,O)),c})})}else{let f=this;return VX(function(...d){let c=f._def.args.safeParse(d,a);if(!c.success)throw new Iwe([n(d,c.error)]);let o=Reflect.apply(u,this,c.data),l=f._def.returns.safeParse(o,a);if(!l.success)throw new Iwe([i(o,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:N8t.create(t).rest(MSr.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||N8t.create([]).rest(MSr.create()),returns:r||MSr.create(),typeName:Gm.ZodFunction,...Nw(n)})}},ctn=class extends Fw{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};ctn.create=(e,t)=>new ctn({getter:e,typeName:Gm.ZodLazy,...Nw(t)});var ltn=class extends Fw{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return qy(r,{received:r.data,code:W_.invalid_literal,expected:this._def.value}),bO}return{status:"valid",value:t.data}}get value(){return this._def.value}};ltn.create=(e,t)=>new ltn({value:e,typeName:Gm.ZodLiteral,...Nw(t)});function V6f(e,t){return new ftn({values:e,typeName:Gm.ZodEnum,...Nw(t)})}var ftn=class e extends Fw{constructor(){super(...arguments),Gvi.set(this,void 0)}_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return qy(r,{expected:MM.joinValues(n),received:r.parsedType,code:W_.invalid_type}),bO}if(Uwa(this,Gvi,"f")||F6f(this,Gvi,new Set(this._def.values),"f"),!Uwa(this,Gvi,"f").has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return qy(r,{received:r.data,code:W_.invalid_enum_value,options:n}),bO}return VX(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};Gvi=new WeakMap;ftn.create=V6f;var dtn=class extends Fw{constructor(){super(...arguments),$vi.set(this,void 0)}_parse(t){let r=MM.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==av.string&&n.parsedType!==av.number){let i=MM.objectValues(r);return qy(n,{expected:MM.joinValues(i),received:n.parsedType,code:W_.invalid_type}),bO}if(Uwa(this,$vi,"f")||F6f(this,$vi,new Set(MM.getValidEnumValues(this._def.values)),"f"),!Uwa(this,$vi,"f").has(t.data)){let i=MM.objectValues(r);return qy(n,{received:n.data,code:W_.invalid_enum_value,options:i}),bO}return VX(t.data)}get enum(){return this._def.values}};$vi=new WeakMap;dtn.create=(e,t)=>new dtn({values:e,typeName:Gm.ZodNativeEnum,...Nw(t)});var Z3r=class extends Fw{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==av.promise&&r.common.async===!1)return qy(r,{code:W_.invalid_type,expected:av.promise,received:r.parsedType}),bO;let n=r.parsedType===av.promise?r.data:Promise.resolve(r.data);return VX(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Z3r.create=(e,t)=>new Z3r({type:e,typeName:Gm.ZodPromise,...Nw(t)});var zwe=class extends Fw{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Gm.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:u=>{qy(n,u),u.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){let u=i.transform(n.data,a);if(n.common.async)return Promise.resolve(u).then(async f=>{if(r.value==="aborted")return bO;let d=await this._def.schema._parseAsync({data:f,path:n.path,parent:n});return d.status==="aborted"?bO:d.status==="dirty"||r.value==="dirty"?aNn(d.value):d});{if(r.value==="aborted")return bO;let f=this._def.schema._parseSync({data:u,path:n.path,parent:n});return f.status==="aborted"?bO:f.status==="dirty"||r.value==="dirty"?aNn(f.value):f}}if(i.type==="refinement"){let u=f=>{let d=i.refinement(f,a);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(n.common.async===!1){let f=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return f.status==="aborted"?bO:(f.status==="dirty"&&r.dirty(),u(f.value),{status:r.value,value:f.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(f=>f.status==="aborted"?bO:(f.status==="dirty"&&r.dirty(),u(f.value).then(()=>({status:r.value,value:f.value}))))}if(i.type==="transform")if(n.common.async===!1){let u=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Kvi(u))return u;let f=i.transform(u.value,a);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:f}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>Kvi(u)?Promise.resolve(i.transform(u.value,a)).then(f=>({status:r.value,value:f})):u);MM.assertNever(i)}};zwe.create=(e,t,r)=>new zwe({schema:e,typeName:Gm.ZodEffects,effect:t,...Nw(r)});zwe.createWithPreprocess=(e,t,r)=>new zwe({schema:t,effect:{type:"preprocess",transform:e},typeName:Gm.ZodEffects,...Nw(r)});var zxe=class extends Fw{_parse(t){return this._getType(t)===av.undefined?VX(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};zxe.create=(e,t)=>new zxe({innerType:e,typeName:Gm.ZodOptional,...Nw(t)});var F8t=class extends Fw{_parse(t){return this._getType(t)===av.null?VX(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};F8t.create=(e,t)=>new F8t({innerType:e,typeName:Gm.ZodNullable,...Nw(t)});var ptn=class extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===av.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ptn.create=(e,t)=>new ptn({innerType:e,typeName:Gm.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Nw(t)});var _tn=class extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Yvi(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Iwe(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Iwe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};_tn.create=(e,t)=>new _tn({innerType:e,typeName:Gm.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Nw(t)});var fNn=class extends Fw{_parse(t){if(this._getType(t)!==av.nan){let n=this._getOrReturnCtx(t);return qy(n,{code:W_.invalid_type,expected:av.nan,received:n.parsedType}),bO}return{status:"valid",value:t.data}}};fNn.create=e=>new fNn({typeName:Gm.ZodNaN,...Nw(e)});var xiw=Symbol("zod_brand"),Xvi=class extends Fw{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Zvi=class e extends Fw{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?bO:a.status==="dirty"?(r.dirty(),aNn(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?bO:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:Gm.ZodPipeline})}},htn=class extends Fw{_parse(t){let r=this._def.innerType._parse(t),n=i=>(Kvi(i)&&(i.value=Object.freeze(i.value)),i);return Yvi(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};htn.create=(e,t)=>new htn({innerType:e,typeName:Gm.ZodReadonly,...Nw(t)});function W6f(e,t={},r){return e?X3r.create().superRefine((n,i)=>{var a,u;if(!e(n)){let f=typeof t=="function"?t(n):typeof t=="string"?{message:t}:t,d=(u=(a=f.fatal)!==null&&a!==void 0?a:r)!==null&&u!==void 0?u:!0,c=typeof f=="string"?{message:f}:f;i.addIssue({code:"custom",...c,fatal:d})}}):X3r.create()}var qiw={object:zne.lazycreate},Gm;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Gm||(Gm={}));var Ciw=(e,t={message:`Input not instance of ${e.name}`})=>W6f(r=>r instanceof e,t),H6f=Y3r.create,J6f=ttn.create,Biw=fNn.create,Iiw=rtn.create,Q6f=ntn.create,ziw=itn.create,Niw=uNn.create,Fiw=atn.create,Riw=otn.create,Liw=X3r.create,Uiw=MSr.create,Viw=M2t.create,Wiw=sNn.create,Hiw=TSr.create,Jiw=zne.create,Qiw=zne.strictCreate,Giw=utn.create,$iw=Vwa.create,Kiw=stn.create,Yiw=N8t.create,Xiw=Wwa.create,Ziw=cNn.create,kiw=lNn.create,eaw=Hwa.create,taw=ctn.create,raw=ltn.create,naw=ftn.create,iaw=dtn.create,aaw=Z3r.create,z6f=zwe.create,oaw=zxe.create,uaw=F8t.create,saw=zwe.createWithPreprocess,caw=Zvi.create,law=()=>H6f().optional(),faw=()=>J6f().optional(),daw=()=>Q6f().optional(),paw={string:e=>Y3r.create({...e,coerce:!0}),number:e=>ttn.create({...e,coerce:!0}),boolean:e=>ntn.create({...e,coerce:!0}),bigint:e=>rtn.create({...e,coerce:!0}),date:e=>itn.create({...e,coerce:!0})},_aw=bO,Nwe=Object.freeze({__proto__:null,defaultErrorMap:oNn,setErrorMap:_iw,getErrorMap:Rwa,makeIssue:Lwa,EMPTY_PATH:hiw,addIssueToContext:qy,ParseStatus:hG,INVALID:bO,DIRTY:aNn,OK:VX,isAborted:Sju,isDirty:Eju,isValid:Kvi,isAsync:Yvi,get util(){return MM},get objectUtil(){return Dju},ZodParsedType:av,getParsedType:K3r,ZodType:Fw,datetimeRegex:U6f,ZodString:Y3r,ZodNumber:ttn,ZodBigInt:rtn,ZodBoolean:ntn,ZodDate:itn,ZodSymbol:uNn,ZodUndefined:atn,ZodNull:otn,ZodAny:X3r,ZodUnknown:MSr,ZodNever:M2t,ZodVoid:sNn,ZodArray:TSr,ZodObject:zne,ZodUnion:utn,ZodDiscriminatedUnion:Vwa,ZodIntersection:stn,ZodTuple:N8t,ZodRecord:Wwa,ZodMap:cNn,ZodSet:lNn,ZodFunction:Hwa,ZodLazy:ctn,ZodLiteral:ltn,ZodEnum:ftn,ZodNativeEnum:dtn,ZodPromise:Z3r,ZodEffects:zwe,ZodTransformer:zwe,ZodOptional:zxe,ZodNullable:F8t,ZodDefault:ptn,ZodCatch:_tn,ZodNaN:fNn,BRAND:xiw,ZodBranded:Xvi,ZodPipeline:Zvi,ZodReadonly:htn,custom:W6f,Schema:Fw,ZodSchema:Fw,late:qiw,get ZodFirstPartyTypeKind(){return Gm},coerce:paw,any:Liw,array:Hiw,bigint:Iiw,boolean:Q6f,date:ziw,discriminatedUnion:$iw,effect:z6f,enum:naw,function:eaw,instanceof:Ciw,intersection:Kiw,lazy:taw,literal:raw,map:Ziw,nan:Biw,nativeEnum:iaw,never:Viw,null:Riw,nullable:uaw,number:J6f,object:Jiw,oboolean:daw,onumber:faw,optional:oaw,ostring:law,pipeline:caw,preprocess:saw,promise:aaw,record:Xiw,set:kiw,strictObject:Qiw,string:H6f,symbol:Niw,transformer:z6f,tuple:Yiw,undefined:Fiw,union:Giw,unknown:Uiw,void:Wiw,NEVER:_aw,ZodIssueCode:W_,quotelessJson:piw,ZodError:Iwe});var haw=Nwe.object({lang:Nwe.string(),label:Nwe.optional(Nwe.string()),source:Nwe.string()}),Mju=Nwe.array(haw);var G6f={README_EXT:"x-readme"};function yaw(e){if(!Array.isArray(e))return!1;for(let t of e)if(!bD(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function $6f(e){let t=B_(e,G6f.README_EXT);if(!bD(t))return[];let r=t["code-samples"];if(!yaw(r))return[];let n=[];for(let i of r)n.push({name:i.name,language:i.language,code:i.code,install:i.install,docs:void 0});return n}function K6f(e,t,r){let i=(B_(t,wh.EXAMPLES)??[]).filter(c=>{let o=UQ.serialization.ExampleEndpointCallSchema.parse(c);return o.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),o.ok}),a=Uhi(t,Ewe.REDOCLY_CODE_SAMPLES_KEBAB,Mju,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],f=[...Uhi(t,Ewe.REDOCLY_CODE_SAMPLES_CAMEL,Mju,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];f.length>0&&i.push({"code-samples":f.map(c=>({name:c.label??c.lang,language:c.lang,code:c.source,install:void 0,docs:void 0}))});let d=$6f(t);return d.length>0&&i.push({"code-samples":d}),i.map(h2t.unknown)}function Y6f(e){let t=B_(e,wh.AVAILABILITY);if(t==="ga"||t==="generally-available")return _W.GenerallyAvailable;if(t==="beta"||t==="pre-release")return _W.Beta;if(t==="deprecated")return _W.Deprecated;if(e.deprecated)return _W.Deprecated}function Jwa(e){return{url:vaw({url:e.url,variables:e.variables??{}}),description:e.description,name:baw(e),audiences:B_(e,wh.AUDIENCES)}}function vaw({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([n,i])=>[n,i.default]));for(let[n,i]of Object.entries(r))e=e.replace(`{${n}}`,i);return e}function baw(e){let t=B_(e,[wh.SERVER_NAME_V1,wh.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function X6f(e){return B_(e,wh.PARAMETER_NAME)}function Z6f(e){return B_(e,wh.SDK_VARIABLE)}function Qwa({path:e,httpMethod:t,parameters:r,context:n,requestBreadcrumbs:i,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let f of r){let d=B_(f,wh.IGNORE);if(d!=null&&d){n.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let c=Kh(f)?n.resolveParameterReference(f):f,o=c.required??!1,l=jxe(c),m=[...i,c.name],O=b8(m),j=c.schema!=null?aP(c.schema,!o,n,m,a,n.namespace,!1,new Set,fSr({schema:c,logger:n.logger})):o?Op.primitive({nameOverride:void 0,generatedName:O,title:void 0,schema:ty.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:fSr({schema:c,logger:n.logger})}),description:void 0,availability:l,groupName:void 0}):Op.optional({nameOverride:void 0,generatedName:O,title:void 0,value:Op.primitive({nameOverride:void 0,generatedName:O,title:void 0,schema:ty.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:fSr({schema:c,logger:n.logger})}),description:void 0,availability:void 0,groupName:void 0}),description:void 0,availability:l,groupName:void 0});if(c.in==="header"&&c.schema!=null&&!Kh(c.schema)&&c.schema.default!=null){let T=c.schema.default;typeof T=="string"&&T.length>0&&(j=Op.literal({nameOverride:void 0,generatedName:O,title:void 0,value:_I.string(T),description:void 0,availability:l,groupName:void 0}))}let A={name:c.name,schema:j,description:c.description,parameterNameOverride:X6f(c),availability:l,source:a};c.in==="query"?u.queryParameters.push(A):c.in==="path"?u.pathParameters.push({...A,variableReference:Z6f(c)}):c.in==="header"?!gaw.has(c.name.toLowerCase())&&!n.authHeaders.has(c.name)?u.headers.push({...A,env:void 0}):n.logger.debug(`Ignoring ${c.name} header, in ${t.toUpperCase()} ${e}`):n.logger.warn(`Skipping ${c.in} parameter, ${c.name}, in ${t.toUpperCase()} ${e}`)}return u}var gaw=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function k6f(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let n=e[r];if(n==null)continue;let i=n.schema;return{contentType:r,schema:i??{},examples:kvi(n,t)}}}function dNn(e,t){for(let r of Object.keys(e))if(r.includes("json")||r==="*/*"){let n=e[r];if(n==null)continue;let i=n.schema;return{contentType:r.includes("*")?void 0:r,schema:i??{},examples:kvi(n,t)}}}function e3f(e,t){for(let r of Object.keys(e)){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:kvi(n,t)}}}function kvi(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let n=B_(e,Ewe.EXAMPLES);return n!=null&&Object.keys(n).length>0&&r.push(...Object.entries(n).map(([i,a])=>({name:a.summary??i,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([i,a])=>{let u=Kh(a)?t.resolveExampleReference(a):a;return{name:u.summary??i,value:u.value,description:u.description}})),r}function maw(e,t){for(let[r,n]of Object.entries(e.content))if(eI.parse(r)?.isURLEncoded())return{schema:n.schema,contentType:r,examples:kvi(n,t)}}function Oaw(e){for(let[t,r]of Object.entries(e.content))if(eI.parse(t)?.isMultipart())return{schema:r.schema,encoding:r.encoding}}function Paw(e){for(let t in e.content)if(eI.parse(t)?.isOctetStream())return!0;return!1}function jaw(e,t){let r=Kh(e)?Tju(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([n,i])=>!Kh(i)&&i.type==="string"&&i.format==="binary")!=null}function pNn({requestBody:e,document:t,context:r,requestBreadcrumbs:n,source:i,namespace:a}){let u=Kh(e)?r.resolveRequestBodyReference(e):e,f=Oaw(u),d=f?.schema,c=f?.encoding,o=maw(u,r),l=dNn(u.content,r);if(o!=null&&o.schema!=null){let O=aP(o.schema,!1,r,n,i,a);return Swe.json({schema:O,description:u.description,contentType:o.contentType,source:i,fullExamples:o.examples,additionalProperties:!1})}if(Paw(u))return Swe.octetStream({description:u.description,source:i});if(d!=null&&l==null||d!=null&&jaw(d,t)){let O=Kh(d)?Tju(d,t):{id:void 0,schema:d},j=aP(O.schema,!1,r,n,i,a),A=[];if(j.type==="object")for(let T of j.properties){if(T.schema.type==="primitive"&&T.schema.schema.type==="string"&&T.schema.schema.format==="binary"){A.push({key:T.key,schema:Pxe.file({isOptional:!1,isArray:!1}),description:T.schema.description,contentType:c?.[T.key]?.contentType});continue}if(T.schema.type==="optional"&&T.schema.value.type==="primitive"&&T.schema.value.schema.type==="string"&&T.schema.value.schema.format==="binary"){A.push({key:T.key,schema:Pxe.file({isOptional:!0,isArray:!1}),description:T.schema.description,contentType:c?.[T.key]?.contentType});continue}if(T.schema.type==="array"&&T.schema.value.type==="primitive"&&T.schema.value.schema.type==="string"&&T.schema.value.schema.format==="binary"){A.push({key:T.key,schema:Pxe.file({isOptional:!1,isArray:!0}),description:T.schema.description,contentType:c?.[T.key]?.contentType});continue}if(T.schema.type==="optional"&&T.schema.value.type==="array"&&T.schema.value.value.type==="primitive"&&T.schema.value.value.schema.type==="string"&&T.schema.value.value.schema.format==="binary"){A.push({key:T.key,schema:Pxe.file({isOptional:!0,isArray:!0}),description:T.schema.description,contentType:c?.[T.key]?.contentType});continue}A.push({key:T.key,schema:Pxe.json(T.schema),description:void 0,contentType:c?.[T.key]?.contentType})}return Swe.multipart({name:Kh(d)&&r.getNumberOfOccurrencesForRef(d)===1?O.id:void 0,description:O.schema.description,properties:A,source:i})}if(l==null)return;let m=aP(l.schema,!1,r,n,i,a,!0);return Swe.json({description:void 0,schema:m,contentType:l.contentType,fullExamples:l.examples,additionalProperties:!Kh(l.schema)&&I7n(l.schema.additionalProperties),source:i})}function Tju(e,t){if(!e.$ref.startsWith(cen))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=n3r(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let n=t.components?.schemas?.[r];if(n==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return Kh(n)?Tju(n,t):{id:r,schema:n}}var xju={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"},t3f=new Set(Object.values(xju));var waw=["200","201","202","204"];function n3f({operationContext:e,responses:t,context:r,responseBreadcrumbs:n,responseStatusCode:i,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let f=Daw({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,c;for(let o of i!=null?[i]:waw){let l=t[o];l!=null&&(d=!0,c==null&&(c=r3f({operationContext:e,response:l,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})))}if(c==null&&!d&&t.default!=null&&(c=r3f({operationContext:e,response:t.default,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})),c!=null)switch(c.type){case"json":return{value:c,errors:f};case"streamingJson":case"streamingSse":return{value:c,errors:f};case"file":case"text":case"streamingText":return{value:c,errors:f};default:sc(c)}return{value:void 0,errors:f}}function r3f({operationContext:e,streamFormat:t,response:r,context:n,responseBreadcrumbs:i,source:a,namespace:u}){let f=Kh(r)?n.resolveResponseReference(r):r;if(f.content!=null&&Object.entries(f.content).find(([l,m])=>{if(m.schema==null)return!1;let O=Kh(m.schema)?n.resolveSchemaReference(m.schema):m.schema;return O.type==="string"&&O.format==="binary"}))return hI.file({description:f.description,source:a});let d=k6f(f.content??{},n);if(d!=null&&t!=null)switch(t){case"json":return hI.streamingJson({description:f.description,responseProperty:B_(e.operation,wh.RESPONSE_PROPERTY),fullExamples:d.examples,schema:aP(d.schema,!1,n,i,a,u),source:a});case"sse":return hI.streamingSse({description:f.description,responseProperty:void 0,schema:mx(aP(d.schema,!1,n,i,a,u)),source:a})}let c=dNn(f.content??{},n);if(c!=null){if(t!=null)switch(t){case"json":return hI.streamingJson({description:f.description,responseProperty:void 0,fullExamples:c.examples,schema:aP(c.schema,!1,n,i,a,u),source:a});case"sse":return hI.streamingSse({description:f.description,responseProperty:void 0,schema:mx(aP(c.schema,!1,n,i,a,u)),source:a})}return hI.json({description:f.description,schema:aP(c.schema,!1,n,i,a,u),responseProperty:B_(e.operation,wh.RESPONSE_PROPERTY),fullExamples:c.examples,source:a})}for(let[o,l]of Object.entries(f.content??{})){let m=eI.parse(o);if(m!=null){if(m.isOctetStream()||m.isPDF()||m.isAudio()||m.isImage()||m.isVideo())return hI.file({description:f.description,source:a});if(m.isPlainText()){let O=l.schema;if(O==null)return hI.text({description:f.description,source:a});let j=Kh(O)?n.resolveSchemaReference(O):O;return j.type==="string"&&j.format==="byte"?hI.file({description:f.description,source:a}):hI.text({description:f.description,source:a})}}}}function Daw({responses:e,context:t,source:r,namespace:n}){let i={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let f=parseInt(a);if(f<400||f>600)continue;let d=Kh(u)?t.resolveResponseReference(u):u,c=e3f(d.content??{},t),o=xju[f];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}i[f]={statusCode:f,nameOverride:void 0,generatedName:o,description:d.description,schema:aP(c?.schema??{},!1,t,[o,"Body"],r,n),fullExamples:c?.examples,source:r}}return i}function xSr({operationContext:e,context:t,responseStatusCode:r,suffix:n,streamFormat:i,source:a}){let{document:u,operation:f,path:d,method:c,baseBreadcrumbs:o,sdkMethodName:l}=e,m=B_(f,wh.IDEMPOTENT),O=B_(f,[wh.REQUEST_NAME_V1,wh.REQUEST_NAME_V2]),j=[...o,"Request"],A=Qwa({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:j,path:d,httpMethod:c,source:a}),T=f.requestBody!=null?pNn({requestBody:f.requestBody,document:u,context:new nNn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:j,source:a,namespace:t.namespace}):void 0;(A.queryParameters.length>0||A.headers.length>0)&&T!=null&&T.type==="json"&&T.schema.type!=="object"&&f.requestBody!=null?T=pNn({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j,"Body"],source:a,namespace:t.namespace}):f.requestBody!=null&&(T=pNn({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j],source:a,namespace:t.namespace}));let B=[...o,"Response"],F=n3f({operationContext:e,streamFormat:i,responses:f.responses,context:t,responseBreadcrumbs:B,responseStatusCode:r,source:a}),C=Y6f(f),N=K6f(e,f,t),U=B_(f,wh.SERVER_NAME_V2);return{summary:f.summary,internal:B_(f,Ewe.INTERNAL),idempotent:m,audiences:B_(f,wh.AUDIENCES)??[],operationId:f.operationId!=null&&n!=null?f.operationId+"_"+n:f.operationId,tags:t.resolveTagsToTagIds(f.tags),namespace:t.namespace,sdkName:l,pathParameters:A.pathParameters,queryParameters:A.queryParameters,headers:A.headers,requestNameOverride:O??void 0,generatedRequestName:b8(j),request:T,response:F.value,errors:F.errors,server:U!=null?[{name:U,url:void 0,audiences:void 0}]:(f.servers??[]).map(ne=>Jwa(ne)),description:f.description,authed:Saw(f,u),availability:C,method:c,path:d,examples:N,pagination:e.pagination,source:a}}function Saw(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function a3f({operationContext:e,context:t,asyncExtension:r,source:n}){let{operation:i,pathItemParameters:a,operationParameters:u}=e,f=r.discriminant.name,d=r.discriminant.value,c=r["response-status-code"],o=i3f({context:t,headerToIgnore:f,parameters:a}),l=i3f({context:t,headerToIgnore:f,parameters:u}),m=xSr({operationContext:{...e,pathItemParameters:o,operationParameters:l,operation:{...i,responses:Object.fromEntries(Object.entries(i.responses).filter(([j])=>parseInt(j)!==c))}},context:t,streamFormat:void 0,source:n}),O=xSr({operationContext:{...e,pathItemParameters:o,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:c,streamFormat:void 0,source:n});return O.headers.push({name:f,schema:Op.literal({nameOverride:void 0,generatedName:b8([f]),title:void 0,description:void 0,availability:void 0,value:_I.string(d),groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:n}),{sync:m,async:O}}function i3f({context:e,headerToIgnore:t,parameters:r}){return r.filter(n=>{let i=Kh(n)?e.resolveParameterReference(n):n;return!(i.in==="header"&&i.name===t)})}var qju="stream";function c3f({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:xSr({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let n=o3f({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(n?.schemaReference!=null){let c=n3r(n.schemaReference);c!=null&&t.excludeSchema(c)}let i=u3f({operation:e.operation,response:r.responseStream}),a=xSr({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+qju}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:n?.requestBody,responses:i},baseBreadcrumbs:[...e.baseBreadcrumbs,qju]},context:t,streamFormat:r.format,suffix:qju,source:t.source});a.examples=a.examples.filter(c=>s3f(c,t)!==!1);let u=o3f({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),f=u3f({operation:e.operation,response:r.response}),d=xSr({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:f}},context:t,source:t.source});return d.examples=d.examples.filter(c=>s3f(c,t)!==!0),{streaming:a,nonStreaming:d}}default:sc(r)}}function o3f({context:e,operation:t,streamingExtension:r,isStreaming:n}){if(t.requestBody==null)return;let i=Kh(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=dNn(i.content,e);if(a==null)return;let u=Kh(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let f=u.properties?.[r.streamConditionProperty];f!=null&&Kh(f)&&(f=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":n,...f??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[eI.APPLICATION_JSON]:{schema:d}}},schemaReference:Kh(a.schema)?a.schema:void 0}}function u3f({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[eI.APPLICATION_JSON]:{schema:t}}}}}function s3f(e,t){return e._visit({unknown:r=>{let n=UQ.serialization.ExampleEndpointCallSchema.parse(r);if(n.ok&&n.value.response!=null)return n.value.response.stream!=null},full:()=>{},_other:()=>{}})}function l3f({context:e,operationContext:t,source:r}){let{document:n,operation:i,path:a,method:u,baseBreadcrumbs:f,sdkMethodName:d}=t,c=[...f,"Payload"],o=Qwa({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:c,path:a,httpMethod:u,source:r});if(i.requestBody==null){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Missing a request body`);return}if(u!=="POST"&&u!=="GET"){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Not POST or GET`);return}let l=pNn({requestBody:i.requestBody,document:n,context:e,requestBreadcrumbs:[...f,"Payload"],source:r,namespace:e.namespace});if(l==null||l.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(i.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:i.summary,sdkName:d,namespace:e.namespace,method:u,operationId:i.operationId,tags:e.resolveTagsToTagIds(i.tags),headers:o.headers,generatedPayloadName:b8(c),payload:l.schema,description:i.description,examples:Eaw(l.fullExamples),source:r}}function Eaw(e){if(e==null)return[];let t=[];for(let r of e){let n=i3r(r.value);n!=null&&t.push({description:r.description,name:r.name,payload:n})}return t}function Cju({context:e,pathItemContext:t,operation:r,convertToWebhook:n}){let i=B_(r,wh.IGNORE);if(i!=null&&i){e.logger.info(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=Aaw(r,e),u=M6f(e.document,r),f={...t,sdkMethodName:a,baseBreadcrumbs:Maw({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path}),operation:r,operationParameters:r.parameters??[],pagination:u};if(n){let l=l3f({context:e,operationContext:f,source:e.source});return l!=null?{type:"webhook",value:l}:void 0}let d=E6f(r);if(d!=null){let l=c3f({context:e,operationContext:f,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let c=D6f(r);if(c!=null){let l=a3f({context:e,operationContext:f,asyncExtension:c,source:e.source});return{type:"async",async:l.async,sync:l.sync}}return{type:"http",value:xSr({context:e,operationContext:f,streamFormat:void 0,source:e.source})}}function Aaw(e,t){let r=B_(e,wh.SDK_METHOD_NAME),n=B_(e,wh.SDK_GROUP_NAME)??[];if(r!=null){let i=typeof n=="string"?[n]:n;return i=t.resolveGroupName(i),{groupName:i,methodName:r}}}function Maw({sdkMethodName:e,operation:t,httpMethod:r,path:n}){let i=[];if(e!=null){if(e.groupName.length>0){let a=e.groupName[e.groupName.length-1];a!=null&&i.push(typeof a=="string"?a:a.name)}i.push(e.methodName)}else t.operationId!=null?i.push(t.operationId):i.push(mE(`${r}_${n.split("/").join("_")}`));return i}function f3f(e,t,r,n){let i=[],a=p3f(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=Taw({operation:f.operation}),c=Cju({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:d});c!=null&&i.push(c)}return i}function d3f(e,t,r,n){let i=[],a=p3f(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=Cju({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:!0});d!=null&&i.push(d)}return i}function p3f(e){let t=[];return e.get!=null&&t.push({method:nG.Get,operation:e.get}),e.post!=null&&t.push({method:nG.Post,operation:e.post}),e.put!=null&&t.push({method:nG.Put,operation:e.put}),e.delete!=null&&t.push({method:nG.Delete,operation:e.delete}),e.patch!=null&&t.push({method:nG.Patch,operation:e.patch}),t}function Taw({operation:e}){return B_(e,[wh.WEBHOOK])??!1}function _3f(e){let t=B_(e,wh.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=B_(e,wh.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function h3f(e){return B_(e,wh.FERN_BASIC_AUTH)}function Bju(e,t){if(Kh(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return xaw(e,t)}function xaw(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=B_(e,Ewe.BEARER_FORMAT),n=B_(e,wh.FERN_HEADER_AUTH);return Y9.header({headerName:e.name,prefix:r!=null?"Bearer":n?.prefix,headerVariableName:n?.name??B_(e,wh.HEADER_VARIABLE_NAME),headerEnvVar:n?.env})}else if(e.type==="http"&&e.scheme==="bearer"){let r=B_(e,wh.FERN_BEARER_TOKEN);return Y9.bearer({tokenVariableName:r?.name??B_(e,wh.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme==="basic"){let r=h3f(e),n=_3f(e);return Y9.basic({usernameVariableName:r?.username?.name??n.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??n.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return Y9.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return Y9.oauth({scopesEnum:qaw(e,t)})}throw new Error(`Failed to convert security scheme ${JSON.stringify(e)}`)}function qaw(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let n=r3r({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,groupName:void 0,context:void 0,source:t}),i=mx(n);if(i.type==="enum")return i}}function y3f(e){return B_(e,wh.BASE_PATH)}var Caw=Nwe.record(Nwe.string(),Nwe.object({summary:Nwe.string().optional(),description:Nwe.string().optional()}));function v3f({document:e,context:t}){return Uhi(e,wh.GROUPS,Caw,t.logger)}function b3f({context:e,document:t}){return B_(t,wh.FERN_VERSION)??void 0}function g3f(e){let t=B_(e,wh.FERN_GLOBAL_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?Vhi({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function m3f(e){let t=B_(e,wh.FERN_IDEMPOTENCY_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?Vhi({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function O3f(e){let t=B_(e,wh.SDK_VARIABLES);return t==null?{}:Object.fromEntries(Object.entries(t).map(([r,n])=>{if(n.type==="string")return[r,{nameOverride:void 0,generatedName:b8([r]),title:n.title,schema:q1.string({default:L7n(n),pattern:n.pattern,format:n.format,minLength:n.minLength,maxLength:n.maxLength}),description:n.description,availability:void 0,groupName:void 0}];throw new Error(`Variable ${r} has unsupported schema ${JSON.stringify(n)}`)}))}var Baw="webhooks";function P3f(e){return B_(e,Baw)??{}}var Gwa=class extends rNn{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discrminatedUnionReferences={};discrminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u})}getDummy(){return new nNn({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,n){let i=this.discrminatedUnionReferences[t.$ref];i!=null?(i.discriminants.add(r),i.numReferences+=n):this.discrminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:n}}getReferencesFromDiscriminatedUnion(t){return this.discrminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,n){let i=this.discrminatedUnionMetadata[t.$ref];i!=null?i.discriminants.set(r,n):this.discrminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,n]])}}getDiscriminatedUnionMetadata(t){return this.discrminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function j3f(e){return B_(e,wh.RESOLUTIONS)}function w3f({openapi:e}){let t=j3f(e);if(t==null)return e;let r={};for(let n of t){let i=`#/components/schemas/${n.name}`;for(let a of n.resolutions)e=Iaw({openapi:e,schemaReference:a,schemaName:n.name}),e=D3f({openapi:e,replaceReference:a,schemaReference:i,replacedReferences:r}),r={...r,...Object.fromEntries(n.resolutions.map(u=>[i,u]))}}return e}function Iaw({openapi:e,schemaReference:t,schemaName:r}){let n=t.replace("#/","").split("/").map(a=>a.replace("~1","/")),i=e;for(let a of n){let u=i[a];if(u==null)return e;i=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=i,e}function D3f({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:n}){let i=Object.keys(n).filter(d=>t.startsWith(d)).sort((d,c)=>c.length-d.length)[0];if(i!=null){let d=n[i];if(d!=null){let c=r.replace(i,d);return D3f({openapi:e,replaceReference:t,schemaReference:c,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replace("~1","/")),u=e;for(let d of a.slice(0,-1)){let c=u[d];if(c==null)return e;u=c}let f=a[a.length-1];return f==null||(u[f]={$ref:r}),e}function $wa({openApi:e,taskContext:t,options:r,source:n,namespace:i}){e=w3f({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([X,k])=>Bju(k,n)==null?[]:[X,Bju(k,n)])),u=new Set(...Object.entries(a).map(([X,k])=>k.type==="basic"||k.type==="bearer"?"Authorization":k.type==="header"?k.headerName:null)),f=new Gwa({document:e,taskContext:t,authHeaders:u,options:r,source:n,namespace:i}),d=O3f(e),c=g3f(e),o=m3f(e),l=r.audiences??[],m=[],O=[];Object.entries(e.paths??{}).forEach(([X,k])=>{if(k==null)return;t.logger.debug(`Converting path ${X}`);let xe=f3f(X,k,e,f);for(let vt of xe){let yt=S3f({operation:vt});if(!(l.length>0&&!l.some(St=>yt.includes(St))))switch(vt.type){case"async":m.push(vt.sync),m.push(vt.async);break;case"http":m.push(vt.value);break;case"streaming":m.push(vt.streaming),vt.nonStreaming&&m.push(vt.nonStreaming);break;case"webhook":O.push(vt.value);break;default:sc(vt)}}}),Object.entries(P3f(e)).forEach(([X,k])=>{if(k==null)return;t.logger.debug(`Converting path ${X}`);let xe=d3f(X,k,e,f);for(let vt of xe){let yt=S3f({operation:vt});l.length>0&&!l.some(St=>yt.includes(St))||O.push(vt.value)}});let j=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([X,k])=>{if(!Kh(k)){let xe=B_(k,wh.IGNORE);if(xe!=null&&xe)return[];if(t3f.has(X))return[X,aP({...k,"x-fern-type-name":`${X}Body`},!1,f,[X],n,i)]}return[X,aP(k,!1,f,[X],n,i)]}).filter(X=>X.length>0)),A=zaw(j,f,n),T=Naw(A,f),B={};for(let[X,k]of Object.entries(T)){let xe=mx(k);f.isSchemaExcluded(X)||(B[X]=xe,t.logger.debug(`Converted schema ${X}`))}let F=new a3r(T,f),C=O.map(X=>{let xe=X.examples;if(!r.disableExamples&&xe.length===0){let vt=F.buildExample({schema:X.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});vt!=null&&(xe=[{name:void 0,description:void 0,payload:vt}])}return{...X,payload:mx(X.payload),examples:xe}}),N=new Oma(T,f),U=m.map(X=>{let k=X.examples,xe=k;if(!r.disableExamples&&(k.length===0||k.every(Qhi))){let St=N.buildEndpointExample(X);St.length>0&&(xe=[...St,...k.filter(Ft=>!Qhi(Ft))])}let vt=X.request,yt=X.response;return{...X,request:vt?.type==="json"?{...vt,schema:mx(vt.schema)}:vt,response:yt?.type==="json"?{...yt,schema:mx(yt.schema)}:yt,queryParameters:X.queryParameters.map(St=>({description:St.description,name:St.name,schema:mx(St.schema),parameterNameOverride:St.parameterNameOverride,availability:St.availability,source:St.source})),pathParameters:X.pathParameters.map(St=>({description:St.description,name:St.name,schema:mx(St.schema),parameterNameOverride:St.parameterNameOverride,variableReference:St.variableReference,availability:St.availability,source:St.source})),headers:X.headers.map(St=>({description:St.description,name:St.name,schema:mx(St.schema),parameterNameOverride:St.parameterNameOverride,env:St.env,availability:St.availability,source:St.source})),examples:xe,errors:Vh(X.errors,St=>{let Ft=St.fullExamples?.map(Zt=>{let Vt=i3r(Zt.value);if(Vt!=null)return{name:Zt.name,description:Zt.description,example:Vt}}).filter(YA);if(Ft?.length===0){let Zt=F.buildExample({schema:St.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});Zt!=null&&Ft.push({name:void 0,description:void 0,example:Zt})}return{generatedName:St.generatedName,nameOverride:St.nameOverride,schema:mx(St.schema),description:St.description,source:St.source,examples:Ft}})}}),ne=v3f({document:e,context:f});return{apiVersion:b3f({context:f,document:e}),basePath:y3f(e),title:e.info.title,description:e.info.description,groups:Object.fromEntries(Object.entries(ne??{}).map(([X,k])=>[X,{summary:k.summary??void 0,description:k.description??void 0}])),servers:(e.servers??[]).map(X=>Jwa(X)),tags:{tagsById:Object.fromEntries((e.tags??[]).map(X=>[X.name,{id:X.name,description:X.description}])),orderedTagIds:e.tags?.map(X=>X.name)},endpoints:U,webhooks:C,channel:[],groupedSchemas:bma(i,B),securitySchemes:a,hasEndpointsMarkedInternal:U.some(X=>X.internal),nonRequestReferencedSchemas:f.getReferencedSchemas(),variables:d,globalHeaders:c,idempotencyHeaders:o}}function zaw(e,t,r){let n={};for(let[i,a]of Object.entries(e)){if(a.type!=="object"){n[i]=a;continue}let u={$ref:`#/components/schemas/${i}`},f=t.getReferencesFromDiscriminatedUnion(u);if(f==null){n[i]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!f.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!f.discriminants.has(o.propertyKey)),source:r};n[i]=d;let c=E3f({schema:a,schemas:e});for(let o of[...new Set(c)]){let l=n[o]??e[o];l==null||l.type!=="object"||(n[o]={...l,type:"object",properties:l.properties.filter(m=>!f.discriminants.has(m.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(m=>!f.discriminants.has(m.propertyKey))})}}return n}function Naw(e,t){let r={};for(let[n,i]of Object.entries(e)){if(i.type!=="object"){r[n]=i;continue}let a={$ref:`#/components/schemas/${n}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[n]=i;continue}let f=[];for(let c of i.properties)if(u.discriminants.has(c.key)){let o=u.discriminants.get(c.key);o!=null&&f.push({...c,schema:Op.literal({nameOverride:void 0,generatedName:b8([i.generatedName,o]),title:void 0,value:_I.string(o),groupName:void 0,description:void 0,availability:i.availability})})}else f.push(c);let d={...i,type:"object",properties:f};r[n]=d}return r}function E3f({schema:e,schemas:t}){let r=[];for(let n of e.allOf){r.push(n.schema);let i=t[n.schema];i!=null&&i.type==="object"&&r.push(...E3f({schema:i,schemas:t}))}return r}function S3f({operation:e}){let t=[];switch(e.type){case"async":t=e.async.audiences;break;case"http":t=e.value.audiences;break;case"streaming":t=e.streaming.audiences;break;case"webhook":break;default:sc(e)}return t}async function M3f({openApi:e,taskContext:t,options:r,source:n,namespace:i}){let a=await(0,A3f.convertObj)(e,{});return $wa({openApi:a.openapi,taskContext:t,options:r,source:n,namespace:i})}var qSr={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,cooerceEnumsToLiterals:!0,respectReadonlySchemas:!1,onlyIncludeReferencedSchemas:!1};async function ytn({absoluteFilePathToWorkspace:e,specs:t,taskContext:r,optionOverrides:n}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channel:[],groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let a of t){let u=(await(0,zju.readFile)(a.absoluteFilepath)).toString(),f=mC(e,a.source.file);a.source.relativePathToDependency!=null&&(f=Wl(a.source.relativePathToDependency,f));let d=a.source.type==="protobuf"?oSr.protobuf({file:f}):oSr.openapi({file:f});if(u.includes("openapi")||u.includes("swagger")){let c=await yIf({absolutePathToOpenAPI:a.absoluteFilepath,context:r,absolutePathToOpenAPIOverrides:a.absoluteFilepathToOverrides});if(Law(c)){let o=$wa({openApi:c,taskContext:r,options:Iju({specSettings:a.settings,overrides:n}),source:d,namespace:a.namespace});i=T3f(i,o)}else if(Uaw(c)){let o=await M3f({openApi:c,taskContext:r,options:Iju({specSettings:a.settings}),source:d,namespace:a.namespace});i=T3f(i,o)}}else if(u.includes("asyncapi")){let c=await Raw({absoluteFilePathToAsyncAPI:a.absoluteFilepath,context:r,absoluteFilePathToAsyncAPIOverrides:a.absoluteFilepathToOverrides}),o=ESf({document:c,taskContext:r,options:Iju({specSettings:a.settings}),source:d,asyncApiOptions:Faw({specSettings:a.settings}),namespace:a.namespace});o.channel!=null&&i.channel.push(o.channel),o.groupedSchemas!=null&&(i.groupedSchemas=x3f(i.groupedSchemas,o.groupedSchemas)),o.basePath!=null&&(i.basePath=o.basePath)}else r.failAndThrow(`${a.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}function Iju({specSettings:e,overrides:t}){return{disableExamples:t?.disableExamples??qSr.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.shouldUseUndiscriminatedUnionsWithLiterals??qSr.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.shouldUseTitleAsName??qSr.useTitlesAsName,audiences:t?.audiences??e?.audiences??qSr.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??qSr.optionalAdditionalProperties,cooerceEnumsToLiterals:t?.cooerceEnumsToLiterals??e?.cooerceEnumsToLiterals??qSr.cooerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??qSr.respectReadonlySchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??qSr.onlyIncludeReferencedSchemas}}function Faw({specSettings:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??ZDf.naming}}function T3f(e,t){return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channel:[...e.channel,...t.channel],groupedSchemas:x3f(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 x3f(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,n]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...n}:e.namespacedSchemas[r]=n;return e}async function Raw({absoluteFilePathToAsyncAPI:e,absoluteFilePathToAsyncAPIOverrides:t,context:r}){let n=(await(0,zju.readFile)(e)).toString(),i=await Fy.load(n);return t!=null?await xja({absoluteFilepathToOverrides:t,context:r,data:i}):i}function Law(e){return e.openapi!=null}function Uaw(e){return e.swagger!=null}function Ywa({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=Nju({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=gx(i.value);if(a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>"),e.description==null&&!i.allowMultiple&&e.parameterNameOverride==null&&e.availability==null)return a;let u={type:a};return i.allowMultiple&&(u["allow-multiple"]=!0),e.description!=null&&(u.docs=e.description),e.parameterNameOverride!=null&&(u.name=e.parameterNameOverride),e.availability!=null&&(u.availability=gz(e.availability)),Vaw(i.value)&&i.value.validation!==void 0&&(u.validation=i.value.validation),u}function Nju({schema:e,context:t,fileContainingReference:r,namespace:n}){if(e.type==="reference"){let i=t.getSchema(e.schema,n);if(i==null)return;if(i.type==="array")return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,declarationFile:ls.of(mD),fileContainingReference:r,namespace:n}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undisciminated"){let a=[];for(let[u,f]of Object.entries(i.value.schemas))f.type==="literal"&&f.value.type==="string"&&(F7n.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:Whi(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[u,f]=i.value.schemas;if(u!=null&&f!=null&&Kwa({array:u,primitive:f}))return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(u!=null&&f!=null&&Kwa({array:u,primitive:f}))return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[u,f]of Object.entries(i.value.schemas))return Nju({schema:f,context:t,fileContainingReference:r,namespace:n})}else if(t.objectQueryParameters)return{value:qO({schema:e,context:t,fileContainingReference:r,declarationFile:ls.of(mD),namespace:n}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let i=t.getSchema(e.value.schema,n);if(i==null)return;if(i.type==="array")return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,declarationFile:ls.of(mD),namespace:n}),allowMultiple:!0};if(t.objectQueryParameters)return{value:qO({schema:e,context:t,fileContainingReference:r,declarationFile:ls.of(mD),namespace:n}),allowMultiple:!1}}if(e.value.type==="array")return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undisciminated"){let i=[];for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="literal"&&u.value.type==="string"&&(F7n.test(u.value.value)?i.push(u.value.value):i.push({value:u.value.value,name:Whi(u.value.value)}));if(i.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:i}}),{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[a,u]=e.value.value.schemas;if(a!=null&&u!=null&&Kwa({array:a,primitive:u}))return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(a!=null&&u!=null&&Kwa({array:u,primitive:a}))return{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[a,u]of Object.entries(e.value.value.schemas))return Nju({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return t.objectQueryParameters?{value:qO({schema:e,context:t,fileContainingReference:r,declarationFile:ls.of(mD),namespace:n}),allowMultiple:!1}:void 0;return{value:qO({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}return e.type==="array"?{value:qO({schema:J0.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}:{value:qO({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}function Kwa({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function Vaw(e){return e.type!=null}function q3f({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"]=Waw(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=Haw({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=k3r(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function Waw(e){let t={};return e.forEach(r=>{let n=k3r(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function Haw({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=k3r(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function k3r(e){switch(e.type){case"primitive":return C3f(e.value);case"object":return B3f(e.properties);case"array":return Jaw(e.value);case"map":return Qaw(e.value);case"oneOf":return Gaw(e.value);case"enum":return e.value;case"literal":return $aw(e.value);case"unknown":return k3r(e.value);default:sc(e)}}function C3f(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:sc(e)}}function B3f(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,k3r(r)]))}function Jaw(e){return e.map(t=>k3r(t))}function Qaw(e){return Object.fromEntries(e.map(t=>[C3f(t.key),k3r(t.value)]))}function Gaw(e){return e.type==="discriminated"?B3f(e.value):k3r(e.value)}function $aw(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:sc(e)}}function CSr(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function Xwa(e,t){return t??(e?.groupName!=null?CSr(e.groupName):void 0)}function I3f({channel:e,context:t,declarationFile:r}){let n={path:e.path,auth:!1};e.summary!=null&&(n["display-name"]=e.summary);let i=CSr(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=lma({pathParameter:d,context:t,fileContainingReference:r,namespace:i});Object.keys(a).length>0&&(n["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let c=Ywa({queryParameter:d,context:t,fileContainingReference:r,namespace:i});c!=null&&(u[d.name]=c)}Object.keys(u).length>0&&(n["query-parameters"]=u);let f={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let c=b8t({header:d,context:t,fileContainingReference:r,namespace:i});f[d.name]=c}Object.keys(f).length>0&&(n.headers=f),t.builder.addChannel(r,{channel:n}),e.subscribe!=null&&t.builder.addChannelMessage(r,{messageId:"subscribe",message:{origin:"server",body:qO({schema:e.subscribe,context:t,fileContainingReference:r,namespace:i})}}),e.publish!=null&&t.builder.addChannelMessage(r,{messageId:"publish",message:{origin:"client",body:qO({schema:e.publish,context:t,fileContainingReference:r,namespace:i})}});for(let d of e.examples){let c=q3f({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:c})}}var z3f="Production",N3f="Default";function F3f(e){return Object.entries(e).reduce((t,[r,n])=>(Kqn(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function R3f(e){if(e.environmentOverrides!=null){for(let[f,d]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:f,schema:d});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 f of e.ir.servers){let d=f.audiences?{url:f.url,audiences:f.audiences}:f.url;if(f.name==null){r.push(d);continue}t[f.name]=d}let n={},i=[];for(let f of e.ir.endpoints)for(let d of f.server){if(d.url==null)continue;let c=d.audiences?{url:d.url,audiences:d.audiences}:d.url;if(d.name==null){i.push(c);continue}n[d.name]=c}let a=Object.keys(t).length,u=Object.keys(n).length;if(a===0&&u===0){let f=e.ir.servers[0]?.url,d=e.ir.servers[0]?.audiences;f!=null&&(e.builder.addEnvironment({name:N3f,schema:d?{url:f,audiences:d}:f}),e.builder.setDefaultEnvironment(N3f))}else if(a>0&&u===0){let f=0;r.length>0&&e.logger.error(`Skipping servers ${r.map(d=>typeof d=="string"?d:d.url).join(", ")} because x-fern-server-name was not provided.`);for(let[d,c]of Object.entries(t))f===0&&e.builder.setDefaultEnvironment(d),e.builder.addEnvironment({name:d,schema:c}),f+=1}else if(u>0){(r.length>0||i.length>0)&&e.logger.error(`Skipping servers ${[...r,...i].map(d=>typeof d=="string"?d:d.url).join(", ")} because x-fern-server-name was not provided.`);let f=Object.entries(t)[0];if(f!=null){let[d,c]=f;e.setDefaultServerName(d)}e.builder.addEnvironment({name:z3f,schema:{urls:{...F3f(t),...F3f(n)}}}),e.builder.setDefaultEnvironment(z3f)}}function Zwa(e){return gx(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var Fju=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},Kaw=.75,Yaw=new Set("authorization");function L3f(e){if(e.globalHeaderOverrides!=null){for(let[r,n]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:n});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,n]of Object.entries(t)){let i="optional<string>";if(n.name==null&&n.env==null&&typeof n.schema=="string")i=n.schema;else if(n!=null){let a=n.schema?C7n(n.schema):void 0,u=a!=null?CSr(a):void 0,f=ls.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?gx(qO({schema:n.schema,context:e,fileContainingReference:u?Wl(ls.of(mE(u)),f):f,namespace:u}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:i})}if(e.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let a of i.headers){if(Yaw.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let f=t[a.name],d=b8t({header:{...a,schema:f?.schema??a.schema,name:f?.name??a.name},fileContainingReference:ls.of(eF),context:e,namespace:void 0});u=new Fju(d),r[a.name]=u}u.increment()}let n=e.ir.endpoints.length*Kaw;for(let[i,a]of Object.entries(r)){let u=t[i],f=a.count===e.ir.endpoints.length,d=a.count>=n;u==null&&(f?e.builder.addGlobalHeader({name:i,schema:a.schema}):d&&e.builder.addGlobalHeader({name:i,schema:Zwa(a.schema)}))}}}function U3f(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?C7n(t.schema):void 0,n=r!=null?CSr(r):void 0,i=b8t({header:{...t,schema:t.schema??J0.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:q1.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:ls.of(eF),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:Zwa(i)})}}function WX(e){switch(e.type){case"primitive":return W3f(e.value);case"object":return H3f(e.properties);case"array":return J3f(e.value);case"map":return Xaw(e.value);case"oneOf":return Zaw(e.value);case"enum":return e.value;case"literal":return kaw(e.value);case"unknown":return WX(e.value);default:sc(e)}}function V3f(e){switch(e.type){case"withStreaming":return{stream:J3f(e.value)};case"withoutStreaming":return{body:WX(e.value)};default:sc(e)}}function W3f(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:sc(e)}}function H3f(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,WX(r)]))}function J3f(e){return e.map(t=>WX(t))}function Xaw(e){return Object.fromEntries(e.map(t=>[W3f(t.key),WX(t.value)]))}function Zaw(e){return e.type==="discriminated"?H3f(e.value):WX(e.value)}function kaw(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:sc(e)}}function Q3f({endpointExample:e,context:t}){let r={};return e.type!=="full"?e.value:(e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=eow(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=tow(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=row({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=WX(e.request)),e.response!=null&&(r.response=V3f(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(n=>n.type==="language"?{name:n.name??void 0,docs:n.description??void 0,language:n.language,code:n.code,install:n.install??void 0}:{name:n.name??void 0,docs:n.description??void 0,sdk:n.sdk,code:n.code}).filter(YA)),r)}function eow(e){let t={};return e.forEach(r=>{let n=WX(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function tow(e){let t={};return e.forEach(r=>{let n=WX(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function row({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=WX(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function G3f(e){return nG._visit(e,{get:()=>UQ.HttpMethodSchema.Get,post:()=>UQ.HttpMethodSchema.Post,put:()=>UQ.HttpMethodSchema.Put,patch:()=>UQ.HttpMethodSchema.Patch,delete:()=>UQ.HttpMethodSchema.Delete,head:()=>{throw new Error("HEAD is unsupported")},options:()=>{throw new Error("HEAD is unsupported")},trace:()=>{throw new Error("HEAD is unsupported")},_other:()=>{throw new Error("Unkown http method is unsupported")}})}function $3f({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,u=e.path,f=Xwa(e.sdkName,e.namespace),d={};for(let A of e.pathParameters)A.parameterNameOverride&&(u=u.replace(A.name,A.parameterNameOverride)),d[A.parameterNameOverride??A.name]=lma({pathParameter:A,context:r,fileContainingReference:t,namespace:f}),a.add(A.name);let c={};for(let A of e.queryParameters){let T=Ywa({queryParameter:A,context:r,fileContainingReference:t,namespace:f});T!=null&&(c[A.name]=T,a.add(A.name))}let o;e.pagination!=null&&(e.pagination.type==="cursor"?o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results}:o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage});let l={path:u,method:G3f(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?lSr(e.source):void 0};Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let m={},O=r.builder.getGlobalHeaderNames(),j=e.headers.filter(A=>!O.has(A.name));for(let A of j){let T=b8t({header:A,context:r,fileContainingReference:t,namespace:f});m[A.name]=T,a.add(typeof T=="string"?A.name:T.name??A.name)}if(e.request!=null){r.setInState(v8.Request);let A=iow({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,queryParameters:Object.keys(c).length>0?c:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(m).length>0?m:void 0,usedNames:a,namespace:f});l.request=A.value,i=[...i,...A.schemaIdsToExclude??[]],r.unsetInState(v8.Request)}else{let A=Object.keys(c).length>0,T=Object.keys(m).length>0,B={};(A||T)&&(B.name=e.requestNameOverride??e.generatedRequestName),A&&(B["query-parameters"]=c),T&&(B.headers=m),Object.keys(B).length>0&&(l.request=B)}if(e.response!=null&&e.response._visit({json:A=>{let T=qO({schema:A.schema,context:r,fileContainingReference:t,namespace:f});l.response={docs:A.description??void 0,type:gx(T)},A.responseProperty!=null&&(l.response.property=A.responseProperty)},streamingJson:A=>{let T=qO({schema:A.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:A.description??void 0,type:gx(T),format:"json"}},streamingSse:A=>{let T=qO({schema:A.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:A.description??void 0,type:gx(T),format:"sse"}},file:A=>{l.response={docs:A.description??void 0,type:"file"}},streamingText:A=>{l["response-stream"]={docs:A.description??void 0,type:"text"}},text:A=>{l.response={docs:A.description??void 0,type:"text"}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let A=r.getDefaultServerName(),T=e.server[0];T==null?A!=null&&(l.url=A):l.url=T.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=gz(e.availability)),Object.entries(e.errors).forEach(([A,T])=>{let B=T.generatedName,F=ls.of(mD);r.builder.enableUniqueErrorsPerEndpoint&&(B=`${e.generatedRequestName}${T.generatedName}`,T.schema!=null&&(T.schema.type!=="reference"&&T.schema.type!=="oneOf"?T.schema.generatedName=`${e.generatedRequestName}${T.schema.generatedName}`:T.schema.type==="oneOf"&&(T.schema.value.generatedName=`${e.generatedRequestName}${T.schema.value.generatedName}`)));let C={"status-code":parseInt(A)},N=HDf({location:K3f,namespaceOverride:f});if(T.schema!=null){let ge=qO({schema:T.schema,context:r,fileContainingReference:N,declarationFile:N,namespace:f});C.type=gx(ge),C.docs=T.description}r.builder.addError(N,{name:B,schema:r.isErrorUnknownSchema(parseInt(A))?{...C,type:"unknown"}:C}),l.errors==null&&(l.errors=[]);let U=r.builder.addImport({file:t,fileToImport:N});l.errors.push(U!=null?`${U}.${B}`:B),C.type!=null&&T.examples?.forEach(ge=>{let X={value:WX(ge.example),name:ge.name,docs:ge.description};r.builder.addErrorExample(N,{name:B,example:X})})}),e.examples.length>0&&(l.examples=now({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[Rju,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function now({endpointExamples:e,context:t}){return e.map(r=>{try{return Q3f({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function iow({endpoint:e,declarationFile:t,context:r,request:n,requestNameOverride:i,generatedRequestName:a,queryParameters:u,nonRequestReferencedSchemas:f,headers:d,usedNames:c,namespace:o}){if(n.type==="json"){let l=n.schema.type==="reference"?n.schema.schema:void 0,m=n.schema.type==="reference"?r.getSchema(n.schema.schema,o):n.schema;if(m?.type!=="object"||l!=null&&f.includes(l)){let B=qO({schema:n.schema,fileContainingReference:t,context:r,namespace:o}),F={schemaIdsToExclude:[],value:{body:B}},C=Object.keys(u??{}).length>0,N=Object.keys(d??{}).length>0;return C&&(F.value["query-parameters"]=u),N&&(F.value.headers=d),(C||N)&&(F.value.name=i??a),n.contentType!=null&&(F.value["content-type"]=n.contentType),n.description!=null&&(F.value.docs=n.description),F}let O=Object.fromEntries(m.properties.filter(B=>B.readonly==null?!0:!((e.method==="POST"||e.method==="PUT")&&B.readonly)).map(B=>{let F=qO({schema:B.schema,fileContainingReference:t,context:r,namespace:o}),C=B.nameOverride??B.key,N=gz(B.availability);if(!c.has(C)&&B.audiences.length<=0)return c.add(C),B.nameOverride!=null?[B.key,{type:gx(F),docs:Rhi(F),name:B.nameOverride,availability:N}]:[B.key,N?{...typeof F=="string"?{type:F}:F,availability:N}:F];let U={type:gx(F),docs:Rhi(F)};return c.has(C)&&(U.name=B.generatedName),B.audiences.length>0&&(U.audiences=B.audiences),N!=null&&(U.availability=N),c.add(C),[B.key,U]})),j=m.allOf.map(B=>{let F=qO({schema:J0.reference(B),fileContainingReference:t,context:r,namespace:o});return gx(F)}),A={properties:O};j.length>0&&(A.extends=j),n.additionalProperties&&(A["extra-properties"]=!0);let T={name:i??m.nameOverride??m.generatedName,"query-parameters":u,headers:d,body:A};return n.contentType!=null&&(T["content-type"]=n.contentType),n.description!=null&&(T.docs=n.description),{schemaIdsToExclude:l!=null?[l]:[],value:T}}else{if(n.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":eI.APPLICATION_OCTET_STREAM,...n.description?{docs:n.description}:{}}};if(n.type==="multipart"){let l=Object.fromEntries(n.properties.map(m=>{if(m.schema.type==="file"){let O=m.schema.isArray?"list<file>":"file";if(O=m.schema.isOptional?`optional<${O}>`:O,m.description!=null||m.contentType!=null){let j={type:O};if(m.description!=null&&(j.docs=m.description),m.contentType!=null){let A=m.contentType.split(",")[0];j["content-type"]=A}return[m.key,j]}return[m.key,O]}else{let O=qO({schema:m.schema.value,fileContainingReference:t,context:r,namespace:o});return m.contentType!=null&&(typeof O=="string"?O={type:O,"content-type":m.contentType}:O["content-type"]=m.contentType),[m.key,O]}}));return{schemaIdsToExclude:n.name==null?[]:[n.name],value:{name:i??n.name??a,"query-parameters":u,headers:d,body:{properties:l},"content-type":eI.MULTIPART_FORM_DATA,...n.description?{docs:n.description}:{}}}}else sc(n)}}function aow({location:e,namespaceOverride:t}){return t!=null?{...e,file:Wl(ls.of(t),e.file)}:e}function oow(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:ls.of(`${mE(r)}.yml`),endpointId:e.summary!=null?mE(e.summary):mE(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:ls.of(mD),endpointId:mE(e.summary)}:{file:ls.of(mD),endpointId:mE(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:ls.of(mD),endpointId:n};let i=e0i(r),a=e0i(n);if(zqt(i,a))return{file:ls.of("__package__.yml"),endpointId:r};let u=cow({operationId:n,tag:r,path:e.path,method:e.method});if(u!=null)return u;let f=[];for(let d=0;d<i.length;++d){let c=i[d];if(c!=null&&c===a[d])f.push(c);else{let o=mE(r);return{file:ls.of(`${o}.yml`),endpointId:n,tag:r}}}if(f.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:ls.of(mE(f.join("_"))+".yml"),endpointId:mE(a.slice(f.length).join("_")),tag:r}}function t0i(e){let t=e.tags[0];if(e.sdkName!=null){let r=Iyu({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:ls.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return aow({namespaceOverride:e.namespace,location:oow(e)})}function e0i(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=m6t(t),t}var uow=new RegExp("[^a-zA-Z0-9{}]+"),sow=new RegExp("[{}]","g");function cow({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(uow).join("_").replaceAll(sow,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:ls.of(mE(t)+".yml"),endpointId:mE(e.slice(0,-1*a.length)),tag:t}}function Y3f(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:u,file:f,tag:d}=t0i(a),c=f.split(".")[0];c!=null&&t.add(c);let o;if(a.sdkName!=null){let O=e.ir.groups;for(let j of a.sdkName.groupName){let A=typeof j=="string"?j:j.name,T=O[A];if(T==null)break;if(T.summary!=null||T.description!=null){o=O[A];break}}}let l=d==null?void 0:n.tagsById[d];e.setInState(v8.Endpoint),e.setEndpointMethod(a.method);let m=$3f({context:e,endpoint:a,declarationFile:f});e.unsetEndpointMethod(),e.unsetInState(v8.Endpoint),i=[...i,...m.schemaIdsToExclude],e.builder.addEndpoint(f,{name:u,schema:m.value,source:a.source!=null?lSr(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(f,{"display-name":o?.summary??l?.id,docs:o?.description??l?.description??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}function X3f(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?CSr(r.groupName):void 0,i=qO({schema:J0.primitive(r),context:e,fileContainingReference:ls.of(mD),namespace:n});e.builder.addVariable({name:t,schema:{type:gx(i),docs:r.description??void 0}})}}function Z3f(e){for(let t of e.ir.webhooks){let r=dow({webhook:t,context:e});if(r==null)continue;let n=Xwa(t.sdkName,t.namespace),i={};for(let u of t.headers)i[u.name]=b8t({header:u,context:e,fileContainingReference:r.file,namespace:n});let a={method:t.method,"display-name":t.summary??void 0,headers:i,payload:qO({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:WX(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function low({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:Wl(ls.of(t),e.file)}:e}function fow({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:ls.of(mD),endpointId:n};let i=e0i(r),a=e0i(n);if(zqt(i,a))return{file:ls.of("__package__.yml"),endpointId:r};let u=[];for(let f=0;f<i.length;++f){let d=i[f];if(d!=null&&d===a[f])u.push(d);else{let c=mE(r);return{file:ls.of(`${c}.yml`),endpointId:n,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:ls.of(mE(u.join("_"))+".yml"),endpointId:mE(a.slice(u.length).join("_")),tag:r}}function dow({webhook:e,context:t}){return e.sdkName!=null?{file:WDf({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:low({namespaceOverride:e.namespace,location:fow({webhook:e,context:t})})}var pow=ls.of(mD);function k3f(e){switch(e.type){case"object":return R8t(e.groupName);case"enum":return R8t(e.groupName);case"oneOf":return R8t(e.value.groupName);case"array":return R8t(e.groupName);case"map":return R8t(e.groupName);case"reference":return R8t(e.groupName);case"literal":return R8t(e.groupName);case"optional":return R8t(e.groupName);case"nullable":return R8t(e.groupName);case"primitive":return R8t(e.groupName);case"unknown":return pow;default:sc(e)}}function R8t(e){return B7n(e)}var Rju="external",K3f=ls.of(mD);function e4f({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let u=k3f(a),f=GDf({schema:a,context:n,declarationFile:u,namespace:r});if(Wzr(f.schema)){let d=gx(f.schema);if(d===(f.name??i)||d===`optional<${f.name??i}>`)continue}n.builder.addType(u,{name:f.name??i,schema:f.schema})}}function t4f(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),R3f(e),L3f(e),U3f(e),XDf(e),X3f(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(Rju);let t=Y3f(e),r=t.sdkGroups;e.setInState(v8.Webhook),Z3f(e),e.unsetInState(v8.Webhook),e.setInState(v8.Channel);for(let i of e.ir.channel){let a=B7n(i.groupName);I3f({channel:i,context:e,declarationFile:a})}e.unsetInState(v8.Channel);let n=_ow({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});e4f({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:n,namespace:void 0,context:e});for(let[i,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))e4f({schemas:a,schemaIdsToExclude:n,namespace:i,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 _ow({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let n=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),i=new Set(t);for(let a of n)r.includes(a)||i.add(a);return Array.from(i)}var r0i=class{context;constructor(t){this.context=t}};var e4r=Jo(require("path"),1);var kwa=Jo(require("path"),1),e1a=class e{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[u,f]of Object.entries(n.files)){let d=i!=null?ls.of(`${i}${kwa.default.sep}${u}`):ls.of(u);t[d]=f}let a=Object.keys(n.directories).sort();for(let u of a){let f=i!=null?`${i}${kwa.default.sep}${u}`:u,d=n.directories[u];r(d,f)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(kwa.default.sep))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[ls.of(t[0])]??={};let[r,...n]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(n)}};var vtn=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new e1a,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":n,"display-name":i,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),n!=null&&(u.service["base-path"]=n),i!=null&&(u.service["display-name"]=i),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 iDr(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{}),r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}addGlobalHeader({name:t,schema:r}){let n=this.getVersionHeader();n!=null&&n===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:n}){if(t===r)return;let i=n??mE((B0(r)+"/"+(0,e4r.basename)(r,(0,e4r.extname)(r))).replaceAll("__package__","root"));if(t===ls.of(eF))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[i]=mC(B0(Hp.of(`/${t}`)),Hp.of(`/${r}`)),i;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[i]=mC(B0(Hp.of(`/${t}`)),Hp.of(`/${r}`)),i}addType(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.types==null&&(i.types={}),i.types[r]=n}addTypeExample(t,r,n){let i=this.getOrCreateFile(t);i.types==null&&(i.types={});let a=i.types[r];a!=null&&(typeof a=="string"?i.types[r]={type:a,examples:[n]}:(a.examples==null&&(a.examples=[]),a.examples.push(n)))}addError(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.errors==null&&(i.errors={}),i.errors[r]==null?i.errors[r]=n:i.errors[r]?.type!==n.type&&(i.errors[r]={"status-code":n["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:n}){let i=this.getOrCreateFile(t);if(i.errors==null)return;let a=i.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(f=>zqt(f,n))??!1)||a.examples?.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(a.service.source=i),a.service.endpoints[r]=n}addWebhook(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.webhooks==null&&(i.webhooks={}),i.webhooks[r]=n}addChannel(t,{channel:r}){let n=this.getOrCreateFile(t);n.channel=r;let i=this.basePath;i!=null&&(n.channel.path=e4r.default.join(i,r.path))}addChannelExample(t,{example:r}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.examples==null&&(n.channel.examples=[]),n.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:n}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.messages[r]=n}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([i,a])=>[i,{...a,path:e4r.default.join(r,a.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([a,u])=>[a,{...u,path:e4r.default.join(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===mD?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}};var t1a=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;onlyIncludeReferencedSchemas;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,enableUniqueErrorsPerEndpoint:n,detectGlobalHeaders:i,environmentOverrides:a,globalHeaderOverrides:u,authOverrides:f,objectQueryParameters:d,respectReadonlySchemas:c,onlyIncludeReferencedSchemas:o}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.enableUniqueErrorsPerEndpoint=n,this.builder=new vtn(n),r.title!=null&&this.builder.setDisplayName({displayName:r.title}),this.detectGlobalHeaders=i,this.environmentOverrides=a,this.authOverrides=f,this.globalHeaderOverrides=u,this.objectQueryParameters=d,this.respectReadonlySchemas=c,this.onlyIncludeReferencedSchemas=o,this.referencedSchemaIds=o?new Set:void 0;let l={};if(!this.enableUniqueErrorsPerEndpoint)for(let m of r.endpoints)for(let[O,j]of Object.entries(m.errors)){let A=parseInt(O),T=l[A];T==null&&j.schema!=null?l[A]=j.schema:T!=null&&j.schema!=null&&Awe(T,j.schema)||this.unknownSchema.add(A)}}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(v8.Channel,v8.Endpoint,v8.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:sc(t)}}markObjectSchemaAsReferenced(t,r){for(let n of t.allOf)this.markSchemaIdAsReferenced(n.schema,r);for(let n of t.properties)this.markSchemaAsReferenced(n.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let n of Object.values(t.schemas))this.markSchemaAsReferenced(n,r);return;case"undisciminated":for(let n of t.schemas)this.markSchemaAsReferenced(n,r);return;default:sc(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let n=this.getSchema(t,r);n!=null&&this.markSchemaAsReferenced(n,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function Lju(e){let t=new t1a(e);return t4f(t)}function r1a(e,t){return Vh(e,t)}var Fxe=class extends p2t{specs;sources;respectReadonlySchemas;onlyIncludeReferencedSchemas;constructor({specs:t,...r}){super(r),this.specs=t,this.sources=this.convertSpecsToIdentifiableSources(t),this.respectReadonlySchemas=this.specs.every(n=>n.settings?.respectReadonlySchemas??!1),this.onlyIncludeReferencedSchemas=this.specs.every(n=>n.settings?.onlyIncludeReferencedSchemas??!1)}async getOpenAPIIr({context:t,relativePathToDependency:r},n){let i=await Gkr({context:t,specs:this.specs,relativePathToDependency:r}),a=how(n);return await ytn({absoluteFilePathToWorkspace:this.absoluteFilePath,specs:i,taskContext:t,optionOverrides:{...a,respectReadonlySchemas:this.respectReadonlySchemas,onlyIncludeReferencedSchemas:this.onlyIncludeReferencedSchemas}})}async getDefinition({context:t,relativePathToDependency:r},n){let i=await this.getOpenAPIIr({context:t,relativePathToDependency:r},n),a=this.specs.every(f=>f.settings?.objectQueryParameters),u=Lju({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,taskContext:t,ir:i,enableUniqueErrorsPerEndpoint:n?.enableUniqueErrorsPerEndpoint??!1,detectGlobalHeaders:n?.detectGlobalHeaders??!0,objectQueryParameters:a,respectReadonlySchemas:this.respectReadonlySchemas,onlyIncludeReferencedSchemas:this.onlyIncludeReferencedSchemas});return{absoluteFilePath:Hp.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:u.rootApiFile["default-url"],contents:u.rootApiFile,rawContents:Fy.dump(u.rootApiFile)},namedDefinitionFiles:{...r1a(u.definitionFiles,f=>({absoluteFilepath:Hp.of("/DUMMY_PATH"),rawContents:Fy.dump(f),contents:f})),[ls.of(mD)]:{absoluteFilepath:Hp.of("/DUMMY_PATH"),rawContents:Fy.dump(u.packageMarkerFile),contents:u.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new _2t({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(YA)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,n=[];return t.reduce((i,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),i.push({type:a.type,id:d6r(),absoluteFilePath:u})),i},n)}};function n0i(e){if(e.settings==null)return;let t={detectGlobalHeaders:!0};return e.settings.unions==="v1"&&(t.enableDiscriminatedUnionV2=!0),t}function how(e){if(e==null)return;let t={};return e.enableDiscriminatedUnionV2&&(t.discriminatedUnionV2=!0),e.optionalAdditionalProperties&&(t.optionalAdditionalProperties=!0),e.cooerceEnumsToLiterals&&(t.cooerceEnumsToLiterals=!0),t}function r4f(e,t){if(yow(e))return t.alias(e);if(vow(e))return t.enum(e);if(bow(e))return t.object(e);if(gow(e))return t.union(e);sc(e)}function yow(e){return e?.alias!=null}function vow(e){return e?.values!=null}function bow(e){return e?.fields!=null}function gow(e){return e?.union!=null}var w1a={};Dc(w1a,{ConjureAliasDeclaration:()=>c1a,ConjureArgument:()=>O1a,ConjureArgumentWithParamType:()=>m1a,ConjureDefinitions:()=>v1a,ConjureEndpoint:()=>P1a,ConjureEnumDeclaration:()=>h1a,ConjureEnumVariant:()=>_1a,ConjureEnumWithDocs:()=>p1a,ConjureObjectDeclaration:()=>d1a,ConjureParamType:()=>g1a,ConjurePrimitive:()=>s1a,ConjureService:()=>j1a,ConjureServiceName:()=>u1a,ConjureType:()=>n4r,ConjureTypeDeclaration:()=>y1a,ConjureTypeReference:()=>i4r,ConjureTypeWithDocs:()=>l1a,ConjureTypes:()=>b1a,ConjureUnionDeclaration:()=>f1a,DefinitionFile:()=>M4f,WithDocs:()=>U8t,commons:()=>Jju,conjure:()=>Qju,services:()=>Gju,types:()=>$ju});var Jju={};Dc(Jju,{WithDocs:()=>U8t});var _y={};Dc(_y,{JsonError:()=>_Nn,ParseError:()=>hNn,any:()=>y4f,boolean:()=>v4f,booleanLiteral:()=>h4f,date:()=>i4f,discriminant:()=>S4f,enum_:()=>i1a,getObjectLikeUtils:()=>L8t,getObjectUtils:()=>vNn,getSchemaUtils:()=>v2,isProperty:()=>r4r,lazy:()=>a4f,lazyObject:()=>d4f,list:()=>o1a,number:()=>b4f,object:()=>a1a,objectWithoutOptionalProperties:()=>f4f,optional:()=>Uju,property:()=>u4f,record:()=>P4f,set:()=>j4f,string:()=>g4f,stringLiteral:()=>_4f,transform:()=>Vju,undiscriminatedUnion:()=>D4f,union:()=>A4f,unknown:()=>m4f,withParsedProperties:()=>Hju});var ES={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 ${mow(e)}.`}function mow(e){if(Array.isArray(e))return"list";if(e===null)return"null";switch(typeof e){case"string":return`"${e}"`;case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function yG(e){return{...e,json:n4f(e.json),parse:n4f(e.parse)}}function n4f(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1924
1924
|
`)),{ok:!0,value:t}):n}}function n1a(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var _Nn=class e extends Error{errors;constructor(t){super(t.map(n1a).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var hNn=class e extends Error{errors;constructor(t){super(t.map(n1a).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function v2(e){return{optional:()=>Uju(e),transform:t=>Vju(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new hNn(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new _Nn(n.errors)}}}function Uju(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>ES.OPTIONAL};return{...t,...v2(t)}}function Vju(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...v2(r)}}var Oow=/^([+-]?\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 i4f(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:Yq(t,"string")}]}:Oow.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:()=>ES.DATE};return{...yG(e),...v2(e)}}function vG(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...yG(r),...v2(r)}}}function i1a(e){let t=new Set(e);return vG(ES.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:Yq(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:Yq(n,"enum")}]}:{ok:!0,value:n})()}function a4f(e){let t=Wju(e);return{...t,...v2(t)}}function Wju(e){return{parse:(t,r)=>yNn(e).parse(t,r),json:(t,r)=>yNn(e).json(t,r),getType:()=>yNn(e).getType()}}function yNn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function i0i(e){return Object.entries(e)}function a0i(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function t4r(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 o0i(e){return Object.keys(e)}function o4f(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function L8t(e){return{withParsedProperties:t=>Hju(e,t)}}function Hju(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((f,[d,c])=>({...f,[d]:typeof c=="function"?c(a.value):c}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!t4r(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Yq(n,"object")}]};let a=new Set(Object.keys(t)),u=a0i(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...v2(r),...L8t(r)}}function u4f(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function r4r(e){return e.isProperty}function a1a(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>r4r(n)?n.rawKey:r),_getParsedProperties:()=>o0i(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of i0i(e)){let d=r4r(f)?f.rawKey:u,c=r4r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,l4f(c)&&a.push(d)}return s4f({value:r,requiredKeys:a,getProperty:u=>{let f=i[u];if(f!=null)return{transformedKey:f.parsedKey,transform:d=>f.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,u]of i0i(e)){let f=r4r(u)?u.valueSchema:u;l4f(f)&&i.push(a)}return s4f({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return r4r(u)?{transformedKey:u.rawKey,transform:f=>u.valueSchema.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:f=>u.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>ES.OBJECT};return{...yG(t),...v2(t),...L8t(t),...vNn(t)}}function s4f({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!t4r(e))return{ok:!1,errors:[{path:a,message:Yq(e,"object")}]};let u=new Set(t),f=[],d={};for(let[c,o]of Object.entries(e)){let l=r(c);if(l!=null){u.delete(c);let m=l.transform(o);m.ok?d[l.transformedKey]=m.value:(d[c]=o,f.push(...m.errors))}else switch(n){case"fail":f.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":d[c]=o;break}}return f.push(...t.filter(c=>u.has(c)).map(c=>({path:a,message:`Missing required key "${c}"`}))),f.length===0||i?{ok:!0,value:d}:{ok:!1,errors:f}}function vNn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>c4f({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>c4f({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>ES.OBJECT};return{...r,...v2(r),...L8t(r),...vNn(r)}}}}function c4f({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=o4f(o0i(t),c=>i.has(c)),f=r(a0i(t,u)),d=n(a0i(t,a));return f.ok&&d.ok?{ok:!0,value:{...f.value,...d.value}}:{ok:!1,errors:[...f.ok?[]:f.errors,...d.ok?[]:d.errors]}}function l4f(e){return!Pow(e)}function Pow(e){switch(e.getType()){case ES.ANY:case ES.UNKNOWN:case ES.OPTIONAL:return!0;default:return!1}}function f4f(e){return a1a(e)}function d4f(e){let t={...Wju(e),_getRawProperties:()=>yNn(e)._getRawProperties(),_getParsedProperties:()=>yNn(e)._getParsedProperties()};return{...t,...v2(t),...L8t(t),...vNn(t)}}function o1a(e){let t={parse:(r,n)=>p4f(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>p4f(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>ES.LIST};return{...yG(t),...v2(t)}}function p4f(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:Yq(e,"list"),path:[]}]}}function _4f(e){return vG(ES.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Yq(r,`"${e}"`)}]})()}function h4f(e){return vG(ES.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Yq(r,`${e.toString()}`)}]})()}var y4f=vG(ES.ANY,e=>({ok:!0,value:e}));var v4f=vG(ES.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Yq(e,"boolean")}]});var b4f=vG(ES.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Yq(e,"number")}]});var g4f=vG(ES.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Yq(e,"string")}]});var m4f=vG(ES.UNKNOWN,e=>({ok:!0,value:e}));function P4f(e,t){let r={parse:(n,i)=>O4f({value:n,isKeyNumeric:e.getType()===ES.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>O4f({value:n,isKeyNumeric:e.getType()===ES.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>ES.RECORD};return{...yG(r),...v2(r)}}function O4f({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return t4r(e)?i0i(e).reduce((a,[u,f])=>{if(f==null)return a;let d=a,c=u;if(t){let O=u.length>0?Number(u):NaN;isNaN(O)||(c=O)}let o=r(c),l=n(f,c);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let m=[];return d.ok||m.push(...d.errors),o.ok||m.push(...o.errors),l.ok||m.push(...l.errors),{ok:!1,errors:m}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:Yq(e,"object")}]}}function j4f(e){let t=o1a(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Yq(n,"Set")}]},getType:()=>ES.SET};return{...yG(r),...v2(r)}}function D4f(e){let t={parse:(r,n)=>w4f((i,a)=>i.parse(r,a),e,n),json:(r,n)=>w4f((i,a)=>i.json(r,a),e,n),getType:()=>ES.UNDISCRIMINATED_UNION};return{...yG(t),...v2(t)}}function w4f(e,t,r){let n=[];for(let[i,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let f of u.errors)n.push({path:f.path,message:`[Variant ${i}] ${f.message}`})}return{ok:!1,errors:n}}function S4f(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function A4f(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=i1a(o0i(t)),a={parse:(u,f)=>E4f({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.parse(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),json:(u,f)=>E4f({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.json(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),getType:()=>ES.UNION};return{...yG(a),...v2(a),...L8t(a)}}function E4f({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!t4r(e))return{ok:!1,errors:[{path:f,message:Yq(e,"object")}]};let{[t]:d,...c}=e;if(d==null)return{ok:!1,errors:[{path:f,message:`Missing discriminant ("${t}")`}]};let o=n(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=i(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...c}}:{ok:!1,errors:[{path:[...f,t],message:"Unexpected discriminant value"}]};let m=u(c,l);return m.ok?{ok:!0,value:{[r]:d,...m.value}}:m}var U8t=_y.objectWithoutOptionalProperties({docs:_y.string().optional()});var Qju={};Dc(Qju,{ConjureServiceName:()=>u1a,DefinitionFile:()=>M4f});var u1a=_y.string();var s1a=_y.enum_(["rid","string","safelong","integer","double","boolean"]);var n4r=_y.undiscriminatedUnion([s1a,_y.string()]);var c1a=_y.objectWithoutOptionalProperties({alias:n4r,docs:_y.string().optional()});var l1a=_y.objectWithoutOptionalProperties({type:n4r,docs:_y.string().optional()});var i4r=_y.undiscriminatedUnion([n4r,l1a]);var f1a=_y.objectWithoutOptionalProperties({union:_y.record(_y.string(),i4r)});var d1a=_y.objectWithoutOptionalProperties({fields:_y.record(_y.string(),i4r)});var p1a=_y.objectWithoutOptionalProperties({value:_y.string()}).extend(U8t);var _1a=_y.undiscriminatedUnion([_y.string(),p1a]);var h1a=_y.objectWithoutOptionalProperties({values:_y.list(_1a)});var y1a=_y.undiscriminatedUnion([c1a,f1a,d1a,h1a]);var v1a=_y.objectWithoutOptionalProperties({objects:_y.record(_y.string(),y1a).optional()});var b1a=_y.objectWithoutOptionalProperties({conjureImports:_y.property("conjure-imports",_y.record(_y.string(),_y.string()).optional()),definitions:v1a.optional()});var g1a=_y.enum_(["path","query","body"]);var m1a=_y.objectWithoutOptionalProperties({paramType:_y.property("param-type",g1a),type:_y.string()}).extend(U8t);var O1a=_y.undiscriminatedUnion([_y.string(),m1a]);var P1a=_y.objectWithoutOptionalProperties({http:_y.string(),args:_y.record(_y.string(),O1a).optional(),returns:i4r.optional()}).extend(U8t);var j1a=_y.objectWithoutOptionalProperties({name:_y.string().optional(),package:_y.string().optional(),basePath:_y.property("base-path",_y.string().optional()),endpoints:_y.record(_y.string(),P1a).optional()}).extend(U8t);var M4f=_y.objectWithoutOptionalProperties({types:b1a.optional(),services:_y.record(u1a,j1a).optional()});var Gju={};Dc(Gju,{ConjureArgument:()=>O1a,ConjureArgumentWithParamType:()=>m1a,ConjureEndpoint:()=>P1a,ConjureParamType:()=>g1a,ConjureService:()=>j1a});var $ju={};Dc($ju,{ConjureAliasDeclaration:()=>c1a,ConjureDefinitions:()=>v1a,ConjureEnumDeclaration:()=>h1a,ConjureEnumVariant:()=>_1a,ConjureEnumWithDocs:()=>p1a,ConjureObjectDeclaration:()=>d1a,ConjurePrimitive:()=>s1a,ConjureType:()=>n4r,ConjureTypeDeclaration:()=>y1a,ConjureTypeReference:()=>i4r,ConjureTypeWithDocs:()=>l1a,ConjureTypes:()=>b1a,ConjureUnionDeclaration:()=>f1a});var T4f=require("fs/promises");async function x4f(e,t){let r=[];for(let n of await YAe(e,t))r.push(await jow({relativeFilepath:mC(e,n),absoluteFilepath:n}));return r}async function jow({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,T4f.readFile)(t)).toString().replaceAll(": rid",": string").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:w1a.DefinitionFile.parseOrThrow(Fy.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}var u0i=class extends r0i{fernDefinitionBuilder=new vtn(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:n,globalHeaderOverrides:i}){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(n!=null){for(let[a,u]of Object.entries(n.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:u});n["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(n["default-environment"]),n["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(n["default-url"])}return await q4f(t,(a,u,f)=>{for(let[o,l]of Object.entries(f.services??{})){let m=PJi({value:o,suffix:"Service"});this.conjureFilepathToFernFilepath[u]=ls.of(`${m}/__package__.yml`);return}let c=uHo(u)?.split(".")[0];c!=null&&(this.conjureFilepathToFernFilepath[u]=ls.of(`${c}/__package__.yml`))}),await q4f(t,(a,u,f)=>{if(f.services==null||Object.keys(f.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[c,o]of Object.entries(f.types?.conjureImports??{})){let l=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:ls.of(o)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:ls.of(l),alias:c})}this.importAllTypes({conjureFile:f,fernFilePath:d});return}for(let[d,c]of Object.entries(f.services)){let o=PJi({value:d,suffix:"Service"}),l=ls.of(`${o}/__package__.yml`),m={};c.basePath!=null&&(m["base-path"]=c.basePath),c.docs!=null&&(m.docs=c.docs),this.fernDefinitionBuilder.setServiceInfo(l,m),this.importAllTypes({conjureFile:f,fernFilePath:l});for(let[O,j]of Object.entries(f.types?.conjureImports??{})){let A=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:ls.of(j)});this.fernDefinitionBuilder.addImport({file:l,fileToImport:ls.of(A),alias:O})}for(let[O,j]of Object.entries(c.endpoints??{})){let A=dUo(j.http);if(A.type==="failure"){this.context?.logger.error(`Failed to parse ${j.http}. Skipping.`);continue}let T={auth:!0,path:A.path,method:A.method,response:j.returns==="binary"?"file":j.returns};j.docs!=null&&(T.docs=j.docs);let B={};if(j.args!=null)for(let F of A.pathParameters){let C=j.args[F];if(C==null)throw new Error(`Failed to find path parameter ${F} in ${j.http}`);B[F]=typeof C=="string"?C:{type:C.type}}Object.entries(B).length>0&&(T["path-parameters"]=B);for(let[F,C]of Object.entries(j.args??{}))if(B[F]==null)if(typeof C=="string")T.request?typeof T.request=="string"&&(T.request={body:T.request}):T.request={},T.request.body=C==="binary"?"bytes":C;else switch(C.paramType){case"body":T.request={body:C.type==="binary"?"bytes":C.type};break;case"query":T.request==null?T.request={"query-parameters":{[F]:C.type}}:typeof T.request!="string"&&T.request?.["query-parameters"]==null?T.request["query-parameters"]={[F]:C.type}:typeof T.request!="string"&&T.request?.["query-parameters"]!=null&&(T.request["query-parameters"][F]=C.type)}T.request!=null&&typeof T.request!="string"&&T.request?.["query-parameters"]!=null&&(T.request.name=`${O}Request`),this.fernDefinitionBuilder.addEndpoint(l,{name:O,schema:T,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[n,i]of Object.entries(t.types?.definitions?.objects??{}))r4f(i,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{union:Object.fromEntries(Object.entries(a.union).map(([u,f])=>[u,{type:typeof f=="string"?f:f.type,docs:typeof f=="string"?void 0:f.docs,key:u}]))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:n}){let i=Wl(B0(t),ls.of(r)),a=DIr(n,i),u=this.conjureFilepathToFernFilepath[a];if(u==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return u}};async function q4f(e,t){for(let r of await x4f(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}var D1a=class extends p2t{absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=Wl(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new _2t({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let i=await new u0i(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:Hp.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:i.rootApiFile["default-url"],contents:i.rootApiFile,rawContents:Fy.dump(i.rootApiFile)},namedDefinitionFiles:{...r1a(i.definitionFiles,a=>({absoluteFilepath:Hp.of("/DUMMY_PATH"),rawContents:Fy.dump(a),contents:a})),[ls.of(mD)]:{absoluteFilepath:Hp.of("/DUMMY_PATH"),rawContents:Fy.dump(i.packageMarkerFile),contents:i.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};function Kju(e,t){for(let[r,n]of X6(e.failures))wow({relativeFilepath:r,failure:n,logger:t})}function wow({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Iw.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 Iw.FILE_READ:r.error("Failed to open file: "+e);break;case Iw.FILE_MISSING:r.error("Missing file: "+e);break;case Iw.FILE_PARSE:t.error instanceof _ci?r.error(Kqt({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Iw.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of Dow(n))r.error(Kqt({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case Iw.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Iw.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${iQi}: `+t.dependencyName);break;case Iw.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Iw.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case Iw.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(Kqt({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(n=>n!=="")]}));break;default:sc(t)}}function Dow(e){switch(e.code){case Tp.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${qc.underline(e.expected)} but received ${qc.underline(e.received)}`}];case Tp.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${qc.underline(t)}`}));case Tp.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>qc.underline(t)).join(", ")}`}];case Tp.invalid_union:case Tp.invalid_arguments:case Tp.invalid_return_type:case Tp.invalid_date:case Tp.invalid_string:case Tp.too_small:case Tp.too_big:case Tp.invalid_intersection_types:case Tp.not_multiple_of:case Tp.custom:default:return[{title:e.message}]}}var C4f=require("fs/promises");async function B4f(e,t){let r=[];for(let n of await YAe(e,t))r.push(await Sow({relativeFilepath:mC(e,n),absoluteFilepath:n}));return r}async function Sow({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,C4f.readFile)(t)).toString()}}async function I4f({absolutePathToWorkspace:e}){let t=Wl(e,ls.of(YLc));if(!await _h(t))return;let n=await B4f(t,"{md,mdx}");return{files:await Promise.all(n.map(i=>({absoluteFilepath:i.absoluteFilepath,contents:i.fileContents})))}}async function Yju({absolutePathToWorkspace:e,namespace:t,definitions:r}){let n=[];for(let i of r){let a=i.overrides!=null?Wl(e,ls.of(i.overrides)):void 0;if(i.schema.type==="protobuf"){let f=Wl(e,ls.of(i.schema.root));if(!await _h(f))return{didSucceed:!1,failures:{[ls.of(i.schema.root)]:{type:Iw.FILE_MISSING}}};let d=Wl(e,ls.of(i.schema.target));if(!await _h(d))return{didSucceed:!1,failures:{[ls.of(i.schema.target)]:{type:Iw.FILE_MISSING}}};n.push({type:"protobuf",absoluteFilepathToProtobufRoot:f,absoluteFilepathToProtobufTarget:d,absoluteFilepathToOverrides:a,generateLocally:i.schema.localGeneration,settings:{audiences:i.audiences??[],shouldUseTitleAsName:i.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:i.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,optionalAdditionalProperties:i.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:i.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:i.settings?.objectQueryParameters??!1,respectReadonlySchemas:i.settings?.respectReadonlySchemas??!1,onlyIncludeReferencedSchemas:i.settings?.onlyIncludeReferencedSchemas??!1}});continue}let u=Wl(e,ls.of(i.schema.path));if(!await _h(u))return{didSucceed:!1,failures:{[ls.of(i.schema.path)]:{type:Iw.FILE_MISSING}}};if(i.overrides!=null&&a!=null&&!await _h(a))return{didSucceed:!1,failures:{[ls.of(i.overrides)]:{type:Iw.FILE_MISSING}}};n.push({type:"openapi",absoluteFilepath:u,absoluteFilepathToOverrides:a,settings:{audiences:i.audiences??[],shouldUseTitleAsName:i.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:i.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,asyncApiNaming:i.settings?.asyncApiMessageNaming,optionalAdditionalProperties:i.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:i.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:i.settings?.objectQueryParameters??!1,respectReadonlySchemas:i.settings?.respectReadonlySchemas??!1,onlyIncludeReferencedSchemas:i.settings?.onlyIncludeReferencedSchemas??!1},source:{type:"openapi",file:u},namespace:t})}return n}async function s0i({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:n}){let i=await yO.loadGeneratorsConfiguration({absolutePathToWorkspace:e,context:t}),a;try{a=await I4f({absolutePathToWorkspace:e})}catch{}if(i?.api!=null&&i?.api.type==="conjure")return{didSucceed:!0,workspace:new D1a({workspaceName:n,absoluteFilePath:e,generatorsConfiguration:i,changelog:a,cliVersion:r,context:t,relativePathToConjureDirectory:ls.of(i.api.pathToConjureDefinition)})};if(i?.api!=null&&(i.api.type==="singleNamespace"&&i.api.definitions.length>0||i.api.type==="multiNamespace")){let u=[];if(i.api.type==="singleNamespace"){let f=await Yju({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.definitions});if(!Array.isArray(f))return f;u.push(...f)}else{for(let[f,d]of Object.entries(i.api.definitions)){let c=await Yju({absolutePathToWorkspace:e,namespace:f,definitions:d});if(!Array.isArray(c))return c;u.push(...c)}if(i.api.rootDefinitions!=null){let f=await Yju({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.rootDefinitions});if(!Array.isArray(f))return f;u.push(...f)}}return{didSucceed:!0,workspace:new Fxe({specs:u,workspaceName:n,absoluteFilePath:e,generatorsConfiguration:i,changelog:a,cliVersion:r})}}return await _h(Wl(e,ls.of(g9)))?{didSucceed:!0,workspace:new a7n({absoluteFilePath:e,generatorsConfiguration:i,workspaceName:n,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:s0i})}:{didSucceed:!1,failures:{[ls.of(dYr)]:{type:Iw.MISCONFIGURED_DIRECTORY}}}}var z4f=require("fs/promises");var N4f=Jo(require("path"),1);async function Xju({fernDirectory:e,context:t}){let r=Wl(e,ls.of(s1r));if(!await _h(r))return;let n=await Eow({absolutePathToDocsDefinition:e,context:t});if(n!=null)return{type:"docs",absoluteFilePath:e,config:n,workspaceName:void 0,absoluteFilepathToDocsConfig:Wl(e,ls.of(s1r))}}async function Eow({absolutePathToDocsDefinition:e,context:t}){if(!await _h(e))return;let r=Wl(e,ls.of(s1r));return await Aow({absolutePathOfConfiguration:r,context:t})}async function Aow({absolutePathOfConfiguration:e,context:t}){let r=await(0,z4f.readFile)(e),n=Fy.load(r.toString());return await Mow({value:n,context:t,filepathBeingParsed:e})}async function Mow({value:e,context:t,filepathBeingParsed:r}){let n=await _Me.RawSchemas.Serializer.DocsConfiguration.parse(e);if(n.ok)return n.value;let i=n.errors.map(u=>{let f=u.path.length>0?`${u.message} at "${u.path.join(" -> ")}"`:u.message;return HY({content:f,prefix:" - "})}),a=[`Failed to parse file: ${N4f.default.relative(process.cwd(),r)}`,...i].join(`
|
|
1925
1925
|
`);return t.failAndThrow(a)}var F4f=require("fs/promises");async function Zju({context:e,nameOverride:t,...r}){let n=await Jzr(t);return n==null?e.failAndThrow(`Directory "${t??Uqt}" not found.`):await R4f({absolutePathToFernDirectory:n,context:e,nameOverride:t,...r})}async function R4f({absolutePathToFernDirectory:e,cliName:t,cliVersion:r,commandLineApiWorkspace:n,defaultToAllApiWorkspaces:i,context:a}){let u=[];return(await _h(Wl(e,ls.of(gIr)))||await _h(Wl(e,ls.of(g9)))||await _h(Wl(e,ls.of(k6)))||await _h(Wl(e,ls.of(dYr)))||await _h(Wl(e,ls.of(XLc))))&&(u=await L4f({cliName:t,fernDirectory:e,cliVersion:r,context:a,commandLineApiWorkspace:n,defaultToAllApiWorkspaces:i})),{config:await W6t.loadProjectConfig({directory:e,context:a}),apiWorkspaces:u,docsWorkspaces:await Xju({fernDirectory:e,context:a}),loadAPIWorkspace:f=>f==null?u[0]:u.find(d=>d.workspaceName===f)}}async function L4f({cliName:e,fernDirectory:t,context:r,cliVersion:n,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:a}){let u=Wl(t,ls.of(gIr));if(await _h(u)){let o=(await(0,F4f.readdir)(u,{withFileTypes:!0})).reduce((O,j)=>(j.isDirectory()&&O.push(j.name),O),[]);if(i!=null){if(!o.includes(i))return r.failAndThrow("API does not exist: "+i)}else{if(o.length===0)return r.failAndThrow("No APIs found.");if(o.length>1&&!a){let O=`There are multiple workspaces. You must specify one with --api:
|
|
1926
1926
|
`,j=Math.max(...o.map(A=>A.length));return O+=o.map(A=>{let T=`${e} ${process.argv.slice(2).join(" ")} --api ${A}`;return` \u203A ${qc.bold(A.padEnd(j))} ${qc.dim(T)}`}).join(`
|