fern-api 0.51.26 → 0.51.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.cjs +4 -4
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -1684,7 +1684,7 @@ ${c.indent}`:""}${Zmf(o)}:${l.indent?" ":""}`;return u=!1,s=!0,l.objectItem=void
1684
1684
  `}),r.replaceAll(/\n$/g,"")}function i31(e){return e?Su.green(r3.radioOn):r3.radioOff}var Uio=Di(dwe(),1);function Lxd(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var gGn=class extends r2{_run(t){this.done=t;let r=TL(this.rl),i=r.line.pipe((0,Uio.map)(this.filterInput.bind(this))),n=this.handleSubmitEvents(i);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,Uio.takeUntil)(n.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),i="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(i=`
1685
1685
  `+Su.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?Su.cyan(Lxd(t,this.opt.mask)):Su.italic.dim("[hidden]"):this.opt.mask?Lxd(t,this.opt.mask):Su.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 fzd=Di(Ids(),1),dzd=Di(dwe(),1);var MGn=class extends r2{_run(t){this.done=t,this.editorResult=new dzd.Subject;let r=TL(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?Su.dim("Received"):Su.dim("Press <enter> to launch your preferred editor."),t&&(r=Su.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,fzd.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 Ozd=Di(hzd(),1);var bzd=Di(require("readline"),1),gzd=Di(vzd(),1),Uji=class{constructor(t){this.rl||=bzd.default.createInterface(Q31(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 Q31(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let n=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw n.isTtyError=!0,n}let r=new gzd.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var qGn=class extends Uji{constructor(t={}){super(t),this.log=(0,Ozd.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return fGn(this.rl,this.bottomBar.split(`
1686
1686
  `).length),this}updateBottomBar(t){return fGn(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+`
1687
- `}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&&Rio(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var qzd=Di(jzd(),1),Tzd=Di(Wls(),1),Czd=Di(Azd(),1),rM=Di(dwe(),1),Bzd=Di(O$n(),1);var uno=Di(dwe(),1),Mzd=Di(O$n(),1),sno=function(e,t,r){return typeof e[t]!="function"?(0,uno.of)(e):(0,uno.from)((0,Mzd.default)(e[t])(r).then(i=>(e[t]=i,e)))};var TGn={isPlainObject:qzd.default,set:Czd.default,get:Tzd.default},jun=class extends Uji{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=TGn.isPlainObject(r)?{...r}:{},TGn.isPlainObject(t)&&(t=Object.values(t).every(n=>TGn.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,rM.from)(t):t;return this.process=i.pipe((0,rM.concatMap)(this.processQuestion.bind(this)),(0,rM.publish)()),this.process.connect(),this.process.pipe((0,rM.reduce)((n,a)=>(TGn.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,rM.defer)(()=>(0,rM.of)(t).pipe((0,rM.concatMap)(this.setDefaultType.bind(this)),(0,rM.concatMap)(this.filterIfRunnable.bind(this)),(0,rM.concatMap)(()=>sno(t,"message",this.answers)),(0,rM.concatMap)(()=>sno(t,"default",this.answers)),(0,rM.concatMap)(()=>sno(t,"choices",this.answers)),(0,rM.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,rM.defer)(()=>(0,rM.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,rM.defer)(()=>(0,rM.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&TGn.get(this.answers,t.name)!==void 0)return(0,rM.empty)();if(t.when===!1)return(0,rM.empty)();if(typeof t.when!="function")return(0,rM.of)(t);let{answers:r}=this;return(0,rM.defer)(()=>(0,rM.from)((0,Bzd.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,rM.filter)(i=>i!=null)))}};function xzd(e){let t=function(r,i){let n;try{n=new jun(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",pGn),this.registerPrompt("input",Bji),this.registerPrompt("number",_Gn),this.registerPrompt("confirm",hGn),this.registerPrompt("rawlist",yGn),this.registerPrompt("expand",vGn),this.registerPrompt("checkbox",bGn),this.registerPrompt("password",gGn),this.registerPrompt("editor",MGn)},t.restoreDefaultPrompts(),t}var Fds=xzd();function f71(e,t){Fds.registerPrompt(e,t)}function d71(){Fds.restoreDefaultPrompts()}var p71={prompt:Fds,ui:{BottomBar:qGn,Prompt:jun},createPromptModule:xzd,registerPrompt:f71,restoreDefaultPrompts:d71,Separator:yte},cno=p71;var HRd=Di(Izd()),R61="4.2.1",n2t;(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"})(n2t||(n2t={}));function F61(e,t){if(!e)throw new Error(t)}function N61(e){return e?.replace(/\/+$/,"")}async function L61(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function U61(){return new Date().getTime()}function zRd(){return new Date().toISOString()}function $Rd(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var WGn=String.fromCharCode,RRd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Pno={};function V61(e,t){if(!Pno[e]){Pno[e]={};for(let r=0;r<e.length;r++)Pno[e][e.charAt(r)]=r}return Pno[e][t]}var HGn={compressToBase64:function(e){if(e==null)return"";let t=HGn._compress(e,6,function(r){return RRd.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:HGn._decompress(e.length,32,function(t){return V61(RRd,e.charAt(t))})},compress:function(e){return HGn._compress(e,16,function(t){return WGn(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,f="",s="",o="",c=2,b=3,g=2,O=0,m=0,w;for(w=0;w<e.length;w+=1)if(f=e.charAt(w),Object.prototype.hasOwnProperty.call(i,f)||(i[f]=b++,n[f]=!0),s=o+f,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(f)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:HGn._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,f=3,s="",o,c,b,g,O,m,w;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=WGn(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=WGn(b);break;case 2:return""}for(i[3]=w,c=w,n.push(w);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,f),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(w=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=WGn(b),w=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=WGn(b),w=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,f),f++),i[w])s=i[w];else if(w===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,f),f++)}}},wps=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}};var jno="0123456789abcdef",wno=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=jno.charAt(this.bytes[r]>>>4),t+=jno.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+=jno.charAt(this.bytes[r]>>>4),t+=jno.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},Sps=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??W61()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return wno.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,wno.ofInner(t)}},W61=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),FRd,NRd=()=>H61().toString(),H61=()=>(FRd||(FRd=new Sps)).generate(),Sno=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},$Gn=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function LRd(e){return typeof e=="object"&&(e instanceof Sno||e instanceof $Gn)}var Dps=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new wps,this._isInitialized=!1,F61(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=N61(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:LRd},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(n2t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(n2t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(n2t.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=NRd();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(f=>f.json()).catch(f=>{this._events.emit("error",f)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!l)return;let f=l[t];return f===void 0&&(f=!1),f}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!l)return;let f=l[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let l=await this.getDecide(t,r,i,n,u),f=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:f,payloads:o}}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:zRd(),uuid:i?.uuid?i.uuid:NRd()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty(n2t.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty(n2t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=$Rd(()=>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(n2t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(n2t.Queue)||[];this.setPersistedProperty(n2t.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:zRd()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${U61()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,f=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(HGn.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,f)}catch(s){throw s instanceof $Gn||n(),this._events.emit("error",s),s}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(l){let f=new AbortController;return setTimeout(()=>f.abort(),l),f.signal}),await L61(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(f){throw new $Gn(f)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new Sno(u);return u},{...this._retryOptions,...i})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(n2t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!LRd(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},Eps=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},Aps=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!Aps){let e=IRd();Aps=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var GRd=Aps,$61=1152921504606847e3,G61=["is_not"],Dno=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},i2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Mps=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=l.fetch||GRd,this.onError=l.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let f of this.featureFlags)if(t===f.key){l=f;break}if(l!==void 0)try{u=this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(f){f instanceof i2?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async f=>{try{let s=this.computeFlagLocally(f,t,r,i,n);a[f.key]=s;let o=await this.computeFeatureFlagPayloadLocally(f.key,s);o&&(u[f.key]=o)}catch(s){s instanceof i2||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new i2("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let f=this.groupTypeMapping[String(l)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new i2("Flag has unknown group type index");if(!(f in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[f];return this.matchFeatureFlagProperties(t,i[f],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,f=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of f)try{if(this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof i2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new i2("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let f=l.type,s=!1;if(f==="cohort"?s=JRd(l,n,this.cohorts,this.debugMode):s=QRd(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&URd(t.key,r)>a/100)}getMatchingVariant(t,r){let i=URd(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new Dno("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof Dno&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=$Rd(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function URd(e,t,r=""){let i=(0,HRd.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/$61}function QRd(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new i2("Operator is_not_set is not supported")}else throw new i2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!G61.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function f(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return VRd(String(n))&&String(u).match(String(n))!==null;case"not_regex":return VRd(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?f(u,String(n),a):f(u,s,a):f(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=Q61(String(n));if(s==null&&(s=WRd(n)),s==null)throw new i2(`Invalid date: ${n}`);let o=WRd(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new i2(`Unknown operator: ${a}`)}}function JRd(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new i2("can't match cohort without a given cohort property value");let a=r[n];return KRd(a,t,r,i)}function KRd(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let f=KRd(l,t,r,i);if(n==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof i2)i&&console.debug(`Failed to compute property ${l} locally: ${f}`),u=!0;else throw f}if(u)throw new i2("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let f;l.type==="cohort"?f=JRd(l,t,r,i):f=QRd(l,t);let s=l.negation||!1;if(n==="AND"){if(!f&&!s||f&&s)return!1}else if(f&&!s||!f&&s)return!0}catch(f){if(f instanceof i2)i&&console.debug(`Failed to compute property ${l} locally: ${f}`),u=!0;else throw f}if(u)throw new i2("can't match cohort without a given cohort property value");return n==="AND"}}function VRd(e){try{return new RegExp(e),!0}catch{return!1}}function WRd(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 i2(`${e} is in an invalid date format`)}else throw new i2(`The date provided ${e} must be a string, number, or date object`)}function Q61(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var J61=30*1e3,K61=50*1e3,qun=class extends Dps{constructor(t,r={}){super(t,r),this._memoryStorage=new Eps,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new Mps({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:J61,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||K61}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):GRd(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return R61}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture({distinctId:t,event:r,properties:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:l,uuid:f}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:f})},o=(b,g,O)=>super.getFeatureFlagsStateless(b,g,void 0,void 0,O),c=Promise.resolve().then(async()=>{if(a)return await o(t,n,l);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let b={};for(let[g,O]of Object.entries(n||{}))b[g]=String(O);return await this.getAllFlags(t,{groups:b,disableGeoip:l,onlyEvaluateLocally:!0})}return{}}).then(b=>{let g={};if(b)for(let[m,w]of Object.entries(b))g[`$feature/${m}`]=w;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:f,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,f,s);f=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,f,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,f,s,a));let g=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(g))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(g):this.distinctIdHasSentFlagCalls[r]=[g],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,locally_evaluated:b,[`$feature/${t}`]:c},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:f,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),l==null&&(l=!1),f==null&&(f=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},f=this.addLocalPersonAndGroupProperties(t,i,u,l);u=f.allPersonProperties,l=f.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},qps=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},l=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&l!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${l}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};qps.POSTHOG_ID_TAG="posthog_distinct_id";var Eno=class{posthog;constructor({posthogApiKey:t}){this.posthog=new qun(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.51.26",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var GGn=class{async sendEvent(){}async identify(){}async flush(){}};var Tun=require("fs/promises"),kRd=require("os"),eFd=require("path");var YRd=Di(require("crypto")),Mno=new Uint8Array(256),Ano=Mno.length;function Tps(){return Ano>Mno.length-16&&(YRd.default.randomFillSync(Mno),Ano=0),Mno.slice(Ano,Ano+=16)}var xL=[];for(let e=0;e<256;++e)xL.push((e+256).toString(16).slice(1));function XRd(e,t=0){return xL[e[t+0]]+xL[e[t+1]]+xL[e[t+2]]+xL[e[t+3]]+"-"+xL[e[t+4]]+xL[e[t+5]]+"-"+xL[e[t+6]]+xL[e[t+7]]+"-"+xL[e[t+8]]+xL[e[t+9]]+"-"+xL[e[t+10]]+xL[e[t+11]]+xL[e[t+12]]+xL[e[t+13]]+xL[e[t+14]]+xL[e[t+15]]}var ZRd=Di(require("crypto")),Cps={randomUUID:ZRd.default.randomUUID};function Y61(e,t,r){if(Cps.randomUUID&&!t&&!e)return Cps.randomUUID();e=e||{};let i=e.random||(e.rng||Tps)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return XRd(i)}var ZCe=Y61;var X61="id",Z61=".fern",QGn=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new qun(r),this.userId=t==null?void 0:Yas(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.51.26",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=ku(Kl.of((0,kRd.homedir)()),yo.of(Z61),yo.of(X61));await zf(t)||(await(0,Tun.mkdir)((0,eFd.dirname)(t),{recursive:!0}),await(0,Tun.writeFile)(t,ZCe())),this.persistedDistinctId=(await(0,Tun.readFile)(t)).toString()}return this.persistedDistinctId}};var Bps;async function Cun(){return Bps==null&&(Bps=await k61()),Bps}async function k61(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new GGn;let r=await LXa();return r!=null?new QGn({token:r,posthogApiKey:e}):await NXa()!=null?new Eno({posthogApiKey:e}):new QGn({token:void 0,posthogApiKey:e})}catch{return new GGn}}function JGn(e,t){return function(){return e.apply(t,arguments)}}var{toString:e41}=Object.prototype,{getPrototypeOf:zps}=Object,Tno=(e=>t=>{let r=e41.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),a2t=e=>(e=e.toLowerCase(),t=>Tno(t)===e),Cno=e=>t=>typeof t===e,{isArray:xun}=Array,KGn=Cno("undefined");function t41(e){return e!==null&&!KGn(e)&&e.constructor!==null&&!KGn(e.constructor)&&_we(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var iFd=a2t("ArrayBuffer");function r41(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&iFd(e.buffer),t}var i41=Cno("string"),_we=Cno("function"),nFd=Cno("number"),Bno=e=>e!==null&&typeof e=="object",n41=e=>e===!0||e===!1,qno=e=>{if(Tno(e)!=="object")return!1;let t=zps(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},a41=a2t("Date"),o41=a2t("File"),u41=a2t("Blob"),s41=a2t("FileList"),c41=e=>Bno(e)&&_we(e.pipe),l41=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||_we(e.append)&&((t=Tno(e))==="formdata"||t==="object"&&_we(e.toString)&&e.toString()==="[object FormData]"))},f41=a2t("URLSearchParams"),[d41,p41,_41,h41]=["ReadableStream","Request","Response","Headers"].map(a2t),y41=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function YGn(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),xun(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function aFd(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var $ji=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,oFd=e=>!KGn(e)&&e!==$ji;function Ips(){let{caseless:e}=oFd(this)&&this||{},t={},r=(i,n)=>{let a=e&&aFd(t,n)||n;qno(t[a])&&qno(i)?t[a]=Ips(t[a],i):qno(i)?t[a]=Ips({},i):xun(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&YGn(arguments[i],r);return t}var v41=(e,t,r,{allOwnKeys:i}={})=>(YGn(t,(n,a)=>{r&&_we(n)?e[a]=JGn(n,r):e[a]=n},{allOwnKeys:i}),e),b41=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),g41=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},O41=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&zps(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},m41=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},P41=e=>{if(!e)return null;if(xun(e))return e;let t=e.length;if(!nFd(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},j41=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&zps(Uint8Array)),w41=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},S41=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},D41=a2t("HTMLFormElement"),E41=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),tFd=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),A41=a2t("RegExp"),uFd=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};YGn(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},M41=e=>{uFd(e,(t,r)=>{if(_we(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(_we(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},q41=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return xun(e)?i(e):i(String(e).split(t)),r},T41=()=>{},C41=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,xps="abcdefghijklmnopqrstuvwxyz",rFd="0123456789",sFd={DIGIT:rFd,ALPHA:xps,ALPHA_DIGIT:xps+xps.toUpperCase()+rFd},B41=(e=16,t=sFd.ALPHA_DIGIT)=>{let r="",{length:i}=t;for(;e--;)r+=t[Math.random()*i|0];return r};function x41(e){return!!(e&&_we(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var I41=e=>{let t=new Array(10),r=(i,n)=>{if(Bno(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=xun(i)?[]:{};return YGn(i,(u,l)=>{let f=r(u,n+1);!KGn(f)&&(a[l]=f)}),t[n]=void 0,a}}return i};return r(e,0)},z41=a2t("AsyncFunction"),R41=e=>e&&(Bno(e)||_we(e))&&_we(e.then)&&_we(e.catch),cFd=((e,t)=>e?setImmediate:t?((r,i)=>($ji.addEventListener("message",({source:n,data:a})=>{n===$ji&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),$ji.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",_we($ji.postMessage)),F41=typeof queueMicrotask<"u"?queueMicrotask.bind($ji):typeof process<"u"&&process.nextTick||cFd,os={isArray:xun,isArrayBuffer:iFd,isBuffer:t41,isFormData:l41,isArrayBufferView:r41,isString:i41,isNumber:nFd,isBoolean:n41,isObject:Bno,isPlainObject:qno,isReadableStream:d41,isRequest:p41,isResponse:_41,isHeaders:h41,isUndefined:KGn,isDate:a41,isFile:o41,isBlob:u41,isRegExp:A41,isFunction:_we,isStream:c41,isURLSearchParams:f41,isTypedArray:j41,isFileList:s41,forEach:YGn,merge:Ips,extend:v41,trim:y41,stripBOM:b41,inherits:g41,toFlatObject:O41,kindOf:Tno,kindOfTest:a2t,endsWith:m41,toArray:P41,forEachEntry:w41,matchAll:S41,isHTMLForm:D41,hasOwnProperty:tFd,hasOwnProp:tFd,reduceDescriptors:uFd,freezeMethods:M41,toObjectSet:q41,toCamelCase:E41,noop:T41,toFiniteNumber:C41,findKey:aFd,global:$ji,isContextDefined:oFd,ALPHABET:sFd,generateString:B41,isSpecCompliantForm:x41,toJSONObject:I41,isAsyncFn:z41,isThenable:R41,setImmediate:cFd,asap:F41};function Iun(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}os.inherits(Iun,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:os.toJSONObject(this.config),code:this.code,status:this.status}}});var lFd=Iun.prototype,fFd={};["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=>{fFd[e]={value:e}});Object.defineProperties(Iun,fFd);Object.defineProperty(lFd,"isAxiosError",{value:!0});Iun.from=(e,t,r,i,n,a)=>{let u=Object.create(lFd);return os.toFlatObject(e,u,function(f){return f!==Error.prototype},l=>l!=="isAxiosError"),Iun.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var yp=Iun;var dFd=Di(CLn(),1),xno=dFd.default;function Rps(e){return os.isPlainObject(e)||os.isArray(e)}function _Fd(e){return os.endsWith(e,"[]")?e.slice(0,-2):e}function pFd(e,t,r){return e?e.concat(t).map(function(n,a){return n=_Fd(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function N41(e){return os.isArray(e)&&!e.some(Rps)}var L41=os.toFlatObject(os,{},null,function(t){return/^is[A-Z]/.test(t)});function U41(e,t,r){if(!os.isObject(e))throw new TypeError("target must be an object");t=t||new(xno||FormData),r=os.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,w){return!os.isUndefined(w[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&os.isSpecCompliantForm(t);if(!os.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(os.isDate(O))return O.toISOString();if(!f&&os.isBlob(O))throw new yp("Blob is not supported. Use a Buffer instead.");return os.isArrayBuffer(O)||os.isTypedArray(O)?f&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,w){let A=O;if(O&&!w&&typeof O=="object"){if(os.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(os.isArray(O)&&N41(O)||(os.isFileList(O)||os.endsWith(m,"[]"))&&(A=os.toArray(O)))return m=_Fd(m),A.forEach(function(q,D){!(os.isUndefined(q)||q===null)&&t.append(u===!0?pFd([m],D,a):u===null?m:m+"[]",s(q))}),!1}return Rps(O)?!0:(t.append(pFd(w,m,a),s(O)),!1)}let c=[],b=Object.assign(L41,{defaultVisitor:o,convertValue:s,isVisitable:Rps});function g(O,m){if(!os.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),os.forEach(O,function(A,M){(!(os.isUndefined(A)||A===null)&&n.call(t,A,os.isString(M)?M.trim():M,m,b))===!0&&g(A,m?m.concat(M):[M])}),c.pop()}}if(!os.isObject(e))throw new TypeError("data must be an object");return g(e),t}var tkr=U41;function hFd(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function yFd(e,t){this._pairs=[],e&&tkr(e,this,t)}var vFd=yFd.prototype;vFd.append=function(t,r){this._pairs.push([t,r])};vFd.toString=function(t){let r=t?function(i){return t.call(this,i,hFd)}:hFd;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var bFd=yFd;function V41(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Gji(e,t,r){if(!t)return e;let i=r&&r.encode||V41,n=r&&r.serialize,a;if(n?a=n(t,r):a=os.isURLSearchParams(t)?t.toString():new bFd(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Fps=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){os.forEach(this.handlers,function(i){i!==null&&t(i)})}},Nps=Fps;var zun={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var gFd=Di(require("url"),1),OFd=gFd.default.URLSearchParams;var mFd={isNode:!0,classes:{URLSearchParams:OFd,FormData:xno,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var Vps={};Ro(Vps,{hasBrowserEnv:()=>Ups,hasStandardBrowserEnv:()=>W41,hasStandardBrowserWebWorkerEnv:()=>H41,navigator:()=>Lps,origin:()=>$41});var Ups=typeof window<"u"&&typeof document<"u",Lps=typeof navigator=="object"&&navigator||void 0,W41=Ups&&(!Lps||["ReactNative","NativeScript","NS"].indexOf(Lps.product)<0),H41=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",$41=Ups&&window.location.href||"http://localhost";var sT={...Vps,...mFd};function Wps(e,t){return tkr(e,new sT.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return sT.isNode&&os.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function G41(e){return os.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Q41(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function J41(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),f=a>=r.length;return u=!u&&os.isArray(n)?n.length:u,f?(os.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!os.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&os.isArray(n[u])&&(n[u]=Q41(n[u])),!l)}if(os.isFormData(e)&&os.isFunction(e.entries)){let r={};return os.forEachEntry(e,(i,n)=>{t(G41(i),n,r,0)}),r}return null}var Ino=J41;function K41(e,t,r){if(os.isString(e))try{return(t||JSON.parse)(e),os.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var Hps={transitional:zun,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=os.isObject(t);if(a&&os.isHTMLForm(t)&&(t=new FormData(t)),os.isFormData(t))return n?JSON.stringify(Ino(t)):t;if(os.isArrayBuffer(t)||os.isBuffer(t)||os.isStream(t)||os.isFile(t)||os.isBlob(t)||os.isReadableStream(t))return t;if(os.isArrayBufferView(t))return t.buffer;if(os.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return Wps(t,this.formSerializer).toString();if((l=os.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return tkr(l?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),K41(t)):t}],transformResponse:[function(t){let r=this.transitional||Hps.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(os.isResponse(t)||os.isReadableStream(t))return t;if(t&&os.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?yp.from(l,yp.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:sT.classes.FormData,Blob:sT.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};os.forEach(["delete","get","head","post","put","patch"],e=>{Hps.headers[e]={}});var Run=Hps;var Y41=os.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"]),PFd=e=>{let t={},r,i,n;return e&&e.split(`
1687
+ `}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&&Rio(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var qzd=Di(jzd(),1),Tzd=Di(Wls(),1),Czd=Di(Azd(),1),rM=Di(dwe(),1),Bzd=Di(O$n(),1);var uno=Di(dwe(),1),Mzd=Di(O$n(),1),sno=function(e,t,r){return typeof e[t]!="function"?(0,uno.of)(e):(0,uno.from)((0,Mzd.default)(e[t])(r).then(i=>(e[t]=i,e)))};var TGn={isPlainObject:qzd.default,set:Czd.default,get:Tzd.default},jun=class extends Uji{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=TGn.isPlainObject(r)?{...r}:{},TGn.isPlainObject(t)&&(t=Object.values(t).every(n=>TGn.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,rM.from)(t):t;return this.process=i.pipe((0,rM.concatMap)(this.processQuestion.bind(this)),(0,rM.publish)()),this.process.connect(),this.process.pipe((0,rM.reduce)((n,a)=>(TGn.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,rM.defer)(()=>(0,rM.of)(t).pipe((0,rM.concatMap)(this.setDefaultType.bind(this)),(0,rM.concatMap)(this.filterIfRunnable.bind(this)),(0,rM.concatMap)(()=>sno(t,"message",this.answers)),(0,rM.concatMap)(()=>sno(t,"default",this.answers)),(0,rM.concatMap)(()=>sno(t,"choices",this.answers)),(0,rM.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,rM.defer)(()=>(0,rM.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,rM.defer)(()=>(0,rM.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&TGn.get(this.answers,t.name)!==void 0)return(0,rM.empty)();if(t.when===!1)return(0,rM.empty)();if(typeof t.when!="function")return(0,rM.of)(t);let{answers:r}=this;return(0,rM.defer)(()=>(0,rM.from)((0,Bzd.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,rM.filter)(i=>i!=null)))}};function xzd(e){let t=function(r,i){let n;try{n=new jun(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",pGn),this.registerPrompt("input",Bji),this.registerPrompt("number",_Gn),this.registerPrompt("confirm",hGn),this.registerPrompt("rawlist",yGn),this.registerPrompt("expand",vGn),this.registerPrompt("checkbox",bGn),this.registerPrompt("password",gGn),this.registerPrompt("editor",MGn)},t.restoreDefaultPrompts(),t}var Fds=xzd();function f71(e,t){Fds.registerPrompt(e,t)}function d71(){Fds.restoreDefaultPrompts()}var p71={prompt:Fds,ui:{BottomBar:qGn,Prompt:jun},createPromptModule:xzd,registerPrompt:f71,restoreDefaultPrompts:d71,Separator:yte},cno=p71;var HRd=Di(Izd()),R61="4.2.1",n2t;(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"})(n2t||(n2t={}));function F61(e,t){if(!e)throw new Error(t)}function N61(e){return e?.replace(/\/+$/,"")}async function L61(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function U61(){return new Date().getTime()}function zRd(){return new Date().toISOString()}function $Rd(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var WGn=String.fromCharCode,RRd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Pno={};function V61(e,t){if(!Pno[e]){Pno[e]={};for(let r=0;r<e.length;r++)Pno[e][e.charAt(r)]=r}return Pno[e][t]}var HGn={compressToBase64:function(e){if(e==null)return"";let t=HGn._compress(e,6,function(r){return RRd.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:HGn._decompress(e.length,32,function(t){return V61(RRd,e.charAt(t))})},compress:function(e){return HGn._compress(e,16,function(t){return WGn(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,f="",s="",o="",c=2,b=3,g=2,O=0,m=0,w;for(w=0;w<e.length;w+=1)if(f=e.charAt(w),Object.prototype.hasOwnProperty.call(i,f)||(i[f]=b++,n[f]=!0),s=o+f,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(f)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:HGn._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,f=3,s="",o,c,b,g,O,m,w;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=WGn(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=WGn(b);break;case 2:return""}for(i[3]=w,c=w,n.push(w);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,f),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(w=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=WGn(b),w=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=WGn(b),w=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,f),f++),i[w])s=i[w];else if(w===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,f),f++)}}},wps=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}};var jno="0123456789abcdef",wno=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=jno.charAt(this.bytes[r]>>>4),t+=jno.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+=jno.charAt(this.bytes[r]>>>4),t+=jno.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},Sps=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??W61()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return wno.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,wno.ofInner(t)}},W61=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),FRd,NRd=()=>H61().toString(),H61=()=>(FRd||(FRd=new Sps)).generate(),Sno=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},$Gn=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function LRd(e){return typeof e=="object"&&(e instanceof Sno||e instanceof $Gn)}var Dps=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new wps,this._isInitialized=!1,F61(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=N61(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:LRd},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(n2t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(n2t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(n2t.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=NRd();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(f=>f.json()).catch(f=>{this._events.emit("error",f)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!l)return;let f=l[t];return f===void 0&&(f=!1),f}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!l)return;let f=l[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let l=await this.getDecide(t,r,i,n,u),f=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:f,payloads:o}}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:zRd(),uuid:i?.uuid?i.uuid:NRd()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty(n2t.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty(n2t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=$Rd(()=>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(n2t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(n2t.Queue)||[];this.setPersistedProperty(n2t.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:zRd()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${U61()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,f=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(HGn.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,f)}catch(s){throw s instanceof $Gn||n(),this._events.emit("error",s),s}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(l){let f=new AbortController;return setTimeout(()=>f.abort(),l),f.signal}),await L61(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(f){throw new $Gn(f)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new Sno(u);return u},{...this._retryOptions,...i})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(n2t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!LRd(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},Eps=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},Aps=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!Aps){let e=IRd();Aps=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var GRd=Aps,$61=1152921504606847e3,G61=["is_not"],Dno=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},i2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Mps=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=l.fetch||GRd,this.onError=l.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let f of this.featureFlags)if(t===f.key){l=f;break}if(l!==void 0)try{u=this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(f){f instanceof i2?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async f=>{try{let s=this.computeFlagLocally(f,t,r,i,n);a[f.key]=s;let o=await this.computeFeatureFlagPayloadLocally(f.key,s);o&&(u[f.key]=o)}catch(s){s instanceof i2||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new i2("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let f=this.groupTypeMapping[String(l)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new i2("Flag has unknown group type index");if(!(f in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[f];return this.matchFeatureFlagProperties(t,i[f],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,f=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of f)try{if(this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof i2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new i2("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let f=l.type,s=!1;if(f==="cohort"?s=JRd(l,n,this.cohorts,this.debugMode):s=QRd(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&URd(t.key,r)>a/100)}getMatchingVariant(t,r){let i=URd(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new Dno("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof Dno&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=$Rd(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function URd(e,t,r=""){let i=(0,HRd.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/$61}function QRd(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new i2("Operator is_not_set is not supported")}else throw new i2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!G61.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function f(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return VRd(String(n))&&String(u).match(String(n))!==null;case"not_regex":return VRd(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?f(u,String(n),a):f(u,s,a):f(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=Q61(String(n));if(s==null&&(s=WRd(n)),s==null)throw new i2(`Invalid date: ${n}`);let o=WRd(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new i2(`Unknown operator: ${a}`)}}function JRd(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new i2("can't match cohort without a given cohort property value");let a=r[n];return KRd(a,t,r,i)}function KRd(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let f=KRd(l,t,r,i);if(n==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof i2)i&&console.debug(`Failed to compute property ${l} locally: ${f}`),u=!0;else throw f}if(u)throw new i2("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let f;l.type==="cohort"?f=JRd(l,t,r,i):f=QRd(l,t);let s=l.negation||!1;if(n==="AND"){if(!f&&!s||f&&s)return!1}else if(f&&!s||!f&&s)return!0}catch(f){if(f instanceof i2)i&&console.debug(`Failed to compute property ${l} locally: ${f}`),u=!0;else throw f}if(u)throw new i2("can't match cohort without a given cohort property value");return n==="AND"}}function VRd(e){try{return new RegExp(e),!0}catch{return!1}}function WRd(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 i2(`${e} is in an invalid date format`)}else throw new i2(`The date provided ${e} must be a string, number, or date object`)}function Q61(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var J61=30*1e3,K61=50*1e3,qun=class extends Dps{constructor(t,r={}){super(t,r),this._memoryStorage=new Eps,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new Mps({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:J61,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||K61}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):GRd(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return R61}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture({distinctId:t,event:r,properties:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:l,uuid:f}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:f})},o=(b,g,O)=>super.getFeatureFlagsStateless(b,g,void 0,void 0,O),c=Promise.resolve().then(async()=>{if(a)return await o(t,n,l);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let b={};for(let[g,O]of Object.entries(n||{}))b[g]=String(O);return await this.getAllFlags(t,{groups:b,disableGeoip:l,onlyEvaluateLocally:!0})}return{}}).then(b=>{let g={};if(b)for(let[m,w]of Object.entries(b))g[`$feature/${m}`]=w;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:f,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,f,s);f=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,f,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,f,s,a));let g=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(g))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(g):this.distinctIdHasSentFlagCalls[r]=[g],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,locally_evaluated:b,[`$feature/${t}`]:c},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:f,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),l==null&&(l=!1),f==null&&(f=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},f=this.addLocalPersonAndGroupProperties(t,i,u,l);u=f.allPersonProperties,l=f.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},qps=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},l=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&l!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${l}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};qps.POSTHOG_ID_TAG="posthog_distinct_id";var Eno=class{posthog;constructor({posthogApiKey:t}){this.posthog=new qun(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.51.28",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var GGn=class{async sendEvent(){}async identify(){}async flush(){}};var Tun=require("fs/promises"),kRd=require("os"),eFd=require("path");var YRd=Di(require("crypto")),Mno=new Uint8Array(256),Ano=Mno.length;function Tps(){return Ano>Mno.length-16&&(YRd.default.randomFillSync(Mno),Ano=0),Mno.slice(Ano,Ano+=16)}var xL=[];for(let e=0;e<256;++e)xL.push((e+256).toString(16).slice(1));function XRd(e,t=0){return xL[e[t+0]]+xL[e[t+1]]+xL[e[t+2]]+xL[e[t+3]]+"-"+xL[e[t+4]]+xL[e[t+5]]+"-"+xL[e[t+6]]+xL[e[t+7]]+"-"+xL[e[t+8]]+xL[e[t+9]]+"-"+xL[e[t+10]]+xL[e[t+11]]+xL[e[t+12]]+xL[e[t+13]]+xL[e[t+14]]+xL[e[t+15]]}var ZRd=Di(require("crypto")),Cps={randomUUID:ZRd.default.randomUUID};function Y61(e,t,r){if(Cps.randomUUID&&!t&&!e)return Cps.randomUUID();e=e||{};let i=e.random||(e.rng||Tps)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return XRd(i)}var ZCe=Y61;var X61="id",Z61=".fern",QGn=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new qun(r),this.userId=t==null?void 0:Yas(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.51.28",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=ku(Kl.of((0,kRd.homedir)()),yo.of(Z61),yo.of(X61));await zf(t)||(await(0,Tun.mkdir)((0,eFd.dirname)(t),{recursive:!0}),await(0,Tun.writeFile)(t,ZCe())),this.persistedDistinctId=(await(0,Tun.readFile)(t)).toString()}return this.persistedDistinctId}};var Bps;async function Cun(){return Bps==null&&(Bps=await k61()),Bps}async function k61(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new GGn;let r=await LXa();return r!=null?new QGn({token:r,posthogApiKey:e}):await NXa()!=null?new Eno({posthogApiKey:e}):new QGn({token:void 0,posthogApiKey:e})}catch{return new GGn}}function JGn(e,t){return function(){return e.apply(t,arguments)}}var{toString:e41}=Object.prototype,{getPrototypeOf:zps}=Object,Tno=(e=>t=>{let r=e41.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),a2t=e=>(e=e.toLowerCase(),t=>Tno(t)===e),Cno=e=>t=>typeof t===e,{isArray:xun}=Array,KGn=Cno("undefined");function t41(e){return e!==null&&!KGn(e)&&e.constructor!==null&&!KGn(e.constructor)&&_we(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var iFd=a2t("ArrayBuffer");function r41(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&iFd(e.buffer),t}var i41=Cno("string"),_we=Cno("function"),nFd=Cno("number"),Bno=e=>e!==null&&typeof e=="object",n41=e=>e===!0||e===!1,qno=e=>{if(Tno(e)!=="object")return!1;let t=zps(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},a41=a2t("Date"),o41=a2t("File"),u41=a2t("Blob"),s41=a2t("FileList"),c41=e=>Bno(e)&&_we(e.pipe),l41=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||_we(e.append)&&((t=Tno(e))==="formdata"||t==="object"&&_we(e.toString)&&e.toString()==="[object FormData]"))},f41=a2t("URLSearchParams"),[d41,p41,_41,h41]=["ReadableStream","Request","Response","Headers"].map(a2t),y41=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function YGn(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),xun(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function aFd(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var $ji=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,oFd=e=>!KGn(e)&&e!==$ji;function Ips(){let{caseless:e}=oFd(this)&&this||{},t={},r=(i,n)=>{let a=e&&aFd(t,n)||n;qno(t[a])&&qno(i)?t[a]=Ips(t[a],i):qno(i)?t[a]=Ips({},i):xun(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&YGn(arguments[i],r);return t}var v41=(e,t,r,{allOwnKeys:i}={})=>(YGn(t,(n,a)=>{r&&_we(n)?e[a]=JGn(n,r):e[a]=n},{allOwnKeys:i}),e),b41=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),g41=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},O41=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&zps(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},m41=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},P41=e=>{if(!e)return null;if(xun(e))return e;let t=e.length;if(!nFd(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},j41=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&zps(Uint8Array)),w41=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},S41=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},D41=a2t("HTMLFormElement"),E41=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),tFd=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),A41=a2t("RegExp"),uFd=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};YGn(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},M41=e=>{uFd(e,(t,r)=>{if(_we(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(_we(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},q41=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return xun(e)?i(e):i(String(e).split(t)),r},T41=()=>{},C41=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,xps="abcdefghijklmnopqrstuvwxyz",rFd="0123456789",sFd={DIGIT:rFd,ALPHA:xps,ALPHA_DIGIT:xps+xps.toUpperCase()+rFd},B41=(e=16,t=sFd.ALPHA_DIGIT)=>{let r="",{length:i}=t;for(;e--;)r+=t[Math.random()*i|0];return r};function x41(e){return!!(e&&_we(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var I41=e=>{let t=new Array(10),r=(i,n)=>{if(Bno(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=xun(i)?[]:{};return YGn(i,(u,l)=>{let f=r(u,n+1);!KGn(f)&&(a[l]=f)}),t[n]=void 0,a}}return i};return r(e,0)},z41=a2t("AsyncFunction"),R41=e=>e&&(Bno(e)||_we(e))&&_we(e.then)&&_we(e.catch),cFd=((e,t)=>e?setImmediate:t?((r,i)=>($ji.addEventListener("message",({source:n,data:a})=>{n===$ji&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),$ji.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",_we($ji.postMessage)),F41=typeof queueMicrotask<"u"?queueMicrotask.bind($ji):typeof process<"u"&&process.nextTick||cFd,os={isArray:xun,isArrayBuffer:iFd,isBuffer:t41,isFormData:l41,isArrayBufferView:r41,isString:i41,isNumber:nFd,isBoolean:n41,isObject:Bno,isPlainObject:qno,isReadableStream:d41,isRequest:p41,isResponse:_41,isHeaders:h41,isUndefined:KGn,isDate:a41,isFile:o41,isBlob:u41,isRegExp:A41,isFunction:_we,isStream:c41,isURLSearchParams:f41,isTypedArray:j41,isFileList:s41,forEach:YGn,merge:Ips,extend:v41,trim:y41,stripBOM:b41,inherits:g41,toFlatObject:O41,kindOf:Tno,kindOfTest:a2t,endsWith:m41,toArray:P41,forEachEntry:w41,matchAll:S41,isHTMLForm:D41,hasOwnProperty:tFd,hasOwnProp:tFd,reduceDescriptors:uFd,freezeMethods:M41,toObjectSet:q41,toCamelCase:E41,noop:T41,toFiniteNumber:C41,findKey:aFd,global:$ji,isContextDefined:oFd,ALPHABET:sFd,generateString:B41,isSpecCompliantForm:x41,toJSONObject:I41,isAsyncFn:z41,isThenable:R41,setImmediate:cFd,asap:F41};function Iun(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}os.inherits(Iun,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:os.toJSONObject(this.config),code:this.code,status:this.status}}});var lFd=Iun.prototype,fFd={};["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=>{fFd[e]={value:e}});Object.defineProperties(Iun,fFd);Object.defineProperty(lFd,"isAxiosError",{value:!0});Iun.from=(e,t,r,i,n,a)=>{let u=Object.create(lFd);return os.toFlatObject(e,u,function(f){return f!==Error.prototype},l=>l!=="isAxiosError"),Iun.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var yp=Iun;var dFd=Di(CLn(),1),xno=dFd.default;function Rps(e){return os.isPlainObject(e)||os.isArray(e)}function _Fd(e){return os.endsWith(e,"[]")?e.slice(0,-2):e}function pFd(e,t,r){return e?e.concat(t).map(function(n,a){return n=_Fd(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function N41(e){return os.isArray(e)&&!e.some(Rps)}var L41=os.toFlatObject(os,{},null,function(t){return/^is[A-Z]/.test(t)});function U41(e,t,r){if(!os.isObject(e))throw new TypeError("target must be an object");t=t||new(xno||FormData),r=os.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,w){return!os.isUndefined(w[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&os.isSpecCompliantForm(t);if(!os.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(os.isDate(O))return O.toISOString();if(!f&&os.isBlob(O))throw new yp("Blob is not supported. Use a Buffer instead.");return os.isArrayBuffer(O)||os.isTypedArray(O)?f&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,w){let A=O;if(O&&!w&&typeof O=="object"){if(os.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(os.isArray(O)&&N41(O)||(os.isFileList(O)||os.endsWith(m,"[]"))&&(A=os.toArray(O)))return m=_Fd(m),A.forEach(function(q,D){!(os.isUndefined(q)||q===null)&&t.append(u===!0?pFd([m],D,a):u===null?m:m+"[]",s(q))}),!1}return Rps(O)?!0:(t.append(pFd(w,m,a),s(O)),!1)}let c=[],b=Object.assign(L41,{defaultVisitor:o,convertValue:s,isVisitable:Rps});function g(O,m){if(!os.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),os.forEach(O,function(A,M){(!(os.isUndefined(A)||A===null)&&n.call(t,A,os.isString(M)?M.trim():M,m,b))===!0&&g(A,m?m.concat(M):[M])}),c.pop()}}if(!os.isObject(e))throw new TypeError("data must be an object");return g(e),t}var tkr=U41;function hFd(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function yFd(e,t){this._pairs=[],e&&tkr(e,this,t)}var vFd=yFd.prototype;vFd.append=function(t,r){this._pairs.push([t,r])};vFd.toString=function(t){let r=t?function(i){return t.call(this,i,hFd)}:hFd;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var bFd=yFd;function V41(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Gji(e,t,r){if(!t)return e;let i=r&&r.encode||V41,n=r&&r.serialize,a;if(n?a=n(t,r):a=os.isURLSearchParams(t)?t.toString():new bFd(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Fps=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){os.forEach(this.handlers,function(i){i!==null&&t(i)})}},Nps=Fps;var zun={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var gFd=Di(require("url"),1),OFd=gFd.default.URLSearchParams;var mFd={isNode:!0,classes:{URLSearchParams:OFd,FormData:xno,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var Vps={};Ro(Vps,{hasBrowserEnv:()=>Ups,hasStandardBrowserEnv:()=>W41,hasStandardBrowserWebWorkerEnv:()=>H41,navigator:()=>Lps,origin:()=>$41});var Ups=typeof window<"u"&&typeof document<"u",Lps=typeof navigator=="object"&&navigator||void 0,W41=Ups&&(!Lps||["ReactNative","NativeScript","NS"].indexOf(Lps.product)<0),H41=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",$41=Ups&&window.location.href||"http://localhost";var sT={...Vps,...mFd};function Wps(e,t){return tkr(e,new sT.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return sT.isNode&&os.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function G41(e){return os.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Q41(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function J41(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),f=a>=r.length;return u=!u&&os.isArray(n)?n.length:u,f?(os.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!os.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&os.isArray(n[u])&&(n[u]=Q41(n[u])),!l)}if(os.isFormData(e)&&os.isFunction(e.entries)){let r={};return os.forEachEntry(e,(i,n)=>{t(G41(i),n,r,0)}),r}return null}var Ino=J41;function K41(e,t,r){if(os.isString(e))try{return(t||JSON.parse)(e),os.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var Hps={transitional:zun,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=os.isObject(t);if(a&&os.isHTMLForm(t)&&(t=new FormData(t)),os.isFormData(t))return n?JSON.stringify(Ino(t)):t;if(os.isArrayBuffer(t)||os.isBuffer(t)||os.isStream(t)||os.isFile(t)||os.isBlob(t)||os.isReadableStream(t))return t;if(os.isArrayBufferView(t))return t.buffer;if(os.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return Wps(t,this.formSerializer).toString();if((l=os.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return tkr(l?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),K41(t)):t}],transformResponse:[function(t){let r=this.transitional||Hps.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(os.isResponse(t)||os.isReadableStream(t))return t;if(t&&os.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?yp.from(l,yp.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:sT.classes.FormData,Blob:sT.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};os.forEach(["delete","get","head","post","put","patch"],e=>{Hps.headers[e]={}});var Run=Hps;var Y41=os.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"]),PFd=e=>{let t={},r,i,n;return e&&e.split(`
1688
1688
  `).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&Y41[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var jFd=Symbol("internals");function XGn(e){return e&&String(e).trim().toLowerCase()}function zno(e){return e===!1||e==null?e:os.isArray(e)?e.map(zno):String(e)}function X41(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,i;for(;i=r.exec(e);)t[i[1]]=i[2];return t}var Z41=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function $ps(e,t,r,i,n){if(os.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!os.isString(t)){if(os.isString(i))return t.indexOf(i)!==-1;if(os.isRegExp(i))return i.test(t)}}function k41(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function e81(e,t){let r=os.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,u){return this[i].call(this,t,n,a,u)},configurable:!0})})}var Fun=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(l,f,s){let o=XGn(f);if(!o)throw new Error("header name must be a non-empty string");let c=os.findKey(n,o);(!c||n[c]===void 0||s===!0||s===void 0&&n[c]!==!1)&&(n[c||f]=zno(l))}let u=(l,f)=>os.forEach(l,(s,o)=>a(s,o,f));if(os.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(os.isString(t)&&(t=t.trim())&&!Z41(t))u(PFd(t),r);else if(os.isHeaders(t))for(let[l,f]of t.entries())a(f,l,i);else t!=null&&a(r,t,i);return this}get(t,r){if(t=XGn(t),t){let i=os.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return X41(n);if(os.isFunction(r))return r.call(this,n,i);if(os.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=XGn(t),t){let i=os.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||$ps(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=XGn(u),u){let l=os.findKey(i,u);l&&(!r||$ps(i,i[l],l,r))&&(delete i[l],n=!0)}}return os.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||$ps(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return os.forEach(this,(n,a)=>{let u=os.findKey(i,a);if(u){r[u]=zno(n),delete r[a];return}let l=t?k41(a):String(a).trim();l!==a&&delete r[a],r[l]=zno(n),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return os.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&os.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
1689
1689
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[jFd]=this[jFd]={accessors:{}}).accessors,n=this.prototype;function a(u){let l=XGn(u);i[l]||(e81(n,u),i[l]=!0)}return os.isArray(t)?t.forEach(a):a(t),this}};Fun.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);os.reduceDescriptors(Fun.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});os.freezeMethods(Fun);var sI=Fun;function ZGn(e,t){let r=this||Run,i=t||r,n=sI.from(i.headers),a=i.data;return os.forEach(e,function(l){a=l.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function kGn(e){return!!(e&&e.__CANCEL__)}function wFd(e,t,r){yp.call(this,e??"canceled",yp.ERR_CANCELED,t,r),this.name="CanceledError"}os.inherits(wFd,yp,{__CANCEL__:!0});var hwe=wFd;function hGt(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new yp("Request failed with status code "+r.status,[yp.ERR_BAD_REQUEST,yp.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Gps(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Qps(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Qji(e,t){return e&&!Gps(t)?Qps(e,t):t}var LFd=Di(BGn(),1),UFd=Di(require("http"),1),VFd=Di(require("https"),1),WFd=Di(require("util"),1),HFd=Di(Zds(),1),R4r=Di(require("zlib"),1);var Jji="1.7.7";function eQn(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var t81=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function Jps(e,t,r){let i=r&&r.Blob||sT.classes.Blob,n=eQn(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=t81.exec(e);if(!a)throw new yp("Invalid URL",yp.ERR_INVALID_URL);let u=a[1],l=a[2],f=a[3],s=Buffer.from(decodeURIComponent(f),l?"base64":"utf8");if(t){if(!i)throw new yp("Blob is not supported",yp.ERR_NOT_SUPPORT);return new i([s],{type:u})}return s}throw new yp("Unsupported protocol "+n,yp.ERR_NOT_SUPPORT)}var Kji=Di(require("stream"),1);var SFd=Di(require("stream"),1);var Kps=Symbol("internals"),Yps=class extends SFd.default.Transform{constructor(t){t=os.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!os.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[Kps]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",i=>{i==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[Kps];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[Kps],a=n.maxRate,u=this.readableHighWaterMark,l=n.timeWindow,f=1e3/l,s=a/f,o=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,c=(g,O)=>{let m=Buffer.byteLength(g);n.bytesSeen+=m,n.bytes+=m,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(g)?process.nextTick(O):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(O)}},b=(g,O)=>{let m=Buffer.byteLength(g),w=null,A=u,M,q=0;if(a){let D=Date.now();(!n.ts||(q=D-n.ts)>=l)&&(n.ts=D,M=s-n.bytes,n.bytes=M<0?-M:0,q=0),M=s-n.bytes}if(a){if(M<=0)return setTimeout(()=>{O(null,g)},l-q);M<A&&(A=M)}A&&m>A&&m-A>o&&(w=g.subarray(A),g=g.subarray(0,A)),c(g,w?()=>{process.nextTick(O,null,w)}:O)};b(t,function g(O,m){if(O)return i(O);m?b(m,g):i(null)})}},Xps=Yps;var $Fd=require("events");var EFd=require("util"),AFd=require("stream");var{asyncIterator:DFd}=Symbol,r81=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[DFd]?yield*e[DFd]():yield e},Rno=r81;var i81=os.ALPHABET.ALPHA_DIGIT+"-_",tQn=new EFd.TextEncoder,rkr=`\r
1690
1690
  `,n81=tQn.encode(rkr),a81=2,Zps=class{constructor(t,r){let{escapeName:i}=this.constructor,n=os.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${rkr}`;n?r=tQn.encode(String(r).replace(/\r?\n|\r\n?/g,rkr)):a+=`Content-Type: ${r.type||"application/octet-stream"}${rkr}`,this.headers=tQn.encode(a+rkr),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+a81,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;os.isTypedArray(t)?yield t:yield*Rno(t),yield n81}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},o81=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+os.generateString(n,i81)}=r||{};if(!os.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=tQn.encode("--"+a+rkr),l=tQn.encode("--"+a+"--"+rkr+rkr),f=l.byteLength,s=Array.from(e.entries()).map(([c,b])=>{let g=new Zps(c,b);return f+=g.size,g});f+=u.byteLength*s.length,f=os.toFiniteNumber(f);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(o["Content-Length"]=f),t&&t(o),AFd.Readable.from(async function*(){for(let c of s)yield u,yield*c.encode();yield l}())},MFd=o81;var qFd=Di(require("stream"),1),kps=class extends qFd.default.Transform{__transform(t,r,i){this.push(t),i()}_transform(t,r,i){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let n=Buffer.alloc(2);n[0]=120,n[1]=156,this.push(n,r)}this.__transform(t,r,i)}},TFd=kps;var u81=(e,t)=>os.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,CFd=u81;function s81(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,u;return t=t!==void 0?t:1e3,function(f){let s=Date.now(),o=i[a];u||(u=s),r[n]=f,i[n]=s;let c=a,b=0;for(;c!==n;)b+=r[c++],c=c%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-u<t)return;let g=o&&s-o;return g?Math.round(b*1e3/g):void 0}}var BFd=s81;function c81(e,t){let r=0,i=1e3/t,n,a,u=(s,o=Date.now())=>{r=o,n=null,a&&(clearTimeout(a),a=null),e.apply(null,s)};return[(...s)=>{let o=Date.now(),c=o-r;c>=i?u(s,o):(n=s,a||(a=setTimeout(()=>{a=null,u(n)},i-c)))},()=>n&&u(n)]}var xFd=c81;var z4r=(e,t,r=3)=>{let i=0,n=BFd(50,250);return xFd(a=>{let u=a.loaded,l=a.lengthComputable?a.total:void 0,f=u-i,s=n(f),o=u<=l;i=u;let c={loaded:u,total:l,progress:l?u/l:void 0,bytes:f,rate:s||void 0,estimated:s&&l&&o?(l-u)/s:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(c)},r)},Nun=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},Lun=e=>(...t)=>os.asap(()=>e(...t));var IFd={flush:R4r.default.constants.Z_SYNC_FLUSH,finishFlush:R4r.default.constants.Z_SYNC_FLUSH},l81={flush:R4r.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:R4r.default.constants.BROTLI_OPERATION_FLUSH},zFd=os.isFunction(R4r.default.createBrotliDecompress),{http:f81,https:d81}=HFd.default,p81=/https:?/,RFd=sT.protocols.map(e=>e+":"),FFd=(e,[t,r])=>(e.on("end",r).on("error",r),t);function _81(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function GFd(e,t,r){let i=t;if(!i&&i!==!1){let n=(0,LFd.getProxyForUrl)(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){GFd(a,t,a.href)}}var h81=typeof process<"u"&&os.kindOf(process)==="process",y81=e=>new Promise((t,r)=>{let i,n,a=(f,s)=>{n||(n=!0,i&&i(f,s))},u=f=>{a(f),t(f)},l=f=>{a(f,!0),r(f)};e(u,l,f=>i=f).catch(l)}),v81=({address:e,family:t})=>{if(!os.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},NFd=(e,t)=>v81(os.isObject(e)?e:{address:e,family:t}),QFd=h81&&function(t){return y81(async function(i,n,a){let{data:u,lookup:l,family:f}=t,{responseType:s,responseEncoding:o}=t,c=t.method.toUpperCase(),b,g=!1,O;if(l){let we=CFd(l,Xe=>os.isArray(Xe)?Xe:[Xe]);l=(Xe,Mt,De)=>{we(Xe,Mt,(Te,It,Ee)=>{if(Te)return De(Te);let St=os.isArray(It)?It.map(ut=>NFd(ut)):[NFd(It,Ee)];Mt.all?De(Te,St):De(Te,St[0].address,St[0].family)})}}let m=new $Fd.EventEmitter,w=()=>{t.cancelToken&&t.cancelToken.unsubscribe(A),t.signal&&t.signal.removeEventListener("abort",A),m.removeAllListeners()};a((we,Xe)=>{b=!0,Xe&&(g=!0,w())});function A(we){m.emit("abort",!we||we.type?new hwe(null,t,O):we)}m.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(A),t.signal&&(t.signal.aborted?A():t.signal.addEventListener("abort",A)));let M=Qji(t.baseURL,t.url),q=new URL(M,sT.hasBrowserEnv?sT.origin:void 0),D=q.protocol||RFd[0];if(D==="data:"){let we;if(c!=="GET")return hGt(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{we=Jps(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Xe){throw yp.from(Xe,yp.ERR_BAD_REQUEST,t)}return s==="text"?(we=we.toString(o),(!o||o==="utf8")&&(we=os.stripBOM(we))):s==="stream"&&(we=Kji.default.Readable.from(we)),hGt(i,n,{data:we,status:200,statusText:"OK",headers:new sI,config:t})}if(RFd.indexOf(D)===-1)return n(new yp("Unsupported protocol "+D,yp.ERR_BAD_REQUEST,t));let C=sI.from(t.headers).normalize();C.set("User-Agent","axios/"+Jji,!1);let{onUploadProgress:R,onDownloadProgress:$}=t,I=t.maxRate,U,H;if(os.isSpecCompliantForm(u)){let we=C.getContentType(/boundary=([-_\w\d]{10,70})/i);u=MFd(u,Xe=>{C.set(Xe)},{tag:`axios-${Jji}-boundary`,boundary:we&&we[1]||void 0})}else if(os.isFormData(u)&&os.isFunction(u.getHeaders)){if(C.set(u.getHeaders()),!C.hasContentLength())try{let we=await WFd.default.promisify(u.getLength).call(u);Number.isFinite(we)&&we>=0&&C.setContentLength(we)}catch{}}else if(os.isBlob(u))u.size&&C.setContentType(u.type||"application/octet-stream"),C.setContentLength(u.size||0),u=Kji.default.Readable.from(Rno(u));else if(u&&!os.isStream(u)){if(!Buffer.isBuffer(u))if(os.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(os.isString(u))u=Buffer.from(u,"utf-8");else return n(new yp("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",yp.ERR_BAD_REQUEST,t));if(C.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new yp("Request body larger than maxBodyLength limit",yp.ERR_BAD_REQUEST,t))}let te=os.toFiniteNumber(C.getContentLength());os.isArray(I)?(U=I[0],H=I[1]):U=H=I,u&&(R||U)&&(os.isStream(u)||(u=Kji.default.Readable.from(u,{objectMode:!1})),u=Kji.default.pipeline([u,new Xps({maxRate:os.toFiniteNumber(U)})],os.noop),R&&u.on("progress",FFd(u,Nun(te,z4r(Lun(R),!1,3)))));let J;if(t.auth){let we=t.auth.username||"",Xe=t.auth.password||"";J=we+":"+Xe}if(!J&&q.username){let we=q.username,Xe=q.password;J=we+":"+Xe}J&&C.delete("authorization");let ee;try{ee=Gji(q.pathname+q.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(we){let Xe=new Error(we.message);return Xe.config=t,Xe.url=t.url,Xe.exists=!0,n(Xe)}C.set("Accept-Encoding","gzip, compress, deflate"+(zFd?", br":""),!1);let fe={path:ee,method:c,headers:C.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:J,protocol:D,family:f,beforeRedirect:_81,beforeRedirects:{}};!os.isUndefined(l)&&(fe.lookup=l),t.socketPath?fe.socketPath=t.socketPath:(fe.hostname=q.hostname.startsWith("[")?q.hostname.slice(1,-1):q.hostname,fe.port=q.port,GFd(fe,t.proxy,D+"//"+q.hostname+(q.port?":"+q.port:"")+fe.path));let me,ve=p81.test(fe.protocol);if(fe.agent=ve?t.httpsAgent:t.httpAgent,t.transport?me=t.transport:t.maxRedirects===0?me=ve?VFd.default:UFd.default:(t.maxRedirects&&(fe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(fe.beforeRedirects.config=t.beforeRedirect),me=ve?d81:f81),t.maxBodyLength>-1?fe.maxBodyLength=t.maxBodyLength:fe.maxBodyLength=1/0,t.insecureHTTPParser&&(fe.insecureHTTPParser=t.insecureHTTPParser),O=me.request(fe,function(Xe){if(O.destroyed)return;let Mt=[Xe],De=+Xe.headers["content-length"];if($||H){let ut=new Xps({maxRate:os.toFiniteNumber(H)});$&&ut.on("progress",FFd(ut,Nun(De,z4r(Lun($),!0,3)))),Mt.push(ut)}let Te=Xe,It=Xe.req||O;if(t.decompress!==!1&&Xe.headers["content-encoding"])switch((c==="HEAD"||Xe.statusCode===204)&&delete Xe.headers["content-encoding"],(Xe.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":Mt.push(R4r.default.createUnzip(IFd)),delete Xe.headers["content-encoding"];break;case"deflate":Mt.push(new TFd),Mt.push(R4r.default.createUnzip(IFd)),delete Xe.headers["content-encoding"];break;case"br":zFd&&(Mt.push(R4r.default.createBrotliDecompress(l81)),delete Xe.headers["content-encoding"])}Te=Mt.length>1?Kji.default.pipeline(Mt,os.noop):Mt[0];let Ee=Kji.default.finished(Te,()=>{Ee(),w()}),St={status:Xe.statusCode,statusText:Xe.statusMessage,headers:new sI(Xe.headers),config:t,request:It};if(s==="stream")St.data=Te,hGt(i,n,St);else{let ut=[],ge=0;Te.on("data",function(wt){ut.push(wt),ge+=wt.length,t.maxContentLength>-1&&ge>t.maxContentLength&&(g=!0,Te.destroy(),n(new yp("maxContentLength size of "+t.maxContentLength+" exceeded",yp.ERR_BAD_RESPONSE,t,It)))}),Te.on("aborted",function(){if(g)return;let wt=new yp("maxContentLength size of "+t.maxContentLength+" exceeded",yp.ERR_BAD_RESPONSE,t,It);Te.destroy(wt),n(wt)}),Te.on("error",function(wt){O.destroyed||n(yp.from(wt,null,t,It))}),Te.on("end",function(){try{let wt=ut.length===1?ut[0]:Buffer.concat(ut);s!=="arraybuffer"&&(wt=wt.toString(o),(!o||o==="utf8")&&(wt=os.stripBOM(wt))),St.data=wt}catch(wt){return n(yp.from(wt,null,t,St.request,St))}hGt(i,n,St)})}m.once("abort",ut=>{Te.destroyed||(Te.emit("error",ut),Te.destroy())})}),m.once("abort",we=>{n(we),O.destroy(we)}),O.on("error",function(Xe){n(yp.from(Xe,null,t,O))}),O.on("socket",function(Xe){Xe.setKeepAlive(!0,1e3*60)}),t.timeout){let we=parseInt(t.timeout,10);if(Number.isNaN(we)){n(new yp("error trying to parse `config.timeout` to int",yp.ERR_BAD_OPTION_VALUE,t,O));return}O.setTimeout(we,function(){if(b)return;let Mt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",De=t.transitional||zun;t.timeoutErrorMessage&&(Mt=t.timeoutErrorMessage),n(new yp(Mt,De.clarifyTimeoutError?yp.ETIMEDOUT:yp.ECONNABORTED,t,O)),A()})}if(os.isStream(u)){let we=!1,Xe=!1;u.on("end",()=>{we=!0}),u.once("error",Mt=>{Xe=!0,O.destroy(Mt)}),u.on("close",()=>{!we&&!Xe&&A(new hwe("Request stream has been aborted",t,O))}),u.pipe(O)}else O.end(u)})};var JFd=sT.hasStandardBrowserEnv?function(){let t=sT.navigator&&/(msie|trident)/i.test(sT.navigator.userAgent),r=document.createElement("a"),i;function n(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 i=n(window.location.href),function(u){let l=os.isString(u)?n(u):u;return l.protocol===i.protocol&&l.host===i.host}}():function(){return function(){return!0}}();var KFd=sT.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];os.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),os.isString(i)&&u.push("path="+i),os.isString(n)&&u.push("domain="+n),a===!0&&u.push("secure"),document.cookie=u.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var YFd=e=>e instanceof sI?{...e}:e;function o2t(e,t){t=t||{};let r={};function i(s,o,c){return os.isPlainObject(s)&&os.isPlainObject(o)?os.merge.call({caseless:c},s,o):os.isPlainObject(o)?os.merge({},o):os.isArray(o)?o.slice():o}function n(s,o,c){if(os.isUndefined(o)){if(!os.isUndefined(s))return i(void 0,s,c)}else return i(s,o,c)}function a(s,o){if(!os.isUndefined(o))return i(void 0,o)}function u(s,o){if(os.isUndefined(o)){if(!os.isUndefined(s))return i(void 0,s)}else return i(void 0,o)}function l(s,o,c){if(c in t)return i(s,o);if(c in e)return i(void 0,s)}let f={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:l,headers:(s,o)=>n(YFd(s),YFd(o),!0)};return os.forEach(Object.keys(Object.assign({},e,t)),function(o){let c=f[o]||n,b=c(e[o],t[o],o);os.isUndefined(b)&&c!==l||(r[o]=b)}),r}var Fno=e=>{let t=o2t({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:l}=t;t.headers=u=sI.from(u),t.url=Gji(Qji(t.baseURL,t.url),e.params,e.paramsSerializer),l&&u.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let f;if(os.isFormData(r)){if(sT.hasStandardBrowserEnv||sT.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((f=u.getContentType())!==!1){let[s,...o]=f?f.split(";").map(c=>c.trim()).filter(Boolean):[];u.setContentType([s||"multipart/form-data",...o].join("; "))}}if(sT.hasStandardBrowserEnv&&(i&&os.isFunction(i)&&(i=i(t)),i||i!==!1&&JFd(t.url))){let s=n&&a&&KFd.read(a);s&&u.set(n,s)}return t};var b81=typeof XMLHttpRequest<"u",XFd=b81&&function(e){return new Promise(function(r,i){let n=Fno(e),a=n.data,u=sI.from(n.headers).normalize(),{responseType:l,onUploadProgress:f,onDownloadProgress:s}=n,o,c,b,g,O;function m(){g&&g(),O&&O(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let w=new XMLHttpRequest;w.open(n.method.toUpperCase(),n.url,!0),w.timeout=n.timeout;function A(){if(!w)return;let q=sI.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),C={data:!l||l==="text"||l==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:q,config:e,request:w};hGt(function($){r($),m()},function($){i($),m()},C),w=null}"onloadend"in w?w.onloadend=A:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(A)},w.onabort=function(){w&&(i(new yp("Request aborted",yp.ECONNABORTED,e,w)),w=null)},w.onerror=function(){i(new yp("Network Error",yp.ERR_NETWORK,e,w)),w=null},w.ontimeout=function(){let D=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",C=n.transitional||zun;n.timeoutErrorMessage&&(D=n.timeoutErrorMessage),i(new yp(D,C.clarifyTimeoutError?yp.ETIMEDOUT:yp.ECONNABORTED,e,w)),w=null},a===void 0&&u.setContentType(null),"setRequestHeader"in w&&os.forEach(u.toJSON(),function(D,C){w.setRequestHeader(C,D)}),os.isUndefined(n.withCredentials)||(w.withCredentials=!!n.withCredentials),l&&l!=="json"&&(w.responseType=n.responseType),s&&([b,O]=z4r(s,!0),w.addEventListener("progress",b)),f&&w.upload&&([c,g]=z4r(f),w.upload.addEventListener("progress",c),w.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(o=q=>{w&&(i(!q||q.type?new hwe(null,e,w):q),w.abort(),w=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let M=eQn(n.url);if(M&&sT.protocols.indexOf(M)===-1){i(new yp("Unsupported protocol "+M+":",yp.ERR_BAD_REQUEST,e));return}w.send(a||null)})};var g81=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,l();let o=s instanceof Error?s:this.reason;i.abort(o instanceof yp?o:new hwe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new yp(`timeout ${t} of ms exceeded`,yp.ETIMEDOUT))},t),l=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:f}=i;return f.unsubscribe=()=>os.asap(l),f}},ZFd=g81;var O81=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let i=0,n;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},m81=async function*(e,t){for await(let r of P81(e))yield*O81(r,t)},P81=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:i}=await t.read();if(r)break;yield i}}finally{await t.cancel()}},e_s=(e,t,r,i)=>{let n=m81(e,t),a=0,u,l=f=>{u||(u=!0,i&&i(f))};return new ReadableStream({async pull(f){try{let{done:s,value:o}=await n.next();if(s){l(),f.close();return}let c=o.byteLength;if(r){let b=a+=c;r(b)}f.enqueue(new Uint8Array(o))}catch(s){throw l(s),s}},cancel(f){return l(f),n.return()}},{highWaterMark:2})};var Lno=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",eNd=Lno&&typeof ReadableStream=="function",j81=Lno&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),tNd=(e,...t)=>{try{return!!e(...t)}catch{return!1}},w81=eNd&&tNd(()=>{let e=!1,t=new Request(sT.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),kFd=64*1024,t_s=eNd&&tNd(()=>os.isReadableStream(new Response("").body)),Nno={stream:t_s&&(e=>e.body)};Lno&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Nno[t]&&(Nno[t]=os.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new yp(`Response type '${t}' is not supported`,yp.ERR_NOT_SUPPORT,i)})})})(new Response);var S81=async e=>{if(e==null)return 0;if(os.isBlob(e))return e.size;if(os.isSpecCompliantForm(e))return(await new Request(sT.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(os.isArrayBufferView(e)||os.isArrayBuffer(e))return e.byteLength;if(os.isURLSearchParams(e)&&(e=e+""),os.isString(e))return(await j81(e)).byteLength},D81=async(e,t)=>{let r=os.toFiniteNumber(e.getContentLength());return r??S81(t)},rNd=Lno&&(async e=>{let{url:t,method:r,data:i,signal:n,cancelToken:a,timeout:u,onDownloadProgress:l,onUploadProgress:f,responseType:s,headers:o,withCredentials:c="same-origin",fetchOptions:b}=Fno(e);s=s?(s+"").toLowerCase():"text";let g=ZFd([n,a&&a.toAbortSignal()],u),O,m=g&&g.unsubscribe&&(()=>{g.unsubscribe()}),w;try{if(f&&w81&&r!=="get"&&r!=="head"&&(w=await D81(o,i))!==0){let C=new Request(t,{method:"POST",body:i,duplex:"half"}),R;if(os.isFormData(i)&&(R=C.headers.get("content-type"))&&o.setContentType(R),C.body){let[$,I]=Nun(w,z4r(Lun(f)));i=e_s(C.body,kFd,$,I)}}os.isString(c)||(c=c?"include":"omit");let A="credentials"in Request.prototype;O=new Request(t,{...b,signal:g,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:i,duplex:"half",credentials:A?c:void 0});let M=await fetch(O),q=t_s&&(s==="stream"||s==="response");if(t_s&&(l||q&&m)){let C={};["status","statusText","headers"].forEach(U=>{C[U]=M[U]});let R=os.toFiniteNumber(M.headers.get("content-length")),[$,I]=l&&Nun(R,z4r(Lun(l),!0))||[];M=new Response(e_s(M.body,kFd,$,()=>{I&&I(),m&&m()}),C)}s=s||"text";let D=await Nno[os.findKey(Nno,s)||"text"](M,e);return!q&&m&&m(),await new Promise((C,R)=>{hGt(C,R,{data:D,headers:sI.from(M.headers),status:M.status,statusText:M.statusText,config:e,request:O})})}catch(A){throw m&&m(),A&&A.name==="TypeError"&&/fetch/i.test(A.message)?Object.assign(new yp("Network Error",yp.ERR_NETWORK,e,O),{cause:A.cause||A}):yp.from(A,A&&A.code,e,O)}});var r_s={http:QFd,xhr:XFd,fetch:rNd};os.forEach(r_s,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var iNd=e=>`- ${e}`,E81=e=>os.isFunction(e)||e===null||e===!1,Uno={getAdapter:e=>{e=os.isArray(e)?e:[e];let{length:t}=e,r,i,n={};for(let a=0;a<t;a++){r=e[a];let u;if(i=r,!E81(r)&&(i=r_s[(u=String(r)).toLowerCase()],i===void 0))throw new yp(`Unknown adapter '${u}'`);if(i)break;n[u||"#"+a]=i}if(!i){let a=Object.entries(n).map(([l,f])=>`adapter ${l} `+(f===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
@@ -1922,11 +1922,11 @@ ${q}${M}${D}${Cop.default.cursorHide}`});var JXn=Di(rPi(),1);function $1s(e,t){i
1922
1922
  Run ${Su.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
1923
1923
  Run ${Su.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),Vun(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function rSs({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!rup(e))return;let n=t??"",a=e.filter(l=>l.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((l,f)=>l.generatorName.localeCompare(f.generatorName)||l.currentVersion.localeCompare(f.currentVersion));for(let l of u)n+=`
1924
1924
  ${await rjS(l.generatorName)} (${l.apiName!=null?"API: "+l.apiName+", ":""}Group: ${l.generatorGroup}) `+Su.dim(l.currentVersion)+Su.reset(" \u2192 ")+Su.green(l.latestVersion);return n+=`
1925
- `,i?Vun(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function rjS(e){let r=await new tup.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 ijS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await nup({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=qYr(o.name,c),g=await qWt({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await nup({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,f,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][f]==null&&(u.versions[l][f]={});let c=qYr(s.name,o),b=await qWt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][f][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function nup({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await T7t({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let f of l.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,u)}})}))}function aup(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let f=Tte(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function Vpo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await ijS({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[f,s]of Object.entries(l.versions))u.push(...aup(s,f,t.logger));else u.push(...aup(l.versions,void 0,t.logger))}return u}var rZn=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var Mfn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var qfn=e=>e!==null&&typeof e=="object";var iZn=(...e)=>{for(let t of e)if((!qfn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return aSs({},...e)},iSs=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function Wpo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:aSs(e[r]??[],t[r]??[])}var nSs=(e={},t={})=>({beforeRequest:Wpo(e,t,"beforeRequest"),beforeRetry:Wpo(e,t,"beforeRetry"),afterResponse:Wpo(e,t,"afterResponse"),beforeError:Wpo(e,t,"beforeError")}),aSs=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(qfn(n)){for(let[a,u]of Object.entries(n))qfn(u)&&a in t&&(u=aSs(t[a],u)),t={...t,[a]:u};qfn(n.hooks)&&(i=nSs(i,n.hooks),t.hooks=i),qfn(n.headers)&&(r=iSs(r,n.headers),t.headers=r)}return t};var oup=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),uup=typeof globalThis.AbortController=="function",sup=typeof globalThis.ReadableStream=="function",cup=typeof globalThis.FormData=="function",Hpo=["get","post","put","patch","head","delete"],njS=()=>{};njS();var lup={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},$po=2147483647,Gpo=Symbol("stop"),fup={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},dup={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 _up=e=>Hpo.includes(e)?e.toUpperCase():e,ajS=["get","put","head","delete","options","trace"],ojS=[408,413,429,500,502,503,504],ujS=[413,429,503],pup={limit:2,methods:ajS,statusCodes:ojS,afterStatusCodes:ujS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},hup=(e={})=>{if(typeof e=="number")return{...pup,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{...pup,...e}};async function oSs(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new Mfn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function uSs(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var yup=(e,t)=>{let r={};for(let i in t)!(i in dup)&&!(i in fup)&&!(i in e)&&(r[i]=t[i]);return r};var nZn=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>$po)throw new RangeError(`The \`timeout\` option cannot be greater than ${$po}`);await Promise.resolve();let l=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let f=new rZn(l,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!sup)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return i._stream(l.clone(),i._options.onDownloadProgress)}return l},u=i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n();for(let[l,f]of Object.entries(lup))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let o=(await u).clone();if(l==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:iSs(this._input.headers,r.headers),hooks:nSs({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:_up(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:hup(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(uup){this.abortController=new globalThis.AbortController;let i=this._options.signal??this._input.signal;i?.addEventListener("abort",()=>{this.abortController.abort(i.reason)}),this._options.signal=this.abortController.signal}if(oup&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(cup&&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 Mfn)throw t;if(t instanceof rZn){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),$po);if(this._retryCount<1)throw r;await uSs(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===Gpo)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=yup(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):oSs(r,t,this.abortController,this._options)}_stream(t,r){let i=Number(t.headers.get("content-length"))||0,n=0;return t.status===204?(r&&r({percent:1,totalBytes:i,transferredBytes:n},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:i},new Uint8Array);async function l(){let{done:f,value:s}=await u.read();if(f){a.close();return}if(r){n+=s.byteLength;let o=i===0?0:n/i;r({percent:o,transferredBytes:n,totalBytes:i},s)}a.enqueue(s),await l()}await l()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var sSs=e=>{let t=(r,i)=>nZn.create(r,iZn(e,i));for(let r of Hpo)t[r]=(i,n)=>nZn.create(i,iZn(e,n,{method:r}));return t.create=r=>sSs(iZn(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),sSs(iZn(e,r))),t.stop=Gpo,t},sjS=sSs(),vup=sjS;var Lup=Di(Nup(),1);function pSs(e){let t=(0,Lup.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var xsp=Di(Bsp(),1),Isp=Di(rPi(),1),ESs=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},ASs=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function MSs(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??pSs(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,xsp.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,l&&(f.authorization=`${l.type} ${l.token}`);let s;try{s=await vup(u,{headers:f,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new ESs(e):c}if(t.allVersions)return s;let o=new ASs(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=Isp.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function lZn(e,t){let{version:r}=await MSs(e.toLowerCase(),t);return r}async function Aei({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:lZn(e.packageName,{version:t?"prerelease":"latest"})}var zsp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],n_o=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=k0.Info;constructor(t){this.ttyAwareLogger=new Upo(t);let r=this.getPackageName(),i=this.getPackageVersion(),n=this.getCliName();(r==null||i==null||n==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:i,cliName:n}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.51.26"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Su.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Kk}failWithoutThrowing(t,r){this.didSucceed=!1,Rpo({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await Cun()).flush(),this.exitProgram()}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await iup({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1925
+ `,i?Vun(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function rjS(e){let r=await new tup.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 ijS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await nup({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=qYr(o.name,c),g=await qWt({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await nup({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,f,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][f]==null&&(u.versions[l][f]={});let c=qYr(s.name,o),b=await qWt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][f][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function nup({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await T7t({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let f of l.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,u)}})}))}function aup(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let f=Tte(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function Vpo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await ijS({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[f,s]of Object.entries(l.versions))u.push(...aup(s,f,t.logger));else u.push(...aup(l.versions,void 0,t.logger))}return u}var rZn=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var Mfn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var qfn=e=>e!==null&&typeof e=="object";var iZn=(...e)=>{for(let t of e)if((!qfn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return aSs({},...e)},iSs=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function Wpo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:aSs(e[r]??[],t[r]??[])}var nSs=(e={},t={})=>({beforeRequest:Wpo(e,t,"beforeRequest"),beforeRetry:Wpo(e,t,"beforeRetry"),afterResponse:Wpo(e,t,"afterResponse"),beforeError:Wpo(e,t,"beforeError")}),aSs=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(qfn(n)){for(let[a,u]of Object.entries(n))qfn(u)&&a in t&&(u=aSs(t[a],u)),t={...t,[a]:u};qfn(n.hooks)&&(i=nSs(i,n.hooks),t.hooks=i),qfn(n.headers)&&(r=iSs(r,n.headers),t.headers=r)}return t};var oup=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),uup=typeof globalThis.AbortController=="function",sup=typeof globalThis.ReadableStream=="function",cup=typeof globalThis.FormData=="function",Hpo=["get","post","put","patch","head","delete"],njS=()=>{};njS();var lup={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},$po=2147483647,Gpo=Symbol("stop"),fup={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},dup={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 _up=e=>Hpo.includes(e)?e.toUpperCase():e,ajS=["get","put","head","delete","options","trace"],ojS=[408,413,429,500,502,503,504],ujS=[413,429,503],pup={limit:2,methods:ajS,statusCodes:ojS,afterStatusCodes:ujS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},hup=(e={})=>{if(typeof e=="number")return{...pup,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{...pup,...e}};async function oSs(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new Mfn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function uSs(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var yup=(e,t)=>{let r={};for(let i in t)!(i in dup)&&!(i in fup)&&!(i in e)&&(r[i]=t[i]);return r};var nZn=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>$po)throw new RangeError(`The \`timeout\` option cannot be greater than ${$po}`);await Promise.resolve();let l=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let f=new rZn(l,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!sup)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return i._stream(l.clone(),i._options.onDownloadProgress)}return l},u=i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n();for(let[l,f]of Object.entries(lup))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let o=(await u).clone();if(l==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:iSs(this._input.headers,r.headers),hooks:nSs({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:_up(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:hup(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(uup){this.abortController=new globalThis.AbortController;let i=this._options.signal??this._input.signal;i?.addEventListener("abort",()=>{this.abortController.abort(i.reason)}),this._options.signal=this.abortController.signal}if(oup&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(cup&&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 Mfn)throw t;if(t instanceof rZn){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),$po);if(this._retryCount<1)throw r;await uSs(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===Gpo)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=yup(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):oSs(r,t,this.abortController,this._options)}_stream(t,r){let i=Number(t.headers.get("content-length"))||0,n=0;return t.status===204?(r&&r({percent:1,totalBytes:i,transferredBytes:n},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:i},new Uint8Array);async function l(){let{done:f,value:s}=await u.read();if(f){a.close();return}if(r){n+=s.byteLength;let o=i===0?0:n/i;r({percent:o,transferredBytes:n,totalBytes:i},s)}a.enqueue(s),await l()}await l()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var sSs=e=>{let t=(r,i)=>nZn.create(r,iZn(e,i));for(let r of Hpo)t[r]=(i,n)=>nZn.create(i,iZn(e,n,{method:r}));return t.create=r=>sSs(iZn(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),sSs(iZn(e,r))),t.stop=Gpo,t},sjS=sSs(),vup=sjS;var Lup=Di(Nup(),1);function pSs(e){let t=(0,Lup.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var xsp=Di(Bsp(),1),Isp=Di(rPi(),1),ESs=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},ASs=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function MSs(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??pSs(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,xsp.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,l&&(f.authorization=`${l.type} ${l.token}`);let s;try{s=await vup(u,{headers:f,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new ESs(e):c}if(t.allVersions)return s;let o=new ASs(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=Isp.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function lZn(e,t){let{version:r}=await MSs(e.toLowerCase(),t);return r}async function Aei({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:lZn(e.packageName,{version:t?"prerelease":"latest"})}var zsp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],n_o=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=k0.Info;constructor(t){this.ttyAwareLogger=new Upo(t);let r=this.getPackageName(),i=this.getPackageVersion(),n=this.getCliName();(r==null||i==null||n==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:i,cliName:n}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.51.28"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Su.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Kk}failWithoutThrowing(t,r){this.didSucceed=!1,Rpo({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await Cun()).flush(),this.exitProgram()}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await iup({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1926
1926
  `)||(r+=`
1927
1927
  `),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=S$u(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new KXn(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let i=this.addTaskWithInit(t).start(),n;try{n=await r(i)}catch(a){throw a.message.includes("globalThis")?(i.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),i.failWithoutThrowing()):i.failWithoutThrowing(void 0,a),new Kk}finally{i.finish()}return n}async instrumentPostHogEvent(t){(await Cun()).sendEvent(t)}logger=h6r(this.log.bind(this));constructTaskInitForWorkspace(t){let r=Rsp(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?Rsp(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=zsp[this.numTasks++%zsp.length],u=Su.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===IT.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logImmediately(t){let r=t.filter(i=>WKr.indexOf(i.level)>=WKr.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===k0.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 Aei({cliEnvironment:this.environment,includePreReleases:t}),i=Tte(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await Vpo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await N1s({message:t,default:r})}async getInput(t){return await L1s({message:t.message,default:t.default})}};function Rsp(e){return`[${e}]:`}var UEp=require("fs/promises");function NBe({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Su.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Su.dim(r)),i.join(`
1928
1928
  `)}var cjp=require("fs/promises");var F2t=class e{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;type=e.Type;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};var xwe=class extends F2t{definition;sources;constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var fZn=class{context;constructor(t){this.context=t}};var a_o=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,l]of Object.entries(i.files)){let f=n!=null?Wh.of(`${n}${K3t}${u}`):Wh.of(u);t[f]=l}let a=Object.keys(i.directories).sort();for(let u of a){let l=n!=null?`${n}${K3t}${u}`:u,f=i.directories[u];r(f,l)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(K3t))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Wh.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var iSi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new a_o,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),i!=null&&(u.service["base-path"]=i),n!=null&&(u.service["display-name"]=n),a!=null&&(u.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return W6r(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))pwS(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??pg((Kqe(r)+"/"+nmi(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Wh.of(UN))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=z4a(Kqe(ztn.of(`/${t}`)),ztn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=z4a(Kqe(ztn.of(`/${t}`)),ztn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(l=>N3t(l,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=Dz(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:Dz(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,u])=>[a,{...u,path:Dz(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===P1?this.packageMarkerFile:this.root.getOrCreateFile(t)}getVersionHeader(){if(this.rootApiFile.version!=null)return typeof this.rootApiFile.version.header=="string"?this.rootApiFile.version.header:this.rootApiFile.version.header.value}};function pwS(e){return e?.header!=null}var N2t={openapi:e=>({...e,type:"openapi",_visit:function(t){return N2t._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return N2t._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 Rfn={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return Rfn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var Z4={basic:e=>({...e,type:"basic",_visit:function(t){return Z4._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Z4._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Z4._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return Z4._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Z4._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 A0={primitive:e=>({value:e,type:"primitive",_visit:function(t){return A0._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return A0._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return A0._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return A0._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return A0._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return A0._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return A0._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return A0._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 Jp={int:e=>({value:e,type:"int",_visit:function(t){return Jp._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return Jp._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return Jp._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return Jp._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return Jp._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return Jp._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Jp._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return Jp._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return Jp._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return Jp._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return Jp._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 Ffn={boolean:e=>({value:e,type:"boolean",_visit:function(t){return Ffn._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Ffn._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 Mei={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return Mei._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return Mei._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var GL={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case GL.GenerallyAvailable:return t.generallyAvailable();case GL.Beta:return t.beta();case GL.Deprecated:return t.deprecated();default:return t._other()}}};var T8r={cursor:e=>({...e,type:"cursor",_visit:function(t){return T8r._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return T8r._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 C8r={language:e=>({...e,type:"language",_visit:function(t){return C8r._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return C8r._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 QL={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 QL.Curl:return t.curl();case QL.Python:return t.python();case QL.Javascript:return t.javascript();case QL.Typescript:return t.typescript();case QL.Go:return t.go();case QL.Ruby:return t.ruby();case QL.Csharp:return t.csharp();case QL.Java:return t.java();case QL.Js:return t.js();case QL.Node:return t.node();case QL.Ts:return t.ts();case QL.Nodets:return t.nodets();case QL.Golang:return t.golang();case QL.Dotnet:return t.dotnet();case QL.Jvm:return t.jvm();default:return t._other()}}};var L2t={unknown:e=>({value:e,type:"unknown",_visit:function(t){return L2t._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return L2t._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 LBe={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return LBe._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return LBe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var RH={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case RH.Get:return t.get();case RH.Post:return t.post();case RH.Put:return t.put();case RH.Patch:return t.patch();case RH.Delete:return t.delete();case RH.Head:return t.head();case RH.Options:return t.options();case RH.Trace:return t.trace();default:return t._other()}}};var qei={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return qei._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return qei._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return qei._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 UBe={file:e=>({...e,type:"file",_visit:function(t){return UBe._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return UBe._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 Cte={file:e=>({...e,type:"file",_visit:function(t){return Cte._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Cte._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Cte._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Cte._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Cte._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Cte._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 ey={primitive:e=>({...e,type:"primitive",_visit:function(t){return ey._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ey._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return ey._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return ey._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return ey._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ey._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return ey._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return ey._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ey._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return ey._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return ey._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 WP={int:e=>({...e,type:"int",_visit:function(t){return WP._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return WP._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return WP._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return WP._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return WP._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return WP._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return WP._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return WP._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return WP._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return WP._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return WP._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 bB={boolean:e=>({value:e,type:"boolean",_visit:function(t){return bB._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return bB._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 B8r={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return B8r._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return B8r._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var Iwe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return Iwe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return Iwe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Iwe._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 gB={file:e=>({...e,type:"file",_visit:function(t){return gB._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return gB._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return gB._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return gB._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return gB._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return gB._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 Fl={primitive:e=>({...e,type:"primitive",_visit:function(t){return Fl._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Fl._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Fl._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Fl._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Fl._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Fl._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Fl._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Fl._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Fl._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Fl._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Fl._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 dK={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return dK._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return dK._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var Xd={int:e=>({...e,type:"int",_visit:function(t){return Xd._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Xd._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Xd._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Xd._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Xd._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Xd._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Xd._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Xd._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Xd._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Xd._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Xd._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime(e);case"date":return t.date(e);case"base64":return t.base64(e);case"boolean":return t.boolean(e);default:return t._other(e)}}};var Uy={};Ro(Uy,{AllOfPropertyConflict:()=>odn,ArraySchema:()=>vho,ArraySchemaWithExample:()=>$ho,Availability:()=>h_o,Base64WithExample:()=>Lho,BasicSecurityScheme:()=>b_o,BearerSecurityScheme:()=>g_o,BooleanSchema:()=>fho,BooleanWithExample:()=>Uho,CasingOverrides:()=>P_o,CommonProperty:()=>Sho,CommonPropertyWithExample:()=>eyo,CursorPagination:()=>Z_o,CustomCodeSample:()=>Y_o,CustomCodeSampleLanguage:()=>Q_o,CustomCodeSampleSdk:()=>K_o,DateWithExample:()=>Nho,DatetimeWithExample:()=>Fho,DiscriminatedOneOfSchema:()=>jho,DiscriminatedOneOfSchemaWithExample:()=>Zho,DoubleSchema:()=>cho,DoubleWithExample:()=>zho,Encoding:()=>__o,Endpoint:()=>eho,EndpointExample:()=>tdn,EndpointResponseExample:()=>G_o,EndpointSdkName:()=>aQt,EndpointWithExample:()=>pcp,EnumSchema:()=>Vfn,EnumSchemaWithExample:()=>Who,EnumValue:()=>Bei,ErrorExample:()=>U_o,FernExample:()=>W_o,FileResponse:()=>Yfn,FileSchema:()=>I_o,FloatWithExample:()=>Iho,FullEndpointExample:()=>X_o,FullExample:()=>aM,FullObjectExample:()=>q_o,FullOneOfExample:()=>C_o,GlobalHeader:()=>pho,Header:()=>Iei,HeaderExample:()=>edn,HeaderSecurityScheme:()=>O_o,HeaderWithExample:()=>Fei,HttpEndpointServer:()=>Zfn,HttpError:()=>V_o,HttpErrorWithExample:()=>qho,HttpMethod:()=>$fn,IdempotencyHeader:()=>_ho,Int64WithExample:()=>Cho,IntSchema:()=>uho,IntWithExample:()=>Tho,JsonRequest:()=>F_o,JsonRequestWithExample:()=>Eho,JsonResponse:()=>Xfn,JsonResponseWithExample:()=>cdn,KeyValuePair:()=>T_o,LiteralExample:()=>M_o,LiteralSchema:()=>adn,LiteralSchemaValue:()=>hho,LongSchema:()=>sho,MapSchema:()=>bho,MapSchemaWithExample:()=>Gho,MultipartRequest:()=>Kfn,MultipartRequestProperty:()=>R_o,MultipartSchema:()=>z_o,NamedFullExample:()=>uQt,Namespace:()=>j_o,NamespaceId:()=>A_o,NullableSchema:()=>Oho,NullableSchemaWithExample:()=>Jho,OauthSecurityScheme:()=>S_o,ObjectProperty:()=>Pho,ObjectPropertyConflictInfo:()=>udn,ObjectPropertyWithExample:()=>Xho,ObjectSchema:()=>yho,ObjectSchemaWithExample:()=>Kho,OctetStreamRequest:()=>Jfn,OffsetPagination:()=>k_o,OneOfSchema:()=>mho,OneOfSchemaWithExample:()=>Yho,OpenApiIntermediateRepresentation:()=>fcp,OpenApiSource:()=>l_o,OptionalSchema:()=>gho,OptionalSchemaWithExample:()=>Qho,Pagination:()=>rdn,PathParameter:()=>Gfn,PathParameterExample:()=>H_o,PathParameterWithExample:()=>Dho,PrimitiveExample:()=>Hfn,PrimitiveSchema:()=>Rei,PrimitiveSchemaValue:()=>dho,PrimitiveSchemaValueWithExample:()=>Vho,PrimitiveSchemaWithExample:()=>ldn,PropertyKey:()=>Wfn,ProtobufEncoding:()=>p_o,ProtobufSource:()=>f_o,QueryParameter:()=>Qfn,QueryParameterExample:()=>kfn,QueryParameterWithExample:()=>sdn,QuerySecurityScheme:()=>m_o,ReferencedSchema:()=>oQt,Request:()=>N_o,RequestWithExample:()=>Aho,Response:()=>L_o,ResponseWithExample:()=>Mho,Schema:()=>uO,SchemaId:()=>pK,SchemaWithExample:()=>GE,Schemas:()=>oho,SdkGroup:()=>w_o,SdkGroupInfo:()=>B_o,SdkGroupName:()=>xei,SecurityScheme:()=>D_o,SecuritySchemeId:()=>v_o,Server:()=>E_o,Source:()=>d_o,StatusCode:()=>rQt,StreamingResponseExample:()=>$_o,StringSchema:()=>lho,StringSchemaWithExample:()=>Rho,SupportedSdkLanguage:()=>J_o,Tag:()=>y_o,TagId:()=>_K,Tags:()=>x_o,TextResponse:()=>zei,Uint64WithExample:()=>xho,UintWithExample:()=>Bho,UnDiscriminatedOneOfSchema:()=>who,UnDiscriminatedOneOfSchemaWithExample:()=>kho,UnknownSchemaWithExample:()=>Hho,Webhook:()=>tho,WebhookExampleCall:()=>ndn,WebhookHttpMethod:()=>idn,WebhookWithExample:()=>_cp,WebsocketChannel:()=>aho,WebsocketHandshake:()=>rho,WebsocketHandshakeWithExample:()=>dcp,WebsocketMessageExample:()=>iho,WebsocketSessionExample:()=>nho,WithAvailability:()=>Q_,WithDescription:()=>vf,WithEncoding:()=>Bte,WithInline:()=>MD,WithName:()=>Bb,WithNamespace:()=>nQt,WithSdkGroupName:()=>oO,WithSource:()=>$h,WithStatusCode:()=>iQt,WithTitle:()=>aO,commons:()=>xSs,example:()=>ISs,finalIr:()=>zSs,parseIr:()=>RSs});var xSs={};Ro(xSs,{BasicSecurityScheme:()=>b_o,BearerSecurityScheme:()=>g_o,Encoding:()=>__o,HeaderSecurityScheme:()=>O_o,Namespace:()=>j_o,NamespaceId:()=>A_o,OauthSecurityScheme:()=>S_o,OpenApiSource:()=>l_o,ProtobufEncoding:()=>p_o,ProtobufSource:()=>f_o,QuerySecurityScheme:()=>m_o,SchemaId:()=>pK,SdkGroup:()=>w_o,SdkGroupName:()=>xei,SecurityScheme:()=>D_o,SecuritySchemeId:()=>v_o,Server:()=>E_o,Source:()=>d_o,StatusCode:()=>rQt,Tag:()=>y_o,TagId:()=>_K,WithAvailability:()=>Q_,WithDescription:()=>vf,WithEncoding:()=>Bte,WithInline:()=>MD,WithName:()=>Bb,WithNamespace:()=>nQt,WithSdkGroupName:()=>oO,WithSource:()=>$h,WithStatusCode:()=>iQt,WithTitle:()=>aO});var Ct={};Ro(Ct,{JsonError:()=>Nfn,ParseError:()=>Lfn,any:()=>Zsp,bigint:()=>Nsp,boolean:()=>ksp,booleanLiteral:()=>Xsp,date:()=>Lsp,discriminant:()=>scp,enum_:()=>u_o,getObjectLikeUtils:()=>U2t,getObjectUtils:()=>nSi,getSchemaUtils:()=>nM,isProperty:()=>Cei,lazy:()=>Usp,lazyObject:()=>Jsp,list:()=>c_o,number:()=>ecp,object:()=>s_o,objectWithoutOptionalProperties:()=>Qsp,optional:()=>qSs,property:()=>Wsp,record:()=>ncp,set:()=>acp,string:()=>tcp,stringLiteral:()=>Ysp,transform:()=>TSs,undiscriminatedUnion:()=>ucp,union:()=>lcp,unknown:()=>rcp,withParsedProperties:()=>BSs});var PP={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function $E(e,t){return`Expected ${t}. Received ${_wS(e)}.`}function _wS(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function k4(e){return{...e,json:Fsp(e.json),parse:Fsp(e.parse)}}function Fsp(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
1929
- `)),{ok:!0,value:t}):i}}function o_o(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var Nfn=class e extends Error{errors;constructor(t){super(t.map(o_o).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var Lfn=class e extends Error{errors;constructor(t){super(t.map(o_o).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function nM(e){return{optional:()=>qSs(e),transform:t=>TSs(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new Lfn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new Nfn(i.errors)}}}function qSs(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>PP.OPTIONAL};return{...t,...nM(t)}}function TSs(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...nM(r)}}function Nsp(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:$E(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:$E(t,"bigint")}]},getType:()=>PP.BIGINT};return{...k4(e),...nM(e)}}var hwS=/^([+-]?\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 Lsp(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:$E(t,"string")}]}:hwS.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:$E(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:$E(t,"Date object")}]},getType:()=>PP.DATE};return{...k4(e),...nM(e)}}function FH(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...k4(r),...nM(r)}}}function u_o(e){let t=new Set(e);return FH(PP.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:$E(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:$E(i,"enum")}]}:{ok:!0,value:i})()}function Usp(e){let t=CSs(e);return{...t,...nM(t)}}function CSs(e){return{parse:(t,r)=>Ufn(e).parse(t,r),json:(t,r)=>Ufn(e).json(t,r),getType:()=>Ufn(e).getType()}}function Ufn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function dZn(e){return Object.entries(e)}function pZn(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function Tei(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 _Zn(e){return Object.keys(e)}function Vsp(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function U2t(e){return{withParsedProperties:t=>BSs(e,t)}}function BSs(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((l,[f,s])=>({...l,[f]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!Tei(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:$E(i,"object")}]};let a=new Set(Object.keys(t)),u=pZn(i,Object.keys(i).filter(l=>!a.has(l)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...nM(r),...U2t(r)}}function Wsp(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function Cei(e){return e.isProperty}function s_o(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>Cei(i)?i.rawKey:r),_getParsedProperties:()=>_Zn(e),parse:(r,i)=>{let n={},a=[];for(let[u,l]of dZn(e)){let f=Cei(l)?l.rawKey:u,s=Cei(l)?l.valueSchema:l,o={rawKey:f,parsedKey:u,valueSchema:s};n[f]=o,Gsp(s)&&a.push(f)}return Hsp({value:r,requiredKeys:a,getProperty:u=>{let l=n[u];if(l!=null)return{transformedKey:l.parsedKey,transform:f=>l.valueSchema.parse(f,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of dZn(e)){let l=Cei(u)?u.valueSchema:u;Gsp(l)&&n.push(a)}return Hsp({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return Cei(u)?{transformedKey:u.rawKey,transform:l=>u.valueSchema.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:l=>u.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>PP.OBJECT};return{...k4(t),...nM(t),...U2t(t),...nSi(t)}}function Hsp({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!Tei(e))return{ok:!1,errors:[{path:a,message:$E(e,"object")}]};let u=new Set(t),l=[],f={};for(let[s,o]of Object.entries(e)){let c=r(s);if(c!=null){u.delete(s);let b=c.transform(o);b.ok?f[c.transformedKey]=b.value:(f[s]=o,l.push(...b.errors))}else switch(i){case"fail":l.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":f[s]=o;break}}return l.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),l.length===0||n?{ok:!0,value:f}:{ok:!1,errors:l}}function nSi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>$sp({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>$sp({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>PP.OBJECT};return{...r,...nM(r),...U2t(r),...nSi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>PP.OBJECT};return{...t,...nM(t),...U2t(t),...nSi(t)}}}}function $sp({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=Vsp(_Zn(t),s=>n.has(s)),l=r(pZn(t,u)),f=i(pZn(t,a));return l.ok&&f.ok?{ok:!0,value:{...l.value,...f.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...f.ok?[]:f.errors]}}function Gsp(e){return!ywS(e)}function ywS(e){switch(e.getType()){case PP.ANY:case PP.UNKNOWN:case PP.OPTIONAL:return!0;default:return!1}}function Qsp(e){return s_o(e)}function Jsp(e){let t={...CSs(e),_getRawProperties:()=>Ufn(e)._getRawProperties(),_getParsedProperties:()=>Ufn(e)._getParsedProperties()};return{...t,...nM(t),...U2t(t),...nSi(t)}}function c_o(e){let t={parse:(r,i)=>Ksp(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Ksp(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>PP.LIST};return{...k4(t),...nM(t)}}function Ksp(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:$E(e,"list"),path:[]}]}}function Ysp(e){return FH(PP.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:$E(r,`"${e}"`)}]})()}function Xsp(e){return FH(PP.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:$E(r,`${e.toString()}`)}]})()}var Zsp=FH(PP.ANY,e=>({ok:!0,value:e}));var ksp=FH(PP.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$E(e,"boolean")}]});var ecp=FH(PP.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$E(e,"number")}]});var tcp=FH(PP.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$E(e,"string")}]});var rcp=FH(PP.UNKNOWN,e=>({ok:!0,value:e}));function ncp(e,t){let r={parse:(i,n)=>icp({value:i,isKeyNumeric:e.getType()===PP.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>icp({value:i,isKeyNumeric:e.getType()===PP.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>PP.RECORD};return{...k4(r),...nM(r)}}function icp({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return Tei(e)?dZn(e).reduce((a,[u,l])=>{if(l==null)return a;let f=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),c=i(l,s);if(f.ok&&o.ok&&c.ok)return{ok:!0,value:{...f.value,[o.value]:c.value}};let b=[];return f.ok||b.push(...f.errors),o.ok||b.push(...o.errors),c.ok||b.push(...c.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:$E(e,"object")}]}}function acp(e){let t=c_o(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:$E(i,"Set")}]},getType:()=>PP.SET};return{...k4(r),...nM(r)}}function ucp(e){let t={parse:(r,i)=>ocp((n,a)=>n.parse(r,a),e,i),json:(r,i)=>ocp((n,a)=>n.json(r,a),e,i),getType:()=>PP.UNDISCRIMINATED_UNION};return{...k4(t),...nM(t)}}function ocp(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let l of u.errors)i.push({path:l.path,message:`[Variant ${n}] ${l.message}`})}return{ok:!1,errors:i}}function scp(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function lcp(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=u_o(_Zn(t)),a={parse:(u,l)=>ccp({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:f=>n.parse(f,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.parse(f,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),json:(u,l)=>ccp({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:f=>n.json(f,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.json(f,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),getType:()=>PP.UNION};return{...k4(a),...nM(a),...U2t(a)}}function ccp({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:l=[]}){if(!Tei(e))return{ok:!1,errors:[{path:l,message:$E(e,"object")}]};let{[t]:f,...s}=e;if(f==null)return{ok:!1,errors:[{path:l,message:`Missing discriminant ("${t}")`}]};let o=i(f);if(!o.ok)return{ok:!1,errors:o.errors};let c=n(o.value);if(c==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...l,t],message:"Unexpected discriminant value"}]};let b=u(s,c);return b.ok?{ok:!0,value:{[r]:f,...b.value}}:b}var aO=Ct.objectWithoutOptionalProperties({title:Ct.string().optional()});var l_o=Ct.objectWithoutOptionalProperties({file:Ct.string()});var f_o=Ct.objectWithoutOptionalProperties({file:Ct.string()});var d_o=Ct.union("type",{openapi:l_o,protobuf:f_o}).transform({transform:e=>{switch(e.type){case"openapi":return N2t.openapi(e);case"protobuf":return N2t.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var $h=Ct.objectWithoutOptionalProperties({source:d_o.optional()});var p_o=Ct.objectWithoutOptionalProperties({typeName:Ct.string()});var __o=Ct.union("type",{protobuf:p_o}).transform({transform:e=>{switch(e.type){case"protobuf":return Rfn.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Bte=Ct.objectWithoutOptionalProperties({encoding:__o.optional()});var vf=Ct.objectWithoutOptionalProperties({description:Ct.string().optional()});var h_o=Ct.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Q_=Ct.objectWithoutOptionalProperties({availability:h_o.optional()});var rQt=Ct.number();var iQt=Ct.objectWithoutOptionalProperties({statusCode:rQt.optional()});var Bb=Ct.objectWithoutOptionalProperties({nameOverride:Ct.string().optional(),generatedName:Ct.string()});var MD=Ct.objectWithoutOptionalProperties({inline:Ct.boolean().optional()});var pK=Ct.string();var _K=Ct.string();var y_o=Ct.objectWithoutOptionalProperties({id:_K}).extend(vf);var v_o=Ct.string();var b_o=Ct.objectWithoutOptionalProperties({usernameVariableName:Ct.string().optional(),usernameEnvVar:Ct.string().optional(),passwordVariableName:Ct.string().optional(),passwordEnvVar:Ct.string().optional()});var g_o=Ct.objectWithoutOptionalProperties({tokenVariableName:Ct.string().optional(),tokenEnvVar:Ct.string().optional()});var O_o=Ct.objectWithoutOptionalProperties({headerName:Ct.string(),prefix:Ct.string().optional(),headerVariableName:Ct.string().optional(),headerEnvVar:Ct.string().optional()});var m_o=Ct.objectWithoutOptionalProperties({queryParameterName:Ct.string()});var P_o=Ct.objectWithoutOptionalProperties({snake:Ct.string().optional(),camel:Ct.string().optional(),screamingSnake:Ct.string().optional(),pascal:Ct.string().optional()});var Bei=Ct.objectWithoutOptionalProperties({nameOverride:Ct.string().optional(),generatedName:Ct.string(),value:Ct.string(),casing:P_o.optional()}).extend(vf).extend(Q_);var j_o=Ct.objectWithoutOptionalProperties({type:Ct.stringLiteral("namespace"),name:Ct.string()});var w_o=Ct.undiscriminatedUnion([Ct.string(),j_o]);var xei=Ct.list(w_o);var oO=Ct.objectWithoutOptionalProperties({groupName:xei.optional()});var Vfn=Ct.objectWithoutOptionalProperties({default:Bei.optional(),values:Ct.list(Bei)}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend($h).extend(aO).extend(MD);var S_o=Ct.objectWithoutOptionalProperties({scopesEnum:Vfn.optional()});var D_o=Ct.union("type",{basic:b_o,bearer:g_o,header:O_o,query:m_o,oauth:S_o}).transform({transform:e=>{switch(e.type){case"basic":return Z4.basic(e);case"bearer":return Z4.bearer(e);case"header":return Z4.header(e);case"query":return Z4.query(e);case"oauth":return Z4.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var E_o=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),url:Ct.string(),audiences:Ct.list(Ct.string()).optional()}).extend(vf);var A_o=Ct.string();var nQt=Ct.objectWithoutOptionalProperties({namespace:Ct.string().optional()});var ISs={};Ro(ISs,{FullExample:()=>aM,FullObjectExample:()=>q_o,FullOneOfExample:()=>C_o,KeyValuePair:()=>T_o,LiteralExample:()=>M_o,PrimitiveExample:()=>Hfn,PropertyKey:()=>Wfn});var Wfn=Ct.string();var Hfn=Ct.union("type",{int:Ct.object({value:Ct.number()}),int64:Ct.object({value:Ct.number()}),uint:Ct.object({value:Ct.number()}),uint64:Ct.object({value:Ct.number()}),float:Ct.object({value:Ct.number()}),double:Ct.object({value:Ct.number()}),string:Ct.object({value:Ct.string()}),datetime:Ct.object({value:Ct.string()}),date:Ct.object({value:Ct.string()}),base64:Ct.object({value:Ct.string()}),boolean:Ct.object({value:Ct.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return Jp.int(e.value);case"int64":return Jp.int64(e.value);case"uint":return Jp.uint(e.value);case"uint64":return Jp.uint64(e.value);case"float":return Jp.float(e.value);case"double":return Jp.double(e.value);case"string":return Jp.string(e.value);case"datetime":return Jp.datetime(e.value);case"date":return Jp.date(e.value);case"base64":return Jp.base64(e.value);case"boolean":return Jp.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var M_o=Ct.union("type",{boolean:Ct.object({value:Ct.boolean()}),string:Ct.object({value:Ct.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Ffn.boolean(e.value);case"string":return Ffn.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var aM=Ct.union("type",{primitive:Ct.object({value:Hfn}),object:Ct.lazyObject(()=>q_o),array:Ct.object({value:Ct.list(Ct.lazy(()=>aM))}),map:Ct.object({value:Ct.list(Ct.lazyObject(()=>T_o))}),enum:Ct.object({value:Ct.string()}),literal:Ct.object({value:M_o}),oneOf:Ct.object({value:Ct.lazy(()=>C_o)}),unknown:Ct.object({value:Ct.lazy(()=>aM)})}).transform({transform:e=>{switch(e.type){case"primitive":return A0.primitive(e.value);case"object":return A0.object(e);case"array":return A0.array(e.value);case"map":return A0.map(e.value);case"enum":return A0.enum(e.value);case"literal":return A0.literal(e.value);case"oneOf":return A0.oneOf(e.value);case"unknown":return A0.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var q_o=Ct.objectWithoutOptionalProperties({properties:Ct.record(Wfn,Ct.lazy(()=>aM))});var T_o=Ct.objectWithoutOptionalProperties({key:Hfn,value:Ct.lazy(()=>aM)});var C_o=Ct.union("type",{discriminated:Ct.object({value:Ct.record(Wfn,Ct.lazy(()=>aM))}),undiscriminated:Ct.object({value:Ct.lazy(()=>aM)})}).transform({transform:e=>{switch(e.type){case"discriminated":return Mei.discriminated(e.value);case"undiscriminated":return Mei.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var zSs={};Ro(zSs,{AllOfPropertyConflict:()=>odn,ArraySchema:()=>vho,Availability:()=>h_o,BooleanSchema:()=>fho,CasingOverrides:()=>P_o,CommonProperty:()=>Sho,CursorPagination:()=>Z_o,CustomCodeSample:()=>Y_o,CustomCodeSampleLanguage:()=>Q_o,CustomCodeSampleSdk:()=>K_o,DiscriminatedOneOfSchema:()=>jho,DoubleSchema:()=>cho,Endpoint:()=>eho,EndpointExample:()=>tdn,EndpointResponseExample:()=>G_o,EndpointSdkName:()=>aQt,EnumSchema:()=>Vfn,EnumValue:()=>Bei,ErrorExample:()=>U_o,FernExample:()=>W_o,FileResponse:()=>Yfn,FileSchema:()=>I_o,FullEndpointExample:()=>X_o,GlobalHeader:()=>pho,Header:()=>Iei,HeaderExample:()=>edn,HttpEndpointServer:()=>Zfn,HttpError:()=>V_o,HttpMethod:()=>$fn,IdempotencyHeader:()=>_ho,IntSchema:()=>uho,JsonRequest:()=>F_o,JsonResponse:()=>Xfn,LiteralSchema:()=>adn,LiteralSchemaValue:()=>hho,LongSchema:()=>sho,MapSchema:()=>bho,MultipartRequest:()=>Kfn,MultipartRequestProperty:()=>R_o,MultipartSchema:()=>z_o,NullableSchema:()=>Oho,ObjectProperty:()=>Pho,ObjectPropertyConflictInfo:()=>udn,ObjectSchema:()=>yho,OctetStreamRequest:()=>Jfn,OffsetPagination:()=>k_o,OneOfSchema:()=>mho,OpenApiIntermediateRepresentation:()=>fcp,OptionalSchema:()=>gho,Pagination:()=>rdn,PathParameter:()=>Gfn,PathParameterExample:()=>H_o,PrimitiveSchema:()=>Rei,PrimitiveSchemaValue:()=>dho,QueryParameter:()=>Qfn,QueryParameterExample:()=>kfn,ReferencedSchema:()=>oQt,Request:()=>N_o,Response:()=>L_o,Schema:()=>uO,Schemas:()=>oho,SdkGroupInfo:()=>B_o,StreamingResponseExample:()=>$_o,StringSchema:()=>lho,SupportedSdkLanguage:()=>J_o,Tags:()=>x_o,TextResponse:()=>zei,UnDiscriminatedOneOfSchema:()=>who,Webhook:()=>tho,WebhookExampleCall:()=>ndn,WebhookHttpMethod:()=>idn,WebsocketChannel:()=>aho,WebsocketHandshake:()=>rho,WebsocketMessageExample:()=>iho,WebsocketSessionExample:()=>nho});var B_o=Ct.objectWithoutOptionalProperties({summary:Ct.string().optional(),description:Ct.string().optional()});var x_o=Ct.objectWithoutOptionalProperties({tagsById:Ct.record(_K,y_o),orderedTagIds:Ct.list(_K).optional()});var $fn=Ct.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var Gfn=Ct.objectWithoutOptionalProperties({name:Ct.string(),schema:Ct.lazy(()=>uO),variableReference:Ct.string().optional(),parameterNameOverride:Ct.string().optional()}).extend(vf).extend(Q_).extend($h);var Qfn=Ct.objectWithoutOptionalProperties({name:Ct.string(),schema:Ct.lazy(()=>uO),parameterNameOverride:Ct.string().optional()}).extend(vf).extend(Q_).extend($h);var Iei=Ct.objectWithoutOptionalProperties({name:Ct.string(),schema:Ct.lazy(()=>uO),env:Ct.string().optional(),parameterNameOverride:Ct.string().optional()}).extend(vf).extend(Q_).extend($h);var aQt=Ct.objectWithoutOptionalProperties({groupName:xei,methodName:Ct.string()});var Jfn=Ct.objectWithoutOptionalProperties({}).extend(vf).extend($h);var I_o=Ct.objectWithoutOptionalProperties({isOptional:Ct.boolean(),isArray:Ct.boolean()});var z_o=Ct.union("type",{file:I_o,json:Ct.object({value:Ct.lazy(()=>uO)})}).transform({transform:e=>{switch(e.type){case"file":return UBe.file(e);case"json":return UBe.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var R_o=Ct.objectWithoutOptionalProperties({key:Ct.string(),schema:z_o,contentType:Ct.string().optional()}).extend(vf);var Kfn=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),properties:Ct.list(R_o)}).extend(vf).extend($h);var F_o=Ct.objectWithoutOptionalProperties({schema:Ct.lazy(()=>uO),contentType:Ct.string().optional(),additionalProperties:Ct.boolean()}).extend(vf).extend($h);var N_o=Ct.union("type",{octetStream:Jfn,multipart:Kfn,json:F_o}).transform({transform:e=>{switch(e.type){case"octetStream":return qei.octetStream(e);case"multipart":return qei.multipart(e);case"json":return qei.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var Yfn=Ct.objectWithoutOptionalProperties({}).extend(vf).extend($h).extend(iQt);var Xfn=Ct.objectWithoutOptionalProperties({schema:Ct.lazy(()=>uO),responseProperty:Ct.string().optional()}).extend(vf).extend($h).extend(iQt);var zei=Ct.objectWithoutOptionalProperties({}).extend(vf).extend($h).extend(iQt);var L_o=Ct.union("type",{file:Yfn,json:Xfn,text:zei,streamingSse:Xfn,streamingText:zei,streamingJson:Xfn}).transform({transform:e=>{switch(e.type){case"file":return Cte.file(e);case"json":return Cte.json(e);case"text":return Cte.text(e);case"streamingSse":return Cte.streamingSse(e);case"streamingText":return Cte.streamingText(e);case"streamingJson":return Cte.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var U_o=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),description:Ct.string().optional(),example:Ct.lazy(()=>aM)});var V_o=Ct.objectWithoutOptionalProperties({schema:Ct.lazy(()=>uO).optional(),examples:Ct.list(U_o).optional()}).extend(vf).extend(Bb).extend($h);var Zfn=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),url:Ct.string().optional(),audiences:Ct.list(Ct.string()).optional()});var W_o=Ct.unknown();var H_o=Ct.objectWithoutOptionalProperties({name:Ct.string(),parameterNameOverride:Ct.string().optional(),value:Ct.lazy(()=>aM)});var kfn=Ct.objectWithoutOptionalProperties({name:Ct.string(),value:Ct.lazy(()=>aM)});var edn=Ct.objectWithoutOptionalProperties({name:Ct.string(),value:Ct.lazy(()=>aM)});var $_o=Ct.objectWithoutOptionalProperties({sse:Ct.boolean(),events:Ct.list(Ct.lazy(()=>aM))});var G_o=Ct.union("type",{withStreaming:$_o,withoutStreaming:Ct.object({value:Ct.lazy(()=>aM)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return LBe.withStreaming(e);case"withoutStreaming":return LBe.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Q_o=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),language:Ct.string(),code:Ct.string(),install:Ct.string().optional()}).extend(vf);var J_o=Ct.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var K_o=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),sdk:J_o,code:Ct.string()}).extend(vf);var Y_o=Ct.union("type",{language:Q_o,sdk:K_o}).transform({transform:e=>{switch(e.type){case"language":return C8r.language(e);case"sdk":return C8r.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var X_o=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),pathParameters:Ct.list(H_o).optional(),queryParameters:Ct.list(kfn).optional(),headers:Ct.list(edn).optional(),request:Ct.lazy(()=>aM).optional(),response:G_o.optional(),codeSamples:Ct.list(Y_o)}).extend(vf);var tdn=Ct.union("type",{unknown:Ct.object({value:W_o}),full:X_o}).transform({transform:e=>{switch(e.type){case"unknown":return L2t.unknown(e.value);case"full":return L2t.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var Z_o=Ct.objectWithoutOptionalProperties({cursor:Ct.string(),nextCursor:Ct.property("next_cursor",Ct.string()),results:Ct.string()});var k_o=Ct.objectWithoutOptionalProperties({offset:Ct.string(),results:Ct.string(),step:Ct.string().optional(),hasNextPage:Ct.string().optional()});var rdn=Ct.union("type",{cursor:Z_o,offset:k_o}).transform({transform:e=>{switch(e.type){case"cursor":return T8r.cursor(e);case"offset":return T8r.offset(e);default:return e}},untransform:({_visit:e,...t})=>t});var eho=Ct.objectWithoutOptionalProperties({authed:Ct.boolean(),internal:Ct.boolean().optional(),idempotent:Ct.boolean().optional(),method:$fn,audiences:Ct.list(Ct.string()),path:Ct.string(),summary:Ct.string().optional(),operationId:Ct.string().optional(),tags:Ct.list(_K),pathParameters:Ct.list(Gfn),queryParameters:Ct.list(Qfn),headers:Ct.list(Iei),sdkName:aQt.optional(),generatedRequestName:Ct.string(),requestNameOverride:Ct.string().optional(),request:N_o.optional(),response:L_o.optional(),errors:Ct.record(rQt,V_o),server:Ct.list(Zfn),examples:Ct.list(tdn),pagination:rdn.optional()}).extend(vf).extend(Q_).extend($h).extend(nQt);var idn=Ct.enum_(["GET","POST"]);var ndn=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),payload:Ct.lazy(()=>aM)}).extend(vf);var tho=Ct.objectWithoutOptionalProperties({sdkName:aQt.optional(),method:idn,summary:Ct.string().optional(),operationId:Ct.string(),tags:Ct.list(_K),headers:Ct.list(Iei),generatedPayloadName:Ct.string(),payload:Ct.lazy(()=>uO),examples:Ct.list(ndn)}).extend(vf).extend($h).extend(nQt);var rho=Ct.objectWithoutOptionalProperties({queryParameters:Ct.list(Qfn),headers:Ct.list(Iei),pathParameters:Ct.list(Gfn)});var iho=Ct.objectWithoutOptionalProperties({messageType:Ct.string(),payload:Ct.lazy(()=>aM)}).extend(vf);var nho=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),queryParameters:Ct.list(kfn).optional(),headers:Ct.list(edn).optional(),messages:Ct.list(iho)}).extend(vf);var aho=Ct.objectWithoutOptionalProperties({audiences:Ct.list(Ct.string()),path:Ct.string(),groupName:xei,summary:Ct.string().optional(),handshake:rho,publish:Ct.lazy(()=>uO).optional(),subscribe:Ct.lazy(()=>uO).optional(),examples:Ct.list(nho)}).extend(vf).extend($h);var oho=Ct.objectWithoutOptionalProperties({rootSchemas:Ct.record(pK,Ct.lazy(()=>uO)),namespacedSchemas:Ct.record(A_o,Ct.record(pK,Ct.lazy(()=>uO)))});var uho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),minimum:Ct.number().optional(),maximum:Ct.number().optional(),exclusiveMinimum:Ct.boolean().optional(),exclusiveMaximum:Ct.boolean().optional(),multipleOf:Ct.number().optional()});var sho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional()});var cho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),minimum:Ct.number().optional(),maximum:Ct.number().optional(),exclusiveMinimum:Ct.boolean().optional(),exclusiveMaximum:Ct.boolean().optional(),multipleOf:Ct.number().optional()});var lho=Ct.objectWithoutOptionalProperties({default:Ct.string().optional(),pattern:Ct.string().optional(),format:Ct.string().optional(),minLength:Ct.number().optional(),maxLength:Ct.number().optional()});var fho=Ct.objectWithoutOptionalProperties({default:Ct.boolean().optional()});var dho=Ct.union("type",{int:uho,int64:sho,uint:Ct.object({}),uint64:Ct.object({}),float:Ct.object({}),double:cho,string:lho,datetime:Ct.object({}),date:Ct.object({}),base64:Ct.object({}),boolean:fho}).transform({transform:e=>{switch(e.type){case"int":return WP.int(e);case"int64":return WP.int64(e);case"uint":return WP.uint();case"uint64":return WP.uint64();case"float":return WP.float();case"double":return WP.double(e);case"string":return WP.string(e);case"datetime":return WP.datetime();case"date":return WP.date();case"base64":return WP.base64();case"boolean":return WP.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var Rei=Ct.objectWithoutOptionalProperties({schema:dho}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(aO);var pho=Ct.objectWithoutOptionalProperties({header:Ct.string(),name:Ct.string().optional(),optional:Ct.boolean().optional(),env:Ct.string().optional(),schema:Ct.lazy(()=>uO).optional()});var _ho=Ct.objectWithoutOptionalProperties({header:Ct.string(),name:Ct.string().optional(),env:Ct.string().optional(),schema:Ct.lazy(()=>uO).optional()});var fcp=Ct.objectWithoutOptionalProperties({apiVersion:Ct.unknown().optional(),title:Ct.string().optional(),description:Ct.string().optional(),basePath:Ct.string().optional(),servers:Ct.list(E_o),groups:Ct.record(Ct.string(),B_o),tags:x_o,hasEndpointsMarkedInternal:Ct.boolean(),endpoints:Ct.list(eho),webhooks:Ct.list(tho),channel:Ct.list(aho),groupedSchemas:oho,variables:Ct.record(Ct.string(),Rei),nonRequestReferencedSchemas:Ct.set(pK),securitySchemes:Ct.record(v_o,D_o),globalHeaders:Ct.list(pho).optional(),idempotencyHeaders:Ct.list(_ho).optional()});var oQt=Ct.objectWithoutOptionalProperties({schema:pK}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend($h).extend(aO);var hho=Ct.union("type",{boolean:Ct.object({value:Ct.boolean()}),string:Ct.object({value:Ct.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return bB.boolean(e.value);case"string":return bB.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var adn=Ct.objectWithoutOptionalProperties({value:hho}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(aO);var uO=Ct.union("type",{primitive:Rei,object:Ct.lazyObject(()=>yho),array:Ct.lazyObject(()=>vho),map:Ct.lazyObject(()=>bho),optional:Ct.lazyObject(()=>gho),enum:Vfn,reference:oQt,literal:adn,oneOf:Ct.object({value:Ct.lazy(()=>mho)}),nullable:Ct.lazyObject(()=>Oho),unknown:Bb}).transform({transform:e=>{switch(e.type){case"primitive":return ey.primitive(e);case"object":return ey.object(e);case"array":return ey.array(e);case"map":return ey.map(e);case"optional":return ey.optional(e);case"enum":return ey.enum(e);case"reference":return ey.reference(e);case"literal":return ey.literal(e);case"oneOf":return ey.oneOf(e.value);case"nullable":return ey.nullable(e);case"unknown":return ey.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var odn=Ct.objectWithoutOptionalProperties({propertyKey:Ct.string(),allOfSchemaIds:Ct.list(pK),conflictingTypeSignatures:Ct.boolean()});var yho=Ct.objectWithoutOptionalProperties({allOf:Ct.list(oQt),properties:Ct.list(Ct.lazyObject(()=>Pho)),allOfPropertyConflicts:Ct.list(odn),additionalProperties:Ct.boolean()}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend($h).extend(aO).extend(MD);var udn=Ct.objectWithoutOptionalProperties({differentSchema:Ct.boolean()});var Pho=Ct.objectWithoutOptionalProperties({key:Ct.string(),schema:Ct.lazy(()=>uO),readonly:Ct.boolean().optional(),conflict:Ct.record(pK,udn),generatedName:Ct.string(),nameOverride:Ct.string().optional(),audiences:Ct.list(Ct.string())}).extend(Q_);var vho=Ct.objectWithoutOptionalProperties({value:Ct.lazy(()=>uO)}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(aO).extend(MD);var bho=Ct.objectWithoutOptionalProperties({key:Rei,value:Ct.lazy(()=>uO)}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(Bte).extend(aO).extend(MD);var gho=Ct.objectWithoutOptionalProperties({value:Ct.lazy(()=>uO)}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(aO).extend(MD);var Oho=Ct.objectWithoutOptionalProperties({value:Ct.lazy(()=>uO)}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(aO).extend(MD);var mho=Ct.union("type",{discriminated:Ct.lazyObject(()=>jho),undiscriminated:Ct.lazyObject(()=>who)}).transform({transform:e=>{switch(e.type){case"discriminated":return B8r.discriminated(e);case"undiscriminated":return B8r.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var jho=Ct.objectWithoutOptionalProperties({discriminantProperty:Ct.string(),commonProperties:Ct.list(Ct.lazyObject(()=>Sho)),schemas:Ct.record(Ct.string(),Ct.lazy(()=>uO))}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(Bte).extend($h).extend(aO).extend(MD);var Sho=Ct.objectWithoutOptionalProperties({key:Ct.string(),schema:Ct.lazy(()=>uO)});var who=Ct.objectWithoutOptionalProperties({schemas:Ct.list(Ct.lazy(()=>uO))}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(Bte).extend($h).extend(aO).extend(MD);var RSs={};Ro(RSs,{ArraySchemaWithExample:()=>$ho,Base64WithExample:()=>Lho,BooleanWithExample:()=>Uho,CommonPropertyWithExample:()=>eyo,DateWithExample:()=>Nho,DatetimeWithExample:()=>Fho,DiscriminatedOneOfSchemaWithExample:()=>Zho,DoubleWithExample:()=>zho,EndpointWithExample:()=>pcp,EnumSchemaWithExample:()=>Who,FloatWithExample:()=>Iho,HeaderWithExample:()=>Fei,HttpErrorWithExample:()=>qho,Int64WithExample:()=>Cho,IntWithExample:()=>Tho,JsonRequestWithExample:()=>Eho,JsonResponseWithExample:()=>cdn,MapSchemaWithExample:()=>Gho,NamedFullExample:()=>uQt,NullableSchemaWithExample:()=>Jho,ObjectPropertyWithExample:()=>Xho,ObjectSchemaWithExample:()=>Kho,OneOfSchemaWithExample:()=>Yho,OptionalSchemaWithExample:()=>Qho,PathParameterWithExample:()=>Dho,PrimitiveSchemaValueWithExample:()=>Vho,PrimitiveSchemaWithExample:()=>ldn,QueryParameterWithExample:()=>sdn,RequestWithExample:()=>Aho,ResponseWithExample:()=>Mho,SchemaWithExample:()=>GE,StringSchemaWithExample:()=>Rho,Uint64WithExample:()=>xho,UintWithExample:()=>Bho,UnDiscriminatedOneOfSchemaWithExample:()=>kho,UnknownSchemaWithExample:()=>Hho,WebhookWithExample:()=>_cp,WebsocketHandshakeWithExample:()=>dcp});var uQt=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),value:Ct.unknown()}).extend(vf);var sdn=Ct.objectWithoutOptionalProperties({name:Ct.string(),schema:Ct.lazy(()=>GE),parameterNameOverride:Ct.string().optional()}).extend(vf).extend(Q_).extend($h);var Fei=Ct.objectWithoutOptionalProperties({name:Ct.string(),schema:Ct.lazy(()=>GE),env:Ct.string().optional(),parameterNameOverride:Ct.string().optional()}).extend(vf).extend(Q_).extend($h);var dcp=Ct.objectWithoutOptionalProperties({queryParameters:Ct.list(sdn),headers:Ct.list(Fei)});var Dho=Ct.objectWithoutOptionalProperties({name:Ct.string(),schema:Ct.lazy(()=>GE),variableReference:Ct.string().optional(),parameterNameOverride:Ct.string().optional()}).extend(vf).extend(Q_).extend($h);var Eho=Ct.objectWithoutOptionalProperties({schema:Ct.lazy(()=>GE),contentType:Ct.string().optional(),fullExamples:Ct.list(uQt).optional(),additionalProperties:Ct.boolean()}).extend(vf).extend($h);var Aho=Ct.union("type",{octetStream:Jfn,multipart:Kfn,json:Eho}).transform({transform:e=>{switch(e.type){case"octetStream":return Iwe.octetStream(e);case"multipart":return Iwe.multipart(e);case"json":return Iwe.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var cdn=Ct.objectWithoutOptionalProperties({schema:Ct.lazy(()=>GE),responseProperty:Ct.string().optional(),fullExamples:Ct.list(uQt).optional()}).extend(vf).extend($h).extend(iQt);var Mho=Ct.union("type",{file:Yfn,json:cdn,text:zei,streamingSse:cdn,streamingText:zei,streamingJson:cdn}).transform({transform:e=>{switch(e.type){case"file":return gB.file(e);case"json":return gB.json(e);case"text":return gB.text(e);case"streamingSse":return gB.streamingSse(e);case"streamingText":return gB.streamingText(e);case"streamingJson":return gB.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var qho=Ct.objectWithoutOptionalProperties({statusCode:rQt,schema:Ct.lazy(()=>GE),fullExamples:Ct.list(uQt).optional()}).extend(vf).extend(Bb).extend($h);var pcp=Ct.objectWithoutOptionalProperties({authed:Ct.boolean(),internal:Ct.boolean().optional(),idempotent:Ct.boolean().optional(),method:$fn,audiences:Ct.list(Ct.string()),path:Ct.string(),summary:Ct.string().optional(),operationId:Ct.string().optional(),tags:Ct.list(_K),pathParameters:Ct.list(Dho),queryParameters:Ct.list(sdn),headers:Ct.list(Fei),sdkName:aQt.optional(),generatedRequestName:Ct.string(),requestNameOverride:Ct.string().optional(),request:Aho.optional(),response:Mho.optional(),errors:Ct.record(rQt,qho),server:Ct.list(Zfn),examples:Ct.list(tdn),pagination:rdn.optional()}).extend(vf).extend(Q_).extend($h).extend(nQt);var _cp=Ct.objectWithoutOptionalProperties({sdkName:aQt.optional(),method:idn,summary:Ct.string().optional(),operationId:Ct.string(),tags:Ct.list(_K),headers:Ct.list(Fei),generatedPayloadName:Ct.string(),payload:Ct.lazy(()=>GE),examples:Ct.list(ndn)}).extend(vf).extend($h).extend(nQt);var Tho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),minimum:Ct.number().optional(),maximum:Ct.number().optional(),exclusiveMinimum:Ct.boolean().optional(),exclusiveMaximum:Ct.boolean().optional(),multipleOf:Ct.number().optional(),example:Ct.number().optional()});var Cho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),example:Ct.number().optional()});var Bho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),example:Ct.number().optional()});var xho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),example:Ct.number().optional()});var Iho=Ct.objectWithoutOptionalProperties({example:Ct.number().optional()});var zho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),minimum:Ct.number().optional(),maximum:Ct.number().optional(),exclusiveMinimum:Ct.boolean().optional(),exclusiveMaximum:Ct.boolean().optional(),multipleOf:Ct.number().optional(),example:Ct.number().optional()});var Rho=Ct.objectWithoutOptionalProperties({default:Ct.string().optional(),pattern:Ct.string().optional(),format:Ct.string().optional(),minLength:Ct.number().optional(),maxLength:Ct.number().optional(),example:Ct.string().optional()});var Fho=Ct.objectWithoutOptionalProperties({example:Ct.string().optional()});var Nho=Ct.objectWithoutOptionalProperties({example:Ct.string().optional()});var Lho=Ct.objectWithoutOptionalProperties({example:Ct.string().optional()});var Uho=Ct.objectWithoutOptionalProperties({default:Ct.boolean().optional(),example:Ct.boolean().optional()});var Vho=Ct.union("type",{int:Tho,int64:Cho,uint:Bho,uint64:xho,float:Iho,double:zho,string:Rho,datetime:Fho,date:Nho,base64:Lho,boolean:Uho}).transform({transform:e=>{switch(e.type){case"int":return Xd.int(e);case"int64":return Xd.int64(e);case"uint":return Xd.uint(e);case"uint64":return Xd.uint64(e);case"float":return Xd.float(e);case"double":return Xd.double(e);case"string":return Xd.string(e);case"datetime":return Xd.datetime(e);case"date":return Xd.date(e);case"base64":return Xd.base64(e);case"boolean":return Xd.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var ldn=Ct.objectWithoutOptionalProperties({schema:Vho}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(aO);var Who=Ct.objectWithoutOptionalProperties({default:Bei.optional(),values:Ct.list(Bei),example:Ct.string().optional()}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend($h).extend(aO).extend(MD);var Hho=Ct.objectWithoutOptionalProperties({example:Ct.unknown()}).extend(oO).extend(Bb).extend(vf).extend(Q_).extend(aO);var GE=Ct.union("type",{primitive:ldn,object:Ct.lazyObject(()=>Kho),array:Ct.lazyObject(()=>$ho),map:Ct.lazyObject(()=>Gho),optional:Ct.lazyObject(()=>Qho),enum:Who,reference:oQt,literal:adn,oneOf:Ct.object({value:Ct.lazy(()=>Yho)}),nullable:Ct.lazyObject(()=>Jho),unknown:Hho}).transform({transform:e=>{switch(e.type){case"primitive":return Fl.primitive(e);case"object":return Fl.object(e);case"array":return Fl.array(e);case"map":return Fl.map(e);case"optional":return Fl.optional(e);case"enum":return Fl.enum(e);case"reference":return Fl.reference(e);case"literal":return Fl.literal(e);case"oneOf":return Fl.oneOf(e.value);case"nullable":return Fl.nullable(e);case"unknown":return Fl.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var $ho=Ct.objectWithoutOptionalProperties({value:Ct.lazy(()=>GE),example:Ct.list(Ct.unknown()).optional()}).extend(oO).extend(Bb).extend(vf).extend(Q_).extend(aO).extend(MD);var Gho=Ct.objectWithoutOptionalProperties({key:ldn,value:Ct.lazy(()=>GE),example:Ct.unknown().optional()}).extend(oO).extend(Bb).extend(vf).extend(Q_).extend(Bte).extend(aO).extend(MD);var Qho=Ct.objectWithoutOptionalProperties({value:Ct.lazy(()=>GE)}).extend(oO).extend(Bb).extend(vf).extend(Q_).extend(aO).extend(MD);var Jho=Ct.objectWithoutOptionalProperties({value:Ct.lazy(()=>GE)}).extend(oO).extend(Bb).extend(vf).extend(Q_).extend(aO).extend(MD);var Kho=Ct.objectWithoutOptionalProperties({allOf:Ct.list(oQt),properties:Ct.list(Ct.lazyObject(()=>Xho)),allOfPropertyConflicts:Ct.list(odn),fullExamples:Ct.list(uQt).optional(),additionalProperties:Ct.boolean()}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend($h).extend(aO).extend(MD);var Xho=Ct.objectWithoutOptionalProperties({key:Ct.string(),schema:Ct.lazy(()=>GE),readonly:Ct.boolean().optional(),audiences:Ct.list(Ct.string()),conflict:Ct.record(pK,udn),nameOverride:Ct.string().optional(),generatedName:Ct.string()}).extend(Q_);var Yho=Ct.union("type",{discriminated:Ct.lazyObject(()=>Zho),undiscriminated:Ct.lazyObject(()=>kho)}).transform({transform:e=>{switch(e.type){case"discriminated":return dK.discriminated(e);case"undiscriminated":return dK.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Zho=Ct.objectWithoutOptionalProperties({discriminantProperty:Ct.string(),commonProperties:Ct.list(Ct.lazyObject(()=>eyo)),schemas:Ct.record(Ct.string(),Ct.lazy(()=>GE))}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(Bte).extend($h).extend(aO).extend(MD);var eyo=Ct.objectWithoutOptionalProperties({key:Ct.string(),schema:Ct.lazy(()=>GE)});var kho=Ct.objectWithoutOptionalProperties({schemas:Ct.list(Ct.lazy(()=>GE))}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(Bte).extend($h).extend(aO).extend(MD);var hcp=/^(\d+)/,fdn=/^[a-zA-Z][a-zA-Z0-9_]*$/,ycp={"<":"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 Nei(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),l=e%10;return l===0?i[u]:`${i[u]}_${t[l]}`}if(e<1e3){let u=Math.floor(e/100),l=e%100;return l===0?`${t[u]}_hundred`:`${t[u]}_hundred_${Nei(l)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${Nei(a)}`}function hZn(e){let t=e.match(hcp);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=Nei(n);return i.length>0?`${a}_${i}`:a}}}function ddn(e){let t=hZn(e),r=ycp[e];return t!=null?G9(pg(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":G9(pg(e)))}function xte(e,t){return e.type==="primitive"&&t.type==="primitive"?vcp(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?vwS(e.values,t.values):e.type==="array"&&t.type==="array"?xte(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"?xte(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?bwS(e.value,t.value):e.type==="object"&&t.type==="object"?gwS(e,t):e.type==="map"&&t.type==="map"?vcp(e.key.schema,t.key.schema)&&xte(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function vcp(e,t){return e.type===t.type}function vwS(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return N3t(r,i)}function bwS(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,i])=>{let n=t.schemas[r];return n==null?!1:xte(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:xte(r,n)}):!1}function gwS(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:xte(a,n.schema)})}var c2;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(c2||(c2={}));var tyo=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=u,this.globalHeaderOverrides=a,this.detectGlobalHeaders=i?.detectGlobalHeaders??!0,this.objectQueryParameters=i?.objectQueryParameters??!1,this.respectReadonlySchemas=i?.respectReadonlySchemas??!1,this.respectNullableSchemas=i?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=i?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=i?.inlinePathParameters??!1,this.referencedSchemaIds=i?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=i?.enableUniqueErrorsPerEndpoint??!1,this.builder=new iSi(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let l={};if(!this.enableUniqueErrorsPerEndpoint)for(let f of r.endpoints)for(let[s,o]of Object.entries(f.errors)){let c=parseInt(s),b=l[c];b==null&&o.schema!=null?l[c]=o.schema:b!=null&&o.schema!=null&&xte(b,o.schema)||this.unknownSchema.add(c)}}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(c2.Channel,c2.Endpoint,c2.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:Zo(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:Zo(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function gx(e){switch(e){case GL.Deprecated:return"deprecated";case GL.Beta:return"pre-release";case GL.GenerallyAvailable:return"generally-available";default:return}}function OwS(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function bcp(e){let t=e?OwS(e):void 0;if(t==null||t.length===0)return FOi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(pg(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(pg(n.name)):r.push(n.name,FOi);break}default:Zo(n.type)}else Zo(n);return r.join("/")}function pdn(e){return Wh.of(`${bcp(e)}.yml`)}function FSs({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?FOi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,bcp(r))}function gcp({sdkName:e,namespaceOverride:t}){return Wh.of(`${FSs({sdkName:e,namespaceOverride:t})}.yml`)}function Ocp({location:e,namespaceOverride:t}){return t!=null?Dz(Wh.of(t),e):e}function ryo(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Zo(e.type)}}function _dn(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:Zo(e)}}function QE(e){return typeof e=="string"?e:e.type}function hdn(e){if(typeof e!="string")return e.docs}function yZn(e){if(typeof e!="string")return e.default}function NSs(e){if(typeof e!="string")return e.validation}var mwS=-2147483648,PwS=2147483647,jwS=-17976931348623157e292,wwS=17976931348623157e292;function h0({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return iyo(e);case"array":return VSs({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return WSs({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return USs({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return $Ss();case"optional":return nyo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return HSs({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return BwS({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,GSs(e);case"object":return xwS({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return IwS({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:Zo(e)}}function iyo(e){switch(e.schema.type){case"string":return EwS({description:e.description,schema:e.schema});case"int":return AwS({description:e.description,schema:e.schema});case"float":return MwS({description:e.description,schema:e.schema});case"double":return qwS({description:e.description,schema:e.schema});case"boolean":return SwS({description:e.description,schema:e.schema});case"int64":return DwS({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:gx(e.availability)}:{}}}function SwS({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function DwS({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function EwS({description:e,schema:t}){let r="string",i=TwS(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function AwS({description:e,schema:t}){let r="integer",i=Pcp(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function MwS({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function qwS({description:e,schema:t}){let r="double",i=Pcp(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function TwS(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=CwS(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function CwS(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 Pcp(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=LSs(r,t),i=LSs(i,t),n=LSs(n,t),!(r==null&&i==null&&a==null&&u==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:u,multipleOf:n}}function LSs(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[mwS,PwS]:[jwS,wwS];return e<r||e>i?void 0:e}function USs({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=zwS(n)??e.schema,u=_dn(n),l=RwS(n),f=ayo({context:r,fileContainingReference:t,declarationFile:pdn(u),type:a}),s=n.type==="nullable"?`optional<${f}>`:f;return e.description==null&&l==null?s:{type:n.type==="nullable"?`optional<${f}>`:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gx(e.availability)}:{}}}function VSs({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=h0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=`list<${QE(u)}>`;return e.description==null&&e.title==null?l:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gx(e.availability)}:{},type:l}}function WSs({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=iyo(e.key),l=h0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),f=e.encoding!=null?ryo(e.encoding):void 0,s=`map<${QE(u)}, ${QE(l)}>`;if(e.description==null&&f==null&&e.title==null)return s;let o={type:s};return e.description!=null&&(o.docs=e.description),e.encoding!=null&&(o.encoding=f),e.availability!=null&&(o.availability=gx(e.availability)),o}function HSs({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.respectNullableSchemas)return nyo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let u=h0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=QE(u),f=hdn(u),s=yZn(u),o=NSs(u),c=l.startsWith("nullable<")?l:`nullable<${l}>`;if(e.availability==null&&e.description==null&&f==null&&s==null&&o==null&&e.title==null)return mcp({typeReference:c,itemType:l});let b={type:c};return(e.description!=null||f!=null)&&(b.docs=e.description??f),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=gx(e.availability)),mcp({typeReference:b,itemType:l})}function nyo({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=h0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=QE(u),f=hdn(u),s=yZn(u),o=NSs(u),c=l.startsWith("optional<")?l:`optional<${l}>`;if(e.availability==null&&e.description==null&&f==null&&s==null&&o==null&&e.title==null)return c;let b={type:c};return(e.description!=null||f!=null)&&(b.docs=e.description??f),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=gx(e.availability)),b}function $Ss(){return"unknown"}function GSs(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Zo(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gx(e.availability)}:{}}}function BwS({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=vZn(e,n),u=e.nameOverride??e.generatedName;i.builder.addType(r,{name:u,schema:a.schema});let l=ayo({type:u,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return l;let f={type:l};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.availability!=null&&(f.availability=gx(e.availability)),f}function xwS({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=QSs({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=e.nameOverride??e.generatedName;i.builder.addType(r,{name:l,schema:u.schema});let f=ayo({type:l,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?f:{type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gx(e.availability)}:{}}}function IwS({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=JSs({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=e.nameOverride??e.generatedName;i.builder.addType(r,{name:l,schema:u.schema});let f=ayo({type:l,fileContainingReference:t,declarationFile:r,context:i});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:gx(e.availability)}:{}}}function ayo({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function zwS(e){return ey._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 RwS(e){return ey._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 mcp({typeReference:e,itemType:t}){return t.startsWith("optional<")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}function x8r(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Zo(e)}}function wcp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=LwS(e);break;case"array":a=FwS({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=NwS({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=UwS({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=WwS(e.nameOverride,e.generatedName);break;case"optional":a=Scp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=VwS({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=vZn(e,n);break;case"literal":a=HwS(e,e.nameOverride,e.generatedName);break;case"object":a=QSs({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=JSs({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:Zo(e)}return a}function QSs({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(c2.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),u=!1,l={},f=new Set;for(let g of e.properties){if(g.readonly&&(u=!0),a&&g.readonly)continue;if(Object.keys(g.conflict).length>0){if(Object.entries(g.conflict).every(([q,D])=>!D.differentSchema))continue;Object.entries(g.conflict).forEach(([q])=>{KSs({property:g.key,schemaId:q,context:t,namespace:i}).forEach(C=>{f.add(C)})})}let O=h0({schema:g.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),m=g.audiences,w=g.nameOverride,A=gx(g.availability);l[g.key]=QwS({typeReference:O,audiences:m,name:w,availability:A})}let s=new Set;for(let g of e.allOfPropertyConflicts)g.allOfSchemaIds.forEach(O=>f.add(O)),g.conflictingTypeSignatures&&s.add(g.propertyKey);let o=[];for(let g of e.allOf){let O=Dcp({schema:g.schema,context:t,namespace:i});if(O==null||f.has(g.schema)||f.has(O))continue;let m=h0({schema:ey.reference(g),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(QE(m))}for(let g of f){let O=YSs(t,g,i);for(let m of O.properties)l[m.key]==null&&(s.has(m.key)&&(l[m.key]="unknown"),l[m.key]=h0({schema:m.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let m of O.allOf){if(f.has(m.schema))continue;let w=h0({schema:ey.reference(m),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(QE(w))}}let c={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(l).map(([g,O])=>GwS(g)?[g,typeof O=="string"?{type:O,name:`_${g}`}:{...O,name:`_${g}`}]:[g,O]))};o.length>0&&(c.extends=o),e.additionalProperties&&(c["extra-properties"]=!0),e.availability!=null&&(c.availability=gx(e.availability)),e.source!=null&&(c.source=x8r(e.source)),c.inline=XSs(e,n);let b=e.nameOverride??e.generatedName;return{name:u&&t.respectReadonlySchemas&&!a?`${b}Read`:b,schema:c}}function KSs({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return KSs({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:u}=YSs(r,t,i),l=a.some(s=>s.key===e),f=[...u.flatMap(s=>KSs({property:e,context:r,schemaId:s.schema,namespace:i}))];if(l||f.length>0)return[t,...f]}return[]}function YSs(e,t,r){let i=e.getSchema(t,r);if(i==null)return{properties:[],allOf:[]};if(i.type==="object")return{properties:i.properties,allOf:i.allOf};if(i.type==="reference")return YSs(e,i.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${i.type}`)}function FwS({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:VSs({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function NwS({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:WSs({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function LwS(e){let t=iyo(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function jcp(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function vZn(e,t){let r={enum:e.values.map(a=>{let u=a.nameOverride??a.generatedName,l=a.value;if(u===l&&a.description==null&&(a.casing==null||jcp(a.casing)))return u;let f={value:a.value};if(u!==l&&(f.name=u),a.description!=null&&(f.docs=a.description),a.casing!=null&&!jcp(a.casing)){let s={},o=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,o=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,o=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,o=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,o=!0),o&&(f.casing=s)}return f})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=XSs(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?x8r(e.source):void 0};for(let a of r.enum){let u=typeof a=="string"?a:a.name??a.value;i.has(u.toLowerCase())||(n.enum.push(a),i.add(u.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function UwS({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:USs({schema:e,context:t,fileContainingReference:r,namespace:i})}}function VwS({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:HSs({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:Scp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function Scp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:nyo({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function WwS(e,t){return{name:e??t,schema:$Ss()}}function HwS(e,t,r){return{name:t??r,schema:GSs(e)}}function JSs({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?ryo(e.encoding):void 0;if(e.type==="discriminated"){let l={};for(let s of e.commonProperties)l[s.key]=h0({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let f={};for(let[s,o]of Object.entries(e.schemas))f[s]=h0({schema:o,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":l,docs:e.description??void 0,availability:e.availability!=null?gx(e.availability):void 0,union:f,encoding:a,source:e.source!=null?x8r(e.source):void 0}}}let u=[];for(let l of e.schemas)u.push(h0({schema:l,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:u,encoding:a,source:e.source!=null?x8r(e.source):void 0,inline:XSs(e,n)}}}var $wS=/^[0-9]/;function GwS(e){return $wS.test(e)}function Dcp({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?Dcp({context:t,schema:i.schema,namespace:r}):e}function QwS({typeReference:e,audiences:t,name:r,availability:i}){return t.length===0&&r==null&&i==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{}}}function XSs(e,t){return e.inline===!0||t>0?!0:void 0}function Ecp(e){let t=e.replace(/^x-|^X-/,"");return pg(t)}var Acp="BasicAuthScheme",oyo="BearerAuthScheme";function Mcp(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:Acp,schema:n}),t||(e.builder.setAuth(Acp),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:oyo,schema:n}),t||(e.builder.setAuth(oyo),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??Ecp(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:oyo,schema:n}),t||(e.builder.setAuth(oyo),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(Wh.of("__package__.yml"),{name:"OauthScope",schema:vZn(i.scopesEnum,0).schema})}}function sQt({header:e,context:t,fileContainingReference:r,namespace:i}){let n=h0({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=QE(n),u=e.name.replace(/^x-|^X-/,""),l=e.parameterNameOverride!=null?e.parameterNameOverride:pg(u);if(e.description==null&&e.name===l&&e.env==null&&e.availability==null)return a;let f={type:a};return l!==e.name&&(f.name=l),e.description!=null&&(f.docs=e.description),e.env!=null&&(f.env=e.env),e.availability!=null&&(f.availability=gx(e.availability)),f}function uyo({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=h0({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return QE(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:QE(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=gx(e.availability)),a}function cyo({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=ZSs({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=QE(n.value),u=yZn(n.value);if(a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>"),e.description==null&&!n.allowMultiple&&e.parameterNameOverride==null&&e.availability==null)return a;let l={type:a};return u!=null&&(l.default=u),n.allowMultiple&&(l["allow-multiple"]=!0),e.description!=null&&(l.docs=e.description),e.parameterNameOverride!=null&&(l.name=e.parameterNameOverride),e.availability!=null&&(l.availability=gx(e.availability)),JwS(n.value)&&n.value.validation!==void 0&&(l.validation=n.value.validation),l}function ZSs({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,groupName:void 0,inline:void 0}),context:t,declarationFile:Wh.of(P1),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[];for(let[u,l]of Object.entries(n.value.schemas))l.type==="literal"&&l.value.type==="string"&&(fdn.test(l.value.value)?a.push(l.value.value):a.push({value:l.value.value,name:ddn(l.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[u,l]=n.value.schemas;if(u!=null&&l!=null&&syo({array:u,primitive:l}))return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:l,description:e.description,availability:e.availability,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(u!=null&&l!=null&&syo({array:u,primitive:l}))return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[u,l]of Object.entries(n.value.schemas))return ZSs({schema:l,context:t,fileContainingReference:r,namespace:i})}else if(t.objectQueryParameters)return{value:h0({schema:e,context:t,fileContainingReference:r,declarationFile:Wh.of(P1),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let n=t.getSchema(e.value.schema,i);if(n==null)return;if(n.type==="array")return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:Wh.of(P1),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:h0({schema:e,context:t,fileContainingReference:r,declarationFile:Wh.of(P1),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let n=[];for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="literal"&&u.value.type==="string"&&(fdn.test(u.value.value)?n.push(u.value.value):n.push({value:u.value.value,name:ddn(u.value.value)}));if(n.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:n}}),{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&&syo({array:a,primitive:u}))return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(a!=null&&u!=null&&syo({array:u,primitive:a}))return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[a,u]of Object.entries(e.value.value.schemas))return ZSs({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.objectQueryParameters?{value:h0({schema:e,context:t,fileContainingReference:r,declarationFile:Wh.of(P1),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:h0({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:h0({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function syo({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function JwS(e){return e.type!=null}function qcp({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"]=KwS(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=YwS({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=Lei(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function KwS(e){let t={};return e.forEach(r=>{let i=Lei(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function YwS({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=Lei(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function Lei(e){switch(e.type){case"primitive":return Tcp(e.value);case"object":return Ccp(e.properties);case"array":return XwS(e.value);case"map":return ZwS(e.value);case"oneOf":return kwS(e.value);case"enum":return e.value;case"literal":return e1S(e.value);case"unknown":return Lei(e.value);default:Zo(e)}}function Tcp(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:Zo(e)}}function Ccp(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Lei(r)]))}function XwS(e){return e.map(t=>Lei(t))}function ZwS(e){return Object.fromEntries(e.map(t=>[Tcp(t.key),Lei(t.value)]))}function kwS(e){return e.type==="discriminated"?Ccp(e.value):Lei(e.value)}function e1S(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Zo(e)}}function I8r(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function lyo(e,t){return t??(e?.groupName!=null?I8r(e.groupName):void 0)}function Bcp({channel:e,context:t,declarationFile:r}){let i={path:e.path,auth:!1};e.audiences!=null&&e.audiences.length>0&&(i.audiences=e.audiences),e.summary!=null&&(i["display-name"]=e.summary);let n=I8r(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let f of e.handshake.pathParameters)a[f.name]=uyo({pathParameter:f,context:t,fileContainingReference:r,namespace:n});Object.keys(a).length>0&&(i["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let f of e.handshake.queryParameters){let s=cyo({queryParameter:f,context:t,fileContainingReference:r,namespace:n});s!=null&&(u[f.name]=s)}Object.keys(u).length>0&&(i["query-parameters"]=u);let l={};if(e.handshake.headers.length>0)for(let f of e.handshake.headers){let s=sQt({header:f,context:t,fileContainingReference:r,namespace:n});l[f.name]=s}Object.keys(l).length>0&&(i.headers=l),t.builder.addChannel(r,{channel:i}),e.subscribe!=null&&t.builder.addChannelMessage(r,{messageId:"subscribe",message:{origin:"server",body:h0({schema:e.subscribe,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}}),e.publish!=null&&t.builder.addChannelMessage(r,{messageId:"publish",message:{origin:"client",body:h0({schema:e.publish,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}});for(let f of e.examples){let s=qcp({context:t,websocketExample:f});t.builder.addChannelExample(r,{example:s})}}var xcp="Production",Icp="Default";function zcp(e){return Object.entries(e).reduce((t,[r,i])=>(hnn(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function Rcp(e){if(e.environmentOverrides!=null){for(let[l,f]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:l,schema:f});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 l of e.ir.servers){let f=l.audiences?{url:l.url,audiences:l.audiences}:l.url;if(l.name==null){r.push(f);continue}t[l.name]=f}let i={},n=[];for(let l of e.ir.endpoints)for(let f of l.server){if(f.url==null)continue;let s=f.audiences?{url:f.url,audiences:f.audiences}:f.url;if(f.name==null){n.push(s);continue}i[f.name]=s}let a=Object.keys(t).length,u=Object.keys(i).length;if(a===0&&u===0){let l=e.ir.servers[0]?.url,f=e.ir.servers[0]?.audiences;l!=null&&(e.builder.addEnvironment({name:Icp,schema:f?{url:l,audiences:f}:l}),e.builder.setDefaultEnvironment(Icp))}else if(a>0&&u===0){let l=0;r.length>0&&e.logger.error(`Skipping servers ${r.map(f=>typeof f=="string"?f:f.url).join(", ")} because x-fern-server-name was not provided.`);for(let[f,s]of Object.entries(t))l===0&&e.builder.setDefaultEnvironment(f),e.builder.addEnvironment({name:f,schema:s}),l+=1}else if(u>0){(r.length>0||n.length>0)&&e.logger.error(`Skipping servers ${[...r,...n].map(f=>typeof f=="string"?f:f.url).join(", ")} because x-fern-server-name was not provided.`);let l=Object.entries(t)[0];if(l!=null){let[f,s]=l;e.setDefaultServerName(f)}e.builder.addEnvironment({name:xcp,schema:{urls:{...zcp(t),...zcp(i)}}}),e.builder.setDefaultEnvironment(xcp)}}function fyo(e){return QE(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var kSs=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},t1S=.75,r1S=new Set("authorization");function Fcp(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?_dn(i.schema):void 0,u=a!=null?I8r(a):void 0,l=Wh.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?QE(h0({schema:i.schema,context:e,fileContainingReference:u?Dz(Wh.of(pg(u)),l):l,namespace:u,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(r1S.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let l=t[a.name],f=sQt({header:{...a,schema:l?.schema??a.schema,name:l?.name??a.name},fileContainingReference:Wh.of(UN),context:e,namespace:void 0});u=new kSs(f),r[a.name]=u}u.increment()}let i=e.ir.endpoints.length*t1S;for(let[n,a]of Object.entries(r)){let u=t[n],l=a.count===e.ir.endpoints.length,f=a.count>=i;u==null&&(l?e.builder.addGlobalHeader({name:n,schema:a.schema}):f&&e.builder.addGlobalHeader({name:n,schema:fyo(a.schema)}))}}}function Ncp(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?_dn(t.schema):void 0,i=r!=null?I8r(r):void 0,n=sQt({header:{...t,schema:t.schema??ey.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:WP.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:Wh.of(UN),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:fyo(n)})}}function NH(e){switch(e.type){case"primitive":return Ucp(e.value);case"object":return Vcp(e.properties);case"array":return Wcp(e.value);case"map":return n1S(e.value);case"oneOf":return a1S(e.value);case"enum":return e.value;case"literal":return o1S(e.value);case"unknown":return NH(e.value);default:Zo(e)}}function Lcp(e){switch(e.type){case"withStreaming":return e.sse?{stream:i1S(e.events)}:{stream:Wcp(e.events)};case"withoutStreaming":return{body:NH(e.value)};default:Zo(e)}}function Ucp(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:Zo(e)}}function Vcp(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,NH(r)]))}function i1S(e){return e.map(t=>({event:"",data:NH(t)}))}function Wcp(e){return e.map(t=>NH(t))}function n1S(e){return Object.fromEntries(e.map(t=>[Ucp(t.key),NH(t.value)]))}function a1S(e){return e.type==="discriminated"?Vcp(e.value):NH(e.value)}function o1S(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Zo(e)}}function Hcp({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"]=u1S(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=s1S(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=c1S({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=NH(e.request)),e.response!=null&&(r.response=Lcp(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(i=>i.type==="language"?{name:i.name??void 0,docs:i.description??void 0,language:i.language,code:i.code,install:i.install??void 0}:{name:i.name??void 0,docs:i.description??void 0,sdk:i.sdk,code:i.code}).filter(dg)),r)}function u1S(e){let t={};return e.forEach(r=>{let i=NH(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function s1S(e){let t={};return e.forEach(r=>{let i=NH(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function c1S({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=NH(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function $cp(e){return RH._visit(e,{get:()=>lH.HttpMethodSchema.Get,post:()=>lH.HttpMethodSchema.Post,put:()=>lH.HttpMethodSchema.Put,patch:()=>lH.HttpMethodSchema.Patch,delete:()=>lH.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("Unknown http method is unsupported")}})}function Gcp(e){return e==="POST"||e==="PUT"||e==="PATCH"}function Qcp({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,u=e.path,l=lyo(e.sdkName,e.namespace),f={};for(let m of e.pathParameters)m.parameterNameOverride&&(u=u.replace(m.name,m.parameterNameOverride)),f[m.parameterNameOverride??m.name]=uyo({pathParameter:m,context:r,fileContainingReference:t,namespace:l}),a.add(m.name);let s={};for(let m of e.queryParameters){let w=cyo({queryParameter:m,context:r,fileContainingReference:t,namespace:l});w!=null&&(s[m.name]=w,a.add(m.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 c={path:u,method:$cp(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?x8r(e.source):void 0};!d1S({context:r,request:e.request})&&Object.keys(f).length>0&&(c["path-parameters"]=f),e.summary!=null&&(c["display-name"]=e.summary);let b={},g=r.builder.getGlobalHeaderNames(),O=e.headers.filter(m=>!g.has(m.name));for(let m of O){let w=sQt({header:m,context:r,fileContainingReference:t,namespace:l});b[m.name]=w,a.add(typeof w=="string"?m.name:w.name??m.name)}if(e.request!=null){r.setInState(c2.Request);let m=f1S({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(f).length>0?f:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(b).length>0?b:void 0,usedNames:a,namespace:l});c.request=m.value,n=[...n,...m.schemaIdsToExclude??[]],r.unsetInState(c2.Request)}else{let m=r.inlinePathParameters&&Object.keys(f).length>0,w=Object.keys(s).length>0,A=Object.keys(b).length>0,M={};(m||w||A)&&(M.name=e.requestNameOverride??e.generatedRequestName),m&&(M["path-parameters"]=f),w&&(M["query-parameters"]=s),A&&(M.headers=b),Object.keys(M).length>0&&(c.request=M)}if(e.response!=null&&e.response._visit({json:m=>{let w=h0({schema:m.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c.response={docs:m.description??void 0,type:QE(w)},m.statusCode!=null&&(c.response["status-code"]=m.statusCode),m.responseProperty!=null&&(c.response.property=m.responseProperty)},streamingJson:m=>{let w=h0({schema:m.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c["response-stream"]={docs:m.description??void 0,type:QE(w),format:"json"}},streamingSse:m=>{let w=h0({schema:m.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c["response-stream"]={docs:m.description??void 0,type:QE(w),format:"sse"}},file:m=>{c.response={docs:m.description??void 0,type:"file","status-code":m.statusCode}},streamingText:m=>{c["response-stream"]={docs:m.description??void 0,type:"text"}},text:m=>{c.response={docs:m.description??void 0,type:"text","status-code":m.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let m=r.getDefaultServerName(),w=e.server[0];w==null?m!=null&&(c.url=m):c.url=w.name??void 0}return e.idempotent&&(c.idempotent=!0),e.availability!=null&&(c.availability=gx(e.availability)),Object.entries(e.errors).forEach(([m,w])=>{let A=w.generatedName,M=Wh.of(P1);r.builder.enableUniqueErrorsPerEndpoint&&(A=`${e.generatedRequestName}${w.generatedName}`,w.schema!=null&&(w.schema.type!=="reference"&&w.schema.type!=="oneOf"?w.schema.generatedName=`${e.generatedRequestName}${w.schema.generatedName}`:w.schema.type==="oneOf"&&(w.schema.value.generatedName=`${e.generatedRequestName}${w.schema.value.generatedName}`)));let q={"status-code":parseInt(m)},D=Ocp({location:Jcp,namespaceOverride:l});if(w.schema!=null){let $=h0({schema:w.schema,context:r,fileContainingReference:D,declarationFile:D,namespace:l,declarationDepth:0});q.type=QE($),q.docs=w.description}r.builder.addError(D,{name:A,schema:r.isErrorUnknownSchema(parseInt(m))?{...q,type:"unknown"}:q}),c.errors==null&&(c.errors=[]);let C=r.builder.addImport({file:t,fileToImport:D});c.errors.push(C!=null?`${C}.${A}`:A),q.type!=null&&w.examples?.forEach($=>{let I={value:NH($.example),name:$.name,docs:$.description};r.builder.addErrorExample(D,{name:A,example:I})})}),e.examples.length>0&&(c.examples=l1S({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?c.audiences=[eDs,...e.audiences]:e.audiences.length>0&&(c.audiences=e.audiences),{value:c,schemaIdsToExclude:n}}function l1S({endpointExamples:e,context:t}){return e.map(r=>{try{return Hcp({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function f1S({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:u,queryParameters:l,nonRequestReferencedSchemas:f,headers:s,usedNames:o,namespace:c}){if(i.type==="json"){let b=i.schema.type==="reference"?i.schema.schema:void 0,g=i.schema.type==="reference"?r.getSchema(i.schema.schema,c):i.schema;if(g?.type!=="object"||b!=null&&f.includes(b)){let M=h0({schema:i.schema,fileContainingReference:t,context:r,namespace:c,declarationDepth:0}),q={schemaIdsToExclude:[],value:{body:M}},D=Object.keys(u??{}).length>0,C=Object.keys(l??{}).length>0,R=Object.keys(s??{}).length>0;return D&&(q.value["path-parameters"]=u),C&&(q.value["query-parameters"]=l),R&&(q.value.headers=s),(D||C||R)&&(q.value.name=n??a),i.contentType!=null&&(q.value["content-type"]=i.contentType),i.description!=null&&(q.value.docs=i.description),q}let O=Object.fromEntries(g.properties.filter(M=>M.readonly==null?!0:!(Gcp(e.method)&&M.readonly)).map(M=>{let q=h0({schema:M.schema,fileContainingReference:t,context:r,namespace:c,declarationDepth:1}),D=M.nameOverride??M.key,C=gx(M.availability);if(!o.has(D)&&M.audiences.length<=0)return o.add(D),M.nameOverride!=null?[M.key,{type:QE(q),docs:hdn(q),name:M.nameOverride,availability:C}]:[M.key,C?{...typeof q=="string"?{type:q}:q,availability:C}:q];let R={type:QE(q),docs:hdn(q)};return o.has(D)&&(R.name=M.generatedName),M.audiences.length>0&&(R.audiences=M.audiences),C!=null&&(R.availability=C),o.add(D),[M.key,R]})),m=g.allOf.map(M=>{let q=h0({schema:ey.reference(M),fileContainingReference:t,context:r,namespace:c,declarationDepth:0});return QE(q)}),w={properties:O};m.length>0&&(w.extends=m),i.additionalProperties&&(w["extra-properties"]=!0);let A={name:n??g.nameOverride??g.generatedName,"path-parameters":u,"query-parameters":l,headers:s,body:w};return i.contentType!=null&&(A["content-type"]=i.contentType),i.description!=null&&(A.docs=i.description),{schemaIdsToExclude:b!=null?[b]:[],value:A}}else{if(i.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":aB.APPLICATION_OCTET_STREAM,...i.description?{docs:i.description}:{}}};if(i.type==="multipart"){let b=Object.fromEntries(i.properties.map(g=>{if(g.schema.type==="file"){let O=g.schema.isArray?"list<file>":"file";if(O=g.schema.isOptional?`optional<${O}>`:O,g.description!=null||g.contentType!=null){let m={type:O};if(g.description!=null&&(m.docs=g.description),g.contentType!=null){let w=g.contentType.split(",")[0];m["content-type"]=w}return[g.key,m]}return[g.key,O]}else{let O=h0({schema:g.schema.value,fileContainingReference:t,context:r,namespace:c,declarationDepth:1});return g.contentType!=null&&(typeof O=="string"?O={type:O,"content-type":g.contentType}:O["content-type"]=g.contentType),[g.key,O]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":u,"query-parameters":l,headers:s,body:{properties:b},"content-type":aB.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else Zo(i)}}function d1S({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;default:Zo(t)}}function p1S({location:e,namespaceOverride:t}){return t!=null?{...e,file:Dz(Wh.of(t),e.file)}:e}function _1S(e){let t=e.namespace,r=e.tags.filter(f=>f!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:Wh.of(`${pg(r)}.yml`),endpointId:e.summary!=null?pg(e.summary):pg(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Wh.of(P1),endpointId:pg(e.summary)}:{file:Wh.of(P1),endpointId:pg(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Wh.of(P1),endpointId:i};let n=bZn(r),a=bZn(i);if(N3t(n,a))return{file:Wh.of("__package__.yml"),endpointId:r};let u=v1S({operationId:i,tag:r,path:e.path,method:e.method});if(u!=null)return u;let l=[];for(let f=0;f<n.length;++f){let s=n[f];if(s!=null&&s===a[f])l.push(s);else{let o=pg(r);return{file:Wh.of(`${o}.yml`),endpointId:i,tag:r}}}if(l.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:Wh.of(pg(l.join("_"))+".yml"),endpointId:pg(a.slice(l.length).join("_")),tag:r}}function gZn(e){let t=e.tags[0];if(e.sdkName!=null){let r=FSs({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Wh.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return p1S({namespaceOverride:e.namespace,location:_1S(e)})}function bZn(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=BUt(t),t}var h1S=new RegExp("[^a-zA-Z0-9{}]+"),y1S=new RegExp("[{}]","g");function v1S({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(h1S).join("_").replaceAll(y1S,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:Wh.of(pg(t)+".yml"),endpointId:pg(e.slice(0,-1*a.length)),tag:t}}function Kcp(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:u,file:l,tag:f}=gZn(a),s=l.split(".")[0];s!=null&&t.add(s);let o;if(a.sdkName!=null){let g=e.ir.groups;for(let O of a.sdkName.groupName){let m=typeof O=="string"?O:O.name,w=g[m];if(w==null)break;if(w.summary!=null||w.description!=null){o=g[m];break}}}let c=f==null?void 0:i.tagsById[f];e.setInState(c2.Endpoint),e.setEndpointMethod(a.method);let b=Qcp({context:e,endpoint:a,declarationFile:l});e.unsetEndpointMethod(),e.unsetInState(c2.Endpoint),n=[...n,...b.schemaIdsToExclude],e.builder.addEndpoint(l,{name:u,schema:b.value,source:a.source!=null?x8r(a.source):void 0}),(c?.id!=null||c?.description!=null)&&e.builder.setServiceInfo(l,{"display-name":o?.summary??c?.id,docs:o?.description??c?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function Ycp(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?I8r(r.groupName):void 0,n=h0({schema:ey.primitive(r),context:e,fileContainingReference:Wh.of(P1),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:QE(n),docs:r.description??void 0}})}}function Xcp(e){for(let t of e.ir.webhooks){let r=O1S({webhook:t,context:e});if(r==null)continue;let i=lyo(t.sdkName,t.namespace),n={};for(let u of t.headers)n[u.name]=sQt({header:u,context:e,fileContainingReference:r.file,namespace:i});let a={method:t.method,"display-name":t.summary??void 0,headers:n,payload:h0({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:NH(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function b1S({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:Dz(Wh.of(t),e.file)}:e}function g1S({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:Wh.of(P1),endpointId:i};let n=bZn(r),a=bZn(i);if(N3t(n,a))return{file:Wh.of("__package__.yml"),endpointId:r};let u=[];for(let l=0;l<n.length;++l){let f=n[l];if(f!=null&&f===a[l])u.push(f);else{let s=pg(r);return{file:Wh.of(`${s}.yml`),endpointId:i,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:Wh.of(pg(u.join("_"))+".yml"),endpointId:pg(a.slice(u.length).join("_")),tag:r}}function O1S({webhook:e,context:t}){return e.sdkName!=null?{file:gcp({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:b1S({namespaceOverride:e.namespace,location:g1S({webhook:e,context:t})})}var m1S=Wh.of(P1);function Zcp(e){switch(e.type){case"object":return cQt(e.groupName);case"enum":return cQt(e.groupName);case"oneOf":return cQt(e.value.groupName);case"array":return cQt(e.groupName);case"map":return cQt(e.groupName);case"reference":return cQt(e.groupName);case"literal":return cQt(e.groupName);case"optional":return cQt(e.groupName);case"nullable":return cQt(e.groupName);case"primitive":return cQt(e.groupName);case"unknown":return m1S;default:Zo(e)}}function cQt(e){return pdn(e)}var eDs="external",Jcp=Wh.of(P1);function kcp({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let u=Zcp(a),l=wcp({schema:a,context:i,declarationFile:u,namespace:r,declarationDepth:0});if(pXr(l.schema)){let f=QE(l.schema);if(f===(l.name??n)||f===`optional<${l.name??n}>`)continue}i.builder.addType(u,{name:l.name??n,schema:l.schema})}}function elp(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),Rcp(e),Fcp(e),Ncp(e),Mcp(e),Ycp(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(eDs);let t=Kcp(e),r=t.sdkGroups;e.setInState(c2.Webhook),Xcp(e),e.unsetInState(c2.Webhook),e.setInState(c2.Channel);for(let n of e.ir.channel){let a=pdn(n.groupName);Bcp({channel:n,context:e,declarationFile:a})}e.unsetInState(c2.Channel);let i=P1S({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});kcp({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))kcp({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function P1S({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}function tDs(e){let t=new tyo(e);return elp(t)}var aSi={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!1,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1};function rDs({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??aSi.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??aSi.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??aSi.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??aSi.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??aSi.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??aSi.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??aSi.inlinePathParameters}}var dyo=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=tDs({taskContext:t,ir:r,options:rDs({overrides:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.args.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.args.objectQueryParameters}}),authOverrides:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration?.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:pp.dump(a.rootApiFile)},namedDefinitionFiles:{...cd(a.definitionFiles,u=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:pp.dump(u),contents:u})),[Wh.of(P1)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:pp.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var OZn=class extends F2t{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;exampleGeneration;converter;constructor(t){super(t),this.inlinePathParameters=t.inlinePathParameters,this.objectQueryParameters=t.objectQueryParameters,this.onlyIncludeReferencedSchemas=t.onlyIncludeReferencedSchemas,this.respectReadonlySchemas=t.respectReadonlySchemas,this.respectNullableSchemas=t.respectNullableSchemas,this.exampleGeneration=t.exampleGeneration,this.converter=new dyo(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new xwe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion})}};function ydn(e){if(e.settings==null)return;let t={detectGlobalHeaders:!0};return e.settings.unions==="v1"&&(t.discriminatedUnionV2=!0),t}var K0p=Di(p0o(),1);var EK={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0};function Gqs({options:e,overrides:t}){return{disableExamples:t?.disableExamples??EK.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??EK.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??EK.useTitlesAsName,audiences:t?.audiences??e?.audiences??EK.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??EK.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??EK.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??EK.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??EK.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??EK.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??EK.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??EK.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??EK.shouldUseUndiscriminatedUnionsWithLiterals,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??EK.objectQueryParameters,filter:t?.filter??e?.filter??EK.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??EK.asyncApiNaming,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0}}var Dbp={naming:"v1"};function Vf(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function Okn(e,t,r,i,n=[]){try{let a=Vf(e,t);if(a!=null)return r.parse(a)}catch{let u=BUt(n).join(" -> ");i.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}var _0o={of(e){return e}};var Ebp={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},Qqs={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:Ebp,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},md={SDK_METHOD_NAME:_0o.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:_0o.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:_0o.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 rp(e){return e.$ref!=null}function XBe(e){switch(Vf(e,md.AVAILABILITY)){case"deprecated":return GL.Deprecated;case"beta":return GL.Beta;case"generally-available":return GL.GenerallyAvailable;default:break}if(!rp(e)&&e.deprecated)return GL.Deprecated}var Uwe={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 ISi(e){let t=Vf(e,"examples");return t!=null&&Array.isArray(t)?t:[]}function Abp({schema:e,logger:t}){return Vf(e,md.ENCODING)??void 0}function Mbp(e){return Vf(e,md.FERN_ENUM)}function qbp({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let u=Vf(i,md.SDK_GROUP_NAME),l=Vf(i,md.TYPE_DEFINITION);if(l!=null)return mkn({fernType:l,nameOverride:e,generatedName:t,title:r,description:n,availability:a,groupName:typeof u=="string"?[u]:u})}function mkn({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u}){return vL({type:e,_default:void 0,validation:void 0,visitor:{primitive:l=>{switch(l.v1){case"BASE_64":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.base64({example:void 0})});case"BOOLEAN":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.boolean({default:void 0,example:void 0})});case"DATE":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.date({example:void 0})});case"DATE_TIME":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.datetime({example:void 0})});case"FLOAT":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.float({example:void 0})});case"DOUBLE":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.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 Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.uint({default:void 0,example:void 0})});case"INTEGER":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.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 Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.uint64({default:void 0,example:void 0})});case"LONG":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Zo(l.v1)}},unknown:()=>Fl.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,groupName:u}),map:({keyType:l,valueType:f})=>l?.type==="primitive"&&f!=null?Fl.map({nameOverride:t,generatedName:r,title:i,key:l,value:f,description:n,availability:a,groupName:u,encoding:void 0,example:void 0,inline:void 0}):void 0,list:l=>l!=null?Fl.array({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,example:void 0,inline:void 0}):void 0,optional:l=>l!=null?Fl.optional({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,inline:void 0}):void 0,nullable:l=>l!=null?Fl.nullable({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,inline:void 0}):void 0,set:l=>l!=null?Fl.array({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,example:void 0,inline:void 0}):void 0,literal:l=>Fl.literal({nameOverride:t,generatedName:r,title:i,value:l._visit({string:f=>bB.string(f),boolean:f=>bB.boolean(f),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,groupName:u}),named:()=>{}}})}function zSi(e){if(e!=null&&typeof e=="boolean")return e}function Tbp({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:u,wrapAsNullable:l,context:f,groupName:s,example:o,encoding:c,source:b,namespace:g}){return typeof n=="boolean"||upn(n)?h0o({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Fl.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:void 0}),groupName:s,example:o,encoding:c}):h0o({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Cbp(rg(n,f.options.optionalAdditionalProperties?l:!1,f,[...i,"Value"],b,g,void 0,void 0,void 0)),groupName:s,example:o,encoding:c})}function Cbp(e){switch(e.type){case"array":case"enum":case"map":case"object":e.inline=!0;break;case"literal":case"primitive":case"reference":case"unknown":break;case"nullable":case"optional":e.inline=!0,e.value=Cbp(e.value);break;case"oneOf":e.value.inline=!0;break;default:Zo(e)}return e}function h0o({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsNullable:a,description:u,availability:l,groupName:f,example:s,encoding:o}){return a?Fl.nullable({nameOverride:e,generatedName:t,title:r,value:Fl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:i.availability,key:i,value:n,groupName:f,encoding:o,example:s,inline:void 0}),description:u,availability:l,groupName:f,inline:void 0}):Fl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:l,key:i,value:n,groupName:f,encoding:o,example:s,inline:void 0})}function upn(e){return e==null?!1:typeof e=="boolean"?e:!rp(e)&&Object.keys(e).length===0}function Bbp({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:u,wrapAsNullable:l,context:f,groupName:s,example:o,source:c,namespace:b}){let g=n==null?Fl.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,groupName:s}):rg(n,!1,f,[...i,"Item"],c,b);return O5S({nameOverride:e,generatedName:t,title:r,groupName:s,itemSchema:g,wrapAsNullable:l,description:a,availability:u,example:o})}function O5S({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsNullable:n,description:a,availability:u,groupName:l,example:f}){return n?Fl.nullable({nameOverride:e,generatedName:t,title:r,value:Fl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,groupName:l,example:f,inline:void 0}),description:a,availability:u,groupName:l,inline:void 0}):Fl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,groupName:l,example:f,inline:void 0})}function Jqs({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:l,wrapAsNullable:f,discriminator:s,context:o,groupName:c,encoding:b,source:g,namespace:O}){let m=s.propertyName,w=Object.fromEntries(Object.entries(s.mapping??{}).map(([M,q])=>{let D=spn({$ref:q},!1,o,[q],b,g,O);return o.markReferencedByDiscriminatedUnion({$ref:q},m,1),[M,D]})),A=Object.entries(n).filter(([M])=>M!==m).map(([M,q])=>{let D=l!=null&&l.includes(M),C=rg(q,!D,o,[...i,M],g,O);return{key:M,schema:C}});return xbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,properties:A,description:a,availability:u,discriminant:m,subtypes:w,groupName:c,source:g})}function Kqs({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:l,wrapAsNullable:f,discriminant:s,variants:o,context:c,groupName:b,encoding:g,source:O,namespace:m}){let w=Object.fromEntries(Object.entries(o).map(([M,q])=>{if(rp(q)){let D=spn(q,!1,c,[q.$ref],g,O,m);return c.markReferencedByDiscriminatedUnion(q,s,1),[M,D]}else{let D=cpn(q,!1,c,[...i,M],g,O,m,new Set([s]));return[M,D]}})),A=Object.entries(n).filter(([M])=>M!==s).map(([M,q])=>{let D=l!=null&&l.includes(M),C=rg(q,!D,c,[...i,M],O,m);return{key:M,schema:C}});return xbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,properties:A,description:a,availability:u,discriminant:s,subtypes:w,groupName:b,source:O})}function xbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,availability:u,discriminant:l,subtypes:f,groupName:s,source:o}){return i?Fl.nullable({nameOverride:e,generatedName:t,title:r,value:Fl.oneOf(dK.discriminated({description:a,availability:u,discriminantProperty:l,nameOverride:e,generatedName:t,title:r,schemas:f,commonProperties:n,groupName:s,encoding:void 0,source:o,inline:void 0})),groupName:s,description:a,availability:u,inline:void 0}):Fl.oneOf(dK.discriminated({description:a,availability:u,discriminantProperty:l,nameOverride:e,generatedName:t,title:r,schemas:f,commonProperties:n,groupName:s,encoding:void 0,source:o,inline:void 0}))}function Ibp(e){if(e.proto!=null)return Rfn.protobuf({typeName:e.proto.type})}function fti({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:u,description:l,availability:f,wrapAsNullable:s,groupName:o,context:c,source:b,inline:g}){let O=P5S(n??[]),m=new Set(a),w=Array.from(m).map((M,q)=>{let D=i?.[M],C=O[q],R=fdn.test(M),$=D?.name??C,I=R?M:ddn(M);return $!=null&&!fdn.test($)&&(c?.logger.warn(`Enum name override ${$} is not a valid name. Falling back on ${I}.`),$=void 0),{nameOverride:$,generatedName:I,value:M,description:D?.description,availability:f,casing:{snake:D?.casing?.snake??void 0,pascal:D?.casing?.pascal??void 0,screamingSnake:D?.casing?.screamingSnake??void 0,camel:D?.casing?.camel??void 0}}}),A=u!=null?w.find(M=>M.value===u):void 0;return m5S({wrapAsNullable:s,nameOverride:e,generatedName:t,title:r,values:w,_default:A,description:l,availability:f,groupName:o,source:b,inline:g})}function m5S({wrapAsNullable:e,nameOverride:t,generatedName:r,title:i,values:n,_default:a,description:u,availability:l,groupName:f,source:s,inline:o}){return e?Fl.nullable({nameOverride:t,generatedName:r,title:i,value:Fl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,default:a,availability:l,example:void 0,groupName:f,source:s,inline:o}),description:u,availability:l,groupName:f,inline:o}):Fl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,availability:l,default:a,example:void 0,groupName:f,source:s,inline:o})}function P5S(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function zbp({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:f,multipleOf:s,description:o,availability:c,wrapAsNullable:b,example:g,groupName:O}){return i==="int64"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint32"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint64"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.int({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:f,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O})}function Rbp(e){return typeof e=="string"?bB.string(e):typeof e=="boolean"?bB.boolean(e):bB.string(`${e}`)}function Fbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,value:n,description:a,availability:u,groupName:l}){return i?Fl.nullable({nameOverride:e,generatedName:t,title:r,value:Fl.literal({nameOverride:e,generatedName:t,title:r,value:Rbp(n),description:a,availability:u,groupName:l}),description:a,availability:u,groupName:l,inline:void 0}):Fl.literal({nameOverride:e,generatedName:t,title:r,value:Rbp(n),description:a,availability:u,groupName:l})}function Yqs({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:f,multipleOf:s,description:o,availability:c,wrapAsNullable:b,example:g,groupName:O}){return i==null||i==="double"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.double({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:f,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="float"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.float({example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="int32"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.int({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:f,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="int64"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint32"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint64"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="time-delta"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.float({example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.float({example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O})}var j5S={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},w5S={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}}},S5S={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}}},D5S={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},E5S={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},A5S={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},M5S={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},q5S={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function y0o(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[j5S,w5S,S5S,D5S,E5S,A5S,M5S,q5S],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:l}=a.applyStrategy(t);t=u,r=[...r,...l]}}while(t.join("")!==n.join(""));return r}function d2(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:G9(pg(n))).join("");return/^\d/.test(i)?hZn(i)??i:i}function Xqs(e){let t=e.join("_");return pg(t)}function Dq(e){switch(e.type){case"object":return ey.object({allOf:e.allOf,properties:e.properties.map(t=>C5S(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,inline:e.inline});case"array":return ey.array({description:e.description,availability:e.availability,value:Dq(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,inline:e.inline});case"enum":return ey.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,inline:e.inline});case"literal":return ey.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 ey.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Dq(e.value),groupName:e.groupName,inline:e.inline});case"optional":return ey.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Dq(e.value),groupName:e.groupName,inline:e.inline});case"primitive":return ey.primitive({description:e.description,availability:e.availability,schema:Nbp(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return ey.map({description:e.description,availability:e.availability,key:ey.primitive({description:e.key.description,availability:e.key.availability,schema:Nbp(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:Dq(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return ey.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 ey.oneOf(T5S(e.value));case"unknown":return ey.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Zo(e)}}function T5S(e){switch(e.type){case"discriminated":return B8r.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:Dq(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,Dq(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return B8r.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>Dq(t)),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:Zo(e)}}function Nbp(e){switch(e.type){case"string":return WP.string(e);case"base64":return WP.base64();case"boolean":return WP.boolean(e);case"date":return WP.date();case"datetime":return WP.datetime();case"double":return WP.double(e);case"float":return WP.float();case"int":return WP.int(e);case"int64":return WP.int64(e);case"uint":return WP.uint();case"uint64":return WP.uint64();default:Zo(e)}}function C5S(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:Dq(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly}}function v0o(e,t){return xte(Dq(e),Dq(t))}function Lbp({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:u,wrapAsNullable:l,allOf:f,context:s,propertiesToExclude:o,groupName:c,fullExamples:b,additionalProperties:g,availability:O,encoding:m,source:w,namespace:A}){let M=[...u??[]],q={...n},D=[],C=[];for(let U of f)if(rp(U)){let H=s.resolveSchemaReference(U);if(H.discriminator!=null&&H.discriminator.mapping!=null)continue;if(H.oneOf!=null){for(let J of H.oneOf){let ee=rp(J)?s.resolveSchemaReference(J):J,fe=rg(ee,!1,s.DUMMY,i,w,A);fe.type==="object"&&D.push(...fe.properties.map(me=>me.schema.type!=="optional"&&me.schema.type!=="nullable"?{...me,schema:Fl.optional({nameOverride:void 0,generatedName:"",title:void 0,value:me.schema,description:void 0,availability:me.availability,groupName:void 0,inline:void 0})}:me))}continue}let te=dti(U);if(te==null)continue;C.push({schemaId:te,convertedSchema:Zqs(U,[te],w,s.options.preserveSchemaIds),properties:Ubp({schema:U,context:s,breadcrumbs:i,source:w,namespace:A})}),s.markSchemaAsReferencedByNonRequest(te)}else{let H=rg(U,!1,s,i,w,A);H.type==="object"&&D.push(...H.properties)}let R={};for(let U of C)for(let[H,te]of Object.entries(U.properties)){let J=R[H];J!=null?(J.schemaIds.push(U.schemaId),J.schemas.some(fe=>v0o(fe,te))||J.schemas.push(te)):R[H]={schemaIds:[U.schemaId],schemas:[te]}}let $=[];for(let[U,H]of Object.entries(R))H.schemaIds.length>1&&$.push({propertyKey:U,allOfSchemaIds:H.schemaIds,conflictingTypeSignatures:H.schemas.length>1});let I=Object.entries(q).map(([U,H])=>{let te=M.includes(U),J=Vf(H,md.AUDIENCES)??[],ee=XBe(H),fe=rp(H)?!1:H.readOnly,me=Vf(H,md.FERN_PROPERTY_NAME),ve=[...i,U],we=Xqs(ve),Xe=te?rg(H,!1,s,ve,w,A):Fl.optional({nameOverride:e,generatedName:we,title:r,description:void 0,availability:ee,value:rg(H,!1,s,ve,w,A),groupName:c,inline:void 0}),Mt={};for(let De of C){let Te=De.properties[U];Te!=null&&!v0o(Xe,Te)?Mt[De.schemaId]={differentSchema:!0}:Te!=null&&(Mt[De.schemaId]={differentSchema:!1})}return{key:U,schema:Xe,nameOverride:me,audiences:J,conflict:Mt,generatedName:Xqs([...i,U]),availability:ee,readonly:fe}});return I.push(...D.map(U=>{let H=U.conflict;for(let te of C){let J=te.properties[U.key];J!=null&&!v0o(U.schema,J)?H[te.schemaId]={differentSchema:!0}:J!=null&&(H[te.schemaId]={differentSchema:!1})}return{...U,conflict:H}})),B5S({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,properties:I.filter(U=>!o.has(U.key)),description:a,allOf:C.map(U=>U.convertedSchema),allOfPropertyConflicts:$,groupName:c,fullExamples:b,additionalProperties:g,availability:O,source:w})}function B5S({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,allOf:u,allOfPropertyConflicts:l,groupName:f,fullExamples:s,additionalProperties:o,availability:c,source:b}){return i?Fl.nullable({nameOverride:e,generatedName:t,title:r,value:Fl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:l,groupName:f,fullExamples:s,additionalProperties:upn(o),availability:void 0,source:b,inline:void 0}),description:a,availability:c,groupName:f,inline:void 0}):Fl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:l,groupName:f,fullExamples:s,additionalProperties:upn(o),availability:c,source:b,inline:void 0})}function Ubp({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[u,l]=rp(e)?[t.resolveSchemaReference(e),y0o(e.$ref)]:[e,r];for(let f of u.allOf??[])a={...a,...Ubp({schema:f,context:t,breadcrumbs:l,source:i,namespace:n})};for(let[f,s]of Object.entries(u.properties??{})){let o=rg(s,!1,t,[...l,f],i,n);a[f]=o}return a}function lpn({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsNullable:u,context:l,subtypes:f,groupName:s,encoding:o,source:c,subtypePrefixOverrides:b,namespace:g}){let O=x5S({schemas:f}),m=f.flatMap((M,q)=>{if(!rp(M)&&M.enum!=null&&l.options.coerceEnumsToLiterals&&M.type==="string")return M.enum.map(C=>Fl.literal({nameOverride:void 0,generatedName:d2([t,C],l.options.preserveSchemaIds),title:void 0,value:bB.string(String(C)),groupName:void 0,description:void 0,availability:C.availability}));let D=O[q];if(b!=null){let C=b[q];C!=null&&"name"in C&&(D=C.name)}return[rg(M,!1,l,[...i,D??`${q}`],c,g)]}),w=[];for(let M=0;M<m.length;++M){let q=m[M],D=!1;for(let C=M+1;C<m.length;++C){let R=m[C];if(q!=null&&R!=null&&xte(q,R)){D=!0;break}}q!=null&&!D&&w.push(q)}if(Object.entries(w).every(([M,q])=>q.type==="literal")){let M={},q=[];return Object.entries(w).forEach(([D,C])=>{C.type==="literal"&&C.value.type==="string"&&(q.push(C.value.value),C.description!=null&&(M[C.value.value]={description:C.description}))}),fti({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,fernEnum:M,enumVarNames:void 0,enumValues:q,_default:void 0,groupName:s,context:l,source:c,inline:void 0})}return w.length===1&&w[0]!=null?w[0]:Vbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,subtypes:w,groupName:s,encoding:o,source:c})}function kqs({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsNullable:a,context:u,groupName:l,discriminator:f,encoding:s,source:o,namespace:c}){let b=Object.entries(f.mapping??{}).map(([m,w],A)=>{let M={$ref:w},q=spn(M,!1,u,[w],s,o,c);return u.markSchemaWithDiscriminantValue(M,f.propertyName,m),q.type==="object"&&(q.properties={[f.propertyName]:Fl.literal({nameOverride:void 0,generatedName:d2([t,m],u.options.preserveSchemaIds),title:void 0,value:bB.string(m),groupName:void 0,description:void 0,availability:void 0}),...q.properties.filter(D=>D.key!==f.propertyName)}),q}),g=[];for(let m=0;m<b.length;++m){let w=b[m],A=!1;for(let M=m+1;M<b.length;++M){let q=b[M];if(w!=null&&q!=null&&xte(w,q)){A=!0;break}}w!=null&&!A&&g.push(w)}if(Object.entries(g).every(([m,w])=>w.type==="literal")){let m={},w=[];return Object.entries(g).forEach(([A,M])=>{M.type==="literal"&&M.value.type==="string"&&(w.push(M.value.value),M.description!=null&&(m[M.value.value]={description:M.description}))}),fti({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,fernEnum:m,enumVarNames:void 0,enumValues:w,_default:void 0,groupName:l,context:u,source:o,inline:void 0})}return g.length===1&&g[0]!=null?g[0]:Vbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,subtypes:g,groupName:l,encoding:s,source:o})}function x5S({schemas:e}){let t={},r=0;for(let a of e){if(!rp(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),l={},f=u;for(let[s,o]of Object.entries(t)){let c=r7a(o,u);f=r7a(f,o),l[s]=c}l[r]=f,t=l}}r++}let i=[],n=0;for(let a of e){let u=t[n];if(u!=null&&u.length>0){let l=u.sort();if(l[0]!=null){i.push(l[0]),++n;continue}}rp(a)?i.push(Nei(n)??`${n}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?i.push(""):i.push(Nei(n)??`${n}`),++n}return i}function Vbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,description:n,availability:a,subtypes:u,groupName:l,encoding:f,source:s}){return i?Fl.nullable({nameOverride:e,generatedName:t,title:r,value:Fl.oneOf(dK.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:l,encoding:f,source:s,inline:void 0})),description:n,availability:a,groupName:l,inline:void 0}):Fl.oneOf(dK.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:l,encoding:f,source:s,inline:void 0}))}function fpn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function b0o({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=ISi(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function Wbp({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=ISi(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function G8r({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=ISi(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function Hbp({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=ISi(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var RSi="#/components/schemas/";function rg(e,t,r,i,n,a,u=!1,l=new Set,f){let s=V5S({schema:e,logger:r.logger});if(rp(e)){let o=dti(e);return o!=null?(u?r.markSchemaAsReferencedByRequest(o):r.markSchemaAsReferencedByNonRequest(o),spn(e,t,r,i,s,n,a)):cpn(r.resolveSchemaReference(e),t,r,y0o(e.$ref),s,n,a,l,u,f)}return cpn(e,t,r,i,s,n,a,l,u,f)}function spn(e,t,r,i,n,a,u){let l=e.$ref.includes("properties")?cpn(r.resolveSchemaReference(e),t,r,i,n,a,u,new Set):Fl.reference(Zqs(e,i,a,r.options.preserveSchemaIds));return t?Fl.nullable({title:void 0,nameOverride:void 0,generatedName:d2(i,r.options.preserveSchemaIds),value:l,description:void 0,availability:void 0,groupName:void 0,inline:void 0}):l}function I5S(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function cpn(e,t,r,i,n,a,u,l=new Set,f=!1,s){typeof e=="string"&&(e={type:e});let o=Vf(e,md.TYPE_NAME)??(r.options.useTitlesAsName?I5S(e.title):void 0),c=Vf(e,md.SDK_GROUP_NAME)??Vf(e,Uwe.TAGS)?.[0],b=(typeof c=="string"?[c]:c)??[];b=r.resolveGroupName(b);let g=d2(i,r.options.preserveSchemaIds),O=e.title,m=e.description,w=XBe(e),A=[];e.example!=null&&A.push({name:void 0,value:e.example,description:void 0});let M=Vf(e,Uwe.EXAMPLES);M!=null&&Object.keys(M).length>0&&A.push(...Object.entries(M).map(([C,R])=>({name:R?.summary??C,value:R.value,description:R.description})));let q=ISi(e);q!=null&&Object.keys(q).length>0&&A.push(...q.map(C=>({name:void 0,value:C,description:void 0})));let D=qbp({schema:e,description:m,title:O,nameOverride:o,generatedName:g,availability:w});if(D!=null)return D;if(Array.isArray(e.type)){let C=e.type.indexOf("null"),R=C!==-1;e.type.length===1?e.type=e.type[0]:e.type.length===2&&R?(e.type.splice(C,1),e.type=e.type[0],e.nullable=!0):(R&&(e.type.splice(C,1),e.nullable=!0),e.oneOf==null?e.oneOf=e.type:e.oneOf.push(...e.type))}if(!t&&e.nullable===!0)return cpn(e,!0,r,i,n,a,u,l,f,s);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!m0o(e.enum))return i8({nameOverride:o,generatedName:g,title:O,primitive:Xd.string({default:fpn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:G8r({schema:e,logger:r.logger,fallback:s})}),groupName:b,wrapAsNullable:t,description:m,availability:w});let C=Mbp(e);return e.enum.length===1&&e.enum[0]!=null&&C==null?Fbp({nameOverride:o,generatedName:g,title:O,wrapAsNullable:t,value:e.enum[0],description:m,availability:w,groupName:b}):fti({nameOverride:o,generatedName:g,title:O,fernEnum:C,enumVarNames:Vf(e,[Uwe.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:m,availability:w,wrapAsNullable:t,groupName:b,context:r,source:a,inline:void 0})}if(m0o(e.type)&&e.type.length>1){let C=e.type.includes("null"),R=e.type.filter($=>$!=="null").map($=>({type:$,nullable:C}));return lpn({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,wrapAsNullable:t,context:r,subtypes:R,groupName:b,encoding:n,source:a,namespace:u})}if(e.type==="boolean"){let C=Vf(e,md.BOOLEAN_LITERAL);return C!=null?$bp({nameOverride:o,generatedName:g,title:O,literal:bB.boolean(C),wrapAsNullable:t,description:m,availability:w,groupName:b}):i8({nameOverride:o,generatedName:g,title:O,primitive:Xd.boolean({default:z5S(e.default),example:Wbp({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:w,groupName:b})}if(e.type==="number")return Yqs({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:zSi(e.exclusiveMinimum),exclusiveMaximum:zSi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:w,wrapAsNullable:t,example:b0o({schema:e,logger:r.logger,fallback:s}),groupName:b});if(e.type==="integer")return zbp({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:zSi(e.exclusiveMinimum),exclusiveMaximum:zSi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:w,wrapAsNullable:t,example:b0o({schema:e,logger:r.logger,fallback:s}),groupName:b});if(e.type==="float")return Yqs({nameOverride:o,generatedName:g,title:O,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:zSi(e.exclusiveMinimum),exclusiveMaximum:zSi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:w,wrapAsNullable:t,example:b0o({schema:e,logger:r.logger,fallback:s}),groupName:b});if(e.type==="string"){if(e.format==="date-time")return i8({nameOverride:o,generatedName:g,title:O,primitive:Xd.datetime({example:G8r({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:w,groupName:b});if(e.format==="json-string")return Fl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:w,groupName:b,example:void 0});let C=Jbp(e,"const");return C!=null?$bp({nameOverride:o,generatedName:g,title:O,literal:bB.string(C),wrapAsNullable:t,description:m,availability:w,groupName:b}):i8({nameOverride:o,generatedName:g,title:O,primitive:Xd.string({default:fpn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:G8r({schema:e,logger:r.logger,fallback:s})}),groupName:b,wrapAsNullable:t,description:m,availability:w})}if(e.type==="array")return Bbp({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,item:e.items,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,example:Hbp({schema:e,logger:r.logger,fallback:s}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&g0o(e))return Tbp({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,additionalProperties:e.additionalProperties,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,encoding:n,example:e.example,source:a,namespace:u});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?kqs({nameOverride:o,generatedName:g,title:O,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,discriminator:e.discriminator,encoding:n,source:a,namespace:u}):Jqs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:b,encoding:n,source:a,namespace:u});if(e.oneOf!=null&&e.oneOf.length>0){let C=Vf(e,md.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||C?kqs({nameOverride:o,generatedName:g,title:O,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,discriminator:e.discriminator,encoding:n,source:a,namespace:u}):Jqs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:b,encoding:n,source:a,namespace:u});if(e.oneOf.length===1&&e.oneOf[0]!=null){let R=rg(e.oneOf[0],t,r,i,a,u,f);return dpn(R,m,b)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let U=e.oneOf[0],H=e.oneOf[1];if(!rp(U)&&U.type==="null")return rg(H,!0,r,i,a,u);if(!rp(H)&&H.type==="null")return rg(U,!0,r,i,a,u)}let R=N5S({schemas:e.oneOf});if(R!=null)return fti({nameOverride:o,generatedName:g,title:O,fernEnum:void 0,enumVarNames:void 0,enumValues:R,_default:e.default,description:m,availability:w,wrapAsNullable:t,groupName:b,context:r,source:a,inline:void 0});let $=Gbp({schemas:e.oneOf,context:r});if($!=null&&!r.options.discriminatedUnionV2&&!C)return Kqs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:w,wrapAsNullable:t,discriminant:$.discriminant,variants:$.schemas,context:r,groupName:b,encoding:n,source:a,namespace:u});let I=e.oneOf.filter(U=>!rp(U)&&U.type==="null").length>0;return lpn({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,wrapAsNullable:t||I,context:r,subtypes:e.oneOf.filter(U=>rp(U)||U.type!=="null"),encoding:n,groupName:b,source:a,namespace:u})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let $=rg(e.anyOf[0],t,r,i,a,u,f);return dpn($,m,b)}if(e.anyOf.length===2){let[$,I]=e.anyOf;if($!=null&&I!=null){if(!rp($)&&$.type==="null"){let U=rg(I,!0,r,i,a,u);return dpn(U,m,b)}else if(!rp(I)&&I.type==="null"){let U=rg($,!0,r,i,a,u);return dpn(U,m,b)}}}let C=Gbp({schemas:e.anyOf,context:r});if(C!=null&&!r.options.discriminatedUnionV2)return Kqs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:w,wrapAsNullable:t,discriminant:C.discriminant,variants:C.schemas,context:r,groupName:b,encoding:n,source:a,namespace:u});let R=e.anyOf.filter($=>!rp($)&&$.type==="null").length>0;return lpn({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,wrapAsNullable:t||R,context:r,subtypes:e.anyOf.filter($=>rp($)||$.type!=="null"),encoding:n,groupName:b,source:a,namespace:u})}if(e.allOf!=null||e.properties!=null){let C=[];for(let $ of e.allOf??[])(rp($)||Object.keys($).length>0)&&C.push($);if((e.properties==null||g0o(e))&&C.length===1&&C[0]!=null){let $=rg(C[0],t,r,i,a,u,f);return dpn($,m,b)}let R=C.filter($=>{let I=O0o($);return I||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify($)}`),I});if((e.properties==null||g0o(e))&&R.length===1&&R[0]!=null){let $=rg(R[0],t,r,i,a,u,f);return dpn($,m,b)}return Lbp({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},description:m,required:e.required,wrapAsNullable:t,allOf:R,context:r,propertiesToExclude:l,groupName:b,fullExamples:A,additionalProperties:e.additionalProperties,availability:w,encoding:n,source:a,namespace:u})}if(e.type==="object"&&R5S(e)&&F5S(e)&&g0o(e))return h0o({nameOverride:o,generatedName:g,title:O,description:m,availability:w,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${g}Key`,title:void 0,description:void 0,availability:void 0,schema:Xd.string({default:fpn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:G8r({schema:e,logger:r.logger,fallback:s})}),groupName:b},valueSchema:Fl.unknown({nameOverride:void 0,generatedName:`${g}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:b}),groupName:b,encoding:n,example:e.example});if(e.type==null){let C=e.example??e.default;return Fl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:w,groupName:b,example:C})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(i)} value=${JSON.stringify(e)}`)}function z5S(e){if(e!=null){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase();if(t==="true")return!0;if(t==="false")return!1}}}function dti(e){if(e.$ref.startsWith(RSi))return e.$ref.replace(RSi,"")}function Zqs(e,t,r,i){let n=Vf(e,md.TYPE_NAME),a=d2(t,i),u=e.description,l=XBe(e),f=dti(e);if(f==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return ey.reference({generatedName:a,nameOverride:n,title:void 0,schema:f,description:u??void 0,availability:l,groupName:void 0,source:r})}function R5S(e){return e.oneOf==null||e.oneOf.length===0}function F5S(e){return e.allOf==null||e.allOf.length===0}function g0o(e){return e.properties==null||jJ(e.properties)===0}function m0o(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function dpn(e,t,r){return e.type==="reference"?Fl.reference({...e,description:t,availability:e.availability,groupName:r}):e.type==="optional"?Fl.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r,inline:void 0}):e.type==="nullable"?Fl.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r,inline:void 0}):e}function O0o(e){return rp(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>O0o(t)):e.oneOf!=null?e.oneOf.every(t=>O0o(t)):e.anyOf!=null?e.anyOf.every(t=>O0o(t)):!1}function $bp({literal:e,wrapAsNullable:t,groupName:r,description:i,availability:n,nameOverride:a,generatedName:u,title:l}){return t?Fl.nullable({nameOverride:a,generatedName:u,title:l,value:Fl.literal({nameOverride:a,generatedName:u,title:l,value:e,description:i,availability:n,groupName:r}),groupName:r,description:i,availability:n,inline:void 0}):Fl.literal({nameOverride:a,generatedName:u,title:l,value:e,groupName:r,description:i,availability:n})}function i8({primitive:e,wrapAsNullable:t,groupName:r,description:i,availability:n,generatedName:a,nameOverride:u,title:l}){return r=typeof r=="string"?[r]:r,t?Fl.nullable({nameOverride:u,generatedName:a,title:l,value:Fl.primitive({nameOverride:u,generatedName:a,title:l,schema:e,description:i,availability:n,groupName:r}),groupName:r,description:i,availability:n,inline:void 0}):Fl.primitive({nameOverride:u,generatedName:a,title:l,schema:e,description:i,availability:n,groupName:r})}function N5S({schemas:e}){let t=new Set;for(let r of e){if(rp(r))return;if(r.enum!=null&&m0o(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function Gbp({schemas:e,context:t}){let r={};for(let i of e){let n=Qbp({schema:i,context:t});for(let[a,u]of Object.entries(n)){let l=r[a];l!=null?l[u]=i:r[a]={[u]:i}}}for(let[i,n]of Object.entries(r))if(Object.keys(n).length===e.length)return{discriminant:i,schemas:n}}function Qbp({schema:e,context:t}){let r=rp(e)?t.resolveSchemaReference(e):e;return L5S({schema:r,context:t})}function L5S({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=Qbp({schema:i,context:t});for(let[a,u]of Object.entries(n??{}))r[a]=u}return r}for(let[i,n]of Object.entries(e.properties??{})){let a=rp(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&m0o(a.enum)&&U5S(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let u=Jbp(a,"const");a.type==="string"&&u!=null&&(r[i]=u),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function U5S(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 Jbp(e,t){let r=e[t];if(r!=null)return r}function V5S({schema:e,logger:t}){let r=Abp({schema:e,logger:t});if(r!=null)return Ibp(r)}function P0o(e,t){let r={},i={};return e==null?r=t:i={[e]:t},{rootSchemas:r,namespacedSchemas:i}}var Kbp="#/components/messages/",eTs=class{logger;document;taskContext;DUMMY;options;namespace;constructor({document:t,taskContext:r,options:i,namespace:n}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=i,this.namespace=n}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let i=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};i.push(n)}return i.concat(t??[])}resolveSchemaReference(t){if(this.document.components==null||this.document.components.schemas==null||!t.$ref.startsWith(RSi))throw new Error(`Failed to resolve ${t.$ref}`);let i=t.$ref.substring(RSi.length).split("/");if(i[0]==null)throw new Error(`${t.$ref} is undefined`);let n=this.document.components.schemas[i[0]];if(n==null)throw new Error(`${i[0]} is undefined`);if(rp(n)&&(n=this.resolveSchemaReference(n)),i[1]==="properties"&&i[2]!=null){let a=n.properties?.[i[2]];if(a==null)throw new Error(`${t.$ref} is undefined. Property does not exist on object.`);rp(a)?n=this.resolveSchemaReference(a):n=a}return n}resolveMessageReference(t){if(this.document.components==null||this.document.components.messages==null||!t.$ref.startsWith(Kbp))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(Kbp.length),i=this.document.components.messages[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return i}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}},j0o=class extends eTs{constructor({document:t,taskContext:r,options:i,namespace:n}){super({document:t,taskContext:r,options:i,namespace:n})}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,i){}markSchemaWithDiscriminantValue(t,r,i){}};function pti(e){if(typeof e=="string")return A0.primitive(Jp.string(e));if(typeof e=="number")return Number.isInteger(e)?A0.primitive(Jp.int(e)):A0.primitive(Jp.double(e));if(typeof e=="boolean")return A0.primitive(Jp.boolean(e));if(Array.isArray(e)){let t=e.map(r=>pti(r));return t.length===0?void 0:A0.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,i]of Object.entries(e)){let n=pti(i);n!=null&&t.push({key:Jp.string(r),value:n})}return A0.map(t)}}function Pkn(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function Ybp(e){if(e!=null&&Array.isArray(e))return e}var _ti=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,i){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=i}buildExample({schema:t,exampleId:r,example:i,options:n,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:i,options:{...n,maxCheckerDepth:n.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:i,depth:n,visitedSchemaIds:a,options:u,skipReadonly:l}){switch(i.type){case"enum":return typeof r=="string"&&Xbp({schema:i,value:r})?A0.enum(r):i.values[0]!=null?A0.enum(i.values[0]?.value):void 0;case"literal":return A0.literal(i.value);case"nullable":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u)))return;let f=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:l});return f!=null&&f.type==="array"&&f.value.length===0||f!=null&&f.type==="map"&&f.value.length===0||f!=null&&f.type==="object"&&Object.keys(f.properties).length===0?void 0:f}case"optional":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u))||Object.is(r,null))return;let f=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:l});return f!=null&&f.type==="array"&&f.value.length===0||f!=null&&f.type==="map"&&f.value.length===0||f!=null&&f.type==="object"&&Object.keys(f.properties).length===0?void 0:f}case"primitive":{let f=this.buildExampleFromPrimitive({schema:i.schema,example:r,options:u});return A0.primitive(f)}case"reference":{let f=this.schemas[i.schema];if(f!=null&&!a.has(i.schema)){a.add(i.schema);let s=f?.type==="object"&&!this.nonRequestReferencedSchemas.has(i.schema),o=this.buildExampleHelper({example:r,schema:f,exampleId:t,visitedSchemaIds:a,depth:n,options:u,skipReadonly:s||this.context.options.respectReadonlySchemas?l:!1});return a.delete(i.schema),o}return}case"oneOf":switch(i.value.type){case"discriminated":{let f={},s={},o={},c=Pkn(r),b=c?.[i.value.discriminantProperty],g=i.value.schemas[b],O=[],m=this.getDiscriminatedUnionVariantSchema(i.value,c);m!=null&&O.push(m),O.push(...Object.entries(i.value.schemas));for(let w of O)if(b!=null&&g!=null&&g.type==="object"){s=this.getAllProperties(g),o=this.getAllRequiredProperties(g),f[i.value.discriminantProperty]=A0.primitive(Jp.string(b));break}else{let A=this.buildExampleHelper({exampleId:t,schema:w[1],example:void 0,visitedSchemaIds:a,depth:n,options:u,skipReadonly:l});if(f[i.value.discriminantProperty]=A0.primitive(Jp.string(w[0])),A!=null&&this.mergeExampleWith(A,f),A?.type==="object"&&A.properties!=null)for(let[M,q]of Object.entries(A.properties))M!==i.value.discriminantProperty&&(f[M]=q)}for(let w of i.value.commonProperties){s[w.key]={schema:w.schema,readonly:!1};let A=this.getResolvedSchema(w.schema);A.type!=="optional"&&A.type!=="nullable"&&(o[w.key]=w.schema)}for(let[w,A]of Object.entries(s)){let M=w in o;if(M&&c?.[w]!=null){let q=this.buildExampleHelper({schema:A.schema,exampleId:t,example:c[w],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});if(q!=null)f[w]=q;else return}else{let q=this.buildExampleHelper({exampleId:t,schema:A.schema,example:c?.[w],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});if(q!=null)f[w]=q;else if(M)return}}return A0.oneOf(Mei.discriminated(f))}case"undiscriminated":{let f=this.getUnDiscriminatedUnionVariantSchema(i.value,r);if(f!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:f,visitedSchemaIds:a,depth:n,options:u,skipReadonly:l});break}}return;case"unknown":if(r!=null){let f=pti(r);if(f!=null)return A0.unknown(f)}return u.ignoreOptionals||this.exceedsMaxDepth(n,u)?void 0:u.isParameter?A0.primitive(Jp.string(u.name??"string")):A0.map([{key:Jp.string("key"),value:A0.primitive(Jp.string("value"))}]);case"array":{let f=Ybp(r),s=[];if(f!=null&&f.length>0)for(let o of f){let c=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});c!=null&&s.push(c)}else if(i.example!=null&&i.example.length>0)for(let o of i.example){let c=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});c!=null&&s.push(c)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});o!=null&&s.push(o)}return A0.array(s)}case"map":{let f=Pkn(r??i.example);if(f!=null&&Object.entries(f).length>0){let c=[];for(let[b,g]of Object.entries(f)){let O=this.buildExampleFromPrimitive({schema:i.key.schema,example:b,options:u}),m=this.buildExampleHelper({exampleId:t,example:g,schema:i.value,visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});m!=null&&c.push({key:O,value:m})}return A0.map(c)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return A0.map([{key:Jp.string("key"),value:A0.unknown(A0.primitive(Jp.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:i.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,visitedSchemaIds:a,depth:n+1,options:{...u,name:"value"},skipReadonly:l});return o!=null?A0.map([{key:s,value:o}]):A0.map([])}case"object":{let f={},s=i.fullExamples?.find(g=>g.name===t)??i.fullExamples?.find(g=>g.name==null)??i.fullExamples?.[0],o=Pkn(r)??(s!=null?Pkn(s.value):{})??{},c=this.getAllProperties(i),b=this.getAllRequiredProperties(i);for(let[g,O]of Object.entries(c)){if(l&&O.readonly)continue;let m=g in b,w=Object.keys(o).includes(g),A=this.buildExampleHelper({schema:O.schema,exampleId:t,example:o[g],visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:l});if(m&&A!=null)f[g]=A;else{if(m)return;(w&&A!=null||!u.ignoreOptionals&&A!=null)&&(f[g]=A)}}if(i.additionalProperties){for(let[g,O]of Object.entries(o))if(!(g in f)){let m=this.buildExampleHelper({schema:Fl.unknown({example:O,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,groupName:void 0}),exampleId:t,example:O,visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:l});m!=null&&(f[g]=m)}}return A0.object({properties:f})}default:Zo(i)}}mergeExampleWith(t,r){t._visit({array:Yo,enum:Yo,literal:Yo,map:i=>{for(let n of i){let a=n.key;a.type==="string"&&(r[a.value]=n.value)}},object:i=>{for(let[n,a]of Object.entries(i.properties))r[n]=a},oneOf:i=>{if(i.type==="discriminated")for(let[n,a]of Object.entries(i.value))r[n]=a;else this.mergeExampleWith(i.value,r)},primitive:Yo,unknown:Yo,_other:Yo})}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let i=r?.[t.discriminantProperty];if(i==null||typeof i!="string")return Object.entries(t.schemas)[0];let n=t.schemas[i];return n==null?Object.entries(t.schemas)[0]:[i,n]}getUnDiscriminatedUnionVariantSchema(t,r){return r==null?t.schemas[0]:t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,u)=>u.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return Xbp({schema:t,value:r})?5:0;case"object":{if(!Dj(r))return 0;let i=this.getAllProperties(t),n=0;for(let[a,u]of Object.entries(i))r[a]!=null?(n++,n+=this.calcExampleHeuristic(u.schema,r[a])):n--;return n}case"array":{if(!Array.isArray(r))return 0;let i=0;for(let n of r)i+=this.calcExampleHeuristic(t.value,n);return i}case"map":{if(!Dj(r))return 0;let i=0;for(let[,n]of Object.entries(r))i+=this.calcExampleHeuristic(t.value,n);return i}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let i=this.getResolvedSchema(t);return i==null?0:this.calcExampleHeuristic(i,r)}case"oneOf":return Object.values(t.value.schemas).map(n=>this.calcExampleHeuristic(n,r)).sort((n,a)=>a-n)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,i=new Set,n){if(this.exceedsMaxCheckerDepth(r,n))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,i,n);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,i,n);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let u of t.properties)if(this.hasExample(u.schema,r+1,i,n))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!i.has(t.schema)){i.add(t.schema);let u=this.hasExample(a,r,i,n);return i.delete(t.schema),u}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,i,n));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let i of t.properties)r[i.key]={schema:i.schema,readonly:i.readonly??!1};for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let i of t.properties){let n=this.getResolvedSchema(i.schema);n.type!=="optional"&&n.type!=="nullable"&&(r[i.key]=i.schema)}for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:i}){switch(r.type){case"string":return t!=null&&typeof t=="string"?Jp.string(t):r.example!=null?Jp.string(r.example):Jp.string(i.name??X0.STRING);case"base64":return t!=null&&typeof t=="string"?Jp.base64(t):r.example!=null?Jp.base64(r.example):Jp.base64(X0.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?Jp.boolean(t):r.example!=null?Jp.boolean(r.example):Jp.boolean(X0.BOOLEAN);case"date":return t!=null&&typeof t=="string"?Jp.date(t):r.example!=null?Jp.date(r.example):Jp.date(X0.DATE);case"datetime":return t!=null&&typeof t=="string"?Jp.datetime(t):r.example!=null?Jp.datetime(r.example):Jp.datetime(X0.DATE_TIME);case"double":return t!=null&&typeof t=="number"?Jp.double(t):r.example!=null?Jp.double(r.example):Jp.double(X0.DOUBLE);case"float":return t!=null&&typeof t=="number"?Jp.float(t):r.example!=null?Jp.float(r.example):Jp.float(X0.FLOAT);case"int":return t!=null&&typeof t=="number"?Jp.int(t):r.example!=null?Jp.int(r.example):Jp.int(X0.INT);case"int64":return t!=null&&typeof t=="number"?Jp.int64(t):r.example!=null?Jp.int64(r.example):Jp.int64(X0.INT64);case"uint":return t!=null&&typeof t=="number"?Jp.uint(t):r.example!=null?Jp.uint(r.example):Jp.uint(X0.UINT);case"uint64":return t!=null&&typeof t=="number"?Jp.uint64(t):r.example!=null?Jp.uint64(r.example):Jp.uint64(X0.UINT64);default:Zo(r)}}};function Xbp({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function gQt(e){switch(e.type){case"object":return Fl.object({allOf:e.allOf,properties:e.properties.map(t=>H5S(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,inline:void 0});case"array":return Fl.array({description:e.description,availability:e.availability,value:gQt(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return Fl.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,inline:void 0});case"literal":return Fl.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 Fl.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:gQt(e.value),groupName:e.groupName,inline:void 0});case"optional":return Fl.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:gQt(e.value),groupName:e.groupName,inline:void 0});case"primitive":return Fl.primitive({description:e.description,availability:e.availability,schema:Zbp(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return Fl.map({description:e.description,availability:e.availability,key:Fl.primitive({description:e.key.description,availability:e.key.availability,schema:Zbp(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:gQt(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return Fl.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 Fl.oneOf(W5S(e.value));case"unknown":return Fl.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,groupName:void 0,description:void 0,availability:void 0});default:Zo(e)}}function W5S(e){switch(e.type){case"discriminated":return dK.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:gQt(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,gQt(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return dK.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>gQt(t)),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:Zo(e)}}function Zbp(e){switch(e.type){case"string":return Xd.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return Xd.base64({example:void 0});case"boolean":return Xd.boolean({default:e.default,example:void 0});case"date":return Xd.date({example:void 0});case"datetime":return Xd.datetime({example:void 0});case"double":return Xd.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 Xd.float({example:void 0});case"int":return Xd.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 Xd.int64({default:e.default,example:void 0});case"uint":return Xd.uint({default:void 0,example:void 0});case"uint64":return Xd.uint64({default:void 0,example:void 0});default:Zo(e)}}function H5S(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:gQt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly}}function w0o(e){return e.type!=="optional"&&e.type!=="nullable"}function tTs(e){return e==="POST"||e==="PUT"||e==="PATCH"}function jkn(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 S0o=class{schemas;context;exampleTypeFactory;logger;constructor(t,r){this.schemas=t,this.context=r,this.schemas=t,this.exampleTypeFactory=new _ti(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=G5S(t.request),i=Q5S(t.response);if(r?.type==="unsupported"||i?.type==="unsupported")return[];let n=[];if(r!=null&&r.type==="present"){let c=this.isSchemaRequired(r.schema);if(r.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:tTs(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});b!=null&&n.push([void 0,b])}else for(let{name:b,value:g}of r.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:tTs(t.method),schema:r.schema,exampleId:b,example:g,options:{isParameter:!1,ignoreOptionals:!0}});O!=null&&n.push([b,O])}if(c&&n.length===0)return this.logger.trace(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(i!=null&&i.type==="present"){let c=this.isSchemaRequired(i.schema);if(t.response?.type==="json"&&t.response.statusCode===204)a.push([void 0,LBe.withoutStreaming(A0.object({properties:{}}))]);else if(i.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:void 0,example:void 0,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});b!=null&&(t.response?.type==="json"?a.push([void 0,LBe.withoutStreaming(b)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,LBe.withStreaming({sse:t.response?.type==="streamingSse",events:[b]})]))}else for(let{name:b,value:g}of i.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:b,example:g,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});O!=null&&(t.response?.type==="json"?a.push([b,LBe.withoutStreaming(O)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,LBe.withStreaming({sse:t.response?.type==="streamingSse",events:[O]})]))}if(c&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let c of t.pathParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!OQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for path parameter ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&u.push({name:c.name,parameterNameOverride:c.parameterNameOverride,value:g})}let l=[];for(let c of t.queryParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!OQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for query parameter ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&l.push({name:c.name,value:g})}let f=[];for(let c of t.headers){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!OQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for header ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&f.push({name:c.name,value:g})}let s=[];t.request!=null&&t.response!=null?s=$5S(n,a):t.request!=null?s=n.map(([c,b])=>({id:c,request:b,response:void 0})):t.response!=null&&(s=a.map(([c,b])=>({id:c,request:void 0,response:b})));let o=t.examples.filter(c=>jkn(c)).flatMap(c=>{if(c.type==="unknown"){if(c.value!=null){let b=c.value["code-samples"];if(b!=null)return this.convertCodeSamples(b)}return}else return c.codeSamples}).filter(c=>dg(c));return s.length===0?[L2t.full({name:void 0,description:void 0,pathParameters:u,queryParameters:l,headers:f,request:void 0,response:void 0,codeSamples:o})]:s.map(({id:c,request:b,response:g})=>L2t.full({name:c,description:void 0,pathParameters:u,queryParameters:l,headers:f,request:b,response:g,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?C8r.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):C8r.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?QL.Csharp:r.sdk,code:r.code})).filter(dg)}isSchemaRequired(t){return w0o(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function $5S(e,t){let r=[];if(e.length<=1){let[n,a]=e[0]??[];if(t.length===0)return r.push({id:n,request:a,response:void 0}),r;for(let[u,l]of t)r.push({id:u??n,request:a,response:l});return r}if(t.length<=1){let[n,a]=t[0]??[];if(t.length===0)return r.push({id:n,request:void 0,response:a}),r;for(let[u,l]of e)r.push({id:u??n,request:l,response:a});return r}let i=new Set;for(let[n,a]of e){let u=t.find(([f])=>f==null)?.[1]??t[0]?.[1];if(n==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let l=!1;for(let f=0;f<t.length;f++){let[s,o]=t[f];s==null||i.has(f)||n===s&&(r.push({id:n,request:a,response:o}),s!=null&&i.add(f),l=!0)}!l&&u!=null&&r.push({id:n,request:a,response:u})}for(let n=0;n<t.length;n++){if(i.has(n))continue;let[a,u]=t[n],l=e.find(([f])=>f==null)?.[1]??e[0]?.[1];l!=null&&r.push({id:a,request:l,response:u})}return r}function G5S(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:J5S(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function Q5S(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"&&e.type!=="streamingSse"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function OQt(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return OQt(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return OQt(e.value.value);default:return!1}default:Zo(e)}}function J5S(e){return Fl.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:gQt(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,inline:void 0}).filter(dg),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,inline:void 0})}var D0o=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new _ti(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,publish:i,subscribe:n,handshake:a,source:u,namespace:l}){let f=[];for(let s of r){let o=[];for(let g of a.queryParameters){let O=this.isSchemaRequired(g.schema),m=this.exampleTypeFactory.buildExample({schema:g.schema,exampleId:void 0,example:s.queryParameters?.[g.name],options:{name:g.name,isParameter:!0,ignoreOptionals:!0}});m!=null&&!OQt(m)&&(m=void 0),!(O&&m==null)&&m!=null&&o.push({name:g.name,value:m})}let c=[];for(let g of a.headers){let O=this.isSchemaRequired(g.schema),m=this.exampleTypeFactory.buildExample({schema:g.schema,exampleId:void 0,example:s.headers?.[g.name],options:{name:g.name,isParameter:!0,ignoreOptionals:!0}});m!=null&&!OQt(m)&&(m=void 0),!(O&&m==null)&&m!=null&&c.push({name:g.name,value:m})}let b=[];for(let g of s.messages){let O=t.resolveMessageReference({$ref:`#/components/messages/${g.messageId}`}),m=rp(O.payload)?t.resolveSchemaReference(O.payload):O.payload,w=this.exampleTypeFactory.buildExample({schema:rg(m,!1,t,[g.messageId],u,l),exampleId:void 0,example:g.value,options:{isParameter:!1,ignoreOptionals:!0}});w!=null&&b.push({messageType:g.type,payload:w,description:void 0})}f.push({name:s.summary,queryParameters:o,headers:c,description:s.description,messages:b})}return f}buildWebsocketSessionExample({publish:t,subscribe:r,handshake:i}){let n={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},a=[];for(let l of i.queryParameters){let f=this.isSchemaRequired(l.schema),s=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(s!=null&&!OQt(s)&&(s=void 0),f&&s==null)return;s!=null&&a.push({name:l.name,value:s})}let u=[];for(let l of i.headers){let f=this.isSchemaRequired(l.schema),s=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(s!=null&&!OQt(s)&&(s=void 0),f&&s==null)return;s!=null&&u.push({name:l.name,value:s})}if(t!=null){let l=this.exampleTypeFactory.buildExample({schema:t,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});l!=null&&n.messages.push({messageType:"publish",payload:l,description:void 0})}if(r!=null){let l=this.exampleTypeFactory.buildExample({schema:r,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});l!=null&&n.messages.push({messageType:"subscribe",payload:l,description:void 0})}return n}isSchemaRequired(t){return w0o(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 ppn={FERN_DISPLAY_NAME:"x-fern-display-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",IGNORE:"x-fern-ignore"};function kbp(e){return Vf(e,ppn.FERN_EXAMPLES)??[]}function t0p({document:e,taskContext:t,options:r,source:i,asyncApiOptions:n,namespace:a}){let u=[];a!=null&&u.push(a),e.tags?.[0]!=null?u.push(e.tags[0].name):n.naming!=="v2"&&u.push("websocket");let l=new j0o({document:e,taskContext:t,options:r,namespace:a}),f={},s;for(let[c,b]of Object.entries(e.components?.schemas??{})){let g=rg(b,!1,l,[c],i,a);f[c]=g}let o=new D0o(f,l);for(let[c,b]of Object.entries(e.channels??{})){let g=Vf(b,ppn.IGNORE);if(g!=null&&g){l.logger.debug(`Channel ${c} is marked with x-fern-ignore. Skipping.`);continue}if(b.bindings?.ws==null){l.logger.error(`Channel ${c} does not have websocket bindings. Skipping.`);continue}let O=[];if(b.parameters!=null)for(let[q,D]of Object.entries(b.parameters??{}))O.push({name:q,description:D.description,parameterNameOverride:void 0,schema:D.schema!=null?rg(D.schema,!1,l,u,i,a):Fl.primitive({schema:Xd.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:XBe(D),source:i});let m=[];if(b.bindings.ws.headers!=null){let q=b.bindings.ws.headers.required??[];for(let[D,C]of Object.entries(b.bindings.ws.headers.properties??{})){let R=rp(C)?l.resolveSchemaReference(C):C;m.push({name:D,schema:rg(R,!q.includes(D),l,u,i,a),description:R.description,parameterNameOverride:void 0,env:void 0,availability:XBe(R),source:i})}}let w=[];if(b.bindings.ws.query!=null){let q=b.bindings.ws.query.required??[];for(let[D,C]of Object.entries(b.bindings.ws.query.properties??{})){let R=rp(C)?l.resolveSchemaReference(C):C;w.push({name:D,schema:rg(R,!q.includes(D),l,u,i,a),description:R.description,parameterNameOverride:void 0,availability:XBe(R),source:i})}}let A;b.publish!=null&&(A=e0p({generatedName:b.publish.operationId??"PublishEvent",event:b.publish,breadcrumbs:u,context:l,source:i,options:r,asyncApiOptions:n}));let M;if(b.subscribe!=null&&(M=e0p({generatedName:b.subscribe.operationId??"SubscribeEvent",event:b.subscribe,breadcrumbs:u,context:l,source:i,options:r,asyncApiOptions:n})),m.length>0||w.length>0||A!=null||M!=null){let q=kbp(b),D=[];if(q.length>0)D=o.buildWebsocketSessionExamplesForExtension({context:l,extensionExamples:q,handshake:{headers:m,queryParameters:w},publish:A,subscribe:M,source:i,namespace:a});else{let R=o.buildWebsocketSessionExample({handshake:{headers:m,queryParameters:w},publish:A,subscribe:M});R!=null&&D.push(R)}let C=e.tags?.[0]?.name!=null?[e.tags?.[0].name]:void 0;s={audiences:Vf(b,md.AUDIENCES)??[],handshake:{headers:m.map(R=>({...R,schema:Dq(R.schema),env:R.env})),queryParameters:w.map(R=>({...R,schema:Dq(R.schema)})),pathParameters:O.map(R=>({...R,parameterNameOverride:void 0,schema:Dq(R.schema)}))},groupName:l.resolveTags(C,"Websocket"),publish:A!=null?Dq(A):A,subscribe:M!=null?Dq(M):M,summary:Vf(b,ppn.FERN_DISPLAY_NAME),path:c,description:void 0,examples:D,source:i};break}}return{groupedSchemas:P0o(a,f),channel:s,basePath:Vf(e,ppn.BASE_PATH)}}function e0p({generatedName:e,event:t,context:r,breadcrumbs:i,source:n,options:a,asyncApiOptions:u}){if(t.message.oneOf!=null){let l=[],f=[];for(let s of t.message.oneOf){let o,c={type:"notFound"};if(rp(s)){let b=r.resolveMessageReference(s);!rp(b.payload)&&u.naming==="v2"?(c=b.name?{type:"name",name:b.name}:c,o={...b.payload,title:b.name??b.payload.title,description:b.name??b.payload.description}):o=b.payload}else o=s;f.push(c),l.push(o)}return lpn({description:t.description??t.message.description,availability:XBe(t.message),subtypes:l,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:i,context:r,encoding:void 0,source:n,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?f:[]})}}function r0p(e){let t=K5S(e),r={};return rTs({obj:t,occurrences:r,breadcrumbs:[]}),r}function rTs({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let i of e)rTs({obj:i,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let i=e.$ref;t[i]==null?t[i]=1:t[i]+=1;return}for(let i in e)rTs({obj:e[i],occurrences:t,breadcrumbs:[...r,i]})}}}function K5S(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?wkn(r.get):void 0,put:r?.put!=null?wkn(r.put):void 0,post:r?.post!=null?wkn(r.post):void 0,patch:r?.patch!=null?wkn(r.patch):void 0,delete:r?.delete!=null?wkn(r.delete):void 0}]))}}function wkn(e){return{...e,requestBody:e.requestBody!=null?rp(e.requestBody)?e.requestBody:Y5S(e.requestBody):void 0}}function Y5S(e){let t,r;for(let i in e.content){let n=aB.parse(i);n!=null&&(n.isJSON()?t=e.content[i]:n.isMultipart()&&(r=e.content[i]))}return r!=null&&t!=null?{...e,content:{[aB.MULTIPART_FORM_DATA]:r}}:e}var E0o=class{endpoints;parser=new OPi;constructor({context:t,options:r}){this.endpoints=r.filter?.endpoints?new Set(this.validateAndFilterEndpoints({context:t,endpoints:r.filter.endpoints})):void 0}skipEndpoint({method:t,path:r}){return this.endpoints!=null&&!this.endpoints.has(`${t} ${r}`)}hasEndpoints(){return this.endpoints!=null}validateAndFilterEndpoints({context:t,endpoints:r}){let i=[];for(let n of r){let a=this.parser.tryParse(n);if(a==null){t.logger.debug(`Ignoring configured filter endpoint "${n}"; expected format "POST /users/get"`);continue}i.push(`${a.method} ${a.path}`)}return i}};var i0p="#/components/parameters/",n0p="#/components/responses/",a0p="#/components/examples/",o0p="#/components/requestBodies/",_pn=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=i,this.refOccurrences=r0p(t),this.options=n,this.source=a,this.filter=new E0o({context:r,options:n}),this.DUMMY=this.getDummy(),this.namespace=u}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};r.push(i)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return{"x-fern-type":"unknown"};i=i[n]}return i==null?(this.logger.warn(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):(rp(i)&&(i=this.resolveSchemaReference(i)),i)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(i0p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(i0p.length),i=this.document.components.parameters[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return rp(i)?this.resolveParameterReference(i):i}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(o0p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(o0p.length),i=this.document.components.requestBodies[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return rp(i)?this.resolveRequestBodyReference(i):i}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(n0p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(n0p.length),i=this.document.components.responses[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return rp(i)?this.resolveResponseReference(i):i}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(a0p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(a0p.length),i=this.document.components.examples[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return rp(i)?this.resolveExampleReference(i):i}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}};var hpn=class extends _pn{constructor({document:t,taskContext:r,options:i,source:n,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:i,source:n,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,i){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,i){}getDiscriminatedUnionMetadata(t){}};var A0o=class extends _pn{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discriminatedUnionReferences={};discriminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u})}getDummy(){return new hpn({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,i){let n=this.discriminatedUnionReferences[t.$ref];n!=null?(n.discriminants.add(r),n.numReferences+=i):this.discriminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:i}}getReferencesFromDiscriminatedUnion(t){return this.discriminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,i){let n=this.discriminatedUnionMetadata[t.$ref];n!=null?n.discriminants.set(r,i):this.discriminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,i]])}}getDiscriminatedUnionMetadata(t){return this.discriminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function u0p(e){return Vf(e,md.ASYNC_CONFIG)}var s0p="$request.";function c0p(e){let t=Vf(e,md.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:X5S(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function X5S(e){return e.startsWith(s0p)?e.slice(s0p.length):e}function l0p(e){let t=e;if(t.cursor!=null)return T8r.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});let r=e;return T8r.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}function f0p(e,t){let r=Vf(t,md.PAGINATION);if(r!=null){if(typeof r=="boolean"){let i=Vf(e,md.PAGINATION);if(typeof i=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return i==null?void 0:l0p(i)}return l0p(r)}}var Z5S=Vs.object({lang:Vs.string(),label:Vs.optional(Vs.string()),source:Vs.string()}),iTs=Vs.array(Z5S);var d0p={README_EXT:"x-readme"};function k5S(e){if(!Array.isArray(e))return!1;for(let t of e)if(!Dj(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function p0p(e){let t=Vf(e,d0p.README_EXT);if(!Dj(t))return[];let r=t["code-samples"];if(!k5S(r))return[];let i=[];for(let n of r)i.push({name:n.name,language:n.language,code:n.code,install:n.install,docs:void 0});return i}function _0p(e,t,r){let n=(Vf(t,md.EXAMPLES)??[]).filter(s=>{let o=lH.serialization.ExampleEndpointCallSchema.parse(s);return o.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),o.ok}),a=Okn(t,Uwe.REDOCLY_CODE_SAMPLES_KEBAB,iTs,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],l=[...Okn(t,Uwe.REDOCLY_CODE_SAMPLES_CAMEL,iTs,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];l.length>0&&n.push({"code-samples":l.map(s=>({name:s.label??s.lang,language:s.lang,code:s.source,install:void 0,docs:void 0}))});let f=p0p(t);return f.length>0&&n.push({"code-samples":f}),n.map(L2t.unknown)}function h0p(e){let t=Vf(e,md.AVAILABILITY);if(t==="ga"||t==="generally-available")return GL.GenerallyAvailable;if(t==="beta"||t==="pre-release")return GL.Beta;if(t==="deprecated")return GL.Deprecated;if(e.deprecated)return GL.Deprecated}function M0o(e){return{url:e9S({url:e.url,variables:e.variables??{}}),description:e.description,name:t9S(e),audiences:Vf(e,md.AUDIENCES)}}function e9S({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,n.default]));for(let[i,n]of Object.entries(r))e=e.replace(`{${i}}`,n);return e}function t9S(e){let t=Vf(e,[md.SERVER_NAME_V1,md.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function y0p(e){return Vf(e,md.PARAMETER_NAME)}function v0p(e){return Vf(e,md.SDK_VARIABLE)}function q0o({path:e,httpMethod:t,parameters:r,context:i,requestBreadcrumbs:n,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let l of r){let f=Vf(l,md.IGNORE);if(f!=null&&f){i.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=rp(l)?i.resolveParameterReference(l):l,o=s.required??!1,c=XBe(s),b=[...n,s.name],g=d2(b,i.options.preserveSchemaIds),O=s.schema!=null?rg(s.schema,!o,i,b,a,i.namespace,!1,new Set,G8r({schema:s,logger:i.logger})):o?Fl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:G8r({schema:s,logger:i.logger})}),description:void 0,availability:c,groupName:void 0}):Fl.optional({nameOverride:void 0,generatedName:g,title:void 0,value:Fl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:G8r({schema:s,logger:i.logger})}),description:void 0,availability:void 0,groupName:void 0}),description:void 0,availability:c,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!rp(s.schema)&&s.schema.default!=null){let w=s.schema.default;typeof w=="string"&&w.length>0&&(O=Fl.literal({nameOverride:void 0,generatedName:g,title:void 0,value:bB.string(w),description:void 0,availability:c,groupName:void 0}))}let m={name:s.name,schema:O,description:s.description,parameterNameOverride:y0p(s),availability:c,source:a};s.in==="query"?u.queryParameters.push(m):s.in==="path"?u.pathParameters.push({...m,variableReference:v0p(s)}):s.in==="header"?!r9S.has(s.name.toLowerCase())&&!i.authHeaders.has(s.name)?u.headers.push({...m,env:void 0}):i.logger.debug(`Ignoring ${s.name} header, in ${t.toUpperCase()} ${e}`):i.logger.warn(`Skipping ${s.in} parameter, ${s.name}, in ${t.toUpperCase()} ${e}`)}return u}var r9S=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function b0p(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r,schema:n??{},examples:Skn(i,t)}}}function ypn(e,t){for(let r of Object.keys(e))if(r.includes("json")||r==="*/*"){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r.includes("*")?void 0:r,schema:n??{},examples:Skn(i,t)}}}function g0p(e,t){for(let r of Object.keys(e)){let i=e[r];if(i==null)continue;return{schema:i.schema??{},examples:Skn(i,t)}}}function Skn(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let i=Vf(e,Uwe.EXAMPLES);return i!=null&&Object.keys(i).length>0&&r.push(...Object.entries(i).map(([n,a])=>({name:a.summary??n,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([n,a])=>{let u=rp(a)?t.resolveExampleReference(a):a;return{name:u.summary??n,value:u.value,description:u.description}})),r}function i9S(e,t){for(let[r,i]of Object.entries(e.content))if(aB.parse(r)?.isURLEncoded())return{schema:i.schema,contentType:r,examples:Skn(i,t)}}function n9S(e){for(let[t,r]of Object.entries(e.content))if(aB.parse(t)?.isMultipart())return{schema:r.schema,encoding:r.encoding}}function a9S(e){for(let t in e.content)if(aB.parse(t)?.isOctetStream())return!0;return!1}function o9S(e,t){let r=rp(e)?nTs(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([i,n])=>!rp(n)&&n.type==="string"&&n.format==="binary")!=null}function vpn({requestBody:e,document:t,context:r,requestBreadcrumbs:i,source:n,namespace:a}){let u=rp(e)?r.resolveRequestBodyReference(e):e,l=n9S(u),f=l?.schema,s=l?.encoding,o=i9S(u,r),c=ypn(u.content,r);if(a9S(u))return Iwe.octetStream({description:u.description,source:n});if(f!=null&&c==null||f!=null&&o9S(f,t)){let b=rp(f)?nTs(f,t):{id:void 0,schema:f},g=rg(b.schema,!1,r,i,n,a),O=[];if(g.type==="object")for(let m of g.properties){if(m.schema.type==="primitive"&&m.schema.schema.type==="string"&&m.schema.schema.format==="binary"){O.push({key:m.key,schema:UBe.file({isOptional:!1,isArray:!1}),description:m.schema.description,contentType:s?.[m.key]?.contentType});continue}if(m.schema.type==="optional"&&m.schema.value.type==="primitive"&&m.schema.value.schema.type==="string"&&m.schema.value.schema.format==="binary"){O.push({key:m.key,schema:UBe.file({isOptional:!0,isArray:!1}),description:m.schema.description,contentType:s?.[m.key]?.contentType});continue}if(m.schema.type==="array"&&m.schema.value.type==="primitive"&&m.schema.value.schema.type==="string"&&m.schema.value.schema.format==="binary"){O.push({key:m.key,schema:UBe.file({isOptional:!1,isArray:!0}),description:m.schema.description,contentType:s?.[m.key]?.contentType});continue}if(m.schema.type==="optional"&&m.schema.value.type==="array"&&m.schema.value.value.type==="primitive"&&m.schema.value.value.schema.type==="string"&&m.schema.value.value.schema.format==="binary"){O.push({key:m.key,schema:UBe.file({isOptional:!0,isArray:!0}),description:m.schema.description,contentType:s?.[m.key]?.contentType});continue}O.push({key:m.key,schema:UBe.json(m.schema),description:void 0,contentType:s?.[m.key]?.contentType})}return Iwe.multipart({name:rp(f)&&r.getNumberOfOccurrencesForRef(f)===1?b.id:void 0,description:b.schema.description,properties:O,source:n})}if(c!=null){let b=rg(c.schema,!1,r,i,n,a,!0);return Iwe.json({description:void 0,schema:b,contentType:c.contentType,fullExamples:c.examples,additionalProperties:!rp(c.schema)&&upn(c.schema.additionalProperties),source:n})}if(o!=null&&o.schema!=null){let b=rg(o.schema,!1,r,i,n,a);return Iwe.json({schema:b,description:u.description,contentType:o.contentType,source:n,fullExamples:o.examples,additionalProperties:!1})}}function nTs(e,t){if(!e.$ref.startsWith(RSi))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=dti(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let i=t.components?.schemas?.[r];if(i==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return rp(i)?nTs(i,t):{id:r,schema:i}}var aTs={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"},O0p=new Set(Object.values(aTs));var u9S=["200","201","202","204"];function P0p({operationContext:e,responses:t,context:r,responseBreadcrumbs:i,responseStatusCode:n,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let l=s9S({responses:t,context:r,source:u,namespace:r.namespace}),f=!1,s;for(let o of n!=null?[n]:u9S){let c=t[o];c!=null&&(f=!0,s==null&&(s=m0p({operationContext:e,response:c,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace,statusCode:typeof o=="string"?parseInt(o):o})))}if(s==null&&!f&&t.default!=null&&(s=m0p({operationContext:e,response:t.default,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:l};case"streamingJson":case"streamingSse":return{value:s,errors:l};case"file":case"text":case"streamingText":return{value:s,errors:l};default:Zo(s)}return{value:void 0,errors:l}}function m0p({operationContext:e,streamFormat:t,response:r,context:i,responseBreadcrumbs:n,source:a,namespace:u,statusCode:l}){let f=rp(r)?i.resolveResponseReference(r):r;if(f.content!=null&&Object.entries(f.content).find(([b,g])=>{if(g.schema==null)return!1;let O=rp(g.schema)?i.resolveSchemaReference(g.schema):g.schema;return O.type==="string"&&O.format==="binary"}))return gB.file({description:f.description,source:a,statusCode:l});let s=b0p(f.content??{},i);if(s!=null&&t!=null)switch(t){case"json":return gB.streamingJson({statusCode:l,description:f.description,responseProperty:Vf(e.operation,md.RESPONSE_PROPERTY),fullExamples:s.examples,schema:rg(s.schema,!1,i,n,a,u),source:a});case"sse":return gB.streamingSse({description:f.description,responseProperty:void 0,fullExamples:s.examples,schema:rg(s.schema,!1,i,n,a,u),source:a,statusCode:l})}let o=ypn(f.content??{},i);if(o!=null){if(t!=null)switch(t){case"json":return gB.streamingJson({description:f.description,responseProperty:void 0,fullExamples:o.examples,schema:rg(o.schema,!1,i,n,a,u),source:a,statusCode:l});case"sse":return gB.streamingSse({description:f.description,responseProperty:void 0,fullExamples:o.examples,schema:rg(o.schema,!1,i,n,a,u),source:a,statusCode:l})}return gB.json({description:f.description,schema:rg(o.schema,!1,i,n,a,u),responseProperty:Vf(e.operation,md.RESPONSE_PROPERTY),fullExamples:o.examples,source:a,statusCode:l})}for(let[c,b]of Object.entries(f.content??{})){let g=aB.parse(c);if(g!=null){if(g.isOctetStream()||g.isPDF()||g.isAudio()||g.isImage()||g.isVideo())return gB.file({description:f.description,source:a,statusCode:l});if(g.isPlainText()){let O=b.schema;if(O==null)return gB.text({description:f.description,source:a,statusCode:l});let m=rp(O)?i.resolveSchemaReference(O):O;return m.type==="string"&&m.format==="byte"?gB.file({description:f.description,source:a,statusCode:l}):gB.text({description:f.description,source:a,statusCode:l})}}}}function s9S({responses:e,context:t,source:r,namespace:i}){let n={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let l=parseInt(a);if(l<400||l>600)continue;let f=rp(u)?t.resolveResponseReference(u):u,s=g0p(f.content??{},t),o=aTs[l];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}n[l]={statusCode:l,nameOverride:void 0,generatedName:o,description:f.description,schema:rg(s?.schema??{},!1,t,[o,"Body"],r,i),fullExamples:s?.examples,source:r}}return n}function Q8r({operationContext:e,context:t,responseStatusCode:r,suffix:i,streamFormat:n,source:a}){let{document:u,operation:l,path:f,method:s,baseBreadcrumbs:o,sdkMethodName:c}=e,b=Vf(l,md.IDEMPOTENT),g=Vf(l,[md.REQUEST_NAME_V1,md.REQUEST_NAME_V2]),O=[...o,"Request"],m=q0o({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:O,path:f,httpMethod:s,source:a}),w=/{([^}]+)}/g,M=[...f.matchAll(w)].map(U=>U[1]).filter(U=>!m.pathParameters.some(H=>H.name===U));if(M.length>0)for(let U of M)m.pathParameters.push({name:U??"",variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:Fl.primitive({schema:Xd.string({default:void 0,example:void 0,format:void 0,maxLength:void 0,minLength:void 0,pattern:void 0}),description:void 0,generatedName:"",nameOverride:void 0,groupName:void 0,availability:void 0,title:void 0}),description:void 0});let q=l.requestBody!=null?vpn({requestBody:l.requestBody,document:u,context:new hpn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:O,source:a,namespace:t.namespace}):void 0;l9S({context:t,convertedParameters:m})&&q!=null&&q.type==="json"&&q.schema.type!=="object"&&l.requestBody!=null?q=vpn({requestBody:l.requestBody,document:u,context:t,requestBreadcrumbs:[...O,"Body"],source:a,namespace:t.namespace}):l.requestBody!=null&&(q=vpn({requestBody:l.requestBody,document:u,context:t,requestBreadcrumbs:[...O],source:a,namespace:t.namespace}));let D=[...o,"Response"],C=P0p({operationContext:e,streamFormat:n,responses:l.responses,context:t,responseBreadcrumbs:D,responseStatusCode:r,source:a});e.method==="GET"&&(q=void 0);let R=h0p(l),$=_0p(e,l,t),I=Vf(l,md.SERVER_NAME_V2);return{summary:l.summary,internal:Vf(l,Uwe.INTERNAL),idempotent:b,audiences:Vf(l,md.AUDIENCES)??[],operationId:l.operationId!=null&&i!=null?l.operationId+"_"+i:l.operationId,tags:t.resolveTagsToTagIds(l.tags),namespace:t.namespace,sdkName:c,pathParameters:m.pathParameters,queryParameters:m.queryParameters,headers:m.headers,requestNameOverride:g??void 0,generatedRequestName:d2(O,t.options.preserveSchemaIds),request:q,response:C.value,errors:C.errors,server:I!=null?[{name:I,url:void 0,audiences:void 0}]:(l.servers??[]).map(U=>M0o(U)),description:l.description,authed:c9S(l,u),availability:R,method:s,path:f,examples:$,pagination:e.pagination,source:a}}function c9S(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function l9S({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function w0p({operationContext:e,context:t,asyncExtension:r,source:i}){let{operation:n,pathItemParameters:a,operationParameters:u}=e,l=r.discriminant.name,f=r.discriminant.value,s=r["response-status-code"],o=j0p({context:t,headerToIgnore:l,parameters:a}),c=j0p({context:t,headerToIgnore:l,parameters:u}),b=Q8r({operationContext:{...e,pathItemParameters:o,operationParameters:c,operation:{...n,responses:Object.fromEntries(Object.entries(n.responses).filter(([O])=>parseInt(O)!==s))}},context:t,streamFormat:void 0,source:i}),g=Q8r({operationContext:{...e,pathItemParameters:o,operationParameters:c,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:i});return g.headers.push({name:l,schema:Fl.literal({nameOverride:void 0,generatedName:d2([l],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:bB.string(f),groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:i}),{sync:b,async:g}}function j0p({context:e,headerToIgnore:t,parameters:r}){return r.filter(i=>{let n=rp(i)?e.resolveParameterReference(i):i;return!(n.in==="header"&&n.name===t)})}var oTs="stream";function A0p({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:Q8r({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let i=S0p({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(i?.schemaReference!=null){let s=dti(i.schemaReference);s!=null&&t.excludeSchema(s)}let n=D0p({operation:e.operation,response:r.responseStream}),a=Q8r({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+oTs}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:i?.requestBody,responses:n},baseBreadcrumbs:[...e.baseBreadcrumbs,oTs]},context:t,streamFormat:r.format,suffix:oTs,source:t.source});a.examples=a.examples.filter(s=>E0p(s,t)!==!1);let u=S0p({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),l=D0p({operation:e.operation,response:r.response}),f=Q8r({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:l}},context:t,source:t.source});return f.examples=f.examples.filter(s=>E0p(s,t)!==!0),{streaming:a,nonStreaming:f}}default:Zo(r)}}function S0p({context:e,operation:t,streamingExtension:r,isStreaming:i}){if(t.requestBody==null)return;let n=rp(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=ypn(n.content,e);if(a==null)return;let u=rp(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let l=u.properties?.[r.streamConditionProperty];l!=null&&rp(l)&&(l=void 0);let f={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":i,...l??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[aB.APPLICATION_JSON]:{schema:f}}},schemaReference:rp(a.schema)?a.schema:void 0}}function D0p({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[aB.APPLICATION_JSON]:{schema:t}}}}}function E0p(e,t){return e._visit({unknown:r=>{let i=lH.serialization.ExampleEndpointCallSchema.parse(r);if(i.ok&&i.value.response!=null)return i.value.response.stream!=null},full:()=>{},_other:()=>{}})}function M0p({context:e,operationContext:t,source:r}){let{document:i,operation:n,path:a,method:u,baseBreadcrumbs:l,sdkMethodName:f}=t,s=[...l,"Payload"],o=q0o({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:u,source:r});if(n.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 c=vpn({requestBody:n.requestBody,document:i,context:e,requestBreadcrumbs:[...l,"Payload"],source:r,namespace:e.namespace});if(c==null||c.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(n.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:n.summary,sdkName:f,namespace:e.namespace,method:u,operationId:n.operationId,tags:e.resolveTagsToTagIds(n.tags),headers:o.headers,generatedPayloadName:d2(s,e.options.preserveSchemaIds),payload:c.schema,description:n.description,examples:f9S(c.fullExamples),source:r}}function f9S(e){if(e==null)return[];let t=[];for(let r of e){let i=pti(r.value);i!=null&&t.push({description:r.description,name:r.name,payload:i})}return t}function uTs({context:e,pathItemContext:t,operation:r,convertToWebhook:i}){let n=Vf(r,md.IGNORE);if(n!=null&&n){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=d9S(r,e),u=f0p(e.document,r),l={...t,sdkMethodName:a,baseBreadcrumbs:p9S({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path}),operation:r,operationParameters:r.parameters??[],pagination:u};if(i){let c=M0p({context:e,operationContext:l,source:e.source});return c!=null?{type:"webhook",value:c}:void 0}let f=c0p(r);if(f!=null){let c=A0p({context:e,operationContext:l,streamingExtension:f});return c!=null?{type:"streaming",streaming:c.streaming,nonStreaming:c.nonStreaming}:void 0}let s=u0p(r);if(s!=null){let c=w0p({context:e,operationContext:l,asyncExtension:s,source:e.source});return{type:"async",async:c.async,sync:c.sync}}return{type:"http",value:Q8r({context:e,operationContext:l,streamFormat:void 0,source:e.source})}}function d9S(e,t){let r=Vf(e,md.SDK_METHOD_NAME),i=Vf(e,md.SDK_GROUP_NAME)??[];if(r!=null){let n=typeof i=="string"?[i]:i;return n=t.resolveGroupName(n),{groupName:n,methodName:r}}}function p9S({sdkMethodName:e,operation:t,httpMethod:r,path:i}){let n=[];if(e!=null){if(e.groupName.length>0){let a=e.groupName[e.groupName.length-1];a!=null&&n.push(typeof a=="string"?a:a.name)}n.push(e.methodName)}else t.operationId!=null?n.push(t.operationId):n.push(pg(`${r}_${i.split("/").join("_")}`));return n}function q0p(e,t,r,i){let n=[],a=C0p(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let l of a){if(i.filter.skipEndpoint({method:l.method,path:e})){i.logger.debug(`Skipping endpoint "${l.method} ${e}"`);continue}let f=_9S({operation:l.operation}),s=uTs({context:i,pathItemContext:{...u,method:l.method},operation:l.operation,convertToWebhook:f});s!=null&&n.push(s)}return n}function T0p(e,t,r,i){let n=[],a=C0p(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let l of a){if(i.filter.skipEndpoint({method:l.method,path:e})){i.logger.debug(`Skipping endpoint "${l.method} ${e}"`);continue}let f=uTs({context:i,pathItemContext:{...u,method:l.method},operation:l.operation,convertToWebhook:!0});f!=null&&n.push(f)}return n}function C0p(e){let t=[];return e.get!=null&&t.push({method:RH.Get,operation:e.get}),e.post!=null&&t.push({method:RH.Post,operation:e.post}),e.put!=null&&t.push({method:RH.Put,operation:e.put}),e.delete!=null&&t.push({method:RH.Delete,operation:e.delete}),e.patch!=null&&t.push({method:RH.Patch,operation:e.patch}),t}function _9S({operation:e}){return Vf(e,[md.WEBHOOK])??!1}function B0p(e){let t=Vf(e,md.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=Vf(e,md.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function x0p(e){return Vf(e,md.FERN_BASIC_AUTH)}function sTs(e,t){if(rp(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return h9S(e,t)}function h9S(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=Vf(e,Uwe.BEARER_FORMAT),i=Vf(e,md.FERN_HEADER_AUTH);return Z4.header({headerName:e.name,prefix:r!=null?"Bearer":i?.prefix,headerVariableName:i?.name??Vf(e,md.HEADER_VARIABLE_NAME),headerEnvVar:i?.env})}else if(e.type==="http"&&e.scheme==="bearer"){let r=Vf(e,md.FERN_BEARER_TOKEN);return Z4.bearer({tokenVariableName:r?.name??Vf(e,md.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme==="basic"){let r=x0p(e),i=B0p(e);return Z4.basic({usernameVariableName:r?.username?.name??i.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??i.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return Z4.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return Z4.oauth({scopesEnum:y9S(e,t)})}throw new Error(`Failed to convert security scheme ${JSON.stringify(e)}`)}function y9S(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let i=fti({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,inline:void 0}),n=Dq(i);if(n.type==="enum")return n}}function I0p(e){return Vf(e,md.BASE_PATH)}var v9S=Vs.record(Vs.string(),Vs.object({summary:Vs.string().optional(),description:Vs.string().optional()}));function z0p({document:e,context:t}){return Okn(e,md.GROUPS,v9S,t.logger)}function R0p({context:e,document:t}){return Vf(t,md.FERN_VERSION)??void 0}function F0p(e){let t=Vf(e,md.FERN_GLOBAL_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?mkn({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function N0p(e){let t=Vf(e,md.FERN_IDEMPOTENCY_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?mkn({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function L0p(e,t){let r=Vf(e,md.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([i,n])=>{if(n.type==="string")return[i,{nameOverride:void 0,generatedName:d2([i],t),title:n.title,schema:WP.string({default:fpn(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 ${i} has unsupported schema ${JSON.stringify(n)}`)}))}var b9S="webhooks";function U0p(e){return Vf(e,b9S)??{}}function V0p(e){return Vf(e,md.RESOLUTIONS)}function W0p({openapi:e}){let t=V0p(e);if(t==null)return e;let r={};for(let i of t){let n=`#/components/schemas/${i.name}`;for(let a of i.resolutions)e=g9S({openapi:e,schemaReference:a,schemaName:i.name}),e=H0p({openapi:e,replaceReference:a,schemaReference:n,replacedReferences:r}),r={...r,...Object.fromEntries(i.resolutions.map(u=>[n,u]))}}return e}function g9S({openapi:e,schemaReference:t,schemaName:r}){let i=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),n=e;for(let a of i){let u=n[a];if(u==null)return e;n=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=n,e}function H0p({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:i}){let n=Object.keys(i).filter(f=>t.startsWith(f)).sort((f,s)=>s.length-f.length)[0];if(n!=null){let f=i[n];if(f!=null){let s=r.replace(n,f);return H0p({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(f=>f.replaceAll("~1","/")),u=e;for(let f of a.slice(0,-1)){let s=u[f];if(s==null)return e;u=s}let l=a[a.length-1];return l==null||(u[l]={$ref:r}),e}function G0p({openApi:e,taskContext:t,options:r,source:i,namespace:n}){e=W0p({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([I,U])=>sTs(U,i)==null?[]:[I,sTs(U,i)])),u=new Set(...Object.entries(a).map(([I,U])=>U.type==="basic"||U.type==="bearer"?"Authorization":U.type==="header"?U.headerName:null)),l=L0p(e,r.preserveSchemaIds),f=F0p(e),s=N0p(e),o=r.audiences??[],c=[],b=[],g=new A0o({document:e,taskContext:t,authHeaders:u,options:r,source:i,namespace:n});g.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([I,U])=>{if(U==null)return;t.logger.debug(`Converting path ${I}`);let H=q0p(I,U,e,g);for(let te of H){let J=$0p({operation:te});if(!(o.length>0&&!o.some(ee=>J.includes(ee))))switch(te.type){case"async":c.push(te.sync),c.push(te.async);break;case"http":c.push(te.value);break;case"streaming":c.push(te.streaming),te.nonStreaming&&c.push(te.nonStreaming);break;case"webhook":b.push(te.value);break;default:Zo(te)}}}),Object.entries(U0p(e)).forEach(([I,U])=>{if(U==null)return;t.logger.debug(`Converting path ${I}`);let H=T0p(I,U,e,g);for(let te of H){let J=$0p({operation:te});o.length>0&&!o.some(ee=>J.includes(ee))||b.push(te.value)}});let O=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([I,U])=>{if(!rp(U)){let H=Vf(U,md.IGNORE);if(H!=null&&H)return[];if(O0p.has(I))return[I,rg({...U,"x-fern-type-name":`${I}Body`},!1,g,[I],i,n)]}return[I,rg(U,!1,g,[I],i,n)]}).filter(I=>I.length>0)),m=O9S(O,g,i),w=m9S(m,g),A={};for(let[I,U]of Object.entries(w)){let H=Dq(U);g.isSchemaExcluded(I)||(A[I]=H,t.logger.debug(`Converted schema ${I}`))}let M=new _ti(w,g.nonRequestReferencedSchemas,g),q=b.map(I=>{let H=I.examples;if(!r.disableExamples&&H.length===0){let te=M.buildExample({schema:I.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});te!=null&&(H=[{name:void 0,description:void 0,payload:te}])}return{...I,payload:Dq(I.payload),examples:H}}),D=new S0o(w,g),C=c.map(I=>{let U=I.examples,H=U;if(!r.disableExamples&&(U.length===0||U.every(jkn))){let ee=D.buildEndpointExample(I);ee.length>0&&(H=[...ee,...U.filter(fe=>!jkn(fe))])}let te=I.request,J=I.response;return{...I,request:te?.type==="json"?{...te,schema:Dq(te.schema)}:te,response:J?.type==="json"?{...J,schema:Dq(J.schema)}:J,queryParameters:I.queryParameters.map(ee=>({description:ee.description,name:ee.name,schema:Dq(ee.schema),parameterNameOverride:ee.parameterNameOverride,availability:ee.availability,source:ee.source})),pathParameters:I.pathParameters.map(ee=>({description:ee.description,name:ee.name,schema:Dq(ee.schema),parameterNameOverride:ee.parameterNameOverride,variableReference:ee.variableReference,availability:ee.availability,source:ee.source})),headers:I.headers.map(ee=>({description:ee.description,name:ee.name,schema:Dq(ee.schema),parameterNameOverride:ee.parameterNameOverride,env:ee.env,availability:ee.availability,source:ee.source})),examples:H,errors:cd(I.errors,ee=>{let fe=ee.fullExamples?.map(me=>{let ve=pti(me.value);if(ve!=null)return{name:me.name,description:me.description,example:ve}}).filter(dg);if(fe?.length===0){let me=M.buildExample({schema:ee.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});me!=null&&fe.push({name:void 0,description:void 0,example:me})}return{generatedName:ee.generatedName,nameOverride:ee.nameOverride,schema:Dq(ee.schema),description:ee.description,source:ee.source,examples:fe}})}}),R=z0p({document:e,context:g});return{apiVersion:R0p({context:g,document:e}),basePath:I0p(e),title:e.info.title,description:e.info.description,groups:Object.fromEntries(Object.entries(R??{}).map(([I,U])=>[I,{summary:U.summary??void 0,description:U.description??void 0}])),servers:(e.servers??[]).map(I=>M0o(I)),tags:{tagsById:Object.fromEntries((e.tags??[]).map(I=>[I.name,{id:I.name,description:I.description}])),orderedTagIds:e.tags?.map(I=>I.name)},endpoints:C,webhooks:q,channel:[],groupedSchemas:P0o(n,A),securitySchemes:a,hasEndpointsMarkedInternal:C.some(I=>I.internal),nonRequestReferencedSchemas:g.getReferencedSchemas(),variables:l,globalHeaders:f,idempotencyHeaders:s}}function O9S(e,t,r){let i={};for(let[n,a]of Object.entries(e)){if(a.type!=="object"){i[n]=a;continue}let u={$ref:`#/components/schemas/${n}`},l=t.getReferencesFromDiscriminatedUnion(u);if(l==null){i[n]=a;continue}let f={...a,type:"object",properties:a.properties.filter(o=>!l.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!l.discriminants.has(o.propertyKey)),source:r};i[n]=f;let s=Q0p({schema:a,schemas:e});for(let o of[...new Set(s)]){let c=i[o]??e[o];c==null||c.type!=="object"||(i[o]={...c,type:"object",properties:c.properties.filter(b=>!l.discriminants.has(b.key)),allOfPropertyConflicts:c.allOfPropertyConflicts.filter(b=>!l.discriminants.has(b.propertyKey))})}}return i}function m9S(e,t){let r={};for(let[i,n]of Object.entries(e)){if(n.type!=="object"){r[i]=n;continue}let a={$ref:`#/components/schemas/${i}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[i]=n;continue}let l=[];for(let s of n.properties)if(u.discriminants.has(s.key)){let o=u.discriminants.get(s.key);o!=null&&l.push({...s,schema:Fl.literal({nameOverride:void 0,generatedName:d2([n.generatedName,o],t.options.preserveSchemaIds),title:void 0,value:bB.string(o),groupName:void 0,description:void 0,availability:n.availability})})}else l.push(s);let f={...n,type:"object",properties:l};r[i]=f}return r}function Q0p({schema:e,schemas:t}){let r=[];for(let i of e.allOf){r.push(i.schema);let n=t[i.schema];n!=null&&n.type==="object"&&r.push(...Q0p({schema:n,schemas:t}))}return r}function $0p({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:Zo(e)}return t}function FSi({context:e,documents:t,options:r}){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 n of t){let a=n.source!=null?n.source:N2t.openapi({file:"<memory>"});switch(n.type){case"openapi":{let u=G0p({taskContext:e,openApi:n.value,options:Gqs({options:n.settings,overrides:r}),source:a,namespace:n.namespace});i=j9S(i,u);break}case"asyncapi":{let u=t0p({document:n.value,taskContext:e,options:Gqs({options:n.settings,overrides:r}),source:a,asyncApiOptions:P9S({options:n.settings}),namespace:n.namespace});u.channel!=null&&i.channel.push(u.channel),u.groupedSchemas!=null&&(i.groupedSchemas=J0p(i.groupedSchemas,u.groupedSchemas)),u.basePath!=null&&(i.basePath=u.basePath);break}default:Zo(n)}}return i}function P9S({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??Dbp.naming}}function j9S(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:J0p(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 J0p(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,i]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...i}:e.namespacedSchemas[r]=i;return e}var T0o={config:new K0p.Config({apis:{},styleguide:{plugins:[Qqs],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};function Dkn(e){return e.swagger!=null}function cTs(e){return e.openapi!=null}function hti(e,t={}){return{...Object.fromEntries(BR(e.namedDefinitionFiles).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...BR(e.importedDefinitions).reduce((r,[i,n])=>({...r,...oUn(hti(n.definition,{defaultURL:n.url}),(a,u)=>Dz(i,Wh.of(u)))}),{})}}function Ekn(e,t={}){return{...Object.fromEntries(BR(e.packageMarkers).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...BR(e.importedDefinitions).reduce((r,[i,n])=>({...r,...oUn(Ekn(n.definition,{defaultURL:n.url}),(a,u)=>Dz(i,Wh.of(u)))}),{})}}function J8r(e){return{...Ekn(e),...hti(e)}}function Lte(e,t){return J8r(e.definition)[t]?.contents}function dF(e,t){for(let[r,i]of BR(J8r(e.definition)))t(r,i.contents,{isPackageMarker:nmi(r)===P1,defaultUrl:i.defaultUrl})}function NSi(e,t){for(let[r,i]of BR(Ekn(e.definition)))t(r,i.contents)}var njp=Di(ijp(),1);async function gea(e){return(await(0,njp.convertObj)(e,{})).openapi}var ojp=require("fs/promises");var ajp=require("fs/promises");async function Ngo({absoluteFilePathToOverrides:e,data:t,context:r}){let i=null;try{let n=(await(0,ajp.readFile)(e,"utf8")).toString();try{i=JSON.parse(n)}catch{i=pp.load(n,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return T$u({data:t,overrides:i})}async function ujp({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,ojp.readFile)(t)).toString(),n=await pp.load(i);return r!=null?await Ngo({absoluteFilePathToOverrides:r,context:e,data:n}):n}var mea=Di(p0o(),1);var sjp=Di(p0o(),1),dBs=Di(require("path"),1);var Oea=class extends sjp.BaseResolver{absolutePathToOpenAPIOverrides;constructor(t){super(),this.absolutePathToOpenAPIOverrides=t}resolveExternalRef(t,r){let i=super.resolveExternalRef(t,r);return o6r(Kl.of(i))?i:this.absolutePathToOpenAPIOverrides!=null?dBs.default.resolve(dBs.default.dirname(this.absolutePathToOpenAPIOverrides),r):i}};async function pBs({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,parsed:r}){return(r!=null?await(0,mea.bundle)({...T0o,doc:{source:new mea.Source(e,"<openapi>"),parsed:r},externalRefResolver:new Oea(t)}):await(0,mea.bundle)({...T0o,ref:e,externalRefResolver:new Oea(t)})).bundle.parsed}async function Pea({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r}){let i=await pBs({absolutePathToOpenAPI:t}),n;if(r!=null?n=r:typeof i=="object"&&i[md.OPENAPI_OVERIDES_FILEPATH]!=null&&(n=ku(Mp(t),yo.of(i[md.OPENAPI_OVERIDES_FILEPATH]))),n!=null){let a=await Ngo({absoluteFilePathToOverrides:n,context:e,data:i});return await pBs({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,parsed:a})}return i}var e6t=class{absoluteFilePath;constructor(t){this.absoluteFilePath=t}async loadDocuments({context:t,specs:r}){let i=[];for(let n of r){let a=(await(0,cjp.readFile)(n.absoluteFilepath)).toString(),u=xT(this.absoluteFilePath,n.source.file);n.source.relativePathToDependency!=null&&(u=ku(n.source.relativePathToDependency,u));let l=n.source.type==="protobuf"?N2t.protobuf({file:u}):N2t.openapi({file:u});if(a.includes("openapi")||a.includes("swagger")){let f=await Pea({absolutePathToOpenAPI:n.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:n.absoluteFilepathToOverrides});if(cTs(f))i.push({type:"openapi",value:f,source:l,namespace:n.namespace,settings:n.settings});else if(Dkn(f)){let s=await gea(f);i.push({type:"openapi",value:s,source:l,namespace:n.namespace,settings:n.settings})}}else if(a.includes("asyncapi")){let f=await ujp({context:t,absoluteFilePath:n.absoluteFilepath,absoluteFilePathToOverrides:n.absoluteFilepathToOverrides});i.push({type:"asyncapi",value:f,source:l,namespace:n.namespace,settings:n.settings})}else t.failAndThrow(`${n.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}};var Kgo=require("fs/promises"),Fwp=Di(Jk(),1);var Rwp=Di(zwp(),1);async function QH(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...u}={}){let l=n.reduce((o,c)=>({...o,[c]:"<redacted>"}),a),f=[t,...r].join(" ");for(let[o,c]of Object.entries(l))f=f.replaceAll(o,c);e?.debug(`+ ${f}`);let s=(0,Rwp.default)(t,r,u);return i||(s.stdout?.pipe(process.stdout),s.stderr?.pipe(process.stderr)),s}function Qgo(e,{logger:t,...r}={}){return(i,n)=>QH(t,e,i,{...r,...n})}var EQS="buf.gen.yaml",Nwp="output",AQS=`${Nwp}/openapi.yaml`,MQS=`
1929
+ `)),{ok:!0,value:t}):i}}function o_o(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var Nfn=class e extends Error{errors;constructor(t){super(t.map(o_o).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var Lfn=class e extends Error{errors;constructor(t){super(t.map(o_o).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function nM(e){return{optional:()=>qSs(e),transform:t=>TSs(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new Lfn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new Nfn(i.errors)}}}function qSs(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>PP.OPTIONAL};return{...t,...nM(t)}}function TSs(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...nM(r)}}function Nsp(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:$E(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:$E(t,"bigint")}]},getType:()=>PP.BIGINT};return{...k4(e),...nM(e)}}var hwS=/^([+-]?\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 Lsp(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:$E(t,"string")}]}:hwS.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:$E(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:$E(t,"Date object")}]},getType:()=>PP.DATE};return{...k4(e),...nM(e)}}function FH(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...k4(r),...nM(r)}}}function u_o(e){let t=new Set(e);return FH(PP.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:$E(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:$E(i,"enum")}]}:{ok:!0,value:i})()}function Usp(e){let t=CSs(e);return{...t,...nM(t)}}function CSs(e){return{parse:(t,r)=>Ufn(e).parse(t,r),json:(t,r)=>Ufn(e).json(t,r),getType:()=>Ufn(e).getType()}}function Ufn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function dZn(e){return Object.entries(e)}function pZn(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function Tei(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 _Zn(e){return Object.keys(e)}function Vsp(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function U2t(e){return{withParsedProperties:t=>BSs(e,t)}}function BSs(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((l,[f,s])=>({...l,[f]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!Tei(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:$E(i,"object")}]};let a=new Set(Object.keys(t)),u=pZn(i,Object.keys(i).filter(l=>!a.has(l)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...nM(r),...U2t(r)}}function Wsp(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function Cei(e){return e.isProperty}function s_o(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>Cei(i)?i.rawKey:r),_getParsedProperties:()=>_Zn(e),parse:(r,i)=>{let n={},a=[];for(let[u,l]of dZn(e)){let f=Cei(l)?l.rawKey:u,s=Cei(l)?l.valueSchema:l,o={rawKey:f,parsedKey:u,valueSchema:s};n[f]=o,Gsp(s)&&a.push(f)}return Hsp({value:r,requiredKeys:a,getProperty:u=>{let l=n[u];if(l!=null)return{transformedKey:l.parsedKey,transform:f=>l.valueSchema.parse(f,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of dZn(e)){let l=Cei(u)?u.valueSchema:u;Gsp(l)&&n.push(a)}return Hsp({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return Cei(u)?{transformedKey:u.rawKey,transform:l=>u.valueSchema.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:l=>u.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>PP.OBJECT};return{...k4(t),...nM(t),...U2t(t),...nSi(t)}}function Hsp({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!Tei(e))return{ok:!1,errors:[{path:a,message:$E(e,"object")}]};let u=new Set(t),l=[],f={};for(let[s,o]of Object.entries(e)){let c=r(s);if(c!=null){u.delete(s);let b=c.transform(o);b.ok?f[c.transformedKey]=b.value:(f[s]=o,l.push(...b.errors))}else switch(i){case"fail":l.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":f[s]=o;break}}return l.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),l.length===0||n?{ok:!0,value:f}:{ok:!1,errors:l}}function nSi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>$sp({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>$sp({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>PP.OBJECT};return{...r,...nM(r),...U2t(r),...nSi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>PP.OBJECT};return{...t,...nM(t),...U2t(t),...nSi(t)}}}}function $sp({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=Vsp(_Zn(t),s=>n.has(s)),l=r(pZn(t,u)),f=i(pZn(t,a));return l.ok&&f.ok?{ok:!0,value:{...l.value,...f.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...f.ok?[]:f.errors]}}function Gsp(e){return!ywS(e)}function ywS(e){switch(e.getType()){case PP.ANY:case PP.UNKNOWN:case PP.OPTIONAL:return!0;default:return!1}}function Qsp(e){return s_o(e)}function Jsp(e){let t={...CSs(e),_getRawProperties:()=>Ufn(e)._getRawProperties(),_getParsedProperties:()=>Ufn(e)._getParsedProperties()};return{...t,...nM(t),...U2t(t),...nSi(t)}}function c_o(e){let t={parse:(r,i)=>Ksp(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Ksp(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>PP.LIST};return{...k4(t),...nM(t)}}function Ksp(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:$E(e,"list"),path:[]}]}}function Ysp(e){return FH(PP.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:$E(r,`"${e}"`)}]})()}function Xsp(e){return FH(PP.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:$E(r,`${e.toString()}`)}]})()}var Zsp=FH(PP.ANY,e=>({ok:!0,value:e}));var ksp=FH(PP.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$E(e,"boolean")}]});var ecp=FH(PP.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$E(e,"number")}]});var tcp=FH(PP.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$E(e,"string")}]});var rcp=FH(PP.UNKNOWN,e=>({ok:!0,value:e}));function ncp(e,t){let r={parse:(i,n)=>icp({value:i,isKeyNumeric:e.getType()===PP.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>icp({value:i,isKeyNumeric:e.getType()===PP.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>PP.RECORD};return{...k4(r),...nM(r)}}function icp({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return Tei(e)?dZn(e).reduce((a,[u,l])=>{if(l==null)return a;let f=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),c=i(l,s);if(f.ok&&o.ok&&c.ok)return{ok:!0,value:{...f.value,[o.value]:c.value}};let b=[];return f.ok||b.push(...f.errors),o.ok||b.push(...o.errors),c.ok||b.push(...c.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:$E(e,"object")}]}}function acp(e){let t=c_o(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:$E(i,"Set")}]},getType:()=>PP.SET};return{...k4(r),...nM(r)}}function ucp(e){let t={parse:(r,i)=>ocp((n,a)=>n.parse(r,a),e,i),json:(r,i)=>ocp((n,a)=>n.json(r,a),e,i),getType:()=>PP.UNDISCRIMINATED_UNION};return{...k4(t),...nM(t)}}function ocp(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let l of u.errors)i.push({path:l.path,message:`[Variant ${n}] ${l.message}`})}return{ok:!1,errors:i}}function scp(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function lcp(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=u_o(_Zn(t)),a={parse:(u,l)=>ccp({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:f=>n.parse(f,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.parse(f,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),json:(u,l)=>ccp({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:f=>n.json(f,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.json(f,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),getType:()=>PP.UNION};return{...k4(a),...nM(a),...U2t(a)}}function ccp({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:l=[]}){if(!Tei(e))return{ok:!1,errors:[{path:l,message:$E(e,"object")}]};let{[t]:f,...s}=e;if(f==null)return{ok:!1,errors:[{path:l,message:`Missing discriminant ("${t}")`}]};let o=i(f);if(!o.ok)return{ok:!1,errors:o.errors};let c=n(o.value);if(c==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...l,t],message:"Unexpected discriminant value"}]};let b=u(s,c);return b.ok?{ok:!0,value:{[r]:f,...b.value}}:b}var aO=Ct.objectWithoutOptionalProperties({title:Ct.string().optional()});var l_o=Ct.objectWithoutOptionalProperties({file:Ct.string()});var f_o=Ct.objectWithoutOptionalProperties({file:Ct.string()});var d_o=Ct.union("type",{openapi:l_o,protobuf:f_o}).transform({transform:e=>{switch(e.type){case"openapi":return N2t.openapi(e);case"protobuf":return N2t.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var $h=Ct.objectWithoutOptionalProperties({source:d_o.optional()});var p_o=Ct.objectWithoutOptionalProperties({typeName:Ct.string()});var __o=Ct.union("type",{protobuf:p_o}).transform({transform:e=>{switch(e.type){case"protobuf":return Rfn.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Bte=Ct.objectWithoutOptionalProperties({encoding:__o.optional()});var vf=Ct.objectWithoutOptionalProperties({description:Ct.string().optional()});var h_o=Ct.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Q_=Ct.objectWithoutOptionalProperties({availability:h_o.optional()});var rQt=Ct.number();var iQt=Ct.objectWithoutOptionalProperties({statusCode:rQt.optional()});var Bb=Ct.objectWithoutOptionalProperties({nameOverride:Ct.string().optional(),generatedName:Ct.string()});var MD=Ct.objectWithoutOptionalProperties({inline:Ct.boolean().optional()});var pK=Ct.string();var _K=Ct.string();var y_o=Ct.objectWithoutOptionalProperties({id:_K}).extend(vf);var v_o=Ct.string();var b_o=Ct.objectWithoutOptionalProperties({usernameVariableName:Ct.string().optional(),usernameEnvVar:Ct.string().optional(),passwordVariableName:Ct.string().optional(),passwordEnvVar:Ct.string().optional()});var g_o=Ct.objectWithoutOptionalProperties({tokenVariableName:Ct.string().optional(),tokenEnvVar:Ct.string().optional()});var O_o=Ct.objectWithoutOptionalProperties({headerName:Ct.string(),prefix:Ct.string().optional(),headerVariableName:Ct.string().optional(),headerEnvVar:Ct.string().optional()});var m_o=Ct.objectWithoutOptionalProperties({queryParameterName:Ct.string()});var P_o=Ct.objectWithoutOptionalProperties({snake:Ct.string().optional(),camel:Ct.string().optional(),screamingSnake:Ct.string().optional(),pascal:Ct.string().optional()});var Bei=Ct.objectWithoutOptionalProperties({nameOverride:Ct.string().optional(),generatedName:Ct.string(),value:Ct.string(),casing:P_o.optional()}).extend(vf).extend(Q_);var j_o=Ct.objectWithoutOptionalProperties({type:Ct.stringLiteral("namespace"),name:Ct.string()});var w_o=Ct.undiscriminatedUnion([Ct.string(),j_o]);var xei=Ct.list(w_o);var oO=Ct.objectWithoutOptionalProperties({groupName:xei.optional()});var Vfn=Ct.objectWithoutOptionalProperties({default:Bei.optional(),values:Ct.list(Bei)}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend($h).extend(aO).extend(MD);var S_o=Ct.objectWithoutOptionalProperties({scopesEnum:Vfn.optional()});var D_o=Ct.union("type",{basic:b_o,bearer:g_o,header:O_o,query:m_o,oauth:S_o}).transform({transform:e=>{switch(e.type){case"basic":return Z4.basic(e);case"bearer":return Z4.bearer(e);case"header":return Z4.header(e);case"query":return Z4.query(e);case"oauth":return Z4.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var E_o=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),url:Ct.string(),audiences:Ct.list(Ct.string()).optional()}).extend(vf);var A_o=Ct.string();var nQt=Ct.objectWithoutOptionalProperties({namespace:Ct.string().optional()});var ISs={};Ro(ISs,{FullExample:()=>aM,FullObjectExample:()=>q_o,FullOneOfExample:()=>C_o,KeyValuePair:()=>T_o,LiteralExample:()=>M_o,PrimitiveExample:()=>Hfn,PropertyKey:()=>Wfn});var Wfn=Ct.string();var Hfn=Ct.union("type",{int:Ct.object({value:Ct.number()}),int64:Ct.object({value:Ct.number()}),uint:Ct.object({value:Ct.number()}),uint64:Ct.object({value:Ct.number()}),float:Ct.object({value:Ct.number()}),double:Ct.object({value:Ct.number()}),string:Ct.object({value:Ct.string()}),datetime:Ct.object({value:Ct.string()}),date:Ct.object({value:Ct.string()}),base64:Ct.object({value:Ct.string()}),boolean:Ct.object({value:Ct.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return Jp.int(e.value);case"int64":return Jp.int64(e.value);case"uint":return Jp.uint(e.value);case"uint64":return Jp.uint64(e.value);case"float":return Jp.float(e.value);case"double":return Jp.double(e.value);case"string":return Jp.string(e.value);case"datetime":return Jp.datetime(e.value);case"date":return Jp.date(e.value);case"base64":return Jp.base64(e.value);case"boolean":return Jp.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var M_o=Ct.union("type",{boolean:Ct.object({value:Ct.boolean()}),string:Ct.object({value:Ct.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Ffn.boolean(e.value);case"string":return Ffn.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var aM=Ct.union("type",{primitive:Ct.object({value:Hfn}),object:Ct.lazyObject(()=>q_o),array:Ct.object({value:Ct.list(Ct.lazy(()=>aM))}),map:Ct.object({value:Ct.list(Ct.lazyObject(()=>T_o))}),enum:Ct.object({value:Ct.string()}),literal:Ct.object({value:M_o}),oneOf:Ct.object({value:Ct.lazy(()=>C_o)}),unknown:Ct.object({value:Ct.lazy(()=>aM)})}).transform({transform:e=>{switch(e.type){case"primitive":return A0.primitive(e.value);case"object":return A0.object(e);case"array":return A0.array(e.value);case"map":return A0.map(e.value);case"enum":return A0.enum(e.value);case"literal":return A0.literal(e.value);case"oneOf":return A0.oneOf(e.value);case"unknown":return A0.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var q_o=Ct.objectWithoutOptionalProperties({properties:Ct.record(Wfn,Ct.lazy(()=>aM))});var T_o=Ct.objectWithoutOptionalProperties({key:Hfn,value:Ct.lazy(()=>aM)});var C_o=Ct.union("type",{discriminated:Ct.object({value:Ct.record(Wfn,Ct.lazy(()=>aM))}),undiscriminated:Ct.object({value:Ct.lazy(()=>aM)})}).transform({transform:e=>{switch(e.type){case"discriminated":return Mei.discriminated(e.value);case"undiscriminated":return Mei.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var zSs={};Ro(zSs,{AllOfPropertyConflict:()=>odn,ArraySchema:()=>vho,Availability:()=>h_o,BooleanSchema:()=>fho,CasingOverrides:()=>P_o,CommonProperty:()=>Sho,CursorPagination:()=>Z_o,CustomCodeSample:()=>Y_o,CustomCodeSampleLanguage:()=>Q_o,CustomCodeSampleSdk:()=>K_o,DiscriminatedOneOfSchema:()=>jho,DoubleSchema:()=>cho,Endpoint:()=>eho,EndpointExample:()=>tdn,EndpointResponseExample:()=>G_o,EndpointSdkName:()=>aQt,EnumSchema:()=>Vfn,EnumValue:()=>Bei,ErrorExample:()=>U_o,FernExample:()=>W_o,FileResponse:()=>Yfn,FileSchema:()=>I_o,FullEndpointExample:()=>X_o,GlobalHeader:()=>pho,Header:()=>Iei,HeaderExample:()=>edn,HttpEndpointServer:()=>Zfn,HttpError:()=>V_o,HttpMethod:()=>$fn,IdempotencyHeader:()=>_ho,IntSchema:()=>uho,JsonRequest:()=>F_o,JsonResponse:()=>Xfn,LiteralSchema:()=>adn,LiteralSchemaValue:()=>hho,LongSchema:()=>sho,MapSchema:()=>bho,MultipartRequest:()=>Kfn,MultipartRequestProperty:()=>R_o,MultipartSchema:()=>z_o,NullableSchema:()=>Oho,ObjectProperty:()=>Pho,ObjectPropertyConflictInfo:()=>udn,ObjectSchema:()=>yho,OctetStreamRequest:()=>Jfn,OffsetPagination:()=>k_o,OneOfSchema:()=>mho,OpenApiIntermediateRepresentation:()=>fcp,OptionalSchema:()=>gho,Pagination:()=>rdn,PathParameter:()=>Gfn,PathParameterExample:()=>H_o,PrimitiveSchema:()=>Rei,PrimitiveSchemaValue:()=>dho,QueryParameter:()=>Qfn,QueryParameterExample:()=>kfn,ReferencedSchema:()=>oQt,Request:()=>N_o,Response:()=>L_o,Schema:()=>uO,Schemas:()=>oho,SdkGroupInfo:()=>B_o,StreamingResponseExample:()=>$_o,StringSchema:()=>lho,SupportedSdkLanguage:()=>J_o,Tags:()=>x_o,TextResponse:()=>zei,UnDiscriminatedOneOfSchema:()=>who,Webhook:()=>tho,WebhookExampleCall:()=>ndn,WebhookHttpMethod:()=>idn,WebsocketChannel:()=>aho,WebsocketHandshake:()=>rho,WebsocketMessageExample:()=>iho,WebsocketSessionExample:()=>nho});var B_o=Ct.objectWithoutOptionalProperties({summary:Ct.string().optional(),description:Ct.string().optional()});var x_o=Ct.objectWithoutOptionalProperties({tagsById:Ct.record(_K,y_o),orderedTagIds:Ct.list(_K).optional()});var $fn=Ct.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var Gfn=Ct.objectWithoutOptionalProperties({name:Ct.string(),schema:Ct.lazy(()=>uO),variableReference:Ct.string().optional(),parameterNameOverride:Ct.string().optional()}).extend(vf).extend(Q_).extend($h);var Qfn=Ct.objectWithoutOptionalProperties({name:Ct.string(),schema:Ct.lazy(()=>uO),parameterNameOverride:Ct.string().optional()}).extend(vf).extend(Q_).extend($h);var Iei=Ct.objectWithoutOptionalProperties({name:Ct.string(),schema:Ct.lazy(()=>uO),env:Ct.string().optional(),parameterNameOverride:Ct.string().optional()}).extend(vf).extend(Q_).extend($h);var aQt=Ct.objectWithoutOptionalProperties({groupName:xei,methodName:Ct.string()});var Jfn=Ct.objectWithoutOptionalProperties({}).extend(vf).extend($h);var I_o=Ct.objectWithoutOptionalProperties({isOptional:Ct.boolean(),isArray:Ct.boolean()});var z_o=Ct.union("type",{file:I_o,json:Ct.object({value:Ct.lazy(()=>uO)})}).transform({transform:e=>{switch(e.type){case"file":return UBe.file(e);case"json":return UBe.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var R_o=Ct.objectWithoutOptionalProperties({key:Ct.string(),schema:z_o,contentType:Ct.string().optional()}).extend(vf);var Kfn=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),properties:Ct.list(R_o)}).extend(vf).extend($h);var F_o=Ct.objectWithoutOptionalProperties({schema:Ct.lazy(()=>uO),contentType:Ct.string().optional(),additionalProperties:Ct.boolean()}).extend(vf).extend($h);var N_o=Ct.union("type",{octetStream:Jfn,multipart:Kfn,json:F_o}).transform({transform:e=>{switch(e.type){case"octetStream":return qei.octetStream(e);case"multipart":return qei.multipart(e);case"json":return qei.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var Yfn=Ct.objectWithoutOptionalProperties({}).extend(vf).extend($h).extend(iQt);var Xfn=Ct.objectWithoutOptionalProperties({schema:Ct.lazy(()=>uO),responseProperty:Ct.string().optional()}).extend(vf).extend($h).extend(iQt);var zei=Ct.objectWithoutOptionalProperties({}).extend(vf).extend($h).extend(iQt);var L_o=Ct.union("type",{file:Yfn,json:Xfn,text:zei,streamingSse:Xfn,streamingText:zei,streamingJson:Xfn}).transform({transform:e=>{switch(e.type){case"file":return Cte.file(e);case"json":return Cte.json(e);case"text":return Cte.text(e);case"streamingSse":return Cte.streamingSse(e);case"streamingText":return Cte.streamingText(e);case"streamingJson":return Cte.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var U_o=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),description:Ct.string().optional(),example:Ct.lazy(()=>aM)});var V_o=Ct.objectWithoutOptionalProperties({schema:Ct.lazy(()=>uO).optional(),examples:Ct.list(U_o).optional()}).extend(vf).extend(Bb).extend($h);var Zfn=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),url:Ct.string().optional(),audiences:Ct.list(Ct.string()).optional()});var W_o=Ct.unknown();var H_o=Ct.objectWithoutOptionalProperties({name:Ct.string(),parameterNameOverride:Ct.string().optional(),value:Ct.lazy(()=>aM)});var kfn=Ct.objectWithoutOptionalProperties({name:Ct.string(),value:Ct.lazy(()=>aM)});var edn=Ct.objectWithoutOptionalProperties({name:Ct.string(),value:Ct.lazy(()=>aM)});var $_o=Ct.objectWithoutOptionalProperties({sse:Ct.boolean(),events:Ct.list(Ct.lazy(()=>aM))});var G_o=Ct.union("type",{withStreaming:$_o,withoutStreaming:Ct.object({value:Ct.lazy(()=>aM)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return LBe.withStreaming(e);case"withoutStreaming":return LBe.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Q_o=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),language:Ct.string(),code:Ct.string(),install:Ct.string().optional()}).extend(vf);var J_o=Ct.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var K_o=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),sdk:J_o,code:Ct.string()}).extend(vf);var Y_o=Ct.union("type",{language:Q_o,sdk:K_o}).transform({transform:e=>{switch(e.type){case"language":return C8r.language(e);case"sdk":return C8r.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var X_o=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),pathParameters:Ct.list(H_o).optional(),queryParameters:Ct.list(kfn).optional(),headers:Ct.list(edn).optional(),request:Ct.lazy(()=>aM).optional(),response:G_o.optional(),codeSamples:Ct.list(Y_o)}).extend(vf);var tdn=Ct.union("type",{unknown:Ct.object({value:W_o}),full:X_o}).transform({transform:e=>{switch(e.type){case"unknown":return L2t.unknown(e.value);case"full":return L2t.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var Z_o=Ct.objectWithoutOptionalProperties({cursor:Ct.string(),nextCursor:Ct.property("next_cursor",Ct.string()),results:Ct.string()});var k_o=Ct.objectWithoutOptionalProperties({offset:Ct.string(),results:Ct.string(),step:Ct.string().optional(),hasNextPage:Ct.string().optional()});var rdn=Ct.union("type",{cursor:Z_o,offset:k_o}).transform({transform:e=>{switch(e.type){case"cursor":return T8r.cursor(e);case"offset":return T8r.offset(e);default:return e}},untransform:({_visit:e,...t})=>t});var eho=Ct.objectWithoutOptionalProperties({authed:Ct.boolean(),internal:Ct.boolean().optional(),idempotent:Ct.boolean().optional(),method:$fn,audiences:Ct.list(Ct.string()),path:Ct.string(),summary:Ct.string().optional(),operationId:Ct.string().optional(),tags:Ct.list(_K),pathParameters:Ct.list(Gfn),queryParameters:Ct.list(Qfn),headers:Ct.list(Iei),sdkName:aQt.optional(),generatedRequestName:Ct.string(),requestNameOverride:Ct.string().optional(),request:N_o.optional(),response:L_o.optional(),errors:Ct.record(rQt,V_o),server:Ct.list(Zfn),examples:Ct.list(tdn),pagination:rdn.optional()}).extend(vf).extend(Q_).extend($h).extend(nQt);var idn=Ct.enum_(["GET","POST"]);var ndn=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),payload:Ct.lazy(()=>aM)}).extend(vf);var tho=Ct.objectWithoutOptionalProperties({sdkName:aQt.optional(),method:idn,summary:Ct.string().optional(),operationId:Ct.string(),tags:Ct.list(_K),headers:Ct.list(Iei),generatedPayloadName:Ct.string(),payload:Ct.lazy(()=>uO),examples:Ct.list(ndn)}).extend(vf).extend($h).extend(nQt);var rho=Ct.objectWithoutOptionalProperties({queryParameters:Ct.list(Qfn),headers:Ct.list(Iei),pathParameters:Ct.list(Gfn)});var iho=Ct.objectWithoutOptionalProperties({messageType:Ct.string(),payload:Ct.lazy(()=>aM)}).extend(vf);var nho=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),queryParameters:Ct.list(kfn).optional(),headers:Ct.list(edn).optional(),messages:Ct.list(iho)}).extend(vf);var aho=Ct.objectWithoutOptionalProperties({audiences:Ct.list(Ct.string()),path:Ct.string(),groupName:xei,summary:Ct.string().optional(),handshake:rho,publish:Ct.lazy(()=>uO).optional(),subscribe:Ct.lazy(()=>uO).optional(),examples:Ct.list(nho)}).extend(vf).extend($h);var oho=Ct.objectWithoutOptionalProperties({rootSchemas:Ct.record(pK,Ct.lazy(()=>uO)),namespacedSchemas:Ct.record(A_o,Ct.record(pK,Ct.lazy(()=>uO)))});var uho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),minimum:Ct.number().optional(),maximum:Ct.number().optional(),exclusiveMinimum:Ct.boolean().optional(),exclusiveMaximum:Ct.boolean().optional(),multipleOf:Ct.number().optional()});var sho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional()});var cho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),minimum:Ct.number().optional(),maximum:Ct.number().optional(),exclusiveMinimum:Ct.boolean().optional(),exclusiveMaximum:Ct.boolean().optional(),multipleOf:Ct.number().optional()});var lho=Ct.objectWithoutOptionalProperties({default:Ct.string().optional(),pattern:Ct.string().optional(),format:Ct.string().optional(),minLength:Ct.number().optional(),maxLength:Ct.number().optional()});var fho=Ct.objectWithoutOptionalProperties({default:Ct.boolean().optional()});var dho=Ct.union("type",{int:uho,int64:sho,uint:Ct.object({}),uint64:Ct.object({}),float:Ct.object({}),double:cho,string:lho,datetime:Ct.object({}),date:Ct.object({}),base64:Ct.object({}),boolean:fho}).transform({transform:e=>{switch(e.type){case"int":return WP.int(e);case"int64":return WP.int64(e);case"uint":return WP.uint();case"uint64":return WP.uint64();case"float":return WP.float();case"double":return WP.double(e);case"string":return WP.string(e);case"datetime":return WP.datetime();case"date":return WP.date();case"base64":return WP.base64();case"boolean":return WP.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var Rei=Ct.objectWithoutOptionalProperties({schema:dho}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(aO);var pho=Ct.objectWithoutOptionalProperties({header:Ct.string(),name:Ct.string().optional(),optional:Ct.boolean().optional(),env:Ct.string().optional(),schema:Ct.lazy(()=>uO).optional()});var _ho=Ct.objectWithoutOptionalProperties({header:Ct.string(),name:Ct.string().optional(),env:Ct.string().optional(),schema:Ct.lazy(()=>uO).optional()});var fcp=Ct.objectWithoutOptionalProperties({apiVersion:Ct.unknown().optional(),title:Ct.string().optional(),description:Ct.string().optional(),basePath:Ct.string().optional(),servers:Ct.list(E_o),groups:Ct.record(Ct.string(),B_o),tags:x_o,hasEndpointsMarkedInternal:Ct.boolean(),endpoints:Ct.list(eho),webhooks:Ct.list(tho),channel:Ct.list(aho),groupedSchemas:oho,variables:Ct.record(Ct.string(),Rei),nonRequestReferencedSchemas:Ct.set(pK),securitySchemes:Ct.record(v_o,D_o),globalHeaders:Ct.list(pho).optional(),idempotencyHeaders:Ct.list(_ho).optional()});var oQt=Ct.objectWithoutOptionalProperties({schema:pK}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend($h).extend(aO);var hho=Ct.union("type",{boolean:Ct.object({value:Ct.boolean()}),string:Ct.object({value:Ct.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return bB.boolean(e.value);case"string":return bB.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var adn=Ct.objectWithoutOptionalProperties({value:hho}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(aO);var uO=Ct.union("type",{primitive:Rei,object:Ct.lazyObject(()=>yho),array:Ct.lazyObject(()=>vho),map:Ct.lazyObject(()=>bho),optional:Ct.lazyObject(()=>gho),enum:Vfn,reference:oQt,literal:adn,oneOf:Ct.object({value:Ct.lazy(()=>mho)}),nullable:Ct.lazyObject(()=>Oho),unknown:Bb}).transform({transform:e=>{switch(e.type){case"primitive":return ey.primitive(e);case"object":return ey.object(e);case"array":return ey.array(e);case"map":return ey.map(e);case"optional":return ey.optional(e);case"enum":return ey.enum(e);case"reference":return ey.reference(e);case"literal":return ey.literal(e);case"oneOf":return ey.oneOf(e.value);case"nullable":return ey.nullable(e);case"unknown":return ey.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var odn=Ct.objectWithoutOptionalProperties({propertyKey:Ct.string(),allOfSchemaIds:Ct.list(pK),conflictingTypeSignatures:Ct.boolean()});var yho=Ct.objectWithoutOptionalProperties({allOf:Ct.list(oQt),properties:Ct.list(Ct.lazyObject(()=>Pho)),allOfPropertyConflicts:Ct.list(odn),additionalProperties:Ct.boolean()}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend($h).extend(aO).extend(MD);var udn=Ct.objectWithoutOptionalProperties({differentSchema:Ct.boolean()});var Pho=Ct.objectWithoutOptionalProperties({key:Ct.string(),schema:Ct.lazy(()=>uO),readonly:Ct.boolean().optional(),conflict:Ct.record(pK,udn),generatedName:Ct.string(),nameOverride:Ct.string().optional(),audiences:Ct.list(Ct.string())}).extend(Q_);var vho=Ct.objectWithoutOptionalProperties({value:Ct.lazy(()=>uO)}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(aO).extend(MD);var bho=Ct.objectWithoutOptionalProperties({key:Rei,value:Ct.lazy(()=>uO)}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(Bte).extend(aO).extend(MD);var gho=Ct.objectWithoutOptionalProperties({value:Ct.lazy(()=>uO)}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(aO).extend(MD);var Oho=Ct.objectWithoutOptionalProperties({value:Ct.lazy(()=>uO)}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(aO).extend(MD);var mho=Ct.union("type",{discriminated:Ct.lazyObject(()=>jho),undiscriminated:Ct.lazyObject(()=>who)}).transform({transform:e=>{switch(e.type){case"discriminated":return B8r.discriminated(e);case"undiscriminated":return B8r.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var jho=Ct.objectWithoutOptionalProperties({discriminantProperty:Ct.string(),commonProperties:Ct.list(Ct.lazyObject(()=>Sho)),schemas:Ct.record(Ct.string(),Ct.lazy(()=>uO))}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(Bte).extend($h).extend(aO).extend(MD);var Sho=Ct.objectWithoutOptionalProperties({key:Ct.string(),schema:Ct.lazy(()=>uO)});var who=Ct.objectWithoutOptionalProperties({schemas:Ct.list(Ct.lazy(()=>uO))}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(Bte).extend($h).extend(aO).extend(MD);var RSs={};Ro(RSs,{ArraySchemaWithExample:()=>$ho,Base64WithExample:()=>Lho,BooleanWithExample:()=>Uho,CommonPropertyWithExample:()=>eyo,DateWithExample:()=>Nho,DatetimeWithExample:()=>Fho,DiscriminatedOneOfSchemaWithExample:()=>Zho,DoubleWithExample:()=>zho,EndpointWithExample:()=>pcp,EnumSchemaWithExample:()=>Who,FloatWithExample:()=>Iho,HeaderWithExample:()=>Fei,HttpErrorWithExample:()=>qho,Int64WithExample:()=>Cho,IntWithExample:()=>Tho,JsonRequestWithExample:()=>Eho,JsonResponseWithExample:()=>cdn,MapSchemaWithExample:()=>Gho,NamedFullExample:()=>uQt,NullableSchemaWithExample:()=>Jho,ObjectPropertyWithExample:()=>Xho,ObjectSchemaWithExample:()=>Kho,OneOfSchemaWithExample:()=>Yho,OptionalSchemaWithExample:()=>Qho,PathParameterWithExample:()=>Dho,PrimitiveSchemaValueWithExample:()=>Vho,PrimitiveSchemaWithExample:()=>ldn,QueryParameterWithExample:()=>sdn,RequestWithExample:()=>Aho,ResponseWithExample:()=>Mho,SchemaWithExample:()=>GE,StringSchemaWithExample:()=>Rho,Uint64WithExample:()=>xho,UintWithExample:()=>Bho,UnDiscriminatedOneOfSchemaWithExample:()=>kho,UnknownSchemaWithExample:()=>Hho,WebhookWithExample:()=>_cp,WebsocketHandshakeWithExample:()=>dcp});var uQt=Ct.objectWithoutOptionalProperties({name:Ct.string().optional(),value:Ct.unknown()}).extend(vf);var sdn=Ct.objectWithoutOptionalProperties({name:Ct.string(),schema:Ct.lazy(()=>GE),parameterNameOverride:Ct.string().optional()}).extend(vf).extend(Q_).extend($h);var Fei=Ct.objectWithoutOptionalProperties({name:Ct.string(),schema:Ct.lazy(()=>GE),env:Ct.string().optional(),parameterNameOverride:Ct.string().optional()}).extend(vf).extend(Q_).extend($h);var dcp=Ct.objectWithoutOptionalProperties({queryParameters:Ct.list(sdn),headers:Ct.list(Fei)});var Dho=Ct.objectWithoutOptionalProperties({name:Ct.string(),schema:Ct.lazy(()=>GE),variableReference:Ct.string().optional(),parameterNameOverride:Ct.string().optional()}).extend(vf).extend(Q_).extend($h);var Eho=Ct.objectWithoutOptionalProperties({schema:Ct.lazy(()=>GE),contentType:Ct.string().optional(),fullExamples:Ct.list(uQt).optional(),additionalProperties:Ct.boolean()}).extend(vf).extend($h);var Aho=Ct.union("type",{octetStream:Jfn,multipart:Kfn,json:Eho}).transform({transform:e=>{switch(e.type){case"octetStream":return Iwe.octetStream(e);case"multipart":return Iwe.multipart(e);case"json":return Iwe.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var cdn=Ct.objectWithoutOptionalProperties({schema:Ct.lazy(()=>GE),responseProperty:Ct.string().optional(),fullExamples:Ct.list(uQt).optional()}).extend(vf).extend($h).extend(iQt);var Mho=Ct.union("type",{file:Yfn,json:cdn,text:zei,streamingSse:cdn,streamingText:zei,streamingJson:cdn}).transform({transform:e=>{switch(e.type){case"file":return gB.file(e);case"json":return gB.json(e);case"text":return gB.text(e);case"streamingSse":return gB.streamingSse(e);case"streamingText":return gB.streamingText(e);case"streamingJson":return gB.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var qho=Ct.objectWithoutOptionalProperties({statusCode:rQt,schema:Ct.lazy(()=>GE),fullExamples:Ct.list(uQt).optional()}).extend(vf).extend(Bb).extend($h);var pcp=Ct.objectWithoutOptionalProperties({authed:Ct.boolean(),internal:Ct.boolean().optional(),idempotent:Ct.boolean().optional(),method:$fn,audiences:Ct.list(Ct.string()),path:Ct.string(),summary:Ct.string().optional(),operationId:Ct.string().optional(),tags:Ct.list(_K),pathParameters:Ct.list(Dho),queryParameters:Ct.list(sdn),headers:Ct.list(Fei),sdkName:aQt.optional(),generatedRequestName:Ct.string(),requestNameOverride:Ct.string().optional(),request:Aho.optional(),response:Mho.optional(),errors:Ct.record(rQt,qho),server:Ct.list(Zfn),examples:Ct.list(tdn),pagination:rdn.optional()}).extend(vf).extend(Q_).extend($h).extend(nQt);var _cp=Ct.objectWithoutOptionalProperties({sdkName:aQt.optional(),method:idn,summary:Ct.string().optional(),operationId:Ct.string(),tags:Ct.list(_K),headers:Ct.list(Fei),generatedPayloadName:Ct.string(),payload:Ct.lazy(()=>GE),examples:Ct.list(ndn)}).extend(vf).extend($h).extend(nQt);var Tho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),minimum:Ct.number().optional(),maximum:Ct.number().optional(),exclusiveMinimum:Ct.boolean().optional(),exclusiveMaximum:Ct.boolean().optional(),multipleOf:Ct.number().optional(),example:Ct.number().optional()});var Cho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),example:Ct.number().optional()});var Bho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),example:Ct.number().optional()});var xho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),example:Ct.number().optional()});var Iho=Ct.objectWithoutOptionalProperties({example:Ct.number().optional()});var zho=Ct.objectWithoutOptionalProperties({default:Ct.number().optional(),minimum:Ct.number().optional(),maximum:Ct.number().optional(),exclusiveMinimum:Ct.boolean().optional(),exclusiveMaximum:Ct.boolean().optional(),multipleOf:Ct.number().optional(),example:Ct.number().optional()});var Rho=Ct.objectWithoutOptionalProperties({default:Ct.string().optional(),pattern:Ct.string().optional(),format:Ct.string().optional(),minLength:Ct.number().optional(),maxLength:Ct.number().optional(),example:Ct.string().optional()});var Fho=Ct.objectWithoutOptionalProperties({example:Ct.string().optional()});var Nho=Ct.objectWithoutOptionalProperties({example:Ct.string().optional()});var Lho=Ct.objectWithoutOptionalProperties({example:Ct.string().optional()});var Uho=Ct.objectWithoutOptionalProperties({default:Ct.boolean().optional(),example:Ct.boolean().optional()});var Vho=Ct.union("type",{int:Tho,int64:Cho,uint:Bho,uint64:xho,float:Iho,double:zho,string:Rho,datetime:Fho,date:Nho,base64:Lho,boolean:Uho}).transform({transform:e=>{switch(e.type){case"int":return Xd.int(e);case"int64":return Xd.int64(e);case"uint":return Xd.uint(e);case"uint64":return Xd.uint64(e);case"float":return Xd.float(e);case"double":return Xd.double(e);case"string":return Xd.string(e);case"datetime":return Xd.datetime(e);case"date":return Xd.date(e);case"base64":return Xd.base64(e);case"boolean":return Xd.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var ldn=Ct.objectWithoutOptionalProperties({schema:Vho}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(aO);var Who=Ct.objectWithoutOptionalProperties({default:Bei.optional(),values:Ct.list(Bei),example:Ct.string().optional()}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend($h).extend(aO).extend(MD);var Hho=Ct.objectWithoutOptionalProperties({example:Ct.unknown()}).extend(oO).extend(Bb).extend(vf).extend(Q_).extend(aO);var GE=Ct.union("type",{primitive:ldn,object:Ct.lazyObject(()=>Kho),array:Ct.lazyObject(()=>$ho),map:Ct.lazyObject(()=>Gho),optional:Ct.lazyObject(()=>Qho),enum:Who,reference:oQt,literal:adn,oneOf:Ct.object({value:Ct.lazy(()=>Yho)}),nullable:Ct.lazyObject(()=>Jho),unknown:Hho}).transform({transform:e=>{switch(e.type){case"primitive":return Fl.primitive(e);case"object":return Fl.object(e);case"array":return Fl.array(e);case"map":return Fl.map(e);case"optional":return Fl.optional(e);case"enum":return Fl.enum(e);case"reference":return Fl.reference(e);case"literal":return Fl.literal(e);case"oneOf":return Fl.oneOf(e.value);case"nullable":return Fl.nullable(e);case"unknown":return Fl.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var $ho=Ct.objectWithoutOptionalProperties({value:Ct.lazy(()=>GE),example:Ct.list(Ct.unknown()).optional()}).extend(oO).extend(Bb).extend(vf).extend(Q_).extend(aO).extend(MD);var Gho=Ct.objectWithoutOptionalProperties({key:ldn,value:Ct.lazy(()=>GE),example:Ct.unknown().optional()}).extend(oO).extend(Bb).extend(vf).extend(Q_).extend(Bte).extend(aO).extend(MD);var Qho=Ct.objectWithoutOptionalProperties({value:Ct.lazy(()=>GE)}).extend(oO).extend(Bb).extend(vf).extend(Q_).extend(aO).extend(MD);var Jho=Ct.objectWithoutOptionalProperties({value:Ct.lazy(()=>GE)}).extend(oO).extend(Bb).extend(vf).extend(Q_).extend(aO).extend(MD);var Kho=Ct.objectWithoutOptionalProperties({allOf:Ct.list(oQt),properties:Ct.list(Ct.lazyObject(()=>Xho)),allOfPropertyConflicts:Ct.list(odn),fullExamples:Ct.list(uQt).optional(),additionalProperties:Ct.boolean()}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend($h).extend(aO).extend(MD);var Xho=Ct.objectWithoutOptionalProperties({key:Ct.string(),schema:Ct.lazy(()=>GE),readonly:Ct.boolean().optional(),audiences:Ct.list(Ct.string()),conflict:Ct.record(pK,udn),nameOverride:Ct.string().optional(),generatedName:Ct.string()}).extend(Q_);var Yho=Ct.union("type",{discriminated:Ct.lazyObject(()=>Zho),undiscriminated:Ct.lazyObject(()=>kho)}).transform({transform:e=>{switch(e.type){case"discriminated":return dK.discriminated(e);case"undiscriminated":return dK.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Zho=Ct.objectWithoutOptionalProperties({discriminantProperty:Ct.string(),commonProperties:Ct.list(Ct.lazyObject(()=>eyo)),schemas:Ct.record(Ct.string(),Ct.lazy(()=>GE))}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(Bte).extend($h).extend(aO).extend(MD);var eyo=Ct.objectWithoutOptionalProperties({key:Ct.string(),schema:Ct.lazy(()=>GE)});var kho=Ct.objectWithoutOptionalProperties({schemas:Ct.list(Ct.lazy(()=>GE))}).extend(vf).extend(Bb).extend(oO).extend(Q_).extend(Bte).extend($h).extend(aO).extend(MD);var hcp=/^(\d+)/,fdn=/^[a-zA-Z][a-zA-Z0-9_]*$/,ycp={"<":"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 Nei(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),l=e%10;return l===0?i[u]:`${i[u]}_${t[l]}`}if(e<1e3){let u=Math.floor(e/100),l=e%100;return l===0?`${t[u]}_hundred`:`${t[u]}_hundred_${Nei(l)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${Nei(a)}`}function hZn(e){let t=e.match(hcp);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=Nei(n);return i.length>0?`${a}_${i}`:a}}}function ddn(e){let t=hZn(e),r=ycp[e];return t!=null?G9(pg(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":G9(pg(e)))}function xte(e,t){return e.type==="primitive"&&t.type==="primitive"?vcp(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?vwS(e.values,t.values):e.type==="array"&&t.type==="array"?xte(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"?xte(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?bwS(e.value,t.value):e.type==="object"&&t.type==="object"?gwS(e,t):e.type==="map"&&t.type==="map"?vcp(e.key.schema,t.key.schema)&&xte(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function vcp(e,t){return e.type===t.type}function vwS(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return N3t(r,i)}function bwS(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,i])=>{let n=t.schemas[r];return n==null?!1:xte(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:xte(r,n)}):!1}function gwS(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:xte(a,n.schema)})}var c2;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(c2||(c2={}));var tyo=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=u,this.globalHeaderOverrides=a,this.detectGlobalHeaders=i?.detectGlobalHeaders??!0,this.objectQueryParameters=i?.objectQueryParameters??!1,this.respectReadonlySchemas=i?.respectReadonlySchemas??!1,this.respectNullableSchemas=i?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=i?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=i?.inlinePathParameters??!1,this.referencedSchemaIds=i?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=i?.enableUniqueErrorsPerEndpoint??!1,this.builder=new iSi(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let l={};if(!this.enableUniqueErrorsPerEndpoint)for(let f of r.endpoints)for(let[s,o]of Object.entries(f.errors)){let c=parseInt(s),b=l[c];b==null&&o.schema!=null?l[c]=o.schema:b!=null&&o.schema!=null&&xte(b,o.schema)||this.unknownSchema.add(c)}}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(c2.Channel,c2.Endpoint,c2.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:Zo(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:Zo(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function gx(e){switch(e){case GL.Deprecated:return"deprecated";case GL.Beta:return"pre-release";case GL.GenerallyAvailable:return"generally-available";default:return}}function OwS(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function bcp(e){let t=e?OwS(e):void 0;if(t==null||t.length===0)return FOi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(pg(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(pg(n.name)):r.push(n.name,FOi);break}default:Zo(n.type)}else Zo(n);return r.join("/")}function pdn(e){return Wh.of(`${bcp(e)}.yml`)}function FSs({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?FOi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,bcp(r))}function gcp({sdkName:e,namespaceOverride:t}){return Wh.of(`${FSs({sdkName:e,namespaceOverride:t})}.yml`)}function Ocp({location:e,namespaceOverride:t}){return t!=null?Dz(Wh.of(t),e):e}function ryo(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Zo(e.type)}}function _dn(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:Zo(e)}}function QE(e){return typeof e=="string"?e:e.type}function hdn(e){if(typeof e!="string")return e.docs}function yZn(e){if(typeof e!="string")return e.default}function NSs(e){if(typeof e!="string")return e.validation}var mwS=-2147483648,PwS=2147483647,jwS=-17976931348623157e292,wwS=17976931348623157e292;function h0({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return iyo(e);case"array":return VSs({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return WSs({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return USs({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return $Ss();case"optional":return nyo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return HSs({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return BwS({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,GSs(e);case"object":return xwS({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return IwS({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:Zo(e)}}function iyo(e){switch(e.schema.type){case"string":return EwS({description:e.description,schema:e.schema});case"int":return AwS({description:e.description,schema:e.schema});case"float":return MwS({description:e.description,schema:e.schema});case"double":return qwS({description:e.description,schema:e.schema});case"boolean":return SwS({description:e.description,schema:e.schema});case"int64":return DwS({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:gx(e.availability)}:{}}}function SwS({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function DwS({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function EwS({description:e,schema:t}){let r="string",i=TwS(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function AwS({description:e,schema:t}){let r="integer",i=Pcp(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function MwS({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function qwS({description:e,schema:t}){let r="double",i=Pcp(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function TwS(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=CwS(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function CwS(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 Pcp(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=LSs(r,t),i=LSs(i,t),n=LSs(n,t),!(r==null&&i==null&&a==null&&u==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:u,multipleOf:n}}function LSs(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[mwS,PwS]:[jwS,wwS];return e<r||e>i?void 0:e}function USs({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=zwS(n)??e.schema,u=_dn(n),l=RwS(n),f=ayo({context:r,fileContainingReference:t,declarationFile:pdn(u),type:a}),s=n.type==="nullable"?`optional<${f}>`:f;return e.description==null&&l==null?s:{type:n.type==="nullable"?`optional<${f}>`:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gx(e.availability)}:{}}}function VSs({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=h0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=`list<${QE(u)}>`;return e.description==null&&e.title==null?l:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gx(e.availability)}:{},type:l}}function WSs({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=iyo(e.key),l=h0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),f=e.encoding!=null?ryo(e.encoding):void 0,s=`map<${QE(u)}, ${QE(l)}>`;if(e.description==null&&f==null&&e.title==null)return s;let o={type:s};return e.description!=null&&(o.docs=e.description),e.encoding!=null&&(o.encoding=f),e.availability!=null&&(o.availability=gx(e.availability)),o}function HSs({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.respectNullableSchemas)return nyo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let u=h0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=QE(u),f=hdn(u),s=yZn(u),o=NSs(u),c=l.startsWith("nullable<")?l:`nullable<${l}>`;if(e.availability==null&&e.description==null&&f==null&&s==null&&o==null&&e.title==null)return mcp({typeReference:c,itemType:l});let b={type:c};return(e.description!=null||f!=null)&&(b.docs=e.description??f),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=gx(e.availability)),mcp({typeReference:b,itemType:l})}function nyo({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=h0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=QE(u),f=hdn(u),s=yZn(u),o=NSs(u),c=l.startsWith("optional<")?l:`optional<${l}>`;if(e.availability==null&&e.description==null&&f==null&&s==null&&o==null&&e.title==null)return c;let b={type:c};return(e.description!=null||f!=null)&&(b.docs=e.description??f),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=gx(e.availability)),b}function $Ss(){return"unknown"}function GSs(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Zo(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gx(e.availability)}:{}}}function BwS({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=vZn(e,n),u=e.nameOverride??e.generatedName;i.builder.addType(r,{name:u,schema:a.schema});let l=ayo({type:u,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return l;let f={type:l};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.availability!=null&&(f.availability=gx(e.availability)),f}function xwS({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=QSs({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=e.nameOverride??e.generatedName;i.builder.addType(r,{name:l,schema:u.schema});let f=ayo({type:l,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?f:{type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:gx(e.availability)}:{}}}function IwS({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=JSs({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=e.nameOverride??e.generatedName;i.builder.addType(r,{name:l,schema:u.schema});let f=ayo({type:l,fileContainingReference:t,declarationFile:r,context:i});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:gx(e.availability)}:{}}}function ayo({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function zwS(e){return ey._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 RwS(e){return ey._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 mcp({typeReference:e,itemType:t}){return t.startsWith("optional<")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}function x8r(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Zo(e)}}function wcp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=LwS(e);break;case"array":a=FwS({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=NwS({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=UwS({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=WwS(e.nameOverride,e.generatedName);break;case"optional":a=Scp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=VwS({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=vZn(e,n);break;case"literal":a=HwS(e,e.nameOverride,e.generatedName);break;case"object":a=QSs({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=JSs({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:Zo(e)}return a}function QSs({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(c2.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),u=!1,l={},f=new Set;for(let g of e.properties){if(g.readonly&&(u=!0),a&&g.readonly)continue;if(Object.keys(g.conflict).length>0){if(Object.entries(g.conflict).every(([q,D])=>!D.differentSchema))continue;Object.entries(g.conflict).forEach(([q])=>{KSs({property:g.key,schemaId:q,context:t,namespace:i}).forEach(C=>{f.add(C)})})}let O=h0({schema:g.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),m=g.audiences,w=g.nameOverride,A=gx(g.availability);l[g.key]=QwS({typeReference:O,audiences:m,name:w,availability:A})}let s=new Set;for(let g of e.allOfPropertyConflicts)g.allOfSchemaIds.forEach(O=>f.add(O)),g.conflictingTypeSignatures&&s.add(g.propertyKey);let o=[];for(let g of e.allOf){let O=Dcp({schema:g.schema,context:t,namespace:i});if(O==null||f.has(g.schema)||f.has(O))continue;let m=h0({schema:ey.reference(g),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(QE(m))}for(let g of f){let O=YSs(t,g,i);for(let m of O.properties)l[m.key]==null&&(s.has(m.key)&&(l[m.key]="unknown"),l[m.key]=h0({schema:m.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let m of O.allOf){if(f.has(m.schema))continue;let w=h0({schema:ey.reference(m),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(QE(w))}}let c={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(l).map(([g,O])=>GwS(g)?[g,typeof O=="string"?{type:O,name:`_${g}`}:{...O,name:`_${g}`}]:[g,O]))};o.length>0&&(c.extends=o),e.additionalProperties&&(c["extra-properties"]=!0),e.availability!=null&&(c.availability=gx(e.availability)),e.source!=null&&(c.source=x8r(e.source)),c.inline=XSs(e,n);let b=e.nameOverride??e.generatedName;return{name:u&&t.respectReadonlySchemas&&!a?`${b}Read`:b,schema:c}}function KSs({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return KSs({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:u}=YSs(r,t,i),l=a.some(s=>s.key===e),f=[...u.flatMap(s=>KSs({property:e,context:r,schemaId:s.schema,namespace:i}))];if(l||f.length>0)return[t,...f]}return[]}function YSs(e,t,r){let i=e.getSchema(t,r);if(i==null)return{properties:[],allOf:[]};if(i.type==="object")return{properties:i.properties,allOf:i.allOf};if(i.type==="reference")return YSs(e,i.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${i.type}`)}function FwS({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:VSs({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function NwS({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:WSs({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function LwS(e){let t=iyo(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function jcp(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function vZn(e,t){let r={enum:e.values.map(a=>{let u=a.nameOverride??a.generatedName,l=a.value;if(u===l&&a.description==null&&(a.casing==null||jcp(a.casing)))return u;let f={value:a.value};if(u!==l&&(f.name=u),a.description!=null&&(f.docs=a.description),a.casing!=null&&!jcp(a.casing)){let s={},o=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,o=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,o=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,o=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,o=!0),o&&(f.casing=s)}return f})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=XSs(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?x8r(e.source):void 0};for(let a of r.enum){let u=typeof a=="string"?a:a.name??a.value;i.has(u.toLowerCase())||(n.enum.push(a),i.add(u.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function UwS({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:USs({schema:e,context:t,fileContainingReference:r,namespace:i})}}function VwS({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:HSs({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:Scp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function Scp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:nyo({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function WwS(e,t){return{name:e??t,schema:$Ss()}}function HwS(e,t,r){return{name:t??r,schema:GSs(e)}}function JSs({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?ryo(e.encoding):void 0;if(e.type==="discriminated"){let l={};for(let s of e.commonProperties)l[s.key]=h0({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let f={};for(let[s,o]of Object.entries(e.schemas))f[s]=h0({schema:o,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":l,docs:e.description??void 0,availability:e.availability!=null?gx(e.availability):void 0,union:f,encoding:a,source:e.source!=null?x8r(e.source):void 0}}}let u=[];for(let l of e.schemas)u.push(h0({schema:l,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:u,encoding:a,source:e.source!=null?x8r(e.source):void 0,inline:XSs(e,n)}}}var $wS=/^[0-9]/;function GwS(e){return $wS.test(e)}function Dcp({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?Dcp({context:t,schema:i.schema,namespace:r}):e}function QwS({typeReference:e,audiences:t,name:r,availability:i}){return t.length===0&&r==null&&i==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{}}}function XSs(e,t){return e.inline===!0||t>0?!0:void 0}function Ecp(e){let t=e.replace(/^x-|^X-/,"");return pg(t)}var Acp="BasicAuthScheme",oyo="BearerAuthScheme";function Mcp(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:Acp,schema:n}),t||(e.builder.setAuth(Acp),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:oyo,schema:n}),t||(e.builder.setAuth(oyo),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??Ecp(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:oyo,schema:n}),t||(e.builder.setAuth(oyo),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(Wh.of("__package__.yml"),{name:"OauthScope",schema:vZn(i.scopesEnum,0).schema})}}function sQt({header:e,context:t,fileContainingReference:r,namespace:i}){let n=h0({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=QE(n),u=e.name.replace(/^x-|^X-/,""),l=e.parameterNameOverride!=null?e.parameterNameOverride:pg(u);if(e.description==null&&e.name===l&&e.env==null&&e.availability==null)return a;let f={type:a};return l!==e.name&&(f.name=l),e.description!=null&&(f.docs=e.description),e.env!=null&&(f.env=e.env),e.availability!=null&&(f.availability=gx(e.availability)),f}function uyo({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=h0({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return QE(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:QE(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=gx(e.availability)),a}function cyo({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=ZSs({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=QE(n.value),u=yZn(n.value);if(a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>"),e.description==null&&!n.allowMultiple&&e.parameterNameOverride==null&&e.availability==null)return a;let l={type:a};return u!=null&&(l.default=u),n.allowMultiple&&(l["allow-multiple"]=!0),e.description!=null&&(l.docs=e.description),e.parameterNameOverride!=null&&(l.name=e.parameterNameOverride),e.availability!=null&&(l.availability=gx(e.availability)),JwS(n.value)&&n.value.validation!==void 0&&(l.validation=n.value.validation),l}function ZSs({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,groupName:void 0,inline:void 0}),context:t,declarationFile:Wh.of(P1),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[];for(let[u,l]of Object.entries(n.value.schemas))l.type==="literal"&&l.value.type==="string"&&(fdn.test(l.value.value)?a.push(l.value.value):a.push({value:l.value.value,name:ddn(l.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[u,l]=n.value.schemas;if(u!=null&&l!=null&&syo({array:u,primitive:l}))return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:l,description:e.description,availability:e.availability,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(u!=null&&l!=null&&syo({array:u,primitive:l}))return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[u,l]of Object.entries(n.value.schemas))return ZSs({schema:l,context:t,fileContainingReference:r,namespace:i})}else if(t.objectQueryParameters)return{value:h0({schema:e,context:t,fileContainingReference:r,declarationFile:Wh.of(P1),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let n=t.getSchema(e.value.schema,i);if(n==null)return;if(n.type==="array")return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:Wh.of(P1),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:h0({schema:e,context:t,fileContainingReference:r,declarationFile:Wh.of(P1),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let n=[];for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="literal"&&u.value.type==="string"&&(fdn.test(u.value.value)?n.push(u.value.value):n.push({value:u.value.value,name:ddn(u.value.value)}));if(n.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:n}}),{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&&syo({array:a,primitive:u}))return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(a!=null&&u!=null&&syo({array:u,primitive:a}))return{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[a,u]of Object.entries(e.value.value.schemas))return ZSs({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.objectQueryParameters?{value:h0({schema:e,context:t,fileContainingReference:r,declarationFile:Wh.of(P1),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:h0({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:h0({schema:ey.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:h0({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function syo({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function JwS(e){return e.type!=null}function qcp({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"]=KwS(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=YwS({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=Lei(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function KwS(e){let t={};return e.forEach(r=>{let i=Lei(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function YwS({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=Lei(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function Lei(e){switch(e.type){case"primitive":return Tcp(e.value);case"object":return Ccp(e.properties);case"array":return XwS(e.value);case"map":return ZwS(e.value);case"oneOf":return kwS(e.value);case"enum":return e.value;case"literal":return e1S(e.value);case"unknown":return Lei(e.value);default:Zo(e)}}function Tcp(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:Zo(e)}}function Ccp(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Lei(r)]))}function XwS(e){return e.map(t=>Lei(t))}function ZwS(e){return Object.fromEntries(e.map(t=>[Tcp(t.key),Lei(t.value)]))}function kwS(e){return e.type==="discriminated"?Ccp(e.value):Lei(e.value)}function e1S(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Zo(e)}}function I8r(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function lyo(e,t){return t??(e?.groupName!=null?I8r(e.groupName):void 0)}function Bcp({channel:e,context:t,declarationFile:r}){let i={path:e.path,auth:!1};e.audiences!=null&&e.audiences.length>0&&(i.audiences=e.audiences),e.summary!=null&&(i["display-name"]=e.summary);let n=I8r(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let f of e.handshake.pathParameters)a[f.name]=uyo({pathParameter:f,context:t,fileContainingReference:r,namespace:n});Object.keys(a).length>0&&(i["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let f of e.handshake.queryParameters){let s=cyo({queryParameter:f,context:t,fileContainingReference:r,namespace:n});s!=null&&(u[f.name]=s)}Object.keys(u).length>0&&(i["query-parameters"]=u);let l={};if(e.handshake.headers.length>0)for(let f of e.handshake.headers){let s=sQt({header:f,context:t,fileContainingReference:r,namespace:n});l[f.name]=s}Object.keys(l).length>0&&(i.headers=l),t.builder.addChannel(r,{channel:i}),e.subscribe!=null&&t.builder.addChannelMessage(r,{messageId:"subscribe",message:{origin:"server",body:h0({schema:e.subscribe,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}}),e.publish!=null&&t.builder.addChannelMessage(r,{messageId:"publish",message:{origin:"client",body:h0({schema:e.publish,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}});for(let f of e.examples){let s=qcp({context:t,websocketExample:f});t.builder.addChannelExample(r,{example:s})}}var xcp="Production",Icp="Default";function zcp(e){return Object.entries(e).reduce((t,[r,i])=>(hnn(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function Rcp(e){if(e.environmentOverrides!=null){for(let[l,f]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:l,schema:f});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 l of e.ir.servers){let f=l.audiences?{url:l.url,audiences:l.audiences}:l.url;if(l.name==null){r.push(f);continue}t[l.name]=f}let i={},n=[];for(let l of e.ir.endpoints)for(let f of l.server){if(f.url==null)continue;let s=f.audiences?{url:f.url,audiences:f.audiences}:f.url;if(f.name==null){n.push(s);continue}i[f.name]=s}let a=Object.keys(t).length,u=Object.keys(i).length;if(a===0&&u===0){let l=e.ir.servers[0]?.url,f=e.ir.servers[0]?.audiences;l!=null&&(e.builder.addEnvironment({name:Icp,schema:f?{url:l,audiences:f}:l}),e.builder.setDefaultEnvironment(Icp))}else if(a>0&&u===0){let l=0;r.length>0&&e.logger.error(`Skipping servers ${r.map(f=>typeof f=="string"?f:f.url).join(", ")} because x-fern-server-name was not provided.`);for(let[f,s]of Object.entries(t))l===0&&e.builder.setDefaultEnvironment(f),e.builder.addEnvironment({name:f,schema:s}),l+=1}else if(u>0){(r.length>0||n.length>0)&&e.logger.error(`Skipping servers ${[...r,...n].map(f=>typeof f=="string"?f:f.url).join(", ")} because x-fern-server-name was not provided.`);let l=Object.entries(t)[0];if(l!=null){let[f,s]=l;e.setDefaultServerName(f)}e.builder.addEnvironment({name:xcp,schema:{urls:{...zcp(t),...zcp(i)}}}),e.builder.setDefaultEnvironment(xcp)}}function fyo(e){return QE(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var kSs=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},t1S=.75,r1S=new Set("authorization");function Fcp(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?_dn(i.schema):void 0,u=a!=null?I8r(a):void 0,l=Wh.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?QE(h0({schema:i.schema,context:e,fileContainingReference:u?Dz(Wh.of(pg(u)),l):l,namespace:u,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(r1S.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let l=t[a.name],f=sQt({header:{...a,schema:l?.schema??a.schema,name:l?.name??a.name},fileContainingReference:Wh.of(UN),context:e,namespace:void 0});u=new kSs(f),r[a.name]=u}u.increment()}let i=e.ir.endpoints.length*t1S;for(let[n,a]of Object.entries(r)){let u=t[n],l=a.count===e.ir.endpoints.length,f=a.count>=i;u==null&&(l?e.builder.addGlobalHeader({name:n,schema:a.schema}):f&&e.builder.addGlobalHeader({name:n,schema:fyo(a.schema)}))}}}function Ncp(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?_dn(t.schema):void 0,i=r!=null?I8r(r):void 0,n=sQt({header:{...t,schema:t.schema??ey.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:WP.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:Wh.of(UN),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:fyo(n)})}}function NH(e){switch(e.type){case"primitive":return Ucp(e.value);case"object":return Vcp(e.properties);case"array":return Wcp(e.value);case"map":return n1S(e.value);case"oneOf":return a1S(e.value);case"enum":return e.value;case"literal":return o1S(e.value);case"unknown":return NH(e.value);default:Zo(e)}}function Lcp(e){switch(e.type){case"withStreaming":return e.sse?{stream:i1S(e.events)}:{stream:Wcp(e.events)};case"withoutStreaming":return{body:NH(e.value)};default:Zo(e)}}function Ucp(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:Zo(e)}}function Vcp(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,NH(r)]))}function i1S(e){return e.map(t=>({event:"",data:NH(t)}))}function Wcp(e){return e.map(t=>NH(t))}function n1S(e){return Object.fromEntries(e.map(t=>[Ucp(t.key),NH(t.value)]))}function a1S(e){return e.type==="discriminated"?Vcp(e.value):NH(e.value)}function o1S(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Zo(e)}}function Hcp({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"]=u1S(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=s1S(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=c1S({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=NH(e.request)),e.response!=null&&(r.response=Lcp(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(i=>i.type==="language"?{name:i.name??void 0,docs:i.description??void 0,language:i.language,code:i.code,install:i.install??void 0}:{name:i.name??void 0,docs:i.description??void 0,sdk:i.sdk,code:i.code}).filter(dg)),r)}function u1S(e){let t={};return e.forEach(r=>{let i=NH(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function s1S(e){let t={};return e.forEach(r=>{let i=NH(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function c1S({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=NH(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function $cp(e){return RH._visit(e,{get:()=>lH.HttpMethodSchema.Get,post:()=>lH.HttpMethodSchema.Post,put:()=>lH.HttpMethodSchema.Put,patch:()=>lH.HttpMethodSchema.Patch,delete:()=>lH.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("Unknown http method is unsupported")}})}function Gcp(e){return e==="POST"||e==="PUT"||e==="PATCH"}function Qcp({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,u=e.path,l=lyo(e.sdkName,e.namespace),f={};for(let m of e.pathParameters)m.parameterNameOverride&&(u=u.replace(m.name,m.parameterNameOverride)),f[m.parameterNameOverride??m.name]=uyo({pathParameter:m,context:r,fileContainingReference:t,namespace:l}),a.add(m.name);let s={};for(let m of e.queryParameters){let w=cyo({queryParameter:m,context:r,fileContainingReference:t,namespace:l});w!=null&&(s[m.name]=w,a.add(m.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 c={path:u,method:$cp(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?x8r(e.source):void 0};!d1S({context:r,request:e.request})&&Object.keys(f).length>0&&(c["path-parameters"]=f),e.summary!=null&&(c["display-name"]=e.summary);let b={},g=r.builder.getGlobalHeaderNames(),O=e.headers.filter(m=>!g.has(m.name));for(let m of O){let w=sQt({header:m,context:r,fileContainingReference:t,namespace:l});b[m.name]=w,a.add(typeof w=="string"?m.name:w.name??m.name)}if(e.request!=null){r.setInState(c2.Request);let m=f1S({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(f).length>0?f:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(b).length>0?b:void 0,usedNames:a,namespace:l});c.request=m.value,n=[...n,...m.schemaIdsToExclude??[]],r.unsetInState(c2.Request)}else{let m=r.inlinePathParameters&&Object.keys(f).length>0,w=Object.keys(s).length>0,A=Object.keys(b).length>0,M={};(m||w||A)&&(M.name=e.requestNameOverride??e.generatedRequestName),m&&(M["path-parameters"]=f),w&&(M["query-parameters"]=s),A&&(M.headers=b),Object.keys(M).length>0&&(c.request=M)}if(e.response!=null&&e.response._visit({json:m=>{let w=h0({schema:m.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c.response={docs:m.description??void 0,type:QE(w)},m.statusCode!=null&&(c.response["status-code"]=m.statusCode),m.responseProperty!=null&&(c.response.property=m.responseProperty)},streamingJson:m=>{let w=h0({schema:m.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c["response-stream"]={docs:m.description??void 0,type:QE(w),format:"json"}},streamingSse:m=>{let w=h0({schema:m.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c["response-stream"]={docs:m.description??void 0,type:QE(w),format:"sse"}},file:m=>{c.response={docs:m.description??void 0,type:"file","status-code":m.statusCode}},streamingText:m=>{c["response-stream"]={docs:m.description??void 0,type:"text"}},text:m=>{c.response={docs:m.description??void 0,type:"text","status-code":m.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let m=r.getDefaultServerName(),w=e.server[0];w==null?m!=null&&(c.url=m):c.url=w.name??void 0}return e.idempotent&&(c.idempotent=!0),e.availability!=null&&(c.availability=gx(e.availability)),Object.entries(e.errors).forEach(([m,w])=>{let A=w.generatedName,M=Wh.of(P1);r.builder.enableUniqueErrorsPerEndpoint&&(A=`${e.generatedRequestName}${w.generatedName}`,w.schema!=null&&(w.schema.type!=="reference"&&w.schema.type!=="oneOf"?w.schema.generatedName=`${e.generatedRequestName}${w.schema.generatedName}`:w.schema.type==="oneOf"&&(w.schema.value.generatedName=`${e.generatedRequestName}${w.schema.value.generatedName}`)));let q={"status-code":parseInt(m)},D=Ocp({location:Jcp,namespaceOverride:l});if(w.schema!=null){let $=h0({schema:w.schema,context:r,fileContainingReference:D,declarationFile:D,namespace:l,declarationDepth:0});q.type=QE($),q.docs=w.description}r.builder.addError(D,{name:A,schema:r.isErrorUnknownSchema(parseInt(m))?{...q,type:"unknown"}:q}),c.errors==null&&(c.errors=[]);let C=r.builder.addImport({file:t,fileToImport:D});c.errors.push(C!=null?`${C}.${A}`:A),q.type!=null&&w.examples?.forEach($=>{let I={value:NH($.example),name:$.name,docs:$.description};r.builder.addErrorExample(D,{name:A,example:I})})}),e.examples.length>0&&(c.examples=l1S({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?c.audiences=[eDs,...e.audiences]:e.audiences.length>0&&(c.audiences=e.audiences),{value:c,schemaIdsToExclude:n}}function l1S({endpointExamples:e,context:t}){return e.map(r=>{try{return Hcp({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function f1S({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:u,queryParameters:l,nonRequestReferencedSchemas:f,headers:s,usedNames:o,namespace:c}){if(i.type==="json"){let b=i.schema.type==="reference"?i.schema.schema:void 0,g=i.schema.type==="reference"?r.getSchema(i.schema.schema,c):i.schema;if(g?.type!=="object"||b!=null&&f.includes(b)){let M=h0({schema:i.schema,fileContainingReference:t,context:r,namespace:c,declarationDepth:0}),q={schemaIdsToExclude:[],value:{body:M}},D=Object.keys(u??{}).length>0,C=Object.keys(l??{}).length>0,R=Object.keys(s??{}).length>0;return D&&(q.value["path-parameters"]=u),C&&(q.value["query-parameters"]=l),R&&(q.value.headers=s),(D||C||R)&&(q.value.name=n??a),i.contentType!=null&&(q.value["content-type"]=i.contentType),i.description!=null&&(q.value.docs=i.description),q}let O=Object.fromEntries(g.properties.filter(M=>M.readonly==null?!0:!(Gcp(e.method)&&M.readonly)).map(M=>{let q=h0({schema:M.schema,fileContainingReference:t,context:r,namespace:c,declarationDepth:1}),D=M.nameOverride??M.key,C=gx(M.availability);if(!o.has(D)&&M.audiences.length<=0)return o.add(D),M.nameOverride!=null?[M.key,{type:QE(q),docs:hdn(q),name:M.nameOverride,availability:C}]:[M.key,C?{...typeof q=="string"?{type:q}:q,availability:C}:q];let R={type:QE(q),docs:hdn(q)};return o.has(D)&&(R.name=M.generatedName),M.audiences.length>0&&(R.audiences=M.audiences),C!=null&&(R.availability=C),o.add(D),[M.key,R]})),m=g.allOf.map(M=>{let q=h0({schema:ey.reference(M),fileContainingReference:t,context:r,namespace:c,declarationDepth:0});return QE(q)}),w={properties:O};m.length>0&&(w.extends=m),i.additionalProperties&&(w["extra-properties"]=!0);let A={name:n??g.nameOverride??g.generatedName,"path-parameters":u,"query-parameters":l,headers:s,body:w};return i.contentType!=null&&(A["content-type"]=i.contentType),i.description!=null&&(A.docs=i.description),{schemaIdsToExclude:b!=null?[b]:[],value:A}}else{if(i.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":aB.APPLICATION_OCTET_STREAM,...i.description?{docs:i.description}:{}}};if(i.type==="multipart"){let b=Object.fromEntries(i.properties.map(g=>{if(g.schema.type==="file"){let O=g.schema.isArray?"list<file>":"file";if(O=g.schema.isOptional?`optional<${O}>`:O,g.description!=null||g.contentType!=null){let m={type:O};if(g.description!=null&&(m.docs=g.description),g.contentType!=null){let w=g.contentType.split(",")[0];m["content-type"]=w}return[g.key,m]}return[g.key,O]}else{let O=h0({schema:g.schema.value,fileContainingReference:t,context:r,namespace:c,declarationDepth:1});return g.contentType!=null&&(typeof O=="string"?O={type:O,"content-type":g.contentType}:O["content-type"]=g.contentType),[g.key,O]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":u,"query-parameters":l,headers:s,body:{properties:b},"content-type":aB.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else Zo(i)}}function d1S({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;default:Zo(t)}}function p1S({location:e,namespaceOverride:t}){return t!=null?{...e,file:Dz(Wh.of(t),e.file)}:e}function _1S(e){let t=e.namespace,r=e.tags.filter(f=>f!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:Wh.of(`${pg(r)}.yml`),endpointId:e.summary!=null?pg(e.summary):pg(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Wh.of(P1),endpointId:pg(e.summary)}:{file:Wh.of(P1),endpointId:pg(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Wh.of(P1),endpointId:i};let n=bZn(r),a=bZn(i);if(N3t(n,a))return{file:Wh.of("__package__.yml"),endpointId:r};let u=v1S({operationId:i,tag:r,path:e.path,method:e.method});if(u!=null)return u;let l=[];for(let f=0;f<n.length;++f){let s=n[f];if(s!=null&&s===a[f])l.push(s);else{let o=pg(r);return{file:Wh.of(`${o}.yml`),endpointId:i,tag:r}}}if(l.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:Wh.of(pg(l.join("_"))+".yml"),endpointId:pg(a.slice(l.length).join("_")),tag:r}}function gZn(e){let t=e.tags[0];if(e.sdkName!=null){let r=FSs({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Wh.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return p1S({namespaceOverride:e.namespace,location:_1S(e)})}function bZn(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=BUt(t),t}var h1S=new RegExp("[^a-zA-Z0-9{}]+"),y1S=new RegExp("[{}]","g");function v1S({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(h1S).join("_").replaceAll(y1S,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:Wh.of(pg(t)+".yml"),endpointId:pg(e.slice(0,-1*a.length)),tag:t}}function Kcp(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:u,file:l,tag:f}=gZn(a),s=l.split(".")[0];s!=null&&t.add(s);let o;if(a.sdkName!=null){let g=e.ir.groups;for(let O of a.sdkName.groupName){let m=typeof O=="string"?O:O.name,w=g[m];if(w==null)break;if(w.summary!=null||w.description!=null){o=g[m];break}}}let c=f==null?void 0:i.tagsById[f];e.setInState(c2.Endpoint),e.setEndpointMethod(a.method);let b=Qcp({context:e,endpoint:a,declarationFile:l});e.unsetEndpointMethod(),e.unsetInState(c2.Endpoint),n=[...n,...b.schemaIdsToExclude],e.builder.addEndpoint(l,{name:u,schema:b.value,source:a.source!=null?x8r(a.source):void 0}),(c?.id!=null||c?.description!=null)&&e.builder.setServiceInfo(l,{"display-name":o?.summary??c?.id,docs:o?.description??c?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function Ycp(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?I8r(r.groupName):void 0,n=h0({schema:ey.primitive(r),context:e,fileContainingReference:Wh.of(P1),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:QE(n),docs:r.description??void 0}})}}function Xcp(e){for(let t of e.ir.webhooks){let r=O1S({webhook:t,context:e});if(r==null)continue;let i=lyo(t.sdkName,t.namespace),n={};for(let u of t.headers)n[u.name]=sQt({header:u,context:e,fileContainingReference:r.file,namespace:i});let a={method:t.method,"display-name":t.summary??void 0,headers:n,payload:h0({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:NH(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function b1S({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:Dz(Wh.of(t),e.file)}:e}function g1S({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:Wh.of(P1),endpointId:i};let n=bZn(r),a=bZn(i);if(N3t(n,a))return{file:Wh.of("__package__.yml"),endpointId:r};let u=[];for(let l=0;l<n.length;++l){let f=n[l];if(f!=null&&f===a[l])u.push(f);else{let s=pg(r);return{file:Wh.of(`${s}.yml`),endpointId:i,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:Wh.of(pg(u.join("_"))+".yml"),endpointId:pg(a.slice(u.length).join("_")),tag:r}}function O1S({webhook:e,context:t}){return e.sdkName!=null?{file:gcp({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:b1S({namespaceOverride:e.namespace,location:g1S({webhook:e,context:t})})}var m1S=Wh.of(P1);function Zcp(e){switch(e.type){case"object":return cQt(e.groupName);case"enum":return cQt(e.groupName);case"oneOf":return cQt(e.value.groupName);case"array":return cQt(e.groupName);case"map":return cQt(e.groupName);case"reference":return cQt(e.groupName);case"literal":return cQt(e.groupName);case"optional":return cQt(e.groupName);case"nullable":return cQt(e.groupName);case"primitive":return cQt(e.groupName);case"unknown":return m1S;default:Zo(e)}}function cQt(e){return pdn(e)}var eDs="external",Jcp=Wh.of(P1);function kcp({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let u=Zcp(a),l=wcp({schema:a,context:i,declarationFile:u,namespace:r,declarationDepth:0});if(pXr(l.schema)){let f=QE(l.schema);if(f===(l.name??n)||f===`optional<${l.name??n}>`)continue}i.builder.addType(u,{name:l.name??n,schema:l.schema})}}function elp(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),Rcp(e),Fcp(e),Ncp(e),Mcp(e),Ycp(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(eDs);let t=Kcp(e),r=t.sdkGroups;e.setInState(c2.Webhook),Xcp(e),e.unsetInState(c2.Webhook),e.setInState(c2.Channel);for(let n of e.ir.channel){let a=pdn(n.groupName);Bcp({channel:n,context:e,declarationFile:a})}e.unsetInState(c2.Channel);let i=P1S({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});kcp({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))kcp({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function P1S({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}function tDs(e){let t=new tyo(e);return elp(t)}var aSi={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!1,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1};function rDs({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??aSi.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??aSi.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??aSi.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??aSi.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??aSi.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??aSi.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??aSi.inlinePathParameters}}var dyo=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=tDs({taskContext:t,ir:r,options:rDs({overrides:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.args.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.args.objectQueryParameters}}),authOverrides:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration?.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:pp.dump(a.rootApiFile)},namedDefinitionFiles:{...cd(a.definitionFiles,u=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:pp.dump(u),contents:u})),[Wh.of(P1)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:pp.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var OZn=class extends F2t{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;exampleGeneration;converter;constructor(t){super(t),this.inlinePathParameters=t.inlinePathParameters,this.objectQueryParameters=t.objectQueryParameters,this.onlyIncludeReferencedSchemas=t.onlyIncludeReferencedSchemas,this.respectReadonlySchemas=t.respectReadonlySchemas,this.respectNullableSchemas=t.respectNullableSchemas,this.exampleGeneration=t.exampleGeneration,this.converter=new dyo(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new xwe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion})}};function ydn(e){if(e.settings==null)return;let t={detectGlobalHeaders:!0};return e.settings.unions==="v1"&&(t.discriminatedUnionV2=!0),t}var K0p=Di(p0o(),1);var EK={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0};function Gqs({options:e,overrides:t}){return{disableExamples:t?.disableExamples??EK.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??EK.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??EK.useTitlesAsName,audiences:t?.audiences??e?.audiences??EK.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??EK.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??EK.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??EK.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??EK.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??EK.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??EK.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??EK.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??EK.shouldUseUndiscriminatedUnionsWithLiterals,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??EK.objectQueryParameters,filter:t?.filter??e?.filter??EK.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??EK.asyncApiNaming,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0}}var Dbp={naming:"v1"};function Vf(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function Okn(e,t,r,i,n=[]){try{let a=Vf(e,t);if(a!=null)return r.parse(a)}catch{let u=BUt(n).join(" -> ");i.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}var _0o={of(e){return e}};var Ebp={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},Qqs={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:Ebp,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},md={SDK_METHOD_NAME:_0o.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:_0o.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:_0o.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 rp(e){return e.$ref!=null}function XBe(e){switch(Vf(e,md.AVAILABILITY)){case"deprecated":return GL.Deprecated;case"beta":return GL.Beta;case"generally-available":return GL.GenerallyAvailable;default:break}if(!rp(e)&&e.deprecated)return GL.Deprecated}var Uwe={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 ISi(e){let t=Vf(e,"examples");return t!=null&&Array.isArray(t)?t:[]}function Abp({schema:e,logger:t}){return Vf(e,md.ENCODING)??void 0}function Mbp(e){return Vf(e,md.FERN_ENUM)}function qbp({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let u=Vf(i,md.SDK_GROUP_NAME),l=Vf(i,md.TYPE_DEFINITION);if(l!=null)return mkn({fernType:l,nameOverride:e,generatedName:t,title:r,description:n,availability:a,groupName:typeof u=="string"?[u]:u})}function mkn({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u}){return vL({type:e,_default:void 0,validation:void 0,visitor:{primitive:l=>{switch(l.v1){case"BASE_64":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.base64({example:void 0})});case"BOOLEAN":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.boolean({default:void 0,example:void 0})});case"DATE":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.date({example:void 0})});case"DATE_TIME":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.datetime({example:void 0})});case"FLOAT":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.float({example:void 0})});case"DOUBLE":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.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 Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.uint({default:void 0,example:void 0})});case"INTEGER":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.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 Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.uint64({default:void 0,example:void 0})});case"LONG":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Fl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Zo(l.v1)}},unknown:()=>Fl.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,groupName:u}),map:({keyType:l,valueType:f})=>l?.type==="primitive"&&f!=null?Fl.map({nameOverride:t,generatedName:r,title:i,key:l,value:f,description:n,availability:a,groupName:u,encoding:void 0,example:void 0,inline:void 0}):void 0,list:l=>l!=null?Fl.array({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,example:void 0,inline:void 0}):void 0,optional:l=>l!=null?Fl.optional({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,inline:void 0}):void 0,nullable:l=>l!=null?Fl.nullable({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,inline:void 0}):void 0,set:l=>l!=null?Fl.array({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,example:void 0,inline:void 0}):void 0,literal:l=>Fl.literal({nameOverride:t,generatedName:r,title:i,value:l._visit({string:f=>bB.string(f),boolean:f=>bB.boolean(f),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,groupName:u}),named:()=>{}}})}function zSi(e){if(e!=null&&typeof e=="boolean")return e}function Tbp({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:u,wrapAsNullable:l,context:f,groupName:s,example:o,encoding:c,source:b,namespace:g}){return typeof n=="boolean"||upn(n)?h0o({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Fl.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:void 0}),groupName:s,example:o,encoding:c}):h0o({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Cbp(rg(n,f.options.optionalAdditionalProperties?l:!1,f,[...i,"Value"],b,g,void 0,void 0,void 0)),groupName:s,example:o,encoding:c})}function Cbp(e){switch(e.type){case"array":case"enum":case"map":case"object":e.inline=!0;break;case"literal":case"primitive":case"reference":case"unknown":break;case"nullable":case"optional":e.inline=!0,e.value=Cbp(e.value);break;case"oneOf":e.value.inline=!0;break;default:Zo(e)}return e}function h0o({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsNullable:a,description:u,availability:l,groupName:f,example:s,encoding:o}){return a?Fl.nullable({nameOverride:e,generatedName:t,title:r,value:Fl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:i.availability,key:i,value:n,groupName:f,encoding:o,example:s,inline:void 0}),description:u,availability:l,groupName:f,inline:void 0}):Fl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:l,key:i,value:n,groupName:f,encoding:o,example:s,inline:void 0})}function upn(e){return e==null?!1:typeof e=="boolean"?e:!rp(e)&&Object.keys(e).length===0}function Bbp({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:u,wrapAsNullable:l,context:f,groupName:s,example:o,source:c,namespace:b}){let g=n==null?Fl.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,groupName:s}):rg(n,!1,f,[...i,"Item"],c,b);return O5S({nameOverride:e,generatedName:t,title:r,groupName:s,itemSchema:g,wrapAsNullable:l,description:a,availability:u,example:o})}function O5S({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsNullable:n,description:a,availability:u,groupName:l,example:f}){return n?Fl.nullable({nameOverride:e,generatedName:t,title:r,value:Fl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,groupName:l,example:f,inline:void 0}),description:a,availability:u,groupName:l,inline:void 0}):Fl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,groupName:l,example:f,inline:void 0})}function Jqs({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:l,wrapAsNullable:f,discriminator:s,context:o,groupName:c,encoding:b,source:g,namespace:O}){let m=s.propertyName,w=Object.fromEntries(Object.entries(s.mapping??{}).map(([M,q])=>{let D=spn({$ref:q},!1,o,[q],b,g,O);return o.markReferencedByDiscriminatedUnion({$ref:q},m,1),[M,D]})),A=Object.entries(n).filter(([M])=>M!==m).map(([M,q])=>{let D=l!=null&&l.includes(M),C=rg(q,!D,o,[...i,M],g,O);return{key:M,schema:C}});return xbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,properties:A,description:a,availability:u,discriminant:m,subtypes:w,groupName:c,source:g})}function Kqs({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:l,wrapAsNullable:f,discriminant:s,variants:o,context:c,groupName:b,encoding:g,source:O,namespace:m}){let w=Object.fromEntries(Object.entries(o).map(([M,q])=>{if(rp(q)){let D=spn(q,!1,c,[q.$ref],g,O,m);return c.markReferencedByDiscriminatedUnion(q,s,1),[M,D]}else{let D=cpn(q,!1,c,[...i,M],g,O,m,new Set([s]));return[M,D]}})),A=Object.entries(n).filter(([M])=>M!==s).map(([M,q])=>{let D=l!=null&&l.includes(M),C=rg(q,!D,c,[...i,M],O,m);return{key:M,schema:C}});return xbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,properties:A,description:a,availability:u,discriminant:s,subtypes:w,groupName:b,source:O})}function xbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,availability:u,discriminant:l,subtypes:f,groupName:s,source:o}){return i?Fl.nullable({nameOverride:e,generatedName:t,title:r,value:Fl.oneOf(dK.discriminated({description:a,availability:u,discriminantProperty:l,nameOverride:e,generatedName:t,title:r,schemas:f,commonProperties:n,groupName:s,encoding:void 0,source:o,inline:void 0})),groupName:s,description:a,availability:u,inline:void 0}):Fl.oneOf(dK.discriminated({description:a,availability:u,discriminantProperty:l,nameOverride:e,generatedName:t,title:r,schemas:f,commonProperties:n,groupName:s,encoding:void 0,source:o,inline:void 0}))}function Ibp(e){if(e.proto!=null)return Rfn.protobuf({typeName:e.proto.type})}function fti({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:u,description:l,availability:f,wrapAsNullable:s,groupName:o,context:c,source:b,inline:g}){let O=P5S(n??[]),m=new Set(a),w=Array.from(m).map((M,q)=>{let D=i?.[M],C=O[q],R=fdn.test(M),$=D?.name??C,I=R?M:ddn(M);return $!=null&&!fdn.test($)&&(c?.logger.warn(`Enum name override ${$} is not a valid name. Falling back on ${I}.`),$=void 0),{nameOverride:$,generatedName:I,value:M,description:D?.description,availability:f,casing:{snake:D?.casing?.snake??void 0,pascal:D?.casing?.pascal??void 0,screamingSnake:D?.casing?.screamingSnake??void 0,camel:D?.casing?.camel??void 0}}}),A=u!=null?w.find(M=>M.value===u):void 0;return m5S({wrapAsNullable:s,nameOverride:e,generatedName:t,title:r,values:w,_default:A,description:l,availability:f,groupName:o,source:b,inline:g})}function m5S({wrapAsNullable:e,nameOverride:t,generatedName:r,title:i,values:n,_default:a,description:u,availability:l,groupName:f,source:s,inline:o}){return e?Fl.nullable({nameOverride:t,generatedName:r,title:i,value:Fl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,default:a,availability:l,example:void 0,groupName:f,source:s,inline:o}),description:u,availability:l,groupName:f,inline:o}):Fl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,availability:l,default:a,example:void 0,groupName:f,source:s,inline:o})}function P5S(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function zbp({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:f,multipleOf:s,description:o,availability:c,wrapAsNullable:b,example:g,groupName:O}){return i==="int64"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint32"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint64"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.int({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:f,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O})}function Rbp(e){return typeof e=="string"?bB.string(e):typeof e=="boolean"?bB.boolean(e):bB.string(`${e}`)}function Fbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,value:n,description:a,availability:u,groupName:l}){return i?Fl.nullable({nameOverride:e,generatedName:t,title:r,value:Fl.literal({nameOverride:e,generatedName:t,title:r,value:Rbp(n),description:a,availability:u,groupName:l}),description:a,availability:u,groupName:l,inline:void 0}):Fl.literal({nameOverride:e,generatedName:t,title:r,value:Rbp(n),description:a,availability:u,groupName:l})}function Yqs({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:f,multipleOf:s,description:o,availability:c,wrapAsNullable:b,example:g,groupName:O}){return i==null||i==="double"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.double({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:f,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="float"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.float({example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="int32"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.int({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:f,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="int64"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint32"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint64"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="time-delta"?i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.float({example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i8({nameOverride:e,generatedName:t,title:r,primitive:Xd.float({example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O})}var j5S={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},w5S={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}}},S5S={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}}},D5S={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},E5S={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},A5S={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},M5S={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},q5S={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function y0o(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[j5S,w5S,S5S,D5S,E5S,A5S,M5S,q5S],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:l}=a.applyStrategy(t);t=u,r=[...r,...l]}}while(t.join("")!==n.join(""));return r}function d2(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:G9(pg(n))).join("");return/^\d/.test(i)?hZn(i)??i:i}function Xqs(e){let t=e.join("_");return pg(t)}function Dq(e){switch(e.type){case"object":return ey.object({allOf:e.allOf,properties:e.properties.map(t=>C5S(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,inline:e.inline});case"array":return ey.array({description:e.description,availability:e.availability,value:Dq(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,inline:e.inline});case"enum":return ey.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,inline:e.inline});case"literal":return ey.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 ey.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Dq(e.value),groupName:e.groupName,inline:e.inline});case"optional":return ey.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Dq(e.value),groupName:e.groupName,inline:e.inline});case"primitive":return ey.primitive({description:e.description,availability:e.availability,schema:Nbp(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return ey.map({description:e.description,availability:e.availability,key:ey.primitive({description:e.key.description,availability:e.key.availability,schema:Nbp(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:Dq(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return ey.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 ey.oneOf(T5S(e.value));case"unknown":return ey.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Zo(e)}}function T5S(e){switch(e.type){case"discriminated":return B8r.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:Dq(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,Dq(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return B8r.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>Dq(t)),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:Zo(e)}}function Nbp(e){switch(e.type){case"string":return WP.string(e);case"base64":return WP.base64();case"boolean":return WP.boolean(e);case"date":return WP.date();case"datetime":return WP.datetime();case"double":return WP.double(e);case"float":return WP.float();case"int":return WP.int(e);case"int64":return WP.int64(e);case"uint":return WP.uint();case"uint64":return WP.uint64();default:Zo(e)}}function C5S(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:Dq(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly}}function v0o(e,t){return xte(Dq(e),Dq(t))}function Lbp({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:u,wrapAsNullable:l,allOf:f,context:s,propertiesToExclude:o,groupName:c,fullExamples:b,additionalProperties:g,availability:O,encoding:m,source:w,namespace:A}){let M=[...u??[]],q={...n},D=[],C=[];for(let U of f)if(rp(U)){let H=s.resolveSchemaReference(U);if(H.discriminator!=null&&H.discriminator.mapping!=null)continue;if(H.oneOf!=null){for(let J of H.oneOf){let ee=rp(J)?s.resolveSchemaReference(J):J,fe=rg(ee,!1,s.DUMMY,i,w,A);fe.type==="object"&&D.push(...fe.properties.map(me=>me.schema.type!=="optional"&&me.schema.type!=="nullable"?{...me,schema:Fl.optional({nameOverride:void 0,generatedName:"",title:void 0,value:me.schema,description:void 0,availability:me.availability,groupName:void 0,inline:void 0})}:me))}continue}let te=dti(U);if(te==null)continue;C.push({schemaId:te,convertedSchema:Zqs(U,[te],w,s.options.preserveSchemaIds),properties:Ubp({schema:U,context:s,breadcrumbs:i,source:w,namespace:A})}),s.markSchemaAsReferencedByNonRequest(te)}else{let H=rg(U,!1,s,i,w,A);H.type==="object"&&D.push(...H.properties)}let R={};for(let U of C)for(let[H,te]of Object.entries(U.properties)){let J=R[H];J!=null?(J.schemaIds.push(U.schemaId),J.schemas.some(fe=>v0o(fe,te))||J.schemas.push(te)):R[H]={schemaIds:[U.schemaId],schemas:[te]}}let $=[];for(let[U,H]of Object.entries(R))H.schemaIds.length>1&&$.push({propertyKey:U,allOfSchemaIds:H.schemaIds,conflictingTypeSignatures:H.schemas.length>1});let I=Object.entries(q).map(([U,H])=>{let te=M.includes(U),J=Vf(H,md.AUDIENCES)??[],ee=XBe(H),fe=rp(H)?!1:H.readOnly,me=Vf(H,md.FERN_PROPERTY_NAME),ve=[...i,U],we=Xqs(ve),Xe=te?rg(H,!1,s,ve,w,A):Fl.optional({nameOverride:e,generatedName:we,title:r,description:void 0,availability:ee,value:rg(H,!1,s,ve,w,A),groupName:c,inline:void 0}),Mt={};for(let De of C){let Te=De.properties[U];Te!=null&&!v0o(Xe,Te)?Mt[De.schemaId]={differentSchema:!0}:Te!=null&&(Mt[De.schemaId]={differentSchema:!1})}return{key:U,schema:Xe,nameOverride:me,audiences:J,conflict:Mt,generatedName:Xqs([...i,U]),availability:ee,readonly:fe}});return I.push(...D.map(U=>{let H=U.conflict;for(let te of C){let J=te.properties[U.key];J!=null&&!v0o(U.schema,J)?H[te.schemaId]={differentSchema:!0}:J!=null&&(H[te.schemaId]={differentSchema:!1})}return{...U,conflict:H}})),B5S({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,properties:I.filter(U=>!o.has(U.key)),description:a,allOf:C.map(U=>U.convertedSchema),allOfPropertyConflicts:$,groupName:c,fullExamples:b,additionalProperties:g,availability:O,source:w})}function B5S({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,allOf:u,allOfPropertyConflicts:l,groupName:f,fullExamples:s,additionalProperties:o,availability:c,source:b}){return i?Fl.nullable({nameOverride:e,generatedName:t,title:r,value:Fl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:l,groupName:f,fullExamples:s,additionalProperties:upn(o),availability:void 0,source:b,inline:void 0}),description:a,availability:c,groupName:f,inline:void 0}):Fl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:l,groupName:f,fullExamples:s,additionalProperties:upn(o),availability:c,source:b,inline:void 0})}function Ubp({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[u,l]=rp(e)?[t.resolveSchemaReference(e),y0o(e.$ref)]:[e,r];for(let f of u.allOf??[])a={...a,...Ubp({schema:f,context:t,breadcrumbs:l,source:i,namespace:n})};for(let[f,s]of Object.entries(u.properties??{})){let o=rg(s,!1,t,[...l,f],i,n);a[f]=o}return a}function lpn({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsNullable:u,context:l,subtypes:f,groupName:s,encoding:o,source:c,subtypePrefixOverrides:b,namespace:g}){let O=x5S({schemas:f}),m=f.flatMap((M,q)=>{if(!rp(M)&&M.enum!=null&&l.options.coerceEnumsToLiterals&&M.type==="string")return M.enum.map(C=>Fl.literal({nameOverride:void 0,generatedName:d2([t,C],l.options.preserveSchemaIds),title:void 0,value:bB.string(String(C)),groupName:void 0,description:void 0,availability:C.availability}));let D=O[q];if(b!=null){let C=b[q];C!=null&&"name"in C&&(D=C.name)}return[rg(M,!1,l,[...i,D??`${q}`],c,g)]}),w=[];for(let M=0;M<m.length;++M){let q=m[M],D=!1;for(let C=M+1;C<m.length;++C){let R=m[C];if(q!=null&&R!=null&&xte(q,R)){D=!0;break}}q!=null&&!D&&w.push(q)}if(Object.entries(w).every(([M,q])=>q.type==="literal")){let M={},q=[];return Object.entries(w).forEach(([D,C])=>{C.type==="literal"&&C.value.type==="string"&&(q.push(C.value.value),C.description!=null&&(M[C.value.value]={description:C.description}))}),fti({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,fernEnum:M,enumVarNames:void 0,enumValues:q,_default:void 0,groupName:s,context:l,source:c,inline:void 0})}return w.length===1&&w[0]!=null?w[0]:Vbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,subtypes:w,groupName:s,encoding:o,source:c})}function kqs({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsNullable:a,context:u,groupName:l,discriminator:f,encoding:s,source:o,namespace:c}){let b=Object.entries(f.mapping??{}).map(([m,w],A)=>{let M={$ref:w},q=spn(M,!1,u,[w],s,o,c);return u.markSchemaWithDiscriminantValue(M,f.propertyName,m),q.type==="object"&&(q.properties={[f.propertyName]:Fl.literal({nameOverride:void 0,generatedName:d2([t,m],u.options.preserveSchemaIds),title:void 0,value:bB.string(m),groupName:void 0,description:void 0,availability:void 0}),...q.properties.filter(D=>D.key!==f.propertyName)}),q}),g=[];for(let m=0;m<b.length;++m){let w=b[m],A=!1;for(let M=m+1;M<b.length;++M){let q=b[M];if(w!=null&&q!=null&&xte(w,q)){A=!0;break}}w!=null&&!A&&g.push(w)}if(Object.entries(g).every(([m,w])=>w.type==="literal")){let m={},w=[];return Object.entries(g).forEach(([A,M])=>{M.type==="literal"&&M.value.type==="string"&&(w.push(M.value.value),M.description!=null&&(m[M.value.value]={description:M.description}))}),fti({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,fernEnum:m,enumVarNames:void 0,enumValues:w,_default:void 0,groupName:l,context:u,source:o,inline:void 0})}return g.length===1&&g[0]!=null?g[0]:Vbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,subtypes:g,groupName:l,encoding:s,source:o})}function x5S({schemas:e}){let t={},r=0;for(let a of e){if(!rp(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),l={},f=u;for(let[s,o]of Object.entries(t)){let c=r7a(o,u);f=r7a(f,o),l[s]=c}l[r]=f,t=l}}r++}let i=[],n=0;for(let a of e){let u=t[n];if(u!=null&&u.length>0){let l=u.sort();if(l[0]!=null){i.push(l[0]),++n;continue}}rp(a)?i.push(Nei(n)??`${n}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?i.push(""):i.push(Nei(n)??`${n}`),++n}return i}function Vbp({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,description:n,availability:a,subtypes:u,groupName:l,encoding:f,source:s}){return i?Fl.nullable({nameOverride:e,generatedName:t,title:r,value:Fl.oneOf(dK.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:l,encoding:f,source:s,inline:void 0})),description:n,availability:a,groupName:l,inline:void 0}):Fl.oneOf(dK.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:l,encoding:f,source:s,inline:void 0}))}function fpn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function b0o({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=ISi(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function Wbp({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=ISi(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function G8r({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=ISi(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function Hbp({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=ISi(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var RSi="#/components/schemas/";function rg(e,t,r,i,n,a,u=!1,l=new Set,f){let s=V5S({schema:e,logger:r.logger});if(rp(e)){let o=dti(e);return o!=null?(u?r.markSchemaAsReferencedByRequest(o):r.markSchemaAsReferencedByNonRequest(o),spn(e,t,r,i,s,n,a)):cpn(r.resolveSchemaReference(e),t,r,y0o(e.$ref),s,n,a,l,u,f)}return cpn(e,t,r,i,s,n,a,l,u,f)}function spn(e,t,r,i,n,a,u){let l=e.$ref.includes("properties")?cpn(r.resolveSchemaReference(e),t,r,i,n,a,u,new Set):Fl.reference(Zqs(e,i,a,r.options.preserveSchemaIds));return t?Fl.nullable({title:void 0,nameOverride:void 0,generatedName:d2(i,r.options.preserveSchemaIds),value:l,description:void 0,availability:void 0,groupName:void 0,inline:void 0}):l}function I5S(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function cpn(e,t,r,i,n,a,u,l=new Set,f=!1,s){typeof e=="string"&&(e={type:e});let o=Vf(e,md.TYPE_NAME)??(r.options.useTitlesAsName?I5S(e.title):void 0),c=Vf(e,md.SDK_GROUP_NAME)??Vf(e,Uwe.TAGS)?.[0],b=(typeof c=="string"?[c]:c)??[];b=r.resolveGroupName(b);let g=d2(i,r.options.preserveSchemaIds),O=e.title,m=e.description,w=XBe(e),A=[];e.example!=null&&A.push({name:void 0,value:e.example,description:void 0});let M=Vf(e,Uwe.EXAMPLES);M!=null&&Object.keys(M).length>0&&A.push(...Object.entries(M).map(([C,R])=>({name:R?.summary??C,value:R.value,description:R.description})));let q=ISi(e);q!=null&&Object.keys(q).length>0&&A.push(...q.map(C=>({name:void 0,value:C,description:void 0})));let D=qbp({schema:e,description:m,title:O,nameOverride:o,generatedName:g,availability:w});if(D!=null)return D;if(Array.isArray(e.type)){let C=e.type.indexOf("null"),R=C!==-1;e.type.length===1?e.type=e.type[0]:e.type.length===2&&R?(e.type.splice(C,1),e.type=e.type[0],e.nullable=!0):(R&&(e.type.splice(C,1),e.nullable=!0),e.oneOf==null?e.oneOf=e.type:e.oneOf.push(...e.type))}if(!t&&e.nullable===!0)return cpn(e,!0,r,i,n,a,u,l,f,s);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!m0o(e.enum))return i8({nameOverride:o,generatedName:g,title:O,primitive:Xd.string({default:fpn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:G8r({schema:e,logger:r.logger,fallback:s})}),groupName:b,wrapAsNullable:t,description:m,availability:w});let C=Mbp(e);return e.enum.length===1&&e.enum[0]!=null&&C==null?Fbp({nameOverride:o,generatedName:g,title:O,wrapAsNullable:t,value:e.enum[0],description:m,availability:w,groupName:b}):fti({nameOverride:o,generatedName:g,title:O,fernEnum:C,enumVarNames:Vf(e,[Uwe.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:m,availability:w,wrapAsNullable:t,groupName:b,context:r,source:a,inline:void 0})}if(m0o(e.type)&&e.type.length>1){let C=e.type.includes("null"),R=e.type.filter($=>$!=="null").map($=>({type:$,nullable:C}));return lpn({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,wrapAsNullable:t,context:r,subtypes:R,groupName:b,encoding:n,source:a,namespace:u})}if(e.type==="boolean"){let C=Vf(e,md.BOOLEAN_LITERAL);return C!=null?$bp({nameOverride:o,generatedName:g,title:O,literal:bB.boolean(C),wrapAsNullable:t,description:m,availability:w,groupName:b}):i8({nameOverride:o,generatedName:g,title:O,primitive:Xd.boolean({default:z5S(e.default),example:Wbp({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:w,groupName:b})}if(e.type==="number")return Yqs({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:zSi(e.exclusiveMinimum),exclusiveMaximum:zSi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:w,wrapAsNullable:t,example:b0o({schema:e,logger:r.logger,fallback:s}),groupName:b});if(e.type==="integer")return zbp({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:zSi(e.exclusiveMinimum),exclusiveMaximum:zSi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:w,wrapAsNullable:t,example:b0o({schema:e,logger:r.logger,fallback:s}),groupName:b});if(e.type==="float")return Yqs({nameOverride:o,generatedName:g,title:O,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:zSi(e.exclusiveMinimum),exclusiveMaximum:zSi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:w,wrapAsNullable:t,example:b0o({schema:e,logger:r.logger,fallback:s}),groupName:b});if(e.type==="string"){if(e.format==="date-time")return i8({nameOverride:o,generatedName:g,title:O,primitive:Xd.datetime({example:G8r({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:w,groupName:b});if(e.format==="json-string")return Fl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:w,groupName:b,example:void 0});let C=Jbp(e,"const");return C!=null?$bp({nameOverride:o,generatedName:g,title:O,literal:bB.string(C),wrapAsNullable:t,description:m,availability:w,groupName:b}):i8({nameOverride:o,generatedName:g,title:O,primitive:Xd.string({default:fpn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:G8r({schema:e,logger:r.logger,fallback:s})}),groupName:b,wrapAsNullable:t,description:m,availability:w})}if(e.type==="array")return Bbp({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,item:e.items,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,example:Hbp({schema:e,logger:r.logger,fallback:s}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&g0o(e))return Tbp({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,additionalProperties:e.additionalProperties,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,encoding:n,example:e.example,source:a,namespace:u});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?kqs({nameOverride:o,generatedName:g,title:O,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,discriminator:e.discriminator,encoding:n,source:a,namespace:u}):Jqs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:b,encoding:n,source:a,namespace:u});if(e.oneOf!=null&&e.oneOf.length>0){let C=Vf(e,md.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||C?kqs({nameOverride:o,generatedName:g,title:O,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,discriminator:e.discriminator,encoding:n,source:a,namespace:u}):Jqs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:b,encoding:n,source:a,namespace:u});if(e.oneOf.length===1&&e.oneOf[0]!=null){let R=rg(e.oneOf[0],t,r,i,a,u,f);return dpn(R,m,b)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let U=e.oneOf[0],H=e.oneOf[1];if(!rp(U)&&U.type==="null")return rg(H,!0,r,i,a,u);if(!rp(H)&&H.type==="null")return rg(U,!0,r,i,a,u)}let R=N5S({schemas:e.oneOf});if(R!=null)return fti({nameOverride:o,generatedName:g,title:O,fernEnum:void 0,enumVarNames:void 0,enumValues:R,_default:e.default,description:m,availability:w,wrapAsNullable:t,groupName:b,context:r,source:a,inline:void 0});let $=Gbp({schemas:e.oneOf,context:r});if($!=null&&!r.options.discriminatedUnionV2&&!C)return Kqs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:w,wrapAsNullable:t,discriminant:$.discriminant,variants:$.schemas,context:r,groupName:b,encoding:n,source:a,namespace:u});let I=e.oneOf.filter(U=>!rp(U)&&U.type==="null").length>0;return lpn({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,wrapAsNullable:t||I,context:r,subtypes:e.oneOf.filter(U=>rp(U)||U.type!=="null"),encoding:n,groupName:b,source:a,namespace:u})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let $=rg(e.anyOf[0],t,r,i,a,u,f);return dpn($,m,b)}if(e.anyOf.length===2){let[$,I]=e.anyOf;if($!=null&&I!=null){if(!rp($)&&$.type==="null"){let U=rg(I,!0,r,i,a,u);return dpn(U,m,b)}else if(!rp(I)&&I.type==="null"){let U=rg($,!0,r,i,a,u);return dpn(U,m,b)}}}let C=Gbp({schemas:e.anyOf,context:r});if(C!=null&&!r.options.discriminatedUnionV2)return Kqs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:w,wrapAsNullable:t,discriminant:C.discriminant,variants:C.schemas,context:r,groupName:b,encoding:n,source:a,namespace:u});let R=e.anyOf.filter($=>!rp($)&&$.type==="null").length>0;return lpn({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,wrapAsNullable:t||R,context:r,subtypes:e.anyOf.filter($=>rp($)||$.type!=="null"),encoding:n,groupName:b,source:a,namespace:u})}if(e.allOf!=null||e.properties!=null){let C=[];for(let $ of e.allOf??[])(rp($)||Object.keys($).length>0)&&C.push($);if((e.properties==null||g0o(e))&&C.length===1&&C[0]!=null){let $=rg(C[0],t,r,i,a,u,f);return dpn($,m,b)}let R=C.filter($=>{let I=O0o($);return I||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify($)}`),I});if((e.properties==null||g0o(e))&&R.length===1&&R[0]!=null){let $=rg(R[0],t,r,i,a,u,f);return dpn($,m,b)}return Lbp({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},description:m,required:e.required,wrapAsNullable:t,allOf:R,context:r,propertiesToExclude:l,groupName:b,fullExamples:A,additionalProperties:e.additionalProperties,availability:w,encoding:n,source:a,namespace:u})}if(e.type==="object"&&R5S(e)&&F5S(e)&&g0o(e))return h0o({nameOverride:o,generatedName:g,title:O,description:m,availability:w,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${g}Key`,title:void 0,description:void 0,availability:void 0,schema:Xd.string({default:fpn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:G8r({schema:e,logger:r.logger,fallback:s})}),groupName:b},valueSchema:Fl.unknown({nameOverride:void 0,generatedName:`${g}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:b}),groupName:b,encoding:n,example:e.example});if(e.type==null){let C=e.example??e.default;return Fl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:w,groupName:b,example:C})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(i)} value=${JSON.stringify(e)}`)}function z5S(e){if(e!=null){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase();if(t==="true")return!0;if(t==="false")return!1}}}function dti(e){if(e.$ref.startsWith(RSi))return e.$ref.replace(RSi,"")}function Zqs(e,t,r,i){let n=Vf(e,md.TYPE_NAME),a=d2(t,i),u=e.description,l=XBe(e),f=dti(e);if(f==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return ey.reference({generatedName:a,nameOverride:n,title:void 0,schema:f,description:u??void 0,availability:l,groupName:void 0,source:r})}function R5S(e){return e.oneOf==null||e.oneOf.length===0}function F5S(e){return e.allOf==null||e.allOf.length===0}function g0o(e){return e.properties==null||jJ(e.properties)===0}function m0o(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function dpn(e,t,r){return e.type==="reference"?Fl.reference({...e,description:t,availability:e.availability,groupName:r}):e.type==="optional"?Fl.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r,inline:void 0}):e.type==="nullable"?Fl.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r,inline:void 0}):e}function O0o(e){return rp(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>O0o(t)):e.oneOf!=null?e.oneOf.every(t=>O0o(t)):e.anyOf!=null?e.anyOf.every(t=>O0o(t)):!1}function $bp({literal:e,wrapAsNullable:t,groupName:r,description:i,availability:n,nameOverride:a,generatedName:u,title:l}){return t?Fl.nullable({nameOverride:a,generatedName:u,title:l,value:Fl.literal({nameOverride:a,generatedName:u,title:l,value:e,description:i,availability:n,groupName:r}),groupName:r,description:i,availability:n,inline:void 0}):Fl.literal({nameOverride:a,generatedName:u,title:l,value:e,groupName:r,description:i,availability:n})}function i8({primitive:e,wrapAsNullable:t,groupName:r,description:i,availability:n,generatedName:a,nameOverride:u,title:l}){return r=typeof r=="string"?[r]:r,t?Fl.nullable({nameOverride:u,generatedName:a,title:l,value:Fl.primitive({nameOverride:u,generatedName:a,title:l,schema:e,description:i,availability:n,groupName:r}),groupName:r,description:i,availability:n,inline:void 0}):Fl.primitive({nameOverride:u,generatedName:a,title:l,schema:e,description:i,availability:n,groupName:r})}function N5S({schemas:e}){let t=new Set;for(let r of e){if(rp(r))return;if(r.enum!=null&&m0o(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function Gbp({schemas:e,context:t}){let r={};for(let i of e){let n=Qbp({schema:i,context:t});for(let[a,u]of Object.entries(n)){let l=r[a];l!=null?l[u]=i:r[a]={[u]:i}}}for(let[i,n]of Object.entries(r))if(Object.keys(n).length===e.length)return{discriminant:i,schemas:n}}function Qbp({schema:e,context:t}){let r=rp(e)?t.resolveSchemaReference(e):e;return L5S({schema:r,context:t})}function L5S({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=Qbp({schema:i,context:t});for(let[a,u]of Object.entries(n??{}))r[a]=u}return r}for(let[i,n]of Object.entries(e.properties??{})){let a=rp(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&m0o(a.enum)&&U5S(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let u=Jbp(a,"const");a.type==="string"&&u!=null&&(r[i]=u),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function U5S(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 Jbp(e,t){let r=e[t];if(r!=null)return r}function V5S({schema:e,logger:t}){let r=Abp({schema:e,logger:t});if(r!=null)return Ibp(r)}function P0o(e,t){let r={},i={};return e==null?r=t:i={[e]:t},{rootSchemas:r,namespacedSchemas:i}}var Kbp="#/components/messages/",eTs=class{logger;document;taskContext;DUMMY;options;namespace;constructor({document:t,taskContext:r,options:i,namespace:n}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=i,this.namespace=n}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let i=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};i.push(n)}return i.concat(t??[])}resolveSchemaReference(t){if(this.document.components==null||this.document.components.schemas==null||!t.$ref.startsWith(RSi))throw new Error(`Failed to resolve ${t.$ref}`);let i=t.$ref.substring(RSi.length).split("/");if(i[0]==null)throw new Error(`${t.$ref} is undefined`);let n=this.document.components.schemas[i[0]];if(n==null)throw new Error(`${i[0]} is undefined`);if(rp(n)&&(n=this.resolveSchemaReference(n)),i[1]==="properties"&&i[2]!=null){let a=n.properties?.[i[2]];if(a==null)throw new Error(`${t.$ref} is undefined. Property does not exist on object.`);rp(a)?n=this.resolveSchemaReference(a):n=a}return n}resolveMessageReference(t){if(this.document.components==null||this.document.components.messages==null||!t.$ref.startsWith(Kbp))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(Kbp.length),i=this.document.components.messages[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return i}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}},j0o=class extends eTs{constructor({document:t,taskContext:r,options:i,namespace:n}){super({document:t,taskContext:r,options:i,namespace:n})}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,i){}markSchemaWithDiscriminantValue(t,r,i){}};function pti(e){if(typeof e=="string")return A0.primitive(Jp.string(e));if(typeof e=="number")return Number.isInteger(e)?A0.primitive(Jp.int(e)):A0.primitive(Jp.double(e));if(typeof e=="boolean")return A0.primitive(Jp.boolean(e));if(Array.isArray(e)){let t=e.map(r=>pti(r));return t.length===0?void 0:A0.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,i]of Object.entries(e)){let n=pti(i);n!=null&&t.push({key:Jp.string(r),value:n})}return A0.map(t)}}function Pkn(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function Ybp(e){if(e!=null&&Array.isArray(e))return e}var _ti=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,i){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=i}buildExample({schema:t,exampleId:r,example:i,options:n,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:i,options:{...n,maxCheckerDepth:n.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:i,depth:n,visitedSchemaIds:a,options:u,skipReadonly:l}){switch(i.type){case"enum":return typeof r=="string"&&Xbp({schema:i,value:r})?A0.enum(r):i.values[0]!=null?A0.enum(i.values[0]?.value):void 0;case"literal":return A0.literal(i.value);case"nullable":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u)))return;let f=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:l});return f!=null&&f.type==="array"&&f.value.length===0||f!=null&&f.type==="map"&&f.value.length===0||f!=null&&f.type==="object"&&Object.keys(f.properties).length===0?void 0:f}case"optional":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u))||Object.is(r,null))return;let f=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:l});return f!=null&&f.type==="array"&&f.value.length===0||f!=null&&f.type==="map"&&f.value.length===0||f!=null&&f.type==="object"&&Object.keys(f.properties).length===0?void 0:f}case"primitive":{let f=this.buildExampleFromPrimitive({schema:i.schema,example:r,options:u});return A0.primitive(f)}case"reference":{let f=this.schemas[i.schema];if(f!=null&&!a.has(i.schema)){a.add(i.schema);let s=f?.type==="object"&&!this.nonRequestReferencedSchemas.has(i.schema),o=this.buildExampleHelper({example:r,schema:f,exampleId:t,visitedSchemaIds:a,depth:n,options:u,skipReadonly:s||this.context.options.respectReadonlySchemas?l:!1});return a.delete(i.schema),o}return}case"oneOf":switch(i.value.type){case"discriminated":{let f={},s={},o={},c=Pkn(r),b=c?.[i.value.discriminantProperty],g=i.value.schemas[b],O=[],m=this.getDiscriminatedUnionVariantSchema(i.value,c);m!=null&&O.push(m),O.push(...Object.entries(i.value.schemas));for(let w of O)if(b!=null&&g!=null&&g.type==="object"){s=this.getAllProperties(g),o=this.getAllRequiredProperties(g),f[i.value.discriminantProperty]=A0.primitive(Jp.string(b));break}else{let A=this.buildExampleHelper({exampleId:t,schema:w[1],example:void 0,visitedSchemaIds:a,depth:n,options:u,skipReadonly:l});if(A!=null){this.mergeExampleWith(A,f),f[i.value.discriminantProperty]=A0.primitive(Jp.string(w[0]));break}}for(let w of i.value.commonProperties){s[w.key]={schema:w.schema,readonly:!1};let A=this.getResolvedSchema(w.schema);A.type!=="optional"&&A.type!=="nullable"&&(o[w.key]=w.schema)}for(let[w,A]of Object.entries(s)){let M=w in o;if(M&&c?.[w]!=null){let q=this.buildExampleHelper({schema:A.schema,exampleId:t,example:c[w],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});if(q!=null)f[w]=q;else return}else{let q=this.buildExampleHelper({exampleId:t,schema:A.schema,example:c?.[w],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});if(q!=null)f[w]=q;else if(M)return}}return A0.oneOf(Mei.discriminated(f))}case"undiscriminated":{let f=this.getUnDiscriminatedUnionVariantSchema(i.value,r);if(f!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:f,visitedSchemaIds:a,depth:n,options:u,skipReadonly:l});break}}return;case"unknown":if(r!=null){let f=pti(r);if(f!=null)return A0.unknown(f)}return u.ignoreOptionals||this.exceedsMaxDepth(n,u)?void 0:u.isParameter?A0.primitive(Jp.string(u.name??"string")):A0.map([{key:Jp.string("key"),value:A0.primitive(Jp.string("value"))}]);case"array":{let f=Ybp(r),s=[];if(f!=null&&f.length>0)for(let o of f){let c=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});c!=null&&s.push(c)}else if(i.example!=null&&i.example.length>0)for(let o of i.example){let c=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});c!=null&&s.push(c)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});o!=null&&s.push(o)}return A0.array(s)}case"map":{let f=Pkn(r??i.example);if(f!=null&&Object.entries(f).length>0){let c=[];for(let[b,g]of Object.entries(f)){let O=this.buildExampleFromPrimitive({schema:i.key.schema,example:b,options:u}),m=this.buildExampleHelper({exampleId:t,example:g,schema:i.value,visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});m!=null&&c.push({key:O,value:m})}return A0.map(c)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return A0.map([{key:Jp.string("key"),value:A0.unknown(A0.primitive(Jp.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:i.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,visitedSchemaIds:a,depth:n+1,options:{...u,name:"value"},skipReadonly:l});return o!=null?A0.map([{key:s,value:o}]):A0.map([])}case"object":{let f={},s=i.fullExamples?.find(g=>g.name===t)??i.fullExamples?.find(g=>g.name==null)??i.fullExamples?.[0],o=Pkn(r)??(s!=null?Pkn(s.value):{})??{},c=this.getAllProperties(i),b=this.getAllRequiredProperties(i);for(let[g,O]of Object.entries(c)){if(l&&O.readonly)continue;let m=g in b,w=Object.keys(o).includes(g),A=this.buildExampleHelper({schema:O.schema,exampleId:t,example:o[g],visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:l});if(m&&A!=null)f[g]=A;else{if(m)return;(w&&A!=null||!u.ignoreOptionals&&A!=null)&&(f[g]=A)}}if(i.additionalProperties){for(let[g,O]of Object.entries(o))if(!(g in f)){let m=this.buildExampleHelper({schema:Fl.unknown({example:O,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,groupName:void 0}),exampleId:t,example:O,visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:l});m!=null&&(f[g]=m)}}return A0.object({properties:f})}default:Zo(i)}}mergeExampleWith(t,r){t._visit({array:Yo,enum:Yo,literal:Yo,map:i=>{for(let n of i){let a=n.key;a.type==="string"&&(r[a.value]=n.value)}},object:i=>{for(let[n,a]of Object.entries(i.properties))r[n]=a},oneOf:i=>{if(i.type==="discriminated")for(let[n,a]of Object.entries(i.value))r[n]=a;else this.mergeExampleWith(i.value,r)},primitive:Yo,unknown:Yo,_other:Yo})}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let i=r?.[t.discriminantProperty];if(i==null||typeof i!="string")return Object.entries(t.schemas)[0];let n=t.schemas[i];return n==null?Object.entries(t.schemas)[0]:[i,n]}getUnDiscriminatedUnionVariantSchema(t,r){return r==null?t.schemas[0]:t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,u)=>u.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return Xbp({schema:t,value:r})?5:0;case"object":{if(!Dj(r))return 0;let i=this.getAllProperties(t),n=0;for(let[a,u]of Object.entries(i))r[a]!=null?(n++,n+=this.calcExampleHeuristic(u.schema,r[a])):n--;return n}case"array":{if(!Array.isArray(r))return 0;let i=0;for(let n of r)i+=this.calcExampleHeuristic(t.value,n);return i}case"map":{if(!Dj(r))return 0;let i=0;for(let[,n]of Object.entries(r))i+=this.calcExampleHeuristic(t.value,n);return i}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let i=this.getResolvedSchema(t);return i==null?0:this.calcExampleHeuristic(i,r)}case"oneOf":return Object.values(t.value.schemas).map(n=>this.calcExampleHeuristic(n,r)).sort((n,a)=>a-n)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,i=new Set,n){if(this.exceedsMaxCheckerDepth(r,n))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,i,n);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,i,n);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let u of t.properties)if(this.hasExample(u.schema,r+1,i,n))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!i.has(t.schema)){i.add(t.schema);let u=this.hasExample(a,r,i,n);return i.delete(t.schema),u}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,i,n));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let i of t.properties)r[i.key]={schema:i.schema,readonly:i.readonly??!1};for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let i of t.properties){let n=this.getResolvedSchema(i.schema);n.type!=="optional"&&n.type!=="nullable"&&(r[i.key]=i.schema)}for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:i}){switch(r.type){case"string":return t!=null&&typeof t=="string"?Jp.string(t):r.example!=null?Jp.string(r.example):Jp.string(i.name??X0.STRING);case"base64":return t!=null&&typeof t=="string"?Jp.base64(t):r.example!=null?Jp.base64(r.example):Jp.base64(X0.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?Jp.boolean(t):r.example!=null?Jp.boolean(r.example):Jp.boolean(X0.BOOLEAN);case"date":return t!=null&&typeof t=="string"?Jp.date(t):r.example!=null?Jp.date(r.example):Jp.date(X0.DATE);case"datetime":return t!=null&&typeof t=="string"?Jp.datetime(t):r.example!=null?Jp.datetime(r.example):Jp.datetime(X0.DATE_TIME);case"double":return t!=null&&typeof t=="number"?Jp.double(t):r.example!=null?Jp.double(r.example):Jp.double(X0.DOUBLE);case"float":return t!=null&&typeof t=="number"?Jp.float(t):r.example!=null?Jp.float(r.example):Jp.float(X0.FLOAT);case"int":return t!=null&&typeof t=="number"?Jp.int(t):r.example!=null?Jp.int(r.example):Jp.int(X0.INT);case"int64":return t!=null&&typeof t=="number"?Jp.int64(t):r.example!=null?Jp.int64(r.example):Jp.int64(X0.INT64);case"uint":return t!=null&&typeof t=="number"?Jp.uint(t):r.example!=null?Jp.uint(r.example):Jp.uint(X0.UINT);case"uint64":return t!=null&&typeof t=="number"?Jp.uint64(t):r.example!=null?Jp.uint64(r.example):Jp.uint64(X0.UINT64);default:Zo(r)}}};function Xbp({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function gQt(e){switch(e.type){case"object":return Fl.object({allOf:e.allOf,properties:e.properties.map(t=>H5S(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,inline:void 0});case"array":return Fl.array({description:e.description,availability:e.availability,value:gQt(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return Fl.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,inline:void 0});case"literal":return Fl.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 Fl.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:gQt(e.value),groupName:e.groupName,inline:void 0});case"optional":return Fl.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:gQt(e.value),groupName:e.groupName,inline:void 0});case"primitive":return Fl.primitive({description:e.description,availability:e.availability,schema:Zbp(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return Fl.map({description:e.description,availability:e.availability,key:Fl.primitive({description:e.key.description,availability:e.key.availability,schema:Zbp(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:gQt(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return Fl.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 Fl.oneOf(W5S(e.value));case"unknown":return Fl.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,groupName:void 0,description:void 0,availability:void 0});default:Zo(e)}}function W5S(e){switch(e.type){case"discriminated":return dK.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:gQt(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,gQt(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return dK.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>gQt(t)),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:Zo(e)}}function Zbp(e){switch(e.type){case"string":return Xd.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return Xd.base64({example:void 0});case"boolean":return Xd.boolean({default:e.default,example:void 0});case"date":return Xd.date({example:void 0});case"datetime":return Xd.datetime({example:void 0});case"double":return Xd.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 Xd.float({example:void 0});case"int":return Xd.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 Xd.int64({default:e.default,example:void 0});case"uint":return Xd.uint({default:void 0,example:void 0});case"uint64":return Xd.uint64({default:void 0,example:void 0});default:Zo(e)}}function H5S(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:gQt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly}}function w0o(e){return e.type!=="optional"&&e.type!=="nullable"}function tTs(e){return e==="POST"||e==="PUT"||e==="PATCH"}function jkn(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 S0o=class{schemas;context;exampleTypeFactory;logger;constructor(t,r){this.schemas=t,this.context=r,this.schemas=t,this.exampleTypeFactory=new _ti(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=G5S(t.request),i=Q5S(t.response);if(r?.type==="unsupported"||i?.type==="unsupported")return[];let n=[];if(r!=null&&r.type==="present"){let c=this.isSchemaRequired(r.schema);if(r.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:tTs(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});b!=null&&n.push([void 0,b])}else for(let{name:b,value:g}of r.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:tTs(t.method),schema:r.schema,exampleId:b,example:g,options:{isParameter:!1,ignoreOptionals:!0}});O!=null&&n.push([b,O])}if(c&&n.length===0)return this.logger.trace(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(i!=null&&i.type==="present"){let c=this.isSchemaRequired(i.schema);if(t.response?.type==="json"&&t.response.statusCode===204)a.push([void 0,LBe.withoutStreaming(A0.object({properties:{}}))]);else if(i.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:void 0,example:void 0,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});b!=null&&(t.response?.type==="json"?a.push([void 0,LBe.withoutStreaming(b)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,LBe.withStreaming({sse:t.response?.type==="streamingSse",events:[b]})]))}else for(let{name:b,value:g}of i.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:b,example:g,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});O!=null&&(t.response?.type==="json"?a.push([b,LBe.withoutStreaming(O)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,LBe.withStreaming({sse:t.response?.type==="streamingSse",events:[O]})]))}if(c&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let c of t.pathParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!OQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for path parameter ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&u.push({name:c.name,parameterNameOverride:c.parameterNameOverride,value:g})}let l=[];for(let c of t.queryParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!OQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for query parameter ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&l.push({name:c.name,value:g})}let f=[];for(let c of t.headers){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!OQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for header ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&f.push({name:c.name,value:g})}let s=[];t.request!=null&&t.response!=null?s=$5S(n,a):t.request!=null?s=n.map(([c,b])=>({id:c,request:b,response:void 0})):t.response!=null&&(s=a.map(([c,b])=>({id:c,request:void 0,response:b})));let o=t.examples.filter(c=>jkn(c)).flatMap(c=>{if(c.type==="unknown"){if(c.value!=null){let b=c.value["code-samples"];if(b!=null)return this.convertCodeSamples(b)}return}else return c.codeSamples}).filter(c=>dg(c));return s.length===0?[L2t.full({name:void 0,description:void 0,pathParameters:u,queryParameters:l,headers:f,request:void 0,response:void 0,codeSamples:o})]:s.map(({id:c,request:b,response:g})=>L2t.full({name:c,description:void 0,pathParameters:u,queryParameters:l,headers:f,request:b,response:g,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?C8r.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):C8r.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?QL.Csharp:r.sdk,code:r.code})).filter(dg)}isSchemaRequired(t){return w0o(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function $5S(e,t){let r=[];if(e.length<=1){let[n,a]=e[0]??[];if(t.length===0)return r.push({id:n,request:a,response:void 0}),r;for(let[u,l]of t)r.push({id:u??n,request:a,response:l});return r}if(t.length<=1){let[n,a]=t[0]??[];if(t.length===0)return r.push({id:n,request:void 0,response:a}),r;for(let[u,l]of e)r.push({id:u??n,request:l,response:a});return r}let i=new Set;for(let[n,a]of e){let u=t.find(([f])=>f==null)?.[1]??t[0]?.[1];if(n==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let l=!1;for(let f=0;f<t.length;f++){let[s,o]=t[f];s==null||i.has(f)||n===s&&(r.push({id:n,request:a,response:o}),s!=null&&i.add(f),l=!0)}!l&&u!=null&&r.push({id:n,request:a,response:u})}for(let n=0;n<t.length;n++){if(i.has(n))continue;let[a,u]=t[n],l=e.find(([f])=>f==null)?.[1]??e[0]?.[1];l!=null&&r.push({id:a,request:l,response:u})}return r}function G5S(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:J5S(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function Q5S(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"&&e.type!=="streamingSse"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function OQt(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return OQt(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return OQt(e.value.value);default:return!1}default:Zo(e)}}function J5S(e){return Fl.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:gQt(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,inline:void 0}).filter(dg),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,inline:void 0})}var D0o=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new _ti(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,publish:i,subscribe:n,handshake:a,source:u,namespace:l}){let f=[];for(let s of r){let o=[];for(let g of a.queryParameters){let O=this.isSchemaRequired(g.schema),m=this.exampleTypeFactory.buildExample({schema:g.schema,exampleId:void 0,example:s.queryParameters?.[g.name],options:{name:g.name,isParameter:!0,ignoreOptionals:!0}});m!=null&&!OQt(m)&&(m=void 0),!(O&&m==null)&&m!=null&&o.push({name:g.name,value:m})}let c=[];for(let g of a.headers){let O=this.isSchemaRequired(g.schema),m=this.exampleTypeFactory.buildExample({schema:g.schema,exampleId:void 0,example:s.headers?.[g.name],options:{name:g.name,isParameter:!0,ignoreOptionals:!0}});m!=null&&!OQt(m)&&(m=void 0),!(O&&m==null)&&m!=null&&c.push({name:g.name,value:m})}let b=[];for(let g of s.messages){let O=t.resolveMessageReference({$ref:`#/components/messages/${g.messageId}`}),m=rp(O.payload)?t.resolveSchemaReference(O.payload):O.payload,w=this.exampleTypeFactory.buildExample({schema:rg(m,!1,t,[g.messageId],u,l),exampleId:void 0,example:g.value,options:{isParameter:!1,ignoreOptionals:!0}});w!=null&&b.push({messageType:g.type,payload:w,description:void 0})}f.push({name:s.summary,queryParameters:o,headers:c,description:s.description,messages:b})}return f}buildWebsocketSessionExample({publish:t,subscribe:r,handshake:i}){let n={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},a=[];for(let l of i.queryParameters){let f=this.isSchemaRequired(l.schema),s=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(s!=null&&!OQt(s)&&(s=void 0),f&&s==null)return;s!=null&&a.push({name:l.name,value:s})}let u=[];for(let l of i.headers){let f=this.isSchemaRequired(l.schema),s=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(s!=null&&!OQt(s)&&(s=void 0),f&&s==null)return;s!=null&&u.push({name:l.name,value:s})}if(t!=null){let l=this.exampleTypeFactory.buildExample({schema:t,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});l!=null&&n.messages.push({messageType:"publish",payload:l,description:void 0})}if(r!=null){let l=this.exampleTypeFactory.buildExample({schema:r,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});l!=null&&n.messages.push({messageType:"subscribe",payload:l,description:void 0})}return n}isSchemaRequired(t){return w0o(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 ppn={FERN_DISPLAY_NAME:"x-fern-display-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",IGNORE:"x-fern-ignore"};function kbp(e){return Vf(e,ppn.FERN_EXAMPLES)??[]}function t0p({document:e,taskContext:t,options:r,source:i,asyncApiOptions:n,namespace:a}){let u=[];a!=null&&u.push(a),e.tags?.[0]!=null?u.push(e.tags[0].name):n.naming!=="v2"&&u.push("websocket");let l=new j0o({document:e,taskContext:t,options:r,namespace:a}),f={},s;for(let[c,b]of Object.entries(e.components?.schemas??{})){let g=rg(b,!1,l,[c],i,a);f[c]=g}let o=new D0o(f,l);for(let[c,b]of Object.entries(e.channels??{})){let g=Vf(b,ppn.IGNORE);if(g!=null&&g){l.logger.debug(`Channel ${c} is marked with x-fern-ignore. Skipping.`);continue}if(b.bindings?.ws==null){l.logger.error(`Channel ${c} does not have websocket bindings. Skipping.`);continue}let O=[];if(b.parameters!=null)for(let[q,D]of Object.entries(b.parameters??{}))O.push({name:q,description:D.description,parameterNameOverride:void 0,schema:D.schema!=null?rg(D.schema,!1,l,u,i,a):Fl.primitive({schema:Xd.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:XBe(D),source:i});let m=[];if(b.bindings.ws.headers!=null){let q=b.bindings.ws.headers.required??[];for(let[D,C]of Object.entries(b.bindings.ws.headers.properties??{})){let R=rp(C)?l.resolveSchemaReference(C):C;m.push({name:D,schema:rg(R,!q.includes(D),l,u,i,a),description:R.description,parameterNameOverride:void 0,env:void 0,availability:XBe(R),source:i})}}let w=[];if(b.bindings.ws.query!=null){let q=b.bindings.ws.query.required??[];for(let[D,C]of Object.entries(b.bindings.ws.query.properties??{})){let R=rp(C)?l.resolveSchemaReference(C):C;w.push({name:D,schema:rg(R,!q.includes(D),l,u,i,a),description:R.description,parameterNameOverride:void 0,availability:XBe(R),source:i})}}let A;b.publish!=null&&(A=e0p({generatedName:b.publish.operationId??"PublishEvent",event:b.publish,breadcrumbs:u,context:l,source:i,options:r,asyncApiOptions:n}));let M;if(b.subscribe!=null&&(M=e0p({generatedName:b.subscribe.operationId??"SubscribeEvent",event:b.subscribe,breadcrumbs:u,context:l,source:i,options:r,asyncApiOptions:n})),m.length>0||w.length>0||A!=null||M!=null){let q=kbp(b),D=[];if(q.length>0)D=o.buildWebsocketSessionExamplesForExtension({context:l,extensionExamples:q,handshake:{headers:m,queryParameters:w},publish:A,subscribe:M,source:i,namespace:a});else{let R=o.buildWebsocketSessionExample({handshake:{headers:m,queryParameters:w},publish:A,subscribe:M});R!=null&&D.push(R)}let C=e.tags?.[0]?.name!=null?[e.tags?.[0].name]:void 0;s={audiences:Vf(b,md.AUDIENCES)??[],handshake:{headers:m.map(R=>({...R,schema:Dq(R.schema),env:R.env})),queryParameters:w.map(R=>({...R,schema:Dq(R.schema)})),pathParameters:O.map(R=>({...R,parameterNameOverride:void 0,schema:Dq(R.schema)}))},groupName:l.resolveTags(C,"Websocket"),publish:A!=null?Dq(A):A,subscribe:M!=null?Dq(M):M,summary:Vf(b,ppn.FERN_DISPLAY_NAME),path:c,description:void 0,examples:D,source:i};break}}return{groupedSchemas:P0o(a,f),channel:s,basePath:Vf(e,ppn.BASE_PATH)}}function e0p({generatedName:e,event:t,context:r,breadcrumbs:i,source:n,options:a,asyncApiOptions:u}){if(t.message.oneOf!=null){let l=[],f=[];for(let s of t.message.oneOf){let o,c={type:"notFound"};if(rp(s)){let b=r.resolveMessageReference(s);!rp(b.payload)&&u.naming==="v2"?(c=b.name?{type:"name",name:b.name}:c,o={...b.payload,title:b.name??b.payload.title,description:b.name??b.payload.description}):o=b.payload}else o=s;f.push(c),l.push(o)}return lpn({description:t.description??t.message.description,availability:XBe(t.message),subtypes:l,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:i,context:r,encoding:void 0,source:n,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?f:[]})}}function r0p(e){let t=K5S(e),r={};return rTs({obj:t,occurrences:r,breadcrumbs:[]}),r}function rTs({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let i of e)rTs({obj:i,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let i=e.$ref;t[i]==null?t[i]=1:t[i]+=1;return}for(let i in e)rTs({obj:e[i],occurrences:t,breadcrumbs:[...r,i]})}}}function K5S(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?wkn(r.get):void 0,put:r?.put!=null?wkn(r.put):void 0,post:r?.post!=null?wkn(r.post):void 0,patch:r?.patch!=null?wkn(r.patch):void 0,delete:r?.delete!=null?wkn(r.delete):void 0}]))}}function wkn(e){return{...e,requestBody:e.requestBody!=null?rp(e.requestBody)?e.requestBody:Y5S(e.requestBody):void 0}}function Y5S(e){let t,r;for(let i in e.content){let n=aB.parse(i);n!=null&&(n.isJSON()?t=e.content[i]:n.isMultipart()&&(r=e.content[i]))}return r!=null&&t!=null?{...e,content:{[aB.MULTIPART_FORM_DATA]:r}}:e}var E0o=class{endpoints;parser=new OPi;constructor({context:t,options:r}){this.endpoints=r.filter?.endpoints?new Set(this.validateAndFilterEndpoints({context:t,endpoints:r.filter.endpoints})):void 0}skipEndpoint({method:t,path:r}){return this.endpoints!=null&&!this.endpoints.has(`${t} ${r}`)}hasEndpoints(){return this.endpoints!=null}validateAndFilterEndpoints({context:t,endpoints:r}){let i=[];for(let n of r){let a=this.parser.tryParse(n);if(a==null){t.logger.debug(`Ignoring configured filter endpoint "${n}"; expected format "POST /users/get"`);continue}i.push(`${a.method} ${a.path}`)}return i}};var i0p="#/components/parameters/",n0p="#/components/responses/",a0p="#/components/examples/",o0p="#/components/requestBodies/",_pn=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=i,this.refOccurrences=r0p(t),this.options=n,this.source=a,this.filter=new E0o({context:r,options:n}),this.DUMMY=this.getDummy(),this.namespace=u}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};r.push(i)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return{"x-fern-type":"unknown"};i=i[n]}return i==null?(this.logger.warn(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):(rp(i)&&(i=this.resolveSchemaReference(i)),i)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(i0p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(i0p.length),i=this.document.components.parameters[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return rp(i)?this.resolveParameterReference(i):i}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(o0p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(o0p.length),i=this.document.components.requestBodies[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return rp(i)?this.resolveRequestBodyReference(i):i}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(n0p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(n0p.length),i=this.document.components.responses[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return rp(i)?this.resolveResponseReference(i):i}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(a0p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(a0p.length),i=this.document.components.examples[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return rp(i)?this.resolveExampleReference(i):i}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}};var hpn=class extends _pn{constructor({document:t,taskContext:r,options:i,source:n,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:i,source:n,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,i){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,i){}getDiscriminatedUnionMetadata(t){}};var A0o=class extends _pn{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discriminatedUnionReferences={};discriminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u})}getDummy(){return new hpn({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,i){let n=this.discriminatedUnionReferences[t.$ref];n!=null?(n.discriminants.add(r),n.numReferences+=i):this.discriminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:i}}getReferencesFromDiscriminatedUnion(t){return this.discriminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,i){let n=this.discriminatedUnionMetadata[t.$ref];n!=null?n.discriminants.set(r,i):this.discriminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,i]])}}getDiscriminatedUnionMetadata(t){return this.discriminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function u0p(e){return Vf(e,md.ASYNC_CONFIG)}var s0p="$request.";function c0p(e){let t=Vf(e,md.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:X5S(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function X5S(e){return e.startsWith(s0p)?e.slice(s0p.length):e}function l0p(e){let t=e;if(t.cursor!=null)return T8r.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});let r=e;return T8r.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}function f0p(e,t){let r=Vf(t,md.PAGINATION);if(r!=null){if(typeof r=="boolean"){let i=Vf(e,md.PAGINATION);if(typeof i=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return i==null?void 0:l0p(i)}return l0p(r)}}var Z5S=Vs.object({lang:Vs.string(),label:Vs.optional(Vs.string()),source:Vs.string()}),iTs=Vs.array(Z5S);var d0p={README_EXT:"x-readme"};function k5S(e){if(!Array.isArray(e))return!1;for(let t of e)if(!Dj(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function p0p(e){let t=Vf(e,d0p.README_EXT);if(!Dj(t))return[];let r=t["code-samples"];if(!k5S(r))return[];let i=[];for(let n of r)i.push({name:n.name,language:n.language,code:n.code,install:n.install,docs:void 0});return i}function _0p(e,t,r){let n=(Vf(t,md.EXAMPLES)??[]).filter(s=>{let o=lH.serialization.ExampleEndpointCallSchema.parse(s);return o.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),o.ok}),a=Okn(t,Uwe.REDOCLY_CODE_SAMPLES_KEBAB,iTs,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],l=[...Okn(t,Uwe.REDOCLY_CODE_SAMPLES_CAMEL,iTs,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];l.length>0&&n.push({"code-samples":l.map(s=>({name:s.label??s.lang,language:s.lang,code:s.source,install:void 0,docs:void 0}))});let f=p0p(t);return f.length>0&&n.push({"code-samples":f}),n.map(L2t.unknown)}function h0p(e){let t=Vf(e,md.AVAILABILITY);if(t==="ga"||t==="generally-available")return GL.GenerallyAvailable;if(t==="beta"||t==="pre-release")return GL.Beta;if(t==="deprecated")return GL.Deprecated;if(e.deprecated)return GL.Deprecated}function M0o(e){return{url:e9S({url:e.url,variables:e.variables??{}}),description:e.description,name:t9S(e),audiences:Vf(e,md.AUDIENCES)}}function e9S({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,n.default]));for(let[i,n]of Object.entries(r))e=e.replace(`{${i}}`,n);return e}function t9S(e){let t=Vf(e,[md.SERVER_NAME_V1,md.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function y0p(e){return Vf(e,md.PARAMETER_NAME)}function v0p(e){return Vf(e,md.SDK_VARIABLE)}function q0o({path:e,httpMethod:t,parameters:r,context:i,requestBreadcrumbs:n,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let l of r){let f=Vf(l,md.IGNORE);if(f!=null&&f){i.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=rp(l)?i.resolveParameterReference(l):l,o=s.required??!1,c=XBe(s),b=[...n,s.name],g=d2(b,i.options.preserveSchemaIds),O=s.schema!=null?rg(s.schema,!o,i,b,a,i.namespace,!1,new Set,G8r({schema:s,logger:i.logger})):o?Fl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:G8r({schema:s,logger:i.logger})}),description:void 0,availability:c,groupName:void 0}):Fl.optional({nameOverride:void 0,generatedName:g,title:void 0,value:Fl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:G8r({schema:s,logger:i.logger})}),description:void 0,availability:void 0,groupName:void 0}),description:void 0,availability:c,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!rp(s.schema)&&s.schema.default!=null){let w=s.schema.default;typeof w=="string"&&w.length>0&&(O=Fl.literal({nameOverride:void 0,generatedName:g,title:void 0,value:bB.string(w),description:void 0,availability:c,groupName:void 0}))}let m={name:s.name,schema:O,description:s.description,parameterNameOverride:y0p(s),availability:c,source:a};s.in==="query"?u.queryParameters.push(m):s.in==="path"?u.pathParameters.push({...m,variableReference:v0p(s)}):s.in==="header"?!r9S.has(s.name.toLowerCase())&&!i.authHeaders.has(s.name)?u.headers.push({...m,env:void 0}):i.logger.debug(`Ignoring ${s.name} header, in ${t.toUpperCase()} ${e}`):i.logger.warn(`Skipping ${s.in} parameter, ${s.name}, in ${t.toUpperCase()} ${e}`)}return u}var r9S=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function b0p(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r,schema:n??{},examples:Skn(i,t)}}}function ypn(e,t){for(let r of Object.keys(e))if(r.includes("json")||r==="*/*"){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r.includes("*")?void 0:r,schema:n??{},examples:Skn(i,t)}}}function g0p(e,t){for(let r of Object.keys(e)){let i=e[r];if(i==null)continue;return{schema:i.schema??{},examples:Skn(i,t)}}}function Skn(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let i=Vf(e,Uwe.EXAMPLES);return i!=null&&Object.keys(i).length>0&&r.push(...Object.entries(i).map(([n,a])=>({name:a.summary??n,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([n,a])=>{let u=rp(a)?t.resolveExampleReference(a):a;return{name:u.summary??n,value:u.value,description:u.description}})),r}function i9S(e,t){for(let[r,i]of Object.entries(e.content))if(aB.parse(r)?.isURLEncoded())return{schema:i.schema,contentType:r,examples:Skn(i,t)}}function n9S(e){for(let[t,r]of Object.entries(e.content))if(aB.parse(t)?.isMultipart())return{schema:r.schema,encoding:r.encoding}}function a9S(e){for(let t in e.content)if(aB.parse(t)?.isOctetStream())return!0;return!1}function o9S(e,t){let r=rp(e)?nTs(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([i,n])=>!rp(n)&&n.type==="string"&&n.format==="binary")!=null}function vpn({requestBody:e,document:t,context:r,requestBreadcrumbs:i,source:n,namespace:a}){let u=rp(e)?r.resolveRequestBodyReference(e):e,l=n9S(u),f=l?.schema,s=l?.encoding,o=i9S(u,r),c=ypn(u.content,r);if(a9S(u))return Iwe.octetStream({description:u.description,source:n});if(f!=null&&c==null||f!=null&&o9S(f,t)){let b=rp(f)?nTs(f,t):{id:void 0,schema:f},g=rg(b.schema,!1,r,i,n,a),O=[];if(g.type==="object")for(let m of g.properties){if(m.schema.type==="primitive"&&m.schema.schema.type==="string"&&m.schema.schema.format==="binary"){O.push({key:m.key,schema:UBe.file({isOptional:!1,isArray:!1}),description:m.schema.description,contentType:s?.[m.key]?.contentType});continue}if(m.schema.type==="optional"&&m.schema.value.type==="primitive"&&m.schema.value.schema.type==="string"&&m.schema.value.schema.format==="binary"){O.push({key:m.key,schema:UBe.file({isOptional:!0,isArray:!1}),description:m.schema.description,contentType:s?.[m.key]?.contentType});continue}if(m.schema.type==="array"&&m.schema.value.type==="primitive"&&m.schema.value.schema.type==="string"&&m.schema.value.schema.format==="binary"){O.push({key:m.key,schema:UBe.file({isOptional:!1,isArray:!0}),description:m.schema.description,contentType:s?.[m.key]?.contentType});continue}if(m.schema.type==="optional"&&m.schema.value.type==="array"&&m.schema.value.value.type==="primitive"&&m.schema.value.value.schema.type==="string"&&m.schema.value.value.schema.format==="binary"){O.push({key:m.key,schema:UBe.file({isOptional:!0,isArray:!0}),description:m.schema.description,contentType:s?.[m.key]?.contentType});continue}O.push({key:m.key,schema:UBe.json(m.schema),description:void 0,contentType:s?.[m.key]?.contentType})}return Iwe.multipart({name:rp(f)&&r.getNumberOfOccurrencesForRef(f)===1?b.id:void 0,description:b.schema.description,properties:O,source:n})}if(c!=null){let b=rg(c.schema,!1,r,i,n,a,!0);return Iwe.json({description:void 0,schema:b,contentType:c.contentType,fullExamples:c.examples,additionalProperties:!rp(c.schema)&&upn(c.schema.additionalProperties),source:n})}if(o!=null&&o.schema!=null){let b=rg(o.schema,!1,r,i,n,a);return Iwe.json({schema:b,description:u.description,contentType:o.contentType,source:n,fullExamples:o.examples,additionalProperties:!1})}}function nTs(e,t){if(!e.$ref.startsWith(RSi))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=dti(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let i=t.components?.schemas?.[r];if(i==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return rp(i)?nTs(i,t):{id:r,schema:i}}var aTs={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"},O0p=new Set(Object.values(aTs));var u9S=["200","201","202","204"];function P0p({operationContext:e,responses:t,context:r,responseBreadcrumbs:i,responseStatusCode:n,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let l=s9S({responses:t,context:r,source:u,namespace:r.namespace}),f=!1,s;for(let o of n!=null?[n]:u9S){let c=t[o];c!=null&&(f=!0,s==null&&(s=m0p({operationContext:e,response:c,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace,statusCode:typeof o=="string"?parseInt(o):o})))}if(s==null&&!f&&t.default!=null&&(s=m0p({operationContext:e,response:t.default,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:l};case"streamingJson":case"streamingSse":return{value:s,errors:l};case"file":case"text":case"streamingText":return{value:s,errors:l};default:Zo(s)}return{value:void 0,errors:l}}function m0p({operationContext:e,streamFormat:t,response:r,context:i,responseBreadcrumbs:n,source:a,namespace:u,statusCode:l}){let f=rp(r)?i.resolveResponseReference(r):r;if(f.content!=null&&Object.entries(f.content).find(([b,g])=>{if(g.schema==null)return!1;let O=rp(g.schema)?i.resolveSchemaReference(g.schema):g.schema;return O.type==="string"&&O.format==="binary"}))return gB.file({description:f.description,source:a,statusCode:l});let s=b0p(f.content??{},i);if(s!=null&&t!=null)switch(t){case"json":return gB.streamingJson({statusCode:l,description:f.description,responseProperty:Vf(e.operation,md.RESPONSE_PROPERTY),fullExamples:s.examples,schema:rg(s.schema,!1,i,n,a,u),source:a});case"sse":return gB.streamingSse({description:f.description,responseProperty:void 0,fullExamples:s.examples,schema:rg(s.schema,!1,i,n,a,u),source:a,statusCode:l})}let o=ypn(f.content??{},i);if(o!=null){if(t!=null)switch(t){case"json":return gB.streamingJson({description:f.description,responseProperty:void 0,fullExamples:o.examples,schema:rg(o.schema,!1,i,n,a,u),source:a,statusCode:l});case"sse":return gB.streamingSse({description:f.description,responseProperty:void 0,fullExamples:o.examples,schema:rg(o.schema,!1,i,n,a,u),source:a,statusCode:l})}return gB.json({description:f.description,schema:rg(o.schema,!1,i,n,a,u),responseProperty:Vf(e.operation,md.RESPONSE_PROPERTY),fullExamples:o.examples,source:a,statusCode:l})}for(let[c,b]of Object.entries(f.content??{})){let g=aB.parse(c);if(g!=null){if(g.isOctetStream()||g.isPDF()||g.isAudio()||g.isImage()||g.isVideo())return gB.file({description:f.description,source:a,statusCode:l});if(g.isPlainText()){let O=b.schema;if(O==null)return gB.text({description:f.description,source:a,statusCode:l});let m=rp(O)?i.resolveSchemaReference(O):O;return m.type==="string"&&m.format==="byte"?gB.file({description:f.description,source:a,statusCode:l}):gB.text({description:f.description,source:a,statusCode:l})}}}}function s9S({responses:e,context:t,source:r,namespace:i}){let n={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let l=parseInt(a);if(l<400||l>600)continue;let f=rp(u)?t.resolveResponseReference(u):u,s=g0p(f.content??{},t),o=aTs[l];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}n[l]={statusCode:l,nameOverride:void 0,generatedName:o,description:f.description,schema:rg(s?.schema??{},!1,t,[o,"Body"],r,i),fullExamples:s?.examples,source:r}}return n}function Q8r({operationContext:e,context:t,responseStatusCode:r,suffix:i,streamFormat:n,source:a}){let{document:u,operation:l,path:f,method:s,baseBreadcrumbs:o,sdkMethodName:c}=e,b=Vf(l,md.IDEMPOTENT),g=Vf(l,[md.REQUEST_NAME_V1,md.REQUEST_NAME_V2]),O=[...o,"Request"],m=q0o({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:O,path:f,httpMethod:s,source:a}),w=/{([^}]+)}/g,M=[...f.matchAll(w)].map(U=>U[1]).filter(U=>!m.pathParameters.some(H=>H.name===U));if(M.length>0)for(let U of M)m.pathParameters.push({name:U??"",variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:Fl.primitive({schema:Xd.string({default:void 0,example:void 0,format:void 0,maxLength:void 0,minLength:void 0,pattern:void 0}),description:void 0,generatedName:"",nameOverride:void 0,groupName:void 0,availability:void 0,title:void 0}),description:void 0});let q=l.requestBody!=null?vpn({requestBody:l.requestBody,document:u,context:new hpn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:O,source:a,namespace:t.namespace}):void 0;l9S({context:t,convertedParameters:m})&&q!=null&&q.type==="json"&&q.schema.type!=="object"&&l.requestBody!=null?q=vpn({requestBody:l.requestBody,document:u,context:t,requestBreadcrumbs:[...O,"Body"],source:a,namespace:t.namespace}):l.requestBody!=null&&(q=vpn({requestBody:l.requestBody,document:u,context:t,requestBreadcrumbs:[...O],source:a,namespace:t.namespace}));let D=[...o,"Response"],C=P0p({operationContext:e,streamFormat:n,responses:l.responses,context:t,responseBreadcrumbs:D,responseStatusCode:r,source:a});e.method==="GET"&&(q=void 0);let R=h0p(l),$=_0p(e,l,t),I=Vf(l,md.SERVER_NAME_V2);return{summary:l.summary,internal:Vf(l,Uwe.INTERNAL),idempotent:b,audiences:Vf(l,md.AUDIENCES)??[],operationId:l.operationId!=null&&i!=null?l.operationId+"_"+i:l.operationId,tags:t.resolveTagsToTagIds(l.tags),namespace:t.namespace,sdkName:c,pathParameters:m.pathParameters,queryParameters:m.queryParameters,headers:m.headers,requestNameOverride:g??void 0,generatedRequestName:d2(O,t.options.preserveSchemaIds),request:q,response:C.value,errors:C.errors,server:I!=null?[{name:I,url:void 0,audiences:void 0}]:(l.servers??[]).map(U=>M0o(U)),description:l.description,authed:c9S(l,u),availability:R,method:s,path:f,examples:$,pagination:e.pagination,source:a}}function c9S(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function l9S({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function w0p({operationContext:e,context:t,asyncExtension:r,source:i}){let{operation:n,pathItemParameters:a,operationParameters:u}=e,l=r.discriminant.name,f=r.discriminant.value,s=r["response-status-code"],o=j0p({context:t,headerToIgnore:l,parameters:a}),c=j0p({context:t,headerToIgnore:l,parameters:u}),b=Q8r({operationContext:{...e,pathItemParameters:o,operationParameters:c,operation:{...n,responses:Object.fromEntries(Object.entries(n.responses).filter(([O])=>parseInt(O)!==s))}},context:t,streamFormat:void 0,source:i}),g=Q8r({operationContext:{...e,pathItemParameters:o,operationParameters:c,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:i});return g.headers.push({name:l,schema:Fl.literal({nameOverride:void 0,generatedName:d2([l],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:bB.string(f),groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:i}),{sync:b,async:g}}function j0p({context:e,headerToIgnore:t,parameters:r}){return r.filter(i=>{let n=rp(i)?e.resolveParameterReference(i):i;return!(n.in==="header"&&n.name===t)})}var oTs="stream";function A0p({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:Q8r({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let i=S0p({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(i?.schemaReference!=null){let s=dti(i.schemaReference);s!=null&&t.excludeSchema(s)}let n=D0p({operation:e.operation,response:r.responseStream}),a=Q8r({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+oTs}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:i?.requestBody,responses:n},baseBreadcrumbs:[...e.baseBreadcrumbs,oTs]},context:t,streamFormat:r.format,suffix:oTs,source:t.source});a.examples=a.examples.filter(s=>E0p(s,t)!==!1);let u=S0p({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),l=D0p({operation:e.operation,response:r.response}),f=Q8r({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:l}},context:t,source:t.source});return f.examples=f.examples.filter(s=>E0p(s,t)!==!0),{streaming:a,nonStreaming:f}}default:Zo(r)}}function S0p({context:e,operation:t,streamingExtension:r,isStreaming:i}){if(t.requestBody==null)return;let n=rp(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=ypn(n.content,e);if(a==null)return;let u=rp(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let l=u.properties?.[r.streamConditionProperty];l!=null&&rp(l)&&(l=void 0);let f={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":i,...l??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[aB.APPLICATION_JSON]:{schema:f}}},schemaReference:rp(a.schema)?a.schema:void 0}}function D0p({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[aB.APPLICATION_JSON]:{schema:t}}}}}function E0p(e,t){return e._visit({unknown:r=>{let i=lH.serialization.ExampleEndpointCallSchema.parse(r);if(i.ok&&i.value.response!=null)return i.value.response.stream!=null},full:()=>{},_other:()=>{}})}function M0p({context:e,operationContext:t,source:r}){let{document:i,operation:n,path:a,method:u,baseBreadcrumbs:l,sdkMethodName:f}=t,s=[...l,"Payload"],o=q0o({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:u,source:r});if(n.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 c=vpn({requestBody:n.requestBody,document:i,context:e,requestBreadcrumbs:[...l,"Payload"],source:r,namespace:e.namespace});if(c==null||c.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(n.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:n.summary,sdkName:f,namespace:e.namespace,method:u,operationId:n.operationId,tags:e.resolveTagsToTagIds(n.tags),headers:o.headers,generatedPayloadName:d2(s,e.options.preserveSchemaIds),payload:c.schema,description:n.description,examples:f9S(c.fullExamples),source:r}}function f9S(e){if(e==null)return[];let t=[];for(let r of e){let i=pti(r.value);i!=null&&t.push({description:r.description,name:r.name,payload:i})}return t}function uTs({context:e,pathItemContext:t,operation:r,convertToWebhook:i}){let n=Vf(r,md.IGNORE);if(n!=null&&n){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=d9S(r,e),u=f0p(e.document,r),l={...t,sdkMethodName:a,baseBreadcrumbs:p9S({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path}),operation:r,operationParameters:r.parameters??[],pagination:u};if(i){let c=M0p({context:e,operationContext:l,source:e.source});return c!=null?{type:"webhook",value:c}:void 0}let f=c0p(r);if(f!=null){let c=A0p({context:e,operationContext:l,streamingExtension:f});return c!=null?{type:"streaming",streaming:c.streaming,nonStreaming:c.nonStreaming}:void 0}let s=u0p(r);if(s!=null){let c=w0p({context:e,operationContext:l,asyncExtension:s,source:e.source});return{type:"async",async:c.async,sync:c.sync}}return{type:"http",value:Q8r({context:e,operationContext:l,streamFormat:void 0,source:e.source})}}function d9S(e,t){let r=Vf(e,md.SDK_METHOD_NAME),i=Vf(e,md.SDK_GROUP_NAME)??[];if(r!=null){let n=typeof i=="string"?[i]:i;return n=t.resolveGroupName(n),{groupName:n,methodName:r}}}function p9S({sdkMethodName:e,operation:t,httpMethod:r,path:i}){let n=[];if(e!=null){if(e.groupName.length>0){let a=e.groupName[e.groupName.length-1];a!=null&&n.push(typeof a=="string"?a:a.name)}n.push(e.methodName)}else t.operationId!=null?n.push(t.operationId):n.push(pg(`${r}_${i.split("/").join("_")}`));return n}function q0p(e,t,r,i){let n=[],a=C0p(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let l of a){if(i.filter.skipEndpoint({method:l.method,path:e})){i.logger.debug(`Skipping endpoint "${l.method} ${e}"`);continue}let f=_9S({operation:l.operation}),s=uTs({context:i,pathItemContext:{...u,method:l.method},operation:l.operation,convertToWebhook:f});s!=null&&n.push(s)}return n}function T0p(e,t,r,i){let n=[],a=C0p(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let l of a){if(i.filter.skipEndpoint({method:l.method,path:e})){i.logger.debug(`Skipping endpoint "${l.method} ${e}"`);continue}let f=uTs({context:i,pathItemContext:{...u,method:l.method},operation:l.operation,convertToWebhook:!0});f!=null&&n.push(f)}return n}function C0p(e){let t=[];return e.get!=null&&t.push({method:RH.Get,operation:e.get}),e.post!=null&&t.push({method:RH.Post,operation:e.post}),e.put!=null&&t.push({method:RH.Put,operation:e.put}),e.delete!=null&&t.push({method:RH.Delete,operation:e.delete}),e.patch!=null&&t.push({method:RH.Patch,operation:e.patch}),t}function _9S({operation:e}){return Vf(e,[md.WEBHOOK])??!1}function B0p(e){let t=Vf(e,md.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=Vf(e,md.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function x0p(e){return Vf(e,md.FERN_BASIC_AUTH)}function sTs(e,t){if(rp(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return h9S(e,t)}function h9S(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=Vf(e,Uwe.BEARER_FORMAT),i=Vf(e,md.FERN_HEADER_AUTH);return Z4.header({headerName:e.name,prefix:r!=null?"Bearer":i?.prefix,headerVariableName:i?.name??Vf(e,md.HEADER_VARIABLE_NAME),headerEnvVar:i?.env})}else if(e.type==="http"&&e.scheme==="bearer"){let r=Vf(e,md.FERN_BEARER_TOKEN);return Z4.bearer({tokenVariableName:r?.name??Vf(e,md.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme==="basic"){let r=x0p(e),i=B0p(e);return Z4.basic({usernameVariableName:r?.username?.name??i.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??i.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return Z4.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return Z4.oauth({scopesEnum:y9S(e,t)})}throw new Error(`Failed to convert security scheme ${JSON.stringify(e)}`)}function y9S(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let i=fti({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,inline:void 0}),n=Dq(i);if(n.type==="enum")return n}}function I0p(e){return Vf(e,md.BASE_PATH)}var v9S=Vs.record(Vs.string(),Vs.object({summary:Vs.string().optional(),description:Vs.string().optional()}));function z0p({document:e,context:t}){return Okn(e,md.GROUPS,v9S,t.logger)}function R0p({context:e,document:t}){return Vf(t,md.FERN_VERSION)??void 0}function F0p(e){let t=Vf(e,md.FERN_GLOBAL_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?mkn({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function N0p(e){let t=Vf(e,md.FERN_IDEMPOTENCY_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?mkn({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function L0p(e,t){let r=Vf(e,md.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([i,n])=>{if(n.type==="string")return[i,{nameOverride:void 0,generatedName:d2([i],t),title:n.title,schema:WP.string({default:fpn(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 ${i} has unsupported schema ${JSON.stringify(n)}`)}))}var b9S="webhooks";function U0p(e){return Vf(e,b9S)??{}}function V0p(e){return Vf(e,md.RESOLUTIONS)}function W0p({openapi:e}){let t=V0p(e);if(t==null)return e;let r={};for(let i of t){let n=`#/components/schemas/${i.name}`;for(let a of i.resolutions)e=g9S({openapi:e,schemaReference:a,schemaName:i.name}),e=H0p({openapi:e,replaceReference:a,schemaReference:n,replacedReferences:r}),r={...r,...Object.fromEntries(i.resolutions.map(u=>[n,u]))}}return e}function g9S({openapi:e,schemaReference:t,schemaName:r}){let i=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),n=e;for(let a of i){let u=n[a];if(u==null)return e;n=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=n,e}function H0p({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:i}){let n=Object.keys(i).filter(f=>t.startsWith(f)).sort((f,s)=>s.length-f.length)[0];if(n!=null){let f=i[n];if(f!=null){let s=r.replace(n,f);return H0p({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(f=>f.replaceAll("~1","/")),u=e;for(let f of a.slice(0,-1)){let s=u[f];if(s==null)return e;u=s}let l=a[a.length-1];return l==null||(u[l]={$ref:r}),e}function G0p({openApi:e,taskContext:t,options:r,source:i,namespace:n}){e=W0p({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([I,U])=>sTs(U,i)==null?[]:[I,sTs(U,i)])),u=new Set(...Object.entries(a).map(([I,U])=>U.type==="basic"||U.type==="bearer"?"Authorization":U.type==="header"?U.headerName:null)),l=L0p(e,r.preserveSchemaIds),f=F0p(e),s=N0p(e),o=r.audiences??[],c=[],b=[],g=new A0o({document:e,taskContext:t,authHeaders:u,options:r,source:i,namespace:n});g.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([I,U])=>{if(U==null)return;t.logger.debug(`Converting path ${I}`);let H=q0p(I,U,e,g);for(let te of H){let J=$0p({operation:te});if(!(o.length>0&&!o.some(ee=>J.includes(ee))))switch(te.type){case"async":c.push(te.sync),c.push(te.async);break;case"http":c.push(te.value);break;case"streaming":c.push(te.streaming),te.nonStreaming&&c.push(te.nonStreaming);break;case"webhook":b.push(te.value);break;default:Zo(te)}}}),Object.entries(U0p(e)).forEach(([I,U])=>{if(U==null)return;t.logger.debug(`Converting path ${I}`);let H=T0p(I,U,e,g);for(let te of H){let J=$0p({operation:te});o.length>0&&!o.some(ee=>J.includes(ee))||b.push(te.value)}});let O=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([I,U])=>{if(!rp(U)){let H=Vf(U,md.IGNORE);if(H!=null&&H)return[];if(O0p.has(I))return[I,rg({...U,"x-fern-type-name":`${I}Body`},!1,g,[I],i,n)]}return[I,rg(U,!1,g,[I],i,n)]}).filter(I=>I.length>0)),m=O9S(O,g,i),w=m9S(m,g),A={};for(let[I,U]of Object.entries(w)){let H=Dq(U);g.isSchemaExcluded(I)||(A[I]=H,t.logger.debug(`Converted schema ${I}`))}let M=new _ti(w,g.nonRequestReferencedSchemas,g),q=b.map(I=>{let H=I.examples;if(!r.disableExamples&&H.length===0){let te=M.buildExample({schema:I.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});te!=null&&(H=[{name:void 0,description:void 0,payload:te}])}return{...I,payload:Dq(I.payload),examples:H}}),D=new S0o(w,g),C=c.map(I=>{let U=I.examples,H=U;if(!r.disableExamples&&(U.length===0||U.every(jkn))){let ee=D.buildEndpointExample(I);ee.length>0&&(H=[...ee,...U.filter(fe=>!jkn(fe))])}let te=I.request,J=I.response;return{...I,request:te?.type==="json"?{...te,schema:Dq(te.schema)}:te,response:J?.type==="json"?{...J,schema:Dq(J.schema)}:J,queryParameters:I.queryParameters.map(ee=>({description:ee.description,name:ee.name,schema:Dq(ee.schema),parameterNameOverride:ee.parameterNameOverride,availability:ee.availability,source:ee.source})),pathParameters:I.pathParameters.map(ee=>({description:ee.description,name:ee.name,schema:Dq(ee.schema),parameterNameOverride:ee.parameterNameOverride,variableReference:ee.variableReference,availability:ee.availability,source:ee.source})),headers:I.headers.map(ee=>({description:ee.description,name:ee.name,schema:Dq(ee.schema),parameterNameOverride:ee.parameterNameOverride,env:ee.env,availability:ee.availability,source:ee.source})),examples:H,errors:cd(I.errors,ee=>{let fe=ee.fullExamples?.map(me=>{let ve=pti(me.value);if(ve!=null)return{name:me.name,description:me.description,example:ve}}).filter(dg);if(fe?.length===0){let me=M.buildExample({schema:ee.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});me!=null&&fe.push({name:void 0,description:void 0,example:me})}return{generatedName:ee.generatedName,nameOverride:ee.nameOverride,schema:Dq(ee.schema),description:ee.description,source:ee.source,examples:fe}})}}),R=z0p({document:e,context:g});return{apiVersion:R0p({context:g,document:e}),basePath:I0p(e),title:e.info.title,description:e.info.description,groups:Object.fromEntries(Object.entries(R??{}).map(([I,U])=>[I,{summary:U.summary??void 0,description:U.description??void 0}])),servers:(e.servers??[]).map(I=>M0o(I)),tags:{tagsById:Object.fromEntries((e.tags??[]).map(I=>[I.name,{id:I.name,description:I.description}])),orderedTagIds:e.tags?.map(I=>I.name)},endpoints:C,webhooks:q,channel:[],groupedSchemas:P0o(n,A),securitySchemes:a,hasEndpointsMarkedInternal:C.some(I=>I.internal),nonRequestReferencedSchemas:g.getReferencedSchemas(),variables:l,globalHeaders:f,idempotencyHeaders:s}}function O9S(e,t,r){let i={};for(let[n,a]of Object.entries(e)){if(a.type!=="object"){i[n]=a;continue}let u={$ref:`#/components/schemas/${n}`},l=t.getReferencesFromDiscriminatedUnion(u);if(l==null){i[n]=a;continue}let f={...a,type:"object",properties:a.properties.filter(o=>!l.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!l.discriminants.has(o.propertyKey)),source:r};i[n]=f;let s=Q0p({schema:a,schemas:e});for(let o of[...new Set(s)]){let c=i[o]??e[o];c==null||c.type!=="object"||(i[o]={...c,type:"object",properties:c.properties.filter(b=>!l.discriminants.has(b.key)),allOfPropertyConflicts:c.allOfPropertyConflicts.filter(b=>!l.discriminants.has(b.propertyKey))})}}return i}function m9S(e,t){let r={};for(let[i,n]of Object.entries(e)){if(n.type!=="object"){r[i]=n;continue}let a={$ref:`#/components/schemas/${i}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[i]=n;continue}let l=[];for(let s of n.properties)if(u.discriminants.has(s.key)){let o=u.discriminants.get(s.key);o!=null&&l.push({...s,schema:Fl.literal({nameOverride:void 0,generatedName:d2([n.generatedName,o],t.options.preserveSchemaIds),title:void 0,value:bB.string(o),groupName:void 0,description:void 0,availability:n.availability})})}else l.push(s);let f={...n,type:"object",properties:l};r[i]=f}return r}function Q0p({schema:e,schemas:t}){let r=[];for(let i of e.allOf){r.push(i.schema);let n=t[i.schema];n!=null&&n.type==="object"&&r.push(...Q0p({schema:n,schemas:t}))}return r}function $0p({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:Zo(e)}return t}function FSi({context:e,documents:t,options:r}){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 n of t){let a=n.source!=null?n.source:N2t.openapi({file:"<memory>"});switch(n.type){case"openapi":{let u=G0p({taskContext:e,openApi:n.value,options:Gqs({options:n.settings,overrides:r}),source:a,namespace:n.namespace});i=j9S(i,u);break}case"asyncapi":{let u=t0p({document:n.value,taskContext:e,options:Gqs({options:n.settings,overrides:r}),source:a,asyncApiOptions:P9S({options:n.settings}),namespace:n.namespace});u.channel!=null&&i.channel.push(u.channel),u.groupedSchemas!=null&&(i.groupedSchemas=J0p(i.groupedSchemas,u.groupedSchemas)),u.basePath!=null&&(i.basePath=u.basePath);break}default:Zo(n)}}return i}function P9S({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??Dbp.naming}}function j9S(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:J0p(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 J0p(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,i]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...i}:e.namespacedSchemas[r]=i;return e}var T0o={config:new K0p.Config({apis:{},styleguide:{plugins:[Qqs],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};function Dkn(e){return e.swagger!=null}function cTs(e){return e.openapi!=null}function hti(e,t={}){return{...Object.fromEntries(BR(e.namedDefinitionFiles).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...BR(e.importedDefinitions).reduce((r,[i,n])=>({...r,...oUn(hti(n.definition,{defaultURL:n.url}),(a,u)=>Dz(i,Wh.of(u)))}),{})}}function Ekn(e,t={}){return{...Object.fromEntries(BR(e.packageMarkers).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...BR(e.importedDefinitions).reduce((r,[i,n])=>({...r,...oUn(Ekn(n.definition,{defaultURL:n.url}),(a,u)=>Dz(i,Wh.of(u)))}),{})}}function J8r(e){return{...Ekn(e),...hti(e)}}function Lte(e,t){return J8r(e.definition)[t]?.contents}function dF(e,t){for(let[r,i]of BR(J8r(e.definition)))t(r,i.contents,{isPackageMarker:nmi(r)===P1,defaultUrl:i.defaultUrl})}function NSi(e,t){for(let[r,i]of BR(Ekn(e.definition)))t(r,i.contents)}var njp=Di(ijp(),1);async function gea(e){return(await(0,njp.convertObj)(e,{})).openapi}var ojp=require("fs/promises");var ajp=require("fs/promises");async function Ngo({absoluteFilePathToOverrides:e,data:t,context:r}){let i=null;try{let n=(await(0,ajp.readFile)(e,"utf8")).toString();try{i=JSON.parse(n)}catch{i=pp.load(n,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return T$u({data:t,overrides:i})}async function ujp({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,ojp.readFile)(t)).toString(),n=await pp.load(i);return r!=null?await Ngo({absoluteFilePathToOverrides:r,context:e,data:n}):n}var mea=Di(p0o(),1);var sjp=Di(p0o(),1),dBs=Di(require("path"),1);var Oea=class extends sjp.BaseResolver{absolutePathToOpenAPIOverrides;constructor(t){super(),this.absolutePathToOpenAPIOverrides=t}resolveExternalRef(t,r){let i=super.resolveExternalRef(t,r);return o6r(Kl.of(i))?i:this.absolutePathToOpenAPIOverrides!=null?dBs.default.resolve(dBs.default.dirname(this.absolutePathToOpenAPIOverrides),r):i}};async function pBs({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,parsed:r}){return(r!=null?await(0,mea.bundle)({...T0o,doc:{source:new mea.Source(e,"<openapi>"),parsed:r},externalRefResolver:new Oea(t)}):await(0,mea.bundle)({...T0o,ref:e,externalRefResolver:new Oea(t)})).bundle.parsed}async function Pea({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r}){let i=await pBs({absolutePathToOpenAPI:t}),n;if(r!=null?n=r:typeof i=="object"&&i[md.OPENAPI_OVERIDES_FILEPATH]!=null&&(n=ku(Mp(t),yo.of(i[md.OPENAPI_OVERIDES_FILEPATH]))),n!=null){let a=await Ngo({absoluteFilePathToOverrides:n,context:e,data:i});return await pBs({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,parsed:a})}return i}var e6t=class{absoluteFilePath;constructor(t){this.absoluteFilePath=t}async loadDocuments({context:t,specs:r}){let i=[];for(let n of r){let a=(await(0,cjp.readFile)(n.absoluteFilepath)).toString(),u=xT(this.absoluteFilePath,n.source.file);n.source.relativePathToDependency!=null&&(u=ku(n.source.relativePathToDependency,u));let l=n.source.type==="protobuf"?N2t.protobuf({file:u}):N2t.openapi({file:u});if(a.includes("openapi")||a.includes("swagger")){let f=await Pea({absolutePathToOpenAPI:n.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:n.absoluteFilepathToOverrides});if(cTs(f))i.push({type:"openapi",value:f,source:l,namespace:n.namespace,settings:n.settings});else if(Dkn(f)){let s=await gea(f);i.push({type:"openapi",value:s,source:l,namespace:n.namespace,settings:n.settings})}}else if(a.includes("asyncapi")){let f=await ujp({context:t,absoluteFilePath:n.absoluteFilepath,absoluteFilePathToOverrides:n.absoluteFilepathToOverrides});i.push({type:"asyncapi",value:f,source:l,namespace:n.namespace,settings:n.settings})}else t.failAndThrow(`${n.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}};var Kgo=require("fs/promises"),Fwp=Di(Jk(),1);var Rwp=Di(zwp(),1);async function QH(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...u}={}){let l=n.reduce((o,c)=>({...o,[c]:"<redacted>"}),a),f=[t,...r].join(" ");for(let[o,c]of Object.entries(l))f=f.replaceAll(o,c);e?.debug(`+ ${f}`);let s=(0,Rwp.default)(t,r,u);return i||(s.stdout?.pipe(process.stdout),s.stderr?.pipe(process.stderr)),s}function Qgo(e,{logger:t,...r}={}){return(i,n)=>QH(t,e,i,{...r,...n})}var EQS="buf.gen.yaml",Nwp="output",AQS=`${Nwp}/openapi.yaml`,MQS=`
1930
1930
  version: v1
1931
1931
  plugins:
1932
1932
  - plugin: openapi
@@ -1983,7 +1983,7 @@ ${U.stack}`)),O}};O=await M();let q=g.apiWorkspaces.flatMap($=>$.getAbsoluteFile
1983
1983
  `},n)),a}var xUp=require("fs");var MbD=["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"];function qbD({readFile:e=r=>(0,xUp.readFileSync)(r,"utf-8"),...t}){let r=new Set,i=[t],n=[],a=[],u=1e3,l=0;do{if(l++,l>u)throw new Error("Infinite loop detected while collecting links and sources");let f=i.shift();if(f==null)break;let{content:s,absoluteFilepath:o}=f;if(o!=null){if(r.has(o))throw new Error(`Circular import detected: ${o}`);r.add(o)}let c=o?Nta(o):"mdx",b=Lta(s,c),g=n4s(b,{allowDangerousHtml:!0,passThrough:[...MbD]});Nf(g,O=>{if(O.type==="mdxjsEsm"&&o!=null)return O.data?.estree&&iUp(O.data.estree,{enter:m=>{if(m.type==="ImportDeclaration"&&m.source.type==="Literal"&&typeof m.source.value=="string"){let w=yo.of(m.source.value),A=Mm(Mp(o),w);(A.endsWith(".mdx")||A.endsWith(".md"))&&i.push({content:e(A),absoluteFilepath:A})}}}),"skip";if(O.type==="element"){let m=O.properties.href;typeof m=="string"&&n.push({href:m,sourceFilepath:o,position:O.position});let w=O.properties.src;typeof w=="string"&&a.push({src:w,sourceFilepath:o,position:O.position})}if(O.type==="mdxJsxFlowElement"||O.type==="mdxJsxTextElement"){let m=O.attributes.find(A=>A.type==="mdxJsxAttribute"&&A.name==="href"),w=O.attributes.find(A=>A.type==="mdxJsxAttribute"&&A.name==="src");if(O.name==="Markdown"){if(o&&w!=null&&typeof w.value=="string"){let A=Mm(Mp(o),w.value);i.push({content:e(A),absoluteFilepath:A})}return"skip"}m!=null&&typeof m.value=="string"&&n.push({href:m.value,sourceFilepath:o,position:O.position}),w!=null&&typeof w.value=="string"&&a.push({src:w.value,sourceFilepath:o,position:O.position})}})}while(i.length>0);return{links:n,sources:a}}function IUp({content:e,absoluteFilepath:t}){try{return qbD({content:e,absoluteFilepath:t})}catch{return{links:[],sources:[]}}}function zUp({relativeFilepath:e,allRuleVisitors:t,addViolations:r}){function i(n){let a=async(u,l)=>{for(let f of t){let s=f[n];if(s!=null){let o=await s(u);r(o.map(c=>({name:c.name,severity:c.severity,relativeFilepath:e,nodePath:l,message:c.message})))}}};return{[n]:a}}return{...i("file"),...i("filepath"),...i("markdownPage"),...i("versionFile"),...i("apiSection"),...i("permissions")}}var NUp=require("fs/promises");async function fU({absoluteFilepathToConfiguration:e,rawUnresolvedFilepath:t,visitor:r,nodePath:i,willBeUploaded:n=!0}){let a=Mm(Mp(e),t);await r.filepath?.({absoluteFilepath:a,value:t,willBeUploaded:n},[a])}var RUp=require("fs/promises");async function o4s({absolutePathToFernFolder:e,navigation:t,fernWorkspaces:r,visitor:i,absoluteFilepathToConfiguration:n,context:a,nodePath:u}){BbD(t)?await Promise.all(t.map(async(l,f)=>{l.layout!=null&&await Promise.all(l.layout.map(async(s,o)=>{await a4s({absolutePathToFernFolder:e,navigationItem:s,visitor:i,nodePath:[...u,`${f}`,"layout",`${o}`],absoluteFilepathToConfiguration:n,fernWorkspaces:r,context:a})}))})):await Promise.all(t.map(async(l,f)=>{await a4s({absolutePathToFernFolder:e,navigationItem:l,visitor:i,nodePath:[...u,`${f}`],absoluteFilepathToConfiguration:n,fernWorkspaces:r,context:a})}))}async function a4s({absolutePathToFernFolder:e,navigationItem:t,visitor:r,nodePath:i,absoluteFilepathToConfiguration:n,fernWorkspaces:a,context:u}){if(await AUt(t,{alphabetized:Yo,api:Yo,apiName:Yo,audiences:Yo,openrpc:async l=>{l!=null&&await fU({absoluteFilepathToConfiguration:n,rawUnresolvedFilepath:l,visitor:r,nodePath:[...i,"openrpc"],willBeUploaded:!1})},displayErrors:Yo,snippets:Yo,summary:Yo,title:Yo,layout:Yo,icon:Yo,slug:Yo,hidden:Yo,skipSlug:Yo,paginated:Yo,playground:Yo,flattened:Yo,featureFlag:Yo,path:async l=>{l!=null&&await fU({absoluteFilepathToConfiguration:n,rawUnresolvedFilepath:l,visitor:r,nodePath:[...i,"path"],willBeUploaded:!1})},page:Yo,contents:async l=>{l!=null&&await Promise.all(l.map(async(f,s)=>{await a4s({absolutePathToFernFolder:e,navigationItem:f,visitor:r,nodePath:[...i,"contents",`${s}`],absoluteFilepathToConfiguration:n,fernWorkspaces:a,context:u})}))},viewers:async l=>{l!=null&&l.length>0&&await r.permissions?.({viewers:l},[...i,"viewers"])},orphaned:Yo}),TbD(t)){let l=Mm(Mp(n),t.path);if(await zf(l)){let f=(await(0,RUp.readFile)(l)).toString();await r.markdownPage?.({title:t.page,content:f,absoluteFilepath:l},[...i,t.path]);try{let{filepaths:s}=Vta(f,{absolutePathToFernFolder:e,absolutePathToMarkdownFile:l});for(let o of s)await r.filepath?.({absoluteFilepath:o,value:xT(e,o),willBeUploaded:!0},[...i,t.path])}catch{}}}if(CbD(t)){let l=a.find(f=>f.workspaceName===t.apiName);l!=null&&await r.apiSection?.({config:t,workspace:l,context:u},[...i,"api"])}}function TbD(e){return e.page!=null}function CbD(e){return e.api!=null}function BbD(e){return e[0]?.tab!=null}async function LUp({contents:e,visitor:t,absoluteFilepathToConfiguration:r,context:i,fernWorkspaces:n,absolutePathToFernFolder:a}){await t.file?.({config:e},[]),await AUt(e,{instances:Yo,analytics:Yo,announcement:Yo,backgroundImage:async u=>{u!=null&&(typeof u=="string"?await fU({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:u,visitor:t,nodePath:["background-image"]}):(u.dark!=null&&await fU({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:u.dark,visitor:t,nodePath:["background-image","dark"]}),u.light!=null&&await fU({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:u.light,visitor:t,nodePath:["background-image","light"]})))},colors:Yo,css:async u=>{u!=null&&(Array.isArray(u)?await Promise.all(u.map((l,f)=>fU({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:l,visitor:t,nodePath:["css",`${f}`],willBeUploaded:!1}))):await fU({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:u,visitor:t,nodePath:["css"],willBeUploaded:!1}))},defaultLanguage:Yo,experimental:Yo,favicon:async u=>{u!=null&&await fU({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:u,visitor:t,nodePath:["favicon"]})},footerLinks:Yo,integrations:Yo,js:async u=>{u!=null&&(Array.isArray(u)?await Promise.all(u.map((l,f)=>FUp({absoluteFilepathToConfiguration:r,visitor:t,script:l,nodePath:["js",`${f}`]}))):await FUp({absoluteFilepathToConfiguration:r,visitor:t,script:u,nodePath:["js"]}))},landingPage:Yo,layout:Yo,logo:async u=>{e.logo?.dark!=null&&await fU({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.logo.dark,visitor:t,nodePath:["logo","dark"]}),e.logo?.light!=null&&await fU({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.logo.light,visitor:t,nodePath:["logo","light"]})},metadata:Yo,navbarLinks:Yo,navigation:async u=>{u!=null&&await o4s({absolutePathToFernFolder:a,navigation:u,visitor:t,nodePath:["navigation"],absoluteFilepathToConfiguration:r,fernWorkspaces:n,context:i})},redirects:Yo,tabs:Yo,title:Yo,typography:async u=>{u!=null&&await AUt(u,{bodyFont:async l=>{l!=null&&await u4s({absoluteFilepathToConfiguration:r,visitor:t,font:l,nodePath:["typography","bodyFont"]})},codeFont:async l=>{l!=null&&await u4s({absoluteFilepathToConfiguration:r,visitor:t,font:l,nodePath:["typography","codeFont"]})},headingsFont:async l=>{l!=null&&await u4s({absoluteFilepathToConfiguration:r,visitor:t,font:l,nodePath:["typography","headingsFont"]})}})},versions:async u=>{u!=null&&await Promise.all(u.map(async(l,f)=>{await fU({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:l.path,visitor:t,nodePath:["versions",`${f}`],willBeUploaded:!1});let s=Mm(Mp(r),l.path),o=pp.load((await(0,NUp.readFile)(s)).toString());await zf(s)&&await t.versionFile?.({path:l.path,content:o},[l.path]);let c=await H1o({value:o});c.type==="success"&&await o4s({absolutePathToFernFolder:a,navigation:c.contents.navigation,visitor:t,nodePath:["navigation"],absoluteFilepathToConfiguration:s,fernWorkspaces:n,context:i})}))},roles:Yo})}async function u4s({absoluteFilepathToConfiguration:e,visitor:t,font:r,nodePath:i}){r.path!=null&&await fU({absoluteFilepathToConfiguration:e,rawUnresolvedFilepath:r.path,visitor:t,nodePath:i,willBeUploaded:!0});for(let n of r.paths??[])typeof n=="string"?await fU({absoluteFilepathToConfiguration:e,rawUnresolvedFilepath:n,visitor:t,nodePath:i,willBeUploaded:!0}):await fU({absoluteFilepathToConfiguration:e,rawUnresolvedFilepath:n.path,visitor:t,nodePath:i,willBeUploaded:!0})}async function FUp({absoluteFilepathToConfiguration:e,visitor:t,script:r,nodePath:i}){let n=typeof r=="string"?r:"path"in r?r.path:null;n&&await fU({absoluteFilepathToConfiguration:e,rawUnresolvedFilepath:n,visitor:t,nodePath:i,willBeUploaded:!0})}var UUp={name:"accent-color-contrast",create:()=>({file:async({config:e})=>{if(e.colors==null)return[];let t=A8a(e.colors);return t==="dark"?J1o(e.colors,"dark"):t==="light"?J1o(e.colors,"light"):t==="darkAndLight"?[...J1o(e.colors,"dark"),...J1o(e.colors,"light")]:[]}})};function J1o(e,t){let r=zVn(e.accentPrimary??e.accentPrimaryDeprecated,"accent-primary",t),i=zVn(e.background,"background",t)??(t==="dark"?"#000":"#FFF"),n=[];if(!Hp(i).isValid())n.push({severity:"fatal",message:`Invalid background color provided for colors.background.${t}: ${i}.`});else{let a=xbD(Hp(i),t);Hp(i).toHexString()!==a.toHexString()&&n.push({severity:"warning",message:`The provided background color for ${t} mode is not ${t} enough. It will be adjusted to ${a.toHexString()}.`}),i=a.toHexString()}if(r==null)n.push({severity:"warning",message:`No accent-color provided for ${t} mode. A random color will be used.`});else if(!Hp(r).isValid())n.push({severity:"fatal",message:`Invalid accent-color provided for colors.accent-primary.${t}: ${r}.`});else{let a=Hp.readability(r,i),u=`${a.toFixed(2)}:1`;a<3?n.push({severity:"warning",message:`The contrast ratio between the accent color and the background color for ${t} mode is ${u}. It should be at least 3:1.`}):a<4.5?n.push({severity:"warning",message:`The contrast ratio between the accent color and the background color for ${t} mode is ${u}. Fern will adjust the color to meet the minimum contrast ratio of 4.5:1 for WCAG AA and 7:1 for WCAG AAA.`}):a<7&&n.push({severity:"warning",message:`The contrast ratio between the accent color and the background color for ${t} mode is ${u}. Fern will adjust the color to meet the minimum contrast ratio of 7:1 for WCAG AAA.`})}return n}function xbD(e,t){return t==="dark"&&e.isDark()||t==="light"&&e.isLight()?e:IbD(e)}function IbD(e){if(e==null)return;let{h:t,s:r,v:i}=e.toHsv();return Hp({h:t,s:r,v:1-i})}var VUp={name:"all-roles-must-be-declared",create:e=>{let t=e.workspace.config.roles;return{permissions:r=>{let i=[...r.viewers??[]],n=[];for(let a of i)(t==null||!t.includes(a))&&n.push({severity:"fatal",message:`Role "${a}" is used but not declared at the top level of the docs.yml file.`});return n}}}};var s4s={name:"filepaths-exist",create:()=>({filepath:async({absoluteFilepath:e,value:t})=>await zf(e)?[]:[{severity:"fatal",message:`Path ${t} does not exist`}]})};var c4s={name:"only-versioned-navigation",create:()=>({file:async({config:e})=>e.navigation!=null&&e.versions!=null?[{severity:"fatal",message:"Cannot contain both navigation and versions. If you want versioned docs, use versions. Otherwise use navigation."}]:[]})};var l4s={name:"playground-environments-exist",create:()=>({apiSection:async({workspace:e,context:t,config:r})=>{let i=(await e.getDefinition({context:t})).rootApiFile.contents.environments,n=new Set(Object.keys(i??{})),a=r.playground?.environments;if(a==null||a.length==null)return[];let u=a.filter(l=>!n.has(l));return u.length===0?[]:u.length===1?[{severity:"fatal",message:`The API does not contain the ${u[0]} environment. ${WUp(Array.from(n))??""}`}]:[{severity:"fatal",message:`The API does not contain the following environments: ${u.join(", ")}. ${WUp(Array.from(n))??""}`}]}})};function WUp(e){if(e.length!==0)return e.length===1&&e[0]!=null?`The only configured environment is ${e[0]}`:`Existing environments include ${e.join(", ")}.`}var f4s={name:"valid-docs-endpoints",create:()=>({file:async({config:e})=>!e.analytics||!Object.keys(e.analytics).length?[]:[[e.analytics.intercom?.apiBase,"Intercom API Base"],[e.analytics.posthog?.endpoint,"Posthog Host Endpoint"]].filter(([i])=>i&&!zbD(i)).map(([i,n])=>({severity:"warning",message:`${n} <${i}> is malformed. Make sure it includes a protocol (e.g. 'https://')!`}))})};function zbD(e){try{return!!new URL(e).protocol}catch{return!1}}var OVp=Di(rVp(),1);var o0D="End-Of-Stream",mI=class extends Error{constructor(){super(o0D)}};var tSo=class{constructor(){this.resolve=()=>null,this.reject=()=>null,this.promise=new Promise((t,r)=>{this.reject=r,this.resolve=t})}};var u0D=1*1024*1024,aia=class{constructor(t){if(this.s=t,this.deferred=null,this.endOfStream=!1,this.peekQueue=[],!t.read||!t.once)throw new Error("Expected an instance of stream.Readable");this.s.once("end",()=>this.reject(new mI)),this.s.once("error",r=>this.reject(r)),this.s.once("close",()=>this.reject(new Error("Stream closed")))}async peek(t,r,i){let n=await this.read(t,r,i);return this.peekQueue.push(t.subarray(r,r+n)),n}async read(t,r,i){if(i===0)return 0;if(this.peekQueue.length===0&&this.endOfStream)throw new mI;let n=i,a=0;for(;this.peekQueue.length>0&&n>0;){let u=this.peekQueue.pop();if(!u)throw new Error("peekData should be defined");let l=Math.min(u.length,n);t.set(u.subarray(0,l),r+a),a+=l,n-=l,l<u.length&&this.peekQueue.push(u.subarray(l))}for(;n>0&&!this.endOfStream;){let u=Math.min(n,u0D),l=await this.readFromStream(t,r+a,u);if(a+=l,l<u)break;n-=l}return a}async readFromStream(t,r,i){let n=this.s.read(i);if(n)return t.set(n,r),n.length;{let a={buffer:t,offset:r,length:i,deferred:new tSo};return this.deferred=a.deferred,this.s.once("readable",()=>{this.readDeferred(a)}),a.deferred.promise}}readDeferred(t){let r=this.s.read(t.length);r?(t.buffer.set(r,t.offset),t.deferred.resolve(r.length),this.deferred=null):this.s.once("readable",()=>{this.readDeferred(t)})}reject(t){this.endOfStream=!0,this.deferred&&(this.deferred.reject(t),this.deferred=null)}};var W4s=require("buffer"),Chn=class{constructor(t){this.position=0,this.numBuffer=new Uint8Array(8),this.fileInfo=t||{}}async readToken(t,r=this.position){let i=W4s.Buffer.alloc(t.len);if(await this.readBuffer(i,{position:r})<t.len)throw new mI;return t.get(i,0)}async peekToken(t,r=this.position){let i=W4s.Buffer.alloc(t.len);if(await this.peekBuffer(i,{position:r})<t.len)throw new mI;return t.get(i,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new mI;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new mI;return t.get(this.numBuffer,0)}async ignore(t){if(this.fileInfo.size!==void 0){let r=this.fileInfo.size-this.position;if(t>r)return this.position+=r,r}return this.position+=t,t}async close(){}normalizeOptions(t,r){if(r&&r.position!==void 0&&r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return r?{mayBeLess:r.mayBeLess===!0,offset:r.offset?r.offset:0,length:r.length?r.length:t.length-(r.offset?r.offset:0),position:r.position?r.position:this.position}:{mayBeLess:!1,offset:0,length:t.length,position:this.position}}};var s0D=256e3,rSo=class extends Chn{constructor(t,r){super(r),this.streamReader=new aia(t)}async getFileInfo(){return this.fileInfo}async readBuffer(t,r){let i=this.normalizeOptions(t,r),n=i.position-this.position;if(n>0)return await this.ignore(n),this.readBuffer(t,r);if(n<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(i.length===0)return 0;let a=await this.streamReader.read(t,i.offset,i.length);if(this.position+=a,(!r||!r.mayBeLess)&&a<i.length)throw new mI;return a}async peekBuffer(t,r){let i=this.normalizeOptions(t,r),n=0;if(i.position){let a=i.position-this.position;if(a>0){let u=new Uint8Array(i.length+a);return n=await this.peekBuffer(u,{mayBeLess:i.mayBeLess}),t.set(u.subarray(a),i.offset),n-a}else if(a<0)throw new Error("Cannot peek from a negative offset in a stream")}if(i.length>0){try{n=await this.streamReader.peek(t,i.offset,i.length)}catch(a){if(r&&r.mayBeLess&&a instanceof mI)return 0;throw a}if(!i.mayBeLess&&n<i.length)throw new mI}return n}async ignore(t){let r=Math.min(s0D,t),i=new Uint8Array(r),n=0;for(;n<t;){let a=t-n,u=await this.readBuffer(i,{length:Math.min(r,a)});if(u<0)return u;n+=u}return n}};var iSo=class extends Chn{constructor(t,r){super(r),this.uint8Array=t,this.fileInfo.size=this.fileInfo.size?this.fileInfo.size:t.length}async readBuffer(t,r){if(r&&r.position){if(r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");this.position=r.position}let i=await this.peekBuffer(t,r);return this.position+=i,i}async peekBuffer(t,r){let i=this.normalizeOptions(t,r),n=Math.min(this.uint8Array.length-i.position,i.length);if(!i.mayBeLess&&n<i.length)throw new mI;return t.set(this.uint8Array.subarray(i.position,i.position+n),i.offset),n}async close(){}};function iVp(e,t){return t=t||{},new rSo(e,t)}function nVp(e,t){return new iSo(e,t)}var z5r=require("buffer");var oVp=Di(aVp(),1),uVp=require("buffer");function rre(e){return new DataView(e.buffer,e.byteOffset)}var sVp={len:1,get(e,t){return rre(e).getUint8(t)},put(e,t,r){return rre(e).setUint8(t,r),t+1}},nSo={len:2,get(e,t){return rre(e).getUint16(t,!0)},put(e,t,r){return rre(e).setUint16(t,r,!0),t+2}},aSo={len:2,get(e,t){return rre(e).getUint16(t)},put(e,t,r){return rre(e).setUint16(t,r),t+2}};var cVp={len:4,get(e,t){return rre(e).getUint32(t,!0)},put(e,t,r){return rre(e).setUint32(t,r,!0),t+4}},lVp={len:4,get(e,t){return rre(e).getUint32(t)},put(e,t,r){return rre(e).setUint32(t,r),t+4}};var fVp={len:4,get(e,t){return rre(e).getInt32(t)},put(e,t,r){return rre(e).setInt32(t,r),t+4}};var dVp={len:8,get(e,t){return rre(e).getBigUint64(t,!0)},put(e,t,r){return rre(e).setBigUint64(t,r,!0),t+8}};var I5r=class{constructor(t,r){this.len=t,this.encoding=r}get(t,r){return uVp.Buffer.from(t).toString(this.encoding,r,r+this.len)}},$4s=class e{constructor(t){this.len=t}static decode(t,r,i){let n="";for(let a=r;a<i;++a)n+=e.codePointToString(e.singleByteDecoder(t[a]));return n}static inRange(t,r,i){return r<=t&&t<=i}static codePointToString(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}static singleByteDecoder(t){if(e.inRange(t,0,127))return t;let r=e.windows1252[t-128];if(r===null)throw Error("invaliding encoding");return r}get(t,r=0){return e.decode(t,r,r+this.len)}};$4s.windows1252=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255];function pVp(e){return[...e].map(t=>t.charCodeAt(0))}function _Vp(e,t=0){let r=Number.parseInt(e.toString("utf8",148,154).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let i=8*32;for(let n=t;n<t+148;n++)i+=e[n];for(let n=t+156;n<t+512;n++)i+=e[n];return r===i}var hVp={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4};var yVp=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","ai","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx"],vVp=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/x-apache-arrow","video/mp4","audio/midi","video/x-matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","audio/opus","video/ogg","audio/ogg","application/ogg","audio/x-flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/x-parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx"];var bVp=4100;async function gVp(e){return new G4s().fromBuffer(e)}function cJt(e,t,r){r={offset:0,...r};for(let[i,n]of t.entries())if(r.mask){if(n!==(r.mask[i]&e[i+r.offset]))return!1}else if(n!==e[i+r.offset])return!1;return!0}var G4s=class{constructor(t){this.detectors=t?.customDetectors,this.fromTokenizer=this.fromTokenizer.bind(this),this.fromBuffer=this.fromBuffer.bind(this),this.parse=this.parse.bind(this)}async fromTokenizer(t){let r=t.position;for(let i of this.detectors||[]){let n=await i(t);if(n)return n;if(r!==t.position)return}return this.parse(t)}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`Buffer\` or \`ArrayBuffer\`, got \`${typeof t}\``);let r=t instanceof Uint8Array?t:new Uint8Array(t);if(r?.length>1)return this.fromTokenizer(nVp(r))}async fromBlob(t){let r=await t.arrayBuffer();return this.fromBuffer(new Uint8Array(r))}async fromStream(t){let r=await iVp(t);try{return await this.fromTokenizer(r)}finally{await r.close()}}async toDetectionStream(t,r={}){let{default:i}=await import("stream"),{sampleSize:n=bVp}=r;return new Promise((a,u)=>{t.on("error",u),t.once("readable",()=>{(async()=>{try{let l=new i.PassThrough,f=i.pipeline?i.pipeline(t,l,()=>{}):t.pipe(l),s=t.read(n)??t.read()??z5r.Buffer.alloc(0);try{l.fileType=await this.fromBuffer(s)}catch(o){o instanceof mI?l.fileType=void 0:u(o)}a(f)}catch(l){u(l)}})()})})}check(t,r){return cJt(this.buffer,t,r)}checkString(t,r){return this.check(pVp(t),r)}async parse(t){if(this.buffer=z5r.Buffer.alloc(bVp),t.fileInfo.size===void 0&&(t.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=t,await t.peekBuffer(this.buffer,{length:12,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await t.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.parse(t);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await t.ignore(6);let r=await t.readToken(hVp);return t.position+r>t.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await t.ignore(r),this.fromTokenizer(t))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){try{for(;t.position+30<t.fileInfo.size;){await t.readBuffer(this.buffer,{length:30});let r={compressedSize:this.buffer.readUInt32LE(18),uncompressedSize:this.buffer.readUInt32LE(22),filenameLength:this.buffer.readUInt16LE(26),extraFieldLength:this.buffer.readUInt16LE(28)};if(r.filename=await t.readToken(new I5r(r.filenameLength,"utf-8")),await t.ignore(r.extraFieldLength),r.filename==="META-INF/mozilla.rsa")return{ext:"xpi",mime:"application/x-xpinstall"};if(r.filename.endsWith(".rels")||r.filename.endsWith(".xml"))switch(r.filename.split("/")[0]){case"_rels":break;case"word":return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};case"ppt":return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};case"xl":return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};default:break}if(r.filename.startsWith("xl/"))return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(r.filename.startsWith("3D/")&&r.filename.endsWith(".model"))return{ext:"3mf",mime:"model/3mf"};if(r.filename==="mimetype"&&r.compressedSize===r.uncompressedSize){let i=await t.readToken(new I5r(r.compressedSize,"utf-8"));switch(i=i.trim(),i){case"application/epub+zip":return{ext:"epub",mime:"application/epub+zip"};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:"application/vnd.oasis.opendocument.text"};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:"application/vnd.oasis.opendocument.spreadsheet"};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:"application/vnd.oasis.opendocument.presentation"};default:}}if(r.compressedSize===0){let i=-1;for(;i<0&&t.position<t.fileInfo.size;)await t.peekBuffer(this.buffer,{mayBeLess:!0}),i=this.buffer.indexOf("504B0304",0,"hex"),await t.ignore(i>=0?i:this.buffer.length)}else await t.ignore(r.compressedSize)}}catch(r){if(!(r instanceof mI))throw r}return{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await t.ignore(28);let r=z5r.Buffer.alloc(8);return await t.readBuffer(r),cJt(r,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/opus"}:cJt(r,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:cJt(r,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:cJt(r,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:cJt(r,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:cJt(r,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("ftyp",{offset:4})&&this.buffer[8]&96){let r=this.buffer.toString("binary",8,12).replace("\0"," ").trim();switch(r){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return r.startsWith("3g")?r.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/x-flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF")){try{await t.ignore(1350);let r=10*1024*1024,i=z5r.Buffer.alloc(Math.min(r,t.fileInfo.size));if(await t.readBuffer(i,{mayBeLess:!0}),i.includes(z5r.Buffer.from("AIPrivateData")))return{ext:"ai",mime:"application/postscript"}}catch(r){if(!(r instanceof mI))throw r}return{ext:"pdf",mime:"application/pdf"}}if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let r=await this.readTiffHeader(!1);if(r)return r}if(this.check([77,77])){let r=await this.readTiffHeader(!0);if(r)return r}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function r(){let l=await t.peekNumber(sVp),f=128,s=0;for(;!(l&f)&&f!==0;)++s,f>>=1;let o=z5r.Buffer.alloc(s+1);return await t.readBuffer(o),o}async function i(){let l=await r(),f=await r();f[0]^=128>>f.length-1;let s=Math.min(6,f.length);return{id:l.readUIntBE(0,l.length),len:f.readUIntBE(f.length-s,s)}}async function n(l){for(;l>0;){let f=await i();if(f.id===17026)return(await t.readToken(new I5r(f.len,"utf-8"))).replaceAll(/\00.*$/g,"");await t.ignore(f.len),--l}}let a=await i();switch(await n(a.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/x-matroska"};default:return}}if(this.check([82,73,70,70])){if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1"))return{ext:"parquet",mime:"application/x-parquet"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let r=this.buffer.toString("binary",2,6);if(r.match("^d*")&&r>=1e3&&r<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await t.ignore(8),await t.readToken(new I5r(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("**ACE",{offset:7})&&(await t.peekBuffer(this.buffer,{length:14,mayBeLess:!0}),this.checkString("**",{offset:12})))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.check([137,80,78,71,13,10,26,10])){await t.ignore(8);async function r(){return{length:await t.readToken(fVp),type:await t.readToken(new I5r(4,"binary"))}}do{let i=await r();if(i.length<0)return;switch(i.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await t.ignore(i.length+4)}}while(t.position+8<t.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/x-apache-arrow"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function r(){let i=z5r.Buffer.alloc(16);return await t.readBuffer(i),{id:i,size:Number(await t.readToken(dVp))}}for(await t.ignore(30);t.position+24<t.fileInfo.size;){let i=await r(),n=i.size-24;if(cJt(i.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let a=z5r.Buffer.alloc(16);if(n-=await t.readBuffer(a),cJt(a,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(cJt(a,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await t.ignore(n)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await t.ignore(20),await t.readToken(new I5r(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.check([0,60,0,63,0,120,0,109,0,108],{offset:2})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await t.peekBuffer(this.buffer,{length:Math.min(256,t.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let r=this.buffer.readUInt32LE(12);if(r>12&&this.buffer.length>=r+16)try{let i=this.buffer.slice(16,r+16).toString();if(JSON.parse(i).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(await t.peekBuffer(this.buffer,{length:Math.min(512,t.fileInfo.size),mayBeLess:!0}),_Vp(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254]))return this.check([60,0,63,0,120,0,109,0,108,0],{offset:2})?{ext:"xml",mime:"application/xml"}:this.check([255,14,83,0,107,0,101,0,116,0,99,0,104,0,85,0,112,0,32,0,77,0,111,0,100,0,101,0,108,0],{offset:2})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:void 0;if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"};if(this.buffer.length>=2&&this.check([255,224],{offset:0,mask:[255,224]})){if(this.check([16],{offset:1,mask:[22]}))return this.check([8],{offset:1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}async readTiffTag(t){let r=await this.tokenizer.readToken(t?aSo:nSo);switch(this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(t){let r=await this.tokenizer.readToken(t?aSo:nSo);for(let i=0;i<r;++i){let n=await this.readTiffTag(t);if(n)return n}}async readTiffHeader(t){let r=(t?aSo:nSo).get(this.buffer,2),i=(t?lVp:cVp).get(this.buffer,4);if(r===42){if(i>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(i>=8&&(this.check([28,0,254,0],{offset:8})||this.check([31,0,11,0],{offset:8})))return{ext:"nef",mime:"image/x-nikon-nef"}}return await this.tokenizer.ignore(i),await this.readTiffIFD(t)??{ext:"tif",mime:"image/tiff"}}if(r===43)return{ext:"tif",mime:"image/tiff"}}};var mP6=new Set(yVp),PP6=new Set(vVp);var mVp=require("fs/promises"),PVp=Di(require("path"),1);var f0D=new Set(["image/jpeg","image/png","image/gif","image/webp","image/tiff","image/x-icon","video/quicktime","video/mp4","video/webm","audio/mpeg","audio/ogg","audio/wav","application/pdf","application/xml","font/woff","font/woff2","font/otf","font/ttf"]),d0D=new Set(["js","svg"]),p0D=new Set(["ASCII","UTF-8","UTF-16","ISO-8859-1","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-9","ISO-8859-10","ISO-8859-13","ISO-8859-14","ISO-8859-15","ISO-8859-16","WINDOWS-1250","WINDOWS-1251","WINDOWS-1252","WINDOWS-1253","WINDOWS-1254","WINDOWS-1255","WINDOWS-1256","WINDOWS-1257","WINDOWS-1258","SHIFT_JIS","SHIFT-JIS","EUC-JP","ISO-2022-JP","BIG5","GB2312","GB18030","KOI8-R"]),Q4s={name:"valid-file-types",create:()=>({filepath:async({absoluteFilepath:e,willBeUploaded:t})=>t?await zf(e)?_0D(e):[]:[]})},_0D=async e=>{let t=new Uint8Array(await(0,mVp.readFile)(e)),r=await gVp(t);if(r!=null)return f0D.has(r.mime)?[]:[{severity:"fatal",message:`The file type of ${r.mime} is not allowed: ${e}`}];let i=PVp.default.extname(e).toLowerCase();if(i.startsWith(".")&&(i=i.substring(1)),d0D.has(i)){let n=OVp.default.detect(t);return n==null?[{severity:"fatal",message:`The encoding of the file could not be detected: ${e}`}]:p0D.has(n.toUpperCase())?[]:[{severity:"fatal",message:`The encoding of ${n} is not allowed: ${e}`}]}return[{severity:"fatal",message:`File is not allowed to be uploaded: ${e}`}]};var jVp=require("fs/promises"),wVp=Di(U4r(),1),J4s={name:"valid-frontmatter",create:()=>({filepath:async({absoluteFilepath:e})=>{if(!e.endsWith(".md")&&!e.endsWith(".mdx"))return[];try{let t=await(0,jVp.readFile)(e,"utf-8");return(0,wVp.default)(t),[]}catch(t){return[{severity:"fatal",message:`Failed to parse frontmatter${t instanceof Error?`: ${t.message}`:""}`}]}}})};var K4s={name:"validate-version-file",create:()=>({versionFile:async({path:e,content:t})=>{let r=await H1o({value:t});return r.type==="success"?[]:[{severity:"fatal",message:`${r.message}`}]}})};function SVp(){return[s4s,c4s,K4s,UUp,Q4s,l4s,f4s,VUp,J4s]}var RVp=require("crypto");var DVp=require("fs"),oSo=class{parse({absoluteFilePath:t}){let r=(0,DVp.readFileSync)(t,"utf-8"),i=r.match(/option\s+csharp_namespace\s*=\s*"([^"]+)";/),n=r.match(/package\s+([a-zA-Z_][\w.]*);/),a=r.match(/service\s+([a-zA-Z_]\w*)\s*{/);return{csharpNamespace:i?.[1],packageName:n?.[1],serviceName:a?.[1]}}};var uSo=class{context;workspace;sourceCache;constructor(t,r){this.context=t,this.workspace=r,this.sourceCache=new Map}resolveSourceOrThrow({source:t,relativeFilepath:r}){let i=this.resolveSource({source:t});if(i==null){if(IWt(t))throw new Error(`Cannot resolve source ${t.proto} from file ${r}`);this.context.logger.warn(`Cannot resolve source ${t.openapi} from file ${r}`)}return i}resolveSource({source:t}){return IWt(t)?this.resolveProtobufSource({source:t}):this.resolveOpenAPISource({source:t})}resolveProtobufSource({source:t}){let r=ku(this.workspace.absoluteFilePath,yo.of(t.proto));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!o6r(r))return;let n=new oSo().parse({absoluteFilePath:r}),a={type:"protobuf",absoluteFilePath:r,relativeFilePath:yo.of(t.proto),csharpNamespace:n.csharpNamespace,packageName:n.packageName,serviceName:n.serviceName};return this.sourceCache.set(r,a),a}resolveOpenAPISource({source:t}){let r=ku(this.workspace.absoluteFilePath,yo.of(t.openapi));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!o6r(r))return;let i={type:"openapi",absoluteFilePath:r,relativeFilePath:yo.of(t.openapi)};return this.sourceCache.set(r,i),i}};function h0D(e){for(var t=[],r=0;r<e.length;){var i=e[r];if(i==="*"||i==="+"||i==="?"){t.push({type:"MODIFIER",index:r,value:e[r++]});continue}if(i==="\\"){t.push({type:"ESCAPED_CHAR",index:r++,value:e[r++]});continue}if(i==="{"){t.push({type:"OPEN",index:r,value:e[r++]});continue}if(i==="}"){t.push({type:"CLOSE",index:r,value:e[r++]});continue}if(i===":"){for(var n="",a=r+1;a<e.length;){var u=e.charCodeAt(a);if(u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||u===95){n+=e[a++];continue}break}if(!n)throw new TypeError("Missing parameter name at ".concat(r));t.push({type:"NAME",index:r,value:n}),r=a;continue}if(i==="("){var l=1,f="",a=r+1;if(e[a]==="?")throw new TypeError('Pattern cannot start with "?" at '.concat(a));for(;a<e.length;){if(e[a]==="\\"){f+=e[a++]+e[a++];continue}if(e[a]===")"){if(l--,l===0){a++;break}}else if(e[a]==="("&&(l++,e[a+1]!=="?"))throw new TypeError("Capturing groups are not allowed at ".concat(a));f+=e[a++]}if(l)throw new TypeError("Unbalanced pattern at ".concat(r));if(!f)throw new TypeError("Missing pattern at ".concat(r));t.push({type:"PATTERN",index:r,value:f}),r=a;continue}t.push({type:"CHAR",index:r,value:e[r++]})}return t.push({type:"END",index:r,value:""}),t}function EVp(e,t){t===void 0&&(t={});for(var r=h0D(e),i=t.prefixes,n=i===void 0?"./":i,a=t.delimiter,u=a===void 0?"/#?":a,l=[],f=0,s=0,o="",c=function(U){if(s<r.length&&r[s].type===U)return r[s++].value},b=function(U){var H=c(U);if(H!==void 0)return H;var te=r[s],J=te.type,ee=te.index;throw new TypeError("Unexpected ".concat(J," at ").concat(ee,", expected ").concat(U))},g=function(){for(var U="",H;H=c("CHAR")||c("ESCAPED_CHAR");)U+=H;return U},O=function(U){for(var H=0,te=u;H<te.length;H++){var J=te[H];if(U.indexOf(J)>-1)return!0}return!1},m=function(U){var H=l[l.length-1],te=U||(H&&typeof H=="string"?H:"");if(H&&!te)throw new TypeError('Must have text between two parameters, missing text after "'.concat(H.name,'"'));return!te||O(te)?"[^".concat(Tri(u),"]+?"):"(?:(?!".concat(Tri(te),")[^").concat(Tri(u),"])+?")};s<r.length;){var w=c("CHAR"),A=c("NAME"),M=c("PATTERN");if(A||M){var q=w||"";n.indexOf(q)===-1&&(o+=q,q=""),o&&(l.push(o),o=""),l.push({name:A||f++,prefix:q,suffix:"",pattern:M||m(q),modifier:c("MODIFIER")||""});continue}var D=w||c("ESCAPED_CHAR");if(D){o+=D;continue}o&&(l.push(o),o="");var C=c("OPEN");if(C){var q=g(),R=c("NAME")||"",$=c("PATTERN")||"",I=g();b("CLOSE"),l.push({name:R||($?f++:""),pattern:R&&!$?m(q):$,prefix:q,suffix:I,modifier:c("MODIFIER")||""});continue}b("END")}return l}function AVp(e,t){return y0D(EVp(e,t),t)}function y0D(e,t){t===void 0&&(t={});var r=Y4s(t),i=t.encode,n=i===void 0?function(f){return f}:i,a=t.validate,u=a===void 0?!0:a,l=e.map(function(f){if(typeof f=="object")return new RegExp("^(?:".concat(f.pattern,")$"),r)});return function(f){for(var s="",o=0;o<e.length;o++){var c=e[o];if(typeof c=="string"){s+=c;continue}var b=f?f[c.name]:void 0,g=c.modifier==="?"||c.modifier==="*",O=c.modifier==="*"||c.modifier==="+";if(Array.isArray(b)){if(!O)throw new TypeError('Expected "'.concat(c.name,'" to not repeat, but got an array'));if(b.length===0){if(g)continue;throw new TypeError('Expected "'.concat(c.name,'" to not be empty'))}for(var m=0;m<b.length;m++){var w=n(b[m],c);if(u&&!l[o].test(w))throw new TypeError('Expected all "'.concat(c.name,'" to match "').concat(c.pattern,'", but got "').concat(w,'"'));s+=c.prefix+w+c.suffix}continue}if(typeof b=="string"||typeof b=="number"){var w=n(String(b),c);if(u&&!l[o].test(w))throw new TypeError('Expected "'.concat(c.name,'" to match "').concat(c.pattern,'", but got "').concat(w,'"'));s+=c.prefix+w+c.suffix;continue}if(!g){var A=O?"an array":"a string";throw new TypeError('Expected "'.concat(c.name,'" to be ').concat(A))}}return s}}function MVp(e,t){var r=[],i=qVp(e,r,t);return v0D(i,r,t)}function v0D(e,t,r){r===void 0&&(r={});var i=r.decode,n=i===void 0?function(a){return a}:i;return function(a){var u=e.exec(a);if(!u)return!1;for(var l=u[0],f=u.index,s=Object.create(null),o=function(b){if(u[b]===void 0)return"continue";var g=t[b-1];g.modifier==="*"||g.modifier==="+"?s[g.name]=u[b].split(g.prefix+g.suffix).map(function(O){return n(O,g)}):s[g.name]=n(u[b],g)},c=1;c<u.length;c++)o(c);return{path:l,index:f,params:s}}}function Tri(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function Y4s(e){return e&&e.sensitive?"":"i"}function b0D(e,t){if(!t)return e;for(var r=/\((?:\?<(.*?)>)?(?!\?)/g,i=0,n=r.exec(e.source);n;)t.push({name:n[1]||i++,prefix:"",suffix:"",modifier:"",pattern:""}),n=r.exec(e.source);return e}function g0D(e,t,r){var i=e.map(function(n){return qVp(n,t,r).source});return new RegExp("(?:".concat(i.join("|"),")"),Y4s(r))}function O0D(e,t,r){return m0D(EVp(e,r),t,r)}function m0D(e,t,r){r===void 0&&(r={});for(var i=r.strict,n=i===void 0?!1:i,a=r.start,u=a===void 0?!0:a,l=r.end,f=l===void 0?!0:l,s=r.encode,o=s===void 0?function(H){return H}:s,c=r.delimiter,b=c===void 0?"/#?":c,g=r.endsWith,O=g===void 0?"":g,m="[".concat(Tri(O),"]|$"),w="[".concat(Tri(b),"]"),A=u?"^":"",M=0,q=e;M<q.length;M++){var D=q[M];if(typeof D=="string")A+=Tri(o(D));else{var C=Tri(o(D.prefix)),R=Tri(o(D.suffix));if(D.pattern)if(t&&t.push(D),C||R)if(D.modifier==="+"||D.modifier==="*"){var $=D.modifier==="*"?"?":"";A+="(?:".concat(C,"((?:").concat(D.pattern,")(?:").concat(R).concat(C,"(?:").concat(D.pattern,"))*)").concat(R,")").concat($)}else A+="(?:".concat(C,"(").concat(D.pattern,")").concat(R,")").concat(D.modifier);else{if(D.modifier==="+"||D.modifier==="*")throw new TypeError('Can not repeat "'.concat(D.name,'" without a prefix and suffix'));A+="(".concat(D.pattern,")").concat(D.modifier)}else A+="(?:".concat(C).concat(R,")").concat(D.modifier)}}if(f)n||(A+="".concat(w,"?")),A+=r.endsWith?"(?=".concat(m,")"):"$";else{var I=e[e.length-1],U=typeof I=="string"?w.indexOf(I[I.length-1])>-1:I===void 0;n||(A+="(?:".concat(w,"(?=").concat(m,"))?")),U||(A+="(?=".concat(w,"|").concat(m,")"))}return new RegExp(A,Y4s(r))}function qVp(e,t,r){return e instanceof RegExp?b0D(e,t):Array.isArray(e)?g0D(e,t,r):O0D(e,t,r)}function TVp(e){return e.split(/[?#]/)[0]??""}function sSo(e){return e.startsWith("/")?e.slice(1):e}function X4s(e){return e.startsWith("/")?e:`/${e}`}function cSo(e){return e.endsWith("/")?e.slice(0,-1):e}function CVp(e){let t=[];return e.config.instances.forEach(r=>{t.push(r.url),typeof r.customDomain=="string"?t.push(r.customDomain):Array.isArray(r.customDomain)&&t.push(...r.customDomain)}),t}function Z4s(e){let t=new URL(Zwe(e));return{domain:t.host,basePath:t.pathname==="/"||t.pathname===""?void 0:t.pathname}}function P0D(e,t){if(e===t)return{params:{},path:t,index:0};try{return MVp(e)(t)}catch(r){return console.error(r,{pattern:e,path:t}),!1}}function j0D(e,t){try{return AVp(e)(t.params)}catch(r){return console.error(r,{match:t,destination:e}),e}}function BVp(e,t,r=[]){for(let i of r){let n=cSo(w0D(i.source,t.basePath)),a=P0D(n,e);if(a){let u=j0D(i.destination,a);if(!u.startsWith("/"))try{new URL(u)}catch{console.error("Invalid redirect destination:",u);return}return{redirect:{destination:encodeURI(u),permanent:i.permanent??!1}}}}}function w0D(e,t){return t==null||e.startsWith(t)?e:Iv(t,e)}async function k4s({pathname:e,markdown:t,absoluteFilepath:r,workspaceAbsoluteFilePath:i,pageSlugs:n,absoluteFilePathsToSlugs:a,redirects:u=[],baseUrl:l}){e=cSo(e);let f=r!=null?a.get(r)??[]:[];if(e.trim()==="")return!0;if(e.startsWith("/")){let o=xVp(e,l,u);if(t&&n.has(sSo(o)))return!0;let c=ku(i,yo.of(sSo(e)));return await zf(c,"file")?!0:f.map(b=>X4s(b))}if(r!=null){let o=ku(Mp(r),yo.of(e));if(await zf(o,"file"))return!0}if(!t)return f.map(o=>X4s(o));let s=[];for(let o of f){let c=new URL(`/${o}`,Zwe(l.domain)),b=xVp(new URL(e,c).pathname,l,u);n.has(sSo(b))||s.push(o)}return s.length>0?s:!0}function xVp(e,t,r){let i=BVp(e,t,r);return i==null?e:i.redirect.destination}var IVp=/^(?:[a-z+]+:)/gi;function S0D(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);return r?(r[0].match(/\n/g)||[]).length+1:0}function e8s(e,t){return e&&{...e,start:{...e.start,line:e.start.line+t},end:{...e.end,line:e.end.line+t}}}function t8s(e,{absoluteFilepath:t,instanceUrls:r}){let i=[],n=[],a=S0D(e),{links:u,sources:l}=IUp({content:e,absoluteFilepath:t});return u.forEach(f=>{if(f.href.trimStart().match(IVp)){if(!f.href.trimStart().startsWith("http"))return;try{let o=new URL(f.href);if(!r.some(c=>f.href.includes(c)))return;n.push({pathname:o.pathname,sourceFilepath:f.sourceFilepath,position:e8s(f.position,a),markdown:!0})}catch{i.push({severity:"warning",message:`Invalid URL: ${f.href}`})}return}let s=TVp(f.href);s.trim()!==""&&n.push({pathname:s,sourceFilepath:f.sourceFilepath,position:e8s(f.position,a),markdown:!0})}),l.forEach(f=>{if(f.src.match(IVp))try{new URL(f.src)}catch{i.push({severity:"warning",message:`Invalid URL: ${f.src}`});return}else n.push({pathname:f.src,sourceFilepath:f.sourceFilepath,position:e8s(f.position,a),markdown:!1})}),{pathnamesToCheck:n,violations:i}}var lSo=DKu({logger:h6r(Yo)}),oia={name:"valid-markdown-links",create:async({workspace:e,fernWorkspaces:t,ossWorkspaces:r})=>{let i=CVp(e),n=i[0]??"http://localhost",u=await new v6t(n,e,r,t,lSo).resolve();if(!u.config.root)throw new Error("Root node not found");let l=To.migrate.FernNavigationV1ToLatest.create().root(u.config.root),f=To.NodeCollector.collect(l),s=new Set,o=new Map,c=[];return f.slugMap.forEach((b,g)=>{if(s.add(g),b==null||!To.isPage(b))return;To.isApiLeaf(b)&&c.push(b);let O=To.getPageId(b);if(O==null)return;let m=ku(e.absoluteFilePath,yo.of(O)),w=o.get(m)??[];w.push(g),o.set(m,w)}),{markdownPage:async({content:b,absoluteFilepath:g})=>{let O=o.get(g);if(!O||O.length===0)return[];let m="error";O.every(q=>!f.indexablePageSlugs.includes(q))&&(m="warning");let{pathnamesToCheck:w,violations:A}=t8s(b,{absoluteFilepath:g,instanceUrls:i}),M=await Promise.all(w.map(async q=>{let D=await k4s({pathname:q.pathname,markdown:q.markdown,absoluteFilepath:g,workspaceAbsoluteFilePath:e.absoluteFilePath,pageSlugs:s,absoluteFilePathsToSlugs:o,redirects:e.config.redirects,baseUrl:Z4s(i[0]??"http://localhost")});return D===!0?[]:D.map(C=>{let R=zVp(q,C);return{name:oia.name,severity:m,message:R}})}));return[...A,...M.flat()]},apiSection:async({workspace:b,config:g})=>{let O=await b.toFernWorkspace({context:lSo},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1}),m=b2({workspace:O,audiences:g.audiences?{type:"select",audiences:g.audiences}:{type:"all"},generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1},readme:void 0,version:void 0,packageName:void 0,context:lSo,sourceResolver:new uSo(lSo,O)}),w=E0D(Ora(m,(0,RVp.randomUUID)())),A=[];for(let M of c){let q=await A0D(dri.prune(w,M));for(let D of q){let{pathnamesToCheck:C,violations:R}=t8s(D,{instanceUrls:i});A.push(...R);let $=await Promise.all(C.map(async I=>{let U=await k4s({pathname:I.pathname,markdown:I.markdown,workspaceAbsoluteFilePath:e.absoluteFilePath,pageSlugs:s,absoluteFilePathsToSlugs:o,redirects:e.config.redirects,baseUrl:Z4s(i[0]??"http://localhost")});return U===!0?[]:U.map(H=>{let te=zVp(I,H);return{name:oia.name,severity:"error",message:te}})}));A.push(...$.flat())}}return A}}}};function zVp(e,t){return`${D0D(e)}Page (${t}) contains a link to ${Su.bold(e.pathname)} that does not exist.`}function D0D(e){let{position:t,sourceFilepath:r}=e;return r==null||t==null?"":`[${r.toString()}:${t.start.line}:${t.start.column}] `}function E0D(e){return dri.ApiDefinitionV1ToLatest.from(e,{useJavaScriptAsTypeScript:!1,alwaysEnableJavaScriptFetch:!1,usesApplicationJsonInFormDataValue:!1}).migrate()}async function A0D(e){let t=[];return dri.Transformer.descriptions(r=>(typeof r=="string"&&t.push(r),r)).apiDefinition(e),t}async function uia(e,t,r,i,n){let a=n?[oia]:SVp();return M0D({workspace:e,rules:a,context:t,fernWorkspaces:r,ossWorkspaces:i})}async function M0D({workspace:e,rules:t,context:r,fernWorkspaces:i,ossWorkspaces:n}){let a=[],u=await Promise.all(t.map(f=>f.create({workspace:e,fernWorkspaces:i,ossWorkspaces:n,logger:r.logger}))),l=zUp({relativeFilepath:yo.of(H3t),allRuleVisitors:u,addViolations:f=>{a.push(...f)}});return await LUp({contents:e.config,visitor:l,absoluteFilepathToConfiguration:ku(e.absoluteFilePath,yo.of(H3t)),absolutePathToFernFolder:e.absoluteFilePath,context:r,fernWorkspaces:i}),a}async function r8s({workspace:e,fernWorkspaces:t,ossWorkspaces:r,context:i,logWarnings:n,errorOnBrokenLinks:a,logSummary:u=!0}){let l=await uia(e,i,t,r),{hasErrors:f}=qri({violations:l,context:i,logWarnings:n,logSummary:u});return a&&(f=f||l.some(s=>s.name==="valid-markdown-links")),{hasErrors:f}}async function fSo({workspace:e,fernWorkspaces:t,ossWorkspaces:r,context:i,logWarnings:n,errorOnBrokenLinks:a}){let{hasErrors:u}=await r8s({workspace:e,context:i,logWarnings:n,fernWorkspaces:t,ossWorkspaces:r,errorOnBrokenLinks:a});u&&i.failAndThrow()}async function FVp({loadProject:e,cliContext:t,port:r,bundlePath:i}){let n=await e(),a=n.docsWorkspaces;a!=null&&(await t.instrumentPostHogEvent({orgId:n.config.organization,command:"fern docs dev"}),await t.runTaskForWorkspace(a,async u=>{u.logger.info(`Starting server on port ${r}`),await $2s({initialProject:n,reloadProject:e,validateProject:async l=>{let f=l.docsWorkspaces;if(f==null)return;let s=await Promise.all(l.apiWorkspaces.map(async o=>o.toFernWorkspace({context:u})));await r8s({workspace:f,context:u,logWarnings:!0,logSummary:!1,fernWorkspaces:s,ossWorkspaces:await ere(l)});for(let o of s)await t.runTaskForWorkspace(o,async c=>{await t4s({workspace:o,context:c,logWarnings:!1,logSummary:!1})})},context:u,port:r,bundlePath:i})}))}async function NVp({project:e,cliContext:t,shouldFix:r}){await Promise.all(e.apiWorkspaces.map(async i=>{i instanceof s8||await t.runTaskForWorkspace(i,async n=>{await Nhs({workspace:await i.toFernWorkspace({context:n}),context:n,shouldFix:r})})}))}var LVp=Di(require("path"),1);async function Bhn({workspace:e,context:t,generationLanguage:r,keywords:i,smartCasing:n,disableExamples:a,audiences:u,readme:l}){return await oJt({workspace:e,context:t,logWarnings:!1}),b2({workspace:e,generationLanguage:r,keywords:i,smartCasing:n,exampleGeneration:{disabled:a},audiences:u,readme:l,version:void 0,packageName:void 0,context:t,sourceResolver:new y2(t,e)})}async function UVp({project:e,irFilepath:t,cliContext:r,generationLanguage:i,audiences:n,version:a,keywords:u,smartCasing:l}){await Promise.all(e.apiWorkspaces.map(async f=>{await r.runTaskForWorkspace(f,async s=>{r.logger.info(`Generating IR for workspace ${f.workspaceName??"api"}`);let o=await f.toFernWorkspace({context:s}),c=await Bhn({workspace:o,context:s,generationLanguage:i,keywords:u,smartCasing:l,disableExamples:!1,audiences:n,readme:void 0});if(c.dynamic==null)throw new Error("Internal error; dynamic IR was not generated");let b=LVp.default.resolve(t);await c6r(Kl.of(b),c.dynamic),s.logger.info(`Wrote IR to ${b}`)})}))}var VVp=require("fs/promises"),WVp=Di(require("path"),1);async function HVp({project:e,outputFilepath:t,cliContext:r,audiences:i}){await Promise.all(e.apiWorkspaces.map(async n=>{await r.runTaskForWorkspace(n,async a=>{let u=await n.toFernWorkspace({context:a}),l=await Bhn({workspace:u,context:a,generationLanguage:void 0,audiences:i,keywords:void 0,smartCasing:!1,disableExamples:!1,readme:void 0}),f=Xwe({ir:l,snippetsConfig:{typescriptSdk:void 0,pythonSdk:void 0,javaSdk:void 0,rubySdk:void 0,goSdk:void 0}}),s=WVp.default.resolve(t);await(0,VVp.writeFile)(s,await d6r(f,{pretty:!0})),a.logger.info(`Wrote FDR API definition to ${s}`)})}))}var qxm=Di(require("path"),1);var Ge=Symbol(),ni=Symbol();var $Vp={laterVersion:"v2",earlierVersion:"v1",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.0.246",[K.TYPESCRIPT_EXPRESS]:"0.0.264",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:ni,[K.STOPLIGHT]:ni,[K.OPENAPI_PYTHON_CLIENT]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>({apiName:e.apiName,auth:e.auth,headers:e.headers,types:e.types,services:e.services,constants:e.constants,constantsV2:e.constantsV2,defaultEnvironment:e.defaultEnvironment,environments:e.environments,errorDiscriminant:e.errorDiscriminant,errorDiscriminationStrategy:e.errorDiscriminationStrategy,sdkConfig:e.sdkConfig,errors:e.errors.map(t=>({name:t.name,docs:t.docs,discriminantValue:{originalValue:t.discriminantValueV4.name.unsafeName.originalValue,camelCase:t.discriminantValueV4.name.unsafeName.camelCase,pascalCase:t.discriminantValueV4.name.unsafeName.pascalCase,snakeCase:t.discriminantValueV4.name.unsafeName.snakeCase,screamingSnakeCase:t.discriminantValueV4.name.unsafeName.screamingSnakeCase,wireValue:t.discriminantValueV4.wireValue},discriminantValueV2:t.discriminantValueV2,discriminantValueV3:t.discriminantValueV3,discriminantValueV4:t.discriminantValueV4,type:t.type,typeV2:t.typeV2,typeV3:t.typeV3,http:t.http,statusCode:t.statusCode}))})};var he={};Ro(he,{V1:()=>RPC,V10:()=>FPC,V11:()=>NPC,V12:()=>LPC,V13:()=>UPC,V14:()=>VPC,V15:()=>WPC,V16:()=>HPC,V17:()=>$PC,V18:()=>GPC,V19:()=>QPC,V2:()=>JPC,V20:()=>KPC,V21:()=>YPC,V22:()=>XPC,V23:()=>y00.FernIrV23,V24:()=>v00.FernIrV24,V25:()=>b00.FernIrV25,V26:()=>g00.FernIrV26,V27:()=>O00.FernIrV27,V28:()=>m00.FernIrV28,V29:()=>P00.FernIrV29,V3:()=>ZPC,V30:()=>j00.FernIrV30,V31:()=>w00.FernIrV31,V32:()=>S00.FernIrV32,V33:()=>D00.FernIrV33,V34:()=>E00.FernIrV34,V35:()=>A00.FernIrV35,V36:()=>M00.FernIrV36,V37:()=>q00.FernIrV37,V38:()=>T00.FernIrV38,V39:()=>C00.FernIrV39,V4:()=>kPC,V40:()=>B00.FernIrV40,V41:()=>x00.FernIrV41,V42:()=>I00.FernIrV42,V43:()=>z00.FernIrV43,V44:()=>R00.FernIrV44,V45:()=>F00.FernIrV45,V46:()=>N00.FernIrV46,V47:()=>L00.FernIrV47,V48:()=>U00.FernIrV48,V49:()=>V00.FernIrV49,V5:()=>ejC,V50:()=>W00.FernIrV50,V51:()=>H00.FernIrV51,V52:()=>$00.FernIrV52,V53:()=>G00.FernIrV53,V54:()=>Q00.FernIrV54,V55:()=>Bc,V6:()=>tjC,V7:()=>rjC,V8:()=>ijC,V9:()=>njC});var RPC=Di(LJp(),1),FPC=Di(ut_(),1),NPC=Di(Tu_(),1),LPC=Di(A__(),1),UPC=Di(SO_(),1),VPC=Di(PD_(),1),WPC=Di(gB_(),1),HPC=Di(T3_(),1),$PC=Di(W9_(),1),GPC=Di(tQ_(),1),QPC=Di(yeh(),1),JPC=Di(foh(),1),KPC=Di(Uph(),1),YPC=Di(OOh(),1),XPC=Di(kDh(),1),y00=Di(bTh(),1),v00=Di(tzh(),1),b00=Di(V3h(),1),g00=Di(B8h(),1),O00=Di(AVh(),1),m00=Di(wQh(),1),P00=Di(OZh(),1),ZPC=Di(lay(),1),j00=Di(dly(),1),w00=Di(_hy(),1),S00=Di(Sgy(),1),D00=Di(ric(),1),E00=Di(JMy(),1),A00=Di(WIy(),1),M00=Di(F7y(),1),q00=Di(I9y(),1),T00=Di(I$y(),1),C00=Di(ZXy(),1),kPC=Di(Ynv(),1),B00=Di(pfv(),1),x00=Di(Cvv(),1),I00=Di(tjv(),1),z00=Di(DAv(),1),R00=Di(Zxv(),1),F00=Di(N7v(),1),N00=Di(CLv(),1),L00=Di(MQv(),1),U00=Di(Deb(),1),V00=Di(Dub(),1),ejC=Di(fpb(),1),W00=Di(Ogb(),1),H00=Di(NSb(),1),$00=Di(cBb(),1),G00=Di(R4b(),1),Q00=Di(gJb(),1),tjC=Di(Ee0(),1),rjC=Di(Io0(),1),ijC=Di(Wd0(),1),njC=Di(h00(),1);function J00({inlinedRequest:e,allTypes:t}){let r=new Set,i=t.reduce((n,a)=>({...n,[zyc(a.name)]:a}),{});for(let n of e.extends)K00({typeName:n,typeNameToDeclaration:i,referencedTypes:r});for(let n of e.properties)Qbn({reference:n.valueType,typeNameToDeclaration:i,referencedTypes:r});return[...r].reduce((n,a)=>{let u=i[a];if(u==null)throw new Error("Cannot find declaration for ID: "+a);return[...n,u.name]},[])}function Qbn({reference:e,typeNameToDeclaration:t,referencedTypes:r}){he.V2.types.TypeReference._visit(e,{primitive:Yo,container:i=>{ajC({container:i,typeNameToDeclaration:t,referencedTypes:r})},named:i=>{K00({typeName:i,typeNameToDeclaration:t,referencedTypes:r})},unknown:Yo,void:Yo,_unknown:()=>{throw new Error("Unknown TypeReference: "+e._type)}})}function ajC({container:e,typeNameToDeclaration:t,referencedTypes:r}){he.V2.types.ContainerType._visit(e,{list:i=>{Qbn({reference:i,typeNameToDeclaration:t,referencedTypes:r})},set:i=>{Qbn({reference:i,typeNameToDeclaration:t,referencedTypes:r})},optional:i=>{Qbn({reference:i,typeNameToDeclaration:t,referencedTypes:r})},map:({keyType:i,valueType:n})=>{Qbn({reference:i,typeNameToDeclaration:t,referencedTypes:r}),Qbn({reference:n,typeNameToDeclaration:t,referencedTypes:r})},literal:Yo,_unknown:()=>{throw new Error("Unknown ContainerType: "+e._type)}})}function K00({typeName:e,typeNameToDeclaration:t,referencedTypes:r}){let i=zyc(e);r.add(i);let n=t[i];if(n==null)throw new Error("Cannot locate type: "+i);for(let a of n.referencedTypes)r.add(zyc(a))}function zyc(e){return[...e.fernFilepathV2.map(t=>t.unsafeName.originalValue),e.nameV3.unsafeName.originalValue].join(".")}var Y00={laterVersion:"v3",earlierVersion:"v2",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.0.249",[K.TYPESCRIPT_EXPRESS]:"0.0.264",[K.JAVA]:Ge,[K.JAVA_MODEL]:"0.0.134-3-g97d4964",[K.JAVA_SDK]:"0.0.134-3-g97d4964",[K.JAVA_SPRING]:"0.0.134-3-g97d4964",[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:ni,[K.STOPLIGHT]:ni,[K.OPENAPI_PYTHON_CLIENT]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>{let t=[...e.types];return{apiName:e.apiName,auth:e.auth,headers:e.headers,types:t,errors:e.errors,constants:e.constants,constantsV2:e.constantsV2,defaultEnvironment:e.defaultEnvironment,environments:e.environments,errorDiscriminant:e.errorDiscriminant,errorDiscriminationStrategy:e.errorDiscriminationStrategy,sdkConfig:e.sdkConfig,services:{websocket:e.services.websocket,http:e.services.http.map(r=>({availability:r.availability,docs:r.docs,name:r.name,basePath:r.basePath,basePathV2:r.basePathV2,headers:r.headers,pathParameters:r.pathParameters,endpoints:r.endpoints.map(i=>ojC(r,i,e.types,n=>{t.push(n)}))}))}}}};function ojC(e,t,r,i){return{docs:t.docs,availability:t.availability,id:t.id,name:t.name,nameV2:t.nameV2,method:t.method,headers:t.headers,path:t.path,pathParameters:t.pathParameters,queryParameters:t.queryParameters,request:ujC(t,e,r,i),response:t.response,errors:t.errors,errorsV2:t.errorsV2,auth:t.auth}}function ujC(e,t,r,i){let n=e.requestBody;return n==null?{docs:void 0,type:he.V2.types.TypeReference.void(),typeV2:void 0}:he.V3.services.http.HttpRequestBody._visit(n,{reference:a=>({docs:a.docs,type:a.requestBodyType,typeV2:a.requestBodyType}),inlinedRequestBody:a=>{let u={fernFilepath:t.name.fernFilepath,fernFilepathV2:t.name.fernFilepathV2,name:a.name.unsafeName.originalValue,nameV2:{originalValue:a.name.unsafeName.originalValue,camelCase:a.name.unsafeName.camelCase,pascalCase:a.name.unsafeName.pascalCase,snakeCase:a.name.unsafeName.snakeCase,screamingSnakeCase:a.name.unsafeName.screamingSnakeCase},nameV3:a.name},l=he.V2.types.Type.object({extends:a.extends,properties:a.properties.map(s=>({availability:e.availability,docs:s.docs,name:{originalValue:s.name.name.unsafeName.originalValue,camelCase:s.name.name.unsafeName.camelCase,pascalCase:s.name.name.unsafeName.pascalCase,snakeCase:s.name.name.unsafeName.snakeCase,screamingSnakeCase:s.name.name.unsafeName.screamingSnakeCase,wireValue:s.name.wireValue},nameV2:s.name,valueType:s.valueType}))});i({docs:void 0,availability:e.availability,name:u,shape:l,referencedTypes:J00({inlinedRequest:a,allTypes:r}),examples:[]});let f=he.V2.types.TypeReference.named(u);return{docs:void 0,type:f,typeV2:f}},_unknown:()=>{throw new Error("Unknown HttpRequestBody type: "+n.type)}})}var k00={laterVersion:"v4",earlierVersion:"v3",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:"0.0.264",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI]:"0.0.11-4-g1c29f6c",[K.POSTMAN]:"0.0.32-rc0",[K.STOPLIGHT]:ni,[K.OPENAPI_PYTHON_CLIENT]:ni,[K.PYTHON_SDK]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>({apiName:e.apiName,auth:e.auth,headers:e.headers,types:e.types.map(t=>({docs:t.docs,availability:t.availability,name:t.name,shape:t.shape,examples:t.examples.map(r=>eg0(r.shape)),referencedTypes:t.referencedTypes})),errors:e.errors,constants:e.constants,constantsV2:e.constantsV2,defaultEnvironment:e.defaultEnvironment,environments:e.environments,errorDiscriminant:e.errorDiscriminant,errorDiscriminationStrategy:e.errorDiscriminationStrategy,sdkConfig:e.sdkConfig,services:{...e.services,http:e.services.http.map(t=>({...t,endpoints:t.endpoints.map(r=>({...r,examples:r.examples.map(i=>djC(i))}))}))}})};function eg0(e){return he.V4.types.ExampleTypeShape._visit(e,{object:t=>he.V3.types.ExampleType.object(sjC(t)),union:t=>he.V3.types.ExampleType.union(ljC(t)),alias:t=>he.V3.types.ExampleType.alias(fjC(t)),enum:he.V3.types.ExampleType.enum,_unknown:()=>{throw new Error("Unknown ExampleTypeShape: "+e.type)}})}function sjC(e){return{properties:e.properties.map(t=>({wireKey:t.wireKey,value:rX(t.value),originalTypeDeclaration:t.originalTypeDeclaration}))}}function rX(e){return he.V4.types.ExampleTypeReferenceShape._visit(e.shape,{primitive:he.V3.types.ExampleTypeReference.primitive,container:t=>he.V3.types.ExampleTypeReference.container(cjC(t)),named:t=>he.V3.types.ExampleTypeReference.named(tg0(t)),unknown:he.V3.types.ExampleTypeReference.unknown,_unknown:()=>{throw new Error("Unknown ExampleTypeReference: "+e.shape.type)}})}function cjC(e){return he.V4.types.ExampleContainer._visit(e,{list:t=>he.V3.types.ExampleContainer.list(t.map(rX)),set:t=>he.V3.types.ExampleContainer.set(t.map(rX)),optional:t=>he.V3.types.ExampleContainer.optional(t!=null?rX(t):void 0),map:t=>he.V3.types.ExampleContainer.map(t.map(r=>({key:rX(r.key),value:rX(r.value)}))),_unknown:()=>{throw new Error("Unknown ExampleContainer: "+e.type)}})}function tg0(e){return{typeName:e.typeName,shape:eg0(e.shape)}}function ljC(e){return{wireDiscriminantValue:e.wireDiscriminantValue,properties:he.V4.types.ExampleSingleUnionTypeProperties._visit(e.properties,{samePropertiesAsObject:t=>he.V3.types.ExampleSingleUnionTypeProperties.samePropertiesAsObject(tg0(t)),singleProperty:t=>he.V3.types.ExampleSingleUnionTypeProperties.singleProperty(rX(t)),noProperties:()=>he.V3.types.ExampleSingleUnionTypeProperties.noProperties(),_unknown:()=>{throw new Error("Unknown ExampleSingleUnionTypeProperties: "+e.properties.type)}})}}function fjC(e){return{value:rX(e.value)}}function djC(e){return{servicePathParameters:e.servicePathParameters.map(t=>X00(t)),endpointPathParameters:e.servicePathParameters.map(t=>X00(t)),serviceHeaders:e.serviceHeaders.map(t=>Z00(t)),endpointHeaders:e.endpointHeaders.map(t=>Z00(t)),queryParameters:e.queryParameters.map(t=>pjC(t)),request:e.request!=null?_jC(e.request):void 0,response:yjC(e.response)}}function X00(e){return{key:e.key,value:rX(e.value)}}function Z00(e){return{key:e.wireKey,value:rX(e.value)}}function pjC(e){return{key:e.wireKey,value:rX(e.value)}}function _jC(e){return he.V4.services.http.ExampleRequestBody._visit(e,{inlinedRequestBody:t=>he.V3.services.http.ExampleRequestBody.inlinedRequestBody({properties:t.properties.map(r=>hjC(r))}),reference:t=>he.V3.services.http.ExampleRequestBody.reference(rX(t)),_unknown:()=>{throw new Error("Unknown ExampleRequestBody: "+e.type)}})}function hjC(e){return{wireKey:e.wireKey,value:rX(e.value),originalTypeDeclaration:e.originalTypeDeclaration}}function yjC(e){return he.V4.services.http.ExampleResponse._visit(e,{ok:t=>he.V3.services.http.ExampleResponse.ok({body:t.body!=null?rX(t.body):void 0}),error:t=>he.V3.services.http.ExampleResponse.error({error:t.error,body:t.body!=null?rX(t.body):void 0}),_unknown:()=>{throw new Error("Unknown ExampleResponse: "+e.type)}})}var cCo=class{errors;constructor(t){this.errors=t.errors.reduce((r,i)=>({...r,[rg0(i.name)]:i}),{})}getDeclaration(t){let r=rg0(t),i=this.errors[r];if(i==null)throw new Error("Error does not exist: "+r);return i}};function rg0(e){return`${e.fernFilepath.join("/")}:${e.name.originalName}`}function Z4t(e){return{originalValue:e.originalName,camelCase:e.camelCase.unsafeName,pascalCase:e.pascalCase.unsafeName,snakeCase:e.snakeCase.unsafeName,screamingSnakeCase:e.screamingSnakeCase.unsafeName}}function cSe(e){return{...Z4t(e.name),wireValue:e.wireValue}}function q2(e){return{safeName:{originalValue:e.originalName,camelCase:e.camelCase.safeName,pascalCase:e.pascalCase.safeName,snakeCase:e.snakeCase.safeName,screamingSnakeCase:e.screamingSnakeCase.safeName},unsafeName:{originalValue:e.originalName,camelCase:e.camelCase.unsafeName,pascalCase:e.pascalCase.unsafeName,snakeCase:e.snakeCase.unsafeName,screamingSnakeCase:e.screamingSnakeCase.unsafeName}}}function T2(e){return{wireValue:e.wireValue,name:q2(e.name)}}function aRi(e){return e.map(t=>Z4t(t))}function oRi(e){return e.map(t=>q2(t))}function K8(e){return{fernFilepath:aRi(e.fernFilepath),fernFilepathV2:oRi(e.fernFilepath),name:e.name.originalName,nameV2:Z4t(e.name),nameV3:q2(e.name)}}function BI(e){return he.V5.types.TypeReference._visit(e,{named:t=>he.V4.types.TypeReference.named(K8(t)),container:t=>he.V4.types.TypeReference.container(Jbn(t)),primitive:t=>he.V4.types.TypeReference.primitive(t),unknown:he.V4.types.TypeReference.unknown,_unknown:()=>{throw new Error("Unknown TypeReference: "+e._type)}})}function Jbn(e){return he.V5.types.ContainerType._visit(e,{list:t=>he.V4.types.ContainerType.list(BI(t)),set:t=>he.V4.types.ContainerType.set(BI(t)),map:({keyType:t,valueType:r})=>he.V4.types.ContainerType.map({keyType:BI(t),valueType:BI(r)}),optional:t=>he.V4.types.ContainerType.optional(BI(t)),literal:t=>he.V5.types.Literal._visit(t,{string:r=>he.V4.types.ContainerType.literal(he.V4.types.Literal.string(r)),_unknown:()=>{throw new Error("Unknown Literal: "+t.type)}}),_unknown:()=>{throw new Error("Unknown ContainerType: "+e._type)}})}var lCo=class{types;constructor(t){this.types=t.types.reduce((r,i)=>({...r,[ig0(i.name)]:i}),{})}resolveTypeReference(t){return he.V5.types.TypeReference._visit(t,{container:r=>he.V4.types.ResolvedTypeReference.container(Jbn(r)),named:r=>{let i=this.getTypeDeclaration(r);return i.shape._type==="alias"?this.resolveTypeReference(i.shape.aliasOf):he.V4.types.ResolvedTypeReference.named({name:K8(r),shape:vjC(i.shape._type)})},primitive:he.V4.types.ResolvedTypeReference.primitive,unknown:he.V4.types.ResolvedTypeReference.unknown,_unknown:()=>{throw new Error("Unknown TypeReference: "+t._type)}})}getTypeDeclaration(t){let r=ig0(t),i=this.types[r];if(i==null)throw new Error("Type does not exist: "+i);return i}};function ig0(e){return`${e.fernFilepath.join("/")}:${e.name.originalName}`}function vjC(e){switch(e){case"object":return he.V4.types.ShapeType.Object;case"union":return he.V4.types.ShapeType.Union;case"enum":return he.V4.types.ShapeType.Enum;default:Zo(e)}}function uRi(e){return{name:cSe(e.name),nameV2:T2(e.name),valueType:BI(e.valueType),availability:e.availability,docs:e.docs}}function ng0(e){return{docs:e.docs,requirement:e.requirement,schemes:e.schemes.map(t=>bjC(t))}}function bjC(e){return he.V5.auth.AuthScheme._visit(e,{basic:he.V4.auth.AuthScheme.basic,bearer:he.V4.auth.AuthScheme.bearer,header:t=>he.V4.auth.AuthScheme.header(uRi(t)),_unknown:()=>{throw new Error("Unknown AuthScheme: "+e._type)}})}function ag0(e){return{docs:e.docs,id:e.id,url:e.url,name:q2(e.name)}}function og0({errorDeclaration:e,errorDiscriminationStrategy:t,typeReferenceResolver:r}){let i=e.type!=null?he.V4.types.Type.alias({aliasOf:BI(e.type),resolvedType:r.resolveTypeReference(e.type)}):void 0;return{docs:e.docs,name:{name:e.name.name.originalName,nameV2:Z4t(e.name.name),nameV3:q2(e.name.name),fernFilepath:aRi(e.name.fernFilepath),fernFilepathV2:oRi(e.name.fernFilepath)},discriminantValueV2:T2(e.discriminantValue),discriminantValueV3:he.V5.ir.ErrorDiscriminationStrategy._visit(t,{statusCode:he.V4.errors.ErrorDeclarationDiscriminantValue.statusCode,property:n=>he.V4.errors.ErrorDeclarationDiscriminantValue.property(T2(n.contentProperty)),_unknown:()=>{throw new Error("Unknown ErrorDiscriminationStrategy: "+t.type)}}),discriminantValueV4:T2(e.discriminantValue),type:i??he.V4.types.Type.alias({aliasOf:he.V4.types.TypeReference.void(),resolvedType:he.V4.types.ResolvedTypeReference.void()}),typeV2:i,typeV3:e.type!=null?BI(e.type):e.type,http:{statusCode:e.statusCode},statusCode:e.statusCode}}function iX(e){return{jsonExample:e.jsonExample,shape:ug0(e.shape)}}function ug0(e){return he.V5.types.ExampleTypeReferenceShape._visit(e,{primitive:he.V4.types.ExampleTypeReferenceShape.primitive,container:t=>he.V4.types.ExampleTypeReferenceShape.container(OjC(t)),unknown:he.V4.types.ExampleTypeReferenceShape.unknown,named:t=>he.V4.types.ExampleTypeReferenceShape.named(gjC(t)),_unknown:()=>{throw new Error("Unknown ExampleTypeReferenceShape: "+e.type)}})}function gjC(e){return{typeName:K8(e.typeName),shape:fCo(e.shape)}}function OjC(e){return he.V5.types.ExampleContainer._visit(e,{list:t=>he.V4.types.ExampleContainer.list(t.map(r=>iX(r))),set:t=>he.V4.types.ExampleContainer.set(t.map(r=>iX(r))),optional:t=>he.V4.types.ExampleContainer.optional(t!=null?iX(t):void 0),map:t=>he.V4.types.ExampleContainer.map(t.map(r=>({key:iX(r.key),value:iX(r.value)}))),_unknown:()=>{throw new Error("Unknown ExampleContainer: "+e.type)}})}function fCo(e){return he.V5.types.ExampleTypeShape._visit(e,{alias:t=>he.V4.types.ExampleTypeShape.alias({value:iX(t.value)}),object:t=>he.V4.types.ExampleTypeShape.object({properties:t.properties.map(r=>({wireKey:r.wireKey,value:iX(r.value),originalTypeDeclaration:K8(r.originalTypeDeclaration)}))}),union:t=>he.V4.types.ExampleTypeShape.union({wireDiscriminantValue:t.wireDiscriminantValue,properties:he.V5.types.ExampleSingleUnionTypeProperties._visit(t.properties,{samePropertiesAsObject:r=>he.V4.types.ExampleSingleUnionTypeProperties.samePropertiesAsObject({typeName:K8(r.typeName),shape:fCo(r.shape)}),singleProperty:r=>he.V4.types.ExampleSingleUnionTypeProperties.singleProperty({jsonExample:r.jsonExample,shape:ug0(r.shape)}),noProperties:he.V4.types.ExampleSingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown ExampleSingleUnionTypeProperties: "+t.properties.type)}})}),enum:t=>he.V4.types.ExampleTypeShape.enum({wireValue:t.wireValue}),_unknown:()=>{throw new Error("Unknown ExampleTypeShape: "+e.type)}})}function lg0({service:e,errorResolver:t}){return{docs:e.docs,availability:e.availability,displayName:e.displayName,name:mjC(e.name),basePath:PjC(e.basePath),basePathV2:e.basePath,endpoints:e.endpoints.map(r=>jjC({endpoint:r,errorResolver:t})),headers:e.headers.map(r=>uRi(r)),pathParameters:e.pathParameters.map(r=>fg0(r))}}function mjC(e){return{name:e.name.pascalCase.unsafeName,fernFilepath:aRi(e.fernFilepath),fernFilepathV2:oRi(e.fernFilepath)}}function PjC(e){return e.parts.reduce((t,r)=>t+`{${r.pathParameter}}`+r.tail,e.head)}function jjC({endpoint:e,errorResolver:t}){return{docs:e.docs,availability:e.availability,id:e.name.originalName,name:Z4t(e.name),nameV2:q2(e.name),displayName:e.displayName,method:e.method,headers:e.headers.map(r=>uRi(r)),path:e.path,pathParameters:e.pathParameters.map(r=>fg0(r)),queryParameters:e.queryParameters.map(r=>wjC(r)),requestBody:e.requestBody!=null?SjC(e.requestBody):void 0,sdkRequest:e.sdkRequest!=null?DjC(e.sdkRequest):void 0,response:EjC(e.response),errors:e.errors.map(r=>AjC(r)),errorsV2:MjC({responseErrors:e.errors,errorResolver:t}),auth:e.auth,examples:e.examples.map(r=>CjC(r))}}function fg0(e){return{docs:e.docs,availability:e.availability,name:Z4t(e.name),nameV2:q2(e.name),valueType:BI(e.valueType)}}function wjC(e){return{docs:e.docs,availability:e.availability,name:cSe(e.name),nameV2:T2(e.name),valueType:BI(e.valueType),allowMultiple:e.allowMultiple}}function SjC(e){return he.V5.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>he.V4.services.http.HttpRequestBody.inlinedRequestBody({name:q2(t.name),extends:t.extends.map(r=>K8(r)),properties:t.properties.map(r=>({docs:r.docs,name:T2(r.name),valueType:BI(r.valueType)}))}),reference:t=>he.V4.services.http.HttpRequestBody.reference({docs:t.docs,requestBodyType:BI(t.requestBodyType)}),_unknown:()=>{throw new Error("Unknown HttpRequestBody type: "+e.type)}})}function DjC(e){return{requestParameterName:q2(e.requestParameterName),shape:he.V5.http.SdkRequestShape._visit(e.shape,{justRequestBody:t=>he.V4.services.http.SdkRequestShape.justRequestBody({docs:t.docs,requestBodyType:BI(t.requestBodyType)}),wrapper:t=>he.V4.services.http.SdkRequestShape.wrapper({wrapperName:q2(t.wrapperName),bodyKey:q2(t.bodyKey)}),_unknown:()=>{throw new Error("Unknown SdkRequestShape type: "+e.shape.type)}})}}function EjC(e){let t=e.type!=null?BI(e.type):void 0;return{docs:e.docs,type:t??he.V4.types.TypeReference.void(),typeV2:t}}function AjC(e){return{docs:e.docs,error:Ryc(e.error)}}function MjC({responseErrors:e,errorResolver:t}){return{discriminant:{originalValue:"errorName",camelCase:"errorName",snakeCase:"error_name",pascalCase:"ErrorName",screamingSnakeCase:"ERROR_NAME",wireValue:"errorName"},types:e.map(r=>qjC({responseError:r,errorResolver:t}))}}function qjC({responseError:e,errorResolver:t}){let r=t.getDeclaration(e.error);return{docs:e.docs,discriminantValue:cSe(r.discriminantValue),shape:TjC({responseError:e,declaration:r})}}function TjC({responseError:e,declaration:t}){return t.type==null?he.V4.services.commons.ResponseErrorShape.noProperties():he.V4.services.commons.ResponseErrorShape.singleProperty({name:{originalValue:"content",camelCase:"content",snakeCase:"content",pascalCase:"Content",screamingSnakeCase:"CONTENT",wireValue:"content"},error:Ryc(e.error)})}function Ryc(e){return{name:e.name.originalName,nameV2:Z4t(e.name),nameV3:q2(e.name),fernFilepath:aRi(e.fernFilepath),fernFilepathV2:oRi(e.fernFilepath)}}function CjC(e){return{docs:e.docs,name:e.name?.originalName,servicePathParameters:e.servicePathParameters.map(t=>sg0(t)),endpointPathParameters:e.endpointPathParameters.map(t=>sg0(t)),serviceHeaders:e.serviceHeaders.map(t=>cg0(t)),endpointHeaders:e.endpointHeaders.map(t=>cg0(t)),queryParameters:e.queryParameters.map(t=>BjC(t)),request:e.request!=null?xjC(e.request):void 0,response:zjC(e.response)}}function sg0(e){return{key:e.key,value:iX(e.value)}}function cg0(e){return{wireKey:e.wireKey,value:iX(e.value)}}function BjC(e){return{wireKey:e.wireKey,value:iX(e.value)}}function xjC(e){return he.V5.http.ExampleRequestBody._visit(e,{inlinedRequestBody:t=>he.V4.services.http.ExampleRequestBody.inlinedRequestBody({jsonExample:t.jsonExample,properties:t.properties.map(r=>IjC(r))}),reference:t=>he.V4.services.http.ExampleRequestBody.reference(iX(t)),_unknown:()=>{throw new Error("Unknown ExampleRequestBody: "+e.type)}})}function IjC(e){return{wireKey:e.wireKey,value:iX(e.value),originalTypeDeclaration:e.originalTypeDeclaration!=null?K8(e.originalTypeDeclaration):void 0}}function zjC(e){return he.V5.http.ExampleResponse._visit(e,{ok:t=>he.V4.services.http.ExampleResponse.ok({body:t.body!=null?iX(t.body):void 0}),error:t=>he.V4.services.http.ExampleResponse.error({error:Ryc(t.error),body:t.body!=null?iX(t.body):void 0}),_unknown:()=>{throw new Error("Unknown ExampleResponse: "+e.type)}})}function dg0(e){return{docs:e.docs,availability:e.availability,name:K8(e.name),shape:RjC(e.shape),examples:e.examples.map(t=>FjC(t)),referencedTypes:e.referencedTypes.map(t=>K8(t))}}function RjC(e){return he.V5.types.Type._visit(e,{alias:({aliasOf:t,resolvedType:r})=>he.V4.types.Type.alias({aliasOf:BI(t),resolvedType:NjC(r)}),enum:t=>he.V4.types.Type.enum({values:t.values.map(r=>({docs:r.docs,availability:r.availability,name:cSe(r.name),nameV2:T2(r.name),value:r.name.wireValue}))}),object:t=>he.V4.types.Type.object({extends:t.extends.map(r=>K8(r)),properties:t.properties.map(r=>({docs:r.docs,availability:r.availability,name:cSe(r.name),nameV2:T2(r.name),valueType:BI(r.valueType)}))}),union:t=>he.V4.types.Type.union({discriminant:t.discriminant.wireValue,discriminantV2:cSe(t.discriminant),discriminantV3:T2(t.discriminant),types:t.types.map(r=>({docs:r.docs,discriminantValue:cSe(r.discriminantValue),discriminantValueV2:T2(r.discriminantValue),valueType:he.V5.types.SingleUnionTypeProperties._visit(r.shape,{samePropertiesAsObject:i=>he.V4.types.TypeReference.named(K8(i)),singleProperty:i=>BI(i.type),noProperties:he.V4.types.TypeReference.void,_unknown:()=>{throw new Error("Unknown SingleUnionTypeProperties: "+r.shape._type)}}),shape:he.V5.types.SingleUnionTypeProperties._visit(r.shape,{samePropertiesAsObject:i=>he.V4.types.SingleUnionTypeProperties.samePropertiesAsObject(K8(i)),singleProperty:i=>he.V4.types.SingleUnionTypeProperties.singleProperty({name:cSe(i.name),nameV2:T2(i.name),type:BI(i.type)}),noProperties:he.V4.types.SingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown SingleUnionTypeProperties: "+r.shape._type)}})}))}),_unknown:()=>{throw new Error("Unknown shape: "+e._type)}})}function FjC(e){return{docs:e.docs,jsonExample:e.jsonExample,name:e.name?.originalName,shape:fCo(e.shape)}}function NjC(e){return he.V5.types.ResolvedTypeReference._visit(e,{named:t=>he.V4.types.ResolvedTypeReference.named({name:K8(t.name),shape:LjC(t.shape)}),container:t=>he.V4.types.ResolvedTypeReference.container(Jbn(t)),primitive:he.V4.types.ResolvedTypeReference.primitive,unknown:he.V4.types.ResolvedTypeReference.unknown,_unknown:()=>{throw new Error("Unknown ResolvedTypeReference: "+e._type)}})}function LjC(e){return he.V5.types.ShapeType._visit(e,{enum:()=>he.V5.types.ShapeType.Enum,object:()=>he.V5.types.ShapeType.Object,union:()=>he.V5.types.ShapeType.Union,_unknown:()=>{throw new Error("Unknown ShapeType: "+e)}})}var pg0={laterVersion:"v5",earlierVersion:"v4",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.0.257-2-g46fe4ff",[K.TYPESCRIPT_EXPRESS]:"0.0.264",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:"0.0.33-9-gf683b5e",[K.PYTHON_PYDANTIC]:"0.0.33-9-gf683b5e",[K.OPENAPI]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:ni,[K.STOPLIGHT]:ni,[K.OPENAPI_PYTHON_CLIENT]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>{let t=new lCo(e),r=new cCo(e);return{apiName:e.apiName.originalName,apiDisplayName:e.apiDisplayName,apiDocs:e.apiDocs,auth:ng0(e.auth),headers:e.headers.map(i=>uRi(i)),types:e.types.map(i=>dg0(i)),services:{http:e.services.map(i=>lg0({service:i,errorResolver:r})),websocket:[]},errors:e.errors.map(i=>og0({errorDeclaration:i,errorDiscriminationStrategy:e.errorDiscriminationStrategy,typeReferenceResolver:t})),constants:{errorDiscriminant:"_error",errorInstanceIdKey:"_errorInstanceId",unknownErrorDiscriminantValue:"_unknown"},constantsV2:{errors:{errorInstanceIdKey:cSe(e.constants.errorInstanceIdKey),errorDiscriminant:{originalValue:"error",camelCase:"error",snakeCase:"error",pascalCase:"Error",screamingSnakeCase:"ERROR",wireValue:"error"},errorContentKey:{originalValue:"content",camelCase:"content",snakeCase:"content",pascalCase:"Content",screamingSnakeCase:"CONTENT",wireValue:"content"}},errorsV2:{errorInstanceIdKey:T2(e.constants.errorInstanceIdKey),errorDiscriminant:{name:{unsafeName:{originalValue:"error",camelCase:"error",snakeCase:"error",pascalCase:"Error",screamingSnakeCase:"ERROR"},safeName:{originalValue:"error",camelCase:"error",snakeCase:"error",pascalCase:"Error",screamingSnakeCase:"ERROR"}},wireValue:"error"},errorContentKey:{name:{unsafeName:{originalValue:"content",camelCase:"content",snakeCase:"content",pascalCase:"Content",screamingSnakeCase:"CONTENT"},safeName:{originalValue:"content",camelCase:"content",snakeCase:"content",pascalCase:"Content",screamingSnakeCase:"CONTENT"}},wireValue:"content"}}},defaultEnvironment:e.defaultEnvironment,environments:e.environments.map(i=>ag0(i)),errorDiscriminant:e.errorDiscriminationStrategy.type==="property"?q2(e.errorDiscriminationStrategy.discriminant.name):void 0,errorDiscriminationStrategy:he.V5.ir.ErrorDiscriminationStrategy._visit(e.errorDiscriminationStrategy,{statusCode:he.V4.ir.ErrorDiscriminationStrategy.statusCode,property:i=>he.V4.ir.ErrorDiscriminationStrategy.property({discriminant:T2(i.discriminant),contentProperty:T2(i.contentProperty)}),_unknown:()=>{throw new Error("Unknown ErrorDiscriminationStrategy: "+e.errorDiscriminationStrategy.type)}}),sdkConfig:e.sdkConfig}}};var _g0={laterVersion:"v6",earlierVersion:"v5",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.0.257-4-ge56e5d2",[K.TYPESCRIPT_EXPRESS]:"0.0.264",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:"0.0.35-1-g071a04a",[K.PYTHON_PYDANTIC]:"0.0.35-1-g071a04a",[K.OPENAPI]:"0.0.16-1-ga2c0ada",[K.STOPLIGHT]:ni,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:ni,[K.OPENAPI_PYTHON_CLIENT]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,{taskContext:t,targetGenerator:r})=>({...e,defaultEnvironment:e.environments?.defaultEnvironment,environments:e.environments!=null?he.V6.environment.Environments._visit(e.environments.environments,{singleBaseUrl:i=>i.environments,multipleBaseUrls:()=>t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support specifying multiple URLs for a single environment. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains a multiple URls for a single environment."),_unknown:()=>{throw new Error("Unknown Environments: "+e.environments?.environments.type)}}):[]})};var hg0={laterVersion:"v7",earlierVersion:"v6",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.0.268",[K.TYPESCRIPT_EXPRESS]:"0.0.268",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:ni,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:ni,[K.OPENAPI_PYTHON_CLIENT]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>({...e,services:e.services.map(t=>{let r=t.name.fernFilepath[t.name.fernFilepath.length-1],i=r!=null?`${r.pascalCase.safeName}Service`:"Service",n=r!=null?`${r.camelCase.unsafeName}Service`:"Service",a=r!=null?`${r.snakeCase.unsafeName}_service`:"service",u=a.toUpperCase(),l=G9(n);return{...t,name:{name:{originalName:i,camelCase:{safeName:n,unsafeName:n},snakeCase:{safeName:a,unsafeName:a},screamingSnakeCase:{safeName:u,unsafeName:u},pascalCase:{safeName:l,unsafeName:l}},fernFilepath:t.name.fernFilepath}}})})};var bg0={laterVersion:"v8",earlierVersion:"v7",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.0.273-5-g1b00245b",[K.TYPESCRIPT_EXPRESS]:"0.0.273-5-g1b00245b",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:"0.0.45-1-g8bb600f",[K.PYTHON_PYDANTIC]:"0.0.45-1-g8bb600f",[K.OPENAPI_PYTHON_CLIENT]:"0.0.0",[K.OPENAPI]:"0.0.20-1-gbbeb9bd",[K.STOPLIGHT]:ni,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>({...e,auth:UjC(e.auth),headers:e.headers.map(t=>dCo(t)),types:e.types.map(t=>VjC(t)),errors:e.errors.map(t=>KjC(t)),services:e.services.map(t=>YjC(t))})};function Fyc(e){return e.allParts}function UjC(e){return{docs:e.docs,requirement:e.requirement,schemes:e.schemes.map(t=>t._type!=="header"?t:he.V7.auth.AuthScheme.header(dCo(t)))}}function dCo(e){return{docs:e.docs,availability:e.availability,name:e.name,valueType:W$(e.valueType)}}function W$(e){return he.V8.types.TypeReference._visit(e,{container:t=>he.V7.types.TypeReference.container(gg0(t)),named:t=>he.V7.types.TypeReference.named(k4t(t)),primitive:he.V7.types.TypeReference.primitive,unknown:he.V7.types.TypeReference.unknown,_unknown:()=>{throw new Error("Unknown type reference: "+e._type)}})}function gg0(e){return he.V8.types.ContainerType._visit(e,{list:t=>he.V7.types.ContainerType.list(W$(t)),optional:t=>he.V7.types.ContainerType.optional(W$(t)),set:t=>he.V7.types.ContainerType.set(W$(t)),map:({keyType:t,valueType:r})=>he.V7.types.ContainerType.map({keyType:W$(t),valueType:W$(r)}),literal:he.V7.types.ContainerType.literal,_unknown:()=>{throw new Error("Unknown ContainerType: "+e._type)}})}function k4t(e){return{name:e.name,fernFilepath:Fyc(e.fernFilepath)}}function VjC(e){return{docs:e.docs,availability:e.availability,name:k4t(e.name),shape:WjC(e.shape),examples:e.examples.map(t=>QjC(t)),referencedTypes:e.referencedTypes.map(t=>k4t(t))}}function WjC(e){return he.V8.types.Type._visit(e,{alias:t=>he.V7.types.Type.alias({aliasOf:W$(t.aliasOf),resolvedType:HjC(t.resolvedType)}),enum:he.V7.types.Type.enum,object:t=>he.V7.types.Type.object({extends:t.extends.map(r=>k4t(r)),properties:t.properties.map(r=>({docs:r.docs,availability:r.availability,name:r.name,valueType:W$(r.valueType)}))}),union:t=>he.V7.types.Type.union({discriminant:t.discriminant,types:t.types.map(r=>$jC(r))}),_unknown:()=>{throw new Error("Unknown Type shape: "+e._type)}})}function HjC(e){return he.V8.types.ResolvedTypeReference._visit(e,{container:t=>he.V7.types.ResolvedTypeReference.container(gg0(t)),named:t=>he.V7.types.ResolvedTypeReference.named({name:k4t(t.name),shape:t.shape}),primitive:he.V7.types.ResolvedTypeReference.primitive,unknown:he.V7.types.ResolvedTypeReference.unknown,_unknown:()=>{throw new Error("Unknown ResolvedTypeReference: "+e._type)}})}function $jC(e){return{docs:e.docs,discriminantValue:e.discriminantValue,shape:GjC(e.shape)}}function GjC(e){return he.V8.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>he.V7.types.SingleUnionTypeProperties.samePropertiesAsObject(k4t(t)),singleProperty:t=>he.V7.types.SingleUnionTypeProperties.singleProperty({name:t.name,type:W$(t.type)}),noProperties:he.V7.types.SingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown SingleUnionTypeProperties: "+e._type)}})}function QjC(e){return{jsonExample:e.jsonExample,docs:e.docs,name:e.name,shape:Nyc(e.shape)}}function Nyc(e){return he.V8.types.ExampleTypeShape._visit(e,{alias:t=>he.V7.types.ExampleTypeShape.alias({value:xie(t.value)}),enum:he.V7.types.ExampleTypeShape.enum,object:t=>he.V7.types.ExampleTypeShape.object({properties:t.properties.map(r=>({wireKey:r.wireKey,value:xie(r.value),originalTypeDeclaration:k4t(r.originalTypeDeclaration)}))}),union:t=>he.V7.types.ExampleTypeShape.union({wireDiscriminantValue:t.wireDiscriminantValue,properties:JjC(t.properties)}),_unknown:()=>{throw new Error("Unknown ExampleTypeShape: "+e.type)}})}function xie(e){return{jsonExample:e.jsonExample,shape:Og0(e.shape)}}function Og0(e){return he.V8.types.ExampleTypeReferenceShape._visit(e,{named:t=>he.V7.types.ExampleTypeReferenceShape.named({typeName:k4t(t.typeName),shape:Nyc(t.shape)}),container:t=>he.V7.types.ExampleTypeReferenceShape.container(he.V8.types.ExampleContainer._visit(t,{list:r=>he.V7.types.ExampleContainer.list(r.map(i=>xie(i))),set:r=>he.V7.types.ExampleContainer.set(r.map(i=>xie(i))),optional:r=>he.V7.types.ExampleContainer.optional(r!=null?xie(r):void 0),map:r=>he.V7.types.ExampleContainer.map(r.map(i=>({key:xie(i.key),value:xie(i.value)}))),_unknown:()=>{throw new Error("Unknown ExampleContainer: "+t.type)}})),primitive:he.V7.types.ExampleTypeReferenceShape.primitive,unknown:he.V7.types.ExampleTypeReferenceShape.unknown,_unknown:()=>{throw new Error("Unknown ExampleTypeReferenceShape: "+e.type)}})}function JjC(e){return he.V8.types.ExampleSingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>he.V7.types.ExampleSingleUnionTypeProperties.samePropertiesAsObject({typeName:k4t(t.typeName),shape:Nyc(t.shape)}),singleProperty:t=>he.V7.types.ExampleSingleUnionTypeProperties.singleProperty({jsonExample:t.jsonExample,shape:Og0(t.shape)}),noProperties:he.V7.types.ExampleSingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown ExampleSingleUnionTypeProperties: "+e.type)}})}function KjC(e){return{docs:e.docs,name:Lyc(e.name),discriminantValue:e.discriminantValue,type:e.type!=null?W$(e.type):void 0,statusCode:e.statusCode}}function Lyc(e){return{name:e.name,fernFilepath:Fyc(e.fernFilepath)}}function YjC(e){return{docs:e.docs,availability:e.availability,name:{fernFilepath:Fyc(e.name.fernFilepath)},displayName:e.displayName,basePath:e.basePath,baseUrl:e.baseUrl,pathParameters:e.pathParameters.map(t=>mg0(t)),headers:e.headers.map(t=>dCo(t)),endpoints:e.endpoints.map(t=>XjC(t))}}function mg0(e){return{availability:e.availability,docs:e.docs,name:e.name,valueType:W$(e.valueType)}}function XjC(e){return{docs:e.docs,availability:e.availability,name:e.name,displayName:e.displayName,errors:e.errors.map(t=>ZjC(t)),auth:e.auth,method:e.method,path:e.path,pathParameters:e.pathParameters.map(t=>mg0(t)),sdkRequest:e.sdkRequest!=null?ewC(e.sdkRequest):void 0,requestBody:e.requestBody!=null?rwC(e.requestBody):void 0,response:iwC(e.response),headers:e.headers.map(t=>dCo(t)),queryParameters:e.queryParameters.map(t=>kjC(t)),examples:e.examples.map(t=>nwC(t))}}function ZjC(e){return{docs:e.docs,error:Lyc(e.error)}}function kjC(e){return{availability:e.availability,docs:e.docs,name:e.name,valueType:W$(e.valueType),allowMultiple:e.allowMultiple}}function ewC(e){return{requestParameterName:e.requestParameterName,shape:twC(e.shape)}}function twC(e){return he.V8.http.SdkRequestShape._visit(e,{justRequestBody:t=>he.V7.http.SdkRequestShape.justRequestBody({docs:t.docs,requestBodyType:W$(t.requestBodyType)}),wrapper:he.V7.http.SdkRequestShape.wrapper,_unknown:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function rwC(e){return he.V8.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>he.V7.http.HttpRequestBody.inlinedRequestBody({name:t.name,extends:t.extends.map(r=>k4t(r)),properties:t.properties.map(r=>({docs:r.docs,name:r.name,valueType:W$(r.valueType)}))}),reference:t=>he.V7.http.HttpRequestBody.reference({docs:t.docs,requestBodyType:W$(t.requestBodyType)}),_unknown:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function iwC(e){return{docs:e.docs,type:e.type!=null?W$(e.type):void 0}}function nwC(e){return{name:e.name,docs:e.docs,servicePathParameters:e.servicePathParameters.map(t=>yg0(t)),endpointPathParameters:e.endpointPathParameters.map(t=>yg0(t)),queryParameters:e.queryParameters.map(t=>awC(t)),serviceHeaders:e.serviceHeaders.map(t=>vg0(t)),endpointHeaders:e.endpointHeaders.map(t=>vg0(t)),request:e.request!=null?owC(e.request):void 0,response:uwC(e.response)}}function yg0(e){return{key:e.key,value:xie(e.value)}}function awC(e){return{wireKey:e.wireKey,value:xie(e.value)}}function vg0(e){return{wireKey:e.wireKey,value:xie(e.value)}}function owC(e){return he.V8.http.ExampleRequestBody._visit(e,{inlinedRequestBody:t=>he.V7.http.ExampleRequestBody.inlinedRequestBody({jsonExample:t.jsonExample,properties:t.properties.map(r=>({wireKey:r.wireKey,value:xie(r.value),originalTypeDeclaration:r.originalTypeDeclaration!=null?k4t(r.originalTypeDeclaration):void 0}))}),reference:t=>he.V7.http.ExampleRequestBody.reference(xie(t)),_unknown:()=>{throw new Error("Unknown ExampleRequestBody: "+e.type)}})}function uwC(e){return he.V8.http.ExampleResponse._visit(e,{ok:t=>he.V7.http.ExampleResponse.ok({body:t.body!=null?xie(t.body):void 0}),error:t=>he.V7.http.ExampleResponse.error({error:Lyc(t.error),body:t.body!=null?xie(t.body):void 0}),_unknown:()=>{throw new Error("Unknown ExampleResponse: "+e.type)}})}var Pg0={laterVersion:"v9",earlierVersion:"v8",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.3.0-2-g85e8aa08",[K.TYPESCRIPT_EXPRESS]:"0.3.0-2-g85e8aa08",[K.JAVA]:Ge,[K.JAVA_MODEL]:"0.0.134-4-gef1ec4f",[K.JAVA_SDK]:"0.0.134-4-gef1ec4f",[K.JAVA_SPRING]:"0.0.134-4-gef1ec4f",[K.PYTHON_FASTAPI]:"0.0.51-1-g977dd1f",[K.PYTHON_PYDANTIC]:"0.0.51-1-g977dd1f",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:ni,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,{taskContext:t,targetGenerator:r})=>{for(let[i,n]of Object.entries(e.types))n.shape._type==="union"&&n.shape.baseProperties.length>0&&t.failWithoutThrowing(r!=null?`Type ${n.name.name.originalName} uses base-properties. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains a union with base-properties.");return t.getResult()===IT.Failure&&t.failAndThrow(),{...e,types:Object.values(e.types),errors:Object.values(e.errors),services:Object.values(e.services)}}};var jg0={laterVersion:"v10",earlierVersion:"v9",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.STOPLIGHT]:ni,[K.OPENAPI]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>{let t=cd(e.services,r=>({docs:void 0,...r}));for(let r of Object.values(e.subpackages))if(r.docs!=null&&r.service!=null){let i=t[r.service];if(i==null)throw new Error("Service does not exist: "+r.service);i.docs=r.docs}return{...e,services:t}}};var wg0={laterVersion:"v11",earlierVersion:"v10",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.5.0-rc0-1-g83a12940",[K.TYPESCRIPT_EXPRESS]:"0.5.0-rc0-1-g83a12940",[K.JAVA]:Ge,[K.JAVA_MODEL]:"0.0.134-15-ge1ac358",[K.JAVA_SDK]:"0.0.134-15-ge1ac358",[K.JAVA_SPRING]:"0.0.134-15-ge1ac358",[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.STOPLIGHT]:ni,[K.OPENAPI]:Ge,[K.POSTMAN]:"0.0.40-1-g9aa2117",[K.PYTHON_SDK]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,t)=>({...e,auth:swC(e.auth,t)})};function swC(e,t){return{...e,schemes:e.schemes.map(r=>cwC(r,t))}}function cwC(e,{taskContext:t,targetGenerator:r}){return he.V11.auth.AuthScheme._visit(e,{bearer:he.V10.auth.AuthScheme.bearer,basic:he.V10.auth.AuthScheme.basic,header:i=>i.prefix!=null?t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support specifying an auth header prefix. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains an auth header prefix."):he.V10.auth.AuthScheme.header({docs:i.docs,availability:{status:he.V10.commons.AvailabilityStatus.GeneralAvailability,message:void 0},name:{name:i.name,wireValue:i.header},valueType:i.valueType}),_unknown:()=>{throw new Error("Unknown auth scheme: "+e._type)}})}var Dg0={laterVersion:"v12",earlierVersion:"v11",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.5.0-rc0-6-g80f89f98",[K.TYPESCRIPT_EXPRESS]:"0.5.0-rc0-6-g80f89f98",[K.JAVA]:Ge,[K.JAVA_MODEL]:"0.1.0-1-gdb5c636",[K.JAVA_SDK]:"0.1.0-1-gdb5c636",[K.JAVA_SPRING]:"0.1.0-1-gdb5c636",[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.STOPLIGHT]:"0.0.23-8-g479c860",[K.OPENAPI]:"0.0.22-1-g1c86b58",[K.POSTMAN]:Ge,[K.PYTHON_SDK]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,{taskContext:t,targetGenerator:r})=>{let i=cd(e.types,n=>({...n,shape:he.V12.types.Type._visit(n.shape,{union:he.V11.types.Type.union,enum:he.V11.types.Type.enum,object:he.V11.types.Type.object,alias:a=>he.V11.types.Type.alias({aliasOf:a.aliasOf,resolvedType:he.V12.types.ResolvedTypeReference._visit(a.resolvedType,{container:he.V11.types.ResolvedTypeReference.container,primitive:he.V11.types.ResolvedTypeReference.primitive,named:u=>u.shape==="UNDISCRIMINATED_UNION"?t.failAndThrow(Sg0({taskContext:t,targetGenerator:r})):he.V11.types.ResolvedTypeReference.named({shape:u.shape,name:u.name}),unknown:he.V11.types.ResolvedTypeReference.unknown,_unknown:()=>{throw new Error("Encountered unknown alias")}})}),undiscriminatedUnion:()=>t.failAndThrow(Sg0({taskContext:t,targetGenerator:r})),_unknown:()=>{throw new Error("Encountered unknown shape")}})}));return{...e,types:i,services:cd(e.services,n=>lwC(n,{taskContext:t,targetGenerator:r}))}}};function Sg0(e){return e.targetGenerator!=null?`Generator ${e.targetGenerator.name}@${e.targetGenerator.version} does not support undiscriminated unions If you'd like to use this feature, please upgrade ${e.targetGenerator.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains an undiscriminated union."}function lwC(e,t){return{...e,endpoints:e.endpoints.map(r=>fwC(r,t))}}function fwC(e,{taskContext:t,targetGenerator:r}){return e.streamingResponse!=null?t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support streaming responses. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains a streaming response."):{...e,requestBody:e.requestBody!=null?he.V12.http.HttpRequestBody._visit(e.requestBody,{inlinedRequestBody:he.V11.http.HttpRequestBody.inlinedRequestBody,reference:he.V11.http.HttpRequestBody.reference,fileUpload:()=>t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support file upload requests. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains a file upload request."),_unknown:()=>{throw new Error("Unknown HttpRequestBody type: "+e.requestBody?.type)}}):void 0,response:e.response!=null?{docs:e.response.docs,type:e.response.responseBodyType}:{docs:void 0,type:void 0}}}var Eg0={laterVersion:"v13",earlierVersion:"v12",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>({...e,types:cd(e.types,t=>t.shape._type!=="undiscriminatedUnion"?{...t,shape:t.shape}:{...t,shape:he.V12.types.Type.undiscriminatedUnion({docs:void 0,members:t.shape.members})}),auth:{...e.auth,schemes:e.auth.schemes.map(t=>t._type!=="header"?t:{...t,name:t.name.name,header:t.name.wireValue})}})};var Ag0={laterVersion:"v14",earlierVersion:"v13",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:ni,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>{let t=cd(e.types,r=>({...r,shape:he.V14.types.Type._visit(r.shape,{union:i=>he.V13.types.Type.union({discriminant:i.discriminant,baseProperties:i.baseProperties.map(n=>({...n,valueType:UF(n.valueType)})),types:i.types.map(n=>_wC(n))}),enum:he.V13.types.Type.enum,object:i=>he.V13.types.Type.object({...i,properties:i.properties.map(n=>({...n,valueType:UF(n.valueType)}))}),alias:i=>he.V13.types.Type.alias({aliasOf:UF(i.aliasOf),resolvedType:ywC(i.resolvedType)}),undiscriminatedUnion:i=>he.V13.types.Type.undiscriminatedUnion(vwC(i)),_unknown:()=>{throw new Error("Encountered unknown shape")}})}));return{...e,auth:dwC(e.auth),headers:e.headers.map(r=>Wyc(r)),types:t,services:cd(e.services,r=>bwC(r)),errors:cd(e.errors,r=>SwC(r))}}};function dwC(e){return{docs:e.docs,requirement:e.requirement,schemes:e.schemes.map(t=>t._type!=="header"?t:he.V13.auth.AuthScheme.header(pwC(t)))}}function pwC(e){return{docs:e.docs,prefix:e.prefix,name:e.name,valueType:UF(e.valueType)}}function Wyc(e){return{docs:e.docs,availability:e.availability,name:e.name,valueType:UF(e.valueType)}}function UF(e){return he.V14.types.TypeReference._visit(e,{container:t=>he.V13.types.TypeReference.container(Mg0(t)),primitive:t=>t==="DATE"?he.V13.types.TypeReference.primitive(he.V13.types.PrimitiveType.String):he.V13.types.TypeReference.primitive(t),named:he.V13.types.TypeReference.named,unknown:he.V13.types.TypeReference.unknown,_unknown:()=>{throw new Error("Unknown type reference: "+e._type)}})}function Mg0(e){return he.V14.types.ContainerType._visit(e,{list:t=>he.V13.types.ContainerType.list(UF(t)),optional:t=>he.V13.types.ContainerType.optional(UF(t)),set:t=>he.V13.types.ContainerType.set(UF(t)),map:({keyType:t,valueType:r})=>he.V13.types.ContainerType.map({keyType:UF(t),valueType:UF(r)}),literal:he.V13.types.ContainerType.literal,_unknown:()=>{throw new Error("Unknown ContainerType: "+e._type)}})}function _wC(e){return{docs:e.docs,discriminantValue:e.discriminantValue,shape:hwC(e.shape)}}function hwC(e){return he.V14.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>he.V13.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>he.V13.types.SingleUnionTypeProperties.singleProperty({name:t.name,type:UF(t.type)}),noProperties:he.V13.types.SingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown SingleUnionTypeProperties: "+e._type)}})}function ywC(e){return he.V14.types.ResolvedTypeReference._visit(e,{container:t=>he.V13.types.ResolvedTypeReference.container(Mg0(t)),named:he.V13.types.ResolvedTypeReference.named,primitive:t=>t==="DATE"?he.V13.types.ResolvedTypeReference.primitive(he.V13.types.PrimitiveType.String):he.V13.types.ResolvedTypeReference.primitive(t),unknown:he.V13.types.ResolvedTypeReference.unknown,_unknown:()=>{throw new Error("Unknown ResolvedTypeReference: "+e._type)}})}function vwC(e){return{members:e.members.map(t=>({...t,type:UF(t.type)}))}}function bwC(e){return{availability:e.availability,name:e.name,displayName:e.displayName,basePath:e.basePath,baseUrl:e.baseUrl,pathParameters:e.pathParameters.map(t=>qg0(t)),headers:e.headers.map(t=>Wyc(t)),endpoints:e.endpoints.map(t=>gwC(t))}}function qg0(e){return{availability:e.availability,docs:e.docs,name:e.name,valueType:UF(e.valueType)}}function gwC(e){return{docs:e.docs,availability:e.availability,name:e.name,displayName:e.displayName,errors:e.errors,auth:e.auth,method:e.method,path:e.path,pathParameters:e.pathParameters.map(t=>qg0(t)),sdkRequest:e.sdkRequest!=null?mwC(e.sdkRequest):void 0,requestBody:e.requestBody!=null?jwC(e.requestBody):void 0,response:e.response!=null?Uyc(e.response):void 0,headers:e.headers.map(t=>Wyc(t)),queryParameters:e.queryParameters.map(t=>OwC(t)),examples:e.examples,streamingResponse:e.streamingResponse!=null?Vyc(e.streamingResponse):void 0,sdkResponse:e.sdkResponse!=null?wwC(e.sdkResponse):void 0}}function OwC(e){return{availability:e.availability,docs:e.docs,name:e.name,valueType:UF(e.valueType),allowMultiple:e.allowMultiple}}function mwC(e){return{requestParameterName:e.requestParameterName,shape:PwC(e.shape)}}function PwC(e){return he.V14.http.SdkRequestShape._visit(e,{justRequestBody:t=>he.V13.http.SdkRequestShape.justRequestBody({docs:t.docs,requestBodyType:UF(t.requestBodyType)}),wrapper:he.V13.http.SdkRequestShape.wrapper,_unknown:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function jwC(e){return he.V14.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>he.V13.http.HttpRequestBody.inlinedRequestBody({name:t.name,extends:t.extends,properties:t.properties.map(r=>({docs:r.docs,name:r.name,valueType:UF(r.valueType)}))}),reference:t=>he.V13.http.HttpRequestBody.reference({docs:t.docs,requestBodyType:UF(t.requestBodyType)}),fileUpload:t=>he.V13.http.HttpRequestBody.fileUpload({name:t.name,properties:t.properties.map(r=>r.type==="bodyProperty"?{...r,valueType:UF(r.valueType)}:r)}),_unknown:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function Uyc(e){return{docs:e.docs,responseBodyType:UF(e.responseBodyType)}}function Vyc(e){return{dataEventType:UF(e.dataEventType),terminator:e.terminator}}function wwC(e){return he.V14.http.SdkResponse._visit(e,{streaming:t=>he.V13.http.SdkResponse.streaming(Vyc(t)),nonStreaming:t=>he.V13.http.SdkResponse.nonStreaming(Uyc(t)),maybeStreaming:t=>he.V13.http.SdkResponse.maybeStreaming({condition:t.condition,nonStreaming:Uyc(t.nonStreaming),streaming:Vyc(t.streaming)}),_unknown:()=>{throw new Error("Encountered unknown sdk response")}})}function SwC(e){return{docs:e.docs,name:e.name,discriminantValue:e.discriminantValue,type:e.type!=null?UF(e.type):void 0,statusCode:e.statusCode}}var Tg0={laterVersion:"v15",earlierVersion:"v14",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:"0.0.52-3-gd9df38df",[K.PYTHON_PYDANTIC]:"0.0.52-3-gd9df38df",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"0.0.52-3-gd9df38df",[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>{let t=cd(e.types,r=>({...r,shape:he.V15.types.Type._visit(r.shape,{union:i=>he.V14.types.Type.union({discriminant:i.discriminant,baseProperties:i.baseProperties.map(n=>({...n,valueType:VF(n.valueType)})),types:i.types.map(n=>AwC(n))}),enum:he.V14.types.Type.enum,object:i=>he.V14.types.Type.object({...i,properties:i.properties.map(n=>({...n,valueType:VF(n.valueType)}))}),alias:i=>he.V14.types.Type.alias({aliasOf:VF(i.aliasOf),resolvedType:qwC(i.resolvedType)}),undiscriminatedUnion:i=>he.V14.types.Type.undiscriminatedUnion(TwC(i)),_unknown:()=>{throw new Error("Encountered unknown shape")}})}));return{...e,auth:DwC(e.auth),headers:e.headers.map(r=>Gyc(r)),types:t,services:cd(e.services,r=>CwC(r)),errors:cd(e.errors,r=>NwC(r))}}};function DwC(e){return{docs:e.docs,requirement:e.requirement,schemes:e.schemes.map(t=>t._type!=="header"?t:he.V14.auth.AuthScheme.header(EwC(t)))}}function EwC(e){return{docs:e.docs,prefix:e.prefix,name:e.name,valueType:VF(e.valueType)}}function Gyc(e){return{docs:e.docs,availability:e.availability,name:e.name,valueType:VF(e.valueType)}}function VF(e){return he.V15.types.TypeReference._visit(e,{container:t=>he.V14.types.TypeReference.container(Cg0(t)),primitive:t=>t==="BASE_64"?he.V14.types.TypeReference.primitive(he.V14.types.PrimitiveType.String):he.V14.types.TypeReference.primitive(t),named:he.V14.types.TypeReference.named,unknown:he.V14.types.TypeReference.unknown,_unknown:()=>{throw new Error("Unknown type reference: "+e._type)}})}function Cg0(e){return he.V15.types.ContainerType._visit(e,{list:t=>he.V14.types.ContainerType.list(VF(t)),optional:t=>he.V14.types.ContainerType.optional(VF(t)),set:t=>he.V14.types.ContainerType.set(VF(t)),map:({keyType:t,valueType:r})=>he.V14.types.ContainerType.map({keyType:VF(t),valueType:VF(r)}),literal:he.V14.types.ContainerType.literal,_unknown:()=>{throw new Error("Unknown ContainerType: "+e._type)}})}function AwC(e){return{docs:e.docs,discriminantValue:e.discriminantValue,shape:MwC(e.shape)}}function MwC(e){return he.V15.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>he.V14.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>he.V14.types.SingleUnionTypeProperties.singleProperty({name:t.name,type:VF(t.type)}),noProperties:he.V14.types.SingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown SingleUnionTypeProperties: "+e._type)}})}function qwC(e){return he.V15.types.ResolvedTypeReference._visit(e,{container:t=>he.V14.types.ResolvedTypeReference.container(Cg0(t)),named:he.V14.types.ResolvedTypeReference.named,primitive:t=>t==="BASE_64"?he.V14.types.ResolvedTypeReference.primitive(he.V14.types.PrimitiveType.String):he.V14.types.ResolvedTypeReference.primitive(t),unknown:he.V14.types.ResolvedTypeReference.unknown,_unknown:()=>{throw new Error("Unknown ResolvedTypeReference: "+e._type)}})}function TwC(e){return{members:e.members.map(t=>({...t,type:VF(t.type)}))}}function CwC(e){return{availability:e.availability,name:e.name,displayName:e.displayName,basePath:e.basePath,baseUrl:e.baseUrl,pathParameters:e.pathParameters.map(t=>Bg0(t)),headers:e.headers.map(t=>Gyc(t)),endpoints:e.endpoints.map(t=>BwC(t))}}function Bg0(e){return{availability:e.availability,docs:e.docs,name:e.name,valueType:VF(e.valueType)}}function BwC(e){return{docs:e.docs,availability:e.availability,name:e.name,displayName:e.displayName,errors:e.errors,auth:e.auth,method:e.method,path:e.path,pathParameters:e.pathParameters.map(t=>Bg0(t)),sdkRequest:e.sdkRequest!=null?IwC(e.sdkRequest):void 0,requestBody:e.requestBody!=null?RwC(e.requestBody):void 0,response:e.response!=null?Hyc(e.response):void 0,headers:e.headers.map(t=>Gyc(t)),queryParameters:e.queryParameters.map(t=>xwC(t)),examples:e.examples,streamingResponse:e.streamingResponse!=null?$yc(e.streamingResponse):void 0,sdkResponse:e.sdkResponse!=null?FwC(e.sdkResponse):void 0}}function xwC(e){return{availability:e.availability,docs:e.docs,name:e.name,valueType:VF(e.valueType),allowMultiple:e.allowMultiple}}function IwC(e){return{requestParameterName:e.requestParameterName,shape:zwC(e.shape)}}function zwC(e){return he.V15.http.SdkRequestShape._visit(e,{justRequestBody:t=>he.V14.http.SdkRequestShape.justRequestBody({docs:t.docs,requestBodyType:VF(t.requestBodyType)}),wrapper:he.V14.http.SdkRequestShape.wrapper,_unknown:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function RwC(e){return he.V15.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>he.V14.http.HttpRequestBody.inlinedRequestBody({name:t.name,extends:t.extends,properties:t.properties.map(r=>({docs:r.docs,name:r.name,valueType:VF(r.valueType)}))}),reference:t=>he.V14.http.HttpRequestBody.reference({docs:t.docs,requestBodyType:VF(t.requestBodyType)}),fileUpload:t=>he.V14.http.HttpRequestBody.fileUpload({name:t.name,properties:t.properties.map(r=>r.type==="bodyProperty"?{...r,valueType:VF(r.valueType)}:r)}),_unknown:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function Hyc(e){return{docs:e.docs,responseBodyType:VF(e.responseBodyType)}}function $yc(e){return{dataEventType:VF(e.dataEventType),terminator:e.terminator}}function FwC(e){return he.V15.http.SdkResponse._visit(e,{streaming:t=>he.V14.http.SdkResponse.streaming($yc(t)),nonStreaming:t=>he.V14.http.SdkResponse.nonStreaming(Hyc(t)),maybeStreaming:t=>he.V14.http.SdkResponse.maybeStreaming({condition:t.condition,nonStreaming:Hyc(t.nonStreaming),streaming:$yc(t.streaming)}),_unknown:()=>{throw new Error("Encountered unknown sdk response")}})}function NwC(e){return{docs:e.docs,name:e.name,discriminantValue:e.discriminantValue,type:e.type!=null?VF(e.type):void 0,statusCode:e.statusCode}}var xg0={laterVersion:"v16",earlierVersion:"v15",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.5.4-1-g4e69d312",[K.TYPESCRIPT_EXPRESS]:"0.5.4-1-g4e69d312",[K.JAVA]:Ge,[K.JAVA_MODEL]:"0.3.8-rc6-1-gcf4b372",[K.JAVA_SDK]:"0.3.8-rc6-1-gcf4b372",[K.JAVA_SPRING]:"0.3.8-rc6-1-gcf4b372",[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,{taskContext:t,targetGenerator:r})=>e.basePath!=null?t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support specifying a base-path in api.yml. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains a root base-path."):{...e,services:cd(e.services,i=>({...i,pathParameters:Qyc(i.pathParameters),endpoints:i.endpoints.map(n=>({...n,allPathParameters:Qyc(n.allPathParameters),pathParameters:Qyc(n.pathParameters)}))}))}};function Qyc(e){return e.map(t=>LwC(t))}function LwC(e){return{...e,availability:{status:he.V15.commons.AvailabilityStatus.GeneralAvailability,message:void 0}}}var Ig0={laterVersion:"v17",earlierVersion:"v16",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,{taskContext:t,targetGenerator:r})=>{for(let[i,n]of Object.entries(e.types))if(n.shape._type==="union"&&n.shape.extends.length>0)return t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support union types with extensions. See ${i} in file ${n.name.fernFilepath.allParts.join("/")}. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains union types with extensions.");return{...e}}};var zg0={laterVersion:"v18",earlierVersion:"v17",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.5.14-1-ga6817141",[K.TYPESCRIPT_EXPRESS]:"0.5.14-1-ga6817141",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:"0.3.0-3-ge125e311",[K.PYTHON_PYDANTIC]:"0.3.0-3-ge125e311",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"0.3.0-3-ge125e311",[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,{taskContext:t,targetGenerator:r})=>({...e,services:cd(e.services,i=>{let n=i.endpoints[0]?.baseUrl;return i.endpoints.some(a=>a.baseUrl!==n)?t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support endpoint-level server URLs. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains endpoint-level server URLs."):{...i,baseUrl:n}})})};var Fg0={laterVersion:"v19",earlierVersion:"v18",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:ni,[K.TYPESCRIPT_BROWSER_SDK]:ni,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.5.19-1-gef223230",[K.TYPESCRIPT_EXPRESS]:"0.5.19-1-gef223230",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:"0.3.4-rc0-9-ge815162f",[K.PYTHON_PYDANTIC]:"0.3.4-rc0-9-ge815162f",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:"0.0.44-1-gbf4b0f3",[K.PYTHON_SDK]:"0.3.4-rc0-9-ge815162f",[K.GO_FIBER]:ni,[K.GO_MODEL]:ni,[K.GO_SDK]:ni,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,t)=>({...e,services:cd(e.services,r=>UwC(r,t)),types:cd(e.types,r=>QwC(r,t))})};function UwC(e,t){return{...e,endpoints:e.endpoints.map(r=>VwC(r,t))}}function VwC(e,t){return{...e,examples:e.examples.map(r=>WwC(r,t))}}function WwC(e,t){return{docs:e.docs,name:e.name,url:e.url,rootPathParameters:e.rootPathParameters.map(r=>Jyc(r,t)),servicePathParameters:e.servicePathParameters.map(r=>Jyc(r,t)),endpointPathParameters:e.endpointPathParameters.map(r=>Jyc(r,t)),serviceHeaders:e.serviceHeaders.map(r=>Rg0(r,t)),endpointHeaders:e.endpointHeaders.map(r=>Rg0(r,t)),queryParameters:e.queryParameters.map(r=>HwC(r,t)),request:e.request!=null?$wC(e.request,t):void 0,response:GwC(e.response,t)}}function Jyc(e,t){return{key:e.key,value:Iie(e.value,t)}}function Rg0(e,t){return{wireKey:e.wireKey,value:Iie(e.value,t)}}function HwC(e,t){return{wireKey:e.wireKey,value:Iie(e.value,t)}}function $wC(e,t){return he.V19.http.ExampleRequestBody._visit(e,{inlinedRequestBody:r=>he.V18.http.ExampleRequestBody.inlinedRequestBody({jsonExample:r.jsonExample,properties:r.properties.map(i=>({wireKey:i.wireKey,value:Iie(i.value,t),originalTypeDeclaration:i.originalTypeDeclaration}))}),reference:r=>he.V18.http.ExampleRequestBody.reference(Iie(r,t)),_unknown:()=>{throw new Error("Unknown ExampleRequestBody: "+e.type)}})}function GwC(e,t){return he.V19.http.ExampleResponse._visit(e,{ok:r=>he.V18.http.ExampleResponse.ok({body:r.body!=null?Iie(r.body,t):void 0}),error:r=>he.V18.http.ExampleResponse.error({error:r.error,body:r.body!=null?Iie(r.body,t):void 0}),_unknown:()=>{throw new Error("Unknown ExampleResponse: "+e.type)}})}function QwC(e,t){return{...e,examples:e.examples.map(r=>JwC(r,t))}}function JwC(e,t){return{...e,shape:Kyc(e.shape,t)}}function Kyc(e,t){return he.V19.types.ExampleTypeShape._visit(e,{alias:r=>he.V18.types.ExampleTypeShape.alias({value:Iie(r.value,t)}),object:r=>he.V18.types.ExampleTypeShape.object({properties:r.properties.map(i=>({wireKey:i.wireKey,value:Iie(i.value,t),originalTypeDeclaration:i.originalTypeDeclaration}))}),union:r=>he.V18.types.ExampleTypeShape.union({wireDiscriminantValue:r.wireDiscriminantValue,properties:he.V19.types.ExampleSingleUnionTypeProperties._visit(r.properties,{singleProperty:i=>he.V18.types.ExampleSingleUnionTypeProperties.singleProperty({jsonExample:i.jsonExample,shape:Ng0(i.shape,t)}),samePropertiesAsObject:i=>he.V18.types.ExampleSingleUnionTypeProperties.samePropertiesAsObject({typeName:i.typeName,shape:Kyc(i.shape,t)}),noProperties:he.V18.types.ExampleSingleUnionTypeProperties.noProperties,_unknown:()=>{throw new Error("Unknown ExampleSingleUnionTypeProperties: "+r.properties.type)}})}),enum:he.V18.types.ExampleTypeShape.enum,_unknown:()=>{throw new Error("Unknown ExampleTypeShape: "+e.type)}})}function Iie(e,t){return{jsonExample:e.jsonExample,shape:Ng0(e.shape,t)}}function Ng0(e,t){return he.V19.types.ExampleTypeReferenceShape._visit(e,{primitive:r=>he.V18.types.ExampleTypeReferenceShape.primitive(KwC(r,t)),named:r=>he.V18.types.ExampleTypeReferenceShape.named({typeName:r.typeName,shape:Kyc(r.shape,t)}),container:r=>he.V18.types.ExampleTypeReferenceShape.container(he.V19.types.ExampleContainer._visit(r,{list:i=>he.V18.types.ExampleContainer.list(i.map(n=>Iie(n,t))),set:i=>he.V18.types.ExampleContainer.set(i.map(n=>Iie(n,t))),optional:i=>he.V18.types.ExampleContainer.optional(i!=null?Iie(i,t):void 0),map:i=>he.V18.types.ExampleContainer.map(i.map(n=>({key:Iie(n.key,t),value:Iie(n.value,t)}))),_unknown:()=>{throw new Error("Unknown ExampleContainer: "+r.type)}})),unknown:he.V18.types.ExampleTypeReferenceShape.unknown,_unknown:()=>{throw new Error("Unknown ExampleTypeReferenceShape: "+e.type)}})}function KwC(e,{taskContext:t,targetGenerator:r}){return e.type==="date"?t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support examples for dates. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains date examples."):e}var Lg0={laterVersion:"v20",earlierVersion:"v19",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.5.26-rc0-3-gdfabd674",[K.TYPESCRIPT_BROWSER_SDK]:"0.5.26-rc0-3-gdfabd674",[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.5.20-3-g2505487f",[K.TYPESCRIPT_EXPRESS]:"0.5.20-3-g2505487f",[K.JAVA]:Ge,[K.JAVA_MODEL]:"0.3.10-rc2-1-g1c0d853",[K.JAVA_SDK]:"0.3.10-rc2-1-g1c0d853",[K.JAVA_SPRING]:"0.3.10-rc2-1-g1c0d853",[K.PYTHON_FASTAPI]:"0.3.6-rc1-2-g6050f7f8",[K.PYTHON_PYDANTIC]:"0.3.6-rc1-2-g6050f7f8",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"0.3.6-rc1-2-g6050f7f8",[K.GO_FIBER]:ni,[K.GO_MODEL]:"0.0.0",[K.GO_SDK]:"0.0.0",[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,t)=>({...e,services:cd(e.services,r=>YwC(r,t))})};function YwC(e,t){return{...e,endpoints:e.endpoints.map(r=>XwC(r,t))}}function XwC(e,t){return{...e,response:e.response!=null?Ug0(e.response,t):void 0,sdkResponse:e.sdkResponse!=null?ZwC(e.sdkResponse,t):void 0}}function Ug0(e,t){return he.V20.http.HttpResponse._visit(e,{fileDownload:()=>Vg0(t),json:r=>r,_unknown:()=>{throw new Error("Unknown HttpResponse: "+e.type)}})}function ZwC(e,t){return he.V20.http.SdkResponse._visit(e,{fileDownload:()=>Vg0(t),streaming:he.V19.http.SdkResponse.streaming,maybeStreaming:r=>he.V19.http.SdkResponse.maybeStreaming({condition:r.condition,streaming:r.streaming,nonStreaming:Ug0(r.nonStreaming,t)}),json:he.V19.http.SdkResponse.nonStreaming,_unknown:()=>{throw new Error("Unknown SdkResponse: "+e.type)}})}function Vg0({targetGenerator:e,taskContext:t}){return t.failAndThrow(e!=null?`Generator ${e.name}@${e.version} does not support file download. If you'd like to use this feature, please upgrade ${e.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains file download.")}var Wg0={laterVersion:"v21",earlierVersion:"v20",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:ni,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,t)=>({...e,services:cd(e.services,r=>kwC(r,t))})};function kwC(e,t){return{...e,endpoints:e.endpoints.map(r=>e1C(r,t))}}function e1C(e,t){return{...e,streamingResponse:e.streamingResponse!=null?Yyc(e.streamingResponse,t):void 0,sdkResponse:e.sdkResponse!=null?t1C(e.sdkResponse,t):void 0}}function Yyc(e,{taskContext:t,targetGenerator:r}){return{dataEventType:he.V21.http.StreamingResponseChunkType._visit(e.dataEventType,{json:i=>i,text:()=>t.failAndThrow(r!=null?`Generator ${r.name}@${r.version} does not support streaming text responses. If you'd like to use this feature, please upgrade ${r.name} to a compatible version.`:"Cannot backwards-migrate IR because this IR contains streaming text responses."),_unknown:()=>{throw new Error("Unknown StreamingResponseChunkType: "+e.dataEventType.type)}}),terminator:e.terminator}}function t1C(e,t){return he.V21.http.SdkResponse._visit(e,{fileDownload:he.V20.http.SdkResponse.fileDownload,streaming:r=>he.V20.http.SdkResponse.streaming(Yyc(r,t)),maybeStreaming:r=>he.V20.http.SdkResponse.maybeStreaming({condition:r.condition,streaming:Yyc(r.streaming,t),nonStreaming:r.nonStreaming}),json:he.V20.http.SdkResponse.json,_unknown:()=>{throw new Error("Unknown SdkResponse: "+e.type)}})}var Hg0={laterVersion:"v22",earlierVersion:"v21",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:"0.5.0-3-gac7ce7c",[K.GO_MODEL]:"0.0.14-8-g2fa39f7",[K.GO_SDK]:"0.0.14-8-g2fa39f7",[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:e=>({...e,services:cd(e.services,t=>r1C(t))})};function r1C(e){return{...e,endpoints:e.endpoints.map(t=>i1C(t))}}function i1C(e){return{...e,...e.response!=null?he.V22.http.HttpResponse._visit(e.response,{json:t=>({response:he.V21.http.HttpResponse.json(t),streamingResponse:void 0,sdkResponse:he.V21.http.SdkResponse.json(t)}),fileDownload:t=>({response:he.V21.http.HttpResponse.fileDownload(t),streamingResponse:void 0,sdkResponse:he.V21.http.SdkResponse.fileDownload(t)}),streaming:t=>({response:void 0,streamingResponse:t,sdkResponse:he.V21.http.SdkResponse.streaming(t)}),_unknown:()=>{throw new Error("Unknown HttpResponse: "+e.response?.type)}}):{response:void 0,streamingResponse:void 0,sdkResponse:void 0}}}var Qg0={laterVersion:"v23",earlierVersion:"v22",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.7.4-rc3-4-g6cf92f81",[K.TYPESCRIPT_BROWSER_SDK]:"0.7.4-rc3-4-g6cf92f81",[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:"0.7.4-rc3-4-g6cf92f81",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:"0.0.28-3-g112d3dd",[K.STOPLIGHT]:"0.0.28-3-g112d3dd",[K.POSTMAN]:"0.0.44-4-gddab2ae",[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>e,migrateBackwards:(e,t)=>{let r=[],i={};for(let[n,a]of Object.entries(e.services)){let u=[];for(let l of a.endpoints){let f=n1C(l);f==null?r.push(l):u.push(f)}i[n]={...a,endpoints:u,headers:a.headers.map(l=>Zyc(l)),pathParameters:a.pathParameters.map(l=>pCo(l))}}return r.length>0&&(t.taskContext.logger.warn(`Generator ${t.targetGenerator?.name}@${t.targetGenerator?.version} does not support bytes requests. `),r.length===1&&r[0]!=null?t.taskContext.logger.warn(`Therefore, endpoint ${r[0].name.originalName} will be skipped.`):t.taskContext.logger.warn(`Therefore, endpoints ${r.map(n=>n.name.originalName).join(", ")} will be skipped.`)),{...e,auth:{...e.auth,schemes:e.auth.schemes.map(n=>o1C(n))},headers:e.headers.map(n=>Zyc(n)),types:cd(e.types,n=>u1C(n)),services:i,errors:cd(e.errors,n=>p1C(n)),subpackages:e.subpackages,pathParameters:e.pathParameters.map(n=>pCo(n)),variables:e.variables.map(n=>_1C(n))}}};function n1C(e){let t;if(!(e.requestBody!=null&&(t=a1C(e.requestBody),t==null)))return{...e,headers:e.headers.map(r=>Zyc(r)),pathParameters:e.pathParameters.map(r=>pCo(r)),allPathParameters:e.allPathParameters.map(r=>pCo(r)),queryParameters:e.queryParameters.map(r=>h1C(r)),requestBody:t,sdkRequest:e.sdkRequest!=null?{requestParameterName:e.sdkRequest.requestParameterName,shape:y1C(e.sdkRequest.shape)}:void 0,response:e.response!=null?v1C(e.response):void 0,examples:e.examples.map(r=>b1C(r))}}function a1C(e){switch(e.type){case"bytes":return;case"fileUpload":return he.V22.http.HttpRequestBody.fileUpload({...e,properties:e.properties.map(t=>O1C(t))});case"inlinedRequestBody":return he.V22.http.HttpRequestBody.inlinedRequestBody({...e,properties:e.properties.map(t=>m1C(t))});case"reference":return he.V22.http.HttpRequestBody.reference({...e,requestBodyType:WF(e.requestBodyType)});default:Zo(e)}}function Zyc(e){return{...e,valueType:WF(e.valueType)}}function o1C(e){return e._visit({bearer:he.V22.auth.AuthScheme.bearer,basic:he.V22.auth.AuthScheme.basic,header:t=>he.V22.auth.AuthScheme.header({...t,valueType:WF(t.valueType)}),_other:()=>{throw new Error("Unknown auth scheme: "+e.type)}})}function u1C(e){return{...e,shape:s1C(e.shape),examples:e.examples.map(t=>c1C(t))}}function s1C(e){return e._visit({alias:t=>he.V22.types.Type.alias({...t,aliasOf:WF(t.aliasOf),resolvedType:f1C(t.resolvedType)}),enum:he.V22.types.Type.enum,object:t=>he.V22.types.Type.object({...t,properties:t.properties.map(r=>$g0(r))}),union:t=>he.V22.types.Type.union({...t,baseProperties:t.baseProperties.map(r=>$g0(r)),types:t.types.map(r=>({...r,shape:d1C(r.shape)}))}),undiscriminatedUnion:t=>he.V22.types.Type.undiscriminatedUnion({...t,members:t.members.map(r=>({...r,type:WF(r.type)}))}),_other:()=>{throw new Error("Unknown type shape: "+e.type)}})}function c1C(e){return{...e,shape:kyc(e.shape)}}function kyc(e){return e._visit({alias:t=>he.V22.types.ExampleTypeShape.alias({...t,value:lSe(t.value)}),enum:he.V22.types.ExampleTypeShape.enum,object:t=>he.V22.types.ExampleTypeShape.object({...t,properties:t.properties.map(r=>({...r,value:lSe(r.value)}))}),union:t=>he.V22.types.ExampleTypeShape.union({...t,properties:l1C(t.properties)}),_other:()=>{throw new Error("Unknown example type shape: "+e.type)}})}function lSe(e){return{...e,shape:evc(e.shape)}}function evc(e){return e._visit({primitive:t=>he.V22.types.ExampleTypeReferenceShape.primitive(t._visit({integer:he.V22.types.ExamplePrimitive.integer,double:he.V22.types.ExamplePrimitive.double,string:he.V22.types.ExamplePrimitive.string,boolean:he.V22.types.ExamplePrimitive.boolean,long:he.V22.types.ExamplePrimitive.long,datetime:r=>he.V22.types.ExamplePrimitive.datetime(r.toISOString()),date:he.V22.types.ExamplePrimitive.date,uuid:he.V22.types.ExamplePrimitive.uuid,_other:()=>{throw new Error("Unknown example primitive: "+t.type)}})),named:t=>he.V22.types.ExampleTypeReferenceShape.named({...t,shape:kyc(t.shape)}),container:t=>he.V22.types.ExampleTypeReferenceShape.container(t._visit({list:r=>he.V22.types.ExampleContainer.list(r.map(i=>lSe(i))),set:r=>he.V22.types.ExampleContainer.set(r.map(i=>lSe(i))),optional:r=>he.V22.types.ExampleContainer.optional(r!=null?lSe(r):void 0),map:r=>he.V22.types.ExampleContainer.map(r.map(i=>({key:lSe(i.key),value:lSe(i.value)}))),_other:()=>{throw new Error("Unknown example container: "+t.type)}})),unknown:he.V22.types.ExampleTypeReferenceShape.unknown,_other:()=>{throw new Error("Unknown example type reference shape: "+e.type)}})}function l1C(e){return e._visit({singleProperty:t=>he.V22.types.ExampleSingleUnionTypeProperties.singleProperty({...t,shape:evc(t.shape)}),noProperties:he.V22.types.ExampleSingleUnionTypeProperties.noProperties,samePropertiesAsObject:t=>he.V22.types.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...t,shape:kyc(t.shape)}),_other:()=>{throw new Error("Unknown example single union type properties: "+e.type)}})}function WF(e){return e._visit({container:t=>he.V22.types.TypeReference.container(Jg0(t)),primitive:he.V22.types.TypeReference.primitive,named:he.V22.types.TypeReference.named,unknown:he.V22.types.TypeReference.unknown,_other:()=>{throw new Error("Unknown type reference: "+e.type)}})}function Jg0(e){return e._visit({list:t=>he.V22.types.ContainerType.list(WF(t)),set:t=>he.V22.types.ContainerType.set(WF(t)),optional:t=>he.V22.types.ContainerType.optional(WF(t)),map:t=>he.V22.types.ContainerType.map({keyType:WF(t.keyType),valueType:WF(t.valueType)}),literal:he.V22.types.ContainerType.literal,_other:()=>{throw new Error("Unknown container type: "+e.type)}})}function f1C(e){return e._visit({container:t=>he.V22.types.ResolvedTypeReference.container(Jg0(t)),primitive:he.V22.types.ResolvedTypeReference.primitive,named:he.V22.types.ResolvedTypeReference.named,unknown:he.V22.types.ResolvedTypeReference.unknown,_other:()=>{throw new Error("Unknown resolved type reference: "+e.type)}})}function $g0(e){return{...e,valueType:WF(e.valueType)}}function d1C(e){return e._visit({noProperties:he.V22.types.SingleUnionTypeProperties.noProperties,singleProperty:t=>he.V22.types.SingleUnionTypeProperties.singleProperty({...t,type:WF(t.type)}),samePropertiesAsObject:he.V22.types.SingleUnionTypeProperties.samePropertiesAsObject,_other:()=>{throw new Error("Unknown single union type properties: "+e.propertiesType)}})}function p1C(e){return{...e,type:e.type!=null?WF(e.type):void 0}}function _1C(e){return{...e,type:WF(e.type)}}function pCo(e){return{...e,valueType:WF(e.valueType)}}function h1C(e){return{...e,valueType:WF(e.valueType)}}function y1C(e){return e._visit({justRequestBody:t=>he.V22.http.SdkRequestShape.justRequestBody({...t,requestBodyType:WF(t.requestBodyType)}),wrapper:he.V22.http.SdkRequestShape.wrapper,_other:()=>{throw new Error("Unknown SDK request shape: "+e.type)}})}function v1C(e){return e._visit({json:t=>he.V22.http.HttpResponse.json({...t,responseBodyType:WF(t.responseBodyType)}),fileDownload:he.V22.http.HttpResponse.fileDownload,streaming:t=>he.V22.http.HttpResponse.streaming({...t,dataEventType:t.dataEventType._visit({json:r=>he.V22.http.StreamingResponseChunkType.json(WF(r)),text:he.V22.http.StreamingResponseChunkType.text,_other:()=>{throw new Error("Unknown streaming data event type: "+t.dataEventType.type)}})}),_other:()=>{throw new Error("Unknown response: "+e.type)}})}function b1C(e){return{...e,rootPathParameters:e.rootPathParameters.map(t=>Xyc(t)),servicePathParameters:e.servicePathParameters.map(t=>Xyc(t)),endpointPathParameters:e.endpointPathParameters.map(t=>Xyc(t)),serviceHeaders:e.serviceHeaders.map(t=>Gg0(t)),endpointHeaders:e.endpointHeaders.map(t=>Gg0(t)),queryParameters:e.queryParameters.map(t=>g1C(t)),request:e.request!=null?e.request._visit({inlinedRequestBody:t=>he.V22.http.ExampleRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,value:lSe(r.value)}))}),reference:t=>he.V22.http.ExampleRequestBody.reference({...t,shape:evc(t.shape)}),_other:()=>{throw new Error("Unknown example request body: "+e.request?.type)}}):void 0,response:e.response._visit({ok:t=>he.V22.http.ExampleResponse.ok({...t,body:t.body!=null?lSe(t.body):void 0}),error:t=>he.V22.http.ExampleResponse.error({...t,body:t.body!=null?lSe(t.body):void 0}),_other:()=>{throw new Error("Unknown example response: "+e.response.type)}})}}function Xyc(e){return{...e,value:lSe(e.value)}}function g1C(e){return{...e,value:lSe(e.value)}}function Gg0(e){return{...e,value:lSe(e.value)}}function O1C(e){return e._visit({file:he.V22.http.FileUploadRequestProperty.file,bodyProperty:t=>he.V22.http.FileUploadRequestProperty.bodyProperty({...t,valueType:WF(t.valueType)}),_other:()=>{throw new Error("Unknown file upload request body property: "+e.type)}})}function m1C(e){return{...e,valueType:WF(e.valueType)}}var eh={};Ro(eh,{V23:()=>HDF,V24:()=>$DF,V25:()=>GDF,V26:()=>QDF,V27:()=>JDF,V28:()=>KDF,V29:()=>YDF,V30:()=>XDF,V31:()=>ZDF,V32:()=>kDF,V33:()=>eEF,V34:()=>tEF,V35:()=>rEF,V36:()=>iEF,V37:()=>nEF,V38:()=>aEF,V39:()=>oEF,V40:()=>uEF,V41:()=>sEF,V42:()=>cEF,V43:()=>lEF,V44:()=>fEF,V45:()=>dEF,V46:()=>pEF,V47:()=>_EF,V48:()=>hEF,V49:()=>yEF,V50:()=>vEF,V51:()=>bEF,V52:()=>gEF,V53:()=>OEF,V54:()=>mEF,V55:()=>Gp});var HDF=Di(Do(),1),$DF=Di(oo(),1),GDF=Di(Ya(),1),QDF=Di(Qa(),1),JDF=Di(La(),1),KDF=Di(Ua(),1),YDF=Di(Va(),1),XDF=Di(xa(),1),ZDF=Di(Ba(),1),kDF=Di(Oa(),1),eEF=Di(Wn(),1),tEF=Di(Vn(),1),rEF=Di(Tn(),1),iEF=Di(Cn(),1),nEF=Di(qn(),1),aEF=Di(Sn(),1),oEF=Di(ln(),1),uEF=Di(fn(),1),sEF=Di(sn(),1),cEF=Di(tn(),1),lEF=Di(en(),1),fEF=Di(Zi(),1),dEF=Di($i(),1),pEF=Di(Li(),1),_EF=Di(Ni(),1),hEF=Di(Ri(),1),yEF=Di(xi(),1),vEF=Di(Mi(),1),bEF=Di(Ei(),1),gEF=Di(bi(),1),OEF=Di(Gt(),1),mEF=Di(Lh(),1);var KCm={laterVersion:"v24",earlierVersion:"v23",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V23.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),migrateBackwards:e=>({...e})};var YCm={laterVersion:"v25",earlierVersion:"v24",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:"0.4.9-1-ge0997b3",[K.JAVA_SDK]:"0.4.9-1-ge0997b3",[K.JAVA_SPRING]:"0.4.9-1-ge0997b3",[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V24.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),migrateBackwards:(e,t)=>{let r=[],i=[],n={};for(let[a,u]of Object.entries(e.services)){let l=[];for(let f of u.endpoints){let s;if(f.sdkRequest!=null&&(s=PEF(f.sdkRequest),s==null)){r.push(f);continue}if(f.response!=null){let o=f.response._visit({fileDownload:c=>he.V24.HttpResponse.fileDownload(c),json:c=>he.V24.HttpResponse.json(c),streaming:c=>he.V24.HttpResponse.streaming(c),text:()=>(i.push(f),he.V24.HttpResponse.json({docs:void 0,responseBodyType:he.V24.TypeReference.unknown()})),_other:()=>{throw new Error("Encountered unknown response type")}});l.push({...f,sdkRequest:s,response:o})}else l.push({...f,sdkRequest:s,response:void 0})}n[a]={...u,endpoints:l}}return i.length>0&&(t.taskContext.logger.warn(`Generator ${t.targetGenerator?.name}@${t.targetGenerator?.version} does not support text/plain responses. `),i.length===1&&i[0]!=null?t.taskContext.logger.warn(`Therefore, endpoint ${i[0].name.originalName} response type will be casted to unknown.`):t.taskContext.logger.warn(`Therefore, endpoints ${i.map(a=>a.name.originalName).join(", ")} response types will be casted to unknown.`)),r.length>0&&(t.taskContext.logger.warn(`Generator ${t.targetGenerator?.name}@${t.targetGenerator?.version} does not support bytes requests. `),r.length===1&&r[0]!=null?t.taskContext.logger.warn(`Therefore, endpoint ${r[0].name.originalName} will be skipped.`):t.taskContext.logger.warn(`Therefore, endpoints ${r.map(a=>a.name.originalName).join(", ")} will be skipped.`)),{...e,services:n}}};function PEF(e){let t=e.shape;if(t.type==="wrapper")return{shape:he.V24.SdkRequestShape.wrapper({...t}),requestParameterName:e.requestParameterName};if(t.value.type==="typeReference")return{shape:he.V24.SdkRequestShape.justRequestBody({...t.value}),requestParameterName:e.requestParameterName}}var ZCm={laterVersion:"v26",earlierVersion:"v25",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:"0.5.0-rc2-16-g4177fafd",[K.PYTHON_PYDANTIC]:"0.5.0-rc2-16-g4177fafd",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"0.5.0-rc2-16-g4177fafd",[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V25.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),migrateBackwards:e=>({...e,types:Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,EEF(r)])),headers:e.headers.map(t=>lzu(t)),webhookGroups:Object.fromEntries(Object.entries(e.webhookGroups).map(([t,r])=>[t,r.map(i=>jEF(i))])),services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,wEF(r)]))})};function jEF(e){return{...e,headers:e.headers.map(t=>lzu(t)),availability:e.availability==null?{status:he.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function wEF(e){return{...e,endpoints:e.endpoints.map(t=>SEF(t)),headers:e.headers.map(t=>lzu(t)),availability:e.availability==null?{status:he.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function SEF(e){return{...e,headers:e.headers.map(t=>lzu(t)),queryParameters:e.queryParameters.map(t=>DEF(t)),availability:e.availability==null?{status:he.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function lzu(e){return{...e,availability:e.availability==null?{status:he.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function DEF(e){return{...e,availability:e.availability==null?{status:he.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function EEF(e){return{...e,shape:e.shape._visit({union:t=>he.V25.Type.union({...t,baseProperties:t.baseProperties.map(r=>XCm(r))}),object:t=>he.V25.Type.object({...t,properties:t.properties.map(r=>XCm(r))}),enum:t=>he.V25.Type.enum({...t,values:t.values.map(r=>AEF(r))}),alias:t=>he.V25.Type.alias(t),undiscriminatedUnion:t=>he.V25.Type.undiscriminatedUnion(t),_other:()=>{throw new Error("Encountered unknown shape")}}),availability:e.availability==null?{status:he.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function XCm(e){return{...e,availability:e.availability==null?{status:he.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}function AEF(e){return{...e,availability:e.availability==null?{status:he.V25.AvailabilityStatus.GeneralAvailability,message:void 0}:e.availability}}var kCm={laterVersion:"v27",earlierVersion:"v26",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:"0.6.1-3-g94ee67a",[K.GO_MODEL]:"0.6.1-3-g94ee67a",[K.GO_SDK]:"0.6.1-3-g94ee67a",[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V26.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),migrateBackwards:e=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,MEF(r)]))})};function MEF(e){return{...e,endpoints:e.endpoints.map(t=>qEF(t))}}function qEF(e){return{...e,response:e.response!=null?TEF(e.response):void 0}}function TEF(e){if(e.type!=="json")return e;let t=e.value;return t.type==="response"?he.V26.HttpResponse.json(t):he.V26.HttpResponse.json({docs:t.docs,responseBodyType:t.responseBodyType})}var eBm={laterVersion:"v28",earlierVersion:"v27",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.8.1-1-g0f40bf18",[K.TYPESCRIPT_BROWSER_SDK]:"0.8.1-1-g0f40bf18",[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:"0.8.1-1-g0f40bf18",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:"0.9.0-2-g6b0be0e",[K.GO_MODEL]:"0.9.0-2-g6b0be0e",[K.GO_SDK]:"0.9.0-2-g6b0be0e",[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V27.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),migrateBackwards:e=>({...e,auth:oAF(e.auth),headers:dzu(e.headers),types:Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,fAF(r)])),services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,UEF(r)])),webhookGroups:Object.fromEntries(Object.entries(e.webhookGroups).map(([t,r])=>[t,IEF(r)])),errors:Object.fromEntries(Object.entries(e.errors).map(([t,r])=>[t,xEF(r)])),pathParameters:fzu(e.pathParameters),variables:CEF(e.variables)})};function CEF(e){return e.map(t=>BEF(t))}function BEF(e){return{...e,type:aR(e.type)}}function xEF(e){return{...e,type:e.type!=null?aR(e.type):void 0}}function IEF(e){return e.map(t=>zEF(t))}function zEF(e){return{...e,headers:dzu(e.headers),payload:REF(e.payload)}}function REF(e){switch(e.type){case"inlinedPayload":return he.V27.WebhookPayload.inlinedPayload(FEF(e));case"reference":return he.V27.WebhookPayload.reference({...e,payloadType:aR(e.payloadType)})}}function FEF(e){return{...e,properties:NEF(e.properties)}}function NEF(e){return e.map(t=>LEF(t))}function LEF(e){return{...e,valueType:aR(e.valueType)}}function UEF(e){return{...e,endpoints:VEF(e.endpoints),headers:dzu(e.headers),pathParameters:fzu(e.pathParameters)}}function VEF(e){return e.map(t=>WEF(t))}function WEF(e){return{...e,headers:dzu(e.headers),pathParameters:fzu(e.pathParameters),allPathParameters:fzu(e.allPathParameters),queryParameters:nAF(e.queryParameters),requestBody:e.requestBody!=null?XEF(e.requestBody):void 0,sdkRequest:e.sdkRequest!=null?JEF(e.sdkRequest):void 0,response:e.response!=null?HEF(e.response):void 0}}function HEF(e){switch(e.type){case"json":return he.V27.HttpResponse.json(QEF(e.value));case"fileDownload":return he.V27.HttpResponse.fileDownload(e);case"text":return he.V27.HttpResponse.text(e);case"streaming":return he.V27.HttpResponse.streaming($EF(e));default:Zo(e)}}function $EF(e){return{...e,dataEventType:GEF(e.dataEventType)}}function GEF(e){switch(e.type){case"json":return he.V27.StreamingResponseChunkType.json(aR(e.json));case"text":return he.V27.StreamingResponseChunkType.text();default:Zo(e)}}function QEF(e){switch(e.type){case"response":return he.V27.JsonResponse.response({...e,responseBodyType:aR(e.responseBodyType)});case"nestedPropertyAsResponse":return he.V27.JsonResponse.nestedPropertyAsResponse({...e,responseBodyType:aR(e.responseBodyType),responseProperty:e.responseProperty!=null?nBm(e.responseProperty):void 0});default:Zo(e)}}function JEF(e){return{...e,shape:KEF(e.shape)}}function KEF(e){switch(e.type){case"justRequestBody":return he.V27.SdkRequestShape.justRequestBody(YEF(e.value));case"wrapper":return he.V27.SdkRequestShape.wrapper(e);default:Zo(e)}}function YEF(e){switch(e.type){case"typeReference":return he.V27.SdkRequestBodyType.typeReference(tBm(e));case"bytes":return he.V27.SdkRequestBodyType.bytes(e);default:Zo(e)}}function XEF(e){switch(e.type){case"inlinedRequestBody":return he.V27.HttpRequestBody.inlinedRequestBody(tAF(e));case"reference":return he.V27.HttpRequestBody.reference(tBm(e));case"fileUpload":return he.V27.HttpRequestBody.fileUpload(ZEF(e));case"bytes":return he.V27.HttpRequestBody.bytes(e);default:Zo(e)}}function ZEF(e){return{...e,properties:kEF(e.properties)}}function kEF(e){return e.map(t=>eAF(t))}function eAF(e){switch(e.type){case"file":return he.V27.FileUploadRequestProperty.file(e);case"bodyProperty":return he.V27.FileUploadRequestProperty.bodyProperty(rBm(e));default:Zo(e)}}function tBm(e){return{...e,requestBodyType:aR(e.requestBodyType)}}function tAF(e){return{...e,properties:rAF(e.properties)}}function rAF(e){return e.map(t=>rBm(t))}function rBm(e){return{...e,valueType:aR(e.valueType)}}function fzu(e){return e.map(t=>iAF(t))}function iAF(e){return{...e,valueType:aR(e.valueType)}}function nAF(e){return e.map(t=>aAF(t))}function aAF(e){return{...e,valueType:aR(e.valueType)}}function oAF(e){return{...e,schemes:uAF(e.schemes)}}function uAF(e){return e.map(t=>sAF(t))}function sAF(e){switch(e.type){case"basic":return he.V27.AuthScheme.basic(e);case"bearer":return he.V27.AuthScheme.bearer(e);case"header":return cAF(e);default:Zo(e)}}function cAF(e){return he.V27.AuthScheme.header({...e,valueType:aR(e.valueType)})}function dzu(e){return e.map(t=>lAF(t))}function lAF(e){return{...e,valueType:aR(e.valueType)}}function fAF(e){return{...e,shape:dAF(e.shape)}}function dAF(e){switch(e.type){case"alias":return he.V27.Type.alias(pAF(e));case"enum":return he.V27.Type.enum(e);case"object":return he.V27.Type.object(_AF(e));case"union":return he.V27.Type.union(hAF(e));case"undiscriminatedUnion":return he.V27.Type.undiscriminatedUnion(yAF(e));default:Zo(e)}}function pAF(e){return{aliasOf:aR(e.aliasOf),resolvedType:OAF(e.resolvedType)}}function _AF(e){return{...e,properties:iBm(e.properties)}}function hAF(e){return{...e,types:vAF(e.types),baseProperties:iBm(e.baseProperties)}}function yAF(e){return{members:gAF(e.members)}}function iBm(e){return e.map(t=>nBm(t))}function nBm(e){return{...e,valueType:aR(e.valueType)}}function vAF(e){return e.map(t=>({...t,shape:bAF(t.shape)}))}function bAF(e){switch(e.propertiesType){case"samePropertiesAsObject":return he.V27.SingleUnionTypeProperties.samePropertiesAsObject(e);case"singleProperty":return he.V27.SingleUnionTypeProperties.singleProperty({name:e.name,type:aR(e.type)});case"noProperties":return he.V27.SingleUnionTypeProperties.noProperties();default:Zo(e)}}function gAF(e){return e.map(t=>({...t,type:aR(t.type)}))}function OAF(e){switch(e.type){case"container":return e.container.type==="literal"?e.container.literal.type==="boolean"?he.V27.ResolvedTypeReference.primitive(he.V27.PrimitiveType.Boolean):he.V27.ResolvedTypeReference.container(he.V27.ContainerType.literal(he.V27.Literal.string(e.container.literal.string))):he.V27.ResolvedTypeReference.container(aBm(e.container));case"named":return he.V27.ResolvedTypeReference.named(e);case"primitive":return he.V27.ResolvedTypeReference.primitive(e.primitive);case"unknown":return he.V27.ResolvedTypeReference.unknown();default:Zo(e)}}function aR(e){switch(e.type){case"container":return e.container.type==="literal"?e.container.literal.type==="boolean"?he.V27.TypeReference.primitive(he.V27.PrimitiveType.Boolean):he.V27.TypeReference.container(he.V27.ContainerType.literal(he.V27.Literal.string(e.container.literal.string))):he.V27.TypeReference.container(aBm(e.container));case"named":return he.V27.TypeReference.named(e);case"primitive":return he.V27.TypeReference.primitive(e.primitive);case"unknown":return he.V27.TypeReference.unknown();default:Zo(e)}}function aBm(e){switch(e.type){case"list":return he.V27.ContainerType.list(aR(e.list));case"map":return he.V27.ContainerType.map({keyType:aR(e.keyType),valueType:aR(e.valueType)});case"optional":return he.V27.ContainerType.optional(aR(e.optional));case"set":return he.V27.ContainerType.set(aR(e.set));case"literal":if(e.literal.type==="boolean")throw new Error("Internal error; failed to transform boolean literal between IR versions");return he.V27.ContainerType.literal(he.V27.Literal.string(e.literal.string));default:Zo(e)}}var uBm={laterVersion:"v29",earlierVersion:"v28",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.8.6-1-g3d8d8591",[K.TYPESCRIPT_BROWSER_SDK]:"0.8.6-1-g3d8d8591",[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:"0.8.6-1-g3d8d8591",[K.JAVA]:Ge,[K.JAVA_MODEL]:"0.5.14-1-ge4bcd98",[K.JAVA_SDK]:"0.5.14-1-ge4bcd98",[K.JAVA_SPRING]:"0.5.14-1-ge4bcd98",[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V28.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,types:Object.fromEntries(Object.keys(e.types).map(t=>[t,mAF({typeId:t,allTypes:e.types})]))})};function mAF({typeId:e,allTypes:t}){let r=oBm({typeId:e,allTypes:t});return{availability:r.availability,docs:r.docs,name:r.name,shape:r.shape,examples:r.examples,referencedTypes:Array.from(r.referencedTypes).map(i=>{let n=oBm({typeId:i,allTypes:t});return{typeId:i,fernFilepath:n.name.fernFilepath,name:n.name.name}})}}function oBm({typeId:e,allTypes:t}){let r=t[e];if(r==null)throw new Error(`Type definition for type id ${e} is undefined`);return r}var sBm={laterVersion:"v30",earlierVersion:"v29",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:"0.6.5-1-g0ef31b7a",[K.PYTHON_PYDANTIC]:"0.6.5-1-g0ef31b7a",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"0.6.5-1-g0ef31b7a",[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V29.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=new hUl(e);return{...e,types:t.convertTypes(e.types),services:t.convertServices(e.services)}}},hUl=class{ir;constructor(t){this.ir=t}convertTypes(t){return Object.fromEntries(Object.entries(t).map(([r,i])=>[r,this.convertType(i)]))}convertServices(t){return Object.fromEntries(Object.entries(t).map(([r,i])=>[r,this.convertService(i)]))}convertService(t){return{...t,endpoints:this.convertEndpoints(t.endpoints)}}convertEndpoints(t){return t.map(r=>({...r,examples:this.convertExampleEndpointCalls(r.examples)}))}convertExampleEndpointCalls(t){return t.map(r=>({...r,rootPathParameters:this.convertExamplePathParameters(r.rootPathParameters),servicePathParameters:this.convertExamplePathParameters(r.servicePathParameters),endpointPathParameters:this.convertExamplePathParameters(r.endpointPathParameters),serviceHeaders:this.convertExampleHeaders(r.serviceHeaders),endpointHeaders:this.convertExampleHeaders(r.endpointHeaders),queryParameters:this.convertExampleQueryParameters(r.queryParameters),request:r.request!=null?this.convertExampleRequestBody(r.request):void 0,response:this.convertExampleResponse(r.response)}))}convertExamplePathParameters(t){return t.map(r=>({key:r.name.originalName,value:this.convertExampleTypeReference(r.value)}))}convertExampleHeaders(t){return t.map(r=>({wireKey:r.name.wireValue,value:this.convertExampleTypeReference(r.value)}))}convertExampleQueryParameters(t){return t.map(r=>({wireKey:r.name.wireValue,value:this.convertExampleTypeReference(r.value)}))}convertExampleRequestBody(t){switch(t.type){case"inlinedRequestBody":return he.V29.ExampleRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,wireKey:r.name.wireValue,value:this.convertExampleTypeReference(r.value)}))});case"reference":return he.V29.ExampleRequestBody.reference(this.convertExampleTypeReference(t));default:Zo(t)}}convertExampleResponse(t){switch(t.type){case"ok":return he.V29.ExampleResponse.ok({body:t.body!=null?this.convertExampleTypeReference(t.body):void 0});case"error":return he.V29.ExampleResponse.error({...t,body:t.body!=null?this.convertExampleTypeReference(t.body):void 0});default:Zo(t)}}convertType(t){return{...t,examples:this.convertExampleTypes(t.examples)}}convertExampleTypes(t){return t.map(r=>this.convertExampleType(r))}convertExampleType(t){return{...t,shape:this.convertExampleTypeShape(t.shape)}}convertExampleTypeReferences(t){return t.map(r=>this.convertExampleTypeReference(r))}convertExampleTypeReference(t){return{...t,shape:this.convertExampleTypeReferenceShape(t.shape)}}convertExampleTypeReferenceShape(t){switch(t.type){case"primitive":return he.V29.ExampleTypeReferenceShape.primitive(this.convertExamplePrimitive(t.primitive));case"container":return he.V29.ExampleTypeReferenceShape.container(this.convertExampleContainer(t.container));case"named":return he.V29.ExampleTypeReferenceShape.named(this.convertExampleNamedType(t));case"unknown":return he.V29.ExampleTypeReferenceShape.unknown(t);default:Zo(t)}}convertExamplePrimitive(t){switch(t.type){case"integer":return he.V29.ExamplePrimitive.integer(t.integer);case"double":return he.V29.ExamplePrimitive.double(t.double);case"string":return he.V29.ExamplePrimitive.string(t.string.original);case"boolean":return he.V29.ExamplePrimitive.boolean(t.boolean);case"long":return he.V29.ExamplePrimitive.long(t.long);case"datetime":return he.V29.ExamplePrimitive.datetime(t.datetime);case"date":return he.V29.ExamplePrimitive.date(t.date);case"uuid":return he.V29.ExamplePrimitive.uuid(t.uuid);default:Zo(t)}}convertExampleContainer(t){switch(t.type){case"list":return he.V29.ExampleContainer.list(this.convertExampleTypeReferences(t.list));case"set":return he.V29.ExampleContainer.set(this.convertExampleTypeReferences(t.set));case"optional":return he.V29.ExampleContainer.optional(t.optional!=null?this.convertExampleTypeReference(t.optional):void 0);case"map":return he.V29.ExampleContainer.map(this.convertKeyValuePairs(t.map));default:Zo(t)}}convertKeyValuePairs(t){return t.map(r=>({key:this.convertExampleTypeReference(r.key),value:this.convertExampleTypeReference(r.value)}))}convertExampleNamedType(t){return{...t,shape:this.convertExampleTypeShape(t.shape)}}convertExampleTypeShape(t){switch(t.type){case"alias":return he.V29.ExampleTypeShape.alias({value:this.convertExampleTypeReference(t.value)});case"enum":return he.V29.ExampleTypeShape.enum({wireValue:t.value.wireValue});case"object":return he.V29.ExampleTypeShape.object(this.convertExampleObjectType(t));case"union":return he.V29.ExampleTypeShape.union(this.convertExampleUnionType(t));default:Zo(t)}}convertExampleObjectType(t){return{properties:t.properties.map(r=>({...r,wireKey:r.name.wireValue,value:this.convertExampleTypeReference(r.value)}))}}convertExampleUnionType(t){return{wireDiscriminantValue:t.singleUnionType.wireDiscriminantValue.wireValue,properties:this.convertExampleSingleUnionTypeProperties(t.singleUnionType.shape)}}convertExampleSingleUnionTypeProperties(t){switch(t.type){case"samePropertiesAsObject":{let r=this.ir.types[t.typeId]?.name;if(r==null)throw new Error(`Internal error; type ID ${t.typeId} does not exist in the IR`);return he.V29.ExampleSingleUnionTypeProperties.samePropertiesAsObject({typeName:r,shape:this.convertExampleTypeShape(he.V30.ExampleTypeShape.object({properties:t.object.properties}))})}case"singleProperty":return he.V29.ExampleSingleUnionTypeProperties.singleProperty({...t,shape:this.convertExampleTypeReferenceShape(t.shape)});case"noProperties":return he.V29.ExampleSingleUnionTypeProperties.noProperties();default:Zo(t)}}};var cBm={laterVersion:"v31",earlierVersion:"v30",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.8.8",[K.TYPESCRIPT_BROWSER_SDK]:"0.8.8",[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:"0.8.8",[K.JAVA]:Ge,[K.JAVA_MODEL]:"0.7.0-rc0",[K.JAVA_SDK]:"0.7.0-rc0",[K.JAVA_SPRING]:"0.7.0-rc0",[K.PYTHON_FASTAPI]:"0.7.5-1-gb54fb677",[K.PYTHON_PYDANTIC]:"0.7.5-1-gb54fb677",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"0.7.5-1-gb54fb677",[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:ni,[K.RUBY_SDK]:ni,[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V30.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({apiName:e.apiName,apiDisplayName:e.apiDisplayName,apiDocs:e.apiDocs,auth:e.auth,headers:e.headers,types:e.types,webhookGroups:e.webhookGroups,errors:e.errors,subpackages:e.subpackages,rootPackage:e.rootPackage,constants:e.constants,environments:e.environments,basePath:e.basePath,pathParameters:e.pathParameters,errorDiscriminationStrategy:e.errorDiscriminationStrategy,sdkConfig:e.sdkConfig,variables:e.variables,serviceTypeReferenceInfo:e.serviceTypeReferenceInfo,services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{availability:r.availability,name:r.name,displayName:r.displayName,basePath:r.basePath,endpoints:r.endpoints.map(i=>({id:i.id,docs:i.docs,availability:i.availability,name:i.name,displayName:i.displayName,method:i.method,headers:i.headers,baseUrl:i.baseUrl,path:i.path,fullPath:i.fullPath,pathParameters:i.pathParameters,allPathParameters:i.allPathParameters,queryParameters:i.queryParameters,requestBody:i.requestBody,sdkRequest:i.sdkRequest,response:i.response,errors:i.errors,auth:i.auth,examples:i.examples})),headers:r.headers,pathParameters:r.pathParameters}]))})};var fBm={laterVersion:"v32",earlierVersion:"v31",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:"0.9.4-2-g139cf36",[K.GO_MODEL]:"0.9.4-2-g139cf36",[K.GO_SDK]:"0.9.4-2-g139cf36",[K.RUBY_MODEL]:"0.0.0",[K.RUBY_SDK]:"0.0.0",[K.CSHARP_MODEL]:ni,[K.CSHARP_SDK]:ni,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V31.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,types:Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,{...r,examples:EAF(r.examples)}])),services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{...r,endpoints:r.endpoints.map(PAF)}]))})};function NWi({examples:e,convert:t}){let r=[];for(let i of e){let n=t(i);n!=null&&r.push(n)}return r}function PAF(e){return{...e,examples:NWi({examples:e.examples,convert:jAF})}}function jAF(e){let t;if(e.request!=null&&(t=wAF(e.request),t==null))return;let r=SAF(e.response);if(r!=null)return{...e,rootPathParameters:NWi({examples:e.rootPathParameters,convert:yUl}),endpointPathParameters:NWi({examples:e.endpointPathParameters,convert:yUl}),servicePathParameters:NWi({examples:e.servicePathParameters,convert:yUl}),endpointHeaders:NWi({examples:e.endpointHeaders,convert:lBm}),serviceHeaders:NWi({examples:e.serviceHeaders,convert:lBm}),queryParameters:NWi({examples:e.queryParameters,convert:DAF}),request:t,response:r}}function wAF(e){switch(e.type){case"inlinedRequestBody":{let t=[];for(let r of e.properties){let i=yme(r.value);i!=null&&t.push({...r,value:i})}return he.V31.ExampleRequestBody.inlinedRequestBody({...e,properties:t})}case"reference":{let t=vUl(e.shape);return t==null?void 0:he.V31.ExampleRequestBody.reference({...e,shape:t})}default:Zo(e)}}function SAF(e){switch(e.type){case"ok":{if(e.body==null)return he.V31.ExampleResponse.ok({body:void 0});let t=yme(e.body);return t==null?void 0:he.V31.ExampleResponse.ok({body:t})}case"error":{if(e.body==null)return he.V31.ExampleResponse.error({...e,body:void 0});let t=yme(e.body);return t==null?void 0:he.V31.ExampleResponse.error({...e,body:t})}}}function yUl(e){let t=yme(e.value);if(t!=null)return{...e,value:t}}function lBm(e){let t=yme(e.value);if(t!=null)return{...e,value:t}}function DAF(e){let t=yme(e.value);if(t!=null)return{...e,value:t}}function EAF(e){let t=[];for(let r of e){let i=AAF(r);i!=null&&t.push(i)}return t}function AAF(e){let t=dBm(e.shape);if(t!=null)return{...e,shape:t}}function dBm(e){switch(e.type){case"enum":return he.V31.ExampleTypeShape.enum(e);case"alias":{let t=yme(e.value);return t==null?void 0:he.V31.ExampleTypeShape.alias({value:t})}case"object":{let t=[];for(let r of e.properties){let i=yme(r.value);i!=null&&t.push({...r,value:i})}return he.V31.ExampleTypeShape.object({properties:t})}case"union":{let t=MAF(e.singleUnionType);return t==null?void 0:he.V31.ExampleTypeShape.union({...e,singleUnionType:t})}case"undiscriminatedUnion":return;default:Zo(e)}}function yme(e){let t=vUl(e.shape);if(t!=null)return{shape:t,jsonExample:e.jsonExample}}function MAF(e){let t=qAF(e.shape);if(t!=null)return{...e,shape:t}}function qAF(e){switch(e.type){case"noProperties":return he.V31.ExampleSingleUnionTypeProperties.noProperties();case"singleProperty":{let t=vUl(e.shape);return t==null?void 0:he.V31.ExampleSingleUnionTypeProperties.singleProperty({...e,shape:t})}case"samePropertiesAsObject":{let t=[];for(let r of e.object.properties){let i=yme(r.value);i!=null&&t.push({...r,value:i})}return he.V31.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...e,object:{properties:t}})}default:Zo(e)}}function vUl(e){switch(e.type){case"container":{let t=TAF(e.container);return t==null?void 0:he.V31.ExampleTypeReferenceShape.container(t)}case"named":{let t=dBm(e.shape);return t==null?void 0:he.V31.ExampleTypeReferenceShape.named({...e,shape:t})}case"primitive":return he.V31.ExampleTypeReferenceShape.primitive(e.primitive);case"unknown":return he.V31.ExampleTypeReferenceShape.unknown(e.unknown);default:Zo(e)}}function TAF(e){switch(e.type){case"list":{let t=[];for(let r of e.list){let i=yme(r);i!=null&&t.push(i)}return he.V31.ExampleContainer.list(t)}case"set":{let t=[];for(let r of e.set){let i=yme(r);i!=null&&t.push(i)}return he.V31.ExampleContainer.set(t)}case"map":{let t=[];for(let r of e.map){let i=yme(r.key),n=yme(r.value);i!=null&&n!=null&&t.push({key:i,value:n})}return he.V31.ExampleContainer.map(t)}case"optional":{if(e.optional==null)return he.V31.ExampleContainer.optional();let t=yme(e.optional);return t==null?he.V31.ExampleContainer.optional():he.V31.ExampleContainer.optional(t)}default:Zo(e)}}var pBm={laterVersion:"v33",earlierVersion:"v32",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.12.0",[K.TYPESCRIPT_BROWSER_SDK]:"0.12.0",[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:"0.13.0-3-g8c56a41",[K.GO_MODEL]:"0.13.0-3-g8c56a41",[K.GO_SDK]:"0.13.0-3-g8c56a41",[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:"0.0.0",[K.CSHARP_SDK]:"0.0.0",[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V32.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=new bUl(e);return{...e,services:Object.fromEntries(Object.entries(e.services).map(([r,i])=>[r,{...i,endpoints:i.endpoints.map(n=>t.convertEndpoint(n))}]))}}},bUl=class{ir;constructor(t){this.ir=t}convertEndpoint(t){return{...t,queryParameters:t.queryParameters.map(r=>this.isTypeReferenceObject(r.valueType)?{...r,valueType:he.V33.TypeReference.container(he.V33.ContainerType.optional(he.V33.TypeReference.primitive("STRING")))}:r),examples:CAF({examples:t.examples,convert:BAF})}}isTypeReferenceObject(t){switch(t.type){case"container":return this.isContainerObject(t.container);case"named":return this.isNamedTypeObject(t);case"primitive":return!1;case"unknown":return!0;default:Zo(t)}}isContainerObject(t){switch(t.type){case"map":case"list":case"set":return!0;case"optional":return this.isTypeReferenceObject(t.optional);case"literal":return!1;default:Zo(t)}}isNamedTypeObject(t){let r=this.ir.types[t.typeId];if(r==null)return!0;switch(r.shape.type){case"alias":return this.isTypeReferenceObject(r.shape.aliasOf);case"enum":return!1;case"object":case"union":case"undiscriminatedUnion":return!0;default:Zo(r.shape)}}};function CAF({examples:e,convert:t}){let r=[];for(let i of e){let n=t(i);n!=null&&r.push(n)}return r}function BAF(e){return{...e,queryParameters:e.queryParameters.filter(t=>!gUl(t.value))}}function gUl(e){switch(e.shape.type){case"container":return xAF(e.shape.container);case"named":return IAF(e.shape);case"primitive":return!1;case"unknown":return!0;default:Zo(e.shape)}}function xAF(e){switch(e.type){case"map":case"list":case"set":return!0;case"optional":return e.optional!=null&&gUl(e.optional);default:Zo(e)}}function IAF(e){switch(e.shape.type){case"alias":return gUl(e.shape.value);case"enum":return!1;case"object":case"union":case"undiscriminatedUnion":return!0;default:Zo(e.shape)}}var fzn=Di(ric(),1);var _Bm={laterVersion:"v34",earlierVersion:"v33",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"0.10.4",[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V33.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([r,i])=>[r,{...i,endpoints:i.endpoints.map(n=>({...n,requestBody:n.requestBody?._visit({inlinedRequestBody:a=>fzn.FernIrV33.HttpRequestBody.inlinedRequestBody(a),reference:a=>fzn.FernIrV33.HttpRequestBody.reference(a),fileUpload:a=>fzn.FernIrV33.HttpRequestBody.fileUpload({...a,properties:a.properties.map(u=>(u.type==="file"&&u.value.type==="fileArray"&&t.taskContext.logger.warn(`${n.method} ${n.fullPath.head} accepts a list of files however the ${t.targetGenerator?.name}@${t.targetGenerator?.version} only supports accepting a single file. File an [issue](https://github.com/fern-api/fern/issues) to add request for file arrays in ${t.targetGenerator?.name}@${t.targetGenerator?.version}!`),u.type==="file"?fzn.FernIrV33.FileUploadRequestProperty.file({...u.value}):u))}),bytes:a=>fzn.FernIrV33.HttpRequestBody.bytes(a),_other:a=>{}})}))}]))})};var hBm={laterVersion:"v35",earlierVersion:"v34",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:"0.18.0",[K.GO_MODEL]:"0.18.0",[K.GO_SDK]:"0.18.0",[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V34.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{...r,endpoints:r.endpoints.map(i=>({docs:i.docs,availability:i.availability,id:i.id,name:i.name,displayName:i.displayName,method:i.method,headers:i.headers,baseUrl:i.baseUrl,path:i.path,fullPath:i.fullPath,pathParameters:i.pathParameters,allPathParameters:i.allPathParameters,queryParameters:i.queryParameters,requestBody:i.requestBody,sdkRequest:i.sdkRequest,response:i.response,errors:i.errors,auth:i.auth,idempotent:i.idempotent,examples:i.examples}))}]))})};var yBm={laterVersion:"v36",earlierVersion:"v35",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"0.11.6",[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V35.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e})};var vBm={laterVersion:"v37",earlierVersion:"v36",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.13.0",[K.TYPESCRIPT_BROWSER_SDK]:"0.13.0",[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:"0.13.0",[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"0.12.0",[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V36.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([r,i])=>[r,{...i,endpoints:i.endpoints.map(n=>({...n,examples:n.examples.filter(a=>a.exampleType==="userProvided")}))}]))})};var bBm={laterVersion:"v38",earlierVersion:"v37",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.15.0-rc0",[K.TYPESCRIPT_BROWSER_SDK]:"0.15.0-rc0",[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:"0.12.0-rc0",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:"0.9.0-rc0",[K.PYTHON_PYDANTIC]:"0.9.0-rc0",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"1.2.0-rc0",[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V37.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([r,i])=>[r,{...i,endpoints:i.endpoints.map(n=>({...n,response:n.response?._visit({fileDownload:a=>he.V37.HttpResponse.fileDownload(a),json:a=>he.V37.HttpResponse.json(a),streaming:a=>a._visit({json:u=>he.V37.HttpResponse.streaming({dataEventType:he.V37.StreamingResponseChunkType.json(u.payload),docs:u.docs,terminator:u.terminator}),sse:()=>{},text:u=>he.V37.HttpResponse.streaming({dataEventType:he.V37.StreamingResponseChunkType.text(),docs:u.docs,terminator:void 0}),_other:()=>{}}),text:a=>he.V37.HttpResponse.text(a),_other:()=>{}})}))}]))})};var gBm={laterVersion:"v39",earlierVersion:"v38",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:"0.9.0-rc1",[K.PYTHON_PYDANTIC]:"0.9.0-rc1",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"1.4.0-rc1",[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:"0.7.0-rc0",[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V38.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,auth:{...e.auth,schemes:e.auth.schemes.map(r=>zAF(r))}})};function zAF(e){switch(e.type){case"basic":return he.V38.AuthScheme.basic(e);case"bearer":return he.V38.AuthScheme.bearer(e);case"header":return he.V38.AuthScheme.header(e);case"oauth":return he.V38.AuthScheme.bearer({docs:e.docs,token:{originalName:"token",camelCase:{unsafeName:"token",safeName:"token"},pascalCase:{unsafeName:"Token",safeName:"Token"},snakeCase:{unsafeName:"token",safeName:"token"},screamingSnakeCase:{unsafeName:"TOKEN",safeName:"TOKEN"}},tokenEnvVar:void 0});default:Zo(e)}}var OBm={laterVersion:"v40",earlierVersion:"v39",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:"0.20.0",[K.GO_MODEL]:"0.20.0",[K.GO_SDK]:"0.20.0",[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V39.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e})};var mBm={laterVersion:"v41",earlierVersion:"v40",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V40.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,errors:Object.fromEntries(Object.entries(e.errors).map(([r,i])=>[r,{name:i.name,discriminantValue:i.discriminantValue,type:i.type,statusCode:i.statusCode,docs:i.docs}]))})};var PBm={laterVersion:"v42",earlierVersion:"v41",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:"0.8.0-rc0",[K.JAVA_SDK]:"0.9.0-rc0",[K.JAVA_SPRING]:"0.8.0-rc0",[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V41.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,auth:{...e.auth,schemes:e.auth.schemes.map(r=>RAF(r))}})};function RAF(e){switch(e.type){case"basic":return he.V41.AuthScheme.basic(e);case"bearer":return he.V41.AuthScheme.bearer(e);case"header":return he.V41.AuthScheme.header(e);case"oauth":return he.V41.AuthScheme.oauth(FAF(e));default:Zo(e)}}function FAF(e){switch(e.configuration.type){case"clientCredentials":return{...e,configuration:he.V41.OAuthConfiguration.clientCredentials({...e.configuration,tokenEndpoint:{...e.configuration.tokenEndpoint,endpointReference:e.configuration.tokenEndpoint.endpointReference.endpointId},refreshEndpoint:e.configuration.refreshEndpoint!=null?{...e.configuration.refreshEndpoint,endpointReference:e.configuration.refreshEndpoint?.endpointReference.endpointId}:void 0})};default:Zo(e.configuration.type)}}var jBm={laterVersion:"v43",earlierVersion:"v42",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.17.0",[K.TYPESCRIPT_BROWSER_SDK]:"0.17.0",[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:"0.13.0",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V42.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([r,i])=>[r,{...i,endpoints:i.endpoints.map(n=>({...n,response:n.response?.body}))}]))})};var SBm={laterVersion:"v44",earlierVersion:"v43",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V43.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:(e,t)=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([r,i])=>[r,{...i,endpoints:i.endpoints.map(n=>({...n,examples:n.examples.map(a=>NAF({example:a})).filter(dg)}))}]))})};function NAF({example:e}){return e._visit({userProvided:t=>he.V43.HttpEndpointExample.userProvided(wBm({example:t})),generated:t=>he.V43.HttpEndpointExample.generated(wBm({example:t})),_other:()=>{}})}function wBm({example:e}){return{...e,response:LAF({example:e.response})}}function LAF({example:e}){switch(e.type){case"ok":return UAF({example:e.value});case"error":return he.V43.ExampleResponse.error(e);default:Zo(e)}}function UAF({example:e}){switch(e.type){case"body":return he.V43.ExampleResponse.ok({body:e.value});case"sse":return he.V43.ExampleResponse.ok({body:void 0});case"stream":return he.V43.ExampleResponse.ok({body:void 0});default:Zo(e)}}var DBm={laterVersion:"v45",earlierVersion:"v44",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V44.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=cd(e.types,r=>({...r,shape:he.V45.types.Type._visit(r.shape,{union:i=>he.V44.types.Type.union({...i,baseProperties:i.baseProperties.map(n=>({...n,valueType:rq(n.valueType)})),types:i.types.map(n=>kAF(n))}),enum:he.V44.types.Type.enum,object:i=>he.V44.types.Type.object({...i,properties:i.properties.map(n=>({...n,valueType:rq(n.valueType)}))}),alias:i=>he.V44.types.Type.alias({aliasOf:rq(i.aliasOf),resolvedType:tMF(i.resolvedType)}),undiscriminatedUnion:i=>he.V44.types.Type.undiscriminatedUnion(rMF(i)),_other:()=>{throw new Error("Encountered unknown shape")}})}));return{...e,auth:JAF(e.auth),headers:e.headers.map(r=>dzn(r)),idempotencyHeaders:e.idempotencyHeaders.map(r=>dzn(r)),types:t,services:cd(e.services,r=>iMF(r)),errors:cd(e.errors,r=>gMF(r)),webhookGroups:cd(e.webhookGroups,r=>$AF(r)),websocketChannels:cd(e.websocketChannels,r=>VAF(r)),pathParameters:e.pathParameters.map(r=>AMa(r)),variables:e.variables.map(r=>nMF(r))}}};function VAF(e){return{...e,headers:e.headers.map(t=>dzn(t)),queryParameters:e.queryParameters.map(t=>MMa(t)),pathParameters:e.pathParameters.map(t=>AMa(t)),messages:e.messages.map(t=>WAF(t))}}function WAF(e){return{...e,body:HAF(e.body)}}function HAF(e){switch(e.type){case"inlinedBody":return he.V44.websocket.WebSocketMessageBody.inlinedBody({...e,properties:e.properties.map(t=>({...t,valueType:rq(t.valueType)}))});case"reference":return he.V44.websocket.WebSocketMessageBody.reference({...e,bodyType:rq(e.bodyType)})}}function $AF(e){return e.map(t=>GAF(t))}function GAF(e){return{...e,headers:e.headers.map(t=>dzn(t)),payload:QAF(e.payload)}}function QAF(e){switch(e.type){case"reference":return he.V44.webhooks.WebhookPayload.reference({...e,payloadType:rq(e.payloadType)});case"inlinedPayload":return he.V44.webhooks.WebhookPayload.inlinedPayload({...e,properties:e.properties.map(t=>({...t,valueType:rq(t.valueType)}))})}}function JAF(e){return{...e,schemes:e.schemes.map(t=>{switch(t.type){case"basic":return he.V44.auth.AuthScheme.basic(t);case"bearer":return he.V44.auth.AuthScheme.bearer(t);case"header":return he.V44.auth.AuthScheme.header(KAF(t));case"oauth":return he.V44.auth.AuthScheme.oauth(YAF(t))}})}}function KAF(e){return{...e,valueType:rq(e.valueType)}}function YAF(e){return{...e,configuration:he.V44.auth.OAuthConfiguration.clientCredentials({...e.configuration,tokenEndpoint:XAF(e.configuration.tokenEndpoint),refreshEndpoint:e.configuration.refreshEndpoint!=null?ZAF(e.configuration.refreshEndpoint):void 0})}}function XAF(e){return{...e,requestProperties:{clientId:pzu(e.requestProperties.clientId),clientSecret:pzu(e.requestProperties.clientSecret),scopes:e.requestProperties.scopes!=null?pzu(e.requestProperties.scopes):void 0},responseProperties:{accessToken:r$r(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?r$r(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?r$r(e.responseProperties.refreshToken):void 0}}}function ZAF(e){return{...e,requestProperties:{refreshToken:pzu(e.requestProperties.refreshToken)},responseProperties:{accessToken:r$r(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?r$r(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?r$r(e.responseProperties.refreshToken):void 0}}}function dzn(e){return{...e,valueType:rq(e.valueType)}}function rq(e){return he.V45.types.TypeReference._visit(e,{container:t=>he.V44.types.TypeReference.container(EBm(t)),primitive:t=>t.v1==="BIG_INTEGER"?he.V44.types.TypeReference.primitive(he.V44.types.PrimitiveType.String):he.V44.types.TypeReference.primitive(t.v1),named:he.V44.types.TypeReference.named,unknown:he.V44.types.TypeReference.unknown,_other:()=>{throw new Error("Unknown type reference: "+e.type)}})}function EBm(e){return he.V45.types.ContainerType._visit(e,{list:t=>he.V44.types.ContainerType.list(rq(t)),optional:t=>he.V44.types.ContainerType.optional(rq(t)),set:t=>he.V44.types.ContainerType.set(rq(t)),map:({keyType:t,valueType:r})=>he.V44.types.ContainerType.map({keyType:rq(t),valueType:rq(r)}),literal:he.V44.types.ContainerType.literal,_other:()=>{throw new Error("Unknown ContainerType: "+e.type)}})}function kAF(e){return{...e,shape:eMF(e.shape)}}function eMF(e){return he.V45.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>he.V44.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>he.V44.types.SingleUnionTypeProperties.singleProperty({...t,type:rq(t.type)}),noProperties:he.V44.types.SingleUnionTypeProperties.noProperties,_other:()=>{throw new Error(`Unknown SingleUnionTypeProperties: ${JSON.stringify(e)}`)}})}function tMF(e){return he.V45.types.ResolvedTypeReference._visit(e,{container:t=>he.V44.types.ResolvedTypeReference.container(EBm(t)),named:he.V44.types.ResolvedTypeReference.named,primitive:t=>t.v1==="BIG_INTEGER"?he.V44.types.ResolvedTypeReference.primitive(he.V44.types.PrimitiveType.String):he.V44.types.ResolvedTypeReference.primitive(t.v1),unknown:he.V44.types.ResolvedTypeReference.unknown,_other:()=>{throw new Error("Unknown ResolvedTypeReference: "+e.type)}})}function rMF(e){return{members:e.members.map(t=>({...t,type:rq(t.type)}))}}function iMF(e){return{...e,pathParameters:e.pathParameters.map(t=>AMa(t)),headers:e.headers.map(t=>dzn(t)),endpoints:e.endpoints.map(t=>aMF(t))}}function AMa(e){return{...e,valueType:rq(e.valueType)}}function nMF(e){return{...e,type:rq(e.type)}}function aMF(e){return{...e,pagination:e.pagination!=null?lMF(e.pagination):void 0,allPathParameters:e.allPathParameters.map(t=>AMa(t)),pathParameters:e.pathParameters.map(t=>AMa(t)),sdkRequest:e.sdkRequest!=null?_MF(e.sdkRequest):void 0,requestBody:e.requestBody!=null?vMF(e.requestBody):void 0,response:e.response!=null?oMF(e.response):void 0,headers:e.headers.map(t=>dzn(t)),queryParameters:e.queryParameters.map(t=>MMa(t))}}function oMF(e){return{...e,body:e.body!=null?uMF(e.body):void 0}}function uMF(e){switch(e.type){case"json":return he.V44.http.HttpResponseBody.json(sMF(e.value));case"fileDownload":return he.V44.http.HttpResponseBody.fileDownload(e);case"text":return he.V44.http.HttpResponseBody.text(e);case"streaming":return he.V44.http.HttpResponseBody.streaming(cMF(e.value))}}function sMF(e){switch(e.type){case"response":return he.V44.http.JsonResponse.response({...e,responseBodyType:rq(e.responseBodyType)});case"nestedPropertyAsResponse":return he.V44.http.JsonResponse.nestedPropertyAsResponse({...e,responseBodyType:rq(e.responseBodyType),responseProperty:e.responseProperty!=null?OUl(e.responseProperty):void 0})}}function cMF(e){switch(e.type){case"json":return he.V44.http.StreamingResponse.json({...e,payload:rq(e.payload)});case"text":return he.V44.http.StreamingResponse.text(e);case"sse":return he.V44.http.StreamingResponse.sse({...e,payload:rq(e.payload)})}}function lMF(e){switch(e.type){case"cursor":return he.V44.http.Pagination.cursor(fMF(e));case"offset":return he.V44.http.Pagination.offset(dMF(e))}}function fMF(e){return{...e,page:MMa(e.page),next:r$r(e.next),results:r$r(e.results)}}function dMF(e){return{...e,page:MMa(e.page),results:r$r(e.results)}}function pzu(e){return{...e,property:pMF(e.property)}}function pMF(e){switch(e.type){case"query":return he.V44.RequestPropertyValue.query(MMa(e));case"body":return he.V44.RequestPropertyValue.body(OUl(e))}}function r$r(e){return{...e,property:OUl(e.property)}}function OUl(e){return{...e,valueType:rq(e.valueType)}}function MMa(e){return{...e,valueType:rq(e.valueType)}}function _MF(e){return{...e,shape:hMF(e.shape)}}function hMF(e){return he.V45.http.SdkRequestShape._visit(e,{justRequestBody:t=>he.V44.http.SdkRequestShape.justRequestBody(yMF(t)),wrapper:he.V44.http.SdkRequestShape.wrapper,_other:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function yMF(e){switch(e.type){case"bytes":return he.V44.http.SdkRequestBodyType.bytes(e);case"typeReference":return he.V44.http.SdkRequestBodyType.typeReference({...e,requestBodyType:rq(e.requestBodyType)})}}function vMF(e){return he.V45.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>he.V44.http.HttpRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,valueType:rq(r.valueType)}))}),reference:t=>he.V44.http.HttpRequestBody.reference({...t,requestBodyType:rq(t.requestBodyType)}),fileUpload:t=>he.V44.http.HttpRequestBody.fileUpload({...t,properties:t.properties.map(r=>{switch(r.type){case"bodyProperty":return he.V44.http.FileUploadRequestProperty.bodyProperty({...r,valueType:rq(r.valueType)});case"file":return he.V44.http.FileUploadRequestProperty.file(bMF(r.value))}})}),bytes:t=>he.V44.http.HttpRequestBody.bytes(t),_other:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function bMF(e){switch(e.type){case"file":return he.V44.http.FileProperty.file(e);case"fileArray":return he.V44.http.FileProperty.fileArray(e)}}function gMF(e){return{...e,type:e.type!=null?rq(e.type):void 0}}var MBm={laterVersion:"v46",earlierVersion:"v45",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.21.0",[K.TYPESCRIPT_BROWSER_SDK]:"0.21.0",[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:"0.16.0",[K.JAVA]:Ge,[K.JAVA_MODEL]:"0.9.0",[K.JAVA_SDK]:"0.10.0",[K.JAVA_SPRING]:"0.9.0",[K.PYTHON_FASTAPI]:"0.10.1",[K.PYTHON_PYDANTIC]:"0.9.1",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"2.9.9",[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V45.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,types:Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,{...r,examples:OMF(r.examples)}])),services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{...r,endpoints:r.endpoints.map(i=>({...i,examples:mMF(i.examples)}))}])),websocketChannels:e.websocketChannels!=null?Object.fromEntries(Object.entries(e.websocketChannels).map(([t,r])=>[t,{...r,examples:PMF(r.examples)}])):void 0,errors:Object.fromEntries(Object.entries(e.errors).map(([t,r])=>[t,{...r,examples:r.examples.map(i=>({...i,shape:pN(i.shape)}))}]))})};function pN(e){return e.shape._visit({container:t=>({...e,shape:t._visit({list:r=>he.V45.ExampleTypeReferenceShape.container(he.V45.ExampleContainer.list(r.map(i=>pN(i)))),set:r=>he.V45.ExampleTypeReferenceShape.container(he.V45.ExampleContainer.set(r.map(i=>pN(i)))),map:r=>he.V45.ExampleTypeReferenceShape.container(he.V45.ExampleContainer.map(r.map(i=>({key:pN(i.key),value:pN(i.value)})))),optional:r=>he.V45.ExampleTypeReferenceShape.container(he.V45.ExampleContainer.optional(r!=null?pN(r):void 0)),literal:r=>he.V45.ExampleTypeReferenceShape.primitive(r._visit({string:i=>he.V45.ExamplePrimitive.string(i),integer:i=>he.V45.ExamplePrimitive.integer(i),double:i=>he.V45.ExamplePrimitive.double(i),long:i=>he.V45.ExamplePrimitive.long(i),boolean:i=>he.V45.ExamplePrimitive.boolean(i),datetime:i=>he.V45.ExamplePrimitive.datetime(i),date:i=>he.V45.ExamplePrimitive.date(i),uuid:i=>he.V45.ExamplePrimitive.uuid(i),_other:i=>{throw new Error(`Unexpected value: ${JSON.stringify(i)}`)}})),_other:r=>{throw new Error(`Unexpected value: ${JSON.stringify(r)}`)}})}),named:t=>({...e,shape:he.V45.ExampleTypeReferenceShape.named({...t,shape:qBm(t.shape)})}),primitive:t=>({...e,shape:he.V45.ExampleTypeReferenceShape.primitive(t._visit({string:r=>he.V45.ExamplePrimitive.string(r),integer:r=>he.V45.ExamplePrimitive.integer(r),double:r=>he.V45.ExamplePrimitive.double(r),long:r=>he.V45.ExamplePrimitive.long(r),boolean:r=>he.V45.ExamplePrimitive.boolean(r),datetime:r=>he.V45.ExamplePrimitive.datetime(r),date:r=>he.V45.ExamplePrimitive.date(r),uuid:r=>he.V45.ExamplePrimitive.uuid(r),_other:r=>{throw new Error(`Unexpected value: ${JSON.stringify(r)}`)}}))}),unknown:t=>({...e,shape:he.V45.ExampleTypeReferenceShape.unknown(t)}),_other:t=>{throw new Error(`Unexpected value: ${JSON.stringify(t)}`)}})}function ABm(e){return{...e,properties:e.properties.map(t=>({...t,value:pN(t.value)}))}}function qBm(e){return e.type==="alias"?he.V45.ExampleTypeShape.alias({value:pN(e.value)}):e.type==="object"?he.V45.ExampleTypeShape.object(ABm(e)):e.type==="union"?he.V45.ExampleTypeShape.union({...e,singleUnionType:{...e.singleUnionType,shape:e.singleUnionType.shape._visit({samePropertiesAsObject:t=>he.V45.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...t,object:ABm(t.object)}),singleProperty:t=>he.V45.ExampleSingleUnionTypeProperties.singleProperty(pN(t)),noProperties:()=>he.V45.ExampleSingleUnionTypeProperties.noProperties(),_other:t=>{throw new Error(`Unexpected value: ${JSON.stringify(t)}`)}})}}):e.type==="undiscriminatedUnion"?he.V45.ExampleTypeShape.undiscriminatedUnion({...e,singleUnionType:pN(e.singleUnionType)}):he.V45.ExampleTypeShape.enum(e)}function OMF(e){return e.map(t=>({...t,shape:qBm(t.shape)}))}function _zu(e){return e.map(t=>({...t,value:pN(t.value)}))}function mUl(e){return e.map(t=>({...t,value:pN(t.value)}))}function TBm(e){return e.map(t=>({...t,value:pN(t.value)}))}function mMF(e){return e.map(t=>{let r={...t,rootPathParameters:_zu(t.rootPathParameters),servicePathParameters:_zu(t.servicePathParameters),endpointPathParameters:_zu(t.endpointPathParameters),serviceHeaders:mUl(t.serviceHeaders),endpointHeaders:mUl(t.endpointHeaders),queryParameters:TBm(t.queryParameters),request:t.request?._visit({inlinedRequestBody:i=>he.V45.ExampleRequestBody.inlinedRequestBody({...i,properties:i.properties.map(n=>({...n,value:pN(n.value)}))}),reference:i=>he.V45.ExampleRequestBody.reference(pN(i)),_other:i=>{throw new Error(`Unexpected value: ${JSON.stringify(i)}`)}}),response:t.response._visit({ok:i=>he.V45.ExampleResponse.ok(i._visit({body:n=>he.V45.ExampleEndpointSuccessResponse.body(n!=null?pN(n):void 0),stream:n=>he.V45.ExampleEndpointSuccessResponse.stream(n.map(pN)),sse:n=>he.V45.ExampleEndpointSuccessResponse.sse(n.map(a=>({...a,data:pN(a.data)}))),_other:n=>{throw new Error(`Unexpected value: ${JSON.stringify(n)}`)}})),error:i=>he.V45.ExampleResponse.error({...i,body:i.body!=null?pN(i.body):void 0}),_other:i=>{throw new Error(`Unexpected value: ${JSON.stringify(i)}`)}})};return t._visit({userProvided:()=>he.V45.HttpEndpointExample.userProvided(r),generated:()=>he.V45.HttpEndpointExample.generated(r),_other:i=>{throw new Error(`Unexpected value: ${JSON.stringify(i)}`)}})})}function PMF(e){return e.map(t=>({...t,pathParameters:_zu(t.pathParameters),headers:mUl(t.headers),queryParameters:TBm(t.queryParameters),messages:t.messages.map(r=>({...r,body:r.body._visit({inlinedBody:i=>he.V45.ExampleWebSocketMessageBody.inlinedBody({...i,properties:i.properties.map(n=>({...n,value:pN(n.value)}))}),reference:i=>he.V45.ExampleWebSocketMessageBody.reference(pN(i)),_other:i=>{throw new Error(`Unexpected value: ${JSON.stringify(i)}`)}})}))}))}var CBm={laterVersion:"v47",earlierVersion:"v46",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V46.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,services:Object.fromEntries(Object.entries(e.services).map(([t,r])=>{let i=r.endpoints.map(n=>{let{autogeneratedExamples:a,userSpecifiedExamples:u,...l}=n;return{...l,autogeneratedExamples:void 0,userSpecifiedExamples:void 0,examples:[...n.userSpecifiedExamples.map(s=>{if(s.example!=null)return he.V46.HttpEndpointExample.userProvided({...s.example,codeSamples:s.codeSamples})}).filter(dg),...n.autogeneratedExamples.map(s=>he.V46.HttpEndpointExample.generated({...s.example,codeSamples:void 0}))]}});return[t,{...r,endpoints:i}]}))})};var BBm={laterVersion:"v48",earlierVersion:"v47",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.29.0",[K.TYPESCRIPT_BROWSER_SDK]:"0.29.0",[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:"0.17.0",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V47.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=Object.fromEntries(Object.entries(e.services).map(([r,i])=>{let n=i.endpoints.map(a=>({...a,pagination:a.pagination!=null?wMF(a.pagination):void 0}));return[r,{...i,endpoints:n}]}));return{...e,sdkConfig:{...e.sdkConfig,hasPaginatedEndpoints:jMF(t)},services:t}}};function jMF(e){for(let t of Object.values(e))for(let r of t.endpoints)if(r.pagination!=null)return!0;return!1}function wMF(e){switch(e.type){case"cursor":{let t=SMF(e);return t!=null?he.V47.Pagination.cursor(t):void 0}case"offset":{let t=DMF(e);return t!=null?he.V47.Pagination.offset(t):void 0}default:Zo(e)}}function SMF(e){let t=xBm(e.page);if(t!=null)return{...e,page:t}}function DMF(e){if(e.step!=null)return;let t=xBm(e.page);if(t!=null)return{...e,page:t}}function xBm(e){switch(e.property.type){case"query":return e.property}}var IBm={laterVersion:"v49",earlierVersion:"v48",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:"0.11.0-rc0",[K.PYTHON_PYDANTIC]:"0.10.0-rc0",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:"2.11.0-rc0",[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:ni,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V48.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=Object.fromEntries(Object.entries(e.services).map(([r,i])=>{let n=i.endpoints.flatMap(a=>{let u;return a.response?.body!=null&&(u=a.response.body?._visit({json:f=>he.V48.HttpResponseBody.json({...f}),fileDownload:f=>he.V48.HttpResponseBody.fileDownload({...f}),text:f=>he.V48.HttpResponseBody.text({...f}),streaming:f=>he.V48.HttpResponseBody.streaming({...f}),streamParameter:()=>{},_other:()=>{}}),u==null)?[]:{...a,response:a.response==null?void 0:{statusCode:a.response?.statusCode,body:u}}});return[r,{...i,endpoints:n}]}));return{...e,services:t}}};var zBm={laterVersion:"v50",earlierVersion:"v49",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.34.0",[K.TYPESCRIPT_BROWSER_SDK]:"0.34.0",[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:"0.17.2",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:"0.0.0",[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V49.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=cd(e.types,r=>({...r,shape:he.V50.types.Type._visit(r.shape,{union:i=>he.V49.types.Type.union({...i,baseProperties:i.baseProperties.map(n=>({...n,valueType:iq(n.valueType)})),types:i.types.map(n=>FMF(n))}),enum:he.V49.types.Type.enum,object:i=>he.V49.types.Type.object({...i,properties:i.properties.map(n=>({...n,valueType:iq(n.valueType)}))}),alias:i=>he.V49.types.Type.alias({aliasOf:iq(i.aliasOf),resolvedType:LMF(i.resolvedType)}),undiscriminatedUnion:i=>he.V49.types.Type.undiscriminatedUnion(UMF(i)),_other:()=>{throw new Error("Encountered unknown shape")}})}));return{...e,auth:BMF(e.auth),headers:e.headers.map(r=>pzn(r)),idempotencyHeaders:e.idempotencyHeaders.map(r=>pzn(r)),types:t,services:cd(e.services,r=>VMF(r)),errors:cd(e.errors,r=>nqF(r)),webhookGroups:cd(e.webhookGroups,r=>qMF(r)),websocketChannels:cd(e.websocketChannels,r=>EMF(r)),pathParameters:e.pathParameters.map(r=>qMa(r)),variables:e.variables.map(r=>WMF(r))}}};function EMF(e){return{...e,headers:e.headers.map(t=>pzn(t)),queryParameters:e.queryParameters.map(t=>jUl(t)),pathParameters:e.pathParameters.map(t=>qMa(t)),messages:e.messages.map(t=>AMF(t))}}function AMF(e){return{...e,body:MMF(e.body)}}function MMF(e){switch(e.type){case"inlinedBody":return he.V49.websocket.WebSocketMessageBody.inlinedBody({...e,properties:e.properties.map(t=>({...t,valueType:iq(t.valueType)}))});case"reference":return he.V49.websocket.WebSocketMessageBody.reference({...e,bodyType:iq(e.bodyType)})}}function qMF(e){return e.map(t=>TMF(t))}function TMF(e){return{...e,headers:e.headers.map(t=>pzn(t)),payload:CMF(e.payload)}}function CMF(e){switch(e.type){case"reference":return he.V49.webhooks.WebhookPayload.reference({...e,payloadType:iq(e.payloadType)});case"inlinedPayload":return he.V49.webhooks.WebhookPayload.inlinedPayload({...e,properties:e.properties.map(t=>({...t,valueType:iq(t.valueType)}))})}}function BMF(e){return{...e,schemes:e.schemes.map(t=>{switch(t.type){case"basic":return he.V49.auth.AuthScheme.basic(t);case"bearer":return he.V49.auth.AuthScheme.bearer(t);case"header":return he.V49.auth.AuthScheme.header(xMF(t));case"oauth":return he.V49.auth.AuthScheme.oauth(IMF(t))}})}}function xMF(e){return{...e,valueType:iq(e.valueType)}}function IMF(e){return{...e,configuration:he.V49.auth.OAuthConfiguration.clientCredentials({...e.configuration,tokenEndpoint:zMF(e.configuration.tokenEndpoint),refreshEndpoint:e.configuration.refreshEndpoint!=null?RMF(e.configuration.refreshEndpoint):void 0})}}function zMF(e){return{...e,requestProperties:{clientId:q_i(e.requestProperties.clientId),clientSecret:q_i(e.requestProperties.clientSecret),scopes:e.requestProperties.scopes!=null?q_i(e.requestProperties.scopes):void 0},responseProperties:{accessToken:i$r(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?i$r(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?i$r(e.responseProperties.refreshToken):void 0}}}function RMF(e){return{...e,requestProperties:{refreshToken:q_i(e.requestProperties.refreshToken)},responseProperties:{accessToken:i$r(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?i$r(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?i$r(e.responseProperties.refreshToken):void 0}}}function pzn(e){return{...e,valueType:iq(e.valueType)}}function iq(e){return he.V50.types.TypeReference._visit(e,{container:t=>he.V49.types.TypeReference.container(RBm(t)),primitive:t=>t.v2?.type==="integer"?he.V49.types.TypeReference.primitive({v1:t.v1,v2:he.V49.types.PrimitiveTypeV2.integer(t.v2)}):t.v2?.type==="double"?he.V49.types.TypeReference.primitive({v1:t.v1,v2:he.V49.types.PrimitiveTypeV2.double(t.v2)}):t.v2?.type==="string"?he.V49.types.TypeReference.primitive({v1:t.v1,v2:he.V49.types.PrimitiveTypeV2.string(t.v2)}):he.V49.types.TypeReference.primitive({v1:t.v1,v2:void 0}),named:he.V49.types.TypeReference.named,unknown:he.V49.types.TypeReference.unknown,_other:()=>{throw new Error("Unknown type reference: "+e.type)}})}function RBm(e){return he.V50.types.ContainerType._visit(e,{list:t=>he.V49.types.ContainerType.list(iq(t)),optional:t=>he.V49.types.ContainerType.optional(iq(t)),set:t=>he.V49.types.ContainerType.set(iq(t)),map:({keyType:t,valueType:r})=>he.V49.types.ContainerType.map({keyType:iq(t),valueType:iq(r)}),literal:he.V49.types.ContainerType.literal,_other:()=>{throw new Error("Unknown ContainerType: "+e.type)}})}function FMF(e){return{...e,shape:NMF(e.shape)}}function NMF(e){return he.V50.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>he.V49.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>he.V49.types.SingleUnionTypeProperties.singleProperty({...t,type:iq(t.type)}),noProperties:he.V49.types.SingleUnionTypeProperties.noProperties,_other:()=>{throw new Error(`Unknown SingleUnionTypeProperties: ${JSON.stringify(e)}`)}})}function LMF(e){return he.V50.types.ResolvedTypeReference._visit(e,{container:t=>he.V49.types.ResolvedTypeReference.container(RBm(t)),named:he.V49.types.ResolvedTypeReference.named,primitive:t=>t.v2?.type==="integer"?he.V49.types.ResolvedTypeReference.primitive({v1:t.v1,v2:he.V49.types.PrimitiveTypeV2.integer(t.v2)}):t.v2?.type==="double"?he.V49.types.ResolvedTypeReference.primitive({v1:t.v1,v2:he.V49.types.PrimitiveTypeV2.double(t.v2)}):t.v2?.type==="string"?he.V49.types.ResolvedTypeReference.primitive({v1:t.v1,v2:he.V49.types.PrimitiveTypeV2.string(t.v2)}):he.V49.types.ResolvedTypeReference.primitive({v1:t.v1,v2:void 0}),unknown:he.V49.types.ResolvedTypeReference.unknown,_other:()=>{throw new Error("Unknown ResolvedTypeReference: "+e.type)}})}function UMF(e){return{members:e.members.map(t=>({...t,type:iq(t.type)}))}}function VMF(e){return{...e,pathParameters:e.pathParameters.map(t=>qMa(t)),headers:e.headers.map(t=>pzn(t)),endpoints:e.endpoints.map(t=>HMF(t))}}function qMa(e){return{...e,valueType:iq(e.valueType)}}function WMF(e){return{...e,type:iq(e.type)}}function HMF(e){return{...e,pagination:e.pagination!=null?KMF(e.pagination):void 0,allPathParameters:e.allPathParameters.map(t=>qMa(t)),pathParameters:e.pathParameters.map(t=>qMa(t)),sdkRequest:e.sdkRequest!=null?kMF(e.sdkRequest):void 0,requestBody:e.requestBody!=null?rqF(e.requestBody):void 0,response:e.response!=null?$MF(e.response):void 0,headers:e.headers.map(t=>pzn(t)),queryParameters:e.queryParameters.map(t=>jUl(t))}}function $MF(e){return{...e,body:e.body!=null?GMF(e.body):void 0}}function GMF(e){switch(e.type){case"json":return he.V49.http.HttpResponseBody.json(FBm(e.value));case"fileDownload":return he.V49.http.HttpResponseBody.fileDownload(e);case"text":return he.V49.http.HttpResponseBody.text(e);case"streaming":return he.V49.http.HttpResponseBody.streaming(NBm(e.value));case"streamParameter":return he.V49.http.HttpResponseBody.streamParameter(JMF(e))}}function FBm(e){switch(e.type){case"response":return he.V49.http.JsonResponse.response({...e,responseBodyType:iq(e.responseBodyType)});case"nestedPropertyAsResponse":return he.V49.http.JsonResponse.nestedPropertyAsResponse({...e,responseBodyType:iq(e.responseBodyType),responseProperty:e.responseProperty!=null?PUl(e.responseProperty):void 0})}}function NBm(e){switch(e.type){case"json":return he.V49.http.StreamingResponse.json({...e,payload:iq(e.payload)});case"text":return he.V49.http.StreamingResponse.text(e);case"sse":return he.V49.http.StreamingResponse.sse({...e,payload:iq(e.payload)})}}function QMF(e){switch(e.type){case"json":return he.V49.http.NonStreamHttpResponseBody.json(FBm(e.value));case"text":return he.V49.http.NonStreamHttpResponseBody.text(e);case"fileDownload":return he.V49.http.NonStreamHttpResponseBody.fileDownload(e)}}function JMF(e){return{nonStreamResponse:QMF(e.nonStreamResponse),streamResponse:NBm(e.streamResponse)}}function KMF(e){switch(e.type){case"cursor":return he.V49.http.Pagination.cursor(YMF(e));case"offset":return he.V49.http.Pagination.offset(XMF(e))}}function YMF(e){return{...e,page:q_i(e.page),next:i$r(e.next),results:i$r(e.results)}}function XMF(e){return{...e,page:q_i(e.page),results:i$r(e.results),step:e.step!=null?q_i(e.step):void 0}}function q_i(e){return{...e,property:ZMF(e.property)}}function ZMF(e){switch(e.type){case"query":return he.V49.RequestPropertyValue.query(jUl(e));case"body":return he.V49.RequestPropertyValue.body(PUl(e))}}function i$r(e){return{...e,property:PUl(e.property)}}function PUl(e){return{...e,valueType:iq(e.valueType)}}function jUl(e){return{...e,valueType:iq(e.valueType)}}function kMF(e){return{...e,streamParameter:e.streamParameter!=null?q_i(e.streamParameter):void 0,shape:eqF(e.shape)}}function eqF(e){return he.V50.http.SdkRequestShape._visit(e,{justRequestBody:t=>he.V49.http.SdkRequestShape.justRequestBody(tqF(t)),wrapper:he.V49.http.SdkRequestShape.wrapper,_other:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function tqF(e){switch(e.type){case"bytes":return he.V49.http.SdkRequestBodyType.bytes(e);case"typeReference":return he.V49.http.SdkRequestBodyType.typeReference({...e,requestBodyType:iq(e.requestBodyType)})}}function rqF(e){return he.V50.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>he.V49.http.HttpRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,valueType:iq(r.valueType)}))}),reference:t=>he.V49.http.HttpRequestBody.reference({...t,requestBodyType:iq(t.requestBodyType)}),fileUpload:t=>he.V49.http.HttpRequestBody.fileUpload({...t,properties:t.properties.map(r=>{switch(r.type){case"bodyProperty":return he.V49.http.FileUploadRequestProperty.bodyProperty({...r,valueType:iq(r.valueType)});case"file":return he.V49.http.FileUploadRequestProperty.file(iqF(r.value))}})}),bytes:t=>he.V49.http.HttpRequestBody.bytes(t),_other:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function iqF(e){switch(e.type){case"file":return he.V49.http.FileProperty.file(e);case"fileArray":return he.V49.http.FileProperty.fileArray(e)}}function nqF(e){return{...e,type:e.type!=null?iq(e.type):void 0}}var VBm={laterVersion:"v51",earlierVersion:"v50",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:"0.1.2",[K.SWIFT_MODEL]:Ge,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V50.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>{let t=cd(e.types,r=>{let i=r.autogeneratedExamples.map(a=>LBm(a)),n=r.userProvidedExamples.map(a=>LBm(a));return{...r,examples:[...i,...n]}});return{...e,types:t,services:cd(e.services,r=>hqF(r)),errors:cd(e.errors,r=>OqF(r)),webhookGroups:cd(e.webhookGroups,r=>sqF(r)),websocketChannels:cd(e.websocketChannels,r=>aqF(r))}}};function aqF(e){return{...e,examples:e.examples.map(t=>oqF(t))}}function oqF(e){return{...e,pathParameters:e.pathParameters.map(t=>hzu(t)),headers:e.headers.map(t=>wUl(t)),queryParameters:e.queryParameters.map(t=>WBm(t)),messages:e.messages.map(t=>({...t,body:uqF(t.body)}))}}function WBm(e){return{...e,value:S6(e.value)}}function wUl(e){return{...e,value:S6(e.value)}}function hzu(e){return{...e,value:S6(e.value)}}function uqF(e){switch(e.type){case"inlinedBody":return he.V50.ExampleWebSocketMessageBody.inlinedBody(HBm(e));case"reference":return he.V50.ExampleWebSocketMessageBody.reference(S6(e))}}function HBm(e){return{...e,properties:e.properties.map(t=>({...t,value:S6(t.value)}))}}function sqF(e){return e.map(t=>({...t,examples:t.examples?.map(r=>({...r,payload:S6(r.payload)}))}))}function LBm(e){return{...e,shape:$Bm(e.shape)}}function SUl(e){switch(e.type){case"primitive":return he.V50.ExampleTypeReferenceShape.primitive({...e.primitive});case"container":return he.V50.ExampleTypeReferenceShape.container(cqF(e));case"unknown":return he.V50.ExampleTypeReferenceShape.unknown(e.unknown);case"named":return he.V50.ExampleTypeReferenceShape.named({...e,typeName:e.typeName,shape:$Bm(e.shape)})}}function cqF(e){switch(e.container.type){case"list":return he.V50.ExampleContainer.list(e.container.list.map(t=>S6(t)));case"set":return he.V50.ExampleContainer.set(e.container.set.map(t=>S6(t)));case"optional":return he.V50.ExampleContainer.optional(e.container.optional!=null?S6(e.container.optional):void 0);case"map":return he.V50.ExampleContainer.map(e.container.map.map(t=>({key:S6(t.key),value:S6(t.value)})));case"literal":return he.V50.ExampleContainer.literal(e.container.literal)}}function S6(e){return{...e,shape:SUl(e.shape)}}function $Bm(e){switch(e.type){case"object":return he.V50.ExampleTypeShape.object({properties:e.properties.map(t=>GBm(t))});case"alias":return he.V50.ExampleTypeShape.alias({value:{...S6(e.value)}});case"enum":return he.V50.ExampleTypeShape.enum(e);case"union":return he.V50.ExampleTypeShape.union(fqF(e));case"undiscriminatedUnion":return he.V50.ExampleTypeShape.undiscriminatedUnion(lqF(e))}}function lqF(e){return{...e,singleUnionType:S6(e.singleUnionType)}}function fqF(e){return{...e,singleUnionType:dqF(e.singleUnionType)}}function dqF(e){return{...e,shape:pqF(e.shape)}}function pqF(e){switch(e.type){case"samePropertiesAsObject":return he.V50.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...e,object:_qF(e.object)});case"singleProperty":return he.V50.ExampleSingleUnionTypeProperties.singleProperty({...e,shape:SUl(e.shape)});case"noProperties":return he.V50.ExampleSingleUnionTypeProperties.noProperties()}}function _qF(e){return{...e,properties:e.properties.map(t=>GBm(t))}}function GBm(e){return{...e,value:{...e.value,shape:SUl(e.value.shape)}}}function hqF(e){return{...e,endpoints:e.endpoints.map(t=>yqF(t))}}function yqF(e){return{...e,autogeneratedExamples:e.autogeneratedExamples.map(t=>({...t,example:UBm(t.example)})),userSpecifiedExamples:e.userSpecifiedExamples.map(t=>({...t,example:t.example!=null?UBm(t.example):void 0}))}}function UBm(e){return{...e,rootPathParameters:e.rootPathParameters.map(t=>hzu(t)),servicePathParameters:e.servicePathParameters.map(t=>hzu(t)),endpointPathParameters:e.endpointPathParameters.map(t=>hzu(t)),serviceHeaders:e.serviceHeaders.map(t=>wUl(t)),endpointHeaders:e.endpointHeaders.map(t=>wUl(t)),queryParameters:e.queryParameters.map(t=>WBm(t)),request:e.request!=null?gqF(e.request):void 0,response:vqF(e.response)}}function vqF(e){switch(e.type){case"error":return he.V50.ExampleResponse.error({...e,body:e.body!=null?S6(e.body):void 0});case"ok":return he.V50.ExampleResponse.ok(bqF(e))}}function bqF(e){switch(e.value.type){case"body":return he.V50.ExampleEndpointSuccessResponse.body(e.value.value!=null?S6(e.value.value):void 0);case"stream":return he.V50.ExampleEndpointSuccessResponse.stream(e.value.value.map(t=>S6(t)));case"sse":return he.V50.ExampleEndpointSuccessResponse.sse(e.value.value.map(t=>({...t,data:S6(t.data)})))}}function gqF(e){switch(e.type){case"inlinedRequestBody":return he.V50.ExampleRequestBody.inlinedRequestBody(HBm(e));case"reference":return he.V50.ExampleRequestBody.reference(S6(e))}}function OqF(e){return{...e,examples:e.examples.map(t=>({...t,shape:S6(t.shape)}))}}var KBm={laterVersion:"v52",earlierVersion:"v51",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:Ge,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:ni},jsonifyEarlierVersion:e=>eh.V51.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,apiVersion:e.apiVersion!=null?PqF(e.apiVersion):void 0,auth:qqF(e.auth),headers:e.headers.map(t=>LWi(t)),idempotencyHeaders:e.idempotencyHeaders.map(t=>LWi(t)),types:mqF(e.types),services:cd(e.services,t=>UqF(t)),webhookGroups:cd(e.webhookGroups,t=>DqF(t)),websocketChannels:cd(e.websocketChannels,t=>jqF(t)),errors:cd(e.errors,t=>iTF(t)),pathParameters:e.pathParameters.map(t=>TMa(t)),variables:e.variables.map(t=>VqF(t))})};function mqF(e){return cd(e,t=>({...t,autogeneratedExamples:t.autogeneratedExamples.map(r=>QBm(r)),userProvidedExamples:t.userProvidedExamples.map(r=>QBm(r)),shape:he.V52.types.Type._visit(t.shape,{union:r=>he.V51.types.Type.union({...r,baseProperties:r.baseProperties.map(i=>({...i,valueType:HD(i.valueType)})),types:r.types.map(i=>RqF(i))}),enum:he.V51.types.Type.enum,object:r=>he.V51.types.Type.object({...r,properties:r.properties.map(i=>({...i,valueType:HD(i.valueType)}))}),alias:r=>he.V51.types.Type.alias({aliasOf:HD(r.aliasOf),resolvedType:NqF(r.resolvedType)}),undiscriminatedUnion:r=>he.V51.types.Type.undiscriminatedUnion(LqF(r)),_other:()=>{throw new Error("Encountered unknown shape")}})}))}function PqF(e){return he.V51.ApiVersionScheme.header({...e,header:LWi(e.header)})}function jqF(e){return{...e,headers:e.headers.map(t=>LWi(t)),queryParameters:e.queryParameters.map(t=>AUl(t)),pathParameters:e.pathParameters.map(t=>TMa(t)),messages:e.messages.map(t=>wqF(t)),examples:e.examples.map(t=>nTF(t))}}function wqF(e){return{...e,body:SqF(e.body)}}function SqF(e){switch(e.type){case"inlinedBody":return he.V51.websocket.WebSocketMessageBody.inlinedBody({...e,properties:e.properties.map(t=>({...t,valueType:HD(t.valueType)}))});case"reference":return he.V51.websocket.WebSocketMessageBody.reference({...e,bodyType:HD(e.bodyType)})}}function DqF(e){return e.map(t=>EqF(t))}function EqF(e){return{...e,headers:e.headers.map(t=>LWi(t)),payload:AqF(e.payload),examples:e.examples!=null?e.examples.map(t=>MqF(t)):void 0}}function AqF(e){switch(e.type){case"reference":return he.V51.webhooks.WebhookPayload.reference({...e,payloadType:HD(e.payloadType)});case"inlinedPayload":return he.V51.webhooks.WebhookPayload.inlinedPayload({...e,properties:e.properties.map(t=>({...t,valueType:HD(t.valueType)}))})}}function MqF(e){return{...e,payload:D6(e.payload)}}function qqF(e){return{...e,schemes:e.schemes.map(t=>{switch(t.type){case"basic":return he.V51.auth.AuthScheme.basic(t);case"bearer":return he.V51.auth.AuthScheme.bearer(t);case"header":return he.V51.auth.AuthScheme.header(TqF(t));case"oauth":return he.V51.auth.AuthScheme.oauth(CqF(t))}})}}function TqF(e){return{...e,valueType:HD(e.valueType)}}function CqF(e){return{...e,configuration:he.V51.auth.OAuthConfiguration.clientCredentials({...e.configuration,tokenEndpoint:BqF(e.configuration.tokenEndpoint),refreshEndpoint:e.configuration.refreshEndpoint!=null?xqF(e.configuration.refreshEndpoint):void 0})}}function BqF(e){return{...e,requestProperties:{clientId:T_i(e.requestProperties.clientId),clientSecret:T_i(e.requestProperties.clientSecret),scopes:e.requestProperties.scopes!=null?T_i(e.requestProperties.scopes):void 0},responseProperties:{accessToken:n$r(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?n$r(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?n$r(e.responseProperties.refreshToken):void 0}}}function xqF(e){return{...e,requestProperties:{refreshToken:T_i(e.requestProperties.refreshToken)},responseProperties:{accessToken:n$r(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?n$r(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?n$r(e.responseProperties.refreshToken):void 0}}}function LWi(e){return{...e,valueType:HD(e.valueType)}}function HD(e){return he.V52.types.TypeReference._visit(e,{container:t=>he.V51.types.TypeReference.container(XBm(t)),primitive:t=>he.V51.types.TypeReference.primitive(YBm(t)),named:he.V51.types.TypeReference.named,unknown:he.V51.types.TypeReference.unknown,_other:()=>{throw new Error("Unknown type reference: "+e.type)}})}function YBm(e){return{v1:IqF(e.v1),v2:e.v2!=null?zqF(e.v2):void 0}}function IqF(e){switch(e){case"UINT":return he.V51.types.PrimitiveTypeV1.Integer;case"UINT_64":return he.V51.types.PrimitiveTypeV1.Long}return e}function zqF(e){switch(e.type){case"integer":return he.V51.types.PrimitiveTypeV2.integer(e);case"double":return he.V51.types.PrimitiveTypeV2.double(e);case"string":return he.V51.types.PrimitiveTypeV2.string(e);case"boolean":return he.V51.types.PrimitiveTypeV2.boolean(e);case"long":return he.V51.types.PrimitiveTypeV2.long(e);case"bigInteger":return he.V51.types.PrimitiveTypeV2.bigInteger(e);case"uint":return;case"uint64":return;default:Zo(e)}}function XBm(e){return he.V52.types.ContainerType._visit(e,{list:t=>he.V51.types.ContainerType.list(HD(t)),optional:t=>he.V51.types.ContainerType.optional(HD(t)),set:t=>he.V51.types.ContainerType.set(HD(t)),map:({keyType:t,valueType:r})=>he.V51.types.ContainerType.map({keyType:HD(t),valueType:HD(r)}),literal:he.V51.types.ContainerType.literal,_other:()=>{throw new Error("Unknown ContainerType: "+e.type)}})}function RqF(e){return{...e,shape:FqF(e.shape)}}function FqF(e){return he.V52.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>he.V51.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>he.V51.types.SingleUnionTypeProperties.singleProperty({...t,type:HD(t.type)}),noProperties:he.V51.types.SingleUnionTypeProperties.noProperties,_other:()=>{throw new Error(`Unknown SingleUnionTypeProperties: ${JSON.stringify(e)}`)}})}function NqF(e){return he.V52.types.ResolvedTypeReference._visit(e,{container:t=>he.V51.types.ResolvedTypeReference.container(XBm(t)),named:he.V51.types.ResolvedTypeReference.named,primitive:t=>he.V51.types.ResolvedTypeReference.primitive(YBm(t)),unknown:he.V51.types.ResolvedTypeReference.unknown,_other:()=>{throw new Error("Unknown ResolvedTypeReference: "+e.type)}})}function LqF(e){return{members:e.members.map(t=>({...t,type:HD(t.type)}))}}function UqF(e){return{...e,pathParameters:e.pathParameters.map(t=>TMa(t)),headers:e.headers.map(t=>LWi(t)),endpoints:e.endpoints.map(t=>WqF(t))}}function TMa(e){return{...e,valueType:HD(e.valueType)}}function VqF(e){return{...e,type:HD(e.type)}}function WqF(e){return{...e,pagination:e.pagination!=null?JqF(e.pagination):void 0,allPathParameters:e.allPathParameters.map(t=>TMa(t)),pathParameters:e.pathParameters.map(t=>TMa(t)),sdkRequest:e.sdkRequest!=null?ZqF(e.sdkRequest):void 0,requestBody:e.requestBody!=null?tTF(e.requestBody):void 0,response:e.response!=null?HqF(e.response):void 0,headers:e.headers.map(t=>LWi(t)),queryParameters:e.queryParameters.map(t=>AUl(t)),autogeneratedExamples:e.autogeneratedExamples.map(t=>({...t,example:JBm(t.example)})),userSpecifiedExamples:e.userSpecifiedExamples.map(t=>({...t,example:t.example!=null?JBm(t.example):void 0}))}}function HqF(e){return{...e,body:e.body!=null?$qF(e.body):void 0}}function $qF(e){switch(e.type){case"json":return he.V51.http.HttpResponseBody.json(ZBm(e.value));case"fileDownload":return he.V51.http.HttpResponseBody.fileDownload(e);case"text":return he.V51.http.HttpResponseBody.text(e);case"streaming":return he.V51.http.HttpResponseBody.streaming(kBm(e.value));case"streamParameter":return he.V51.http.HttpResponseBody.streamParameter(QqF(e))}}function ZBm(e){switch(e.type){case"response":return he.V51.http.JsonResponse.response({...e,responseBodyType:HD(e.responseBodyType)});case"nestedPropertyAsResponse":return he.V51.http.JsonResponse.nestedPropertyAsResponse({...e,responseBodyType:HD(e.responseBodyType),responseProperty:e.responseProperty!=null?EUl(e.responseProperty):void 0})}}function kBm(e){switch(e.type){case"json":return he.V51.http.StreamingResponse.json({...e,payload:HD(e.payload)});case"text":return he.V51.http.StreamingResponse.text(e);case"sse":return he.V51.http.StreamingResponse.sse({...e,payload:HD(e.payload)})}}function GqF(e){switch(e.type){case"json":return he.V51.http.NonStreamHttpResponseBody.json(ZBm(e.value));case"text":return he.V51.http.NonStreamHttpResponseBody.text(e);case"fileDownload":return he.V51.http.NonStreamHttpResponseBody.fileDownload(e)}}function QqF(e){return{nonStreamResponse:GqF(e.nonStreamResponse),streamResponse:kBm(e.streamResponse)}}function JqF(e){switch(e.type){case"cursor":return he.V51.http.Pagination.cursor(KqF(e));case"offset":return he.V51.http.Pagination.offset(YqF(e))}}function KqF(e){return{...e,page:T_i(e.page),next:n$r(e.next),results:n$r(e.results)}}function YqF(e){return{...e,page:T_i(e.page),results:n$r(e.results),step:e.step!=null?T_i(e.step):void 0}}function T_i(e){return{...e,property:XqF(e.property)}}function XqF(e){switch(e.type){case"query":return he.V51.RequestPropertyValue.query(AUl(e));case"body":return he.V51.RequestPropertyValue.body(EUl(e))}}function n$r(e){return{...e,property:EUl(e.property)}}function EUl(e){return{...e,valueType:HD(e.valueType)}}function AUl(e){return{...e,valueType:HD(e.valueType)}}function ZqF(e){return{...e,streamParameter:e.streamParameter!=null?T_i(e.streamParameter):void 0,shape:kqF(e.shape)}}function kqF(e){return he.V52.http.SdkRequestShape._visit(e,{justRequestBody:t=>he.V51.http.SdkRequestShape.justRequestBody(eTF(t)),wrapper:he.V51.http.SdkRequestShape.wrapper,_other:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function eTF(e){switch(e.type){case"bytes":return he.V51.http.SdkRequestBodyType.bytes(e);case"typeReference":return he.V51.http.SdkRequestBodyType.typeReference({...e,requestBodyType:HD(e.requestBodyType)})}}function tTF(e){return he.V52.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>he.V51.http.HttpRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,valueType:HD(r.valueType)}))}),reference:t=>he.V51.http.HttpRequestBody.reference({...t,requestBodyType:HD(t.requestBodyType)}),fileUpload:t=>he.V51.http.HttpRequestBody.fileUpload({...t,properties:t.properties.map(r=>{switch(r.type){case"bodyProperty":return he.V51.http.FileUploadRequestProperty.bodyProperty({...r,valueType:HD(r.valueType)});case"file":return he.V51.http.FileUploadRequestProperty.file(rTF(r.value))}})}),bytes:t=>he.V51.http.HttpRequestBody.bytes(t),_other:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function rTF(e){switch(e.type){case"file":return he.V51.http.FileProperty.file(e);case"fileArray":return he.V51.http.FileProperty.fileArray(e)}}function iTF(e){return{...e,type:e.type!=null?HD(e.type):void 0,examples:e.examples.map(t=>({...t,shape:D6(t.shape)}))}}function nTF(e){return{...e,pathParameters:e.pathParameters.map(t=>yzu(t)),headers:e.headers.map(t=>DUl(t)),queryParameters:e.queryParameters.map(t=>exm(t)),messages:e.messages.map(t=>({...t,body:aTF(t.body)}))}}function exm(e){return{...e,value:D6(e.value)}}function DUl(e){return{...e,value:D6(e.value)}}function yzu(e){return{...e,value:D6(e.value)}}function aTF(e){switch(e.type){case"inlinedBody":return he.V51.ExampleWebSocketMessageBody.inlinedBody(txm(e));case"reference":return he.V51.ExampleWebSocketMessageBody.reference(D6(e))}}function txm(e){return{...e,properties:e.properties.map(t=>({...t,value:D6(t.value)}))}}function QBm(e){return{...e,shape:ixm(e.shape)}}function MUl(e){switch(e.type){case"primitive":return he.V51.ExampleTypeReferenceShape.primitive(oTF(e));case"container":return he.V51.ExampleTypeReferenceShape.container(uTF(e));case"unknown":return he.V51.ExampleTypeReferenceShape.unknown(e.unknown);case"named":return he.V51.ExampleTypeReferenceShape.named({...e,typeName:e.typeName,shape:ixm(e.shape)})}}function rxm(e){switch(e.type){case"integer":return he.V51.ExamplePrimitive.integer(e.integer);case"uint":return he.V51.ExamplePrimitive.integer(e.uint);case"uint64":return he.V51.ExamplePrimitive.integer(e.uint64);case"double":return he.V51.ExamplePrimitive.double(e.double);case"long":return he.V51.ExamplePrimitive.long(e.long);case"boolean":return he.V51.ExamplePrimitive.boolean(e.boolean);case"string":return he.V51.ExamplePrimitive.string(e.string);case"date":return he.V51.ExamplePrimitive.date(e.date);case"datetime":return he.V51.ExamplePrimitive.datetime(e.datetime);case"uuid":return he.V51.ExamplePrimitive.uuid(e.uuid)}}function oTF(e){return rxm(e.primitive)}function uTF(e){switch(e.container.type){case"list":return he.V51.ExampleContainer.list({list:e.container.list.map(t=>D6(t)),itemType:HD(e.container.itemType)});case"set":return he.V51.ExampleContainer.set({set:e.container.set.map(t=>D6(t)),itemType:HD(e.container.itemType)});case"optional":return he.V51.ExampleContainer.optional({optional:e.container.optional!=null?D6(e.container.optional):void 0,valueType:HD(e.container.valueType)});case"map":return he.V51.ExampleContainer.map({map:e.container.map.map(t=>({key:D6(t.key),value:D6(t.value)})),keyType:HD(e.container.keyType),valueType:HD(e.container.valueType)});case"literal":return he.V51.ExampleContainer.literal({literal:rxm(e.container.literal)})}}function D6(e){return{...e,shape:MUl(e.shape)}}function ixm(e){switch(e.type){case"object":return he.V51.ExampleTypeShape.object({properties:e.properties.map(t=>nxm(t))});case"alias":return he.V51.ExampleTypeShape.alias({value:{...D6(e.value)}});case"enum":return he.V51.ExampleTypeShape.enum(e);case"union":return he.V51.ExampleTypeShape.union(cTF(e));case"undiscriminatedUnion":return he.V51.ExampleTypeShape.undiscriminatedUnion(sTF(e))}}function sTF(e){return{...e,singleUnionType:D6(e.singleUnionType)}}function cTF(e){return{...e,singleUnionType:lTF(e.singleUnionType)}}function lTF(e){return{...e,shape:fTF(e.shape)}}function fTF(e){switch(e.type){case"samePropertiesAsObject":return he.V51.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...e,object:dTF(e.object)});case"singleProperty":return he.V51.ExampleSingleUnionTypeProperties.singleProperty({...e,shape:MUl(e.shape)});case"noProperties":return he.V51.ExampleSingleUnionTypeProperties.noProperties()}}function dTF(e){return{...e,properties:e.properties.map(t=>nxm(t))}}function nxm(e){return{...e,value:{...e.value,shape:MUl(e.value.shape)}}}function JBm(e){return{...e,rootPathParameters:e.rootPathParameters.map(t=>yzu(t)),servicePathParameters:e.servicePathParameters.map(t=>yzu(t)),endpointPathParameters:e.endpointPathParameters.map(t=>yzu(t)),serviceHeaders:e.serviceHeaders.map(t=>DUl(t)),endpointHeaders:e.endpointHeaders.map(t=>DUl(t)),queryParameters:e.queryParameters.map(t=>exm(t)),request:e.request!=null?hTF(e.request):void 0,response:pTF(e.response)}}function pTF(e){switch(e.type){case"error":return he.V51.ExampleResponse.error({...e,body:e.body!=null?D6(e.body):void 0});case"ok":return he.V51.ExampleResponse.ok(_TF(e))}}function _TF(e){switch(e.value.type){case"body":return he.V51.ExampleEndpointSuccessResponse.body(e.value.value!=null?D6(e.value.value):void 0);case"stream":return he.V51.ExampleEndpointSuccessResponse.stream(e.value.value.map(t=>D6(t)));case"sse":return he.V51.ExampleEndpointSuccessResponse.sse(e.value.value.map(t=>({...t,data:D6(t.data)})))}}function hTF(e){switch(e.type){case"inlinedRequestBody":return he.V51.ExampleRequestBody.inlinedRequestBody(txm(e));case"reference":return he.V51.ExampleRequestBody.reference(D6(e))}}var uxm={laterVersion:"v53",earlierVersion:"v52",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.38.0-rc0",[K.TYPESCRIPT_BROWSER_SDK]:"0.38.0-rc0",[K.TYPESCRIPT]:"0.38.0-rc0",[K.TYPESCRIPT_SDK]:"0.38.0-rc0",[K.TYPESCRIPT_EXPRESS]:"0.17.3",[K.JAVA]:Ge,[K.JAVA_MODEL]:"1.3.0",[K.JAVA_SDK]:"2.5.0",[K.JAVA_SPRING]:"1.3.0",[K.PYTHON_FASTAPI]:"1.1.0-rc0",[K.PYTHON_PYDANTIC]:"1.1.0-rc0",[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:"0.1.0",[K.STOPLIGHT]:Ge,[K.POSTMAN]:"0.2.0",[K.PYTHON_SDK]:"3.3.0-rc0",[K.GO_FIBER]:"0.23.5",[K.GO_MODEL]:"0.23.5",[K.GO_SDK]:"0.28.3",[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:"0.5.0",[K.SWIFT_MODEL]:Ge,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:"0.1.0"},jsonifyEarlierVersion:e=>eh.V52.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,apiVersion:e.apiVersion!=null?vTF(e.apiVersion):void 0,auth:STF(e.auth),headers:e.headers.map(t=>UWi(t)),idempotencyHeaders:e.idempotencyHeaders.map(t=>UWi(t)),types:yTF(e.types),services:cd(e.services,t=>zTF(t)),webhookGroups:cd(e.webhookGroups,t=>mTF(t)),websocketChannels:cd(e.websocketChannels,t=>bTF(t)),errors:cd(e.errors,t=>ZTF(t)),pathParameters:e.pathParameters.map(t=>CMa(t)),variables:e.variables.map(t=>RTF(t))})};function yTF(e){return cd(e,t=>({...t,autogeneratedExamples:t.autogeneratedExamples.map(r=>axm(r)),userProvidedExamples:t.userProvidedExamples.map(r=>axm(r)),shape:he.V53.types.Type._visit(t.shape,{union:r=>he.V52.types.Type.union({...r,baseProperties:r.baseProperties.map(i=>({...i,valueType:$D(i.valueType)})),types:r.types.map(i=>CTF(i))}),enum:he.V52.types.Type.enum,object:r=>he.V52.types.Type.object({...r,properties:r.properties.map(i=>({...i,valueType:$D(i.valueType)}))}),alias:r=>he.V52.types.Type.alias({aliasOf:$D(r.aliasOf),resolvedType:xTF(r.resolvedType)}),undiscriminatedUnion:r=>he.V52.types.Type.undiscriminatedUnion(ITF(r)),_other:()=>{throw new Error("Encountered unknown shape")}})}))}function vTF(e){return he.V52.ApiVersionScheme.header({...e,header:UWi(e.header)})}function bTF(e){return{...e,headers:e.headers.map(t=>UWi(t)),queryParameters:e.queryParameters.map(t=>CUl(t)),pathParameters:e.pathParameters.map(t=>CMa(t)),messages:e.messages.map(t=>gTF(t)),examples:e.examples.map(t=>kTF(t))}}function gTF(e){return{...e,body:OTF(e.body)}}function OTF(e){switch(e.type){case"inlinedBody":return he.V52.websocket.WebSocketMessageBody.inlinedBody({...e,properties:e.properties.map(t=>({...t,valueType:$D(t.valueType)}))});case"reference":return he.V52.websocket.WebSocketMessageBody.reference({...e,bodyType:$D(e.bodyType)})}}function mTF(e){return e.map(t=>PTF(t))}function PTF(e){return{...e,headers:e.headers.map(t=>UWi(t)),payload:jTF(e.payload),examples:e.examples!=null?e.examples.map(t=>wTF(t)):void 0}}function jTF(e){switch(e.type){case"reference":return he.V52.webhooks.WebhookPayload.reference({...e,payloadType:$D(e.payloadType)});case"inlinedPayload":return he.V52.webhooks.WebhookPayload.inlinedPayload({...e,properties:e.properties.map(t=>({...t,valueType:$D(t.valueType)}))})}}function wTF(e){return{...e,payload:E6(e.payload)}}function STF(e){return{...e,schemes:e.schemes.map(t=>{switch(t.type){case"basic":return he.V52.auth.AuthScheme.basic(t);case"bearer":return he.V52.auth.AuthScheme.bearer(t);case"header":return he.V52.auth.AuthScheme.header(DTF(t));case"oauth":return he.V52.auth.AuthScheme.oauth(ETF(t))}})}}function DTF(e){return{...e,valueType:$D(e.valueType)}}function ETF(e){return{...e,configuration:he.V52.auth.OAuthConfiguration.clientCredentials({...e.configuration,tokenEndpoint:ATF(e.configuration.tokenEndpoint),refreshEndpoint:e.configuration.refreshEndpoint!=null?MTF(e.configuration.refreshEndpoint):void 0})}}function ATF(e){return{...e,requestProperties:{clientId:C_i(e.requestProperties.clientId),clientSecret:C_i(e.requestProperties.clientSecret),scopes:e.requestProperties.scopes!=null?C_i(e.requestProperties.scopes):void 0},responseProperties:{accessToken:a$r(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?a$r(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?a$r(e.responseProperties.refreshToken):void 0}}}function MTF(e){return{...e,requestProperties:{refreshToken:C_i(e.requestProperties.refreshToken)},responseProperties:{accessToken:a$r(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?a$r(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?a$r(e.responseProperties.refreshToken):void 0}}}function UWi(e){return{...e,valueType:$D(e.valueType)}}function $D(e){return he.V53.types.TypeReference._visit(e,{container:t=>he.V52.types.TypeReference.container(cxm(t)),primitive:t=>he.V52.types.TypeReference.primitive(sxm(t)),named:he.V52.types.TypeReference.named,unknown:he.V52.types.TypeReference.unknown,_other:()=>{throw new Error("Unknown type reference: "+e.type)}})}function sxm(e){return{v1:qTF(e.v1),v2:e.v2!=null?TTF(e.v2):void 0}}function qTF(e){switch(e){case"FLOAT":return he.V52.types.PrimitiveTypeV1.Double}return e}function TTF(e){switch(e.type){case"integer":return he.V52.types.PrimitiveTypeV2.integer(e);case"double":return he.V52.types.PrimitiveTypeV2.double(e);case"string":return he.V52.types.PrimitiveTypeV2.string(e);case"boolean":return he.V52.types.PrimitiveTypeV2.boolean(e);case"long":return he.V52.types.PrimitiveTypeV2.long(e);case"bigInteger":return he.V52.types.PrimitiveTypeV2.bigInteger(e);case"uint":return he.V52.types.PrimitiveTypeV2.uint();case"uint64":return he.V52.types.PrimitiveTypeV2.uint64();case"date":return;case"dateTime":return;case"uuid":return;case"base64":return;case"float":return;default:Zo(e)}}function cxm(e){return he.V53.types.ContainerType._visit(e,{list:t=>he.V52.types.ContainerType.list($D(t)),optional:t=>he.V52.types.ContainerType.optional($D(t)),set:t=>he.V52.types.ContainerType.set($D(t)),map:({keyType:t,valueType:r})=>he.V52.types.ContainerType.map({keyType:$D(t),valueType:$D(r)}),literal:he.V52.types.ContainerType.literal,_other:()=>{throw new Error("Unknown ContainerType: "+e.type)}})}function CTF(e){return{...e,shape:BTF(e.shape)}}function BTF(e){return he.V53.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>he.V52.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>he.V52.types.SingleUnionTypeProperties.singleProperty({...t,type:$D(t.type)}),noProperties:he.V52.types.SingleUnionTypeProperties.noProperties,_other:()=>{throw new Error(`Unknown SingleUnionTypeProperties: ${JSON.stringify(e)}`)}})}function xTF(e){return he.V53.types.ResolvedTypeReference._visit(e,{container:t=>he.V52.types.ResolvedTypeReference.container(cxm(t)),named:he.V52.types.ResolvedTypeReference.named,primitive:t=>he.V52.types.ResolvedTypeReference.primitive(sxm(t)),unknown:he.V52.types.ResolvedTypeReference.unknown,_other:()=>{throw new Error("Unknown ResolvedTypeReference: "+e.type)}})}function ITF(e){return{members:e.members.map(t=>({...t,type:$D(t.type)}))}}function zTF(e){return{...e,pathParameters:e.pathParameters.map(t=>CMa(t)),headers:e.headers.map(t=>UWi(t)),endpoints:e.endpoints.map(t=>FTF(t))}}function CMa(e){return{...e,valueType:$D(e.valueType)}}function RTF(e){return{...e,type:$D(e.type)}}function FTF(e){return{...e,pagination:e.pagination!=null?WTF(e.pagination):void 0,allPathParameters:e.allPathParameters.map(t=>CMa(t)),pathParameters:e.pathParameters.map(t=>CMa(t)),sdkRequest:e.sdkRequest!=null?QTF(e.sdkRequest):void 0,requestBody:e.requestBody!=null?YTF(e.requestBody):void 0,response:e.response!=null?NTF(e.response):void 0,headers:e.headers.map(t=>UWi(t)),queryParameters:e.queryParameters.map(t=>CUl(t)),autogeneratedExamples:e.autogeneratedExamples.map(t=>({...t,example:oxm(t.example)})),userSpecifiedExamples:e.userSpecifiedExamples.map(t=>({...t,example:t.example!=null?oxm(t.example):void 0}))}}function NTF(e){return{...e,body:e.body!=null?LTF(e.body):void 0}}function LTF(e){switch(e.type){case"json":return he.V52.http.HttpResponseBody.json(lxm(e.value));case"fileDownload":return he.V52.http.HttpResponseBody.fileDownload(e);case"text":return he.V52.http.HttpResponseBody.text(e);case"streaming":return he.V52.http.HttpResponseBody.streaming(fxm(e.value));case"streamParameter":return he.V52.http.HttpResponseBody.streamParameter(VTF(e))}}function lxm(e){switch(e.type){case"response":return he.V52.http.JsonResponse.response({...e,responseBodyType:$D(e.responseBodyType)});case"nestedPropertyAsResponse":return he.V52.http.JsonResponse.nestedPropertyAsResponse({...e,responseBodyType:$D(e.responseBodyType),responseProperty:e.responseProperty!=null?TUl(e.responseProperty):void 0})}}function fxm(e){switch(e.type){case"json":return he.V52.http.StreamingResponse.json({...e,payload:$D(e.payload)});case"text":return he.V52.http.StreamingResponse.text(e);case"sse":return he.V52.http.StreamingResponse.sse({...e,payload:$D(e.payload)})}}function UTF(e){switch(e.type){case"json":return he.V52.http.NonStreamHttpResponseBody.json(lxm(e.value));case"text":return he.V52.http.NonStreamHttpResponseBody.text(e);case"fileDownload":return he.V52.http.NonStreamHttpResponseBody.fileDownload(e)}}function VTF(e){return{nonStreamResponse:UTF(e.nonStreamResponse),streamResponse:fxm(e.streamResponse)}}function WTF(e){switch(e.type){case"cursor":return he.V52.http.Pagination.cursor(HTF(e));case"offset":return he.V52.http.Pagination.offset($TF(e))}}function HTF(e){return{...e,page:C_i(e.page),next:a$r(e.next),results:a$r(e.results)}}function $TF(e){return{...e,page:C_i(e.page),results:a$r(e.results),step:e.step!=null?C_i(e.step):void 0}}function C_i(e){return{...e,property:GTF(e.property)}}function GTF(e){switch(e.type){case"query":return he.V52.RequestPropertyValue.query(CUl(e));case"body":return he.V52.RequestPropertyValue.body(TUl(e))}}function a$r(e){return{...e,property:TUl(e.property)}}function TUl(e){return{...e,valueType:$D(e.valueType)}}function CUl(e){return{...e,valueType:$D(e.valueType)}}function QTF(e){return{...e,streamParameter:e.streamParameter!=null?C_i(e.streamParameter):void 0,shape:JTF(e.shape)}}function JTF(e){return he.V53.http.SdkRequestShape._visit(e,{justRequestBody:t=>he.V52.http.SdkRequestShape.justRequestBody(KTF(t)),wrapper:he.V52.http.SdkRequestShape.wrapper,_other:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function KTF(e){switch(e.type){case"bytes":return he.V52.http.SdkRequestBodyType.bytes(e);case"typeReference":return he.V52.http.SdkRequestBodyType.typeReference({...e,requestBodyType:$D(e.requestBodyType)})}}function YTF(e){return he.V53.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>he.V52.http.HttpRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,valueType:$D(r.valueType)}))}),reference:t=>he.V52.http.HttpRequestBody.reference({...t,requestBodyType:$D(t.requestBodyType)}),fileUpload:t=>he.V52.http.HttpRequestBody.fileUpload({...t,properties:t.properties.map(r=>{switch(r.type){case"bodyProperty":return he.V52.http.FileUploadRequestProperty.bodyProperty({...r,valueType:$D(r.valueType)});case"file":return he.V52.http.FileUploadRequestProperty.file(XTF(r.value))}})}),bytes:t=>he.V52.http.HttpRequestBody.bytes(t),_other:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function XTF(e){switch(e.type){case"file":return he.V52.http.FileProperty.file(e);case"fileArray":return he.V52.http.FileProperty.fileArray(e)}}function ZTF(e){return{...e,type:e.type!=null?$D(e.type):void 0,examples:e.examples.map(t=>({...t,shape:E6(t.shape)}))}}function kTF(e){return{...e,pathParameters:e.pathParameters.map(t=>vzu(t)),headers:e.headers.map(t=>qUl(t)),queryParameters:e.queryParameters.map(t=>dxm(t)),messages:e.messages.map(t=>({...t,body:eCF(t.body)}))}}function dxm(e){return{...e,value:E6(e.value)}}function qUl(e){return{...e,value:E6(e.value)}}function vzu(e){return{...e,value:E6(e.value)}}function eCF(e){switch(e.type){case"inlinedBody":return he.V52.ExampleWebSocketMessageBody.inlinedBody(pxm(e));case"reference":return he.V52.ExampleWebSocketMessageBody.reference(E6(e))}}function pxm(e){return{...e,properties:e.properties.map(t=>({...t,value:E6(t.value)}))}}function axm(e){return{...e,shape:hxm(e.shape)}}function BUl(e){switch(e.type){case"primitive":return he.V52.ExampleTypeReferenceShape.primitive(tCF(e));case"container":return he.V52.ExampleTypeReferenceShape.container(rCF(e));case"unknown":return he.V52.ExampleTypeReferenceShape.unknown(e.unknown);case"named":return he.V52.ExampleTypeReferenceShape.named({...e,typeName:e.typeName,shape:hxm(e.shape)})}}function _xm(e){switch(e.type){case"integer":return he.V52.ExamplePrimitive.integer(e.integer);case"uint":return he.V52.ExamplePrimitive.integer(e.uint);case"uint64":return he.V52.ExamplePrimitive.integer(e.uint64);case"float":return he.V52.ExamplePrimitive.double(e.float);case"double":return he.V52.ExamplePrimitive.double(e.double);case"long":return he.V52.ExamplePrimitive.long(e.long);case"boolean":return he.V52.ExamplePrimitive.boolean(e.boolean);case"string":return he.V52.ExamplePrimitive.string(e.string);case"date":return he.V52.ExamplePrimitive.date(e.date);case"datetime":return he.V52.ExamplePrimitive.datetime(e.datetime);case"uuid":return he.V52.ExamplePrimitive.uuid(e.uuid);case"base64":return he.V52.ExamplePrimitive.string({original:e.base64});case"bigInteger":return he.V52.ExamplePrimitive.string({original:e.bigInteger})}}function tCF(e){return _xm(e.primitive)}function rCF(e){switch(e.container.type){case"list":return he.V52.ExampleContainer.list({list:e.container.list.map(t=>E6(t)),itemType:$D(e.container.itemType)});case"set":return he.V52.ExampleContainer.set({set:e.container.set.map(t=>E6(t)),itemType:$D(e.container.itemType)});case"optional":return he.V52.ExampleContainer.optional({optional:e.container.optional!=null?E6(e.container.optional):void 0,valueType:$D(e.container.valueType)});case"map":return he.V52.ExampleContainer.map({map:e.container.map.map(t=>({key:E6(t.key),value:E6(t.value)})),keyType:$D(e.container.keyType),valueType:$D(e.container.valueType)});case"literal":return he.V52.ExampleContainer.literal({literal:_xm(e.container.literal)})}}function E6(e){return{...e,shape:BUl(e.shape)}}function hxm(e){switch(e.type){case"object":return he.V52.ExampleTypeShape.object({properties:e.properties.map(t=>yxm(t))});case"alias":return he.V52.ExampleTypeShape.alias({value:{...E6(e.value)}});case"enum":return he.V52.ExampleTypeShape.enum(e);case"union":return he.V52.ExampleTypeShape.union(nCF(e));case"undiscriminatedUnion":return he.V52.ExampleTypeShape.undiscriminatedUnion(iCF(e))}}function iCF(e){return{...e,singleUnionType:E6(e.singleUnionType)}}function nCF(e){return{...e,singleUnionType:aCF(e.singleUnionType)}}function aCF(e){return{...e,shape:oCF(e.shape)}}function oCF(e){switch(e.type){case"samePropertiesAsObject":return he.V52.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...e,object:uCF(e.object)});case"singleProperty":return he.V52.ExampleSingleUnionTypeProperties.singleProperty({...e,shape:BUl(e.shape)});case"noProperties":return he.V52.ExampleSingleUnionTypeProperties.noProperties()}}function uCF(e){return{...e,properties:e.properties.map(t=>yxm(t))}}function yxm(e){return{...e,value:{...e.value,shape:BUl(e.value.shape)}}}function oxm(e){return{...e,rootPathParameters:e.rootPathParameters.map(t=>vzu(t)),servicePathParameters:e.servicePathParameters.map(t=>vzu(t)),endpointPathParameters:e.endpointPathParameters.map(t=>vzu(t)),serviceHeaders:e.serviceHeaders.map(t=>qUl(t)),endpointHeaders:e.endpointHeaders.map(t=>qUl(t)),queryParameters:e.queryParameters.map(t=>dxm(t)),request:e.request!=null?lCF(e.request):void 0,response:sCF(e.response)}}function sCF(e){switch(e.type){case"error":return he.V52.ExampleResponse.error({...e,body:e.body!=null?E6(e.body):void 0});case"ok":return he.V52.ExampleResponse.ok(cCF(e))}}function cCF(e){switch(e.value.type){case"body":return he.V52.ExampleEndpointSuccessResponse.body(e.value.value!=null?E6(e.value.value):void 0);case"stream":return he.V52.ExampleEndpointSuccessResponse.stream(e.value.value.map(t=>E6(t)));case"sse":return he.V52.ExampleEndpointSuccessResponse.sse(e.value.value.map(t=>({...t,data:E6(t.data)})))}}function lCF(e){switch(e.type){case"inlinedRequestBody":return he.V52.ExampleRequestBody.inlinedRequestBody(pxm(e));case"reference":return he.V52.ExampleRequestBody.reference(E6(e))}}var vxm={laterVersion:"v54",earlierVersion:"v53",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:Ge,[K.TYPESCRIPT_BROWSER_SDK]:Ge,[K.TYPESCRIPT]:Ge,[K.TYPESCRIPT_SDK]:Ge,[K.TYPESCRIPT_EXPRESS]:Ge,[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:Ge,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:Ge},jsonifyEarlierVersion:e=>eh.V53.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,services:cd(e.services,t=>({...t,endpoints:t.endpoints.map(r=>({...r,response:fCF(r.response)}))}))})};function fCF(e){if(e!=null)return{statusCode:e.statusCode,body:e.body?.type==="bytes"?he.V53.HttpResponseBody.fileDownload({docs:void 0}):e.body}}var Oxm={laterVersion:"v55",earlierVersion:"v54",firstGeneratorVersionToConsumeNewIR:{[K.TYPESCRIPT_NODE_SDK]:"0.47.0",[K.TYPESCRIPT_BROWSER_SDK]:"0.47.0",[K.TYPESCRIPT]:"0.47.0",[K.TYPESCRIPT_SDK]:"0.47.0",[K.TYPESCRIPT_EXPRESS]:"0.17.7",[K.JAVA]:Ge,[K.JAVA_MODEL]:Ge,[K.JAVA_SDK]:Ge,[K.JAVA_SPRING]:Ge,[K.PYTHON_FASTAPI]:Ge,[K.PYTHON_PYDANTIC]:Ge,[K.OPENAPI_PYTHON_CLIENT]:Ge,[K.OPENAPI]:Ge,[K.STOPLIGHT]:Ge,[K.POSTMAN]:Ge,[K.PYTHON_SDK]:Ge,[K.GO_FIBER]:Ge,[K.GO_MODEL]:Ge,[K.GO_SDK]:Ge,[K.RUBY_MODEL]:Ge,[K.RUBY_SDK]:Ge,[K.CSHARP_MODEL]:Ge,[K.CSHARP_SDK]:Ge,[K.SWIFT_MODEL]:Ge,[K.SWIFT_SDK]:ni,[K.PHP_MODEL]:ni,[K.PHP_SDK]:Ge},jsonifyEarlierVersion:e=>eh.V54.IntermediateRepresentation.jsonOrThrow(e,{unrecognizedObjectKeys:"strip",skipValidation:!0}),migrateBackwards:e=>({...e,apiVersion:e.apiVersion!=null?pCF(e.apiVersion):void 0,auth:mCF(e.auth),headers:e.headers.map(t=>VWi(t)),idempotencyHeaders:e.idempotencyHeaders.map(t=>VWi(t)),types:dCF(e.types),services:cd(e.services,t=>qCF(t)),webhookGroups:cd(e.webhookGroups,t=>vCF(t)),websocketChannels:cd(e.websocketChannels,t=>_CF(t)),errors:cd(e.errors,t=>GCF(t)),pathParameters:e.pathParameters.map(t=>BMa(t)),variables:e.variables.map(t=>TCF(t)),dynamic:e.dynamic!=null?aBF(e.dynamic):void 0})};function dCF(e){return cd(e,t=>({...t,autogeneratedExamples:t.autogeneratedExamples.map(r=>bxm(r)),userProvidedExamples:t.userProvidedExamples.map(r=>bxm(r)),shape:he.V55.types.Type._visit(t.shape,{union:r=>he.V54.types.Type.union({...r,baseProperties:r.baseProperties.map(i=>({...i,valueType:rP(i.valueType)})),types:r.types.map(i=>DCF(i))}),enum:he.V54.types.Type.enum,object:r=>he.V54.types.Type.object({...r,properties:r.properties.map(i=>({...i,valueType:rP(i.valueType)})),extendedProperties:r.extendedProperties?.map(i=>({...i,valueType:rP(i.valueType)}))}),alias:r=>he.V54.types.Type.alias({aliasOf:rP(r.aliasOf),resolvedType:ACF(r.resolvedType)}),undiscriminatedUnion:r=>he.V54.types.Type.undiscriminatedUnion(MCF(r)),_other:()=>{throw new Error("Encountered unknown shape")}})}))}function pCF(e){return he.V54.ApiVersionScheme.header({...e,header:VWi(e.header)})}function _CF(e){return{...e,headers:e.headers.map(t=>VWi(t)),queryParameters:e.queryParameters.map(t=>zUl(t)),pathParameters:e.pathParameters.map(t=>BMa(t)),messages:e.messages.map(t=>hCF(t)),examples:e.examples.map(t=>QCF(t))}}function hCF(e){return{...e,body:yCF(e.body)}}function yCF(e){switch(e.type){case"inlinedBody":return he.V54.websocket.WebSocketMessageBody.inlinedBody({...e,properties:e.properties.map(t=>({...t,valueType:rP(t.valueType)}))});case"reference":return he.V54.websocket.WebSocketMessageBody.reference({...e,bodyType:rP(e.bodyType)})}}function vCF(e){return e.map(t=>bCF(t))}function bCF(e){return{...e,headers:e.headers.map(t=>VWi(t)),payload:gCF(e.payload),examples:e.examples!=null?e.examples.map(t=>OCF(t)):void 0}}function gCF(e){switch(e.type){case"reference":return he.V54.webhooks.WebhookPayload.reference({...e,payloadType:rP(e.payloadType)});case"inlinedPayload":return he.V54.webhooks.WebhookPayload.inlinedPayload({...e,properties:e.properties.map(t=>({...t,valueType:rP(t.valueType)}))})}}function OCF(e){return{...e,payload:b7(e.payload)}}function mCF(e){return{...e,schemes:e.schemes.map(t=>{switch(t.type){case"basic":return he.V54.auth.AuthScheme.basic(t);case"bearer":return he.V54.auth.AuthScheme.bearer(t);case"header":return he.V54.auth.AuthScheme.header(PCF(t));case"oauth":return he.V54.auth.AuthScheme.oauth(jCF(t))}})}}function PCF(e){return{...e,valueType:rP(e.valueType)}}function jCF(e){return{...e,configuration:he.V54.auth.OAuthConfiguration.clientCredentials({...e.configuration,tokenEndpoint:wCF(e.configuration.tokenEndpoint),refreshEndpoint:e.configuration.refreshEndpoint!=null?SCF(e.configuration.refreshEndpoint):void 0})}}function wCF(e){return{...e,requestProperties:{clientId:B_i(e.requestProperties.clientId),clientSecret:B_i(e.requestProperties.clientSecret),scopes:e.requestProperties.scopes!=null?B_i(e.requestProperties.scopes):void 0},responseProperties:{accessToken:PNr(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?PNr(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?PNr(e.responseProperties.refreshToken):void 0}}}function SCF(e){return{...e,requestProperties:{refreshToken:B_i(e.requestProperties.refreshToken)},responseProperties:{accessToken:PNr(e.responseProperties.accessToken),expiresIn:e.responseProperties.expiresIn!=null?PNr(e.responseProperties.expiresIn):void 0,refreshToken:e.responseProperties.refreshToken!=null?PNr(e.responseProperties.refreshToken):void 0}}}function VWi(e){return{...e,valueType:rP(e.valueType)}}function rP(e){return e.type==="container"&&e.container.type==="nullable"?bBF(e.container.nullable):e.type==="container"&&e.container.type==="optional"?vBF(e.container.optional):he.V55.types.TypeReference._visit(e,{container:t=>he.V54.types.TypeReference.container(Pxm(t)),primitive:t=>he.V54.types.TypeReference.primitive(mxm(t)),named:he.V54.types.TypeReference.named,unknown:he.V54.types.TypeReference.unknown,_other:()=>{throw new Error("Unknown type reference: "+e.type)}})}function mxm(e){return{v1:e.v1,v2:e.v2!=null?e.v2:void 0}}function Pxm(e){return he.V55.types.ContainerType._visit(e,{list:t=>he.V54.types.ContainerType.list(rP(t)),optional:t=>he.V54.types.ContainerType.optional(rP(t)),nullable:t=>he.V54.types.ContainerType.optional(rP(t)),set:t=>he.V54.types.ContainerType.set(rP(t)),map:({keyType:t,valueType:r})=>he.V54.types.ContainerType.map({keyType:rP(t),valueType:rP(r)}),literal:he.V54.types.ContainerType.literal,_other:()=>{throw new Error("Unknown ContainerType: "+e.type)}})}function DCF(e){return{...e,shape:ECF(e.shape)}}function ECF(e){return he.V55.types.SingleUnionTypeProperties._visit(e,{samePropertiesAsObject:t=>he.V54.types.SingleUnionTypeProperties.samePropertiesAsObject(t),singleProperty:t=>he.V54.types.SingleUnionTypeProperties.singleProperty({...t,type:rP(t.type)}),noProperties:he.V54.types.SingleUnionTypeProperties.noProperties,_other:()=>{throw new Error(`Unknown SingleUnionTypeProperties: ${JSON.stringify(e)}`)}})}function ACF(e){return he.V55.types.ResolvedTypeReference._visit(e,{container:t=>he.V54.types.ResolvedTypeReference.container(Pxm(t)),named:he.V54.types.ResolvedTypeReference.named,primitive:t=>he.V54.types.ResolvedTypeReference.primitive(mxm(t)),unknown:he.V54.types.ResolvedTypeReference.unknown,_other:()=>{throw new Error("Unknown ResolvedTypeReference: "+e.type)}})}function MCF(e){return{members:e.members.map(t=>({...t,type:rP(t.type)}))}}function qCF(e){return{...e,pathParameters:e.pathParameters.map(t=>BMa(t)),headers:e.headers.map(t=>VWi(t)),endpoints:e.endpoints.map(t=>CCF(t))}}function BMa(e){return{...e,valueType:rP(e.valueType)}}function TCF(e){return{...e,type:rP(e.type)}}function CCF(e){return{...e,pagination:e.pagination!=null?RCF(e.pagination):void 0,allPathParameters:e.allPathParameters.map(t=>BMa(t)),pathParameters:e.pathParameters.map(t=>BMa(t)),sdkRequest:e.sdkRequest!=null?UCF(e.sdkRequest):void 0,requestBody:e.requestBody!=null?HCF(e.requestBody):void 0,response:e.response!=null?BCF(e.response):void 0,headers:e.headers.map(t=>VWi(t)),queryParameters:e.queryParameters.map(t=>zUl(t)),autogeneratedExamples:e.autogeneratedExamples.map(t=>({...t,example:gxm(t.example)})),userSpecifiedExamples:e.userSpecifiedExamples.map(t=>({...t,example:t.example!=null?gxm(t.example):void 0}))}}function BCF(e){return{...e,body:e.body!=null?xCF(e.body):void 0}}function xCF(e){switch(e.type){case"json":return he.V54.http.HttpResponseBody.json(jxm(e.value));case"fileDownload":return he.V54.http.HttpResponseBody.fileDownload(e);case"bytes":return he.V54.http.HttpResponseBody.bytes(e);case"text":return he.V54.http.HttpResponseBody.text(e);case"streaming":return he.V54.http.HttpResponseBody.streaming(wxm(e.value));case"streamParameter":return he.V54.http.HttpResponseBody.streamParameter(zCF(e));default:Zo(e)}}function jxm(e){switch(e.type){case"response":return he.V54.http.JsonResponse.response({...e,responseBodyType:rP(e.responseBodyType)});case"nestedPropertyAsResponse":return he.V54.http.JsonResponse.nestedPropertyAsResponse({...e,responseBodyType:rP(e.responseBodyType),responseProperty:e.responseProperty!=null?IUl(e.responseProperty):void 0})}}function wxm(e){switch(e.type){case"json":return he.V54.http.StreamingResponse.json({...e,payload:rP(e.payload)});case"text":return he.V54.http.StreamingResponse.text(e);case"sse":return he.V54.http.StreamingResponse.sse({...e,payload:rP(e.payload)})}}function ICF(e){switch(e.type){case"json":return he.V54.http.NonStreamHttpResponseBody.json(jxm(e.value));case"bytes":return he.V54.http.NonStreamHttpResponseBody.bytes(e);case"text":return he.V54.http.NonStreamHttpResponseBody.text(e);case"fileDownload":return he.V54.http.NonStreamHttpResponseBody.fileDownload(e);default:Zo(e)}}function zCF(e){return{nonStreamResponse:ICF(e.nonStreamResponse),streamResponse:wxm(e.streamResponse)}}function RCF(e){switch(e.type){case"cursor":return he.V54.http.Pagination.cursor(FCF(e));case"offset":return he.V54.http.Pagination.offset(NCF(e))}}function FCF(e){return{...e,page:B_i(e.page),next:PNr(e.next),results:PNr(e.results)}}function NCF(e){return{...e,page:B_i(e.page),results:PNr(e.results),step:e.step!=null?B_i(e.step):void 0,hasNextPage:e.hasNextPage!=null?PNr(e.hasNextPage):void 0}}function B_i(e){return{...e,property:LCF(e.property)}}function LCF(e){switch(e.type){case"query":return he.V54.RequestPropertyValue.query(zUl(e));case"body":return he.V54.RequestPropertyValue.body(IUl(e))}}function PNr(e){return{...e,property:IUl(e.property)}}function IUl(e){return{...e,valueType:rP(e.valueType)}}function zUl(e){return{...e,valueType:rP(e.valueType)}}function UCF(e){return{...e,streamParameter:e.streamParameter!=null?B_i(e.streamParameter):void 0,shape:VCF(e.shape)}}function VCF(e){return he.V55.http.SdkRequestShape._visit(e,{justRequestBody:t=>he.V54.http.SdkRequestShape.justRequestBody(WCF(t)),wrapper:he.V54.http.SdkRequestShape.wrapper,_other:()=>{throw new Error("Unknown SdkRequestShape: "+e.type)}})}function WCF(e){switch(e.type){case"bytes":return he.V54.http.SdkRequestBodyType.bytes(e);case"typeReference":return he.V54.http.SdkRequestBodyType.typeReference({...e,requestBodyType:rP(e.requestBodyType)})}}function HCF(e){return he.V55.http.HttpRequestBody._visit(e,{inlinedRequestBody:t=>he.V54.http.HttpRequestBody.inlinedRequestBody({...t,properties:t.properties.map(r=>({...r,valueType:rP(r.valueType)})),extendedProperties:t.extendedProperties?.map(r=>({...r,valueType:rP(r.valueType)}))}),reference:t=>he.V54.http.HttpRequestBody.reference({...t,requestBodyType:rP(t.requestBodyType)}),fileUpload:t=>he.V54.http.HttpRequestBody.fileUpload({...t,properties:t.properties.map(r=>{switch(r.type){case"bodyProperty":return he.V54.http.FileUploadRequestProperty.bodyProperty({...r,valueType:rP(r.valueType)});case"file":return he.V54.http.FileUploadRequestProperty.file($CF(r.value))}})}),bytes:t=>he.V54.http.HttpRequestBody.bytes(t),_other:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}})}function $CF(e){switch(e.type){case"file":return he.V54.http.FileProperty.file(e);case"fileArray":return he.V54.http.FileProperty.fileArray(e)}}function GCF(e){return{...e,type:e.type!=null?rP(e.type):void 0,examples:e.examples.map(t=>({...t,shape:b7(t.shape)}))}}function QCF(e){return{...e,pathParameters:e.pathParameters.map(t=>bzu(t)),headers:e.headers.map(t=>xUl(t)),queryParameters:e.queryParameters.map(t=>Sxm(t)),messages:e.messages.map(t=>({...t,body:JCF(t.body)}))}}function Sxm(e){return{...e,value:b7(e.value)}}function xUl(e){return{...e,value:b7(e.value)}}function bzu(e){return{...e,value:b7(e.value)}}function JCF(e){switch(e.type){case"inlinedBody":return he.V54.ExampleWebSocketMessageBody.inlinedBody(Dxm(e));case"reference":return he.V54.ExampleWebSocketMessageBody.reference(b7(e))}}function Dxm(e){return{...e,properties:e.properties.map(t=>({...t,value:b7(t.value)}))}}function bxm(e){return{...e,shape:Exm(e.shape)}}function RUl(e){switch(e.type){case"primitive":return he.V54.ExampleTypeReferenceShape.primitive(KCF(e));case"container":return he.V54.ExampleTypeReferenceShape.container(YCF(e));case"unknown":return he.V54.ExampleTypeReferenceShape.unknown(e.unknown);case"named":return he.V54.ExampleTypeReferenceShape.named({...e,typeName:e.typeName,shape:Exm(e.shape)})}}function KCF(e){return e.primitive}function YCF(e){switch(e.container.type){case"list":return he.V54.ExampleContainer.list({list:e.container.list.map(t=>b7(t)),itemType:rP(e.container.itemType)});case"set":return he.V54.ExampleContainer.set({set:e.container.set.map(t=>b7(t)),itemType:rP(e.container.itemType)});case"optional":return he.V54.ExampleContainer.optional({optional:e.container.optional!=null?b7(e.container.optional):void 0,valueType:rP(e.container.valueType)});case"nullable":return he.V54.ExampleContainer.optional({optional:e.container.nullable!=null?b7(e.container.nullable):void 0,valueType:rP(e.container.valueType)});case"map":return he.V54.ExampleContainer.map({map:e.container.map.map(t=>({key:b7(t.key),value:b7(t.value)})),keyType:rP(e.container.keyType),valueType:rP(e.container.valueType)});case"literal":return he.V54.ExampleContainer.literal({literal:e.container.literal})}}function b7(e){return{...e,shape:RUl(e.shape)}}function Exm(e){switch(e.type){case"object":return he.V54.ExampleTypeShape.object({properties:e.properties.map(t=>Axm(t))});case"alias":return he.V54.ExampleTypeShape.alias({value:{...b7(e.value)}});case"enum":return he.V54.ExampleTypeShape.enum(e);case"union":return he.V54.ExampleTypeShape.union(ZCF(e));case"undiscriminatedUnion":return he.V54.ExampleTypeShape.undiscriminatedUnion(XCF(e))}}function XCF(e){return{...e,singleUnionType:b7(e.singleUnionType)}}function ZCF(e){return{...e,singleUnionType:kCF(e.singleUnionType)}}function kCF(e){return{...e,shape:eBF(e.shape)}}function eBF(e){switch(e.type){case"samePropertiesAsObject":return he.V54.ExampleSingleUnionTypeProperties.samePropertiesAsObject({...e,object:tBF(e.object)});case"singleProperty":return he.V54.ExampleSingleUnionTypeProperties.singleProperty({...e,shape:RUl(e.shape)});case"noProperties":return he.V54.ExampleSingleUnionTypeProperties.noProperties()}}function tBF(e){return{...e,properties:e.properties.map(t=>Axm(t))}}function Axm(e){return{...e,value:{...e.value,shape:RUl(e.value.shape)}}}function gxm(e){return{...e,rootPathParameters:e.rootPathParameters.map(t=>bzu(t)),servicePathParameters:e.servicePathParameters.map(t=>bzu(t)),endpointPathParameters:e.endpointPathParameters.map(t=>bzu(t)),serviceHeaders:e.serviceHeaders.map(t=>xUl(t)),endpointHeaders:e.endpointHeaders.map(t=>xUl(t)),queryParameters:e.queryParameters.map(t=>Sxm(t)),request:e.request!=null?nBF(e.request):void 0,response:rBF(e.response)}}function rBF(e){switch(e.type){case"error":return he.V54.ExampleResponse.error({...e,body:e.body!=null?b7(e.body):void 0});case"ok":return he.V54.ExampleResponse.ok(iBF(e))}}function iBF(e){switch(e.value.type){case"body":return he.V54.ExampleEndpointSuccessResponse.body(e.value.value!=null?b7(e.value.value):void 0);case"stream":return he.V54.ExampleEndpointSuccessResponse.stream(e.value.value.map(t=>b7(t)));case"sse":return he.V54.ExampleEndpointSuccessResponse.sse(e.value.value.map(t=>({...t,data:b7(t.data)})))}}function nBF(e){switch(e.type){case"inlinedRequestBody":return he.V54.ExampleRequestBody.inlinedRequestBody(Dxm(e));case"reference":return he.V54.ExampleRequestBody.reference(b7(e))}}function aBF(e){return{...e,types:cd(e.types,t=>oBF(t)),endpoints:cd(e.endpoints,t=>uBF(t)),headers:e.headers?.map(t=>EFt(t))}}function oBF(e){switch(e.type){case"alias":return he.V54.dynamic.NamedType.alias({...e,typeReference:dEe(e.typeReference)});case"enum":return he.V54.dynamic.NamedType.enum(e);case"object":return he.V54.dynamic.NamedType.object({...e,properties:e.properties.map(t=>EFt(t))});case"discriminatedUnion":return he.V54.dynamic.NamedType.discriminatedUnion({...e,types:Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,cBF(r)]))});case"undiscriminatedUnion":return he.V54.dynamic.NamedType.undiscriminatedUnion({...e,types:e.types.map(t=>dEe(t))});default:Zo(e)}}function uBF(e){return{...e,auth:e.auth!=null?sBF(e.auth):void 0,request:lBF(e.request)}}function sBF(e){switch(e.type){case"basic":return he.V54.dynamic.Auth.basic(e);case"bearer":return he.V54.dynamic.Auth.bearer(e);case"header":return he.V54.dynamic.Auth.header({header:EFt(e.header)})}}function dEe(e){switch(e.type){case"list":return he.V54.dynamic.TypeReference.list(dEe(e.value));case"optional":return OBF(e.value);case"nullable":return gBF(e.value);case"map":return he.V54.dynamic.TypeReference.map({...e,key:dEe(e.key),value:dEe(e.value)});case"literal":return he.V54.dynamic.TypeReference.literal(e.value);case"named":return he.V54.dynamic.TypeReference.named(e.value);case"primitive":return he.V54.dynamic.TypeReference.primitive(e.value);case"set":return he.V54.dynamic.TypeReference.set(dEe(e.value));case"unknown":return he.V54.dynamic.TypeReference.unknown();default:Zo(e)}}function cBF(e){switch(e.type){case"samePropertiesAsObject":return he.V54.dynamic.SingleDiscriminatedUnionType.samePropertiesAsObject({...e,properties:e.properties.map(t=>EFt(t))});case"singleProperty":return he.V54.dynamic.SingleDiscriminatedUnionType.singleProperty({...e,typeReference:dEe(e.typeReference),properties:e.properties?.map(t=>EFt(t))});case"noProperties":return he.V54.dynamic.SingleDiscriminatedUnionType.noProperties({...e,properties:e.properties?.map(t=>EFt(t))});default:Zo(e)}}function EFt(e){return{...e,typeReference:dEe(e.typeReference)}}function lBF(e){switch(e.type){case"body":return he.V54.dynamic.Request.body(fBF(e));case"inlined":return he.V54.dynamic.Request.inlined(dBF(e));default:Zo(e)}}function fBF(e){return{pathParameters:e.pathParameters?.map(t=>EFt(t)),body:e.body!=null?Mxm(e.body):void 0}}function dBF(e){return{...e,pathParameters:e.pathParameters?.map(t=>EFt(t)),queryParameters:e.queryParameters?.map(t=>EFt(t)),headers:e.headers?.map(t=>EFt(t)),body:e.body!=null?pBF(e.body):void 0}}function pBF(e){switch(e.type){case"properties":return he.V54.dynamic.InlinedRequestBody.properties(e.value.map(t=>EFt(t)));case"referenced":return he.V54.dynamic.InlinedRequestBody.referenced(_BF(e));case"fileUpload":return he.V54.dynamic.InlinedRequestBody.fileUpload(hBF(e));default:Zo(e)}}function _BF(e){return{...e,bodyType:Mxm(e.bodyType)}}function Mxm(e){switch(e.type){case"bytes":return he.V54.dynamic.ReferencedRequestBodyType.bytes();case"typeReference":return he.V54.dynamic.ReferencedRequestBodyType.typeReference(dEe(e.value));default:Zo(e)}}function hBF(e){return{properties:e.properties.map(t=>yBF(t))}}function yBF(e){switch(e.type){case"file":return he.V54.dynamic.FileUploadRequestBodyProperty.file(e);case"fileArray":return he.V54.dynamic.FileUploadRequestBodyProperty.fileArray(e);case"bodyProperty":return he.V54.dynamic.FileUploadRequestBodyProperty.bodyProperty(EFt(e));default:Zo(e)}}function vBF(e){return e.type==="container"&&e.container.type==="nullable"?he.V54.types.TypeReference.container(he.V54.types.ContainerType.optional(rP(e.container.nullable))):he.V54.types.TypeReference.container(he.V54.types.ContainerType.optional(rP(e)))}function bBF(e){return e.type==="container"&&e.container.type==="optional"?rP(e):he.V54.types.TypeReference.container(he.V54.types.ContainerType.optional(rP(e)))}function gBF(e){return e.type==="optional"?dEe(e):he.V54.dynamic.TypeReference.optional(dEe(e))}function OBF(e){return e.type==="nullable"?he.V54.dynamic.TypeReference.optional(dEe(e.value)):he.V54.dynamic.TypeReference.optional(dEe(e))}function xMa(){return PBF}var gzu=class{migrations;constructor(t){this.migrations=t}withMigration(t){return new FUl([...this.migrations,t])}},FUl=class extends gzu{build(){return new NUl(this.migrations)}},NUl=class{migrations;constructor(t){this.migrations=t}migrateForGenerator({intermediateRepresentation:t,context:r,targetGenerator:i}){return this.migrate({intermediateRepresentation:t,shouldMigrate:n=>this.shouldRunMigration({migration:n,targetGenerator:i}),context:r,targetGenerator:i})}migrateThroughMigration({migration:t,intermediateRepresentation:r,context:i,targetGenerator:n}){return this.migrateThroughVersion({version:t.earlierVersion,intermediateRepresentation:r,context:i,targetGenerator:n})}migrateThroughVersion({version:t,intermediateRepresentation:r,context:i,targetGenerator:n}){let a=!1;if(this.migrations[0]?.laterVersion===t)return{ir:r,jsonify:()=>Promise.resolve().then(()=>Gp.IntermediateRepresentation.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}))};let l=this.migrate({intermediateRepresentation:r,shouldMigrate:f=>{let s=f.earlierVersion===t;return a||=s,s||!a},context:i,targetGenerator:n});return a||i.failAndThrow(`IR ${t} does not exist`),l}migrate({intermediateRepresentation:t,shouldMigrate:r,context:i,targetGenerator:n}){let a=t,u=async()=>await Gp.IntermediateRepresentation.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"});for(let l of this.migrations){if(!r(l))break;i.logger.debug(`Migrating IR from ${l.laterVersion} to ${l.earlierVersion}`),a=l.migrateBackwards(a,{taskContext:i,targetGenerator:n}),u=()=>Promise.resolve().then(()=>l.jsonifyEarlierVersion(a))}return{ir:a,jsonify:u}}shouldRunMigration({migration:t,targetGenerator:r}){let i=t.firstGeneratorVersionToConsumeNewIR[r.name];if(i==null)throw new Error(`Cannot migrate intermediate representation. Unrecognized generator: ${r.name}. If leveraging a custom generator, ensure you are specifying "ir-version" within the generator configuration.`);switch(i){case Ge:return!0;case ni:throw new Error(`Cannot migrate intermediate representation. Generator was created after intermediate representation ${t.laterVersion}.`)}return Tte(i,r.version)}getIRVersionForGenerator({targetGenerator:t}){let r=this.migrations[0]?.laterVersion;for(let i of this.migrations)if(this.shouldRunMigration({migration:i,targetGenerator:t}))r=i.earlierVersion;else break;return r}},mBF={Builder:new gzu([])},PBF=mBF.Builder.withMigration(Oxm).withMigration(vxm).withMigration(uxm).withMigration(KBm).withMigration(VBm).withMigration(zBm).withMigration(IBm).withMigration(BBm).withMigration(CBm).withMigration(MBm).withMigration(DBm).withMigration(SBm).withMigration(jBm).withMigration(PBm).withMigration(mBm).withMigration(OBm).withMigration(gBm).withMigration(bBm).withMigration(vBm).withMigration(yBm).withMigration(hBm).withMigration(_Bm).withMigration(pBm).withMigration(fBm).withMigration(cBm).withMigration(sBm).withMigration(uBm).withMigration(eBm).withMigration(kCm).withMigration(ZCm).withMigration(YCm).withMigration(KCm).withMigration(Qg0).withMigration(Hg0).withMigration(Wg0).withMigration(Lg0).withMigration(Fg0).withMigration(zg0).withMigration(Ig0).withMigration(xg0).withMigration(Tg0).withMigration(Ag0).withMigration(Eg0).withMigration(Dg0).withMigration(wg0).withMigration(jg0).withMigration(Pg0).withMigration(bg0).withMigration(hg0).withMigration(_g0).withMigration(pg0).withMigration(k00).withMigration(Y00).withMigration($Vp).build();function IMa({intermediateRepresentation:e,context:t,targetGenerator:r}){return xMa().migrateForGenerator({intermediateRepresentation:e,context:t,targetGenerator:r}).jsonify()}function LUl({intermediateRepresentation:e,context:t,targetGenerator:r,irVersion:i}){return xMa().migrateThroughVersion({version:i,intermediateRepresentation:e,context:t,targetGenerator:r}).jsonify()}function zMa({intermediateRepresentation:e,context:t,version:r}){return xMa().migrateThroughVersion({version:r,intermediateRepresentation:e,context:t}).jsonify()}async function Txm({project:e,irFilepath:t,cliContext:r,generationLanguage:i,audiences:n,version:a,keywords:u,smartCasing:l,readme:f}){await Promise.all(e.apiWorkspaces.map(async s=>{await r.runTaskForWorkspace(s,async o=>{r.logger.info(`Generating IR for workspace ${s.workspaceName??"api"}`);let c=await s.toFernWorkspace({context:o}),b=await jBF({workspace:c,context:o,generationLanguage:i,keywords:u,smartCasing:l,disableExamples:!1,audiences:n,version:a,readme:f}),g=qxm.default.resolve(t);await c6r(Kl.of(g),b),o.logger.info(`Wrote IR to ${g}`)})}))}async function jBF({workspace:e,context:t,generationLanguage:r,audiences:i,keywords:n,smartCasing:a,disableExamples:u,version:l,readme:f}){let s=await Bhn({workspace:e,context:t,generationLanguage:r,audiences:i,keywords:n,smartCasing:a,disableExamples:u,readme:f});return l==null?Gp.IntermediateRepresentation.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):zMa({intermediateRepresentation:s,version:l,context:t})}var Cxm=require("fs/promises"),Bxm=Di(require("path"),1);async function xxm({project:e,outputFilepath:t,cliContext:r}){await Promise.all(e.apiWorkspaces.map(async i=>{await r.runTaskForWorkspace(i,async n=>{let a=await Era(i,n),u=Bxm.default.resolve(t);await(0,Cxm.writeFile)(u,await d6r(a,{pretty:!0})),n.logger.info(`Wrote FDR API definition to ${u}`)})}))}var Ixm=require("fs/promises"),zxm=Di(require("path"),1);async function Rxm({project:e,irFilepath:t,cliContext:r,sdkLanguage:i}){await Promise.all(e.apiWorkspaces.map(async n=>{await r.runTaskForWorkspace(n,async a=>{if(n instanceof Qti){a.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(n instanceof s8))return;let u=new e6t(n.absoluteFilePath),l=await t6t({context:a,specs:n.specs}),f=FSi({context:a,documents:await u.loadDocuments({context:a,specs:l})}),s=zxm.default.resolve(t),o=await Uy.OpenApiIntermediateRepresentation.jsonOrThrow(f,{skipValidation:!0});await(0,Ixm.writeFile)(s,await d6r(o,{pretty:!0})),a.logger.info(`Wrote IR to ${s}`)})}))}var Ozu=require("fs/promises");async function Nxm({project:e,includeModels:t,cliContext:r}){await Promise.all(e.apiWorkspaces.map(async i=>{await r.runTaskForWorkspace(i,async n=>{i instanceof s8?await SBF({workspace:i,context:n,includeModels:t}):n.logger.warn("Skipping fern workspace definition generation")})}))}async function wBF(e,t){let r=null;try{let i=(await(0,Ozu.readFile)(e,"utf8")).toString();try{r=JSON.parse(i)}catch{r=pp.load(i,{json:!0})}}catch{return t.failAndThrow(`Failed to read OpenAPI overrides from file ${e}`)}return r}async function SBF({workspace:e,includeModels:t,context:r}){let i=new e6t(e.absoluteFilePath),n=await t6t({context:r,specs:e.specs});for(let a of n){let u=FSi({context:r,documents:await i.loadDocuments({context:r,specs:[a]})}),l={};a.absoluteFilepathToOverrides!==void 0&&(l=await wBF(a.absoluteFilepathToOverrides,r));let f="path"in l?l.path:{};for(let c of u.endpoints){let b=gZn(c);c.path in f||(f[c.path]={});let g=f[c.path];if(g!=null&&g[c.method]==null){let O=b.file.split("/").map(w=>w.replace(".yml","")).filter(w=>w!=="__package__"),m={};O.length>0&&(m["x-fern-sdk-group-name"]=O),m["x-fern-sdk-method-name"]=b.endpointId,g[c.method.toLowerCase()]=m}else l==null&&r.logger.warn(`Endpoint ${c.path} ${c.method} is defined multiple times`)}let s="path"in l?l.path:{};if(t){Fxm(s,u.groupedSchemas.rootSchemas);for(let[c,b]of Object.entries(u.groupedSchemas.namespacedSchemas))Fxm(s,b)}let o={schemas:s};await(0,Ozu.writeFile)(ku(Mp(a.absoluteFilepath),yo.of("openapi-overrides.yml")),pp.dump({paths:f,components:o}))}}function Fxm(e,t){for(let[r,i]of Object.entries(t)){if(r in e)continue;let n={};n["x-fern-type-name"]="nameOverride"in i?i.nameOverride??r:r,e[r]=n}}var mzu="api",Lxm="group";var Uxm=".preview",Vxm="approved-output-directories",Wxm=".fern";var Kxm=require("fs/promises");var $xm=require("fs/promises");var Hxm=require("os");function RMa(){return ku(Kl.of((0,Hxm.homedir)()),yo.of(Wxm),yo.of(Vxm))}async function Gxm(){let e=RMa();if(!await zf(e))return[];let r=await(0,$xm.readFile)(e,{encoding:"utf-8"});return JSON.parse(r)}var Pzu=require("fs/promises"),Qxm=Di(require("path"),1);async function Jxm(e){await(0,Pzu.mkdir)(Qxm.default.dirname(RMa()),{recursive:!0}),await(0,Pzu.writeFile)(RMa(),JSON.stringify(e,null,2))}async function Yxm(e,t,r){if(!e||jKu()||r)return{shouldProceed:!0};let i=await Gxm();return i?.includes(e)?{shouldProceed:!0}:await zf(e)?(await(0,Kxm.readdir)(e)).length===0?{shouldProceed:!0}:await t.confirmPrompt(`Directory ${e} contains existing files that may be overwritten. Continue?`,!1)?(await Jxm([...i??[],e]),{shouldProceed:!0}):{shouldProceed:!1}:{shouldProceed:!0}}var p7m=Di(hg(),1),pNt=Di(c7m(),1),bEe=Di(nq(),1);var J_i=Di(require("path"),1),nHi="/fern",aHi=J_i.default.join(nHi,"output"),aWl=J_i.default.join(nHi,"config.json"),HRu=J_i.default.join(nHi,"ir.json"),uqa=J_i.default.join(nHi,"snippet.json"),sqa=J_i.default.join(nHi,"snippet-templates.json"),YTL=J_i.default.join(nHi,"generators"),l7m=J_i.default.join(nHi,"sources");var R7F="0.0.1";function f7m(e){return e!=null?p7m.GithubPublishInfo._visit(e,{npm:t=>pNt.FernGeneratorExec.GithubPublishInfo.npm({registryUrl:t.registryUrl,packageName:t.packageName,tokenEnvironmentVariable:(0,bEe.EnvironmentVariable)(t.token??"")}),maven:t=>pNt.FernGeneratorExec.GithubPublishInfo.maven({registryUrl:t.registryUrl,coordinate:t.coordinate,usernameEnvironmentVariable:(0,bEe.EnvironmentVariable)(t.credentials?.username??""),passwordEnvironmentVariable:(0,bEe.EnvironmentVariable)(t.credentials?.password??""),signature:t.signature!=null?{keyIdEnvironmentVariable:(0,bEe.EnvironmentVariable)(t.signature.keyId??""),passwordEnvironmentVariable:(0,bEe.EnvironmentVariable)(t.signature.password??""),secretKeyEnvironmentVariable:(0,bEe.EnvironmentVariable)(t.signature.secretKey??"")}:void 0}),pypi:t=>pNt.FernGeneratorExec.GithubPublishInfo.pypi({registryUrl:t.registryUrl,packageName:t.packageName,usernameEnvironmentVariable:(0,bEe.EnvironmentVariable)(t.credentials?.username??""),passwordEnvironmentVariable:(0,bEe.EnvironmentVariable)(t.credentials?.password??"")}),rubygems:t=>pNt.FernGeneratorExec.GithubPublishInfo.rubygems({registryUrl:t.registryUrl,packageName:t.packageName,apiKeyEnvironmentVariable:(0,bEe.EnvironmentVariable)(t.apiKey??"")}),postman:t=>pNt.FernGeneratorExec.GithubPublishInfo.postman({apiKeyEnvironmentVariable:(0,bEe.EnvironmentVariable)(t.apiKey??""),workspaceIdEnvironmentVariable:(0,bEe.EnvironmentVariable)(t.workspaceId??"")}),nuget:t=>pNt.FernGeneratorExec.GithubPublishInfo.nuget({registryUrl:t.registryUrl,packageName:t.packageName,apiKeyEnvironmentVariable:(0,bEe.EnvironmentVariable)(t.apiKey??"")}),_other:()=>{}}):void 0}function _7m({generatorInvocation:e,customConfig:t,workspaceName:r,organization:i,outputVersion:n=R7F,absolutePathToSnippet:a,absolutePathToSnippetTemplates:u,writeUnitTests:l,generateOauthClients:f,generatePaginatedClients:s}){let o=[],c=e.outputMode._visit({publish:b=>({...d7m(n,b),publishingMetadata:e.publishMetadata}),publishV2:b=>({...d7m(n,b),publishingMetadata:e.publishMetadata}),downloadFiles:()=>({mode:pNt.FernGeneratorExec.OutputMode.downloadFiles(),path:aHi,publishingMetadata:e.publishMetadata}),github:b=>{let g={mode:pNt.FernGeneratorExec.OutputMode.github({repoUrl:`https://github.com/${b.owner}/${b.repo}`,version:n,publishInfo:f7m(b.publishInfo),installationToken:void 0}),path:aHi,publishingMetadata:e.publishMetadata};return a!==void 0&&(o.push(`${a}:${uqa}`),g.snippetFilepath=uqa),u!==void 0&&(o.push(`${u}:${sqa}`),g.snippetTemplateFilepath=sqa),g},githubV2:b=>{let g=b._visit({commitAndRelease:m=>`https://github.com/${m.owner}/${m.repo}`,push:m=>`https://github.com/${m.owner}/${m.repo}`,pullRequest:m=>`https://github.com/${m.owner}/${m.repo}`,_other:()=>{throw new Error("Encountered unknown github mode")}}),O={mode:pNt.FernGeneratorExec.OutputMode.github({repoUrl:g,version:n,publishInfo:f7m(b.publishInfo)}),path:aHi,publishingMetadata:e.publishMetadata};return a!==void 0&&(o.push(`${a}:${uqa}`),O.snippetFilepath=uqa),u!==void 0&&(o.push(`${u}:${sqa}`),O.snippetTemplateFilepath=sqa),O},_other:()=>{throw new Error("Output type did not match any of the types supported by Fern")}});return{binds:o,config:{irFilepath:HRu,output:c,publish:void 0,customConfig:t,workspaceName:r,organization:i,environment:pNt.FernGeneratorExec.GeneratorEnvironment.local(),dryRun:!1,whitelabel:!1,writeUnitTests:l,generateOauthClients:f,generatePaginatedClients:s}}}function d7m(e,t){let r;return"registryOverrides"in t?r=t.registryOverrides.maven??t.registryOverrides.npm:r!=null&&(r=t._visit({mavenOverride:i=>i,npmOverride:i=>i,pypiOverride:i=>i,rubyGemsOverride:i=>i,postman:i=>i,nugetOverride:i=>i,_other:()=>{}})),{mode:pNt.FernGeneratorExec.OutputMode.publish({registries:{maven:{group:"",password:r?.password??"",registryUrl:r?.registryUrl??"",username:r?.username??""},npm:{registryUrl:r?.registryUrl??"",scope:"",token:r?.token??""}},publishTarget:void 0,registriesV2:{maven:{password:r?.password??"",registryUrl:r?.registryUrl??"",username:r?.username??"",coordinate:r?.coordinate??"",signature:r?.signature},npm:{registryUrl:r?.registryUrl??"",token:r?.token??"",packageName:r?.packageName??""},pypi:{packageName:r?.coordinate??"",password:r?.password??"",registryUrl:r?.registryUrl??"",username:r?.username??"",pypiMetadata:r?.pypiMetadata},rubygems:{registryUrl:r?.registryUrl??"",apiKey:r?.apiKey??"",packageName:r?.packageName??""},nuget:{registryUrl:r?.registryUrl??"",apiKey:r?.apiKey??"",packageName:r?.packageName??""}},version:e}),path:aHi}}async function h7m({workspace:e,audiences:t,generatorInvocation:r,context:i,irVersionOverride:n,version:a,packageName:u,sourceConfig:l,includeOptionalRequestPropertyExamples:f}){let s=b2({workspace:e,audiences:t,generationLanguage:r.language,keywords:r.keywords,smartCasing:r.smartCasing,exampleGeneration:{includeOptionalRequestPropertyExamples:f,disabled:r.disableExamples},readme:r.readme,version:a,packageName:u,context:i,sourceResolver:new y2(i,e)});l!=null&&(s.sourceConfig=l),i.logger.debug("Generated IR");let o=n!=null?await zMa({intermediateRepresentation:s,context:i,version:n}):await IMa({intermediateRepresentation:s,context:i,targetGenerator:{name:r.name,version:r.version}});return{latest:s,migrated:o}}var O7m=require("fs/promises"),Jzn=Di(Jk(),1);var y7m=require("fs/promises"),v7m=Di(Jk(),1);async function oWl({logger:e,imageName:t,args:r=[],binds:i=[],writeLogsToFile:n=!0,removeAfterCompletion:a=!1}){let u=()=>F7F({logger:e,imageName:t,args:r,binds:i,removeAfterCompletion:a,writeLogsToFile:n});try{await u()}catch(l){if(l instanceof Error&&l.message.includes("No such image"))await N7F(t),await u();else throw l}}async function F7F({logger:e,imageName:t,args:r,binds:i,removeAfterCompletion:n,writeLogsToFile:a}){let u=["run","--user","root",...i.flatMap(c=>["-v",c]),n?"--rm":"",t,...r].filter(Boolean),{stdout:l,stderr:f,exitCode:s}=await QH(e,"docker",u,{reject:!1,all:!0,doNotPipeOutput:!0}),o=l+f;if(a){let c=await v7m.default.file();await(0,y7m.writeFile)(c.path,o),e.info(`Generator logs here: ${c.path}`)}if(s!==0)throw new Error(`Docker exited with code ${s}.
1984
1984
  ${l}
1985
1985
  ${f}`)}async function N7F(e){await QH(void 0,"docker",["pull",e],{all:!0,doNotPipeOutput:!0})}var m7m=Di(Lf(),1);var b7m=Di(_1o(),1),Cme=require("fs/promises"),g7m=Di(Jk(),1);var $Ru=class{context;absolutePathToTmpOutputDirectory;absolutePathToTmpSnippetJSON;absolutePathToTmpSnippetTemplatesJSON;absolutePathToLocalSnippetTemplateJSON;absolutePathToLocalOutput;absolutePathToLocalSnippetJSON;constructor({context:t,absolutePathToTmpOutputDirectory:r,absolutePathToTmpSnippetJSON:i,absolutePathToLocalSnippetTemplateJSON:n,absolutePathToLocalOutput:a,absolutePathToLocalSnippetJSON:u,absolutePathToTmpSnippetTemplatesJSON:l}){this.context=t,this.absolutePathToLocalOutput=a,this.absolutePathToTmpOutputDirectory=r,this.absolutePathToTmpSnippetJSON=i,this.absolutePathToLocalSnippetJSON=u,this.absolutePathToLocalSnippetTemplateJSON=n,this.absolutePathToTmpSnippetTemplatesJSON=l}async copyGeneratedFiles(){await this.isFernIgnorePresent()?await this.copyGeneratedFilesWithFernIgnore():await this.copyGeneratedFilesNoFernIgnore(),this.absolutePathToTmpSnippetJSON!=null&&this.absolutePathToLocalSnippetJSON!=null&&await zf(this.absolutePathToTmpSnippetJSON)&&await this.copySnippetJSON({absolutePathToTmpSnippetJSON:this.absolutePathToTmpSnippetJSON,absolutePathToLocalSnippetJSON:this.absolutePathToLocalSnippetJSON}),this.absolutePathToTmpSnippetTemplatesJSON!=null&&this.absolutePathToLocalSnippetTemplateJSON!=null&&await zf(this.absolutePathToTmpSnippetTemplatesJSON)&&await this.copySnippetJSON({absolutePathToTmpSnippetJSON:this.absolutePathToTmpSnippetTemplatesJSON,absolutePathToLocalSnippetJSON:this.absolutePathToLocalSnippetTemplateJSON})}async isFernIgnorePresent(){let t=Kl.of(ku(this.absolutePathToLocalOutput,yo.of($7a)));return await zf(t)}async copyGeneratedFilesWithFernIgnore(){let t=Kl.of((await g7m.default.dir({})).path),r=Kl.of(ku(this.absolutePathToLocalOutput,yo.of($7a))),i=await U7F({absolutePathToFernignore:r});await(0,Cme.cp)(this.absolutePathToLocalOutput,t,{recursive:!0}),await this.runGitCommand(["init"],t),await this.runGitCommand(["add","."],t),(await this.runGitCommand(["config","--list"],t)).includes("user.name")||(await this.runGitCommand(["config","user.name","fern-api"],t),await this.runGitCommand(["config","user.email","info@buildwithfern.com"],t)),await this.runGitCommand(["commit","--allow-empty","-m",'"init"'],t),await this.runGitCommand(["rm","-rf","."],t),await this.copyGeneratedFilesToDirectory(t),await this.runGitCommand(["reset","--",...i],t),await this.runGitCommand(["restore","."],t),await(0,Cme.rmdir)(this.absolutePathToLocalOutput,{recursive:!0}),await(0,Cme.cp)(t,this.absolutePathToLocalOutput,{recursive:!0})}async copyGeneratedFilesNoFernIgnore(){this.context.logger.debug(`rm -rf ${this.absolutePathToLocalOutput}`),await(0,Cme.rm)(this.absolutePathToLocalOutput,{force:!0,recursive:!0}),await this.copyGeneratedFilesToDirectory(this.absolutePathToLocalOutput)}async copyGeneratedFilesToDirectory(t){let[r,...i]=await(0,Cme.readdir)(this.absolutePathToTmpOutputDirectory);if(r!=null)if(this.context.logger.debug(`Copying generated files to ${t}`),r.endsWith(".zip")){await(0,b7m.default)(ku(this.absolutePathToTmpOutputDirectory,yo.of(r)),t);for(let n of i)await(0,Cme.cp)(ku(this.absolutePathToTmpOutputDirectory,yo.of(n)),ku(t,yo.of(n)),{recursive:!0})}else await(0,Cme.cp)(this.absolutePathToTmpOutputDirectory,t,{recursive:!0})}async copySnippetJSON({absolutePathToTmpSnippetJSON:t,absolutePathToLocalSnippetJSON:r}){this.context.logger.debug(`Copying generated snippets to ${r}`),await(0,Cme.cp)(t,r)}async runGitCommand(t,r){return(await QH(this.context.logger,"git",t,{cwd:r,doNotPipeOutput:!0})).stdout}},L7F=/\r?\n/;async function U7F({absolutePathToFernignore:e}){let t=(await(0,Cme.readFile)(e)).toString();return[$7a,...t.trim().split(L7F).filter(r=>!r.startsWith("#")&&r.length>0)]}async function P7m({organization:e,workspace:t,generatorInvocation:r,absolutePathToLocalOutput:i,absolutePathToLocalSnippetJSON:n,absolutePathToLocalSnippetTemplateJSON:a,absolutePathToFernConfig:u,audiences:l,workspaceTempDir:f,keepDocker:s,context:o,irVersionOverride:c,outputVersionOverride:b,writeUnitTests:g,generateOauthClients:O,generatePaginatedClients:m,includeOptionalRequestPropertyExamples:w}){let{latest:A,migrated:M}=await h7m({workspace:t,audiences:l,generatorInvocation:r,context:o,irVersionOverride:c,packageName:j0.getPackageName({generatorInvocation:r}),version:b,sourceConfig:H7F(t),includeOptionalRequestPropertyExamples:w}),q=await V7F({workspaceTempDir:f,context:o,ir:M});o.logger.debug("Wrote IR to: "+q);let D=await Jzn.default.file({tmpdir:f.path}),C=Kl.of(D.path);o.logger.debug("Will write config.json to: "+C);let R=await Jzn.default.dir({tmpdir:f.path}),$=Kl.of(R.path);o.logger.debug("Will write output to: "+$);let I;if(n!=null){let J=await Jzn.default.file({tmpdir:f.path});I=Kl.of(J.path),o.logger.debug("Will write snippet.json to: "+I)}let U;if(a!=null){let J=await Jzn.default.file({tmpdir:f.path});U=Kl.of(J.path),o.logger.debug("Will write snippet-templates.json to: "+U)}let{generatorConfig:H}=await W7F({absolutePathToOutput:$,absolutePathToSnippet:I,absolutePathToSnippetTemplates:U,absolutePathToIr:q,absolutePathToWriteConfigJson:C,workspaceName:t.definition.rootApiFile.contents.name,organization:e,outputVersion:b,keepDocker:s,generatorInvocation:r,context:o,writeUnitTests:g,generateOauthClients:O,generatePaginatedClients:m,sources:t.getSources()});return await new $Ru({context:o,absolutePathToLocalOutput:i,absolutePathToTmpOutputDirectory:$,absolutePathToLocalSnippetJSON:n,absolutePathToLocalSnippetTemplateJSON:a,absolutePathToTmpSnippetJSON:I,absolutePathToTmpSnippetTemplatesJSON:U}).copyGeneratedFiles(),{absolutePathToIr:q,absolutePathToConfigJson:C,ir:A,generatorConfig:H}}async function V7F({ir:e,workspaceTempDir:t,context:r}){r.logger.debug("Migrated IR");let i=await Jzn.default.file({tmpdir:t.path}),n=Kl.of(i.path);return await c6r(n,e,{pretty:!1}),r.logger.debug(`Wrote IR to ${n}`),n}async function W7F({workspaceName:e,organization:t,outputVersion:r,absolutePathToOutput:i,absolutePathToSnippet:n,absolutePathToSnippetTemplates:a,absolutePathToIr:u,absolutePathToWriteConfigJson:l,keepDocker:f,context:s,generatorInvocation:o,writeUnitTests:c,generateOauthClients:b,generatePaginatedClients:g,sources:O}){let{name:m,version:w,config:A}=o,M=`${m}:${w}`,q=[`${l}:${aWl}:ro`,`${u}:${HRu}:ro`,`${i}:${aHi}`];for(let I of O)q.push(`${I.absoluteFilePath}:${j7m(I)}:ro`);let{config:D,binds:C}=_7m({generatorInvocation:o,customConfig:A,workspaceName:e,outputVersion:r,organization:t,absolutePathToSnippet:n,absolutePathToSnippetTemplates:a,writeUnitTests:c,generateOauthClients:b,generatePaginatedClients:g});q.push(...C);let R=await m7m.GeneratorConfig.json(D);if(!R.ok)throw new Error(`Failed to parse config.json into ${l}`);if(await(0,O7m.writeFile)(l,JSON.stringify(R.value,void 0,4)),!await PKu(l,5e3))throw new Error(`Failed to create ${l}`);return await oWl({logger:s.logger,imageName:M,args:[aWl],binds:q,removeAfterCompletion:!f}),{generatorConfig:D}}function H7F(e){return{sources:e.getSources().map(t=>t.type==="protobuf"?xee.proto({id:t.id,protoRootUrl:`file:///${j7m(t)}`}):xee.openapi())}}function j7m(e){return`${l7m}/${e.id}`}var uWl=Di(require("os"),1),w7m=Di(require("path"),1),S7m=Di(Jk(),1);async function sWl({projectConfig:e,workspace:t,generatorGroup:r,keepDocker:i,context:n}){let a=await $7F();(await Promise.all(r.generators.map(async l=>n.runInteractiveTask({name:l.name},async f=>{if(l.absolutePathToLocalOutput==null)f.failWithoutThrowing("Cannot generate because output location is not local-file-system");else{let s=await t.toFernWorkspace({context:n},ydn(l));await P7m({organization:e.organization,absolutePathToFernConfig:e._absolutePath,workspace:s,generatorInvocation:l,absolutePathToLocalOutput:l.absolutePathToLocalOutput,absolutePathToLocalSnippetJSON:void 0,absolutePathToLocalSnippetTemplateJSON:void 0,audiences:r.audiences,workspaceTempDir:a,keepDocker:i,context:f,irVersionOverride:l.irVersionOverride,outputVersionOverride:void 0,writeUnitTests:!1,generateOauthClients:!1,generatePaginatedClients:!1}),f.logger.info(Su.green("Wrote files to "+l.absolutePathToLocalOutput))}})))).some(l=>!l)&&n.failAndThrow()}async function $7F(){return S7m.default.dir({tmpdir:uWl.default.platform()==="darwin"?w7m.default.join("/private",uWl.default.tmpdir()):void 0,prefix:"fern"})}var ZRu=Di(LPi(),1);var D7m=require("fs"),GRu=require("fs/promises"),E7m=require("stream/promises");async function A7m({snippetsS3PreSignedReadUrl:e,absolutePathToLocalSnippetJSON:t,context:r}){try{await G7F({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}),r.logger.info(Su.green(`Downloaded to ${t}`))}catch{r.logger.debug(Su.yellow("Failed to download snippet.json from output."))}}async function G7F({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await zz.get(e,{responseType:"stream"});await zf(t)&&await(0,GRu.rm)(t,{recursive:!0}),await(0,GRu.mkdir)(Mp(t),{recursive:!0}),await(0,E7m.pipeline)(r.data,(0,D7m.createWriteStream)(t))}var fWl=Di(twe(),1);var C7m=Di(_1o(),1),B7m=require("fs"),KRu=require("fs/promises"),lWl=Di(require("path"),1),x7m=require("stream/promises");var QRu=Di(T7m(),1);function d$r(e,t,{target:r="stdout",...i}={}){return QRu.default[r]?Efn.link(e,t):i.fallback===!1?e:typeof i.fallback=="function"?i.fallback(e,t):`${e} (\u200B${t}\u200B)`}d$r.isSupported=QRu.default.stdout;d$r.stderr=(e,t,r={})=>d$r(e,t,{target:"stderr",...r});d$r.stderr.isSupported=QRu.default.stderr;var I7m=Di(Jk(),1);var JRu=class{context;generatorInvocation;absolutePathToPreview;lengthOfLastLogs=0;constructor({interactiveTaskContext:t,generatorInvocation:r,absolutePathToPreview:i}){this.context=t,this.generatorInvocation=r,this.absolutePathToPreview=i}async processUpdate(t){t==null&&this.context.failAndThrow("Task is missing on job status");let r=t.packages.map(n=>n.coordinate._visit({npm:a=>`${a.name}@${a.version}`,maven:a=>`${a.group}:${a.artifact}:${a.version}`,pypi:a=>`${a.name} ${a.version}`,ruby:a=>`${a.name}:${a.version}`,nuget:a=>`${a.name} ${a.version}`,_other:()=>"<unknown package>"}));this.absolutePathToPreview==null&&this.context.setSubtitle(r.length>0?r.map(n=>`\u25E6 ${n}`).join(`
1986
- `):void 0);for(let n of t.logs.slice(this.lengthOfLastLogs))this.context.logger.log(Y7F(n.level),n.message);this.lengthOfLastLogs=t.logs.length;let i=n=>{this.context.logger.debug(`Generated files. ${d$r("View here",n,{fallback:(a,u)=>`${a}: ${u}`})}`)};return await t.status._visit({notStarted:Yo,running:Yo,failed:({message:n,s3PreSignedReadUrl:a})=>{a!=null&&i(a),this.context.failAndThrow(n)},finished:async n=>{if(n.s3PreSignedReadUrlV2!=null){i(n.s3PreSignedReadUrlV2);let a=this.getAbsolutePathToLocalOutput();a!=null&&await J7F({s3PreSignedReadUrl:n.s3PreSignedReadUrlV2,absolutePathToLocalOutput:a,context:this.context})}if(this.absolutePathToPreview==null)for(let a of r)this.context.logger.info(`Published ${a}`);this.#e=!0,this.#t=n.createdSnippets!=null?n.createdSnippets:!1,this.#r=n.snippetsS3PreSignedReadUrl},_other:()=>{this.context.logger.warn("Received unknown update type: "+t.status.type)}}),this.#e?{createdSnippets:this.#t,snippetsS3PreSignedReadUrl:this.#r}:void 0}getAbsolutePathToLocalOutput(){return this.absolutePathToPreview!=null?ku(this.absolutePathToPreview,yo.of(lWl.default.basename(this.generatorInvocation.name))):this.generatorInvocation.absolutePathToLocalOutput}#e=!1;get isFinished(){return this.#e}#t=!1;get createdSnippets(){return this.#t}#r=void 0;get snippetsS3PreSignedReadUrl(){return this.#r}};async function J7F({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t,context:r}){try{await K7F({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}),r.logger.info(Su.green(`Downloaded to ${t}`))}catch(i){r.failAndThrow("Failed to download files",i)}}async function K7F({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await zz.get(e,{responseType:"stream"}),i=await I7m.default.dir({prefix:"fern",unsafeCleanup:!0}),n=lWl.default.join(i.path,"output.zip");await(0,x7m.pipeline)(r.data,(0,B7m.createWriteStream)(n)),await zf(t)&&await(0,KRu.rm)(t,{recursive:!0}),await(0,KRu.mkdir)(t,{recursive:!0}),await(0,C7m.default)(n,t)}function Y7F(e){switch(e){case"DEBUG":return k0.Debug;case"INFO":return k0.Info;case"WARN":return k0.Warn;case"ERROR":return k0.Error;default:return k0.Info}}var XRu=require("fs/promises"),z7m=Di(Jk(),1);var X7F="proto.zip",YRu=class{sourceTypes;context;sources;constructor(t,r){this.context=t,this.sources=Object.fromEntries(r.map(i=>[i.id,i])),this.sourceTypes=new Set(Object.values(this.sources).map(i=>i.type))}async uploadSources(t){for(let[r,i]of Object.entries(t)){let n=this.getSourceOrThrow(r);await this.uploadSource(n,i.uploadUrl)}return this.convertFdrSourceUploadsToSourceConfig(t)}async uploadSource(t,r){let i=await this.getUploadCommand(t),n=await(0,XRu.readFile)(i.absoluteFilePath),a=await fetch(r,{method:"PUT",body:n,headers:{"Content-Type":"application/octet-stream"}});await i.cleanup(),a.ok||this.context.failAndThrow(`Failed to upload source file: ${t.absoluteFilePath}. Status: ${a.status}, ${a.statusText}`)}async getUploadCommand(t){if(t.type==="protobuf"){let r=await this.zipSource(t.absoluteFilePath);return{absoluteFilePath:r,cleanup:async()=>{this.context.logger.debug(`Removing ${r}`),await(0,XRu.unlink)(r)}}}return{absoluteFilePath:t.absoluteFilePath,cleanup:async()=>{}}}async zipSource(t){let r=await z7m.default.dir(),i=ku(Kl.of(r.path),yo.of(X7F));return this.context.logger.debug(`Zipping source ${t} into ${i}`),await QH(this.context.logger,"zip",["-r",i,"."],{cwd:t,doNotPipeOutput:!0}),i}convertFdrSourceUploadsToSourceConfig(t){let r=[];for(let[i,n]of Object.entries(t))switch(this.getSourceOrThrow(i).type){case"protobuf":r.push(xee.proto({id:i,protoRootUrl:n.downloadUrl}));continue;case"openapi":r.push(xee.openapi());continue;case"asyncapi":continue}return{sources:r}}getSourceOrThrow(t){let r=this.sources[t];return r==null&&this.context.failAndThrow(`Internal error; server responded with source id "${t}" which does not exist in the workspace.`),r}};var R7m=Di(CLn(),1),Bme=require("fs/promises");var F7m=require("path"),N7m=Di(rmo(),1),L7m=Di(Jk(),1);var Yzn=Di(LPi(),1);async function U7m({projectConfig:e,workspace:t,organization:r,intermediateRepresentation:i,generatorInvocation:n,version:a,context:u,shouldLogS3Url:l,token:f,whitelabel:s,irVersionOverride:o,absolutePathToPreview:c}){let b=await Z7F({projectConfig:e,workspace:t,organization:r,generatorInvocation:n,version:a,context:u,shouldLogS3Url:l,token:f,whitelabel:s,absolutePathToPreview:c});return await k7F({intermediateRepresentation:i,job:b,context:u,generatorInvocation:n,irVersionOverride:o}),b}async function Z7F({projectConfig:e,workspace:t,organization:r,generatorInvocation:i,version:n,context:a,shouldLogS3Url:u,token:l,whitelabel:f,absolutePathToPreview:s}){let o=l4r({token:l.value}),c={id:i.name,version:i.version,outputMode:i.outputMode,customConfig:i.config,publishMetadata:i.publishMetadata},b;if(i.outputMode.type.startsWith("github"))try{let O=await L7m.default.dir(),m=Kl.of(O.path);a.logger.debug(`Writing mock fern definition to ${m}`);let w=ku(m,yo.of(K9)),A=ku(w,yo.of(v4));await(0,Bme.mkdir)(A,{recursive:!0});let M=ku(A,yo.of(UN));await(0,Bme.writeFile)(M,pp.dump(t.definition.rootApiFile.contents)),await V7m({absolutePathToDefinitionDirectory:A,definition:t.definition});let q=ku(w,yo.of($k));await(0,Bme.writeFile)(q,JSON.stringify(e.rawConfig,void 0,2));try{let R=t.getSources();for(let $ of R){let I=await(0,Bme.readFile)($.absoluteFilePath),U=(0,F7m.relative)(t.absoluteFilePath,$.absoluteFilePath),H=ku(w,yo.of(U));await(0,Bme.mkdir)(Mp(H),{recursive:!0}),await(0,Bme.writeFile)(H,new Uint8Array(I))}}catch(R){a.logger.debug(`Failed to write source files to disk, continuing: ${R}`)}let D=ku(m,yo.of("definition.tgz"));await(0,N7m.create)({file:D,cwd:w},["."]),a.logger.debug("Getting upload URL for Fern definition.");let C=await o.remoteGen.getDefinitionUploadUrl({apiName:t.definition.rootApiFile.contents.name,organizationName:r,version:n});C.ok?(a.logger.debug("Uploading definition..."),await zz.put(C.body.s3Url,await(0,Bme.readFile)(D)),b={definitionS3DownloadUrl:C.body.s3Url,outputPath:".mock",cliVersion:e.version}):C.error.content.reason==="status-code"?a.logger.debug(`Failed with status-code to get upload URL with status code ${C.error.content.statusCode}, continuing: ${C.error.content.body}`):C.error.content.reason==="non-json"?a.logger.debug(`Failed with non-json to get upload URL with status code ${C.error.content.statusCode}, continuing: ${C.error.content.rawBody}`):C.error.content.reason==="unknown"&&a.logger.debug(`Failed to get upload URL as unknown error occurred continuing: ${C.error.content.errorMessage}`)}catch(O){a.logger.debug(`Failed to upload definition to S3, continuing: ${O}`)}let g=await o.remoteGen.createJobV3({apiName:t.definition.rootApiFile.contents.name,version:n,organizationName:r,generators:[c],uploadToS3:t2F({outputMode:i.outputMode,generatorInvocation:i,absolutePathToPreview:s,shouldLogS3Url:u}),whitelabel:f,fernDefinitionMetadata:b,preview:s!=null});return g.ok?g.body:e2F(g.error)._visit({illegalApiNameError:()=>a.failAndThrow("API name is invalid: "+t.definition.rootApiFile.contents.name),illegalApiVersionError:()=>a.failAndThrow("API version is invalid: "+n),cannotPublishToNpmScope:({validScope:O,invalidScope:m})=>a.failAndThrow(`You do not have permission to publish to ${m} (expected ${O})`),cannotPublishToMavenGroup:({validGroup:O,invalidGroup:m})=>a.failAndThrow(`You do not have permission to publish to ${m} (expected ${O})`),cannotPublishPypiPackage:({validPrefix:O,invalidPackageName:m})=>a.failAndThrow(`You do not have permission to publish to ${m} (expected ${O})`),generatorsDoNotExistError:O=>a.failAndThrow("Generators do not exist: "+O.nonExistentGenerators.map(m=>`${m.id}@${m.version}`).join(", ")),insufficientPermissions:()=>a.failAndThrow("Insufficient permissions."),orgNotConfiguredForWhitelabel:()=>a.failAndThrow("Your org is not configured for white-labeling. Please reach out to support@buildwithfern.com."),_other:O=>a.failAndThrow("Failed to create job",O)})}async function V7m({absolutePathToDefinitionDirectory:e,definition:t}){for(let[r,i]of Object.entries(t.namedDefinitionFiles)){let n=ku(e,yo.of(r));await(0,Bme.mkdir)(Mp(n),{recursive:!0}),await(0,Bme.writeFile)(n,pp.dump(i.contents))}for(let[r,i]of Object.entries(t.packageMarkers))if(i.contents.export==null){let n=ku(e,yo.of(r));await(0,Bme.mkdir)(Mp(n),{recursive:!0}),await(0,Bme.writeFile)(n,pp.dump(i.contents))}for(let[r,i]of Object.entries(t.importedDefinitions))await V7m({absolutePathToDefinitionDirectory:ku(e,yo.of(r)),definition:i.definition})}async function k7F({intermediateRepresentation:e,generatorInvocation:t,job:r,context:i,irVersionOverride:n}){let a=n==null?await IMa({intermediateRepresentation:e,context:i,targetGenerator:{name:t.name,version:t.version}}):await LUl({intermediateRepresentation:e,context:i,irVersion:n,targetGenerator:{name:t.name,version:t.version}}),u=new R7m.default,l=await d6r(a,{onWrite:s=>{i.logger.debug("Wrote IR to disk: "+s)}});u.append("file",l);let f=Iv(ins(),`/api/remote-gen/jobs/${r.jobId}/start`);try{await zz.post(f,u,{headers:u.getHeaders(),maxBodyLength:1/0})}catch(s){let o=s instanceof sNd?s.response?.data:s;i.logger.debug(`POST ${f} failed with ${JSON.stringify(s)}`),i.failAndThrow("Failed to start job",o)}}function e2F(e){if(e?.reason==="status-code"){let t=e.body;switch(t?._error){case"IllegalApiNameError":return Yzn.FernFiddle.remoteGen.createJobV3.Error.illegalApiNameError();case"GeneratorsDoNotExistError":return Yzn.FernFiddle.remoteGen.createJobV3.Error.generatorsDoNotExistError(t.body);case"CannotPublishToNpmScope":return Yzn.FernFiddle.remoteGen.createJobV3.Error.cannotPublishToNpmScope(t.body);case"CannotPublishToMavenScope":return Yzn.FernFiddle.remoteGen.createJobV3.Error.cannotPublishToMavenGroup(t.body);case"InsufficientPermissions":return Yzn.FernFiddle.remoteGen.createJobV3.Error.insufficientPermissions(t.body)}}return e}function t2F({outputMode:e,generatorInvocation:t,absolutePathToPreview:r,shouldLogS3Url:i}){return e.type==="downloadFiles"||t.absolutePathToLocalSnippets!=null||r!=null||i}var W7m=l4r();var r2F=3;function H7m({job:e,taskId:t,taskHandler:r,context:i}){let n=0,a=async()=>{let u=await W7m.remoteGen.getJobStatus(e.jobId);if(u.ok)return u.body[t];i.logger.debug("Failed to get job status.",JSON.stringify(u.error.content))};return new Promise((u,l)=>{f();async function f(){try{let s=await a();if(s==null)n++,n===r2F&&i.failAndThrow(`Failed to get job status after ${n} attempts.`),setTimeout(f,2e3+1e3*n);else{n=0;let o=await r.processUpdate(s);r.isFinished?u(o):setTimeout(f,2e3)}}catch(s){l(s)}}})}async function $7m({projectConfig:e,organization:t,workspace:r,interactiveTaskContext:i,generatorInvocation:n,version:a,audiences:u,shouldLogS3Url:l,token:f,whitelabel:s,irVersionOverride:o,absolutePathToPreview:c,readme:b}){let g=HPi({token:f.value}),O=j0.getPackageName({generatorInvocation:n}),m=b2({workspace:r,generationLanguage:n.language,keywords:n.keywords,smartCasing:n.smartCasing,exampleGeneration:{disabled:n.disableExamples},audiences:u,readme:b,packageName:O,version:a??await n2F({fdr:g,packageName:O,generatorInvocation:n}),context:i,sourceResolver:new y2(i,r)}),w=r.getSources(),A=Xwe({ir:m,snippetsConfig:{typescriptSdk:void 0,pythonSdk:void 0,javaSdk:void 0,rubySdk:void 0,goSdk:void 0}}),M=await g.api.v1.register.registerApiDefinition({orgId:fWl.FernRegistry.OrgId(t),apiId:fWl.FernRegistry.ApiId(m.apiName.originalName),definition:A,sources:w.length>0?a2F(w):void 0}),q,D;M.ok&&(q=M.body.apiDefinitionId,D=M.body.sources);let C=new YRu(i,w);if(D==null&&C.sourceTypes.has("protobuf")&&(M.ok||i.failAndThrow(`Failed to register API definition: ${JSON.stringify(M.error.content)}`),i.failAndThrow("Did not successfully upload Protobuf source files.")),D!=null){i.logger.debug("Uploading source files ...");let J=await C.uploadSources(D);i.logger.debug("Setting IR source configuration ..."),m.sourceConfig=J}let R=c!=null,$=J=>wen(J,{onError:ee=>i.failAndThrow(ee)},{substituteAsEmpty:R}),I=$(n),U=await U7m({projectConfig:e,workspace:r,organization:t,generatorInvocation:I,context:i,version:a,intermediateRepresentation:{...m,fdrApiDefinitionId:q,publishConfig:i2F({generatorInvocation:I})},shouldLogS3Url:l,token:f,whitelabel:s!=null?$(s):void 0,irVersionOverride:o,absolutePathToPreview:c});i.logger.debug(`Job ID: ${U.jobId}`);let H=U.taskIds[0];if(H==null){i.failAndThrow("Did not receive a task ID.");return}i.logger.debug(`Task ID: ${H}`);let te=new JRu({job:U,taskId:H,generatorInvocation:n,interactiveTaskContext:i,absolutePathToPreview:c});return await H7m({job:U,taskHandler:te,taskId:H,context:i})}function i2F({generatorInvocation:e}){return e.outputMode._visit({downloadFiles:()=>{},github:()=>{},githubV2:()=>{},publish:()=>{},publishV2:t=>t._visit({mavenOverride:()=>{},pypiOverride:()=>{},nugetOverride:()=>{},npmOverride:()=>{},rubyGemsOverride:()=>{},postman:r=>{let i;return e.raw?.output?.location==="postman"&&(i=e.raw.output?.["collection-id"]),Bc.PublishingConfig.direct({target:Bc.PublishTarget.postman({apiKey:r.apiKey,workspaceId:r.workspaceId,collectionId:i})})},_other:()=>{}}),_other:()=>{}})}async function n2F({fdr:e,packageName:t,generatorInvocation:r}){if(r.language==null)return;let i;switch(r.language){case"csharp":i="Csharp";break;case"go":i="Go";break;case"java":i="Java";break;case"python":i="Python";break;case"ruby":i="Ruby";break;case"typescript":i="TypeScript";break;default:return}if(t==null)return;let n=await e.sdks.versions.computeSemanticVersion({githubRepository:r.outputMode.type==="githubV2"?`${r.outputMode.githubV2.owner}/${r.outputMode.githubV2.repo}`:void 0,language:i,package:t});if(n.ok)return n.body.version}function a2F(e){return Object.fromEntries(Object.values(e).map(t=>[t.id,{type:t.type==="protobuf"?"proto":t.type}]))}async function dWl({projectConfig:e,organization:t,workspace:r,context:i,generatorGroup:n,version:a,shouldLogS3Url:u,token:l,whitelabel:f,absolutePathToPreview:s,mode:o}){if(n.generators.length===0)return i.logger.warn("No generators specified."),null;let c=[],b=[];return c.push(...n.generators.map(O=>i.runInteractiveTask({name:O.name},async m=>{let w=await r.toFernWorkspace({context:i},ydn(O)),A=await $7m({projectConfig:e,organization:t,workspace:w,interactiveTaskContext:m,generatorInvocation:{...O,outputMode:O.outputMode._visit({downloadFiles:()=>O.outputMode,github:M=>ZRu.FernFiddle.OutputMode.github({...M,makePr:o==="pull-request"}),githubV2:M=>o==="pull-request"?ZRu.FernFiddle.OutputMode.githubV2(ZRu.FernFiddle.GithubOutputModeV2.pullRequest(M)):O.outputMode,publish:()=>O.outputMode,publishV2:()=>O.outputMode,_other:()=>O.outputMode})},version:a,audiences:n.audiences,shouldLogS3Url:u,token:l,whitelabel:f,readme:O.readme,irVersionOverride:O.irVersionOverride,absolutePathToPreview:s});A!=null&&A.createdSnippets&&(b.push(O),O.absolutePathToLocalSnippets!=null&&A.snippetsS3PreSignedReadUrl!=null&&await A7m({snippetsS3PreSignedReadUrl:A.snippetsS3PreSignedReadUrl,absolutePathToLocalSnippetJSON:O.absolutePathToLocalSnippets,context:m}))}))),(await Promise.all(c)).some(O=>!O)&&i.failAndThrow(),{snippetsProducedBy:b}}var I2m=require("fs/promises");var TWl=Di(uen(),1);var _Nt=Di(twe(),1);var A2m=Di(E2m(),1);var M2m=require("util");var R6F=(0,M2m.promisify)(A2m.default);async function q2m(e,t,r){let i=rUn(e,t),n=[];for(let a of i){let u=await Promise.all(a.map(async l=>{try{let f=await R6F(l);return f==null||f.height==null||f.width==null?void 0:{filePath:l,width:f.width,height:f.height,blurDataUrl:void 0}}catch(f){r.logger.error(`Failed to measure image size for ${l}. ${f?.message}`);return}}));n.push(...u.filter(dg))}return new Map(n.map(a=>[a.filePath,a]))}var F6F=10,T2m=10;async function z2m({token:e,organization:t,docsWorkspace:r,domain:i,customDomains:n,fernWorkspaces:a,ossWorkspaces:u,context:l,preview:f,editThisPage:s,isPrivate:o=!1}){let c=HPi({token:e.value}),b=o?{type:"private",authType:"sso"}:{type:"public"},g,O=n[0]??i,m=N6F(i),A=await new v6t(i,r,u,a,l,s,async q=>{let D=new Map(q.map(H=>[H.absoluteFilePath,H])),R=q.map(H=>({...H,mediaType:TWl.lookup(H.absoluteFilePath)})).filter(H=>H.mediaType!==!1).filter(H=>aB.parse(H.mediaType)?.isImage()??!1).map(H=>H.absoluteFilePath),$=await q2m(R,F6F,l),I=[];[...$.values()].forEach(H=>{let te=D.get(H.filePath);if(te==null)return;let J={filePath:_Nt.FernRegistry.docs.v1.write.FilePath(R4a(te.relativeFilePath)),width:H.width,height:H.height,blurDataUrl:H.blurDataUrl,alt:void 0};I.push(J)});let U=q.filter(({absoluteFilePath:H})=>!$.has(H)).map(({relativeFilePath:H})=>R4a(H));if(f){let H=await c.docs.v2.write.startDocsPreviewRegister({orgId:_Nt.FernRegistry.OrgId(t),authConfig:o?{type:"private",authType:"sso"}:{type:"public"},filepaths:U.map(te=>_Nt.FernRegistry.docs.v1.write.FilePath(te)),images:I,basePath:m});return H.ok?(O=H.body.previewUrl,g=H.body.docsRegistrationId,await C2m(H.body.uploadUrls,r.absoluteFilePath,l,T2m),B2m(H.body.uploadUrls,r.absoluteFilePath)):await x2m(H.error,l)}else{let H=await c.docs.v2.write.startDocsRegister({domain:i,customDomains:n,authConfig:b,apiId:_Nt.FernRegistry.ApiId(""),orgId:_Nt.FernRegistry.OrgId(t),filepaths:U.map(te=>_Nt.FernRegistry.docs.v1.write.FilePath(te)),images:I});return H.ok?(g=H.body.docsRegistrationId,await C2m(H.body.uploadUrls,r.absoluteFilePath,l,T2m),B2m(H.body.uploadUrls,r.absoluteFilePath)):x2m(H.error,l)}},async({ir:q,snippetsConfig:D,playgroundConfig:C,apiName:R})=>{let $=Xwe({ir:q,snippetsConfig:D,playgroundConfig:C}),I=await c.api.v1.register.registerApiDefinition({orgId:_Nt.FernRegistry.OrgId(t),apiId:_Nt.FernRegistry.ApiId(q.apiName.originalName),definition:$,definitionV2:void 0});if(I.ok)return l.logger.debug(`Registered API Definition ${I.body.apiDefinitionId}`),I.body.apiDefinitionId;switch(I.error.error){case"UnauthorizedError":case"UserNotInOrgError":return l.failAndThrow("You do not have permissions to register the docs. Reach out to support@buildwithfern.com");default:return R!=null?l.failAndThrow(`Failed to publish docs because API definition (${R}) could not be uploaded. Please contact support@buildwithfern.com
1986
+ `):void 0);for(let n of t.logs.slice(this.lengthOfLastLogs))this.context.logger.log(Y7F(n.level),n.message);this.lengthOfLastLogs=t.logs.length;let i=n=>{this.context.logger.debug(`Generated files. ${d$r("View here",n,{fallback:(a,u)=>`${a}: ${u}`})}`)};return await t.status._visit({notStarted:Yo,running:Yo,failed:({message:n,s3PreSignedReadUrl:a})=>{a!=null&&i(a),this.context.failAndThrow(n)},finished:async n=>{if(n.s3PreSignedReadUrlV2!=null){i(n.s3PreSignedReadUrlV2);let a=this.getAbsolutePathToLocalOutput();a!=null&&await J7F({s3PreSignedReadUrl:n.s3PreSignedReadUrlV2,absolutePathToLocalOutput:a,context:this.context})}if(this.absolutePathToPreview==null)for(let a of r)this.context.logger.info(`Published ${a}`);this.#e=!0,this.#t=n.createdSnippets!=null?n.createdSnippets:!1,this.#r=n.snippetsS3PreSignedReadUrl},_other:()=>{this.context.logger.warn("Received unknown update type: "+t.status.type)}}),this.#e?{createdSnippets:this.#t,snippetsS3PreSignedReadUrl:this.#r}:void 0}getAbsolutePathToLocalOutput(){return this.absolutePathToPreview!=null?ku(this.absolutePathToPreview,yo.of(lWl.default.basename(this.generatorInvocation.name))):this.generatorInvocation.absolutePathToLocalOutput}#e=!1;get isFinished(){return this.#e}#t=!1;get createdSnippets(){return this.#t}#r=void 0;get snippetsS3PreSignedReadUrl(){return this.#r}};async function J7F({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t,context:r}){try{await K7F({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}),r.logger.info(Su.green(`Downloaded to ${t}`))}catch(i){r.failAndThrow("Failed to download files",i)}}async function K7F({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await zz.get(e,{responseType:"stream"}),i=await I7m.default.dir({prefix:"fern",unsafeCleanup:!0}),n=lWl.default.join(i.path,"output.zip");await(0,x7m.pipeline)(r.data,(0,B7m.createWriteStream)(n)),await zf(t)&&await(0,KRu.rm)(t,{recursive:!0}),await(0,KRu.mkdir)(t,{recursive:!0}),await(0,C7m.default)(n,t)}function Y7F(e){switch(e){case"DEBUG":return k0.Debug;case"INFO":return k0.Info;case"WARN":return k0.Warn;case"ERROR":return k0.Error;default:return k0.Info}}var XRu=require("fs/promises"),z7m=Di(Jk(),1);var X7F="proto.zip",YRu=class{sourceTypes;context;sources;constructor(t,r){this.context=t,this.sources=Object.fromEntries(r.map(i=>[i.id,i])),this.sourceTypes=new Set(Object.values(this.sources).map(i=>i.type))}async uploadSources(t){for(let[r,i]of Object.entries(t)){let n=this.getSourceOrThrow(r);await this.uploadSource(n,i.uploadUrl)}return this.convertFdrSourceUploadsToSourceConfig(t)}async uploadSource(t,r){let i=await this.getUploadCommand(t),n=await(0,XRu.readFile)(i.absoluteFilePath),a=await fetch(r,{method:"PUT",body:n,headers:{"Content-Type":"application/octet-stream"}});await i.cleanup(),a.ok||this.context.failAndThrow(`Failed to upload source file: ${t.absoluteFilePath}. Status: ${a.status}, ${a.statusText}`)}async getUploadCommand(t){if(t.type==="protobuf"){let r=await this.zipSource(t.absoluteFilePath);return{absoluteFilePath:r,cleanup:async()=>{this.context.logger.debug(`Removing ${r}`),await(0,XRu.unlink)(r)}}}return{absoluteFilePath:t.absoluteFilePath,cleanup:async()=>{}}}async zipSource(t){let r=await z7m.default.dir(),i=ku(Kl.of(r.path),yo.of(X7F));return this.context.logger.debug(`Zipping source ${t} into ${i}`),await QH(this.context.logger,"zip",["-r",i,"."],{cwd:t,doNotPipeOutput:!0}),i}convertFdrSourceUploadsToSourceConfig(t){let r=[];for(let[i,n]of Object.entries(t))switch(this.getSourceOrThrow(i).type){case"protobuf":r.push(xee.proto({id:i,protoRootUrl:n.downloadUrl}));continue;case"openapi":r.push(xee.openapi());continue;case"asyncapi":continue}return{sources:r}}getSourceOrThrow(t){let r=this.sources[t];return r==null&&this.context.failAndThrow(`Internal error; server responded with source id "${t}" which does not exist in the workspace.`),r}};var R7m=Di(CLn(),1),Bme=require("fs/promises");var F7m=require("path"),N7m=Di(rmo(),1),L7m=Di(Jk(),1);var Yzn=Di(LPi(),1);async function U7m({projectConfig:e,workspace:t,organization:r,intermediateRepresentation:i,generatorInvocation:n,version:a,context:u,shouldLogS3Url:l,token:f,whitelabel:s,irVersionOverride:o,absolutePathToPreview:c}){let b=await Z7F({projectConfig:e,workspace:t,organization:r,generatorInvocation:n,version:a,context:u,shouldLogS3Url:l,token:f,whitelabel:s,absolutePathToPreview:c});return await k7F({intermediateRepresentation:i,job:b,context:u,generatorInvocation:n,irVersionOverride:o}),b}async function Z7F({projectConfig:e,workspace:t,organization:r,generatorInvocation:i,version:n,context:a,shouldLogS3Url:u,token:l,whitelabel:f,absolutePathToPreview:s}){let o=l4r({token:l.value}),c={id:i.name,version:i.version,outputMode:i.outputMode,customConfig:i.config,publishMetadata:i.publishMetadata},b;if(i.outputMode.type.startsWith("github"))try{let O=await L7m.default.dir(),m=Kl.of(O.path);a.logger.debug(`Writing mock fern definition to ${m}`);let w=ku(m,yo.of(K9)),A=ku(w,yo.of(v4));await(0,Bme.mkdir)(A,{recursive:!0});let M=ku(A,yo.of(UN));await(0,Bme.writeFile)(M,pp.dump(t.definition.rootApiFile.contents)),await V7m({absolutePathToDefinitionDirectory:A,definition:t.definition});let q=ku(w,yo.of($k));await(0,Bme.writeFile)(q,JSON.stringify(e.rawConfig,void 0,2));try{let R=t.getSources();for(let $ of R){let I=await(0,Bme.readFile)($.absoluteFilePath),U=(0,F7m.relative)(t.absoluteFilePath,$.absoluteFilePath),H=ku(w,yo.of(U));await(0,Bme.mkdir)(Mp(H),{recursive:!0}),await(0,Bme.writeFile)(H,new Uint8Array(I))}}catch(R){a.logger.debug(`Failed to write source files to disk, continuing: ${R}`)}let D=ku(m,yo.of("definition.tgz"));await(0,N7m.create)({file:D,cwd:w},["."]),a.logger.debug("Getting upload URL for Fern definition.");let C=await o.remoteGen.getDefinitionUploadUrl({apiName:t.definition.rootApiFile.contents.name,organizationName:r,version:n});C.ok?(a.logger.debug("Uploading definition..."),await zz.put(C.body.s3Url,await(0,Bme.readFile)(D)),b={definitionS3DownloadUrl:C.body.s3Url,outputPath:".mock",cliVersion:e.version}):C.error.content.reason==="status-code"?a.logger.debug(`Failed with status-code to get upload URL with status code ${C.error.content.statusCode}, continuing: ${C.error.content.body}`):C.error.content.reason==="non-json"?a.logger.debug(`Failed with non-json to get upload URL with status code ${C.error.content.statusCode}, continuing: ${C.error.content.rawBody}`):C.error.content.reason==="unknown"&&a.logger.debug(`Failed to get upload URL as unknown error occurred continuing: ${C.error.content.errorMessage}`)}catch(O){a.logger.debug(`Failed to upload definition to S3, continuing: ${O}`)}let g=await o.remoteGen.createJobV3({apiName:t.definition.rootApiFile.contents.name,version:n,organizationName:r,generators:[c],uploadToS3:t2F({outputMode:i.outputMode,generatorInvocation:i,absolutePathToPreview:s,shouldLogS3Url:u}),whitelabel:f,fernDefinitionMetadata:b,preview:s!=null});return g.ok?g.body:e2F(g.error)._visit({illegalApiNameError:()=>a.failAndThrow("API name is invalid: "+t.definition.rootApiFile.contents.name),illegalApiVersionError:()=>a.failAndThrow("API version is invalid: "+n),cannotPublishToNpmScope:({validScope:O,invalidScope:m})=>a.failAndThrow(`You do not have permission to publish to ${m} (expected ${O})`),cannotPublishToMavenGroup:({validGroup:O,invalidGroup:m})=>a.failAndThrow(`You do not have permission to publish to ${m} (expected ${O})`),cannotPublishPypiPackage:({validPrefix:O,invalidPackageName:m})=>a.failAndThrow(`You do not have permission to publish to ${m} (expected ${O})`),generatorsDoNotExistError:O=>a.failAndThrow("Generators do not exist: "+O.nonExistentGenerators.map(m=>`${m.id}@${m.version}`).join(", ")),insufficientPermissions:()=>a.failAndThrow("Insufficient permissions."),orgNotConfiguredForWhitelabel:()=>a.failAndThrow("Your org is not configured for white-labeling. Please reach out to support@buildwithfern.com."),_other:O=>a.failAndThrow("Failed to create job",O)})}async function V7m({absolutePathToDefinitionDirectory:e,definition:t}){for(let[r,i]of Object.entries(t.namedDefinitionFiles)){let n=ku(e,yo.of(r));await(0,Bme.mkdir)(Mp(n),{recursive:!0}),await(0,Bme.writeFile)(n,pp.dump(i.contents))}for(let[r,i]of Object.entries(t.packageMarkers))if(i.contents.export==null){let n=ku(e,yo.of(r));await(0,Bme.mkdir)(Mp(n),{recursive:!0}),await(0,Bme.writeFile)(n,pp.dump(i.contents))}for(let[r,i]of Object.entries(t.importedDefinitions))await V7m({absolutePathToDefinitionDirectory:ku(e,yo.of(r)),definition:i.definition})}async function k7F({intermediateRepresentation:e,generatorInvocation:t,job:r,context:i,irVersionOverride:n}){let a=n==null?await IMa({intermediateRepresentation:e,context:i,targetGenerator:{name:t.name,version:t.version}}):await LUl({intermediateRepresentation:e,context:i,irVersion:n,targetGenerator:{name:t.name,version:t.version}}),u=new R7m.default,l=await d6r(a,{onWrite:s=>{i.logger.debug("Wrote IR to disk: "+s)}});u.append("file",l);let f=Iv(ins(),`/api/remote-gen/jobs/${r.jobId}/start`);try{await zz.post(f,u,{headers:u.getHeaders(),maxBodyLength:1/0})}catch(s){let o=s instanceof sNd?s.response?.data:s;i.logger.debug(`POST ${f} failed with ${JSON.stringify(s)}`),i.failAndThrow("Failed to start job",o)}}function e2F(e){if(e?.reason==="status-code"){let t=e.body;switch(t?._error){case"IllegalApiNameError":return Yzn.FernFiddle.remoteGen.createJobV3.Error.illegalApiNameError();case"GeneratorsDoNotExistError":return Yzn.FernFiddle.remoteGen.createJobV3.Error.generatorsDoNotExistError(t.body);case"CannotPublishToNpmScope":return Yzn.FernFiddle.remoteGen.createJobV3.Error.cannotPublishToNpmScope(t.body);case"CannotPublishToMavenScope":return Yzn.FernFiddle.remoteGen.createJobV3.Error.cannotPublishToMavenGroup(t.body);case"InsufficientPermissions":return Yzn.FernFiddle.remoteGen.createJobV3.Error.insufficientPermissions(t.body)}}return e}function t2F({outputMode:e,generatorInvocation:t,absolutePathToPreview:r,shouldLogS3Url:i}){return e.type==="downloadFiles"||t.absolutePathToLocalSnippets!=null||r!=null||i}var W7m=l4r();var r2F=3;function H7m({job:e,taskId:t,taskHandler:r,context:i}){let n=0,a=async()=>{let u=await W7m.remoteGen.getJobStatus(e.jobId);if(u.ok)return u.body[t];i.logger.debug("Failed to get job status.",JSON.stringify(u.error.content))};return new Promise((u,l)=>{f();async function f(){try{let s=await a();if(s==null)n++,n===r2F&&i.failAndThrow(`Failed to get job status after ${n} attempts.`),setTimeout(f,2e3+1e3*n);else{n=0;let o=await r.processUpdate(s);r.isFinished?u(o):setTimeout(f,2e3)}}catch(s){l(s)}}})}async function $7m({projectConfig:e,organization:t,workspace:r,interactiveTaskContext:i,generatorInvocation:n,version:a,audiences:u,shouldLogS3Url:l,token:f,whitelabel:s,irVersionOverride:o,absolutePathToPreview:c,readme:b}){let g=HPi({token:f.value}),O=j0.getPackageName({generatorInvocation:n}),m=b2({workspace:r,generationLanguage:n.language,keywords:n.keywords,smartCasing:n.smartCasing,exampleGeneration:{disabled:n.disableExamples,skipAutogenerationIfManualExamplesExist:!0},audiences:u,readme:b,packageName:O,version:a??await n2F({fdr:g,packageName:O,generatorInvocation:n}),context:i,sourceResolver:new y2(i,r)}),w=r.getSources(),A=Xwe({ir:m,snippetsConfig:{typescriptSdk:void 0,pythonSdk:void 0,javaSdk:void 0,rubySdk:void 0,goSdk:void 0}}),M=await g.api.v1.register.registerApiDefinition({orgId:fWl.FernRegistry.OrgId(t),apiId:fWl.FernRegistry.ApiId(m.apiName.originalName),definition:A,sources:w.length>0?a2F(w):void 0}),q,D;M.ok&&(q=M.body.apiDefinitionId,D=M.body.sources);let C=new YRu(i,w);if(D==null&&C.sourceTypes.has("protobuf")&&(M.ok||i.failAndThrow(`Failed to register API definition: ${JSON.stringify(M.error.content)}`),i.failAndThrow("Did not successfully upload Protobuf source files.")),D!=null){i.logger.debug("Uploading source files ...");let J=await C.uploadSources(D);i.logger.debug("Setting IR source configuration ..."),m.sourceConfig=J}let R=c!=null,$=J=>wen(J,{onError:ee=>i.failAndThrow(ee)},{substituteAsEmpty:R}),I=$(n),U=await U7m({projectConfig:e,workspace:r,organization:t,generatorInvocation:I,context:i,version:a,intermediateRepresentation:{...m,fdrApiDefinitionId:q,publishConfig:i2F({generatorInvocation:I})},shouldLogS3Url:l,token:f,whitelabel:s!=null?$(s):void 0,irVersionOverride:o,absolutePathToPreview:c});i.logger.debug(`Job ID: ${U.jobId}`);let H=U.taskIds[0];if(H==null){i.failAndThrow("Did not receive a task ID.");return}i.logger.debug(`Task ID: ${H}`);let te=new JRu({job:U,taskId:H,generatorInvocation:n,interactiveTaskContext:i,absolutePathToPreview:c});return await H7m({job:U,taskHandler:te,taskId:H,context:i})}function i2F({generatorInvocation:e}){return e.outputMode._visit({downloadFiles:()=>{},github:()=>{},githubV2:()=>{},publish:()=>{},publishV2:t=>t._visit({mavenOverride:()=>{},pypiOverride:()=>{},nugetOverride:()=>{},npmOverride:()=>{},rubyGemsOverride:()=>{},postman:r=>{let i;return e.raw?.output?.location==="postman"&&(i=e.raw.output?.["collection-id"]),Bc.PublishingConfig.direct({target:Bc.PublishTarget.postman({apiKey:r.apiKey,workspaceId:r.workspaceId,collectionId:i})})},_other:()=>{}}),_other:()=>{}})}async function n2F({fdr:e,packageName:t,generatorInvocation:r}){if(r.language==null)return;let i;switch(r.language){case"csharp":i="Csharp";break;case"go":i="Go";break;case"java":i="Java";break;case"python":i="Python";break;case"ruby":i="Ruby";break;case"typescript":i="TypeScript";break;default:return}if(t==null)return;let n=await e.sdks.versions.computeSemanticVersion({githubRepository:r.outputMode.type==="githubV2"?`${r.outputMode.githubV2.owner}/${r.outputMode.githubV2.repo}`:void 0,language:i,package:t});if(n.ok)return n.body.version}function a2F(e){return Object.fromEntries(Object.values(e).map(t=>[t.id,{type:t.type==="protobuf"?"proto":t.type}]))}async function dWl({projectConfig:e,organization:t,workspace:r,context:i,generatorGroup:n,version:a,shouldLogS3Url:u,token:l,whitelabel:f,absolutePathToPreview:s,mode:o}){if(n.generators.length===0)return i.logger.warn("No generators specified."),null;let c=[],b=[];return c.push(...n.generators.map(O=>i.runInteractiveTask({name:O.name},async m=>{let w=await r.toFernWorkspace({context:i},ydn(O)),A=await $7m({projectConfig:e,organization:t,workspace:w,interactiveTaskContext:m,generatorInvocation:{...O,outputMode:O.outputMode._visit({downloadFiles:()=>O.outputMode,github:M=>ZRu.FernFiddle.OutputMode.github({...M,makePr:o==="pull-request"}),githubV2:M=>o==="pull-request"?ZRu.FernFiddle.OutputMode.githubV2(ZRu.FernFiddle.GithubOutputModeV2.pullRequest(M)):O.outputMode,publish:()=>O.outputMode,publishV2:()=>O.outputMode,_other:()=>O.outputMode})},version:a,audiences:n.audiences,shouldLogS3Url:u,token:l,whitelabel:f,readme:O.readme,irVersionOverride:O.irVersionOverride,absolutePathToPreview:s});A!=null&&A.createdSnippets&&(b.push(O),O.absolutePathToLocalSnippets!=null&&A.snippetsS3PreSignedReadUrl!=null&&await A7m({snippetsS3PreSignedReadUrl:A.snippetsS3PreSignedReadUrl,absolutePathToLocalSnippetJSON:O.absolutePathToLocalSnippets,context:m}))}))),(await Promise.all(c)).some(O=>!O)&&i.failAndThrow(),{snippetsProducedBy:b}}var I2m=require("fs/promises");var TWl=Di(uen(),1);var _Nt=Di(twe(),1);var A2m=Di(E2m(),1);var M2m=require("util");var R6F=(0,M2m.promisify)(A2m.default);async function q2m(e,t,r){let i=rUn(e,t),n=[];for(let a of i){let u=await Promise.all(a.map(async l=>{try{let f=await R6F(l);return f==null||f.height==null||f.width==null?void 0:{filePath:l,width:f.width,height:f.height,blurDataUrl:void 0}}catch(f){r.logger.error(`Failed to measure image size for ${l}. ${f?.message}`);return}}));n.push(...u.filter(dg))}return new Map(n.map(a=>[a.filePath,a]))}var F6F=10,T2m=10;async function z2m({token:e,organization:t,docsWorkspace:r,domain:i,customDomains:n,fernWorkspaces:a,ossWorkspaces:u,context:l,preview:f,editThisPage:s,isPrivate:o=!1}){let c=HPi({token:e.value}),b=o?{type:"private",authType:"sso"}:{type:"public"},g,O=n[0]??i,m=N6F(i),A=await new v6t(i,r,u,a,l,s,async q=>{let D=new Map(q.map(H=>[H.absoluteFilePath,H])),R=q.map(H=>({...H,mediaType:TWl.lookup(H.absoluteFilePath)})).filter(H=>H.mediaType!==!1).filter(H=>aB.parse(H.mediaType)?.isImage()??!1).map(H=>H.absoluteFilePath),$=await q2m(R,F6F,l),I=[];[...$.values()].forEach(H=>{let te=D.get(H.filePath);if(te==null)return;let J={filePath:_Nt.FernRegistry.docs.v1.write.FilePath(R4a(te.relativeFilePath)),width:H.width,height:H.height,blurDataUrl:H.blurDataUrl,alt:void 0};I.push(J)});let U=q.filter(({absoluteFilePath:H})=>!$.has(H)).map(({relativeFilePath:H})=>R4a(H));if(f){let H=await c.docs.v2.write.startDocsPreviewRegister({orgId:_Nt.FernRegistry.OrgId(t),authConfig:o?{type:"private",authType:"sso"}:{type:"public"},filepaths:U.map(te=>_Nt.FernRegistry.docs.v1.write.FilePath(te)),images:I,basePath:m});return H.ok?(O=H.body.previewUrl,g=H.body.docsRegistrationId,await C2m(H.body.uploadUrls,r.absoluteFilePath,l,T2m),B2m(H.body.uploadUrls,r.absoluteFilePath)):await x2m(H.error,l)}else{let H=await c.docs.v2.write.startDocsRegister({domain:i,customDomains:n,authConfig:b,apiId:_Nt.FernRegistry.ApiId(""),orgId:_Nt.FernRegistry.OrgId(t),filepaths:U.map(te=>_Nt.FernRegistry.docs.v1.write.FilePath(te)),images:I});return H.ok?(g=H.body.docsRegistrationId,await C2m(H.body.uploadUrls,r.absoluteFilePath,l,T2m),B2m(H.body.uploadUrls,r.absoluteFilePath)):x2m(H.error,l)}},async({ir:q,snippetsConfig:D,playgroundConfig:C,apiName:R})=>{let $=Xwe({ir:q,snippetsConfig:D,playgroundConfig:C}),I=await c.api.v1.register.registerApiDefinition({orgId:_Nt.FernRegistry.OrgId(t),apiId:_Nt.FernRegistry.ApiId(q.apiName.originalName),definition:$,definitionV2:void 0});if(I.ok)return l.logger.debug(`Registered API Definition ${I.body.apiDefinitionId}`),I.body.apiDefinitionId;switch(I.error.error){case"UnauthorizedError":case"UserNotInOrgError":return l.failAndThrow("You do not have permissions to register the docs. Reach out to support@buildwithfern.com");default:return R!=null?l.failAndThrow(`Failed to publish docs because API definition (${R}) could not be uploaded. Please contact support@buildwithfern.com
1987
1987
  ${I.error}`):l.failAndThrow(`Failed to publish docs because API definition could not be uploaded. Please contact support@buildwithfern.com
1988
1988
  ${I.error}`)}},async({api:q,apiName:D})=>{let C=await c.api.v1.register.registerApiDefinition({orgId:_Nt.FernRegistry.OrgId(t),apiId:_Nt.FernRegistry.ApiId(D??q.id),definition:void 0,definitionV2:q});if(C.ok)return l.logger.debug(`Registered API Definition ${C.body.apiDefinitionId}`),C.body.apiDefinitionId;switch(C.error.error){case"UnauthorizedError":case"UserNotInOrgError":return l.failAndThrow("You do not have permissions to register the docs. Reach out to support@buildwithfern.com");default:return D!=null?l.failAndThrow(`Failed to publish docs because API definition (${D}) could not be uploaded. Please contact support@buildwithfern.com
1989
1989
  ${JSON.stringify(C.error)}`):l.failAndThrow(`Failed to publish docs because API definition could not be uploaded. Please contact support@buildwithfern.com