fern-api 2.10.0 → 2.11.0

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 +3 -3
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -1152,7 +1152,7 @@ ${WUp.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&S9s(th
1152
1152
  `+xHi.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?xHi.default.cyan(ZUp(t,this.opt.mask)):xHi.default.italic(xHi.default.dim("[hidden]")):this.opt.mask?ZUp(t,this.opt.mask):xHi.default.italic(xHi.default.dim("[input is hidden] "))}getSpinningValue(t){return this.getMaskedValue(t)}filterInput(t){return t||(this.opt.default==null?"":this.opt.default)}onEnd(t){this.status="answered",this.answer=t.value,this.render(),this.screen.done(),this.done(t.value)}onError(t){this.render(t.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}};var v0o=ae(y1(),1);var Z4p=ae(sGs(),1),y0o=require("child_process"),rTn=require("fs"),h0o=ae(require("path"),1),k4p=ae(require("os"),1),e3p=require("crypto"),HGs=ae(Y4p(),1);var d0o=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var $ga=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var p0o=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var _0o=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function b0o(e="",t,r){let i=new KGs(e,r);i.runAsync((n,a)=>{if(n)setImmediate(t,n,void 0);else try{i.cleanup(),setImmediate(t,void 0,a)}catch(o){setImmediate(t,o,void 0)}})}function X4p(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function OgS(e){let t=[],r="";for(let i=0;i<e.length;i++){let n=e.charAt(i);i>0&&n===" "&&e[i-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${n}`}return r.length>0&&t.push(r),t}var KGs=class{text="";tempFile;editor;lastExitStatus=0;fileOptions={};get temp_file(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile}get last_exit_status(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus}constructor(t="",r){this.text=t,r&&(this.fileOptions=r),this.determineEditor(),this.createTemporaryFile()}run(){return this.launchEditor(),this.readTemporaryFile(),this.text}runAsync(t){try{this.launchEditorAsync(()=>{try{this.readTemporaryFile(),setImmediate(t,void 0,this.text)}catch(r){setImmediate(t,r,void 0)}})}catch(r){setImmediate(t,r,void 0)}}cleanup(){this.removeTemporaryFile()}determineEditor(){let t=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:process.platform.startsWith("win")?"notepad":"vim",r=OgS(t).map(n=>n.replace("\\ "," ")),i=r.shift();this.editor={args:r,bin:i}}createTemporaryFile(){try{let t=this.fileOptions.dir??k4p.default.tmpdir(),r=(0,e3p.randomUUID)(),i=X4p(this.fileOptions.prefix),n=X4p(this.fileOptions.postfix),a=`${i}${r}${n}`,o=h0o.default.resolve(t,a),c=h0o.default.resolve(t)+h0o.default.sep;if(!o.startsWith(c))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=o;let f={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(f.mode=this.fileOptions.mode),(0,rTn.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new d0o(t)}}readTemporaryFile(){try{let t=(0,rTn.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,Z4p.detect)(t)??"utf8";HGs.default.encodingExists(r)||(r="utf8"),this.text=HGs.default.decode(t,r)}}catch(t){throw new p0o(t)}}removeTemporaryFile(){try{(0,rTn.unlinkSync)(this.tempFile)}catch(t){throw new _0o(t)}}launchEditor(){try{let t=(0,y0o.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new $ga(t)}}launchEditorAsync(t){try{(0,y0o.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",i=>{this.lastExitStatus=i,setImmediate(t)})}catch(r){throw new $ga(r)}}};var t3p=ae(Z_e(),1);var Yga=class extends b1{_run(t){this.done=t,this.editorResult=new t3p.Subject;let r=qQ(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"?v0o.default.dim("Received"):v0o.default.dim("Press <enter> to launch your preferred editor."),t&&(r=v0o.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),b0o(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 o3p=require("stream");var n3p=ae(require("readline"),1),a3p=ae(i3p(),1),JHi=class{constructor(t){this.rl||=n3p.default.createInterface(mgS(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 mgS(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 a3p.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var Xga=class extends JHi{constructor(t={}){super(t),this.log=new o3p.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return Tga(this.rl,this.bottomBar.split(`
1153
1153
  `).length),this}updateBottomBar(t){return Tga(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+`
1154
1154
  `}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&&Umo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var dO=ae(Z_e(),1),c3p=ae(tga(),1);var g0o=ae(Z_e(),1),u3p=ae(tga(),1),O0o=function(e,t,r){return typeof e[t]!="function"?(0,g0o.of)(e):(0,g0o.from)((0,u3p.default)(e[t])(r).then(i=>(e[t]=i,e)))};var s3p={set:(e,t="",r)=>{let i=e;t.split(".").forEach((n,a,o)=>{n==="__proto__"||n==="constructor"||(a===o.length-1?i[n]=r:(!(n in i)||typeof i[n]!="object")&&(i[n]={}),i=i[n])})},get:(e,t="",r)=>{let i=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((o,c)=>o!=null?o[c]:o,e),n=i(/[,[\]]+?/)||i(/[,.[\]]+?/);return n===void 0||n===e?r:n}},iTn=class extends JHi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let i;return Array.isArray(t)?i=(0,dO.from)(t):(0,dO.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,dO.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,dO.from)([t]),this.process=i.pipe((0,dO.concatMap)(this.processQuestion.bind(this)),(0,dO.publish)()),this.process.connect(),this.process.pipe((0,dO.reduce)((n,a)=>(s3p.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,dO.defer)(()=>(0,dO.of)(t).pipe((0,dO.concatMap)(this.setDefaultType.bind(this)),(0,dO.concatMap)(this.filterIfRunnable.bind(this)),(0,dO.concatMap)(()=>O0o(t,"message",this.answers)),(0,dO.concatMap)(()=>O0o(t,"default",this.answers)),(0,dO.concatMap)(()=>O0o(t,"choices",this.answers)),(0,dO.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,dO.defer)(()=>(0,dO.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,dO.defer)(()=>(0,dO.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&s3p.get(this.answers,t.name)!==void 0)return dO.EMPTY;if(t.when===!1)return dO.EMPTY;if(typeof t.when!="function")return(0,dO.of)(t);let{answers:r}=this;return(0,dO.defer)(()=>(0,dO.from)((0,c3p.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,dO.filter)(i=>i!=null)))}};function l3p(e){let t=function(r,i){let n;try{n=new iTn(t.prompts,e)}catch(o){return Promise.reject(o)}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",zga),this.registerPrompt("input",WHi),this.registerPrompt("number",Nga),this.registerPrompt("confirm",Fga),this.registerPrompt("rawlist",Qga),this.registerPrompt("expand",Uga),this.registerPrompt("checkbox",Lga),this.registerPrompt("password",Vga),this.registerPrompt("editor",Yga)},t.restoreDefaultPrompts(),t}var $Gs=l3p();function jgS(e,t){$Gs.registerPrompt(e,t)}function wgS(){$Gs.restoreDefaultPrompts()}var EgS={prompt:$Gs,ui:{BottomBar:Xga,Prompt:iTn},createPromptModule:l3p,registerPrompt:jgS,restoreDefaultPrompts:wgS,Separator:w6},A0o=EgS;var yTn=require("path"),WLp=require("fs"),xLp=require("readline"),_Lp="posthog-node";function kAS(e,{organization:t,projectId:r,prefix:i,severityAllowList:n=["error"]}={}){return a=>{if(!(n==="*"||n.includes(a.level)))return a;a.tags||(a.tags={});let c=a.tags[L0o.POSTHOG_ID_TAG];if(c===void 0)return a;let f=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${c}`,f).toString();a.tags["PostHog Person URL"]=s;let u=a.exception?.values||[],l=u.map(_=>({..._,stacktrace:_.stacktrace?{..._.stacktrace,type:"raw",frames:(_.stacktrace.frames||[]).map(h=>({...h,platform:"node:javascript"}))}:void 0})),p={$exception_message:u[0]?.value||a.message,$exception_type:u[0]?.type,$exception_personURL:s,$exception_level:a.level,$exception_list:l,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:u[0]?.value||a.message,$sentry_exception_type:u[0]?.type,$sentry_tags:a.tags};return t&&r&&(p.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:p}),a}}var L0o=class{constructor(t,r,i,n){this.name=_Lp,this.name=_Lp,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(kAS(t,{organization:r,projectId:c,prefix:i,severityAllowList:n}))}}};L0o.POSTHOG_ID_TAG="posthog_distinct_id";var z0o="0123456789abcdef",V0o=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+=z0o.charAt(this.bytes[r]>>>4),t+=z0o.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+=z0o.charAt(this.bytes[r]>>>4),t+=z0o.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}},q7s=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??emS()}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 V0o.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,V0o.ofInner(t)}},emS=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),hLp,T7s=()=>tmS().toString(),tmS=()=>(hLp||(hLp=new q7s)).generate();function rmS(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function imS(e,t){global.process.on("uncaughtException",rmS(e,t))}function nmS(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var N0o,yLp,F0o;function amS(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return F0o&&r.length===yLp||(yLp=r.length,F0o=r.reduce((i,n)=>{N0o||(N0o={});let a=N0o[n];if(a)i[a[0]]=a[1];else{let o=e(n);for(let c=o.length-1;c>=0;c--){let s=o[c]?.filename,u=t[n];if(s&&u){i[s]=u,N0o[n]=[s,u];break}}}return i},{})),F0o}function omS(e){return typeof Event<"u"&&GLp(e,Event)}function umS(e){return HLp(e,"Object")}function V7s(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return GLp(e,Error)}}function GLp(e,t){try{return e instanceof t}catch{return!1}}function smS(e){return HLp(e,"ErrorEvent")}function HLp(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function cmS(e,t,r,i){let a=i&&i.mechanism||{handled:!0,type:"generic"},o=KLp(a,r,i);return{$exception_list:await Promise.all(o.map(async s=>{let u=await ymS(e,t,s);return u.value=u.value||"",u.type=u.type||"Error",u.mechanism=a,u}))}}function KLp(e,t,r){let i=lmS(e,t,r);return i.cause?[i,...KLp(e,i.cause,r)]:[i]}function lmS(e,t,r){if(V7s(t))return t;if(e.synthetic=!0,umS(t)){let n=fmS(t);if(n)return n;let a=dmS(t),o=r?.syntheticException||new Error(a);return o.message=a,o}let i=r?.syntheticException||new Error(t);return i.message=`${t}`,i}function fmS(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(V7s(r))return r}}function dmS(e){if("name"in e&&typeof e.name=="string"){let i=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(i+=` with message '${e.message}'`),i}else if("message"in e&&typeof e.message=="string")return e.message;let t=_mS(e);if(smS(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=pmS(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function pmS(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function _mS(e,t=40){let r=Object.keys(hmS(e));r.sort();let i=r[0];if(!i)return"[object has no keys]";if(i.length>=t)return bLp(i,t);for(let n=r.length;n>0;n--){let a=r.slice(0,n).join(", ");if(!(a.length>t))return n===r.length?a:bLp(a,t)}return""}function bLp(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function hmS(e){return V7s(e)?{message:e.message,name:e.name,stack:e.stack,...vLp(e)}:omS(e)?{type:e.type,target:gLp(e.target),currentTarget:gLp(e.currentTarget),...vLp(e)}:e}function vLp(e){if(typeof e=="object"&&e!==null){let t={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}else return{}}function gLp(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function ymS(e,t,r){let i={type:r.name||r.constructor.name,value:r.message},n=bmS(e,r);for(let a of t)n=await a(n);return n.length&&(i.stacktrace={frames:n,type:"raw"}),i}function bmS(e,t){return vmS(e(t.stack||"",1),e)}function vmS(e,t){let r=amS(t);return e.forEach(i=>{i.filename&&(i.chunk_id=r[i.filename])}),e}var gmS=2e3,pTn=class e{static async captureException(t,r,i,n,a){let o={...a};n||(o.$process_person_profile=!1);let c=await cmS(this.stackParser,this.frameModifiers,r,i);t.capture({event:"$exception",distinctId:n||T7s(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(imS(this.onException.bind(this),this.onFatalError.bind(this)),nmS(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(gmS)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function OmS(e=process.argv[1]?(0,yTn.dirname)(process.argv[1]):process.cwd(),t=yTn.sep==="\\"){let r=t?OLp(e):e;return i=>{if(!i)return;let n=t?OLp(i):i,{dir:a,base:o,ext:c}=yTn.posix.parse(n);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,c.length*-1));let f=decodeURIComponent(o);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${f}`;if(a.startsWith(r)){let u=a.slice(r.length+1).replace(/\//g,".");return u?`${u}:${f}`:f}return f}}function OLp(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var W0o=class{constructor(t){this._maxSize=t,this._cache=new Map}get(t){let r=this._cache.get(t);if(r!==void 0)return this._cache.delete(t),this._cache.set(t,r),r}set(t,r){this._cache.set(t,r)}reduce(){for(;this._cache.size>=this._maxSize;){let t=this._cache.keys().next().value;t&&this._cache.delete(t)}}},U0o=new W0o(25),JLp=new W0o(20),W7s=7,AmS=1e3,mmS=1e4;async function PmS(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||SmS(o)||MmS(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(JLp.get(n))continue;let a=t[n];if(!a)continue;a.sort((f,s)=>f-s);let o=BmS(a);if(o.every(f=>DmS(n,f)))continue;let c=ImS(U0o,n,{});i.push(jmS(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&wmS(e,U0o),U0o.reduce(),e}function jmS(e,t,r){return new Promise(i=>{let n=(0,WLp.createReadStream)(e),a=(0,xLp.createInterface)({input:n});function o(){n.destroy(),i()}let c=0,f=0,s=t[f];if(s===void 0){o();return}let u=s[0],l=s[1];function p(){JLp.set(e,1),a.close(),a.removeAllListeners(),o()}n.on("error",p),a.on("error",p),a.on("close",o),a.on("line",_=>{if(c++,!(c<u)&&(r[c]=CmS(_,0),c>=l)){if(f===t.length-1){a.close(),a.removeAllListeners();return}f++;let h=t[f];if(h===void 0){a.close(),a.removeAllListeners();return}u=h[0],l=h[1]}})})}function wmS(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let i=t.get(r.filename);if(i===void 0)continue;EmS(r.lineno,r,i)}}function EmS(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=$Lp(e);n<e;n++){let a=r[n];if(a===void 0){ALp(t);return}t.pre_context.push(a)}if(r[e]===void 0){ALp(t);return}t.context_line=r[e];let i=YLp(e);t.post_context=[];for(let n=e+1;n<=i;n++){let a=r[n];if(a===void 0)break;t.post_context.push(a)}}function ALp(e){delete e.pre_context,delete e.context_line,delete e.post_context}function SmS(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function MmS(e){return e.lineno!==void 0&&e.lineno>mmS||e.colno!==void 0&&e.colno>AmS}function DmS(e,t){let r=U0o.get(e);if(r===void 0)return!1;for(let i=t[0];i<=t[1];i++)if(r[i]===void 0)return!1;return!0}function BmS(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=mLp(r),n=[];for(;;){if(t===e.length-1){n.push(i);break}let a=e[t+1];if(typeof a!="number")break;a<=i[1]?i[1]=a+W7s:(n.push(i),i=mLp(a)),t++}return n}function mLp(e){return[$Lp(e),YLp(e)]}function $Lp(e){return Math.max(1,e-W7s)}function YLp(e){return e+W7s}function ImS(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function CmS(e,t){let r=e,i=r.length;if(i<=150)return r;t>i&&(t=i);let n=Math.max(t-60,0);n<5&&(n=0);let a=Math.min(n+140,i);return a>i-5&&(a=i),a===i&&(n=Math.max(a-140,0)),r=r.slice(n,a),n>0&&(r=`...${r}`),a<i&&(r+="..."),r}var qmS="4.18.0",B6;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.DecideEndpointWasHit="decide_endpoint_was_hit",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config"})(B6||(B6={}));var PLp;(function(e){e.Left="left",e.Right="right",e.Center="center"})(PLp||(PLp={}));var jLp;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(jLp||(jLp={}));var wLp;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(wLp||(wLp={}));var ELp;(function(e){e.Html="html",e.Text="text"})(ELp||(ELp={}));var SLp;(function(e){e.Number="number",e.Emoji="emoji"})(SLp||(SLp={}));var MLp;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(MLp||(MLp={}));var DLp;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(DLp||(DLp={}));var BLp;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(BLp||(BLp={}));var ILp;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(ILp||(ILp={}));var TmS=e=>{if("flags"in e){let t=zmS(e.flags),r=NmS(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,XLp(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,RmS(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function RmS(e,t,r){return{key:e,enabled:typeof t=="string"?!0:t,variant:typeof t=="string"?t:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:r?JSON.stringify(r):void 0,description:void 0}}}var zmS=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,x7s(r)]).filter(([,t])=>t!==void 0)),NmS=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let i=t[r];return i.enabled&&i.metadata&&i.metadata.payload!==void 0}).map(r=>{let i=t[r].metadata?.payload;return[r,i?XLp(i):void 0]}))},x7s=e=>e===void 0?void 0:e.variant??e.enabled,XLp=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},FmS=1,QmS=new Set(["61be3dd8","96f6df5f","8cfdba9b","bf027177","e59430a8","7fa5500b","569798e9","04809ff7","0ebc61a5","32de7f98","3beeb69a","12d34ad9","733853ec","0645bb64","5dcbee21","b1f95fa3","2189e408","82b460c2","3a8cc979","29ef8843","2cdbf767","38084b54","50f9f8de","41d0df91","5c236689","c11aedd3","ada46672","f4331ee1","42fed62a","c957462c","d62f705a","e0162666","01b3e5cf","441cef7f","bb9cafee","8f348eb0","b2553f3a","97469d7d","39f21a76","03706dcc","27d50569","307584a7","6433e92e","150c7fbb","49f57f22","3772f65b","01eb8256","3c9e9234","f853c7f7","c0ac4b67","cd609d40","10ca9b1a","8a87f11b","8e8e5216","1f6b63b3","db7943dd","79b7164c","07f78e33","2d21b6fd","952db5ee","a7d3b43f","1924dd9c","84e1b8f6","dff631b6","c5aa8a79","fa133a95","498a4508","24748755","98f3d658","21bbda67","7dbfed69","be3ec24c","fc80b8e2","75cc0998"]),UmS="utf8";function LmS(e,t){if(!e||typeof e!="string"||VmS(e))throw new Error(t)}function VmS(e){return e.trim().length===0}function WmS(e){return e?.replace(/\/+$/,"")}async function xmS(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 CLp(){return new Date().getTime()}function I7s(){return new Date().toISOString()}function x0o(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function GmS(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function HmS(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16).padStart(8,"0")}function KmS(e,t=0,r){let i=HmS(e);return r?.has(i)?!1:parseInt(i,16)/4294967295<t}function qLp(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var uOa=String.fromCharCode,TLp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Q0o={};function JmS(e,t){if(!Q0o[e]){Q0o[e]={};for(let r=0;r<e.length;r++)Q0o[e][e.charAt(r)]=r}return Q0o[e][t]}var fTn={compressToBase64:function(e){if(e==null)return"";let t=fTn._compress(e,6,function(r){return TLp.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:fTn._decompress(e.length,32,function(t){return JmS(TLp,e.charAt(t))})},compress:function(e){return fTn._compress(e,16,function(t){return uOa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],o,c,f="",s="",u="",l=2,p=3,_=2,h=0,y=0,b;for(b=0;b<e.length;b+=1)if(f=e.charAt(b),Object.prototype.hasOwnProperty.call(i,f)||(i[f]=p++,n[f]=!0),s=u+f,Object.prototype.hasOwnProperty.call(i,s))u=s;else{if(Object.prototype.hasOwnProperty.call(n,u)){if(u.charCodeAt(0)<256){for(o=0;o<_;o++)h=h<<1,y==t-1?(y=0,a.push(r(h)),h=0):y++;for(c=u.charCodeAt(0),o=0;o<8;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}else{for(c=1,o=0;o<_;o++)h=h<<1|c,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}l--,l==0&&(l=Math.pow(2,_),_++),delete n[u]}else for(c=i[u],o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;l--,l==0&&(l=Math.pow(2,_),_++),i[s]=p++,u=String(f)}if(u!==""){if(Object.prototype.hasOwnProperty.call(n,u)){if(u.charCodeAt(0)<256){for(o=0;o<_;o++)h=h<<1,y==t-1?(y=0,a.push(r(h)),h=0):y++;for(c=u.charCodeAt(0),o=0;o<8;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}else{for(c=1,o=0;o<_;o++)h=h<<1|c,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}l--,l==0&&(l=Math.pow(2,_),_++),delete n[u]}else for(c=i[u],o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;l--,l==0&&(l=Math.pow(2,_),_++)}for(c=2,o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;for(;;)if(h=h<<1,y==t-1){a.push(r(h));break}else y++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:fTn._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},o=4,c=4,f=3,s="",u,l,p,_,h,y,b;for(u=0;u<3;u+=1)i[u]=u;for(p=0,h=Math.pow(2,2),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;switch(p){case 0:for(p=0,h=Math.pow(2,8),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;b=uOa(p);break;case 1:for(p=0,h=Math.pow(2,16),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;b=uOa(p);break;case 2:return""}for(i[3]=b,l=b,n.push(b);;){if(a.index>e)return"";for(p=0,h=Math.pow(2,f),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;switch(b=p){case 0:for(p=0,h=Math.pow(2,8),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;i[c++]=uOa(p),b=c-1,o--;break;case 1:for(p=0,h=Math.pow(2,16),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;i[c++]=uOa(p),b=c-1,o--;break;case 2:return n.join("")}if(o==0&&(o=Math.pow(2,f),f++),i[b])s=i[b];else if(b===c)s=l+l.charAt(0);else return null;n.push(s),i[c++]=l+s.charAt(0),o--,l=s,o==0&&(o=Math.pow(2,f),f++)}}},R7s=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)}},_Tn=class extends Error{constructor(t,r){super("HTTP error while fetching PostHog: status="+t.status+", reqByteLength="+r),this.response=t,this.reqByteLength=r,this.name="PostHogFetchHttpError"}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}},sOa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function RLp(e){if(e instanceof _Tn){let t="";try{t=await e.text}catch{}console.error(`Error while flushing PostHog: message=${e.message}, response body=${t}`,e)}else console.error("Error while flushing PostHog",e);return Promise.resolve()}function C7s(e){return typeof e=="object"&&(e instanceof _Tn||e instanceof sOa)}function zLp(e){return typeof e=="object"&&e instanceof _Tn&&e.status===413}var z7s;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(z7s||(z7s={}));var N7s=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new R7s,this._isInitialized=!1,LmS(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=WmS(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.preloadFeatureFlags=r?.preloadFeatureFlags??!0,this.defaultOptIn=r?.defaultOptIn??!0,this.disableSurveys=r?.disableSurveys??!1,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:C7s},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=r?.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(B6.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(B6.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(B6.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=T7s();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}async identifyStatelessImmediate(t,r,i){let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",n,i)}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}async captureStatelessImmediate(t,r,i,n){let a=this.buildPayload({distinct_id:t,event:r,properties:i});await this.sendImmediate("capture",a,n)}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}async aliasStatelessImmediate(t,r,i,n){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,n)}groupIdentifyStateless(t,r,i,n,a,o){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...o||{}}});this.enqueue("capture",c,n)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,i,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(n=>n.json()).catch(n=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",n)),this._events.emit("error",n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let c=KmS(this.apiKey,FmS,QmS)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",c)),this.fetchWithRetry(c,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(s=>s.json()).then(s=>TmS(s)).catch(s=>{this._events.emit("error",s)})}async getFeatureFlagStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,i,n,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let f=x7s(c.response);return f===void 0&&(f=!1),{response:f,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,i,n,a,o,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,i,n,a,o,[t]);if(!c)return;let f=c[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a,o){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)).payloads}async getFeatureFlagsStateless(t,r={},i={},n={},a,o){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a,o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,i,n,a,o);return c?{flags:c.featureFlags,payloads:c.featureFlagPayloads,requestId:c.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},i={},n={},a,o){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),o&&(c.flag_keys_to_evaluate=o);let f=await this.getDecide(t,r,i,n,c);if(f!==void 0)return f.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),f.quotaLimited?.includes(z7s.FeatureFlags)?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:f?.requestId}):f}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this.logMsgIfDebug(()=>console.log("PostHog Debug","Loading surveys is disabled.")),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},n=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let o=`Surveys API could not be loaded: ${a.status}`,c=new Error(o);this.logMsgIfDebug(()=>console.error(c)),this._events.emit("error",new Error(o));return}return a.json()}).catch(a=>{this.logMsgIfDebug(()=>console.error("Surveys API could not be loaded",a)),this._events.emit("error",a)}))?.surveys;return n&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(n))),n??[]}get props(){return this._props||(this._props=this.getPersistedProperty(B6.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(B6.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(B6.Props,this.props)})}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n=this.prepareMessage(t,r,i),a=this.getPersistedProperty(B6.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:n}),this.setPersistedProperty(B6.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=x0o(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,i){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized||await this._initPromise,this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={api_key:this.apiKey,batch:[this.prepareMessage(t,r,i)],sent_at:I7s()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${CLp()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,c=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(fTn.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(o,c)}catch(f){this._events.emit("error",f)}}prepareMessage(t,r,i){let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:I7s(),uuid:i?.uuid?i.uuid:T7s()};return(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId),n}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await RLp(t)})}async flush(){let t=qLp([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),qLp([t]).then(()=>{this.flushPromise===t&&(this.flushPromise=null)}),t}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(B6.Queue)||[];if(!t.length)return;let r=[],i=t.length;for(;t.length>0&&r.length<i;){let n=t.slice(0,this.maxBatchSize),a=n.map(p=>p.message),o=()=>{let _=(this.getPersistedProperty(B6.Queue)||[]).slice(n.length);this.setPersistedProperty(B6.Queue,_),t=_},c={api_key:this.apiKey,batch:a,sent_at:I7s()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${CLp()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,u=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(fTn.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:p=>zLp(p)?!1:C7s(p)};try{await this.fetchWithRetry(s,u,l)}catch(p){if(zLp(p)&&a.length>1){this.maxBatchSize=Math.max(1,Math.floor(a.length/2)),this.logMsgIfDebug(()=>console.warn(`Received 413 when sending batch of size ${a.length}, reducing batch size to ${this.maxBatchSize}`));continue}throw p instanceof sOa||o(),this._events.emit("error",p),p}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,i,n){var a;(a=AbortSignal).timeout??(a.timeout=function(s){let u=new AbortController;return setTimeout(()=>u.abort(),s),u.signal});let o=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(o,UmS)}catch{c=new TextEncoder().encode(o).length}return await xmS(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(u){throw new sOa(u)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new _Tn(f,c);return f},{...this._retryOptions,...i})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let i=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(B6.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!C7s(n))throw n;await RLp(n)}};return Promise.race([new Promise((n,a)=>{x0o(()=>{this.logMsgIfDebug(()=>console.error("Timed out while shutting down PostHog")),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),i()])}async shutdown(t=3e4){return this.shutdownPromise?this.logMsgIfDebug(()=>console.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup")):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}},F7s=GmS();if(!F7s){let e=pLp();F7s=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 ZLp=F7s,G0o=class{constructor(t){this.factory=t}async getValue(){return this.value!==void 0?this.value:(this.initializationPromise===void 0&&(this.initializationPromise=(async()=>{try{let t=await this.factory();return this.value=t,t}finally{this.initializationPromise=void 0}})()),this.initializationPromise)}isInitialized(){return this.value!==void 0}async waitForInitialization(){this.isInitialized()||await this.getValue()}},kLp=new G0o(async()=>{try{return await import("crypto")}catch{return}});async function $mS(){return await kLp.getValue()}var YmS=new G0o(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await kLp.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function XmS(){return await YmS.getValue()}async function ZmS(e){let t=await $mS();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await XmS();if(r){let i=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(i)).map(a=>a.toString(16).padStart(2,"0")).join("")}throw new Error("No crypto implementation available. Tried Node Crypto API and Web SubtleCrypto API")}var kmS=60*1e3,e0S=1152921504606847e3,t0S=["is_not"],dTn=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},v1=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Q7s=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:o,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=c.fetch||ZLp,this.onError=c.onError,this.customHeaders=o,this.onLoad=c.onLoad,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;for(let f of this.featureFlags)if(t===f.key){c=f;break}if(c!==void 0)try{o=await this.computeFlagLocally(c,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(f){f instanceof v1?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 o}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={},o={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async f=>{try{let s=await this.computeFlagLocally(f,t,r,i,n);a[f.key]=s;let u=await this.computeFeatureFlagPayloadLocally(f.key,s);u&&(o[f.key]=u)}catch(s){s instanceof v1||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${s}`)),c=!0}})),{response:a,payloads:o,fallbackToDecide:c}}async computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new v1("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let f=this.groupTypeMapping[String(c)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new v1("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 await this.matchFeatureFlagProperties(t,i[f],s)}else return await this.matchFeatureFlagProperties(t,r,n)}async matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],o=!1,c,f=[...a].sort((s,u)=>{let l=!!s.variant,p=!!u.variant;return l&&p?0:l?-1:p?1:0});for(let s of f)try{if(await this.isConditionMatch(t,r,s,i)){let u=s.variant,l=n.multivariate?.variants||[];u&&l.some(p=>p.key===u)?c=u:c=await this.getMatchingVariant(t,r)||!0;break}}catch(u){if(u instanceof v1)o=!0;else throw u}if(c!==void 0)return c;if(o)throw new v1("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,i,n){let a=i.rollout_percentage,o=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((i.properties||[]).length>0){for(let c of i.properties){let f=c.type,s=!1;if(f==="cohort"?s=t8p(c,n,this.cohorts,this.debugMode):s=e8p(c,n,o),!s)return!1}if(a==null)return!0}return!(a!=null&&await NLp(t.key,r)>a/100)}async getMatchingVariant(t,r){let i=await NLp(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{n=i+c.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:c.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(kmS,this.pollingInterval*2**this.backOffCount):this.pollingInterval}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.getPollingInterval());try{let t=await this._requestFeatureFlagDefinitions();if(!t)return;switch(t.status){case 401:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new dTn(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new dTn(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new dTn(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let r=await t.json()??{};if(!("flags"in r)){this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`));return}this.featureFlags=r.flags??[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||{},this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof dTn&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET"){return{method:t,headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions(),i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=x0o(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,i=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;n=x0o(()=>{a.abort()},this.timeout),i.signal=a.signal}try{return this.fetch(r,i)}finally{clearTimeout(n)}}};async function NLp(e,t,r=""){let i=await ZmS(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/e0S}function e8p(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 v1("Operator is_not_set is not supported")}else throw new v1(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!t0S.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,u){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(u).toLowerCase()):String(s).toLowerCase()===String(u).toLowerCase()}function f(s,u,l){if(l==="gt")return s>u;if(l==="gte")return s>=u;if(l==="lt")return s<u;if(l==="lte")return s<=u;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(n,o);case"is_not":return!c(n,o);case"is_set":return i in t;case"icontains":return String(o).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(n).toLowerCase());case"regex":return FLp(String(n))&&String(o).match(String(n))!==null;case"not_regex":return FLp(String(n))&&String(o).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&&o!=null?typeof o=="string"?f(o,String(n),a):f(o,s,a):f(String(o),String(n),a)}case"is_date_after":case"is_date_before":{let s=r0S(String(n));if(s==null&&(s=QLp(n)),s==null)throw new v1(`Invalid date: ${n}`);let u=QLp(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new v1(`Unknown operator: ${a}`)}}function t8p(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new v1("can't match cohort without a given cohort property value");let a=r[n];return r8p(a,t,r,i)}function r8p(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let f=r8p(c,t,r,i);if(n==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof v1)i&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new v1("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let c of a)try{let f;c.type==="cohort"?f=t8p(c,t,r,i):f=e8p(c,t);let s=c.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 v1)i&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new v1("can't match cohort without a given cohort property value");return n==="AND"}}function FLp(e){try{return new RegExp(e),!0}catch{return!1}}function QLp(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 v1(`${e} is in an invalid date format`)}else throw new v1(`The date provided ${e} must be a string, number, or date object`)}function r0S(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 U7s=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},i0S=100,ULp=30*1e3,n0S=50*1e3,L7s=class extends N7s{constructor(t,r={}){if(super(t,r),this._memoryStorage=new U7s,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,i0S):ULp,r.personalApiKey){if(r.personalApiKey.includes("phc_"))throw new Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');this.featureFlagsPoller=new Q7s({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},onLoad:i=>{this._events.emit("localEvaluationFlagsLoaded",i)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new pTn(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||n0S}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):ZLp(t,r)}getLibraryVersion(){return qmS}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:s}=t,u=_=>{super.captureStateless(r,i,_,{timestamp:c,disableGeoip:f,uuid:s})},l=async(_,h,y)=>(await super.getFeatureFlagsStateless(_,h,void 0,void 0,y)).flags,p=Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let _={};for(let[h,y]of Object.entries(a||{}))_[h]=String(y);return await this.getAllFlags(r,{groups:_,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(_=>{let h={};if(_)for(let[b,v]of Object.entries(_))h[`$feature/${b}`]=v;let y=Object.keys(_||{}).filter(b=>_?.[b]!==!1).sort();return y.length>0&&(h.$active_feature_flags=y),h}).catch(()=>({})).then(_=>{u({..._,...n,$groups:a})});this.addPendingPromise(p)}async captureImmediate(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:s}=t,u=_=>super.captureStatelessImmediate(r,i,_,{timestamp:c,disableGeoip:f,uuid:s}),l=async(_,h,y)=>(await super.getFeatureFlagsStateless(_,h,void 0,void 0,y)).flags;await Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let _={};for(let[h,y]of Object.entries(a||{}))_[h]=String(y);return await this.getAllFlags(r,{groups:_,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(_=>{let h={};if(_)for(let[b,v]of Object.entries(_))h[`$feature/${b}`]=v;let y=Object.keys(_||{}).filter(b=>_?.[b]!==!1).sort();return y.length>0&&(h.$active_feature_flags=y),h}).catch(()=>({})).then(_=>{u({..._,...n,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:n},{disableGeoip:i})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=ULp){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let i=setTimeout(()=>{n(),r(!1)},t),n=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(i),n(),r(a>0)})})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:o,sendFeatureFlagEvents:c,personProperties:f,groupProperties:s}=i||{},u=this.addLocalPersonAndGroupProperties(r,n,f,s);f=u.allPersonProperties,s=u.allGroupProperties,o==null&&(o=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,f,s),p=l!==void 0,_,h;if(!p&&!o){let b=await super.getFeatureFlagDetailStateless(t,r,n,f,s,a);if(b===void 0)return;h=b.response,l=x7s(h),_=b?.requestId}let y=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(y))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(y):this.distinctIdHasSentFlagCalls[r]=[y],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:h?.metadata?.id,$feature_flag_version:h?.metadata?.version,$feature_flag_reason:h?.reason?.description??h?.reason?.code,locally_evaluated:p,[`$feature/${t}`]:l,$feature_flag_request_id:_},groups:n,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:o}=n||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:f,personProperties:s,groupProperties:u}=n||{},l=this.addLocalPersonAndGroupProperties(r,a,s,u);s=l.allPersonProperties,u=l.allGroupProperties;let p;return this.featureFlagsPoller!==void 0&&(i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),i&&(p=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i))),c==null&&(c=!1),f==null&&(f=!0),c==null&&(c=!1),!(p!==void 0)&&!c&&(p=await super.getFeatureFlagPayloadStateless(t,r,a,s,u,o)),p}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:c}=r||{},f=this.addLocalPersonAndGroupProperties(t,i,o,c);o=f.allPersonProperties,c=f.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,o,c),u={},l={},p=!0;if(s&&(u=s.response,l=s.payloads,p=s.fallbackToDecide),p&&!a){let _=await super.getFeatureFlagsAndPayloadsStateless(t,i,o,c,n);u={...u,..._.flags||{}},l={...l,..._.payloads||{}}}return{featureFlags:u,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...n?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,i){let n=new Error("PostHog syntheticException");pTn.captureException(this,t,{syntheticException:n},r,i)}},LLp=/\(error: (.*)\)/,i8p=50,n8p="?";function a0S(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return i=>{let n=i.match(r);if(n){let a,o,c,f,s;if(n[1]){c=n[1];let p=c.lastIndexOf(".");if(c[p-1]==="."&&p--,p>0){a=c.slice(0,p),o=c.slice(p+1);let _=a.indexOf(".Module");_>0&&(c=c.slice(_+1),a=a.slice(0,_))}f=void 0}o&&(f=a,s=o),o==="<anonymous>"&&(s=void 0,c=void 0),c===void 0&&(s=s||n8p,c=f?`${f}.${s}`:s);let u=n[2]?.startsWith("file://")?n[2].slice(7):n[2],l=n[5]==="native";return u?.match(/\/[A-Z]:/)&&(u=u.slice(1)),!u&&n[5]&&!l&&(u=n[5]),{filename:u?decodeURI(u):void 0,module:e?e(u):void 0,function:c,lineno:VLp(n[3]),colno:VLp(n[4]),in_app:o0S(u||"",l),platform:"node:javascript"}}if(i.match(t))return{filename:i,platform:"node:javascript"}}}function o0S(e,t=!1){return!(t||e&&!e.startsWith("/")&&!e.match(/^[A-Z]:/)&&!e.startsWith(".")&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&e!==void 0&&!e.includes("node_modules/")}function VLp(e){return parseInt(e||"",10)||void 0}function u0S(e){return[90,a0S(e)]}function s0S(e){let r=[u0S(e)].sort((i,n)=>i[0]-n[0]).map(i=>i[1]);return(i,n=0)=>{let a=[],o=i.split(`
1155
- `);for(let c=n;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let s=LLp.test(f)?f.replace(LLp,"$1"):f;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=i8p)break}}return c0S(a)}}function c0S(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,i8p).map(r=>({...r,filename:r.filename||l0S(t).filename,function:r.function||n8p}))}function l0S(e){return e[e.length-1]||{}}pTn.stackParser=s0S(OmS());pTn.frameModifiers=[PmS];var hTn=class extends L7s{getLibraryId(){return"posthog-node"}};var H0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new hTn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"2.10.0",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var cOa=class{async sendEvent(){}async identify(){}async flush(){}};var bTn=require("fs/promises"),s8p=require("os"),c8p=require("path");var a8p=ae(require("crypto")),J0o=new Uint8Array(256),K0o=J0o.length;function G7s(){return K0o>J0o.length-16&&(a8p.default.randomFillSync(J0o),K0o=0),J0o.slice(K0o,K0o+=16)}var RQ=[];for(let e=0;e<256;++e)RQ.push((e+256).toString(16).slice(1));function o8p(e,t=0){return RQ[e[t+0]]+RQ[e[t+1]]+RQ[e[t+2]]+RQ[e[t+3]]+"-"+RQ[e[t+4]]+RQ[e[t+5]]+"-"+RQ[e[t+6]]+RQ[e[t+7]]+"-"+RQ[e[t+8]]+RQ[e[t+9]]+"-"+RQ[e[t+10]]+RQ[e[t+11]]+RQ[e[t+12]]+RQ[e[t+13]]+RQ[e[t+14]]+RQ[e[t+15]]}var u8p=ae(require("crypto")),H7s={randomUUID:u8p.default.randomUUID};function f0S(e,t,r){if(H7s.randomUUID&&!t&&!e)return H7s.randomUUID();e=e||{};let i=e.random||(e.rng||G7s)();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 o8p(i)}var ehe=f0S;var d0S="id",p0S=".fern",lOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new hTn(r),this.userId=t==null?void 0:p8s(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:"2.10.0",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Ft(Lr.of((0,s8p.homedir)()),ke.of(p0S),ke.of(d0S));await Ri(t)||(await(0,bTn.mkdir)((0,c8p.dirname)(t),{recursive:!0}),await(0,bTn.writeFile)(t,ehe())),this.persistedDistinctId=(await(0,bTn.readFile)(t)).toString()}return this.persistedDistinctId}};var K7s;async function vTn(){return K7s==null&&(K7s=await _0S()),K7s}async function _0S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new cOa;let r=await fbo();return r!=null?new lOa({token:r,posthogApiKey:e}):await Aqn()!=null?new H0o({posthogApiKey:e}):new lOa({token:void 0,posthogApiKey:e})}catch{return new cOa}}function fOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:h0S}=Object.prototype,{getPrototypeOf:$7s}=Object,{iterator:Y0o,toStringTag:f8p}=Symbol,X0o=(e=>t=>{let r=h0S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),zNt=e=>(e=e.toLowerCase(),t=>X0o(t)===e),Z0o=e=>t=>typeof t===e,{isArray:OTn}=Array,gTn=Z0o("undefined");function dOa(e){return e!==null&&!gTn(e)&&e.constructor!==null&&!gTn(e.constructor)&&I6(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var d8p=zNt("ArrayBuffer");function y0S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&d8p(e.buffer),t}var b0S=Z0o("string"),I6=Z0o("function"),p8p=Z0o("number"),pOa=e=>e!==null&&typeof e=="object",v0S=e=>e===!0||e===!1,$0o=e=>{if(X0o(e)!=="object")return!1;let t=$7s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(f8p in e)&&!(Y0o in e)},g0S=e=>{if(!pOa(e)||dOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},O0S=zNt("Date"),A0S=zNt("File"),m0S=zNt("Blob"),P0S=zNt("FileList"),j0S=e=>pOa(e)&&I6(e.pipe),w0S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||I6(e.append)&&((t=X0o(e))==="formdata"||t==="object"&&I6(e.toString)&&e.toString()==="[object FormData]"))},E0S=zNt("URLSearchParams"),[S0S,M0S,D0S,B0S]=["ReadableStream","Request","Response","Headers"].map(zNt),I0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function _Oa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),OTn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(dOa(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(i=0;i<o;i++)c=a[i],t.call(null,e[c],c,e)}}function _8p(e,t){if(dOa(e))return null;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 e6i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,h8p=e=>!gTn(e)&&e!==e6i;function J7s(){let{caseless:e,skipUndefined:t}=h8p(this)&&this||{},r={},i=(n,a)=>{let o=e&&_8p(r,a)||a;$0o(r[o])&&$0o(n)?r[o]=J7s(r[o],n):$0o(n)?r[o]=J7s({},n):OTn(n)?r[o]=n.slice():(!t||!gTn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&_Oa(arguments[n],i);return r}var C0S=(e,t,r,{allOwnKeys:i}={})=>(_Oa(t,(n,a)=>{r&&I6(n)?e[a]=fOa(n,r):e[a]=n},{allOwnKeys:i}),e),q0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),T0S=(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)},R0S=(e,t,r,i)=>{let n,a,o,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)o=n[a],(!i||i(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&$7s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},z0S=(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},N0S=e=>{if(!e)return null;if(OTn(e))return e;let t=e.length;if(!p8p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},F0S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&$7s(Uint8Array)),Q0S=(e,t)=>{let i=(e&&e[Y0o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},U0S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},L0S=zNt("HTMLFormElement"),V0S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),l8p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),W0S=zNt("RegExp"),y8p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};_Oa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},x0S=e=>{y8p(e,(t,r)=>{if(I6(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(I6(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+"'")})}})},G0S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return OTn(e)?i(e):i(String(e).split(t)),r},H0S=()=>{},K0S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function J0S(e){return!!(e&&I6(e.append)&&e[f8p]==="FormData"&&e[Y0o])}var $0S=e=>{let t=new Array(10),r=(i,n)=>{if(pOa(i)){if(t.indexOf(i)>=0)return;if(dOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=OTn(i)?[]:{};return _Oa(i,(o,c)=>{let f=r(o,n+1);!gTn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},Y0S=zNt("AsyncFunction"),X0S=e=>e&&(pOa(e)||I6(e))&&I6(e.then)&&I6(e.catch),b8p=((e,t)=>e?setImmediate:t?((r,i)=>(e6i.addEventListener("message",({source:n,data:a})=>{n===e6i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),e6i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",I6(e6i.postMessage)),Z0S=typeof queueMicrotask<"u"?queueMicrotask.bind(e6i):typeof process<"u"&&process.nextTick||b8p,k0S=e=>e!=null&&I6(e[Y0o]),kt={isArray:OTn,isArrayBuffer:d8p,isBuffer:dOa,isFormData:w0S,isArrayBufferView:y0S,isString:b0S,isNumber:p8p,isBoolean:v0S,isObject:pOa,isPlainObject:$0o,isEmptyObject:g0S,isReadableStream:S0S,isRequest:M0S,isResponse:D0S,isHeaders:B0S,isUndefined:gTn,isDate:O0S,isFile:A0S,isBlob:m0S,isRegExp:W0S,isFunction:I6,isStream:j0S,isURLSearchParams:E0S,isTypedArray:F0S,isFileList:P0S,forEach:_Oa,merge:J7s,extend:C0S,trim:I0S,stripBOM:q0S,inherits:T0S,toFlatObject:R0S,kindOf:X0o,kindOfTest:zNt,endsWith:z0S,toArray:N0S,forEachEntry:Q0S,matchAll:U0S,isHTMLForm:L0S,hasOwnProperty:l8p,hasOwnProp:l8p,reduceDescriptors:y8p,freezeMethods:x0S,toObjectSet:G0S,toCamelCase:V0S,noop:H0S,toFiniteNumber:K0S,findKey:_8p,global:e6i,isContextDefined:h8p,isSpecCompliantForm:J0S,toJSONObject:$0S,isAsyncFn:Y0S,isThenable:X0S,setImmediate:b8p,asap:Z0S,isIterable:k0S};function ATn(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)}kt.inherits(ATn,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:kt.toJSONObject(this.config),code:this.code,status:this.status}}});var v8p=ATn.prototype,g8p={};["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=>{g8p[e]={value:e}});Object.defineProperties(ATn,g8p);Object.defineProperty(v8p,"isAxiosError",{value:!0});ATn.from=(e,t,r,i,n,a)=>{let o=Object.create(v8p);kt.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return ATn.call(o,c,f,r,i,n),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var ya=ATn;var O8p=ae(F7i(),1),k0o=O8p.default;function Y7s(e){return kt.isPlainObject(e)||kt.isArray(e)}function m8p(e){return kt.endsWith(e,"[]")?e.slice(0,-2):e}function A8p(e,t,r){return e?e.concat(t).map(function(n,a){return n=m8p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function ePS(e){return kt.isArray(e)&&!e.some(Y7s)}var tPS=kt.toFlatObject(kt,{},null,function(t){return/^is[A-Z]/.test(t)});function rPS(e,t,r){if(!kt.isObject(e))throw new TypeError("target must be an object");t=t||new(k0o||FormData),r=kt.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!kt.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&kt.isSpecCompliantForm(t);if(!kt.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(kt.isDate(h))return h.toISOString();if(kt.isBoolean(h))return h.toString();if(!f&&kt.isBlob(h))throw new ya("Blob is not supported. Use a Buffer instead.");return kt.isArrayBuffer(h)||kt.isTypedArray(h)?f&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,y,b){let v=h;if(h&&!b&&typeof h=="object"){if(kt.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(kt.isArray(h)&&ePS(h)||(kt.isFileList(h)||kt.endsWith(y,"[]"))&&(v=kt.toArray(h)))return y=m8p(y),v.forEach(function(A,g){!(kt.isUndefined(A)||A===null)&&t.append(o===!0?A8p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return Y7s(h)?!0:(t.append(A8p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(tPS,{defaultVisitor:u,convertValue:s,isVisitable:Y7s});function _(h,y){if(!kt.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),kt.forEach(h,function(v,O){(!(kt.isUndefined(v)||v===null)&&n.call(t,v,kt.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!kt.isObject(e))throw new TypeError("data must be an object");return _(e),t}var zBi=rPS;function P8p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function j8p(e,t){this._pairs=[],e&&zBi(e,this,t)}var w8p=j8p.prototype;w8p.append=function(t,r){this._pairs.push([t,r])};w8p.toString=function(t){let r=t?function(i){return t.call(this,i,P8p)}:P8p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var E8p=j8p;function iPS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function t6i(e,t,r){if(!t)return e;let i=r&&r.encode||iPS;kt.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=kt.isURLSearchParams(t)?t.toString():new E8p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var X7s=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){kt.forEach(this.handlers,function(i){i!==null&&t(i)})}},Z7s=X7s;var mTn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var B8p=ae(require("crypto"),1);var S8p=ae(require("url"),1),M8p=S8p.default.URLSearchParams;var k7s="abcdefghijklmnopqrstuvwxyz",D8p="0123456789",I8p={DIGIT:D8p,ALPHA:k7s,ALPHA_DIGIT:k7s+k7s.toUpperCase()+D8p},nPS=(e=16,t=I8p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);B8p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},C8p={isNode:!0,classes:{URLSearchParams:M8p,FormData:k0o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:I8p,generateString:nPS,protocols:["http","https","file","data"]};var rHs={};Kt(rHs,{hasBrowserEnv:()=>tHs,hasStandardBrowserEnv:()=>aPS,hasStandardBrowserWebWorkerEnv:()=>oPS,navigator:()=>eHs,origin:()=>uPS});var tHs=typeof window<"u"&&typeof document<"u",eHs=typeof navigator=="object"&&navigator||void 0,aPS=tHs&&(!eHs||["ReactNative","NativeScript","NS"].indexOf(eHs.product)<0),oPS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",uPS=tHs&&window.location.href||"http://localhost";var OA={...rHs,...C8p};function iHs(e,t){return zBi(e,new OA.classes.URLSearchParams,{visitor:function(r,i,n,a){return OA.isNode&&kt.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function sPS(e){return kt.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function cPS(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 lPS(e){function t(r,i,n,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&kt.isArray(n)?n.length:o,f?(kt.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!kt.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&kt.isArray(n[o])&&(n[o]=cPS(n[o])),!c)}if(kt.isFormData(e)&&kt.isFunction(e.entries)){let r={};return kt.forEachEntry(e,(i,n)=>{t(sPS(i),n,r,0)}),r}return null}var ePo=lPS;function fPS(e,t,r){if(kt.isString(e))try{return(t||JSON.parse)(e),kt.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var nHs={transitional:mTn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=kt.isObject(t);if(a&&kt.isHTMLForm(t)&&(t=new FormData(t)),kt.isFormData(t))return n?JSON.stringify(ePo(t)):t;if(kt.isArrayBuffer(t)||kt.isBuffer(t)||kt.isStream(t)||kt.isFile(t)||kt.isBlob(t)||kt.isReadableStream(t))return t;if(kt.isArrayBufferView(t))return t.buffer;if(kt.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return iHs(t,this.formSerializer).toString();if((c=kt.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return zBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),fPS(t)):t}],transformResponse:[function(t){let r=this.transitional||nHs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(kt.isResponse(t)||kt.isReadableStream(t))return t;if(t&&kt.isString(t)&&(i&&!this.responseType||n)){let o=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?ya.from(c,ya.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:OA.classes.FormData,Blob:OA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};kt.forEach(["delete","get","head","post","put","patch"],e=>{nHs.headers[e]={}});var PTn=nHs;var dPS=kt.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"]),q8p=e=>{let t={},r,i,n;return e&&e.split(`
1155
+ `);for(let c=n;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let s=LLp.test(f)?f.replace(LLp,"$1"):f;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=i8p)break}}return c0S(a)}}function c0S(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,i8p).map(r=>({...r,filename:r.filename||l0S(t).filename,function:r.function||n8p}))}function l0S(e){return e[e.length-1]||{}}pTn.stackParser=s0S(OmS());pTn.frameModifiers=[PmS];var hTn=class extends L7s{getLibraryId(){return"posthog-node"}};var H0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new hTn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"2.11.0",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var cOa=class{async sendEvent(){}async identify(){}async flush(){}};var bTn=require("fs/promises"),s8p=require("os"),c8p=require("path");var a8p=ae(require("crypto")),J0o=new Uint8Array(256),K0o=J0o.length;function G7s(){return K0o>J0o.length-16&&(a8p.default.randomFillSync(J0o),K0o=0),J0o.slice(K0o,K0o+=16)}var RQ=[];for(let e=0;e<256;++e)RQ.push((e+256).toString(16).slice(1));function o8p(e,t=0){return RQ[e[t+0]]+RQ[e[t+1]]+RQ[e[t+2]]+RQ[e[t+3]]+"-"+RQ[e[t+4]]+RQ[e[t+5]]+"-"+RQ[e[t+6]]+RQ[e[t+7]]+"-"+RQ[e[t+8]]+RQ[e[t+9]]+"-"+RQ[e[t+10]]+RQ[e[t+11]]+RQ[e[t+12]]+RQ[e[t+13]]+RQ[e[t+14]]+RQ[e[t+15]]}var u8p=ae(require("crypto")),H7s={randomUUID:u8p.default.randomUUID};function f0S(e,t,r){if(H7s.randomUUID&&!t&&!e)return H7s.randomUUID();e=e||{};let i=e.random||(e.rng||G7s)();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 o8p(i)}var ehe=f0S;var d0S="id",p0S=".fern",lOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new hTn(r),this.userId=t==null?void 0:p8s(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:"2.11.0",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Ft(Lr.of((0,s8p.homedir)()),ke.of(p0S),ke.of(d0S));await Ri(t)||(await(0,bTn.mkdir)((0,c8p.dirname)(t),{recursive:!0}),await(0,bTn.writeFile)(t,ehe())),this.persistedDistinctId=(await(0,bTn.readFile)(t)).toString()}return this.persistedDistinctId}};var K7s;async function vTn(){return K7s==null&&(K7s=await _0S()),K7s}async function _0S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new cOa;let r=await fbo();return r!=null?new lOa({token:r,posthogApiKey:e}):await Aqn()!=null?new H0o({posthogApiKey:e}):new lOa({token:void 0,posthogApiKey:e})}catch{return new cOa}}function fOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:h0S}=Object.prototype,{getPrototypeOf:$7s}=Object,{iterator:Y0o,toStringTag:f8p}=Symbol,X0o=(e=>t=>{let r=h0S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),zNt=e=>(e=e.toLowerCase(),t=>X0o(t)===e),Z0o=e=>t=>typeof t===e,{isArray:OTn}=Array,gTn=Z0o("undefined");function dOa(e){return e!==null&&!gTn(e)&&e.constructor!==null&&!gTn(e.constructor)&&I6(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var d8p=zNt("ArrayBuffer");function y0S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&d8p(e.buffer),t}var b0S=Z0o("string"),I6=Z0o("function"),p8p=Z0o("number"),pOa=e=>e!==null&&typeof e=="object",v0S=e=>e===!0||e===!1,$0o=e=>{if(X0o(e)!=="object")return!1;let t=$7s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(f8p in e)&&!(Y0o in e)},g0S=e=>{if(!pOa(e)||dOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},O0S=zNt("Date"),A0S=zNt("File"),m0S=zNt("Blob"),P0S=zNt("FileList"),j0S=e=>pOa(e)&&I6(e.pipe),w0S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||I6(e.append)&&((t=X0o(e))==="formdata"||t==="object"&&I6(e.toString)&&e.toString()==="[object FormData]"))},E0S=zNt("URLSearchParams"),[S0S,M0S,D0S,B0S]=["ReadableStream","Request","Response","Headers"].map(zNt),I0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function _Oa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),OTn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(dOa(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(i=0;i<o;i++)c=a[i],t.call(null,e[c],c,e)}}function _8p(e,t){if(dOa(e))return null;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 e6i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,h8p=e=>!gTn(e)&&e!==e6i;function J7s(){let{caseless:e,skipUndefined:t}=h8p(this)&&this||{},r={},i=(n,a)=>{let o=e&&_8p(r,a)||a;$0o(r[o])&&$0o(n)?r[o]=J7s(r[o],n):$0o(n)?r[o]=J7s({},n):OTn(n)?r[o]=n.slice():(!t||!gTn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&_Oa(arguments[n],i);return r}var C0S=(e,t,r,{allOwnKeys:i}={})=>(_Oa(t,(n,a)=>{r&&I6(n)?e[a]=fOa(n,r):e[a]=n},{allOwnKeys:i}),e),q0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),T0S=(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)},R0S=(e,t,r,i)=>{let n,a,o,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)o=n[a],(!i||i(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&$7s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},z0S=(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},N0S=e=>{if(!e)return null;if(OTn(e))return e;let t=e.length;if(!p8p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},F0S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&$7s(Uint8Array)),Q0S=(e,t)=>{let i=(e&&e[Y0o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},U0S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},L0S=zNt("HTMLFormElement"),V0S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),l8p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),W0S=zNt("RegExp"),y8p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};_Oa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},x0S=e=>{y8p(e,(t,r)=>{if(I6(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(I6(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+"'")})}})},G0S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return OTn(e)?i(e):i(String(e).split(t)),r},H0S=()=>{},K0S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function J0S(e){return!!(e&&I6(e.append)&&e[f8p]==="FormData"&&e[Y0o])}var $0S=e=>{let t=new Array(10),r=(i,n)=>{if(pOa(i)){if(t.indexOf(i)>=0)return;if(dOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=OTn(i)?[]:{};return _Oa(i,(o,c)=>{let f=r(o,n+1);!gTn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},Y0S=zNt("AsyncFunction"),X0S=e=>e&&(pOa(e)||I6(e))&&I6(e.then)&&I6(e.catch),b8p=((e,t)=>e?setImmediate:t?((r,i)=>(e6i.addEventListener("message",({source:n,data:a})=>{n===e6i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),e6i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",I6(e6i.postMessage)),Z0S=typeof queueMicrotask<"u"?queueMicrotask.bind(e6i):typeof process<"u"&&process.nextTick||b8p,k0S=e=>e!=null&&I6(e[Y0o]),kt={isArray:OTn,isArrayBuffer:d8p,isBuffer:dOa,isFormData:w0S,isArrayBufferView:y0S,isString:b0S,isNumber:p8p,isBoolean:v0S,isObject:pOa,isPlainObject:$0o,isEmptyObject:g0S,isReadableStream:S0S,isRequest:M0S,isResponse:D0S,isHeaders:B0S,isUndefined:gTn,isDate:O0S,isFile:A0S,isBlob:m0S,isRegExp:W0S,isFunction:I6,isStream:j0S,isURLSearchParams:E0S,isTypedArray:F0S,isFileList:P0S,forEach:_Oa,merge:J7s,extend:C0S,trim:I0S,stripBOM:q0S,inherits:T0S,toFlatObject:R0S,kindOf:X0o,kindOfTest:zNt,endsWith:z0S,toArray:N0S,forEachEntry:Q0S,matchAll:U0S,isHTMLForm:L0S,hasOwnProperty:l8p,hasOwnProp:l8p,reduceDescriptors:y8p,freezeMethods:x0S,toObjectSet:G0S,toCamelCase:V0S,noop:H0S,toFiniteNumber:K0S,findKey:_8p,global:e6i,isContextDefined:h8p,isSpecCompliantForm:J0S,toJSONObject:$0S,isAsyncFn:Y0S,isThenable:X0S,setImmediate:b8p,asap:Z0S,isIterable:k0S};function ATn(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)}kt.inherits(ATn,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:kt.toJSONObject(this.config),code:this.code,status:this.status}}});var v8p=ATn.prototype,g8p={};["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=>{g8p[e]={value:e}});Object.defineProperties(ATn,g8p);Object.defineProperty(v8p,"isAxiosError",{value:!0});ATn.from=(e,t,r,i,n,a)=>{let o=Object.create(v8p);kt.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return ATn.call(o,c,f,r,i,n),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var ya=ATn;var O8p=ae(F7i(),1),k0o=O8p.default;function Y7s(e){return kt.isPlainObject(e)||kt.isArray(e)}function m8p(e){return kt.endsWith(e,"[]")?e.slice(0,-2):e}function A8p(e,t,r){return e?e.concat(t).map(function(n,a){return n=m8p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function ePS(e){return kt.isArray(e)&&!e.some(Y7s)}var tPS=kt.toFlatObject(kt,{},null,function(t){return/^is[A-Z]/.test(t)});function rPS(e,t,r){if(!kt.isObject(e))throw new TypeError("target must be an object");t=t||new(k0o||FormData),r=kt.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!kt.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&kt.isSpecCompliantForm(t);if(!kt.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(kt.isDate(h))return h.toISOString();if(kt.isBoolean(h))return h.toString();if(!f&&kt.isBlob(h))throw new ya("Blob is not supported. Use a Buffer instead.");return kt.isArrayBuffer(h)||kt.isTypedArray(h)?f&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,y,b){let v=h;if(h&&!b&&typeof h=="object"){if(kt.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(kt.isArray(h)&&ePS(h)||(kt.isFileList(h)||kt.endsWith(y,"[]"))&&(v=kt.toArray(h)))return y=m8p(y),v.forEach(function(A,g){!(kt.isUndefined(A)||A===null)&&t.append(o===!0?A8p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return Y7s(h)?!0:(t.append(A8p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(tPS,{defaultVisitor:u,convertValue:s,isVisitable:Y7s});function _(h,y){if(!kt.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),kt.forEach(h,function(v,O){(!(kt.isUndefined(v)||v===null)&&n.call(t,v,kt.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!kt.isObject(e))throw new TypeError("data must be an object");return _(e),t}var zBi=rPS;function P8p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function j8p(e,t){this._pairs=[],e&&zBi(e,this,t)}var w8p=j8p.prototype;w8p.append=function(t,r){this._pairs.push([t,r])};w8p.toString=function(t){let r=t?function(i){return t.call(this,i,P8p)}:P8p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var E8p=j8p;function iPS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function t6i(e,t,r){if(!t)return e;let i=r&&r.encode||iPS;kt.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=kt.isURLSearchParams(t)?t.toString():new E8p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var X7s=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){kt.forEach(this.handlers,function(i){i!==null&&t(i)})}},Z7s=X7s;var mTn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var B8p=ae(require("crypto"),1);var S8p=ae(require("url"),1),M8p=S8p.default.URLSearchParams;var k7s="abcdefghijklmnopqrstuvwxyz",D8p="0123456789",I8p={DIGIT:D8p,ALPHA:k7s,ALPHA_DIGIT:k7s+k7s.toUpperCase()+D8p},nPS=(e=16,t=I8p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);B8p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},C8p={isNode:!0,classes:{URLSearchParams:M8p,FormData:k0o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:I8p,generateString:nPS,protocols:["http","https","file","data"]};var rHs={};Kt(rHs,{hasBrowserEnv:()=>tHs,hasStandardBrowserEnv:()=>aPS,hasStandardBrowserWebWorkerEnv:()=>oPS,navigator:()=>eHs,origin:()=>uPS});var tHs=typeof window<"u"&&typeof document<"u",eHs=typeof navigator=="object"&&navigator||void 0,aPS=tHs&&(!eHs||["ReactNative","NativeScript","NS"].indexOf(eHs.product)<0),oPS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",uPS=tHs&&window.location.href||"http://localhost";var OA={...rHs,...C8p};function iHs(e,t){return zBi(e,new OA.classes.URLSearchParams,{visitor:function(r,i,n,a){return OA.isNode&&kt.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function sPS(e){return kt.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function cPS(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 lPS(e){function t(r,i,n,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&kt.isArray(n)?n.length:o,f?(kt.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!kt.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&kt.isArray(n[o])&&(n[o]=cPS(n[o])),!c)}if(kt.isFormData(e)&&kt.isFunction(e.entries)){let r={};return kt.forEachEntry(e,(i,n)=>{t(sPS(i),n,r,0)}),r}return null}var ePo=lPS;function fPS(e,t,r){if(kt.isString(e))try{return(t||JSON.parse)(e),kt.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var nHs={transitional:mTn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=kt.isObject(t);if(a&&kt.isHTMLForm(t)&&(t=new FormData(t)),kt.isFormData(t))return n?JSON.stringify(ePo(t)):t;if(kt.isArrayBuffer(t)||kt.isBuffer(t)||kt.isStream(t)||kt.isFile(t)||kt.isBlob(t)||kt.isReadableStream(t))return t;if(kt.isArrayBufferView(t))return t.buffer;if(kt.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return iHs(t,this.formSerializer).toString();if((c=kt.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return zBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),fPS(t)):t}],transformResponse:[function(t){let r=this.transitional||nHs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(kt.isResponse(t)||kt.isReadableStream(t))return t;if(t&&kt.isString(t)&&(i&&!this.responseType||n)){let o=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?ya.from(c,ya.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:OA.classes.FormData,Blob:OA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};kt.forEach(["delete","get","head","post","put","patch"],e=>{nHs.headers[e]={}});var PTn=nHs;var dPS=kt.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"]),q8p=e=>{let t={},r,i,n;return e&&e.split(`
1156
1156
  `).forEach(function(o){n=o.indexOf(":"),r=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!r||t[r]&&dPS[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var T8p=Symbol("internals");function hOa(e){return e&&String(e).trim().toLowerCase()}function tPo(e){return e===!1||e==null?e:kt.isArray(e)?e.map(tPo):String(e)}function pPS(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 _PS=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function aHs(e,t,r,i,n){if(kt.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!kt.isString(t)){if(kt.isString(i))return t.indexOf(i)!==-1;if(kt.isRegExp(i))return i.test(t)}}function hPS(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function yPS(e,t){let r=kt.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,o){return this[i].call(this,t,n,a,o)},configurable:!0})})}var jTn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,f,s){let u=hOa(f);if(!u)throw new Error("header name must be a non-empty string");let l=kt.findKey(n,u);(!l||n[l]===void 0||s===!0||s===void 0&&n[l]!==!1)&&(n[l||f]=tPo(c))}let o=(c,f)=>kt.forEach(c,(s,u)=>a(s,u,f));if(kt.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(kt.isString(t)&&(t=t.trim())&&!_PS(t))o(q8p(t),r);else if(kt.isObject(t)&&kt.isIterable(t)){let c={},f,s;for(let u of t){if(!kt.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[s=u[0]]=(f=c[s])?kt.isArray(f)?[...f,u[1]]:[f,u[1]]:u[1]}o(c,r)}else t!=null&&a(r,t,i);return this}get(t,r){if(t=hOa(t),t){let i=kt.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return pPS(n);if(kt.isFunction(r))return r.call(this,n,i);if(kt.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=hOa(t),t){let i=kt.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||aHs(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(o){if(o=hOa(o),o){let c=kt.findKey(i,o);c&&(!r||aHs(i,i[c],c,r))&&(delete i[c],n=!0)}}return kt.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||aHs(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return kt.forEach(this,(n,a)=>{let o=kt.findKey(i,a);if(o){r[o]=tPo(n),delete r[a];return}let c=t?hPS(a):String(a).trim();c!==a&&delete r[a],r[c]=tPo(n),i[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return kt.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&kt.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(`
1157
1157
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[T8p]=this[T8p]={accessors:{}}).accessors,n=this.prototype;function a(o){let c=hOa(o);i[c]||(yPS(n,o),i[c]=!0)}return kt.isArray(t)?t.forEach(a):a(t),this}};jTn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);kt.reduceDescriptors(jTn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});kt.freezeMethods(jTn);var QS=jTn;function yOa(e,t){let r=this||PTn,i=t||r,n=QS.from(i.headers),a=i.data;return kt.forEach(e,function(c){a=c.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function bOa(e){return!!(e&&e.__CANCEL__)}function R8p(e,t,r){ya.call(this,e??"canceled",ya.ERR_CANCELED,t,r),this.name="CanceledError"}kt.inherits(R8p,ya,{__CANCEL__:!0});var the=R8p;function a9t(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new ya("Request failed with status code "+r.status,[ya.ERR_BAD_REQUEST,ya.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function oHs(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function uHs(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function r6i(e,t,r){let i=!oHs(t);return e&&(i||r==!1)?uHs(e,t):t}var X8p=ae(m0o(),1),Z8p=ae(require("http"),1),k8p=ae(require("https"),1),eVp=ae(require("util"),1),tVp=ae(s7s(),1),xbi=ae(require("zlib"),1);var i6i="1.12.2";function vOa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var bPS=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function sHs(e,t,r){let i=r&&r.Blob||OA.classes.Blob,n=vOa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=bPS.exec(e);if(!a)throw new ya("Invalid URL",ya.ERR_INVALID_URL);let o=a[1],c=a[2],f=a[3],s=Buffer.from(decodeURIComponent(f),c?"base64":"utf8");if(t){if(!i)throw new ya("Blob is not supported",ya.ERR_NOT_SUPPORT);return new i([s],{type:o})}return s}throw new ya("Unsupported protocol "+n,ya.ERR_NOT_SUPPORT)}var a6i=ae(require("stream"),1);var z8p=ae(require("stream"),1);var cHs=Symbol("internals"),lHs=class extends z8p.default.Transform{constructor(t){t=kt.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!kt.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[cHs]={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[cHs];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[cHs],a=n.maxRate,o=this.readableHighWaterMark,c=n.timeWindow,f=1e3/c,s=a/f,u=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,l=(_,h)=>{let y=Buffer.byteLength(_);n.bytesSeen+=y,n.bytes+=y,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(_)?process.nextTick(h):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(h)}},p=(_,h)=>{let y=Buffer.byteLength(_),b=null,v=o,O,A=0;if(a){let g=Date.now();(!n.ts||(A=g-n.ts)>=c)&&(n.ts=g,O=s-n.bytes,n.bytes=O<0?-O:0,A=0),O=s-n.bytes}if(a){if(O<=0)return setTimeout(()=>{h(null,_)},c-A);O<v&&(v=O)}v&&y>v&&y-v>u&&(b=_.subarray(v),_=_.subarray(0,v)),l(_,b?()=>{process.nextTick(h,null,b)}:h)};p(t,function _(h,y){if(h)return i(h);y?p(y,_):i(null)})}},fHs=lHs;var rVp=require("events");var F8p=ae(require("util"),1),Q8p=require("stream");var{asyncIterator:N8p}=Symbol,vPS=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[N8p]?yield*e[N8p]():yield e},rPo=vPS;var gPS=OA.ALPHABET.ALPHA_DIGIT+"-_",gOa=typeof TextEncoder=="function"?new TextEncoder:new F8p.default.TextEncoder,n6i=`\r
1158
1158
  `,OPS=gOa.encode(n6i),APS=2,dHs=class{constructor(t,r){let{escapeName:i}=this.constructor,n=kt.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${n6i}`;n?r=gOa.encode(String(r).replace(/\r?\n|\r\n?/g,n6i)):a+=`Content-Type: ${r.type||"application/octet-stream"}${n6i}`,this.headers=gOa.encode(a+n6i),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+APS,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;kt.isTypedArray(t)?yield t:yield*rPo(t),yield OPS}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},mPS=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+OA.generateString(n,gPS)}=r||{};if(!kt.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let o=gOa.encode("--"+a+n6i),c=gOa.encode("--"+a+"--"+n6i),f=c.byteLength,s=Array.from(e.entries()).map(([l,p])=>{let _=new dHs(l,p);return f+=_.size,_});f+=o.byteLength*s.length,f=kt.toFiniteNumber(f);let u={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(u["Content-Length"]=f),t&&t(u),Q8p.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},U8p=mPS;var L8p=ae(require("stream"),1),pHs=class extends L8p.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)}},V8p=pHs;var PPS=(e,t)=>kt.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,W8p=PPS;function jPS(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,o;return t=t!==void 0?t:1e3,function(f){let s=Date.now(),u=i[a];o||(o=s),r[n]=f,i[n]=s;let l=a,p=0;for(;l!==n;)p+=r[l++],l=l%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-o<t)return;let _=u&&s-u;return _?Math.round(p*1e3/_):void 0}}var x8p=jPS;function wPS(e,t){let r=0,i=1e3/t,n,a,o=(s,u=Date.now())=>{r=u,n=null,a&&(clearTimeout(a),a=null),e(...s)};return[(...s)=>{let u=Date.now(),l=u-r;l>=i?o(s,u):(n=s,a||(a=setTimeout(()=>{a=null,o(n)},i-l)))},()=>n&&o(n)]}var G8p=wPS;var Wbi=(e,t,r=3)=>{let i=0,n=x8p(50,250);return G8p(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,f=o-i,s=n(f),u=o<=c;i=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:f,rate:s||void 0,estimated:s&&c&&u?(c-o)/s:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},wTn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},ETn=e=>(...t)=>kt.asap(()=>e(...t));function _Hs(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),i=e.slice(t+1);if(/;base64/i.test(r)){let a=i.length,o=i.length;for(let p=0;p<o;p++)if(i.charCodeAt(p)===37&&p+2<o){let _=i.charCodeAt(p+1),h=i.charCodeAt(p+2);(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102)&&(h>=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102)&&(a-=2,p+=2)}let c=0,f=o-1,s=p=>p>=2&&i.charCodeAt(p-2)===37&&i.charCodeAt(p-1)===51&&(i.charCodeAt(p)===68||i.charCodeAt(p)===100);f>=0&&(i.charCodeAt(f)===61?(c++,f--):s(f)&&(c++,f-=3)),c===1&&f>=0&&(i.charCodeAt(f)===61||s(f))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(i,"utf8")}var H8p={flush:xbi.default.constants.Z_SYNC_FLUSH,finishFlush:xbi.default.constants.Z_SYNC_FLUSH},EPS={flush:xbi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:xbi.default.constants.BROTLI_OPERATION_FLUSH},K8p=kt.isFunction(xbi.default.createBrotliDecompress),{http:SPS,https:MPS}=tVp.default,DPS=/https:?/,J8p=OA.protocols.map(e=>e+":"),$8p=(e,[t,r])=>(e.on("end",r).on("error",r),t);function BPS(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function iVp(e,t,r){let i=t;if(!i&&i!==!1){let n=X8p.default.getProxyForUrl(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){iVp(a,t,a.href)}}var IPS=typeof process<"u"&&kt.kindOf(process)==="process",CPS=e=>new Promise((t,r)=>{let i,n,a=(f,s)=>{n||(n=!0,i&&i(f,s))},o=f=>{a(f),t(f)},c=f=>{a(f,!0),r(f)};e(o,c,f=>i=f).catch(c)}),qPS=({address:e,family:t})=>{if(!kt.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},Y8p=(e,t)=>qPS(kt.isObject(e)?e:{address:e,family:t}),nVp=IPS&&function(t){return CPS(async function(i,n,a){let{data:o,lookup:c,family:f}=t,{responseType:s,responseEncoding:u}=t,l=t.method.toUpperCase(),p,_=!1,h;if(c){let H=W8p(c,ue=>kt.isArray(ue)?ue:[ue]);c=(ue,se,x)=>{H(ue,se,(G,Pe,ne)=>{if(G)return x(G);let Ee=kt.isArray(Pe)?Pe.map(Qe=>Y8p(Qe)):[Y8p(Pe,ne)];se.all?x(G,Ee):x(G,Ee[0].address,Ee[0].family)})}}let y=new rVp.EventEmitter,b=()=>{t.cancelToken&&t.cancelToken.unsubscribe(v),t.signal&&t.signal.removeEventListener("abort",v),y.removeAllListeners()};a((H,ue)=>{p=!0,ue&&(_=!0,b())});function v(H){y.emit("abort",!H||H.type?new the(null,t,h):H)}y.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(v),t.signal&&(t.signal.aborted?v():t.signal.addEventListener("abort",v)));let O=r6i(t.baseURL,t.url,t.allowAbsoluteUrls),A=new URL(O,OA.hasBrowserEnv?OA.origin:void 0),g=A.protocol||J8p[0];if(g==="data:"){if(t.maxContentLength>-1){let ue=String(t.url||O||"");if(_Hs(ue)>t.maxContentLength)return n(new ya("maxContentLength size of "+t.maxContentLength+" exceeded",ya.ERR_BAD_RESPONSE,t))}let H;if(l!=="GET")return a9t(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{H=sHs(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(ue){throw ya.from(ue,ya.ERR_BAD_REQUEST,t)}return s==="text"?(H=H.toString(u),(!u||u==="utf8")&&(H=kt.stripBOM(H))):s==="stream"&&(H=a6i.default.Readable.from(H)),a9t(i,n,{data:H,status:200,statusText:"OK",headers:new QS,config:t})}if(J8p.indexOf(g)===-1)return n(new ya("Unsupported protocol "+g,ya.ERR_BAD_REQUEST,t));let m=QS.from(t.headers).normalize();m.set("User-Agent","axios/"+i6i,!1);let{onUploadProgress:j,onDownloadProgress:M}=t,E=t.maxRate,D,B;if(kt.isSpecCompliantForm(o)){let H=m.getContentType(/boundary=([-_\w\d]{10,70})/i);o=U8p(o,ue=>{m.set(ue)},{tag:`axios-${i6i}-boundary`,boundary:H&&H[1]||void 0})}else if(kt.isFormData(o)&&kt.isFunction(o.getHeaders)){if(m.set(o.getHeaders()),!m.hasContentLength())try{let H=await eVp.default.promisify(o.getLength).call(o);Number.isFinite(H)&&H>=0&&m.setContentLength(H)}catch{}}else if(kt.isBlob(o)||kt.isFile(o))o.size&&m.setContentType(o.type||"application/octet-stream"),m.setContentLength(o.size||0),o=a6i.default.Readable.from(rPo(o));else if(o&&!kt.isStream(o)){if(!Buffer.isBuffer(o))if(kt.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(kt.isString(o))o=Buffer.from(o,"utf-8");else return n(new ya("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",ya.ERR_BAD_REQUEST,t));if(m.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return n(new ya("Request body larger than maxBodyLength limit",ya.ERR_BAD_REQUEST,t))}let F=kt.toFiniteNumber(m.getContentLength());kt.isArray(E)?(D=E[0],B=E[1]):D=B=E,o&&(j||D)&&(kt.isStream(o)||(o=a6i.default.Readable.from(o,{objectMode:!1})),o=a6i.default.pipeline([o,new fHs({maxRate:kt.toFiniteNumber(D)})],kt.noop),j&&o.on("progress",$8p(o,wTn(F,Wbi(ETn(j),!1,3)))));let N;if(t.auth){let H=t.auth.username||"",ue=t.auth.password||"";N=H+":"+ue}if(!N&&A.username){let H=A.username,ue=A.password;N=H+":"+ue}N&&m.delete("authorization");let T;try{T=t6i(A.pathname+A.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(H){let ue=new Error(H.message);return ue.config=t,ue.url=t.url,ue.exists=!0,n(ue)}m.set("Accept-Encoding","gzip, compress, deflate"+(K8p?", br":""),!1);let R={path:T,method:l,headers:m.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:N,protocol:g,family:f,beforeRedirect:BPS,beforeRedirects:{}};!kt.isUndefined(c)&&(R.lookup=c),t.socketPath?R.socketPath=t.socketPath:(R.hostname=A.hostname.startsWith("[")?A.hostname.slice(1,-1):A.hostname,R.port=A.port,iVp(R,t.proxy,g+"//"+A.hostname+(A.port?":"+A.port:"")+R.path));let Q,U=DPS.test(R.protocol);if(R.agent=U?t.httpsAgent:t.httpAgent,t.transport?Q=t.transport:t.maxRedirects===0?Q=U?k8p.default:Z8p.default:(t.maxRedirects&&(R.maxRedirects=t.maxRedirects),t.beforeRedirect&&(R.beforeRedirects.config=t.beforeRedirect),Q=U?MPS:SPS),t.maxBodyLength>-1?R.maxBodyLength=t.maxBodyLength:R.maxBodyLength=1/0,t.insecureHTTPParser&&(R.insecureHTTPParser=t.insecureHTTPParser),h=Q.request(R,function(ue){if(h.destroyed)return;let se=[ue],x=+ue.headers["content-length"];if(M||B){let Qe=new fHs({maxRate:kt.toFiniteNumber(B)});M&&Qe.on("progress",$8p(Qe,wTn(x,Wbi(ETn(M),!0,3)))),se.push(Qe)}let G=ue,Pe=ue.req||h;if(t.decompress!==!1&&ue.headers["content-encoding"])switch((l==="HEAD"||ue.statusCode===204)&&delete ue.headers["content-encoding"],(ue.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":se.push(xbi.default.createUnzip(H8p)),delete ue.headers["content-encoding"];break;case"deflate":se.push(new V8p),se.push(xbi.default.createUnzip(H8p)),delete ue.headers["content-encoding"];break;case"br":K8p&&(se.push(xbi.default.createBrotliDecompress(EPS)),delete ue.headers["content-encoding"])}G=se.length>1?a6i.default.pipeline(se,kt.noop):se[0];let ne=a6i.default.finished(G,()=>{ne(),b()}),Ee={status:ue.statusCode,statusText:ue.statusMessage,headers:new QS(ue.headers),config:t,request:Pe};if(s==="stream")Ee.data=G,a9t(i,n,Ee);else{let Qe=[],re=0;G.on("data",function(Ve){Qe.push(Ve),re+=Ve.length,t.maxContentLength>-1&&re>t.maxContentLength&&(_=!0,G.destroy(),n(new ya("maxContentLength size of "+t.maxContentLength+" exceeded",ya.ERR_BAD_RESPONSE,t,Pe)))}),G.on("aborted",function(){if(_)return;let Ve=new ya("stream has been aborted",ya.ERR_BAD_RESPONSE,t,Pe);G.destroy(Ve),n(Ve)}),G.on("error",function(Ve){h.destroyed||n(ya.from(Ve,null,t,Pe))}),G.on("end",function(){try{let Ve=Qe.length===1?Qe[0]:Buffer.concat(Qe);s!=="arraybuffer"&&(Ve=Ve.toString(u),(!u||u==="utf8")&&(Ve=kt.stripBOM(Ve))),Ee.data=Ve}catch(Ve){return n(ya.from(Ve,null,t,Ee.request,Ee))}a9t(i,n,Ee)})}y.once("abort",Qe=>{G.destroyed||(G.emit("error",Qe),G.destroy())})}),y.once("abort",H=>{n(H),h.destroy(H)}),h.on("error",function(ue){n(ya.from(ue,null,t,h))}),h.on("socket",function(ue){ue.setKeepAlive(!0,1e3*60)}),t.timeout){let H=parseInt(t.timeout,10);if(Number.isNaN(H)){n(new ya("error trying to parse `config.timeout` to int",ya.ERR_BAD_OPTION_VALUE,t,h));return}h.setTimeout(H,function(){if(p)return;let se=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",x=t.transitional||mTn;t.timeoutErrorMessage&&(se=t.timeoutErrorMessage),n(new ya(se,x.clarifyTimeoutError?ya.ETIMEDOUT:ya.ECONNABORTED,t,h)),v()})}if(kt.isStream(o)){let H=!1,ue=!1;o.on("end",()=>{H=!0}),o.once("error",se=>{ue=!0,h.destroy(se)}),o.on("close",()=>{!H&&!ue&&v(new the("Request stream has been aborted",t,h))}),o.pipe(h)}else h.end(o)})};var aVp=OA.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,OA.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(OA.origin),OA.navigator&&/(msie|trident)/i.test(OA.navigator.userAgent)):()=>!0;var oVp=OA.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let o=[e+"="+encodeURIComponent(t)];kt.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),kt.isString(i)&&o.push("path="+i),kt.isString(n)&&o.push("domain="+n),a===!0&&o.push("secure"),document.cookie=o.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 uVp=e=>e instanceof QS?{...e}:e;function NNt(e,t){t=t||{};let r={};function i(s,u,l,p){return kt.isPlainObject(s)&&kt.isPlainObject(u)?kt.merge.call({caseless:p},s,u):kt.isPlainObject(u)?kt.merge({},u):kt.isArray(u)?u.slice():u}function n(s,u,l,p){if(kt.isUndefined(u)){if(!kt.isUndefined(s))return i(void 0,s,l,p)}else return i(s,u,l,p)}function a(s,u){if(!kt.isUndefined(u))return i(void 0,u)}function o(s,u){if(kt.isUndefined(u)){if(!kt.isUndefined(s))return i(void 0,s)}else return i(void 0,u)}function c(s,u,l){if(l in t)return i(s,u);if(l in e)return i(void 0,s)}let f={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(s,u,l)=>n(uVp(s),uVp(u),l,!0)};return kt.forEach(Object.keys({...e,...t}),function(u){let l=f[u]||n,p=l(e[u],t[u],u);kt.isUndefined(p)&&l!==c||(r[u]=p)}),r}var iPo=e=>{let t=NNt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=QS.from(o),t.url=t6i(r6i(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),kt.isFormData(r)){if(OA.hasStandardBrowserEnv||OA.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(kt.isFunction(r.getHeaders)){let f=r.getHeaders(),s=["content-type","content-length"];Object.entries(f).forEach(([u,l])=>{s.includes(u.toLowerCase())&&o.set(u,l)})}}if(OA.hasStandardBrowserEnv&&(i&&kt.isFunction(i)&&(i=i(t)),i||i!==!1&&aVp(t.url))){let f=n&&a&&oVp.read(a);f&&o.set(n,f)}return t};var TPS=typeof XMLHttpRequest<"u",sVp=TPS&&function(e){return new Promise(function(r,i){let n=iPo(e),a=n.data,o=QS.from(n.headers).normalize(),{responseType:c,onUploadProgress:f,onDownloadProgress:s}=n,u,l,p,_,h;function y(){_&&_(),h&&h(),n.cancelToken&&n.cancelToken.unsubscribe(u),n.signal&&n.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(n.method.toUpperCase(),n.url,!0),b.timeout=n.timeout;function v(){if(!b)return;let A=QS.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),m={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:A,config:e,request:b};a9t(function(M){r(M),y()},function(M){i(M),y()},m),b=null}"onloadend"in b?b.onloadend=v:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(v)},b.onabort=function(){b&&(i(new ya("Request aborted",ya.ECONNABORTED,e,b)),b=null)},b.onerror=function(g){let m=g&&g.message?g.message:"Network Error",j=new ya(m,ya.ERR_NETWORK,e,b);j.event=g||null,i(j),b=null},b.ontimeout=function(){let g=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",m=n.transitional||mTn;n.timeoutErrorMessage&&(g=n.timeoutErrorMessage),i(new ya(g,m.clarifyTimeoutError?ya.ETIMEDOUT:ya.ECONNABORTED,e,b)),b=null},a===void 0&&o.setContentType(null),"setRequestHeader"in b&&kt.forEach(o.toJSON(),function(g,m){b.setRequestHeader(m,g)}),kt.isUndefined(n.withCredentials)||(b.withCredentials=!!n.withCredentials),c&&c!=="json"&&(b.responseType=n.responseType),s&&([p,h]=Wbi(s,!0),b.addEventListener("progress",p)),f&&b.upload&&([l,_]=Wbi(f),b.upload.addEventListener("progress",l),b.upload.addEventListener("loadend",_)),(n.cancelToken||n.signal)&&(u=A=>{b&&(i(!A||A.type?new the(null,e,b):A),b.abort(),b=null)},n.cancelToken&&n.cancelToken.subscribe(u),n.signal&&(n.signal.aborted?u():n.signal.addEventListener("abort",u)));let O=vOa(n.url);if(O&&OA.protocols.indexOf(O)===-1){i(new ya("Unsupported protocol "+O+":",ya.ERR_BAD_REQUEST,e));return}b.send(a||null)})};var RPS=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,c();let u=s instanceof Error?s:this.reason;i.abort(u instanceof ya?u:new the(u instanceof Error?u.message:u))}},o=t&&setTimeout(()=>{o=null,a(new ya(`timeout ${t} of ms exceeded`,ya.ETIMEDOUT))},t),c=()=>{e&&(o&&clearTimeout(o),o=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=()=>kt.asap(c),f}},cVp=RPS;var zPS=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},NPS=async function*(e,t){for await(let r of FPS(e))yield*zPS(r,t)},FPS=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()}},hHs=(e,t,r,i)=>{let n=NPS(e,t),a=0,o,c=f=>{o||(o=!0,i&&i(f))};return new ReadableStream({async pull(f){try{let{done:s,value:u}=await n.next();if(s){c(),f.close();return}let l=u.byteLength;if(r){let p=a+=l;r(p)}f.enqueue(new Uint8Array(u))}catch(s){throw c(s),s}},cancel(f){return c(f),n.return()}},{highWaterMark:2})};var lVp=64*1024,{isFunction:nPo}=kt,QPS=(({Request:e,Response:t})=>({Request:e,Response:t}))(kt.global),{ReadableStream:fVp,TextEncoder:dVp}=kt.global,pVp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},UPS=e=>{e=kt.merge.call({skipUndefined:!0},QPS,e);let{fetch:t,Request:r,Response:i}=e,n=t?nPo(t):typeof fetch=="function",a=nPo(r),o=nPo(i);if(!n)return!1;let c=n&&nPo(fVp),f=n&&(typeof dVp=="function"?(h=>y=>h.encode(y))(new dVp):async h=>new Uint8Array(await new r(h).arrayBuffer())),s=a&&c&&pVp(()=>{let h=!1,y=new r(OA.origin,{body:new fVp,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!y}),u=o&&c&&pVp(()=>kt.isReadableStream(new i("").body)),l={stream:u&&(h=>h.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!l[h]&&(l[h]=(y,b)=>{let v=y&&y[h];if(v)return v.call(y);throw new ya(`Response type '${h}' is not supported`,ya.ERR_NOT_SUPPORT,b)})});let p=async h=>{if(h==null)return 0;if(kt.isBlob(h))return h.size;if(kt.isSpecCompliantForm(h))return(await new r(OA.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(kt.isArrayBufferView(h)||kt.isArrayBuffer(h))return h.byteLength;if(kt.isURLSearchParams(h)&&(h=h+""),kt.isString(h))return(await f(h)).byteLength},_=async(h,y)=>{let b=kt.toFiniteNumber(h.getContentLength());return b??p(y)};return async h=>{let{url:y,method:b,data:v,signal:O,cancelToken:A,timeout:g,onDownloadProgress:m,onUploadProgress:j,responseType:M,headers:E,withCredentials:D="same-origin",fetchOptions:B}=iPo(h),F=t||fetch;M=M?(M+"").toLowerCase():"text";let N=cVp([O,A&&A.toAbortSignal()],g),T=null,R=N&&N.unsubscribe&&(()=>{N.unsubscribe()}),Q;try{if(j&&s&&b!=="get"&&b!=="head"&&(Q=await _(E,v))!==0){let G=new r(y,{method:"POST",body:v,duplex:"half"}),Pe;if(kt.isFormData(v)&&(Pe=G.headers.get("content-type"))&&E.setContentType(Pe),G.body){let[ne,Ee]=wTn(Q,Wbi(ETn(j)));v=hHs(G.body,lVp,ne,Ee)}}kt.isString(D)||(D=D?"include":"omit");let U=a&&"credentials"in r.prototype,H={...B,signal:N,method:b.toUpperCase(),headers:E.normalize().toJSON(),body:v,duplex:"half",credentials:U?D:void 0};T=a&&new r(y,H);let ue=await(a?F(T,B):F(y,H)),se=u&&(M==="stream"||M==="response");if(u&&(m||se&&R)){let G={};["status","statusText","headers"].forEach(Qe=>{G[Qe]=ue[Qe]});let Pe=kt.toFiniteNumber(ue.headers.get("content-length")),[ne,Ee]=m&&wTn(Pe,Wbi(ETn(m),!0))||[];ue=new i(hHs(ue.body,lVp,ne,()=>{Ee&&Ee(),R&&R()}),G)}M=M||"text";let x=await l[kt.findKey(l,M)||"text"](ue,h);return!se&&R&&R(),await new Promise((G,Pe)=>{a9t(G,Pe,{data:x,headers:QS.from(ue.headers),status:ue.status,statusText:ue.statusText,config:h,request:T})})}catch(U){throw R&&R(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new ya("Network Error",ya.ERR_NETWORK,h,T),{cause:U.cause||U}):ya.from(U,U&&U.code,h,T)}}},LPS=new Map,yHs=e=>{let t=e?e.env:{},{fetch:r,Request:i,Response:n}=t,a=[i,n,r],o=a.length,c=o,f,s,u=LPS;for(;c--;)f=a[c],s=u.get(f),s===void 0&&u.set(f,s=c?new Map:UPS(t)),u=s;return s},Iv5=yHs();var bHs={http:nVp,xhr:sVp,fetch:{get:yHs}};kt.forEach(bHs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var _Vp=e=>`- ${e}`,WPS=e=>kt.isFunction(e)||e===null||e===!1,aPo={getAdapter:(e,t)=>{e=kt.isArray(e)?e:[e];let{length:r}=e,i,n,a={};for(let o=0;o<r;o++){i=e[o];let c;if(n=i,!WPS(i)&&(n=bHs[(c=String(i)).toLowerCase()],n===void 0))throw new ya(`Unknown adapter '${c}'`);if(n&&(kt.isFunction(n)||(n=n.get(t))))break;a[c||"#"+o]=n}if(!n){let o=Object.entries(a).map(([f,s])=>`adapter ${f} `+(s===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
@@ -1396,7 +1396,7 @@ ${g}${O}${m}${vQn}`});function $Qo({message:e,error:t,logger:r,logLevel:i=$s.Err
1396
1396
  Run ${Lt.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
1397
1397
  Run ${Lt.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),QBi(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function koc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!ad_(e))return;let n=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let o=a.sort((c,f)=>c.generatorName.localeCompare(f.generatorName)||c.currentVersion.localeCompare(f.currentVersion));for(let c of o)n+=`
1398
1398
  ${await wZS(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Lt.dim(c.currentVersion)+Lt.reset(" \u2192 ")+Lt.green(c.latestVersion);return n+=`
1399
- `,i?QBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function wZS(e){let r=await new nd_.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 EZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await ud_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=NMi(u.name,l),_=await dNt({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await ud_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=NMi(s.name,u),p=await dNt({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function ud_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await $_e({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.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,o)}})}))}function sd_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let f=k6(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function kQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await EZS({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...sd_(s,f,t.logger));else o.push(...sd_(c.versions,void 0,t.logger))}return o}var qPa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${n} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var mQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var euc=(()=>{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})(),cd_=typeof globalThis.AbortController=="function",ld_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",fd_=typeof globalThis.ReadableStream=="function",dd_=typeof globalThis.FormData=="function",eUo=["get","post","put","patch","head","delete"],SZS=()=>{};SZS();var pd_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},tUo=2147483647,_d_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,rUo=Symbol("stop"),hd_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},yd_={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 MZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=_d_,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},bd_=(e,t,r)=>{let i,n=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),i){n+=i.byteLength;let c=t===0?0:n/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,n),transferredBytes:n},i)}i=a},flush(){i&&(n+=i.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},i))}}))},vd_=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(bd_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},gd_=(e,t,r)=>{if(!e.body)return e;let i=MZS(r??e.body);return new Request(e,{duplex:"half",body:bd_(e.body,i,t)})};var PQn=e=>e!==null&&typeof e=="object";var TPa=(...e)=>{for(let t of e)if((!PQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return iuc({},...e)},tuc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,o]of n.entries())i&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function iUo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:iuc(e[r]??[],t[r]??[])}var ruc=(e={},t={})=>({beforeRequest:iUo(e,t,"beforeRequest"),beforeRetry:iUo(e,t,"beforeRetry"),afterResponse:iUo(e,t,"afterResponse"),beforeError:iUo(e,t,"beforeError")}),iuc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(PQn(n)){for(let[a,o]of Object.entries(n))PQn(o)&&a in t&&(o=iuc(t[a],o)),t={...t,[a]:o};PQn(n.hooks)&&(i=ruc(i,n.hooks),t.hooks=i),PQn(n.headers)&&(r=tuc(r,n.headers),t.headers=r)}return t};var Ad_=e=>eUo.includes(e)?e.toUpperCase():e,DZS=["get","put","head","delete","options","trace"],BZS=[408,413,429,500,502,503,504],IZS=[413,429,503],Od_={limit:2,methods:DZS,statusCodes:BZS,afterStatusCodes:IZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},md_=(e={})=>{if(typeof e=="number")return{...Od_,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{...Od_,...e}};async function nuc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new mQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function auc(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 Pd_=(e,t)=>{let r={};for(let i in t)!(i in yd_)&&!(i in hd_)&&!(i in e)&&(r[i]=t[i]);return r},jd_=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var RPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>tUo)throw new RangeError(`The \`timeout\` option cannot be greater than ${tUo}`);await Promise.resolve();let c=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let f=new qPa(c,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(!fd_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return vd_(c.clone(),i._options.onDownloadProgress)}return c},o=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{let c=i._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),i.request.bodyUsed||f.push(i.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(pd_))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:tuc(this._input.headers,r.headers),hooks:ruc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Ad_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:md_(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(cd_&&ld_){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(euc&&(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),jd_(this._options.searchParams)){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(dd_&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!euc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=gd_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof mQn)throw t;if(t instanceof qPa){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),tUo);if(this._retryCount<1)throw r;await auc(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})===rUo)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=Pd_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):nuc(this._originalRequest,t,this.abortController,this._options)}};var ouc=e=>{let t=(r,i)=>RPa.create(r,TPa(e,i));for(let r of eUo)t[r]=(i,n)=>RPa.create(i,TPa(e,n,{method:r}));return t.create=r=>ouc(TPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),ouc(TPa(e,r))),t.stop=rUo,t},CZS=ouc(),wd_=CZS;var Jd_=ae(Kd_(),1);function fuc(e){let t=(0,Jd_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Vp_=ae(Lp_(),1),Wp_=ae(A_e(),1),juc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},wuc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function Euc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??fuc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Vp_.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,c&&(f.authorization=`${c.type} ${c.token}`);let s;try{s=await wd_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new juc(e):l}if(t.allVersions)return s;let u=new wuc(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(i&&!l)for(let[_,h]of Object.entries(s.versions))h.deprecated&&delete s.versions[_];if(!l){let _=Object.keys(s.versions);if(r=Wp_.default.maxSatisfying(_,r),!r)throw u}let{time:p}=s;if(s=s.versions[r],s.time=p,!s)throw u}return s}async function LPa(e,t){let{version:r}=await Euc(e.toLowerCase(),t);return r}async function CCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:LPa(e.packageName,{version:t?"prerelease":"latest"})}var xp_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],hUo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new ZQo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"2.10.0"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Lt.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new qE}failWithoutThrowing(t,r){this.didSucceed=!1,$Qo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await vTn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await od_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1399
+ `,i?QBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function wZS(e){let r=await new nd_.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 EZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await ud_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=NMi(u.name,l),_=await dNt({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await ud_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=NMi(s.name,u),p=await dNt({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function ud_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await $_e({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.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,o)}})}))}function sd_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let f=k6(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function kQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await EZS({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...sd_(s,f,t.logger));else o.push(...sd_(c.versions,void 0,t.logger))}return o}var qPa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${n} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var mQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var euc=(()=>{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})(),cd_=typeof globalThis.AbortController=="function",ld_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",fd_=typeof globalThis.ReadableStream=="function",dd_=typeof globalThis.FormData=="function",eUo=["get","post","put","patch","head","delete"],SZS=()=>{};SZS();var pd_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},tUo=2147483647,_d_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,rUo=Symbol("stop"),hd_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},yd_={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 MZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=_d_,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},bd_=(e,t,r)=>{let i,n=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),i){n+=i.byteLength;let c=t===0?0:n/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,n),transferredBytes:n},i)}i=a},flush(){i&&(n+=i.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},i))}}))},vd_=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(bd_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},gd_=(e,t,r)=>{if(!e.body)return e;let i=MZS(r??e.body);return new Request(e,{duplex:"half",body:bd_(e.body,i,t)})};var PQn=e=>e!==null&&typeof e=="object";var TPa=(...e)=>{for(let t of e)if((!PQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return iuc({},...e)},tuc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,o]of n.entries())i&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function iUo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:iuc(e[r]??[],t[r]??[])}var ruc=(e={},t={})=>({beforeRequest:iUo(e,t,"beforeRequest"),beforeRetry:iUo(e,t,"beforeRetry"),afterResponse:iUo(e,t,"afterResponse"),beforeError:iUo(e,t,"beforeError")}),iuc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(PQn(n)){for(let[a,o]of Object.entries(n))PQn(o)&&a in t&&(o=iuc(t[a],o)),t={...t,[a]:o};PQn(n.hooks)&&(i=ruc(i,n.hooks),t.hooks=i),PQn(n.headers)&&(r=tuc(r,n.headers),t.headers=r)}return t};var Ad_=e=>eUo.includes(e)?e.toUpperCase():e,DZS=["get","put","head","delete","options","trace"],BZS=[408,413,429,500,502,503,504],IZS=[413,429,503],Od_={limit:2,methods:DZS,statusCodes:BZS,afterStatusCodes:IZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},md_=(e={})=>{if(typeof e=="number")return{...Od_,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{...Od_,...e}};async function nuc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new mQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function auc(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 Pd_=(e,t)=>{let r={};for(let i in t)!(i in yd_)&&!(i in hd_)&&!(i in e)&&(r[i]=t[i]);return r},jd_=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var RPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>tUo)throw new RangeError(`The \`timeout\` option cannot be greater than ${tUo}`);await Promise.resolve();let c=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let f=new qPa(c,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(!fd_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return vd_(c.clone(),i._options.onDownloadProgress)}return c},o=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{let c=i._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),i.request.bodyUsed||f.push(i.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(pd_))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:tuc(this._input.headers,r.headers),hooks:ruc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Ad_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:md_(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(cd_&&ld_){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(euc&&(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),jd_(this._options.searchParams)){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(dd_&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!euc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=gd_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof mQn)throw t;if(t instanceof qPa){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),tUo);if(this._retryCount<1)throw r;await auc(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})===rUo)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=Pd_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):nuc(this._originalRequest,t,this.abortController,this._options)}};var ouc=e=>{let t=(r,i)=>RPa.create(r,TPa(e,i));for(let r of eUo)t[r]=(i,n)=>RPa.create(i,TPa(e,n,{method:r}));return t.create=r=>ouc(TPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),ouc(TPa(e,r))),t.stop=rUo,t},CZS=ouc(),wd_=CZS;var Jd_=ae(Kd_(),1);function fuc(e){let t=(0,Jd_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Vp_=ae(Lp_(),1),Wp_=ae(A_e(),1),juc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},wuc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function Euc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??fuc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Vp_.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,c&&(f.authorization=`${c.type} ${c.token}`);let s;try{s=await wd_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new juc(e):l}if(t.allVersions)return s;let u=new wuc(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(i&&!l)for(let[_,h]of Object.entries(s.versions))h.deprecated&&delete s.versions[_];if(!l){let _=Object.keys(s.versions);if(r=Wp_.default.maxSatisfying(_,r),!r)throw u}let{time:p}=s;if(s=s.versions[r],s.time=p,!s)throw u}return s}async function LPa(e,t){let{version:r}=await Euc(e.toLowerCase(),t);return r}async function CCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:LPa(e.packageName,{version:t?"prerelease":"latest"})}var xp_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],hUo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new ZQo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"2.11.0"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Lt.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new qE}failWithoutThrowing(t,r){this.didSucceed=!1,$Qo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await vTn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await od_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1400
1400
  `)||(r+=`
1401
1401
  `),this.stderr.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram({code:t}={}){process.exit(t??(this.didSucceed?0:1))}longestWorkspaceName;registerWorkspaces(t){let r=Ows(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 SPa(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 qE}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await vTn()).sendEvent(t)}logger=x8t((t,...r)=>this.log(t,...r));stderr=x8t((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=Gp_(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?Gp_(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=xp_[this.numTasks++%xp_.length],o=Lt.hex(a)(n);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===gj.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let i=t.filter(n=>uMi.indexOf(n.level)>=uMi.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===$s.Debug,stderr:r})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await CCi({cliEnvironment:this.environment,includePreReleases:t}),i=k6(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await kQo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await Loc({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Lt.yellow("?"),style:{answer:n=>Lt.cyan(n),message:n=>Lt.bold(n),highlight:n=>Lt.cyan(n)}}})}catch(i){throw i?.name==="ExitPromptError"?(this.logger.info(`
1402
1402
  Cancelled by user.`),new qE):i}}async getInput(t){return await Noc({message:t.message,default:t.default})}};function Gp_(e){return`[${e}]:`}var _Ft=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};function yUo(e,t,r,i){if(typeof r!="function")throw new Error("method for before hook must be a function");return i||(i={}),Array.isArray(t)?t.reverse().reduce((n,a)=>yUo.bind(null,e,a,n,i),r)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((n,a)=>a.hook.bind(null,n,i),r)():r(i))}function Hp_(e,t,r,i){let n=i;e.registry[r]||(e.registry[r]=[]),t==="before"&&(i=(a,o)=>Promise.resolve().then(n.bind(null,o)).then(a.bind(null,o))),t==="after"&&(i=(a,o)=>{let c;return Promise.resolve().then(a.bind(null,o)).then(f=>(c=f,n(c,o))).then(()=>c)}),t==="error"&&(i=(a,o)=>Promise.resolve().then(a.bind(null,o)).catch(c=>n(c,o))),e.registry[r].push({hook:i,orig:n})}function Kp_(e,t,r){if(!e.registry[t])return;let i=e.registry[t].map(n=>n.orig).indexOf(r);i!==-1&&e.registry[t].splice(i,1)}var Jp_=Function.bind,$p_=Jp_.bind(Jp_);function Yp_(e,t,r){let i=$p_(Kp_,null).apply(null,r?[t,r]:[t]);e.api={remove:i},e.remove=i,["before","error","after","wrap"].forEach(n=>{let a=r?[t,n,r]:[t,n];e[n]=e.api[n]=$p_(Hp_,null).apply(null,a)})}function F2S(){let e=Symbol("Singular"),t={registry:{}},r=yUo.bind(null,t,e);return Yp_(r,t,e),r}function Q2S(){let e={registry:{}},t=yUo.bind(null,e);return Yp_(t,e),t}var Xp_={Singular:F2S,Collection:Q2S};var U2S="0.0.0-development",L2S=`octokit-endpoint.js/${U2S} ${TR()}`,V2S={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":L2S},mediaType:{format:""}};function W2S(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function x2S(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}function e__(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(i=>{x2S(t[i])?i in e?r[i]=e__(e[i],t[i]):Object.assign(r,{[i]:t[i]}):Object.assign(r,{[i]:t[i]})}),r}function Zp_(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function Muc(e,t,r){if(typeof t=="string"){let[n,a]=t.split(" ");r=Object.assign(a?{method:n,url:a}:{url:n},r)}else r=Object.assign({},t);r.headers=W2S(r.headers),Zp_(r),Zp_(r.headers);let i=e__(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(i.mediaType.previews=e.mediaType.previews.filter(n=>!i.mediaType.previews.includes(n)).concat(i.mediaType.previews)),i.mediaType.previews=(i.mediaType.previews||[]).map(n=>n.replace(/-preview/,""))),i}function G2S(e,t){let r=/\?/.test(e)?"&":"?",i=Object.keys(t);return i.length===0?e:e+r+i.map(n=>n==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${n}=${encodeURIComponent(t[n])}`).join("&")}var H2S=/\{[^{}}]+\}/g;function K2S(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function J2S(e){let t=e.match(H2S);return t?t.map(K2S).reduce((r,i)=>r.concat(i),[]):[]}function kp_(e,t){let r={__proto__:null};for(let i of Object.keys(e))t.indexOf(i)===-1&&(r[i]=e[i]);return r}function t__(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function IQn(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function VPa(e,t,r){return t=e==="+"||e==="#"?t__(t):IQn(t),r?IQn(r)+"="+t:t}function BQn(e){return e!=null}function Suc(e){return e===";"||e==="&"||e==="?"}function $2S(e,t,r,i){var n=e[r],a=[];if(BQn(n)&&n!=="")if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")n=n.toString(),i&&i!=="*"&&(n=n.substring(0,parseInt(i,10))),a.push(VPa(t,n,Suc(t)?r:""));else if(i==="*")Array.isArray(n)?n.filter(BQn).forEach(function(o){a.push(VPa(t,o,Suc(t)?r:""))}):Object.keys(n).forEach(function(o){BQn(n[o])&&a.push(VPa(t,n[o],o))});else{let o=[];Array.isArray(n)?n.filter(BQn).forEach(function(c){o.push(VPa(t,c))}):Object.keys(n).forEach(function(c){BQn(n[c])&&(o.push(IQn(c)),o.push(VPa(t,n[c].toString())))}),Suc(t)?a.push(IQn(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?BQn(n)&&a.push(IQn(r)):n===""&&(t==="&"||t==="?")?a.push(IQn(r)+"="):n===""&&a.push("");return a}function Y2S(e){return{expand:X2S.bind(null,e)}}function X2S(e,t){var r=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(i,n,a){if(n){let c="",f=[];if(r.indexOf(n.charAt(0))!==-1&&(c=n.charAt(0),n=n.substr(1)),n.split(/,/g).forEach(function(s){var u=/([^:\*]*)(?::(\d+)|(\*))?/.exec(s);f.push($2S(t,c,u[1],u[2]||u[3]))}),c&&c!=="+"){var o=",";return c==="?"?o="&":c!=="#"&&(o=c),(f.length!==0?c:"")+f.join(o)}else return f.join(",")}else return t__(a)}),e==="/"?e:e.replace(/\/$/,"")}function r__(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),i=Object.assign({},e.headers),n,a=kp_(e,["method","baseUrl","url","headers","request","mediaType"]),o=J2S(r);r=Y2S(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(u=>o.includes(u)).concat("baseUrl"),f=kp_(a,c);if(!/application\/octet-stream/i.test(i.accept)&&(e.mediaType.format&&(i.accept=i.accept.split(/,/).map(u=>u.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),r.endsWith("/graphql")&&e.mediaType.previews?.length)){let u=i.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];i.accept=u.concat(e.mediaType.previews).map(l=>{let p=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${l}-preview${p}`}).join(",")}return["GET","HEAD"].includes(t)?r=G2S(r,f):"data"in f?n=f.data:Object.keys(f).length&&(n=f),!i["content-type"]&&typeof n<"u"&&(i["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof n>"u"&&(n=""),Object.assign({method:t,url:r,headers:i},typeof n<"u"?{body:n}:null,e.request?{request:e.request}:null)}function Z2S(e,t,r){return r__(Muc(e,t,r))}function i__(e,t){let r=Muc(e,t),i=Z2S.bind(null,r);return Object.assign(i,{DEFAULTS:r,defaults:i__.bind(null,r),merge:Muc.bind(null,r),parse:r__})}var n__=i__(null,V2S);var l__=ae(s__(),1);var hFt=class extends Error{name;status;request;response;constructor(t,r,i){super(t),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in i&&(this.response=i.response);let n=Object.assign({},i.request);i.request.headers.authorization&&(n.headers=Object.assign({},i.request.headers,{authorization:i.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),n.url=n.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=n}};var k2S="10.0.6",ekS={headers:{"user-agent":`octokit-request.js/${k2S} ${TR()}`}};function tkS(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}async function c__(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");let r=e.request?.log||console,i=e.request?.parseSuccessResponseBody!==!1,n=tkS(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([l,p])=>[l,String(p)])),o;try{o=await t(e.url,{method:e.method,body:n,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(l){let p="Unknown Error";if(l instanceof Error){if(l.name==="AbortError")throw l.status=500,l;p=l.message,l.name==="TypeError"&&"cause"in l&&(l.cause instanceof Error?p=l.cause.message:typeof l.cause=="string"&&(p=l.cause))}let _=new hFt(p,500,{request:e});throw _.cause=l,_}let c=o.status,f=o.url,s={};for(let[l,p]of o.headers)s[l]=p;let u={url:f,status:c,headers:s,data:""};if("deprecation"in s){let l=s.link&&s.link.match(/<([^<>]+)>; rel="deprecation"/),p=l&&l.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${s.sunset}${p?`. See ${p}`:""}`)}if(c===204||c===205)return u;if(e.method==="HEAD"){if(c<400)return u;throw new hFt(o.statusText,c,{response:u,request:e})}if(c===304)throw u.data=await Duc(o),new hFt("Not modified",c,{response:u,request:e});if(c>=400)throw u.data=await Duc(o),new hFt(ikS(u.data),c,{response:u,request:e});return u.data=i?await Duc(o):o.body,u}async function Duc(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,l__.safeParse)(t);if(rkS(r)){let i="";try{return i=await e.text(),JSON.parse(i)}catch{return i}}else return r.type.startsWith("text/")||r.parameters.charset?.toLowerCase()==="utf-8"?e.text().catch(()=>""):e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function rkS(e){return e.type==="application/json"||e.type==="application/scim+json"}function ikS(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if("message"in e){let t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(r=>JSON.stringify(r)).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function Buc(e,t){let r=e.defaults(t);return Object.assign(function(n,a){let o=r.merge(n,a);if(!o.request||!o.request.hook)return c__(r.parse(o));let c=(f,s)=>c__(r.parse(r.merge(f,s)));return Object.assign(c,{endpoint:r,defaults:Buc.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:Buc.bind(null,r)})}var WO=Buc(n__,ekS);var nkS="0.0.0-development";function akS(e){return`Request failed due to following response errors:
@@ -1413,7 +1413,7 @@ Cancelled by user.`),new qE):i}}async getInput(t){return await Noc({message:t.me
1413
1413
  })
1414
1414
  `);let s={},u=new i.Events(s);return s.on("secondary-limit",f.onSecondaryRateLimit),s.on("rate-limit",f.onRateLimit),s.on("error",l=>e.log.warn("Error in throttling-plugin limit handler",l)),f.retryLimiter.on("failed",async function(l,p){let[_,h,y]=p.args,{pathname:b}=new URL(y.url,"http://github.test");if(!(b.startsWith("/graphql")&&l.status!==401||l.status===403||l.status===429))return;let O=~~h.retryCount;h.retryCount=O,y.request.retryCount=O;let{wantRetry:A,retryAfter:g=0}=await(async function(){if(/\bsecondary rate\b/i.test(l.message)){let m=Number(l.response.headers["retry-after"])||_.fallbackSecondaryRateRetryAfter;return{wantRetry:await u.trigger("secondary-limit",m,y,e,O),retryAfter:m}}if(l.response.headers!=null&&l.response.headers["x-ratelimit-remaining"]==="0"||(l.response.data?.errors??[]).some(m=>m.type==="RATE_LIMITED")){let m=new Date(~~l.response.headers["x-ratelimit-reset"]*1e3).getTime(),j=Math.max(Math.ceil((m-Date.now())/1e3)+1,0);return{wantRetry:await u.trigger("rate-limit",j,y,e,O),retryAfter:j}}return{}})();if(A)return h.retryCount++,g*_.retryAfterBaseValue}),e.hook.wrap("request",zkS.bind(null,f)),{}}AUo.VERSION=RkS;AUo.triggersNotification=B__;function I__(e){let t=e.clientType||"oauth-app",r=e.baseUrl||"https://github.com",i={clientType:t,allowSignup:e.allowSignup!==!1,clientId:e.clientId,login:e.login||null,redirectUrl:e.redirectUrl||null,state:e.state||Math.random().toString(36).substr(2),url:""};if(t==="oauth-app"){let n="scopes"in e?e.scopes:[];i.scopes=typeof n=="string"?n.split(/[,\s]+/).filter(Boolean):n}return i.url=VkS(`${r}/login/oauth/authorize`,i),i}function VkS(e,t){let r={allowSignup:"allow_signup",clientId:"client_id",login:"login",redirectUrl:"redirect_uri",scopes:"scope",state:"state"},i=e;return Object.keys(r).filter(n=>t[n]!==null).filter(n=>n!=="scopes"?!0:t.clientType==="github-app"?!1:!Array.isArray(t[n])||t[n].length>0).map(n=>[r[n],`${t[n]}`]).forEach(([n,a],o)=>{i+=o===0?"?":"&",i+=`${n}=${encodeURIComponent(a)}`}),i}function R__(e){let t=e.endpoint.DEFAULTS;return/^https:\/\/(api\.)?github\.com$/.test(t.baseUrl)?"https://github.com":t.baseUrl.replace("/api/v3","")}async function mUo(e,t,r){let i={baseUrl:R__(e),headers:{accept:"application/json"},...r},n=await e(t,i);if("error"in n.data){let a=new hFt(`${n.data.error_description} (${n.data.error}, ${n.data.error_uri})`,400,{request:e.endpoint.merge(t,i)});throw a.response=n,a}return n}function z__({request:e=WO,...t}){let r=R__(e);return I__({...t,baseUrl:r})}async function N__(e){let t=e.request||WO,r=await mUo(t,"POST /login/oauth/access_token",{client_id:e.clientId,client_secret:e.clientSecret,code:e.code,redirect_uri:e.redirectUrl}),i={clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.data.access_token,scopes:r.data.scope.split(/\s+/).filter(Boolean)};if(e.clientType==="github-app"){if("refresh_token"in r.data){let n=new Date(r.headers.date).getTime();i.refreshToken=r.data.refresh_token,i.expiresAt=C__(n,r.data.expires_in),i.refreshTokenExpiresAt=C__(n,r.data.refresh_token_expires_in)}delete i.scopes}return{...r,authentication:i}}function C__(e,t){return new Date(e+t*1e3).toISOString()}async function F__(e){let t=e.request||WO,r={client_id:e.clientId};return"scopes"in e&&Array.isArray(e.scopes)&&(r.scope=e.scopes.join(" ")),mUo(t,"POST /login/device/code",r)}async function Vuc(e){let t=e.request||WO,r=await mUo(t,"POST /login/oauth/access_token",{client_id:e.clientId,device_code:e.code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),i={clientType:e.clientType,clientId:e.clientId,token:r.data.access_token,scopes:r.data.scope.split(/\s+/).filter(Boolean)};if("clientSecret"in e&&(i.clientSecret=e.clientSecret),e.clientType==="github-app"){if("refresh_token"in r.data){let n=new Date(r.headers.date).getTime();i.refreshToken=r.data.refresh_token,i.expiresAt=q__(n,r.data.expires_in),i.refreshTokenExpiresAt=q__(n,r.data.refresh_token_expires_in)}delete i.scopes}return{...r,authentication:i}}function q__(e,t){return new Date(e+t*1e3).toISOString()}async function PUo(e){let r=await(e.request||WO)("POST /applications/{client_id}/token",{headers:{authorization:`basic ${btoa(`${e.clientId}:${e.clientSecret}`)}`},client_id:e.clientId,access_token:e.token}),i={clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:e.token,scopes:r.data.scopes};return r.data.expires_at&&(i.expiresAt=r.data.expires_at),e.clientType==="github-app"&&delete i.scopes,{...r,authentication:i}}async function jUo(e){let t=e.request||WO,r=await mUo(t,"POST /login/oauth/access_token",{client_id:e.clientId,client_secret:e.clientSecret,grant_type:"refresh_token",refresh_token:e.refreshToken}),i=new Date(r.headers.date).getTime(),n={clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,token:r.data.access_token,refreshToken:r.data.refresh_token,expiresAt:T__(i,r.data.expires_in),refreshTokenExpiresAt:T__(i,r.data.refresh_token_expires_in)};return{...r,authentication:n}}function T__(e,t){return new Date(e+t*1e3).toISOString()}async function Q__(e){let{request:t,clientType:r,clientId:i,clientSecret:n,token:a,...o}=e,f=await(e.request||WO)("POST /applications/{client_id}/token/scoped",{headers:{authorization:`basic ${btoa(`${i}:${n}`)}`},client_id:i,access_token:a,...o}),s=Object.assign({clientType:r,clientId:i,clientSecret:n,token:f.data.token},f.data.expires_at?{expiresAt:f.data.expires_at}:{});return{...f,authentication:s}}async function GPa(e){let t=e.request||WO,r=btoa(`${e.clientId}:${e.clientSecret}`),i=await t("PATCH /applications/{client_id}/token",{headers:{authorization:`basic ${r}`},client_id:e.clientId,access_token:e.token}),n={clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:i.data.token,scopes:i.data.scopes};return i.data.expires_at&&(n.expiresAt=i.data.expires_at),e.clientType==="github-app"&&delete n.scopes,{...i,authentication:n}}async function HPa(e){let t=e.request||WO,r=btoa(`${e.clientId}:${e.clientSecret}`);return t("DELETE /applications/{client_id}/token",{headers:{authorization:`basic ${r}`},client_id:e.clientId,access_token:e.token})}async function KPa(e){let t=e.request||WO,r=btoa(`${e.clientId}:${e.clientSecret}`);return t("DELETE /applications/{client_id}/grant",{headers:{authorization:`basic ${r}`},client_id:e.clientId,access_token:e.token})}async function L__(e,t){let r=WkS(e,t.auth);if(r)return r;let{data:i}=await F__({clientType:e.clientType,clientId:e.clientId,request:t.request||e.request,scopes:t.auth.scopes||e.scopes});await e.onVerification(i);let n=await Wuc(t.request||e.request,e.clientId,e.clientType,i);return e.authentication=n,n}function WkS(e,t){if(t.refresh===!0||!e.authentication)return!1;if(e.clientType==="github-app")return e.authentication;let r=e.authentication,i=("scopes"in t&&t.scopes||e.scopes).join(" "),n=r.scopes.join(" ");return i===n?r:!1}async function U__(e){await new Promise(t=>setTimeout(t,e*1e3))}async function Wuc(e,t,r,i){try{let n={clientId:t,request:e,code:i.device_code},{authentication:a}=r==="oauth-app"?await Vuc({...n,clientType:"oauth-app"}):await Vuc({...n,clientType:"github-app"});return{type:"token",tokenType:"oauth",...a}}catch(n){if(!n.response)throw n;let a=n.response.data.error;if(a==="authorization_pending")return await U__(i.interval),Wuc(e,t,r,i);if(a==="slow_down")return await U__(i.interval+7),Wuc(e,t,r,i);throw n}}async function xkS(e,t){return L__(e,{auth:t})}async function GkS(e,t,r,i){let n=t.endpoint.merge(r,i);if(/\/login\/(oauth\/access_token|device\/code)$/.test(n.url))return t(n);let{token:a}=await L__(e,{request:t,auth:{type:"oauth"}});return n.headers.authorization=`token ${a}`,t(n)}var HkS="0.0.0-development";function V__(e){let t=e.request||WO.defaults({headers:{"user-agent":`octokit-auth-oauth-device.js/${HkS} ${TR()}`}}),{request:r=t,...i}=e,n=e.clientType==="github-app"?{...i,clientType:"github-app",request:r}:{...i,clientType:"oauth-app",request:r,scopes:e.scopes||[]};if(!e.clientId)throw new Error('[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)');if(!e.onVerification)throw new Error('[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)');return Object.assign(xkS.bind(null,n),{hook:GkS.bind(null,n)})}var x__="0.0.0-development";async function W__(e){if("code"in e.strategyOptions){let{authentication:t}=await N__({clientId:e.clientId,clientSecret:e.clientSecret,clientType:e.clientType,onTokenCreated:e.onTokenCreated,...e.strategyOptions,request:e.request});return{type:"token",tokenType:"oauth",...t}}if("onVerification"in e.strategyOptions){let r=await V__({clientType:e.clientType,clientId:e.clientId,onTokenCreated:e.onTokenCreated,...e.strategyOptions,request:e.request})({type:"oauth"});return{clientSecret:e.clientSecret,...r}}if("token"in e.strategyOptions)return{type:"token",tokenType:"oauth",clientId:e.clientId,clientSecret:e.clientSecret,clientType:e.clientType,onTokenCreated:e.onTokenCreated,...e.strategyOptions};throw new Error("[@octokit/auth-oauth-user] Invalid strategy options")}async function xuc(e,t={}){if(e.authentication||(e.authentication=e.clientType==="oauth-app"?await W__(e):await W__(e)),e.authentication.invalid)throw new Error("[@octokit/auth-oauth-user] Token is invalid");let r=e.authentication;if("expiresAt"in r&&(t.type==="refresh"||new Date(r.expiresAt)<new Date)){let{authentication:i}=await jUo({clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,refreshToken:r.refreshToken,request:e.request});e.authentication={tokenType:"oauth",type:"token",...i}}if(t.type==="refresh"){if(e.clientType==="oauth-app")throw new Error("[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens");if(!r.hasOwnProperty("expiresAt"))throw new Error("[@octokit/auth-oauth-user] Refresh token missing");await e.onTokenCreated?.(e.authentication,{type:t.type})}if(t.type==="check"||t.type==="reset"){let i=t.type==="check"?PUo:GPa;try{let{authentication:n}=await i({clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:e.authentication.token,request:e.request});return e.authentication={tokenType:"oauth",type:"token",...n},t.type==="reset"&&await e.onTokenCreated?.(e.authentication,{type:t.type}),e.authentication}catch(n){throw n.status===404&&(n.message="[@octokit/auth-oauth-user] Token is invalid",e.authentication.invalid=!0),n}}if(t.type==="delete"||t.type==="deleteAuthorization"){let i=t.type==="delete"?HPa:KPa;try{await i({clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:e.authentication.token,request:e.request})}catch(n){if(n.status!==404)throw n}return e.authentication.invalid=!0,e.authentication}return e.authentication}var KkS=/\/applications\/[^/]+\/(token|grant)s?/;function JPa(e){return e&&KkS.test(e)}async function JkS(e,t,r,i={}){let n=t.endpoint.merge(r,i);if(/\/login\/(oauth\/access_token|device\/code)$/.test(n.url))return t(n);if(JPa(n.url)){let o=btoa(`${e.clientId}:${e.clientSecret}`);return n.headers.authorization=`basic ${o}`,t(n)}let{token:a}=e.clientType==="oauth-app"?await xuc({...e,request:t}):await xuc({...e,request:t});return n.headers.authorization="token "+a,t(n)}function WL({clientId:e,clientSecret:t,clientType:r="oauth-app",request:i=WO.defaults({headers:{"user-agent":`octokit-auth-oauth-app.js/${x__} ${TR()}`}}),onTokenCreated:n,...a}){let o=Object.assign({clientType:r,clientId:e,clientSecret:t,onTokenCreated:n,strategyOptions:a,request:i});return Object.assign(xuc.bind(null,o),{hook:JkS.bind(null,o)})}WL.VERSION=x__;async function $kS(e,t){if(t.type==="oauth-app")return{type:"oauth-app",clientId:e.clientId,clientSecret:e.clientSecret,clientType:e.clientType,headers:{authorization:`basic ${btoa(`${e.clientId}:${e.clientSecret}`)}`}};if("factory"in t){let{type:n,...a}={...t,...e};return t.factory(a)}let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.request,...t};return(e.clientType==="oauth-app"?await WL({...r,clientType:e.clientType}):await WL({...r,clientType:e.clientType}))()}async function YkS(e,t,r,i){let n=t.endpoint.merge(r,i);if(/\/login\/(oauth\/access_token|device\/code)$/.test(n.url))return t(n);if(e.clientType==="github-app"&&!JPa(n.url))throw new Error(`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${n.method} ${n.url}" is not supported.`);let a=btoa(`${e.clientId}:${e.clientSecret}`);n.headers.authorization=`basic ${a}`;try{return await t(n)}catch(o){throw o.status!==401||(o.message=`[@octokit/auth-oauth-app] "${n.method} ${n.url}" does not support clientId/clientSecret basic authentication.`),o}}var XkS="0.0.0-development";function wUo(e){let t=Object.assign({request:WO.defaults({headers:{"user-agent":`octokit-auth-oauth-app.js/${XkS} ${TR()}`}}),clientType:"oauth-app"},e);return Object.assign($kS.bind(null,t),{hook:YkS.bind(null,t)})}async function SUo({appId:e,privateKey:t,timeDifference:r,createJwt:i}){try{if(i){let{jwt:o,expiresAt:c}=await i(e,r);return{type:"app",token:o,appId:e,expiresAt:c}}let n={id:e,privateKey:t};r&&Object.assign(n,{now:Math.floor(Date.now()/1e3)+r});let a=await PUs(n);return{type:"app",token:a.token,appId:a.appId,expiresAt:new Date(a.expiration*1e3).toISOString()}}catch(n){throw t==="-----BEGIN RSA PRIVATE KEY-----"?new Error("The 'privateKey` option contains only the first line '-----BEGIN RSA PRIVATE KEY-----'. If you are setting it using a `.env` file, make sure it is set on a single line with newlines replaced by '\n'"):n}}function kkS(){return new X_o(15e3,1e3*60*59)}async function eeM(e,t){let r=Guc(t),i=await e.get(r);if(!i)return;let[n,a,o,c,f,s]=i.split("|"),u=t.permissions||f.split(/,/).reduce((l,p)=>(/!$/.test(p)?l[p.slice(0,-1)]="write":l[p]="read",l),{});return{token:n,createdAt:a,expiresAt:o,permissions:u,repositoryIds:t.repositoryIds,repositoryNames:t.repositoryNames,singleFileName:s,repositorySelection:c}}async function teM(e,t,r){let i=Guc(t),n=t.permissions?"":Object.keys(r.permissions).map(o=>`${o}${r.permissions[o]==="write"?"!":""}`).join(","),a=[r.token,r.createdAt,r.expiresAt,r.repositorySelection,n,r.singleFileName].join("|");await e.set(i,a)}function Guc({installationId:e,permissions:t={},repositoryIds:r=[],repositoryNames:i=[]}){let n=Object.keys(t).sort().map(c=>t[c]==="read"?c:`${c}!`).join(","),a=r.sort().join(","),o=i.join(",");return[e,a,o,n].filter(Boolean).join("|")}function G__({installationId:e,token:t,createdAt:r,expiresAt:i,repositorySelection:n,permissions:a,repositoryIds:o,repositoryNames:c,singleFileName:f}){return Object.assign({type:"token",tokenType:"installation",token:t,installationId:e,permissions:a,createdAt:r,expiresAt:i,repositorySelection:n},o?{repositoryIds:o}:null,c?{repositoryNames:c}:null,f?{singleFileName:f}:null)}async function H__(e,t,r){let i=Number(t.installationId||e.installationId);if(!i)throw new Error("[@octokit/auth-app] installationId option is required for installation authentication.");if(t.factory){let{type:a,factory:o,oauthApp:c,...f}={...e,...t};return o(f)}let n=r||e.request;return reM(e,{...t,installationId:i},n)}var EUo=new Map;function reM(e,t,r){let i=Guc(t);if(EUo.has(i))return EUo.get(i);let n=ieM(e,t,r).finally(()=>EUo.delete(i));return EUo.set(i,n),n}async function ieM(e,t,r){if(!t.refresh){let O=await eeM(e.cache,t);if(O){let{token:A,createdAt:g,expiresAt:m,permissions:j,repositoryIds:M,repositoryNames:E,singleFileName:D,repositorySelection:B}=O;return G__({installationId:t.installationId,token:A,createdAt:g,expiresAt:m,permissions:j,repositorySelection:B,repositoryIds:M,repositoryNames:E,singleFileName:D})}}let i=await SUo(e),n={installation_id:t.installationId,mediaType:{previews:["machine-man"]},headers:{authorization:`bearer ${i.token}`}};t.repositoryIds&&Object.assign(n,{repository_ids:t.repositoryIds}),t.repositoryNames&&Object.assign(n,{repositories:t.repositoryNames}),t.permissions&&Object.assign(n,{permissions:t.permissions});let{data:{token:a,expires_at:o,repositories:c,permissions:f,repository_selection:s,single_file:u}}=await r("POST /app/installations/{installation_id}/access_tokens",n),l=f||{},p=s||"all",_=c?c.map(O=>O.id):void 0,h=c?c.map(O=>O.name):void 0,y=new Date().toISOString(),b={token:a,createdAt:y,expiresAt:o,repositorySelection:p,permissions:l,repositoryIds:_,repositoryNames:h};u&&Object.assign(n,{singleFileName:u}),await teM(e.cache,t,b);let v={installationId:t.installationId,token:a,createdAt:y,expiresAt:o,repositorySelection:p,permissions:l,repositoryIds:_,repositoryNames:h};return u&&Object.assign(v,{singleFileName:u}),G__(v)}async function neM(e,t){switch(t.type){case"app":return SUo(e);case"oauth-app":return e.oauthApp({type:"oauth-app"});case"installation":return H__(e,{...t,type:"installation"});case"oauth-user":return e.oauthApp(t);default:throw new Error(`Invalid auth type: ${t.type}`)}}var aeM=["/app","/app/hook/config","/app/hook/deliveries","/app/hook/deliveries/{delivery_id}","/app/hook/deliveries/{delivery_id}/attempts","/app/installations","/app/installations/{installation_id}","/app/installations/{installation_id}/access_tokens","/app/installations/{installation_id}/suspended","/app/installation-requests","/marketplace_listing/accounts/{account_id}","/marketplace_listing/plan","/marketplace_listing/plans","/marketplace_listing/plans/{plan_id}/accounts","/marketplace_listing/stubbed/accounts/{account_id}","/marketplace_listing/stubbed/plan","/marketplace_listing/stubbed/plans","/marketplace_listing/stubbed/plans/{plan_id}/accounts","/orgs/{org}/installation","/repos/{owner}/{repo}/installation","/users/{username}/installation"];function oeM(e){let r=`^(?:${e.map(i=>i.split("/").map(n=>n.startsWith("{")?"(?:.+?)":n).join("/")).map(i=>`(?:${i})`).join("|")})$`;return new RegExp(r,"i")}var ueM=oeM(aeM);function seM(e){return!!e&&ueM.test(e.split("?")[0])}var ceM=5*1e3;function leM(e){return!(e.message.match(/'Expiration time' claim \('exp'\) must be a numeric value representing the future time at which the assertion expires/)||e.message.match(/'Issued at' claim \('iat'\) must be an Integer representing the time that the assertion was issued/))}async function feM(e,t,r,i){let n=t.endpoint.merge(r,i),a=n.url;if(/\/login\/oauth\/access_token$/.test(a))return t(n);if(seM(a.replace(t.endpoint.DEFAULTS.baseUrl,""))){let{token:f}=await SUo(e);n.headers.authorization=`bearer ${f}`;let s;try{s=await t(n)}catch(u){if(leM(u)||typeof u.response.headers.date>"u")throw u;let l=Math.floor((Date.parse(u.response.headers.date)-Date.parse(new Date().toString()))/1e3);e.log.warn(u.message),e.log.warn(`[@octokit/auth-app] GitHub API time and system time are different by ${l} seconds. Retrying request with the difference accounted for.`);let{token:p}=await SUo({...e,timeDifference:l});return n.headers.authorization=`bearer ${p}`,t(n)}return s}if(JPa(a)){let f=await e.oauthApp({type:"oauth-app"});return n.headers.authorization=f.headers.authorization,t(n)}let{token:o,createdAt:c}=await H__(e,{},t.defaults({baseUrl:n.baseUrl}));return n.headers.authorization=`token ${o}`,K__(e,t,n,c)}async function K__(e,t,r,i,n=0){let a=+new Date-+new Date(i);try{return await t(r)}catch(o){if(o.status!==401)throw o;if(a>=ceM)throw n>0&&(o.message=`After ${n} retries within ${a/1e3}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`),o;++n;let c=n*1e3;return e.log.warn(`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${n}, wait: ${c/1e3}s)`),await new Promise(f=>setTimeout(f,c)),K__(e,t,r,i,n)}}var deM="8.1.2";function CQn(e){if(!e.appId)throw new Error("[@octokit/auth-app] appId option is required");if(!e.privateKey&&!e.createJwt)throw new Error("[@octokit/auth-app] privateKey option is required");if(e.privateKey&&e.createJwt)throw new Error("[@octokit/auth-app] privateKey and createJwt options are mutually exclusive");if("installationId"in e&&!e.installationId)throw new Error("[@octokit/auth-app] installationId is set to a falsy value");let t=e.log||{};typeof t.warn!="function"&&(t.warn=console.warn.bind(console));let r=e.request||WO.defaults({headers:{"user-agent":`octokit-auth-app.js/${deM} ${TR()}`}}),i=Object.assign({request:r,cache:kkS()},e,e.installationId?{installationId:Number(e.installationId)}:{},{log:t,oauthApp:wUo({clientType:"github-app",clientId:e.clientId||"",clientSecret:e.clientSecret||"",request:r})});return Object.assign(neM.bind(null,i),{hook:feM.bind(null,i)})}async function peM(e){return{type:"unauthenticated",reason:e}}function _eM(e){return e.status!==403||!e.response?!1:e.response.headers["x-ratelimit-remaining"]==="0"}var heM=/\babuse\b/i;function yeM(e){return e.status!==403?!1:heM.test(e.message)}async function beM(e,t,r,i){let n=t.endpoint.merge(r,i);return t(n).catch(a=>{throw a.status===404?(a.message=`Not found. May be due to lack of authentication. Reason: ${e}`,a):_eM(a)?(a.message=`API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${e}`,a):yeM(a)?(a.message=`You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${e}`,a):a.status===401?(a.message=`Unauthorized. "${n.method} ${n.url}" failed most likely due to lack of authentication. Reason: ${e}`,a):(a.status>=400&&a.status<500&&(a.message=a.message.replace(/\.?$/,`. May be caused by lack of authentication (${e}).`)),a)})}var SJi=function(t){if(!t||!t.reason)throw new Error("[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth");return Object.assign(peM.bind(null,t.reason),{hook:beM.bind(null,t.reason)})};var J__="8.0.3";function $__(e,t,r){if(Array.isArray(t)){for(let i of t)$__(e,i,r);return}e.eventHandlers[t]||(e.eventHandlers[t]=[]),e.eventHandlers[t].push(r)}var veM=qCi.defaults({userAgent:`octokit-oauth-app.js/${J__} ${TR()}`});async function Gvi(e,t){let{name:r,action:i}=t;if(e.eventHandlers[`${r}.${i}`])for(let n of e.eventHandlers[`${r}.${i}`])await n(t);if(e.eventHandlers[r])for(let n of e.eventHandlers[r])await n(t)}async function geM(e,t){return e.octokit.auth({type:"oauth-user",...t,async factory(r){let i=new e.Octokit({authStrategy:WL,auth:r}),n=await i.auth({type:"get"});return await Gvi(e,{name:"token",action:"created",token:n.token,scopes:n.scopes,authentication:n,octokit:i}),i}})}function OeM(e,t){let r={clientId:e.clientId,request:e.octokit.request,...t,allowSignup:e.allowSignup??t.allowSignup,redirectUrl:t.redirectUrl??e.redirectUrl,scopes:t.scopes??e.defaultScopes};return z__({clientType:e.clientType,...r})}async function AeM(e,t){let r=await e.octokit.auth({type:"oauth-user",...t});return await Gvi(e,{name:"token",action:"created",token:r.token,scopes:r.scopes,authentication:r,octokit:new e.Octokit({authStrategy:WL,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.token,scopes:r.scopes,refreshToken:r.refreshToken,expiresAt:r.expiresAt,refreshTokenExpiresAt:r.refreshTokenExpiresAt}})}),{authentication:r}}async function meM(e,t){let r=await PUo({clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t});return Object.assign(r.authentication,{type:"token",tokenType:"oauth"}),r}async function PeM(e,t){let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t};if(e.clientType==="oauth-app"){let a=await GPa({clientType:"oauth-app",...r}),o=Object.assign(a.authentication,{type:"token",tokenType:"oauth"});return await Gvi(e,{name:"token",action:"reset",token:a.authentication.token,scopes:a.authentication.scopes||void 0,authentication:o,octokit:new e.Octokit({authStrategy:WL,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:a.authentication.token,scopes:a.authentication.scopes}})}),{...a,authentication:o}}let i=await GPa({clientType:"github-app",...r}),n=Object.assign(i.authentication,{type:"token",tokenType:"oauth"});return await Gvi(e,{name:"token",action:"reset",token:i.authentication.token,authentication:n,octokit:new e.Octokit({authStrategy:WL,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:i.authentication.token}})}),{...i,authentication:n}}async function jeM(e,t){if(e.clientType==="oauth-app")throw new Error("[@octokit/oauth-app] app.refreshToken() is not supported for OAuth Apps");let r=await jUo({clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,refreshToken:t.refreshToken}),i=Object.assign(r.authentication,{type:"token",tokenType:"oauth"});return await Gvi(e,{name:"token",action:"refreshed",token:r.authentication.token,authentication:i,octokit:new e.Octokit({authStrategy:WL,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.authentication.token}})}),{...r,authentication:i}}async function weM(e,t){if(e.clientType==="oauth-app")throw new Error("[@octokit/oauth-app] app.scopeToken() is not supported for OAuth Apps");let r=await Q__({clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t}),i=Object.assign(r.authentication,{type:"token",tokenType:"oauth"});return await Gvi(e,{name:"token",action:"scoped",token:r.authentication.token,authentication:i,octokit:new e.Octokit({authStrategy:WL,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.authentication.token}})}),{...r,authentication:i}}async function EeM(e,t){let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t},i=e.clientType==="oauth-app"?await HPa({clientType:"oauth-app",...r}):await HPa({clientType:"github-app",...r});return await Gvi(e,{name:"token",action:"deleted",token:t.token,octokit:new e.Octokit({authStrategy:SJi,auth:{reason:'Handling "token.deleted" event. The access for the token has been revoked.'}})}),i}async function SeM(e,t){let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t},i=e.clientType==="oauth-app"?await KPa({clientType:"oauth-app",...r}):await KPa({clientType:"github-app",...r});return await Gvi(e,{name:"token",action:"deleted",token:t.token,octokit:new e.Octokit({authStrategy:SJi,auth:{reason:'Handling "token.deleted" event. The access for the token has been revoked.'}})}),await Gvi(e,{name:"authorization",action:"deleted",token:t.token,octokit:new e.Octokit({authStrategy:SJi,auth:{reason:'Handling "authorization.deleted" event. The access for the app has been revoked.'}})}),i}var MUo=class{static VERSION=J__;static defaults(e){return class extends this{constructor(...r){super({...e,...r[0]})}}}constructor(e){let t=e.Octokit||veM;this.type=e.clientType||"oauth-app";let r=new t({authStrategy:wUo,auth:{clientType:this.type,clientId:e.clientId,clientSecret:e.clientSecret}}),i={clientType:this.type,clientId:e.clientId,clientSecret:e.clientSecret,defaultScopes:e.defaultScopes||[],allowSignup:e.allowSignup,baseUrl:e.baseUrl,redirectUrl:e.redirectUrl,log:e.log,Octokit:t,octokit:r,eventHandlers:{}};this.on=$__.bind(null,i),this.octokit=r,this.getUserOctokit=geM.bind(null,i),this.getWebFlowAuthorizationUrl=OeM.bind(null,i),this.createToken=AeM.bind(null,i),this.checkToken=meM.bind(null,i),this.resetToken=PeM.bind(null,i),this.refreshToken=jeM.bind(null,i),this.scopeToken=weM.bind(null,i),this.deleteToken=EeM.bind(null,i),this.deleteAuthorization=SeM.bind(null,i)}type;on;octokit;getUserOctokit;getWebFlowAuthorizationUrl;createToken;checkToken;resetToken;refreshToken;scopeToken;deleteToken;deleteAuthorization};var Y__=require("crypto"),Z__=require("crypto"),Huc=require("buffer"),X__="6.0.0";async function DUo(e,t){if(!e||!t)throw new TypeError("[@octokit/webhooks-methods] secret & payload required for sign()");if(typeof t!="string")throw new TypeError("[@octokit/webhooks-methods] payload must be a string");let r="sha256";return`${r}=${(0,Y__.createHmac)(r,e).update(t).digest("hex")}`}DUo.VERSION=X__;async function $Pa(e,t,r){if(!e||!t||!r)throw new TypeError("[@octokit/webhooks-methods] secret, eventPayload & signature required");if(typeof t!="string")throw new TypeError("[@octokit/webhooks-methods] eventPayload must be a string");let i=Huc.Buffer.from(r),n=Huc.Buffer.from(await DUo(e,t));return i.length!==n.length?!1:(0,Z__.timingSafeEqual)(i,n)}$Pa.VERSION=X__;async function k__(e,t,r,i){if(await $Pa(e,t,r))return!0;if(i!==void 0)for(let a of i){let o=await $Pa(a,t,r);if(o)return o}return!1}var rh_=(e={})=>(typeof e.debug!="function"&&(e.debug=()=>{}),typeof e.info!="function"&&(e.info=()=>{}),typeof e.warn!="function"&&(e.warn=console.warn.bind(console)),typeof e.error!="function"&&(e.error=console.error.bind(console)),e),MeM=["branch_protection_configuration","branch_protection_configuration.disabled","branch_protection_configuration.enabled","branch_protection_rule","branch_protection_rule.created","branch_protection_rule.deleted","branch_protection_rule.edited","check_run","check_run.completed","check_run.created","check_run.requested_action","check_run.rerequested","check_suite","check_suite.completed","check_suite.requested","check_suite.rerequested","code_scanning_alert","code_scanning_alert.appeared_in_branch","code_scanning_alert.closed_by_user","code_scanning_alert.created","code_scanning_alert.fixed","code_scanning_alert.reopened","code_scanning_alert.reopened_by_user","commit_comment","commit_comment.created","create","custom_property","custom_property.created","custom_property.deleted","custom_property.promote_to_enterprise","custom_property.updated","custom_property_values","custom_property_values.updated","delete","dependabot_alert","dependabot_alert.auto_dismissed","dependabot_alert.auto_reopened","dependabot_alert.created","dependabot_alert.dismissed","dependabot_alert.fixed","dependabot_alert.reintroduced","dependabot_alert.reopened","deploy_key","deploy_key.created","deploy_key.deleted","deployment","deployment.created","deployment_protection_rule","deployment_protection_rule.requested","deployment_review","deployment_review.approved","deployment_review.rejected","deployment_review.requested","deployment_status","deployment_status.created","discussion","discussion.answered","discussion.category_changed","discussion.closed","discussion.created","discussion.deleted","discussion.edited","discussion.labeled","discussion.locked","discussion.pinned","discussion.reopened","discussion.transferred","discussion.unanswered","discussion.unlabeled","discussion.unlocked","discussion.unpinned","discussion_comment","discussion_comment.created","discussion_comment.deleted","discussion_comment.edited","fork","github_app_authorization","github_app_authorization.revoked","gollum","installation","installation.created","installation.deleted","installation.new_permissions_accepted","installation.suspend","installation.unsuspend","installation_repositories","installation_repositories.added","installation_repositories.removed","installation_target","installation_target.renamed","issue_comment","issue_comment.created","issue_comment.deleted","issue_comment.edited","issues","issues.assigned","issues.closed","issues.deleted","issues.demilestoned","issues.edited","issues.labeled","issues.locked","issues.milestoned","issues.opened","issues.pinned","issues.reopened","issues.transferred","issues.typed","issues.unassigned","issues.unlabeled","issues.unlocked","issues.unpinned","issues.untyped","label","label.created","label.deleted","label.edited","marketplace_purchase","marketplace_purchase.cancelled","marketplace_purchase.changed","marketplace_purchase.pending_change","marketplace_purchase.pending_change_cancelled","marketplace_purchase.purchased","member","member.added","member.edited","member.removed","membership","membership.added","membership.removed","merge_group","merge_group.checks_requested","merge_group.destroyed","meta","meta.deleted","milestone","milestone.closed","milestone.created","milestone.deleted","milestone.edited","milestone.opened","org_block","org_block.blocked","org_block.unblocked","organization","organization.deleted","organization.member_added","organization.member_invited","organization.member_removed","organization.renamed","package","package.published","package.updated","page_build","personal_access_token_request","personal_access_token_request.approved","personal_access_token_request.cancelled","personal_access_token_request.created","personal_access_token_request.denied","ping","project","project.closed","project.created","project.deleted","project.edited","project.reopened","project_card","project_card.converted","project_card.created","project_card.deleted","project_card.edited","project_card.moved","project_column","project_column.created","project_column.deleted","project_column.edited","project_column.moved","projects_v2","projects_v2.closed","projects_v2.created","projects_v2.deleted","projects_v2.edited","projects_v2.reopened","projects_v2_item","projects_v2_item.archived","projects_v2_item.converted","projects_v2_item.created","projects_v2_item.deleted","projects_v2_item.edited","projects_v2_item.reordered","projects_v2_item.restored","projects_v2_status_update","projects_v2_status_update.created","projects_v2_status_update.deleted","projects_v2_status_update.edited","public","pull_request","pull_request.assigned","pull_request.auto_merge_disabled","pull_request.auto_merge_enabled","pull_request.closed","pull_request.converted_to_draft","pull_request.demilestoned","pull_request.dequeued","pull_request.edited","pull_request.enqueued","pull_request.labeled","pull_request.locked","pull_request.milestoned","pull_request.opened","pull_request.ready_for_review","pull_request.reopened","pull_request.review_request_removed","pull_request.review_requested","pull_request.synchronize","pull_request.unassigned","pull_request.unlabeled","pull_request.unlocked","pull_request_review","pull_request_review.dismissed","pull_request_review.edited","pull_request_review.submitted","pull_request_review_comment","pull_request_review_comment.created","pull_request_review_comment.deleted","pull_request_review_comment.edited","pull_request_review_thread","pull_request_review_thread.resolved","pull_request_review_thread.unresolved","push","registry_package","registry_package.published","registry_package.updated","release","release.created","release.deleted","release.edited","release.prereleased","release.published","release.released","release.unpublished","repository","repository.archived","repository.created","repository.deleted","repository.edited","repository.privatized","repository.publicized","repository.renamed","repository.transferred","repository.unarchived","repository_advisory","repository_advisory.published","repository_advisory.reported","repository_dispatch","repository_dispatch.sample.collected","repository_import","repository_ruleset","repository_ruleset.created","repository_ruleset.deleted","repository_ruleset.edited","repository_vulnerability_alert","repository_vulnerability_alert.create","repository_vulnerability_alert.dismiss","repository_vulnerability_alert.reopen","repository_vulnerability_alert.resolve","secret_scanning_alert","secret_scanning_alert.created","secret_scanning_alert.publicly_leaked","secret_scanning_alert.reopened","secret_scanning_alert.resolved","secret_scanning_alert.validated","secret_scanning_alert_location","secret_scanning_alert_location.created","secret_scanning_scan","secret_scanning_scan.completed","security_advisory","security_advisory.published","security_advisory.updated","security_advisory.withdrawn","security_and_analysis","sponsorship","sponsorship.cancelled","sponsorship.created","sponsorship.edited","sponsorship.pending_cancellation","sponsorship.pending_tier_change","sponsorship.tier_changed","star","star.created","star.deleted","status","sub_issues","sub_issues.parent_issue_added","sub_issues.parent_issue_removed","sub_issues.sub_issue_added","sub_issues.sub_issue_removed","team","team.added_to_repository","team.created","team.deleted","team.edited","team.removed_from_repository","team_add","watch","watch.started","workflow_dispatch","workflow_job","workflow_job.completed","workflow_job.in_progress","workflow_job.queued","workflow_job.waiting","workflow_run","workflow_run.completed","workflow_run.in_progress","workflow_run.requested"];function DeM(e,t={}){if(typeof e!="string")throw new TypeError("eventName must be of type string");if(e==="*")throw new TypeError('Using the "*" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.onAny() method instead');if(e==="error")throw new TypeError('Using the "error" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.onError() method instead');if(t.onUnknownEventName!=="ignore"&&!MeM.includes(e)){if(t.onUnknownEventName!=="warn")throw new TypeError(`"${e}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`);(t.log||console).warn(`"${e}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`)}}function Kuc(e,t,r){e.hooks[t]||(e.hooks[t]=[]),e.hooks[t].push(r)}function ih_(e,t,r){if(Array.isArray(t)){t.forEach(i=>ih_(e,i,r));return}DeM(t,{onUnknownEventName:"warn",log:e.log}),Kuc(e,t,r)}function BeM(e,t){Kuc(e,"*",t)}function IeM(e,t){Kuc(e,"error",t)}function eh_(e,t){let r;try{r=e(t)}catch(i){console.log('FATAL: Error occurred in "error" event handler'),console.log(i)}r&&r.catch&&r.catch(i=>{console.log('FATAL: Error occurred in "error" event handler'),console.log(i)})}function CeM(e,t,r){let i=[e.hooks[r],e.hooks["*"]];return t&&i.unshift(e.hooks[`${r}.${t}`]),[].concat(...i.filter(Boolean))}function qeM(e,t){let r=e.hooks.error||[];if(t instanceof Error){let o=Object.assign(new AggregateError([t],t.message),{event:t});return r.forEach(c=>eh_(c,o)),Promise.reject(o)}if(!t||!t.name){let o=new Error("Event name not passed");throw new AggregateError([o],o.message)}if(!t.payload){let o=new Error("Event name not passed");throw new AggregateError([o],o.message)}let i=CeM(e,"action"in t.payload?t.payload.action:null,t.name);if(i.length===0)return Promise.resolve();let n=[],a=i.map(o=>{let c=Promise.resolve(t);return e.transform&&(c=c.then(e.transform)),c.then(f=>o(f)).catch(f=>n.push(Object.assign(f,{event:t})))});return Promise.all(a).then(()=>{if(n.length===0)return;let o=new AggregateError(n,n.map(c=>c.message).join(`
1415
1415
  `));throw Object.assign(o,{event:t}),r.forEach(c=>eh_(c,o)),o})}function nh_(e,t,r){if(Array.isArray(t)){t.forEach(i=>nh_(e,i,r));return}if(e.hooks[t]){for(let i=e.hooks[t].length-1;i>=0;i--)if(e.hooks[t][i]===r){e.hooks[t].splice(i,1);return}}}function TeM(e){let t={hooks:{},log:rh_(e&&e.log)};return e&&e.transform&&(t.transform=e.transform),{on:ih_.bind(null,t),onAny:BeM.bind(null,t),onError:IeM.bind(null,t),removeListener:nh_.bind(null,t),receive:qeM.bind(null,t)}}async function ReM(e,t){if(!await k__(e.secret,t.payload,t.signature,e.additionalSecrets).catch(()=>!1)){let n=new Error("[@octokit/webhooks] signature does not match event payload and secret");return n.event=t,n.status=400,e.eventHandler.receive(n)}let i;try{i=JSON.parse(t.payload)}catch(n){throw n.message="Invalid JSON",n.status=400,new AggregateError([n],n.message)}return e.eventHandler.receive({id:t.id,name:t.name,payload:i})}var th_=new TextDecoder("utf-8",{fatal:!1}),K7W=th_.decode.bind(th_);var ah_=class{sign;verify;on;onAny;onError;removeListener;receive;verifyAndReceive;constructor(e){if(!e||!e.secret)throw new Error("[@octokit/webhooks] options.secret required");let t={eventHandler:TeM(e),secret:e.secret,additionalSecrets:e.additionalSecrets,hooks:{},log:rh_(e.log)};this.sign=DUo.bind(null,e.secret),this.verify=$Pa.bind(null,e.secret),this.on=t.eventHandler.on,this.onAny=t.eventHandler.onAny,this.onError=t.eventHandler.onError,this.removeListener=t.eventHandler.removeListener,this.receive=t.eventHandler.receive,this.verifyAndReceive=ReM.bind(null,t)}};var zeM="16.1.2";function NeM(e,t){return new ah_({secret:t.secret,transform:async r=>{if(!("installation"in r.payload)||typeof r.payload.installation!="object"){let a=new e.constructor({authStrategy:SJi,auth:{reason:'"installation" key missing in webhook event payload'}});return{...r,octokit:a}}let i=r.payload.installation.id,n=await e.auth({type:"installation",installationId:i,factory(a){return new a.octokit.constructor({...a.octokitOptions,authStrategy:CQn,auth:{...a,installationId:i}})}});return n.hook.before("request",a=>{a.headers["x-github-delivery"]=r.id}),{...r,octokit:n}}})}async function oh_(e,t){return e.octokit.auth({type:"installation",installationId:t,factory(r){let i={...r.octokitOptions,authStrategy:CQn,auth:{...r,installationId:t}};return new r.octokit.constructor(i)}})}function FeM(e){return Object.assign(QeM.bind(null,e),{iterator:uh_.bind(null,e)})}async function QeM(e,t){let r=uh_(e)[Symbol.asyncIterator](),i=await r.next();for(;!i.done;)await t(i.value),i=await r.next()}function uh_(e){return{async*[Symbol.asyncIterator](){let t=OUo.iterator(e.octokit,"GET /app/installations");for await(let{data:r}of t)for(let i of r)yield{octokit:await oh_(e,i.id),installation:i}}}}function UeM(e){return Object.assign(LeM.bind(null,e),{iterator:sh_.bind(null,e)})}async function LeM(e,t,r){let i=sh_(e,r?t:void 0)[Symbol.asyncIterator](),n=await i.next();for(;!n.done;)r?await r(n.value):await t(n.value),n=await i.next()}function VeM(e,t){return{async*[Symbol.asyncIterator](){yield{octokit:await e.getInstallationOctokit(t)}}}}function sh_(e,t){return{async*[Symbol.asyncIterator](){let r=t?VeM(e,t.installationId):e.eachInstallation.iterator();for await(let{octokit:i}of r){let n=OUo.iterator(i,"GET /installation/repositories");for await(let{data:a}of n)for(let o of a)yield{octokit:i,repository:o}}}}}function WeM(e){let t;return async function(i={}){t||(t=xeM(e));let n=await t,a=new URL(n);return i.target_id!==void 0&&(a.pathname+="/permissions",a.searchParams.append("target_id",i.target_id.toFixed())),i.state!==void 0&&a.searchParams.append("state",i.state),a.href}}async function xeM(e){let{data:t}=await e.octokit.request("GET /app");if(!t)throw new Error("[@octokit/app] unable to fetch metadata for app");return`${t.html_url}/installations/new`}var ch_=class{static VERSION=zeM;static defaults(e){return class extends this{constructor(...r){super({...e,...r[0]})}}}octokit;webhooks;oauth;getInstallationOctokit;eachInstallation;eachRepository;getInstallationUrl;log;constructor(e){let t=e.Octokit||qCi,r=Object.assign({appId:e.appId,privateKey:e.privateKey},e.oauth?{clientId:e.oauth.clientId,clientSecret:e.oauth.clientSecret}:{}),i={authStrategy:CQn,auth:r};"log"in e&&typeof e.log<"u"&&(i.log=e.log),this.octokit=new t(i),this.log=Object.assign({debug:()=>{},info:()=>{},warn:console.warn.bind(console),error:console.error.bind(console)},e.log),e.webhooks?this.webhooks=NeM(this.octokit,e.webhooks):Object.defineProperty(this,"webhooks",{get(){throw new Error("[@octokit/app] webhooks option not set")}}),e.oauth?this.oauth=new MUo({...e.oauth,clientType:"github-app",Octokit:t}):Object.defineProperty(this,"oauth",{get(){throw new Error("[@octokit/app] oauth.clientId / oauth.clientSecret options are not set")}}),this.getInstallationOctokit=oh_.bind(null,this),this.eachInstallation=FeM(this),this.eachRepository=UeM(this),this.getInstallationUrl=WeM(this)}};var GeM="0.0.0-development",BUo=qCi.plugin(Quc,Ruc,j__,Uuc,AUo).defaults({userAgent:`octokit.js/${GeM}`,throttle:{onRateLimit:HeM,onSecondaryRateLimit:KeM}});function HeM(e,t,r){if(r.log.warn(`Request quota exhausted for request ${t.method} ${t.url}`),t.request.retryCount===0)return r.log.info(`Retrying after ${e} seconds!`),!0}function KeM(e,t,r){if(r.log.warn(`SecondaryRateLimit detected for request ${t.method} ${t.url}`),t.request.retryCount===0)return r.log.info(`Retrying after ${e} seconds!`),!0}var yHW=ch_.defaults({Octokit:BUo}),bHW=MUo.defaults({Octokit:BUo});var lh_=ae(A_e(),1);async function Juc({packageName:e,generatorInvocation:t}){if(t.language==null||e==null)return;let r=await JeM({packageName:e,language:t.language,githubRepository:keM(t)});return r==null?void 0:lh_.default.inc(r,"patch")??void 0}async function JeM({packageName:e,language:t,githubRepository:r}){let i;switch(t){case"typescript":i=await $eM(e);break;case"python":i=await YeM(e);break;case"csharp":case"go":case"java":case"ruby":case"php":case"swift":break}return i!=null||r!=null&&(i=await XeM(r)),i}async function $eM(e){try{return await LPa(e)}catch{return}}async function YeM(e){try{let t=await fetch(`https://pypi.org/pypi/${e}/json`);return t.ok?(await t.json()).info.version:void 0}catch{return}}async function XeM(e){try{let{owner:t,repo:r}=ZeM(e);return(await new BUo().rest.repos.listTags({owner:t,repo:r,per_page:1})).data?.[0]?.name}catch{return}}function ZeM(e){let[t,r]=e.split("/");if(t==null||r==null)throw new Error(`Invalid github repository: ${e}`);return{owner:t,repo:r}}function keM(e){if(e.outputMode.type==="githubV2")return`${e.outputMode.githubV2.owner}/${e.outputMode.githubV2.repo}`}var rK=class extends _Ft{definition;sources;type="fern";constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var etM={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!0,respectReadonlySchemas:!1,respectNullableSchemas:!0,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!0,useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,wrapReferencesToNullableInOptional:!1,coerceOptionalSchemasToNullable:!1,groupEnvironmentsByHost:!1,removeDiscriminantsFromSchemas:wn.RemoveDiscriminantsFromSchemas.Always};function ttM(e){let{defaults:t,options:r,overrides:i,overrideOnly:n=new Set,undefinedIfAbsent:a=new Set}=e,o={};for(let c of Object.keys(t))n.has(c)?o[c]=i?.[c]!==void 0?i[c]:t[c]:a.has(c)?o[c]=i?.[c]!==void 0?i[c]:r?.[c]!==void 0?r[c]:void 0:o[c]=i?.[c]??r?.[c]??t[c];return o}function MJi({options:e,overrides:t}){return ttM({defaults:etM,options:e,overrides:t})}var xL={openapi:e=>({...e,type:"openapi",_visit:function(t){return xL._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return xL._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 qQn={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return qQn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var yz={basic:e=>({...e,type:"basic",_visit:function(t){return yz._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return yz._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return yz._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return yz._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return yz._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 Sl={primitive:e=>({value:e,type:"primitive",_visit:function(t){return Sl._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Sl._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return Sl._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return Sl._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return Sl._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return Sl._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Sl._visit(this,t)}}),null:e=>({...e,type:"null",_visit:function(t){return Sl._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return Sl._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"null":return t.null(e);case"unknown":return t.unknown(e.value);default:return t._other(e)}}};var Ha={int:e=>({value:e,type:"int",_visit:function(t){return Ha._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return Ha._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return Ha._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return Ha._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return Ha._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return Ha._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Ha._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return Ha._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return Ha._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return Ha._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return Ha._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 TCi={boolean:e=>({value:e,type:"boolean",_visit:function(t){return TCi._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return TCi._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 RCi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return RCi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return RCi._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 IUo={};Kt(IUo,{Availability:()=>bz,CustomCodeSample:()=>fGt,EndpointExample:()=>G0e,EndpointResponseExample:()=>H0e,HttpMethod:()=>gz,LiteralSchemaValue:()=>Fj,MultipartRequestPropertyEncoding:()=>Xuc,MultipartSchema:()=>dGt,OneOfSchema:()=>pGt,Pagination:()=>Dhe,PrimitiveSchemaValue:()=>ah,Request:()=>yFt,Response:()=>KQ,RetriesConfiguration:()=>YPa,Schema:()=>Zs,SupportedSdkLanguage:()=>vz,WebhookHttpMethod:()=>Yuc,WebsocketMessageOrigin:()=>$uc});var $uc={Client:"client",Server:"server",_visit:(e,t)=>{switch(e){case $uc.Client:return t.client();case $uc.Server:return t.server();default:return t._other()}}};var Yuc={Get:"GET",Post:"POST",_visit:(e,t)=>{switch(e){case Yuc.Get:return t.get();case Yuc.Post:return t.post();default:return t._other()}}};var bz={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case bz.GenerallyAvailable:return t.generallyAvailable();case bz.Beta:return t.beta();case bz.Deprecated:return t.deprecated();default:return t._other()}}};var YPa={disabled:e=>({value:e,type:"disabled",_visit:function(t){return YPa._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"disabled":return t.disabled(e.value);default:return t._other(e)}}};var Dhe={cursor:e=>({...e,type:"cursor",_visit:function(t){return Dhe._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return Dhe._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return Dhe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var fGt={language:e=>({...e,type:"language",_visit:function(t){return fGt._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return fGt._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 vz={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 vz.Curl:return t.curl();case vz.Python:return t.python();case vz.Javascript:return t.javascript();case vz.Typescript:return t.typescript();case vz.Go:return t.go();case vz.Ruby:return t.ruby();case vz.Csharp:return t.csharp();case vz.Java:return t.java();case vz.Js:return t.js();case vz.Node:return t.node();case vz.Ts:return t.ts();case vz.Nodets:return t.nodets();case vz.Golang:return t.golang();case vz.Dotnet:return t.dotnet();case vz.Jvm:return t.jvm();default:return t._other()}}};var G0e={unknown:e=>({value:e,type:"unknown",_visit:function(t){return G0e._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return G0e._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 H0e={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return H0e._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return H0e._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 gz={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case gz.Get:return t.get();case gz.Post:return t.post();case gz.Put:return t.put();case gz.Patch:return t.patch();case gz.Delete:return t.delete();case gz.Head:return t.head();case gz.Options:return t.options();case gz.Trace:return t.trace();default:return t._other()}}};var yFt={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return yFt._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return yFt._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return yFt._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return yFt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var Xuc={Json:"json",Form:"form",_visit:(e,t)=>{switch(e){case Xuc.Json:return t.json();case Xuc.Form:return t.form();default:return t._other()}}};var dGt={file:e=>({...e,type:"file",_visit:function(t){return dGt._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return dGt._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 KQ={file:e=>({...e,type:"file",_visit:function(t){return KQ._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return KQ._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return KQ._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return KQ._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return KQ._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return KQ._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return KQ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Zs={primitive:e=>({...e,type:"primitive",_visit:function(t){return Zs._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Zs._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Zs._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Zs._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Zs._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Zs._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Zs._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Zs._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Zs._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Zs._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Zs._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 ah={int:e=>({...e,type:"int",_visit:function(t){return ah._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return ah._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return ah._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return ah._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return ah._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return ah._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return ah._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return ah._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return ah._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return ah._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return ah._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 Fj={boolean:e=>({value:e,type:"boolean",_visit:function(t){return Fj._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Fj._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 pGt={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return pGt._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return pGt._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 bx={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return bx._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return bx._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return bx._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return bx._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var mP={file:e=>({...e,type:"file",_visit:function(t){return mP._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return mP._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return mP._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return mP._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return mP._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return mP._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return mP._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var ri={primitive:e=>({...e,type:"primitive",_visit:function(t){return ri._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ri._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return ri._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return ri._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return ri._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ri._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return ri._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return ri._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ri._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return ri._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return ri._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 Bhe={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return Bhe._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return Bhe._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 Ln={int:e=>({...e,type:"int",_visit:function(t){return Ln._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Ln._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Ln._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Ln._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Ln._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Ln._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Ln._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Ln._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Ln._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Ln._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Ln._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 Ns={};Kt(Ns,{AllOfPropertyConflict:()=>nUn,ArraySchema:()=>$4o,ArraySchemaWithExample:()=>E3o,Availability:()=>LUo,Base64WithExample:()=>A3o,BasicSecurityScheme:()=>WUo,BearerSecurityScheme:()=>xUo,BooleanSchema:()=>V4o,BooleanWithExample:()=>m3o,BytesResponse:()=>JQn,CasingOverrides:()=>KUo,CommonProperty:()=>i3o,CommonPropertyWithExample:()=>R3o,CursorPagination:()=>w4o,CustomCodeSample:()=>P4o,CustomCodeSampleLanguage:()=>O4o,CustomCodeSampleSdk:()=>m4o,CustomPagination:()=>S4o,DateWithExample:()=>O3o,DatetimeWithExample:()=>g3o,DiscriminatedOneOfSchema:()=>t3o,DiscriminatedOneOfSchemaWithExample:()=>q3o,DoubleSchema:()=>U4o,DoubleWithExample:()=>b3o,Encoding:()=>UUo,Endpoint:()=>M4o,EndpointExample:()=>ZQn,EndpointResponseExample:()=>g4o,EndpointSdkName:()=>yGt,EndpointSecurity:()=>UQn,EndpointWithExample:()=>Uh_,EnumSchema:()=>NQn,EnumSchemaWithExample:()=>j3o,EnumValue:()=>QCi,ErrorExample:()=>_4o,FernExample:()=>y4o,FileResponse:()=>HQn,FileSchema:()=>o4o,FloatWithExample:()=>y3o,FormUrlEncodedRequest:()=>f4o,FullEndpointExample:()=>j4o,FullExample:()=>Xm,FullObjectExample:()=>t4o,FullOneOfExample:()=>i4o,GlobalHeader:()=>G4o,GlobalSecurity:()=>x4o,Header:()=>LCi,HeaderExample:()=>XQn,HeaderSecurityScheme:()=>GUo,HeaderWithExample:()=>xCi,HttpEndpointServer:()=>$Qn,HttpError:()=>h4o,HttpErrorWithExample:()=>f3o,HttpMethod:()=>LQn,IdempotencyHeader:()=>H4o,Int64WithExample:()=>p3o,IntSchema:()=>F4o,IntWithExample:()=>d3o,JsonRequest:()=>l4o,JsonRequestWithExample:()=>u3o,JsonResponse:()=>KQn,JsonResponseWithExample:()=>uUn,KeyValuePair:()=>r4o,LiteralExample:()=>kUo,LiteralSchema:()=>iUn,LiteralSchemaValue:()=>K4o,LongSchema:()=>Q4o,MapSchema:()=>Y4o,MapSchemaWithExample:()=>S3o,MultipartRequest:()=>GQn,MultipartRequestProperty:()=>c4o,MultipartRequestPropertyEncoding:()=>s4o,MultipartSchema:()=>u4o,NamedFullExample:()=>J0e,Namespace:()=>JUo,NamespaceId:()=>ZUo,NullExample:()=>e4o,NullableSchema:()=>Z4o,NullableSchemaWithExample:()=>D3o,OauthSecurityScheme:()=>YUo,ObjectProperty:()=>e3o,ObjectPropertyConflictInfo:()=>aUn,ObjectPropertyWithExample:()=>C3o,ObjectSchema:()=>J4o,ObjectSchemaWithExample:()=>B3o,OctetStreamRequest:()=>xQn,OffsetPagination:()=>E4o,OneOfSchema:()=>k4o,OneOfSchemaWithExample:()=>I3o,OpenApiIntermediateRepresentation:()=>Fh_,OpenApiSource:()=>zUo,OptionalSchema:()=>X4o,OptionalSchemaWithExample:()=>M3o,Pagination:()=>kQn,ParseFormUrlEncodedRequest:()=>s3o,ParseMultipartRequest:()=>o3o,ParseOctetStreamRequest:()=>a3o,PathParameter:()=>VQn,PathParameterExample:()=>b4o,PathParameterWithExample:()=>n3o,PrimitiveExample:()=>QQn,PrimitiveSchema:()=>WCi,PrimitiveSchemaValue:()=>W4o,PrimitiveSchemaValueWithExample:()=>P3o,PrimitiveSchemaWithExample:()=>sUn,PropertyKey:()=>FQn,ProtobufEncoding:()=>QUo,ProtobufSource:()=>NUo,QueryParameter:()=>WQn,QueryParameterExample:()=>YQn,QueryParameterWithExample:()=>oUn,QuerySecurityScheme:()=>HUo,ReferencedSchema:()=>bGt,Request:()=>d4o,RequestWithExample:()=>c3o,Response:()=>p4o,ResponseWithExample:()=>l3o,RetriesConfiguration:()=>eUn,Schema:()=>nd,SchemaId:()=>vx,SchemaWithExample:()=>_O,Schemas:()=>N4o,SdkGroup:()=>$Uo,SdkGroupInfo:()=>n4o,SdkGroupName:()=>UCi,SecurityScheme:()=>XUo,SecuritySchemeId:()=>FCi,Server:()=>eja,Source:()=>FUo,StatusCode:()=>_Gt,StreamingResponseExample:()=>v4o,StringSchema:()=>L4o,StringSchemaWithExample:()=>v3o,SupportedSdkLanguage:()=>A4o,Tag:()=>VUo,TagId:()=>gx,Tags:()=>a4o,TextResponse:()=>VCi,Uint64WithExample:()=>h3o,UintWithExample:()=>_3o,UnDiscriminatedOneOfSchema:()=>r3o,UnDiscriminatedOneOfSchemaWithExample:()=>T3o,UnknownSchemaWithExample:()=>w3o,Webhook:()=>D4o,WebhookExampleCall:()=>rUn,WebhookHttpMethod:()=>tUn,WebhookWithExample:()=>Lh_,WebsocketChannel:()=>z4o,WebsocketHandshake:()=>B4o,WebsocketHandshakeWithExample:()=>Qh_,WebsocketMessageExample:()=>T4o,WebsocketMessageOrigin:()=>I4o,WebsocketMessageSchema:()=>C4o,WebsocketServer:()=>q4o,WebsocketSessionExample:()=>R4o,WithAvailability:()=>gu,WithDescription:()=>Ti,WithEncoding:()=>iK,WithInline:()=>pO,WithName:()=>Gl,WithNamespace:()=>Ml,WithSdkGroupName:()=>Hd,WithSdkMethodName:()=>hGt,WithSource:()=>tu,WithStatusCode:()=>K0e,WithTitle:()=>Gd,commons:()=>rsc,example:()=>isc,finalIr:()=>nsc,parseIr:()=>asc});var rsc={};Kt(rsc,{BasicSecurityScheme:()=>WUo,BearerSecurityScheme:()=>xUo,Encoding:()=>UUo,HeaderSecurityScheme:()=>GUo,Namespace:()=>JUo,NamespaceId:()=>ZUo,OauthSecurityScheme:()=>YUo,OpenApiSource:()=>zUo,ProtobufEncoding:()=>QUo,ProtobufSource:()=>NUo,QuerySecurityScheme:()=>HUo,SchemaId:()=>vx,SdkGroup:()=>$Uo,SdkGroupName:()=>UCi,SecurityScheme:()=>XUo,SecuritySchemeId:()=>FCi,Server:()=>eja,Source:()=>FUo,StatusCode:()=>_Gt,Tag:()=>VUo,TagId:()=>gx,WithAvailability:()=>gu,WithDescription:()=>Ti,WithEncoding:()=>iK,WithInline:()=>pO,WithName:()=>Gl,WithNamespace:()=>Ml,WithSdkGroupName:()=>Hd,WithSdkMethodName:()=>hGt,WithSource:()=>tu,WithStatusCode:()=>K0e,WithTitle:()=>Gd});var L={};Kt(L,{JsonError:()=>TQn,ParseError:()=>RQn,any:()=>wh_,bigint:()=>dh_,boolean:()=>Eh_,booleanLiteral:()=>jh_,date:()=>ph_,discriminant:()=>Rh_,enum_:()=>qUo,getObjectLikeUtils:()=>bFt,getObjectUtils:()=>DJi,getSchemaUtils:()=>Ym,isProperty:()=>NCi,lazy:()=>_h_,lazyObject:()=>Ah_,list:()=>RUo,number:()=>Sh_,object:()=>TUo,objectWithoutOptionalProperties:()=>Oh_,optional:()=>Zuc,property:()=>yh_,record:()=>Ih_,set:()=>Ch_,string:()=>Mh_,stringLiteral:()=>Ph_,transform:()=>kuc,undiscriminatedUnion:()=>Th_,union:()=>Nh_,unknown:()=>Dh_,withParsedProperties:()=>tsc});var oh={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 MA(e,t){return`Expected ${t}. Received ${rtM(e)}.`}function rtM(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 Oz(e){return{...e,json:fh_(e.json),parse:fh_(e.parse)}}function fh_(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(`
1416
- `)),{ok:!0,value:t}):i}}function CUo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var TQn=class e extends Error{errors;constructor(t){super(t.map(CUo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var RQn=class e extends Error{errors;constructor(t){super(t.map(CUo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Ym(e){return{optional:()=>Zuc(e),transform:t=>kuc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new RQn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new TQn(i.errors)}}}function Zuc(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:()=>oh.OPTIONAL};return{...t,...Ym(t)}}function kuc(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,...Ym(r)}}function dh_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:MA(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:MA(t,"bigint")}]},getType:()=>oh.BIGINT};return{...Oz(e),...Ym(e)}}var itM=/^([+-]?\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 ph_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:MA(t,"string")}]}:itM.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:MA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:MA(t,"Date object")}]},getType:()=>oh.DATE};return{...Oz(e),...Ym(e)}}function GL(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...Oz(r),...Ym(r)}}}function qUo(e){let t=new Set(e);return GL(oh.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:MA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:MA(i,"enum")}]}:{ok:!0,value:i})()}function _h_(e){let t=esc(e);return{...t,...Ym(t)}}function esc(e){return{parse:(t,r)=>zQn(e).parse(t,r),json:(t,r)=>zQn(e).json(t,r),getType:()=>zQn(e).getType()}}function zQn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function XPa(e){return Object.entries(e)}function ZPa(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function zCi(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 kPa(e){return Object.keys(e)}function hh_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function bFt(e){return{withParsedProperties:t=>tsc(e,t)}}function tsc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[f,s])=>({...c,[f]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(i,n)=>{if(!zCi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:MA(i,"object")}]};let a=new Set(Object.keys(t)),o=ZPa(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...Ym(r),...bFt(r)}}function yh_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function NCi(e){return e.isProperty}function TUo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>NCi(i)?i.rawKey:r),_getParsedProperties:()=>kPa(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of XPa(e)){let f=NCi(c)?c.rawKey:o,s=NCi(c)?c.valueSchema:c,u={rawKey:f,parsedKey:o,valueSchema:s};n[f]=u,gh_(s)&&a.push(f)}return bh_({value:r,requiredKeys:a,getProperty:o=>{let c=n[o];if(c!=null)return{transformedKey:c.parsedKey,transform:f=>c.valueSchema.parse(f,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,o]of XPa(e)){let c=NCi(o)?o.valueSchema:o;gh_(c)&&n.push(a)}return bh_({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return NCi(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>oh.OBJECT};return{...Oz(t),...Ym(t),...bFt(t),...DJi(t)}}function bh_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!zCi(e))return{ok:!1,errors:[{path:a,message:MA(e,"object")}]};let o=new Set(t),c=[],f={};for(let[s,u]of Object.entries(e)){let l=r(s);if(l!=null){o.delete(s);let p=l.transform(u);p.ok?f[l.transformedKey]=p.value:(f[s]=u,c.push(...p.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":f[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:f}:{ok:!1,errors:c}}function DJi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>vh_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>vh_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>oh.OBJECT};return{...r,...Ym(r),...bFt(r),...DJi(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:()=>oh.OBJECT};return{...t,...Ym(t),...bFt(t),...DJi(t)}}}}function vh_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=hh_(kPa(t),s=>n.has(s)),c=r(ZPa(t,o)),f=i(ZPa(t,a));return c.ok&&f.ok?{ok:!0,value:{...c.value,...f.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...f.ok?[]:f.errors]}}function gh_(e){return!ntM(e)}function ntM(e){switch(e.getType()){case oh.ANY:case oh.UNKNOWN:case oh.OPTIONAL:return!0;default:return!1}}function Oh_(e){return TUo(e)}function Ah_(e){let t={...esc(e),_getRawProperties:()=>zQn(e)._getRawProperties(),_getParsedProperties:()=>zQn(e)._getParsedProperties()};return{...t,...Ym(t),...bFt(t),...DJi(t)}}function RUo(e){let t={parse:(r,i)=>mh_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>mh_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>oh.LIST};return{...Oz(t),...Ym(t)}}function mh_(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:MA(e,"list"),path:[]}]}}function Ph_(e){return GL(oh.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:MA(r,`"${e}"`)}]})()}function jh_(e){return GL(oh.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:MA(r,`${e.toString()}`)}]})()}var wh_=GL(oh.ANY,e=>({ok:!0,value:e}));var Eh_=GL(oh.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:MA(e,"boolean")}]});var Sh_=GL(oh.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:MA(e,"number")}]});var Mh_=GL(oh.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:MA(e,"string")}]});var Dh_=GL(oh.UNKNOWN,e=>({ok:!0,value:e}));function Ih_(e,t){let r={parse:(i,n)=>Bh_({value:i,isKeyNumeric:e.getType()===oh.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>Bh_({value:i,isKeyNumeric:e.getType()===oh.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>oh.RECORD};return{...Oz(r),...Ym(r)}}function Bh_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return zCi(e)?XPa(e).reduce((a,[o,c])=>{if(c==null)return a;let f=a,s=o;if(t){let _=o.length>0?Number(o):NaN;isNaN(_)||(s=_)}let u=r(s),l=i(c,s);if(f.ok&&u.ok&&l.ok)return{ok:!0,value:{...f.value,[u.value]:l.value}};let p=[];return f.ok||p.push(...f.errors),u.ok||p.push(...u.errors),l.ok||p.push(...l.errors),{ok:!1,errors:p}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:MA(e,"object")}]}}function Ch_(e){let t=RUo(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:MA(i,"Set")}]},getType:()=>oh.SET};return{...Oz(r),...Ym(r)}}function Th_(e){let t={parse:(r,i)=>qh_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>qh_((n,a)=>n.json(r,a),e,i),getType:()=>oh.UNDISCRIMINATED_UNION};return{...Oz(t),...Ym(t)}}function qh_(e,t,r){let i=[];for(let[n,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function Rh_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Nh_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=qUo(kPa(t)),a={parse:(o,c)=>zh_({value:o,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:f=>n.parse(f,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.parse(f,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>zh_({value:o,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:f=>n.json(f,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.json(f,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>oh.UNION};return{...Oz(a),...Ym(a),...bFt(a)}}function zh_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!zCi(e))return{ok:!1,errors:[{path:c,message:MA(e,"object")}]};let{[t]:f,...s}=e;if(f==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=i(f);if(!u.ok)return{ok:!1,errors:u.errors};let l=n(u.value);if(l==null)return a?{ok:!0,value:{[r]:u.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let p=o(s,l);return p.ok?{ok:!0,value:{[r]:f,...p.value}}:p}var Gd=L.objectWithoutOptionalProperties({title:L.string().optional()});var zUo=L.objectWithoutOptionalProperties({file:L.string()});var NUo=L.objectWithoutOptionalProperties({file:L.string()});var FUo=L.union("type",{openapi:zUo,protobuf:NUo}).transform({transform:e=>{switch(e.type){case"openapi":return xL.openapi(e);case"protobuf":return xL.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var tu=L.objectWithoutOptionalProperties({source:FUo.optional()});var QUo=L.objectWithoutOptionalProperties({typeName:L.string()});var UUo=L.union("type",{protobuf:QUo}).transform({transform:e=>{switch(e.type){case"protobuf":return qQn.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var iK=L.objectWithoutOptionalProperties({encoding:UUo.optional()});var Ti=L.objectWithoutOptionalProperties({description:L.string().optional()});var LUo=L.enum_(["GenerallyAvailable","Beta","Deprecated"]);var gu=L.objectWithoutOptionalProperties({availability:LUo.optional()});var _Gt=L.number();var K0e=L.objectWithoutOptionalProperties({statusCode:_Gt.optional()});var Gl=L.objectWithoutOptionalProperties({nameOverride:L.string().optional(),generatedName:L.string()});var pO=L.objectWithoutOptionalProperties({inline:L.boolean().optional()});var vx=L.string();var gx=L.string();var VUo=L.objectWithoutOptionalProperties({id:gx}).extend(Ti);var FCi=L.string();var WUo=L.objectWithoutOptionalProperties({usernameVariableName:L.string().optional(),usernameEnvVar:L.string().optional(),passwordVariableName:L.string().optional(),passwordEnvVar:L.string().optional()});var xUo=L.objectWithoutOptionalProperties({tokenVariableName:L.string().optional(),tokenEnvVar:L.string().optional()});var GUo=L.objectWithoutOptionalProperties({headerName:L.string(),prefix:L.string().optional(),headerVariableName:L.string().optional(),headerEnvVar:L.string().optional()});var HUo=L.objectWithoutOptionalProperties({queryParameterName:L.string()});var KUo=L.objectWithoutOptionalProperties({snake:L.string().optional(),camel:L.string().optional(),screamingSnake:L.string().optional(),pascal:L.string().optional()});var QCi=L.objectWithoutOptionalProperties({nameOverride:L.string().optional(),generatedName:L.string(),value:L.string(),casing:KUo.optional()}).extend(Ti).extend(gu);var JUo=L.objectWithoutOptionalProperties({type:L.stringLiteral("namespace"),name:L.string()});var $Uo=L.undiscriminatedUnion([L.string(),JUo]);var UCi=L.list($Uo);var Hd=L.objectWithoutOptionalProperties({groupName:UCi.optional()});var Ml=L.objectWithoutOptionalProperties({namespace:L.string().optional()});var NQn=L.objectWithoutOptionalProperties({default:QCi.optional(),values:L.list(QCi)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var YUo=L.objectWithoutOptionalProperties({scopesEnum:NQn.optional()});var XUo=L.union("type",{basic:WUo,bearer:xUo,header:GUo,query:HUo,oauth:YUo}).transform({transform:e=>{switch(e.type){case"basic":return yz.basic(e);case"bearer":return yz.bearer(e);case"header":return yz.header(e);case"query":return yz.query(e);case"oauth":return yz.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var eja=L.objectWithoutOptionalProperties({name:L.string().optional(),url:L.string(),audiences:L.list(L.string()).optional()}).extend(Ti);var ZUo=L.string();var hGt=L.objectWithoutOptionalProperties({sdkMethodName:L.string().optional()});var isc={};Kt(isc,{FullExample:()=>Xm,FullObjectExample:()=>t4o,FullOneOfExample:()=>i4o,KeyValuePair:()=>r4o,LiteralExample:()=>kUo,NullExample:()=>e4o,PrimitiveExample:()=>QQn,PropertyKey:()=>FQn});var FQn=L.string();var QQn=L.union("type",{int:L.object({value:L.number()}),int64:L.object({value:L.number()}),uint:L.object({value:L.number()}),uint64:L.object({value:L.number()}),float:L.object({value:L.number()}),double:L.object({value:L.number()}),string:L.object({value:L.string()}),datetime:L.object({value:L.string()}),date:L.object({value:L.string()}),base64:L.object({value:L.string()}),boolean:L.object({value:L.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return Ha.int(e.value);case"int64":return Ha.int64(e.value);case"uint":return Ha.uint(e.value);case"uint64":return Ha.uint64(e.value);case"float":return Ha.float(e.value);case"double":return Ha.double(e.value);case"string":return Ha.string(e.value);case"datetime":return Ha.datetime(e.value);case"date":return Ha.date(e.value);case"base64":return Ha.base64(e.value);case"boolean":return Ha.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var kUo=L.union("type",{boolean:L.object({value:L.boolean()}),string:L.object({value:L.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return TCi.boolean(e.value);case"string":return TCi.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var e4o=L.objectWithoutOptionalProperties({});var Xm=L.union("type",{primitive:L.object({value:QQn}),object:L.lazyObject(()=>t4o),array:L.object({value:L.list(L.lazy(()=>Xm))}),map:L.object({value:L.list(L.lazyObject(()=>r4o))}),enum:L.object({value:L.string()}),literal:L.object({value:kUo}),oneOf:L.object({value:L.lazy(()=>i4o)}),null:e4o,unknown:L.object({value:L.lazy(()=>Xm)})}).transform({transform:e=>{switch(e.type){case"primitive":return Sl.primitive(e.value);case"object":return Sl.object(e);case"array":return Sl.array(e.value);case"map":return Sl.map(e.value);case"enum":return Sl.enum(e.value);case"literal":return Sl.literal(e.value);case"oneOf":return Sl.oneOf(e.value);case"null":return Sl.null(e);case"unknown":return Sl.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var t4o=L.objectWithoutOptionalProperties({properties:L.record(FQn,L.lazy(()=>Xm))});var r4o=L.objectWithoutOptionalProperties({key:QQn,value:L.lazy(()=>Xm)});var i4o=L.union("type",{discriminated:L.object({value:L.record(FQn,L.lazy(()=>Xm))}),undiscriminated:L.object({value:L.lazy(()=>Xm)})}).transform({transform:e=>{switch(e.type){case"discriminated":return RCi.discriminated(e.value);case"undiscriminated":return RCi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var nsc={};Kt(nsc,{AllOfPropertyConflict:()=>nUn,ArraySchema:()=>$4o,Availability:()=>LUo,BooleanSchema:()=>V4o,BytesResponse:()=>JQn,CasingOverrides:()=>KUo,CommonProperty:()=>i3o,CursorPagination:()=>w4o,CustomCodeSample:()=>P4o,CustomCodeSampleLanguage:()=>O4o,CustomCodeSampleSdk:()=>m4o,CustomPagination:()=>S4o,DiscriminatedOneOfSchema:()=>t3o,DoubleSchema:()=>U4o,Endpoint:()=>M4o,EndpointExample:()=>ZQn,EndpointResponseExample:()=>g4o,EndpointSdkName:()=>yGt,EndpointSecurity:()=>UQn,EnumSchema:()=>NQn,EnumValue:()=>QCi,ErrorExample:()=>_4o,FernExample:()=>y4o,FileResponse:()=>HQn,FileSchema:()=>o4o,FormUrlEncodedRequest:()=>f4o,FullEndpointExample:()=>j4o,GlobalHeader:()=>G4o,GlobalSecurity:()=>x4o,Header:()=>LCi,HeaderExample:()=>XQn,HttpEndpointServer:()=>$Qn,HttpError:()=>h4o,HttpMethod:()=>LQn,IdempotencyHeader:()=>H4o,IntSchema:()=>F4o,JsonRequest:()=>l4o,JsonResponse:()=>KQn,LiteralSchema:()=>iUn,LiteralSchemaValue:()=>K4o,LongSchema:()=>Q4o,MapSchema:()=>Y4o,MultipartRequest:()=>GQn,MultipartRequestProperty:()=>c4o,MultipartRequestPropertyEncoding:()=>s4o,MultipartSchema:()=>u4o,NullableSchema:()=>Z4o,ObjectProperty:()=>e3o,ObjectPropertyConflictInfo:()=>aUn,ObjectSchema:()=>J4o,OctetStreamRequest:()=>xQn,OffsetPagination:()=>E4o,OneOfSchema:()=>k4o,OpenApiIntermediateRepresentation:()=>Fh_,OptionalSchema:()=>X4o,Pagination:()=>kQn,PathParameter:()=>VQn,PathParameterExample:()=>b4o,PrimitiveSchema:()=>WCi,PrimitiveSchemaValue:()=>W4o,QueryParameter:()=>WQn,QueryParameterExample:()=>YQn,ReferencedSchema:()=>bGt,Request:()=>d4o,Response:()=>p4o,RetriesConfiguration:()=>eUn,Schema:()=>nd,Schemas:()=>N4o,SdkGroupInfo:()=>n4o,StreamingResponseExample:()=>v4o,StringSchema:()=>L4o,SupportedSdkLanguage:()=>A4o,Tags:()=>a4o,TextResponse:()=>VCi,UnDiscriminatedOneOfSchema:()=>r3o,Webhook:()=>D4o,WebhookExampleCall:()=>rUn,WebhookHttpMethod:()=>tUn,WebsocketChannel:()=>z4o,WebsocketHandshake:()=>B4o,WebsocketMessageExample:()=>T4o,WebsocketMessageOrigin:()=>I4o,WebsocketMessageSchema:()=>C4o,WebsocketServer:()=>q4o,WebsocketSessionExample:()=>R4o});var n4o=L.objectWithoutOptionalProperties({summary:L.string().optional(),description:L.string().optional()});var a4o=L.objectWithoutOptionalProperties({tagsById:L.record(gx,VUo),orderedTagIds:L.list(gx).optional()});var UQn=L.list(L.record(FCi,L.list(L.string())));var LQn=L.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var VQn=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>nd),variableReference:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var WQn=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>nd),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var LCi=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>nd),env:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var yGt=L.objectWithoutOptionalProperties({groupName:UCi,methodName:L.string()});var xQn=L.objectWithoutOptionalProperties({contentType:L.string().optional()}).extend(Ti).extend(tu);var o4o=L.objectWithoutOptionalProperties({isOptional:L.boolean(),isArray:L.boolean()}).extend(Ti);var u4o=L.union("type",{file:o4o,json:L.object({value:L.lazy(()=>nd)})}).transform({transform:e=>{switch(e.type){case"file":return dGt.file(e);case"json":return dGt.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var s4o=L.enum_(["json","form"]);var c4o=L.objectWithoutOptionalProperties({key:L.string(),schema:u4o,contentType:L.string().optional(),exploded:L.boolean().optional(),encoding:s4o.optional()}).extend(Ti);var GQn=L.objectWithoutOptionalProperties({name:L.string().optional(),properties:L.list(c4o)}).extend(Ti).extend(tu);var l4o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd),contentType:L.string().optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu);var f4o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd),contentType:L.string().optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu);var d4o=L.union("type",{octetStream:xQn,multipart:GQn,json:l4o,formUrlEncoded:f4o}).transform({transform:e=>{switch(e.type){case"octetStream":return yFt.octetStream(e);case"multipart":return yFt.multipart(e);case"json":return yFt.json(e);case"formUrlEncoded":return yFt.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var HQn=L.objectWithoutOptionalProperties({}).extend(Ti).extend(tu).extend(K0e);var KQn=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd),responseProperty:L.string().optional()}).extend(Ti).extend(tu).extend(K0e);var VCi=L.objectWithoutOptionalProperties({}).extend(Ti).extend(tu).extend(K0e);var JQn=L.objectWithoutOptionalProperties({}).extend(Ti).extend(tu).extend(K0e);var p4o=L.union("type",{file:HQn,json:KQn,text:VCi,bytes:JQn,streamingSse:KQn,streamingText:VCi,streamingJson:KQn}).transform({transform:e=>{switch(e.type){case"file":return KQ.file(e);case"json":return KQ.json(e);case"text":return KQ.text(e);case"bytes":return KQ.bytes(e);case"streamingSse":return KQ.streamingSse(e);case"streamingText":return KQ.streamingText(e);case"streamingJson":return KQ.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var _4o=L.objectWithoutOptionalProperties({name:L.string().optional(),description:L.string().optional(),example:L.lazy(()=>Xm)});var h4o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd).optional(),examples:L.list(_4o).optional()}).extend(Ti).extend(Gl).extend(tu);var $Qn=L.objectWithoutOptionalProperties({name:L.string().optional(),url:L.string().optional(),audiences:L.list(L.string()).optional()});var y4o=L.unknown();var b4o=L.objectWithoutOptionalProperties({name:L.string(),parameterNameOverride:L.string().optional(),value:L.lazy(()=>Xm)});var YQn=L.objectWithoutOptionalProperties({name:L.string(),value:L.lazy(()=>Xm)});var XQn=L.objectWithoutOptionalProperties({name:L.string(),value:L.lazy(()=>Xm)});var v4o=L.objectWithoutOptionalProperties({sse:L.boolean(),events:L.list(L.lazy(()=>Xm))});var g4o=L.union("type",{withStreaming:v4o,withoutStreaming:L.object({value:L.lazy(()=>Xm)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return H0e.withStreaming(e);case"withoutStreaming":return H0e.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var O4o=L.objectWithoutOptionalProperties({name:L.string().optional(),language:L.string(),code:L.string(),install:L.string().optional()}).extend(Ti);var A4o=L.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var m4o=L.objectWithoutOptionalProperties({name:L.string().optional(),sdk:A4o,code:L.string()}).extend(Ti);var P4o=L.union("type",{language:O4o,sdk:m4o}).transform({transform:e=>{switch(e.type){case"language":return fGt.language(e);case"sdk":return fGt.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var j4o=L.objectWithoutOptionalProperties({name:L.string().optional(),pathParameters:L.list(b4o).optional(),queryParameters:L.list(YQn).optional(),headers:L.list(XQn).optional(),request:L.lazy(()=>Xm).optional(),response:g4o.optional(),codeSamples:L.list(P4o)}).extend(Ti);var ZQn=L.union("type",{unknown:L.object({value:y4o}),full:j4o}).transform({transform:e=>{switch(e.type){case"unknown":return G0e.unknown(e.value);case"full":return G0e.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var w4o=L.objectWithoutOptionalProperties({cursor:L.string(),nextCursor:L.property("next_cursor",L.string()),results:L.string()});var E4o=L.objectWithoutOptionalProperties({offset:L.string(),results:L.string(),step:L.string().optional(),hasNextPage:L.string().optional()});var S4o=L.objectWithoutOptionalProperties({results:L.string()});var kQn=L.union("type",{cursor:w4o,offset:E4o,custom:S4o}).transform({transform:e=>{switch(e.type){case"cursor":return Dhe.cursor(e);case"offset":return Dhe.offset(e);case"custom":return Dhe.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var eUn=L.union("type",{disabled:L.object({value:L.boolean().optional()})}).transform({transform:e=>{switch(e.type){case"disabled":return YPa.disabled(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var M4o=L.objectWithoutOptionalProperties({authed:L.boolean(),security:UQn.optional(),internal:L.boolean().optional(),idempotent:L.boolean().optional(),method:LQn,audiences:L.list(L.string()),path:L.string(),summary:L.string().optional(),operationId:L.string().optional(),tags:L.list(gx),pathParameters:L.list(VQn),queryParameters:L.list(WQn),headers:L.list(LCi),sdkName:yGt.optional(),generatedRequestName:L.string(),requestNameOverride:L.string().optional(),request:d4o.optional(),response:p4o.optional(),errors:L.record(_Gt,h4o),servers:L.list($Qn),examples:L.list(ZQn),pagination:kQn.optional(),retries:eUn.optional()}).extend(Ti).extend(gu).extend(tu).extend(Ml);var tUn=L.enum_(["GET","POST"]);var rUn=L.objectWithoutOptionalProperties({name:L.string().optional(),payload:L.lazy(()=>Xm)}).extend(Ti);var D4o=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),sdkName:yGt.optional(),method:tUn,summary:L.string().optional(),operationId:L.string(),tags:L.list(gx),headers:L.list(LCi),generatedPayloadName:L.string(),payload:L.lazy(()=>nd),examples:L.list(rUn)}).extend(Ti).extend(tu).extend(Ml);var B4o=L.objectWithoutOptionalProperties({queryParameters:L.list(WQn),headers:L.list(LCi),pathParameters:L.list(VQn)});var I4o=L.enum_(["client","server"]);var C4o=L.objectWithoutOptionalProperties({name:L.string(),origin:I4o,body:L.lazy(()=>nd)});var q4o=L.objectWithoutOptionalProperties({name:L.string(),url:L.string()});var T4o=L.objectWithoutOptionalProperties({messageType:L.string(),payload:L.lazy(()=>Xm)}).extend(Ti);var R4o=L.objectWithoutOptionalProperties({name:L.string().optional(),queryParameters:L.list(YQn).optional(),headers:L.list(XQn).optional(),messages:L.list(T4o)}).extend(Ti);var z4o=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),path:L.string(),groupName:UCi,summary:L.string().optional(),handshake:B4o,messages:L.list(C4o),servers:L.list(q4o),examples:L.list(R4o)}).extend(Ti).extend(tu);var N4o=L.objectWithoutOptionalProperties({rootSchemas:L.record(vx,L.lazy(()=>nd)),namespacedSchemas:L.record(ZUo,L.record(vx,L.lazy(()=>nd)))});var F4o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional()});var Q4o=L.objectWithoutOptionalProperties({default:L.number().optional()});var U4o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional()});var L4o=L.objectWithoutOptionalProperties({default:L.string().optional(),pattern:L.string().optional(),format:L.string().optional(),minLength:L.number().optional(),maxLength:L.number().optional()});var V4o=L.objectWithoutOptionalProperties({default:L.boolean().optional()});var W4o=L.union("type",{int:F4o,int64:Q4o,uint:L.object({}),uint64:L.object({}),float:L.object({}),double:U4o,string:L4o,datetime:L.object({}),date:L.object({}),base64:L.object({}),boolean:V4o}).transform({transform:e=>{switch(e.type){case"int":return ah.int(e);case"int64":return ah.int64(e);case"uint":return ah.uint();case"uint64":return ah.uint64();case"float":return ah.float();case"double":return ah.double(e);case"string":return ah.string(e);case"datetime":return ah.datetime();case"date":return ah.date();case"base64":return ah.base64();case"boolean":return ah.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var WCi=L.objectWithoutOptionalProperties({schema:W4o}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var x4o=L.list(L.record(FCi,L.list(L.string())));var G4o=L.objectWithoutOptionalProperties({header:L.string(),name:L.string().optional(),optional:L.boolean().optional(),env:L.string().optional(),schema:L.lazy(()=>nd).optional()});var H4o=L.objectWithoutOptionalProperties({header:L.string(),name:L.string().optional(),env:L.string().optional(),schema:L.lazy(()=>nd).optional()});var Fh_=L.objectWithoutOptionalProperties({apiVersion:L.unknown().optional(),title:L.string().optional(),description:L.string().optional(),basePath:L.string().optional(),servers:L.list(eja),websocketServers:L.list(eja),groups:L.record(L.string(),n4o),tags:a4o,hasEndpointsMarkedInternal:L.boolean(),endpoints:L.list(M4o),webhooks:L.list(D4o),channels:L.record(L.string(),z4o),groupedSchemas:N4o,variables:L.record(L.string(),WCi),nonRequestReferencedSchemas:L.set(vx),securitySchemes:L.record(FCi,XUo),security:x4o.optional(),globalHeaders:L.list(G4o).optional(),idempotencyHeaders:L.list(H4o).optional()});var bGt=L.objectWithoutOptionalProperties({schema:vx}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd);var K4o=L.union("type",{boolean:L.object({value:L.boolean()}),string:L.object({value:L.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Fj.boolean(e.value);case"string":return Fj.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var iUn=L.objectWithoutOptionalProperties({value:K4o}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var nd=L.union("type",{primitive:WCi,object:L.lazyObject(()=>J4o),array:L.lazyObject(()=>$4o),map:L.lazyObject(()=>Y4o),optional:L.lazyObject(()=>X4o),enum:NQn,reference:bGt,literal:iUn,oneOf:L.object({value:L.lazy(()=>k4o)}),nullable:L.lazyObject(()=>Z4o),unknown:Gl}).transform({transform:e=>{switch(e.type){case"primitive":return Zs.primitive(e);case"object":return Zs.object(e);case"array":return Zs.array(e);case"map":return Zs.map(e);case"optional":return Zs.optional(e);case"enum":return Zs.enum(e);case"reference":return Zs.reference(e);case"literal":return Zs.literal(e);case"oneOf":return Zs.oneOf(e.value);case"nullable":return Zs.nullable(e);case"unknown":return Zs.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var nUn=L.objectWithoutOptionalProperties({propertyKey:L.string(),allOfSchemaIds:L.list(vx),conflictingTypeSignatures:L.boolean()});var J4o=L.objectWithoutOptionalProperties({allOf:L.list(bGt),properties:L.list(L.lazyObject(()=>e3o)),allOfPropertyConflicts:L.list(nUn),additionalProperties:L.boolean()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var aUn=L.objectWithoutOptionalProperties({differentSchema:L.boolean()});var e3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>nd),readonly:L.boolean().optional(),writeonly:L.boolean().optional(),conflict:L.record(vx,aUn),generatedName:L.string(),nameOverride:L.string().optional(),audiences:L.list(L.string())}).extend(gu);var $4o=L.objectWithoutOptionalProperties({value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var Y4o=L.objectWithoutOptionalProperties({key:WCi,value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(Gd).extend(pO);var X4o=L.objectWithoutOptionalProperties({value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var Z4o=L.objectWithoutOptionalProperties({value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var k4o=L.union("type",{discriminated:L.lazyObject(()=>t3o),undiscriminated:L.lazyObject(()=>r3o)}).transform({transform:e=>{switch(e.type){case"discriminated":return pGt.discriminated(e);case"undiscriminated":return pGt.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var t3o=L.objectWithoutOptionalProperties({discriminantProperty:L.string(),commonProperties:L.list(L.lazyObject(()=>i3o)),schemas:L.record(L.string(),L.lazy(()=>nd))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var i3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>nd)});var r3o=L.objectWithoutOptionalProperties({schemas:L.list(L.lazy(()=>nd))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var asc={};Kt(asc,{ArraySchemaWithExample:()=>E3o,Base64WithExample:()=>A3o,BooleanWithExample:()=>m3o,CommonPropertyWithExample:()=>R3o,DateWithExample:()=>O3o,DatetimeWithExample:()=>g3o,DiscriminatedOneOfSchemaWithExample:()=>q3o,DoubleWithExample:()=>b3o,EndpointWithExample:()=>Uh_,EnumSchemaWithExample:()=>j3o,FloatWithExample:()=>y3o,HeaderWithExample:()=>xCi,HttpErrorWithExample:()=>f3o,Int64WithExample:()=>p3o,IntWithExample:()=>d3o,JsonRequestWithExample:()=>u3o,JsonResponseWithExample:()=>uUn,MapSchemaWithExample:()=>S3o,NamedFullExample:()=>J0e,NullableSchemaWithExample:()=>D3o,ObjectPropertyWithExample:()=>C3o,ObjectSchemaWithExample:()=>B3o,OneOfSchemaWithExample:()=>I3o,OptionalSchemaWithExample:()=>M3o,ParseFormUrlEncodedRequest:()=>s3o,ParseMultipartRequest:()=>o3o,ParseOctetStreamRequest:()=>a3o,PathParameterWithExample:()=>n3o,PrimitiveSchemaValueWithExample:()=>P3o,PrimitiveSchemaWithExample:()=>sUn,QueryParameterWithExample:()=>oUn,RequestWithExample:()=>c3o,ResponseWithExample:()=>l3o,SchemaWithExample:()=>_O,StringSchemaWithExample:()=>v3o,Uint64WithExample:()=>h3o,UintWithExample:()=>_3o,UnDiscriminatedOneOfSchemaWithExample:()=>T3o,UnknownSchemaWithExample:()=>w3o,WebhookWithExample:()=>Lh_,WebsocketHandshakeWithExample:()=>Qh_});var J0e=L.objectWithoutOptionalProperties({name:L.string().optional(),value:L.unknown()}).extend(Ti);var oUn=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>_O),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var xCi=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>_O),env:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var Qh_=L.objectWithoutOptionalProperties({queryParameters:L.list(oUn),headers:L.list(xCi)});var n3o=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>_O),variableReference:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var a3o=L.objectWithoutOptionalProperties({}).extend(xQn).extend(hGt);var o3o=L.objectWithoutOptionalProperties({}).extend(GQn).extend(hGt);var u3o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>_O),contentType:L.string().optional(),fullExamples:L.list(J0e).optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu).extend(hGt);var s3o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>_O),contentType:L.string().optional(),fullExamples:L.list(J0e).optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu).extend(hGt);var c3o=L.union("type",{octetStream:a3o,multipart:o3o,json:u3o,formUrlEncoded:s3o}).transform({transform:e=>{switch(e.type){case"octetStream":return bx.octetStream(e);case"multipart":return bx.multipart(e);case"json":return bx.json(e);case"formUrlEncoded":return bx.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var uUn=L.objectWithoutOptionalProperties({schema:L.lazy(()=>_O),responseProperty:L.string().optional(),fullExamples:L.list(J0e).optional()}).extend(Ti).extend(tu).extend(K0e);var l3o=L.union("type",{file:HQn,json:uUn,text:VCi,bytes:JQn,streamingSse:uUn,streamingText:VCi,streamingJson:uUn}).transform({transform:e=>{switch(e.type){case"file":return mP.file(e);case"json":return mP.json(e);case"text":return mP.text(e);case"bytes":return mP.bytes(e);case"streamingSse":return mP.streamingSse(e);case"streamingText":return mP.streamingText(e);case"streamingJson":return mP.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var f3o=L.objectWithoutOptionalProperties({statusCode:_Gt,schema:L.lazy(()=>_O),fullExamples:L.list(J0e).optional()}).extend(Ti).extend(Gl).extend(tu);var Uh_=L.objectWithoutOptionalProperties({authed:L.boolean(),security:UQn.optional(),internal:L.boolean().optional(),idempotent:L.boolean().optional(),method:LQn,audiences:L.list(L.string()),path:L.string(),summary:L.string().optional(),operationId:L.string().optional(),tags:L.list(gx),pathParameters:L.list(n3o),queryParameters:L.list(oUn),headers:L.list(xCi),sdkName:yGt.optional(),generatedRequestName:L.string(),requestNameOverride:L.string().optional(),request:c3o.optional(),response:l3o.optional(),errors:L.record(_Gt,f3o),servers:L.list($Qn),examples:L.list(ZQn),pagination:kQn.optional(),retries:eUn.optional()}).extend(Ti).extend(gu).extend(tu).extend(Ml);var Lh_=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),sdkName:yGt.optional(),method:tUn,summary:L.string().optional(),operationId:L.string(),tags:L.list(gx),headers:L.list(xCi),generatedPayloadName:L.string(),payload:L.lazy(()=>_O),examples:L.list(rUn)}).extend(Ti).extend(tu).extend(Ml);var d3o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional(),example:L.number().optional()});var p3o=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var _3o=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var h3o=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var y3o=L.objectWithoutOptionalProperties({example:L.number().optional()});var b3o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional(),example:L.number().optional()});var v3o=L.objectWithoutOptionalProperties({default:L.string().optional(),pattern:L.string().optional(),format:L.string().optional(),minLength:L.number().optional(),maxLength:L.number().optional(),example:L.string().optional()});var g3o=L.objectWithoutOptionalProperties({example:L.string().optional()});var O3o=L.objectWithoutOptionalProperties({example:L.string().optional()});var A3o=L.objectWithoutOptionalProperties({example:L.string().optional()});var m3o=L.objectWithoutOptionalProperties({default:L.boolean().optional(),example:L.boolean().optional()});var P3o=L.union("type",{int:d3o,int64:p3o,uint:_3o,uint64:h3o,float:y3o,double:b3o,string:v3o,datetime:g3o,date:O3o,base64:A3o,boolean:m3o}).transform({transform:e=>{switch(e.type){case"int":return Ln.int(e);case"int64":return Ln.int64(e);case"uint":return Ln.uint(e);case"uint64":return Ln.uint64(e);case"float":return Ln.float(e);case"double":return Ln.double(e);case"string":return Ln.string(e);case"datetime":return Ln.datetime(e);case"date":return Ln.date(e);case"base64":return Ln.base64(e);case"boolean":return Ln.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var sUn=L.objectWithoutOptionalProperties({schema:P3o}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var j3o=L.objectWithoutOptionalProperties({default:QCi.optional(),values:L.list(QCi),example:L.string().optional()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var w3o=L.objectWithoutOptionalProperties({example:L.unknown()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var _O=L.union("type",{primitive:sUn,object:L.lazyObject(()=>B3o),array:L.lazyObject(()=>E3o),map:L.lazyObject(()=>S3o),optional:L.lazyObject(()=>M3o),enum:j3o,reference:bGt,literal:iUn,oneOf:L.object({value:L.lazy(()=>I3o)}),nullable:L.lazyObject(()=>D3o),unknown:w3o}).transform({transform:e=>{switch(e.type){case"primitive":return ri.primitive(e);case"object":return ri.object(e);case"array":return ri.array(e);case"map":return ri.map(e);case"optional":return ri.optional(e);case"enum":return ri.enum(e);case"reference":return ri.reference(e);case"literal":return ri.literal(e);case"oneOf":return ri.oneOf(e.value);case"nullable":return ri.nullable(e);case"unknown":return ri.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var E3o=L.objectWithoutOptionalProperties({value:L.lazy(()=>_O),example:L.list(L.unknown()).optional()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var S3o=L.objectWithoutOptionalProperties({key:sUn,value:L.lazy(()=>_O),example:L.unknown().optional()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(Gd).extend(pO);var M3o=L.objectWithoutOptionalProperties({value:L.lazy(()=>_O)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var D3o=L.objectWithoutOptionalProperties({value:L.lazy(()=>_O)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var B3o=L.objectWithoutOptionalProperties({allOf:L.list(bGt),properties:L.list(L.lazyObject(()=>C3o)),allOfPropertyConflicts:L.list(nUn),fullExamples:L.list(J0e).optional(),additionalProperties:L.boolean()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var C3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>_O),readonly:L.boolean().optional(),writeonly:L.boolean().optional(),audiences:L.list(L.string()),conflict:L.record(vx,aUn),nameOverride:L.string().optional(),generatedName:L.string()}).extend(gu);var I3o=L.union("type",{discriminated:L.lazyObject(()=>q3o),undiscriminated:L.lazyObject(()=>T3o)}).transform({transform:e=>{switch(e.type){case"discriminated":return Bhe.discriminated(e);case"undiscriminated":return Bhe.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var q3o=L.objectWithoutOptionalProperties({discriminantProperty:L.string(),commonProperties:L.list(L.lazyObject(()=>R3o)),schemas:L.record(L.string(),L.lazy(()=>_O))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var R3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>_O)});var T3o=L.objectWithoutOptionalProperties({schemas:L.list(L.lazy(()=>_O))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var Vh_=/^(\d+)/,cUn=/^[a-zA-Z][a-zA-Z0-9_]*$/,Wh_={"<":"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 BJi(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 o=Math.floor(e/10),c=e%10;return c===0?i[o]:`${i[o]}_${t[c]}`}if(e<1e3){let o=Math.floor(e/100),c=e%100;return c===0?`${t[o]}_hundred`:`${t[o]}_hundred_${BJi(c)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${BJi(a)}`}function tja(e){let t=e.match(Vh_);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=BJi(n);return i.length>0?`${a}_${i}`:a}}}function lUn(e){let t=tja(e),r=Wh_[e];return t!=null?QP(No(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":QP(No(e)))}function nK(e,t){return e.type==="primitive"&&t.type==="primitive"?xh_(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?atM(e.values,t.values):e.type==="array"&&t.type==="array"?nK(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"?nK(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?otM(e.value,t.value):e.type==="object"&&t.type==="object"?utM(e,t):e.type==="map"&&t.type==="map"?xh_(e.key.schema,t.key.schema)&&nK(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function xh_(e,t){return e.type===t.type}function atM(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return t1(r,i)}function otM(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:nK(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:nK(r,n)}):!1}function utM(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:nK(a,n.schema)})}function ZE(e){switch(e){case bz.Deprecated:return"deprecated";case bz.Beta:return"pre-release";case bz.GenerallyAvailable:return"generally-available";default:return}}function stM(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 Gh_(e){let t=e?stM(e):void 0;if(t==null||t.length===0)return Kxi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(No(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(No(n.name)):r.push(n.name,Kxi);break}default:vt(n.type)}else vt(n);return r.join("/")}function GCi(e){return Tu.of(`${Gh_(e)}.yml`)}function osc({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Kxi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,Gh_(r))}function Hh_({sdkName:e,namespaceOverride:t}){return Tu.of(`${osc({sdkName:e,namespaceOverride:t})}.yml`)}function Kh_({location:e,namespaceOverride:t}){return t!=null?rD(Tu.of(t),e):e}function z3o(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:vt(e.type)}}function fUn(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:vt(e)}}function hO(e){return typeof e=="string"?e:e.type}function dUn(e){if(typeof e!="string")return e.docs}function rja(e){if(typeof e!="string")return e.default}function usc(e){if(typeof e!="string")return e.validation}function $h_(e){let t=hO(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?Jh_(e):{...e,type:Jh_(e.type)}}function Jh_(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function IJi(e){return hO(e).startsWith("optional<")?e:typeof e=="string"?Yh_(e):{...e,type:Yh_(e.type)}}function Yh_(e){return e.startsWith("optional<")?e:`optional<${e}>`}var ctM=-2147483648,ltM=2147483647,ftM=-17976931348623157e292,dtM=17976931348623157e292;function Af({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 N3o(e);case"array":return lsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return fsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return csc({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return psc();case"optional":return F3o({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return dsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return AtM({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,_sc(e);case"object":return mtM({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return PtM({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:vt(e)}}function N3o(e){switch(e.schema.type){case"string":return htM({description:e.description,schema:e.schema});case"int":return ytM({description:e.description,schema:e.schema});case"float":return btM({description:e.description,schema:e.schema});case"double":return vtM({description:e.description,schema:e.schema});case"boolean":return ptM({description:e.description,schema:e.schema});case"int64":return _tM({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:ZE(e.availability)}:{}}}function ptM({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 _tM({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 htM({description:e,schema:t}){let r="string",i=gtM(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 ytM({description:e,schema:t}){let r="integer",i=Xh_(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 btM({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function vtM({description:e,schema:t}){let r="double",i=Xh_(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 gtM(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=OtM(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function OtM(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 Xh_(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:o}=e;if(r=ssc(r,t),i=ssc(i,t),n=ssc(n,t),!(r==null&&i==null&&a==null&&o==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:o,multipleOf:n}}function ssc(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[ctM,ltM]:[ftM,dtM];return e<r||e>i?void 0:e}function csc({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=jtM(n)??e.schema,o=fUn(n),c=wtM(n),s=Q3o({context:r,fileContainingReference:t,declarationFile:GCi(o),type:a});return n.type==="nullable"&&(s=r.options.wrapReferencesToNullableInOptional?`optional<${s}>`:`nullable<${s}>`),n.type==="optional"&&!s.startsWith("optional<")&&(s=`optional<${s}>`),e.description==null&&c==null?s:{type:s,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{}}}function lsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=`list<${hO(o)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{},type:c}}function fsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=N3o(e.key),c=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),f=e.encoding!=null?z3o(e.encoding):void 0,s=`map<${hO(o)}, ${hO(c)}>`;if(e.description==null&&f==null&&e.title==null)return s;let u={type:s};return e.description!=null&&(u.docs=e.description),e.encoding!=null&&(u.encoding=f),e.availability!=null&&(u.availability=ZE(e.availability)),u}function dsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.options.respectNullableSchemas)return F3o({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let o=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hO(o),f=dUn(o),s=rja(o),u=usc(o),l=$h_(c);if(i.options.wrapReferencesToNullableInOptional&&(l=IJi(l)),e.availability==null&&e.description==null&&f==null&&s==null&&u==null&&e.title==null)return l;let p=typeof l=="string"?{type:l}:l;return(e.description!=null||f!=null)&&(p.docs=e.description??f),s!=null&&(p.default=s),u!=null&&(p.validation=u),e.availability!=null&&(p.availability=ZE(e.availability)),p}function F3o({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hO(o),f=dUn(o),s=rja(o),u=usc(o),l=IJi(c);if(e.availability==null&&e.description==null&&f==null&&s==null&&u==null&&e.title==null)return l;let p=typeof l=="string"?{type:l}:l;return(e.description!=null||f!=null)&&(p.docs=e.description??f),s!=null&&(p.default=s),u!=null&&(p.validation=u),e.availability!=null&&(p.availability=ZE(e.availability)),p}function psc(){return"unknown"}function _sc(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:vt(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{}}}function AtM({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=ija(e,n),o=e.nameOverride??e.generatedName;i.builder.addType(r,{name:o,schema:a.schema});let c=Q3o({type:o,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return c;let f={type:c};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.availability!=null&&(f.availability=ZE(e.availability)),f}function mtM({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=hsc({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:o.schema});let f=Q3o({type:c,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:ZE(e.availability)}:{}}}function PtM({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=ysc({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:o.schema});let f=Q3o({type:c,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:ZE(e.availability)}:{}}}function Q3o({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 jtM(e){return Zs._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 wtM(e){return Zs._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:()=>{}})}var C1;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(C1||(C1={}));function Hvi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:vt(e)}}function kh_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=MtM(e);break;case"array":a=EtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=StM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=DtM({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=ItM(e.nameOverride,e.generatedName);break;case"optional":a=ty_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=BtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=ija(e,n);break;case"literal":a=CtM(e,e.nameOverride,e.generatedName);break;case"object":a=hsc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=ysc({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:vt(e)}return a}function hsc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(C1.Request)&&t.options.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),o=!1,c={},f=new Set;for(let _ of e.properties){if(_.readonly&&(o=!0),a&&_.readonly)continue;if(Object.keys(_.conflict).length>0){if(Object.entries(_.conflict).every(([g,m])=>!m.differentSchema))continue;Object.entries(_.conflict).forEach(([g])=>{bsc({property:_.key,schemaId:g,context:t,namespace:i}).forEach(j=>{f.add(j)})})}let h=Af({schema:_.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),y=_.audiences,b=_.nameOverride,v=ZE(_.availability),O=ztM(_);c[_.key]=RtM({typeReference:h,audiences:y,name:b,availability:v,propertyAccess:O})}let s=new Set;for(let _ of e.allOfPropertyConflicts)_.allOfSchemaIds.forEach(h=>f.add(h)),_.conflictingTypeSignatures&&s.add(_.propertyKey);let u=[];for(let _ of e.allOf){let h=ry_({schema:_.schema,context:t,namespace:i});if(h==null||f.has(_.schema)||f.has(h))continue;let y=Af({schema:Zs.reference(_),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(hO(y))}for(let _ of f){let h=vsc(t,_,i);for(let y of h.properties)c[y.key]==null&&(s.has(y.key)&&(c[y.key]="unknown"),c[y.key]=Af({schema:y.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let y of h.allOf){if(f.has(y.schema))continue;let b=Af({schema:Zs.reference(y),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(hO(b))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([_,h])=>TtM(_)?[_,typeof h=="string"?{type:h,name:`_${_}`}:{...h,name:`_${_}`}]:[_,h]))};u.length>0&&(l.extends=u),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=ZE(e.availability)),e.source!=null&&(l.source=Hvi(e.source)),l.inline=gsc(e,n);let p=e.nameOverride??e.generatedName;return{name:o&&t.options.respectReadonlySchemas&&!a?`${p}Read`:p,schema:l}}function bsc({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return bsc({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:o}=vsc(r,t,i),c=a.some(s=>s.key===e),f=[...o.flatMap(s=>bsc({property:e,context:r,schemaId:s.schema,namespace:i}))];if(c||f.length>0)return[t,...f]}return[]}function ey_(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?vsc(e,t.schema,r):t.type==="nullable"?ey_(e,t.value,r):{properties:[],allOf:[]}}function vsc(e,t,r){let i=e.getSchema(t,r);return i==null?{properties:[],allOf:[]}:ey_(e,i,r)}function EtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:lsc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function StM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:fsc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function MtM(e){let t=N3o(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 Zh_(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function ija(e,t){let r={enum:e.values.map(a=>{let o=a.nameOverride??a.generatedName,c=a.value;if(o===c&&a.description==null&&(a.casing==null||Zh_(a.casing)))return o;let f={value:a.value};if(o!==c&&(f.name=o),a.description!=null&&(f.docs=a.description),a.casing!=null&&!Zh_(a.casing)){let s={},u=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,u=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,u=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,u=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,u=!0),u&&(f.casing=s)}return f})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=gsc(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?Hvi(e.source):void 0};for(let a of r.enum){let o=typeof a=="string"?a:a.name??a.value;i.has(o.toLowerCase())||(n.enum.push(a),i.add(o.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function DtM({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:csc({schema:e,context:t,fileContainingReference:r,namespace:i})}}function BtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.options.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:dsc({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:ty_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function ty_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:F3o({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function ItM(e,t){return{name:e??t,schema:psc()}}function CtM(e,t,r){return{name:t??r,schema:_sc(e)}}function ysc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?z3o(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=Af({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let f={};for(let[s,u]of Object.entries(e.schemas))f[s]=Af({schema:u,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?ZE(e.availability):void 0,union:f,encoding:a,source:e.source!=null?Hvi(e.source):void 0}}}let o=[];for(let c of e.schemas)o.push(Af({schema:c,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:o,encoding:a,source:e.source!=null?Hvi(e.source):void 0,inline:gsc(e,n)}}}var qtM=/^[0-9]/;function TtM(e){return qtM.test(e)}function ry_({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?ry_({context:t,schema:i.schema,namespace:r}):e}function RtM({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function gsc(e,t){return e.inline===!0||t>0?!0:void 0}function ztM(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return OD.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return OD.ObjectPropertyAccess.WriteOnly}}function iy_(e){let t=e.replace(/^x-|^X-/,"");return No(t)}function ny_(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:r,schema:n}),t||(e.builder.setAuth(r),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:r,schema:n}),t||(e.builder.setAuth(r),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??iy_(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:r,schema:n}),t||(e.builder.setAuth(r),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(Tu.of("__package__.yml"),{name:"OauthScope",schema:ija(i.scopesEnum,0).schema})}}function vGt({header:e,context:t,fileContainingReference:r,namespace:i}){let n=Af({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=hO(n),o=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:No(o);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let f={type:a};return c!==e.name&&(f.name=c),e.description!=null&&(f.docs=e.description),e.env!=null&&(f.env=e.env),e.availability!=null&&(f.availability=ZE(e.availability)),f}function U3o({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=Af({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return hO(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:hO(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=ZE(e.availability)),a}function V3o({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=Osc({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=hO(n.value),o=rja(n.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return o!=null&&(c.default=o),n.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=ZE(e.availability)),NtM(n.value)&&n.value.validation!==void 0&&(c.validation=n.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function Osc({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:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:Tu.of(ob),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,f]of Object.entries(n.value.schemas))f.type==="primitive"&&f.schema.type==="string"&&(o=!0),f.type==="literal"&&f.value.type==="string"&&(cUn.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:lUn(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[c,f]=n.value.schemas;if(c!=null&&f!=null&&L3o({array:c,primitive:f}))return{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&f!=null&&L3o({array:c,primitive:f}))return{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[c,f]of Object.entries(n.value.schemas))return Osc({schema:f,context:t,fileContainingReference:r,namespace:i})}else if(t.options.objectQueryParameters)return{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let n=e.type==="optional"?Zs.optional:Zs.nullable;if(e.value.type==="reference"){let a=t.getSchema(e.value.schema,i);if(a==null)return;if(a.type==="array")return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a.value,description:e.description??a.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.options.objectQueryParameters)return{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,f]of Object.entries(e.value.value.schemas))f.type==="primitive"&&f.schema.type==="string"&&(o=!0),f.type==="literal"&&f.value.type==="string"&&(cUn.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:lUn(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[c,f]=e.value.value.schemas;if(c!=null&&f!=null&&L3o({array:c,primitive:f}))return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&f!=null&&L3o({array:f,primitive:c}))return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}if(t.options.objectQueryParameters)return{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1};for(let[c,f]of Object.entries(e.value.value.schemas))return Osc({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.options.objectQueryParameters?{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:Af({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:Af({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function L3o({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function NtM(e){return typeof e=="object"&&e!==null&&"type"in e}function ay_({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"]=FtM(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=QtM({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=HCi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function FtM(e){let t={};return e.forEach(r=>{let i=HCi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function QtM({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=HCi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function HCi(e){switch(e.type){case"primitive":return oy_(e.value);case"object":return uy_(e.properties);case"array":return UtM(e.value);case"map":return LtM(e.value);case"oneOf":return VtM(e.value);case"enum":return e.value;case"literal":return WtM(e.value);case"unknown":return HCi(e.value);case"null":return null;default:vt(e)}}function oy_(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:vt(e)}}function uy_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,HCi(r)]))}function UtM(e){return e.map(t=>HCi(t))}function LtM(e){return Object.fromEntries(e.map(t=>[oy_(t.key),HCi(t.value)]))}function VtM(e){return e.type==="discriminated"?uy_(e.value):HCi(e.value)}function WtM(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:vt(e)}}function nja(e){try{let r=new URL(e).pathname.split("/").filter(i=>i.length>0);if(r.length>0)return r[r.length-1]}catch{}}function W3o(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function x3o(e,t,r=!1){let i=nja(t);return r&&i!=null?i:e!=null&&i!=null?`${e}_${i}`:i??e??"websocket"}function Kvi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function G3o(e,t){return t??(e?.groupName!=null?Kvi(e.groupName):void 0)}function sy_({channel:e,context:t,declarationFile:r}){let i=e.servers[0],n=i!=null?t.options.groupEnvironmentsByHost?t.getUrlId(i.url)??x3o(i.name,i.url,!0):i.name:void 0;t.logger.debug(`[buildChannel] Channel path="${e.path}", server name="${i?.name}", server url="${i?.url}", resolved urlId="${n}" (from collision map: ${t.getUrlId(i?.url??"")!=null})`);let a={path:e.path,url:n,auth:!1};e.audiences!=null&&e.audiences.length>0&&(a.audiences=e.audiences),e.summary!=null&&(a["display-name"]=e.summary),e.description!=null&&(a.docs=e.description);let o=Kvi(e.groupName),c={};if(e.handshake.pathParameters.length>0)for(let u of e.handshake.pathParameters)c[u.name]=U3o({pathParameter:u,context:t,fileContainingReference:r,namespace:o});Object.keys(c).length>0&&(a["path-parameters"]=c);let f={};if(e.handshake.queryParameters.length>0)for(let u of e.handshake.queryParameters){let l=V3o({queryParameter:u,context:t,fileContainingReference:r,namespace:o});l!=null&&(f[u.name]=l)}Object.keys(f).length>0&&(a["query-parameters"]=f);let s={};if(e.handshake.headers.length>0)for(let u of e.handshake.headers){let l=vGt({header:u,context:t,fileContainingReference:r,namespace:o});s[u.name]=l}Object.keys(s).length>0&&(a.headers=s),t.builder.addChannel(r,{channel:a});for(let u of e.messages)t.builder.addChannelMessage(r,{messageId:u.name,message:{origin:u.origin,body:Af({schema:u.body,context:t,fileContainingReference:r,namespace:o,declarationDepth:0})}});for(let u of e.examples){let l=ay_({context:t,websocketExample:u});t.builder.addChannelExample(r,{example:l})}}function Asc(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var $0e="Base",fy_="Default";function cy_(e){try{return new URL(e).hostname}catch{return}}function ly_(e){return e??fy_}function xtM(e,t){let r=new Map;for(let i of e){if(Asc(i)||!("url"in i)||!i.url)continue;let n=cy_(i.url)??i.url;r.has(n)||r.set(n,{environmentName:ly_(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.httpServers.push({name:i.name,url:i.url,audiences:i.audiences})}for(let i of t){let n=cy_(i.url)??i.url;r.has(n)||r.set(n,{environmentName:ly_(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.websocketServers.push(i)}return r}function CJi(e){return Object.entries(e).reduce((t,[r,i])=>(ghe(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function dy_(e){if(e.environmentOverrides!=null){for(let[v,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:v,schema:O});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[],i=e.ir.servers.some(v=>Asc(v)),n=e.ir.servers;for(let v of n)if(Asc(v)){let O={urls:{}};for(let[A,g]of Object.entries(v.urls))O.urls[A]=g.url;v.name&&(t[v.name]=O)}else if("url"in v&&v.url){let O=v.audiences?{url:v.url,audiences:v.audiences}:v.url;if(v.name==null){r.push(O);continue}t[v.name]=O}let a={},o={},c=[];for(let v of e.ir.endpoints)for(let O of v.servers){if(O.url==null&&O.name!=null){a[O.name]||(a[O.name]=[]);continue}if(O.url==null)continue;let A=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){c.push(A);continue}a[O.name]||(a[O.name]=[]),a[O.name]?.push({url:O.url,audiences:O.audiences}),o[O.name]=A}let f={},s=[];for(let v of e.ir.websocketServers){e.logger.debug(`[buildEnvironments] Processing WebSocket server: name="${v.name}", url="${v.url}"`);let O=v.audiences?{url:v.url,audiences:v.audiences}:v.url;if(v.name==null){s.push(O);continue}f[v.name]=O}let u=Object.keys(t).length,l=u>0,p=Object.keys(o).length>0,_=Object.keys(a).some(v=>a[v]?.length===0),h=Object.keys(f).length>0;if(e.options.groupEnvironmentsByHost&&h&&(l||e.ir.servers.length>0)){let v=Object.entries(f).map(([A,g])=>({name:A,url:typeof g=="string"?g:g.url,audiences:typeof g=="string"?void 0:g.audiences})),O=xtM(n,v);if(O.size>0){let A=!0;for(let[g,m]of O.entries()){let j={},M=[...m.httpServers.map(D=>({...D,isHttp:!0})),...m.websocketServers.map(D=>({...D,isHttp:!1}))],E=new Map;for(let D of M){let B=nja(D.url),F=W3o(D.url);B&&F&&(E.has(B)||E.set(B,new Set),E.get(B)?.add(F))}if(m.httpServers.length>0){let D=m.httpServers[0];D!=null&&(j[$0e]=D.url,e.setUrlId(D.url,$0e));for(let B=1;B<m.httpServers.length;B++){let F=m.httpServers[B];if(F!=null){let N=nja(F.url),T=W3o(F.url),R=N?E.get(N):void 0,Q=R&&R.size>1,H=Q&&T!=="https"?`${N}_${T}`:N||`Http${B+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${F.url}", pathSegment="${N}", protocol="${T}", hasCollision=${Q}, urlId="${H}"`),j[H]=F.url,e.setUrlId(F.url,H)}}}for(let D of m.websocketServers){let B=nja(D.url),F=W3o(D.url),N=B?E.get(B):void 0,T=N&&N.size>1,R=T?`${B}_${F}`:x3o(D.name,D.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${D.name}", url="${D.url}", pathSegment="${B}", protocol="${F}", hasCollision=${T}, urlId="${R}"`),j[R]=D.url,e.setUrlId(D.url,R)}if(Object.keys(j).length>1)e.builder.addEnvironment({name:m.environmentName,schema:{urls:j}});else if(Object.keys(j).length===1){let D=Object.values(j)[0];D!=null&&e.builder.addEnvironment({name:m.environmentName,schema:D})}A&&(e.builder.setDefaultEnvironment(m.environmentName),Object.keys(j).length>1&&e.builder.setDefaultUrl($0e),A=!1)}return}}if(!l&&!p&&h&&e.ir.servers.length===0){for(let[v,O]of Object.entries(f))e.builder.addEnvironment({name:v,schema:O});e.builder.setDefaultEnvironment(Object.keys(f)[0]),e.builder.setDefaultUrl($0e);return}if(c.length>0&&e.logger.debug(`Skipping endpoint level servers ${c.map(v=>typeof v=="string"?v:v.url).join(", ")} because x-fern-server-name was not provided.`),!l){let v=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(v!=null){let A=O?{url:v,audiences:O}:v;t[fy_]=A}}let y=Object.values(t).map(v=>typeof v=="string"?v:ghe(v)?Object.values(v.urls)[0]:v.url),b=r.filter(v=>{let O=typeof v=="string"?v:v.url;return!y.includes(O)});if(b.length>0&&e.logger.debug(`Skipping top level servers ${b.map(v=>typeof v=="string"?v:v.url).join(", ")} because x-fern-server-name was not provided.`),i){let v=!0;for(let[O,A]of Object.entries(t))if(e.builder.addEnvironment({name:O,schema:A}),v){if(e.builder.setDefaultEnvironment(O),ghe(A)){let g=Object.keys(A.urls)[0];g&&e.builder.setDefaultUrl(g)}v=!1}return}if(!p&&!_){let v=!0;for(let[O,A]of Object.entries(t))if(v){if(h){let g=typeof A=="string"?A:ghe(A)?Object.values(A.urls)[0]:A.url;e.builder.addEnvironment({name:O,schema:{urls:{[$0e]:g??"",...CJi(f)}}})}else e.builder.addEnvironment({name:O,schema:A});e.builder.setDefaultEnvironment(O),v=!1}else if(h){let g=typeof A=="string"?A:ghe(A)?Object.values(A.urls)[0]:A.url;e.builder.addEnvironment({name:O,schema:{urls:{[$0e]:g??"",...CJi(f)}}})}else e.builder.addEnvironment({name:O,schema:A});h&&e.builder.setDefaultUrl($0e)}else if(u===1){let v=Object.keys(t)[0],O=Object.values(t)[0],A=typeof O=="string"?O:ghe(O)?Object.values(O.urls)[0]:O.url;e.builder.addEnvironment({name:v,schema:{urls:{[$0e]:A??"",...CJi(o),...CJi(f)}}}),e.builder.setDefaultEnvironment(v),e.builder.setDefaultUrl($0e)}else{let v=new Map;for(let O of e.ir.endpoints)for(let A of O.servers)if(A.url!=null&&A.name!=null){v.has(A.name)||v.set(A.name,new Map);let g=A.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",m=v.get(A.name);m&&m.set(g,A.url)}if(v.size>0){let O=!0;for(let[A,g]of Object.entries(t)){let m=typeof g=="string"?g:ghe(g)?Object.values(g.urls)[0]:g.url;if(!m)continue;let j=m.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",M={[$0e]:m};for(let[E,D]of v.entries()){let B=D.get(j)||D.get("production")||D.values().next().value;B&&(M[E]=B)}h&&Object.assign(M,CJi(f)),Object.keys(M).length>1?e.builder.addEnvironment({name:A,schema:{urls:M}}):e.builder.addEnvironment({name:A,schema:m}),O&&(e.builder.setDefaultEnvironment(A),O=!1)}v.size>0&&e.builder.setDefaultUrl($0e)}else{let O=!0;for(let[A,g]of Object.entries(t)){if(h||Object.keys(o).length>0){let m=typeof g=="string"?g:ghe(g)?Object.values(g.urls)[0]:g.url;e.builder.addEnvironment({name:A,schema:{urls:{[$0e]:m??"",...CJi(o),...CJi(f)}}})}else e.builder.addEnvironment({name:A,schema:g});O&&(e.builder.setDefaultEnvironment(A),O=!1)}}}}var msc=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},GtM=.75,HtM=new Set("authorization");function py_(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?fUn(i.schema):void 0,o=a!=null?Kvi(a):void 0,c=Tu.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?hO(Af({schema:i.schema,context:e,fileContainingReference:o?rD(Tu.of(No(o)),c):c,namespace:o,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.options.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(HtM.has(a.name.toLowerCase()))continue;let o=r[a.name];if(o==null){let c=t[a.name],f=vGt({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:Tu.of(i1),context:e,namespace:void 0});o=new msc(f),r[a.name]=o}o.increment()}let i=e.ir.endpoints.length*GtM;for(let[n,a]of Object.entries(r)){let o=t[n],c=a.count===e.ir.endpoints.length,f=a.count>=i;o==null&&(c?e.builder.addGlobalHeader({name:n,schema:a.schema}):f&&e.builder.addGlobalHeader({name:n,schema:IJi(a.schema)}))}}}function _y_(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?fUn(t.schema):void 0,i=r!=null?Kvi(r):void 0,n=vGt({header:{...t,schema:t.schema??Zs.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:ah.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:Tu.of(i1),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:IJi(n)})}}function HL(e){switch(e.type){case"primitive":return yy_(e.value);case"object":return by_(e.properties);case"array":return vy_(e.value);case"map":return JtM(e.value);case"oneOf":return $tM(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return YtM(e.value);case"unknown":return HL(e.value);case"null":return null;default:vt(e)}}function hy_(e){switch(e.type){case"withStreaming":return e.sse?{stream:KtM(e.events)}:{stream:vy_(e.events)};case"withoutStreaming":return{body:HL(e.value)};default:vt(e)}}function yy_(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:vt(e)}}function by_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,HL(r)]))}function KtM(e){return e.map(t=>({event:"",data:HL(t)}))}function vy_(e){return e.map(t=>HL(t))}function JtM(e){return Object.fromEntries(e.map(t=>[yy_(t.key),HL(t.value)]))}function $tM(e){return e.type==="discriminated"?by_(e.value):HL(e.value)}function YtM(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:vt(e)}}function gy_({endpointExample:e,context:t}){let r={};if(e.type!=="full")return e.value;e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=XtM(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=ZtM(e.queryParameters));let i=e.headers!=null&&e.headers.length>0,n=t.builder.getGlobalHeaders(),a=Object.keys(n).length>0,o=new Set(e.headers?.map(c=>c.name)??[]);if(i||a){let c=[];if(e.headers!=null)for(let f of e.headers)f.name!==t.builder.getAuthHeaderName()&&c.push(f);for(let[f,s]of Object.entries(n))if(!o.has(f))if(s!=null&&typeof s=="object"&&s.type!=null){let u=PB({type:s.type,_default:void 0,validation:void 0,visitor:{primitive:l=>l.toString(),map:l=>l.toString(),list:l=>l,optional:l=>l,nullable:l=>l,set:l=>l,named:l=>l,literal:l=>{if(l.type==="string")return l.string;if(l.type==="boolean")return l.boolean.toString()},unknown:Et}});u!=null&&c.push({name:f,value:Sl.literal(TCi.string(u))})}else c.push({name:f,value:Sl.primitive(Ha.string(f))});r.headers=ktM({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=HL(e.request)),e.response!=null&&(r.response=hy_(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(c=>c.type==="language"?{name:c.name??void 0,docs:c.description??void 0,language:c.language,code:c.code,install:c.install??void 0}:{name:c.name??void 0,docs:c.description??void 0,sdk:c.sdk,code:c.code}).filter(ps)),r}function XtM(e){let t={};return e.forEach(r=>{let i=HL(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function ZtM(e){let t={};return e.forEach(r=>{let i=HL(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function ktM({context:e,namedFullExamples:t}){let r={};return t.forEach(i=>{let n=HL(i.value);n!=null&&(r[i.name]=n)}),r}function Oy_(e){return gz._visit(e,{get:()=>OD.HttpMethodSchema.Get,post:()=>OD.HttpMethodSchema.Post,put:()=>OD.HttpMethodSchema.Put,patch:()=>OD.HttpMethodSchema.Patch,delete:()=>OD.HttpMethodSchema.Delete,head:()=>OD.HttpMethodSchema.Head,options:()=>{throw new Error("OPTIONS is unsupported")},trace:()=>{throw new Error("TRACE is unsupported")},_other:()=>{throw new Error("Unknown http method is unsupported")}})}function Ay_(e){return e==="POST"||e==="PUT"||e==="PATCH"}function my_({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,o=e.path,c=G3o(e.sdkName,e.namespace),f={};for(let b of e.pathParameters)b.parameterNameOverride&&(o=o.replace(b.name,b.parameterNameOverride)),f[b.parameterNameOverride??b.name]=U3o({pathParameter:b,context:r,fileContainingReference:t,namespace:c}),a.add(b.name);let s={};for(let b of e.queryParameters){let v=V3o({queryParameter:b,context:r,fileContainingReference:t,namespace:c});v!=null&&(s[b.name]=v,a.add(b.name))}let u;if(e.pagination!=null)switch(e.pagination.type){case"cursor":u={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":u={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":u={type:"custom",results:e.pagination.results};break;default:vt(e.pagination)}let l={path:o,method:Oy_(e.method),auth:erM({endpoint:e,context:r}),docs:e.description??void 0,pagination:u,source:e.source!=null?Hvi(e.source):void 0};!nrM({context:r,request:e.request})&&Object.keys(f).length>0&&(l["path-parameters"]=f),e.summary!=null&&(l["display-name"]=e.summary);let p={},_=r.builder.getGlobalHeaderNames(),h=r.builder.getAuthHeaderName();h!=null&&_.add(h);let y=e.headers.filter(b=>!_.has(b.name));for(let b of y){let v=vGt({header:b,context:r,fileContainingReference:t,namespace:c});p[b.name]=v,a.add(typeof v=="string"?b.name:v.name??b.name)}if(e.request!=null){r.setInState(C1.Request);let b=irM({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.options.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(p).length>0?p:void 0,usedNames:a,namespace:c});l.request=b.value,n=[...n,...b.schemaIdsToExclude??[]],r.unsetInState(C1.Request)}else{let b=r.options.inlinePathParameters&&Object.keys(f).length>0,v=Object.keys(s).length>0,O=Object.keys(p).length>0,A={};(b||v||O)&&(A.name=e.requestNameOverride??e.generatedRequestName),b&&(A["path-parameters"]=f),v&&(A["query-parameters"]=s),O&&(A.headers=p),Object.keys(A).length>0&&(l.request=A)}if(e.response!=null&&e.response._visit({json:b=>{let v=Af({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:b.description??void 0,type:hO(v)},b.statusCode!=null&&(l.response["status-code"]=b.statusCode),b.responseProperty!=null&&(l.response.property=b.responseProperty)},streamingJson:b=>{let v=Af({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:hO(v),format:"json"}},streamingSse:b=>{let v=Af({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:hO(v),format:"sse"}},file:b=>{l.response={docs:b.description??void 0,type:"file","status-code":b.statusCode}},bytes:b=>{l.response={docs:b.description??void 0,type:"bytes","status-code":b.statusCode}},streamingText:b=>{l["response-stream"]={docs:b.description??void 0,type:"text"}},text:b=>{l.response={docs:b.description??void 0,type:"text","status-code":b.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let b=r.getDefaultServerName(),v=e.servers[0];v==null?b!=null&&(l.url=b):l.url=v.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=ZE(e.availability)),Object.entries(e.errors).forEach(([b,v])=>{let O=v.generatedName,A=Tu.of(ob);r.builder.enableUniqueErrorsPerEndpoint&&(O=`${e.generatedRequestName}${v.generatedName}`,v.schema!=null&&(v.schema.type!=="reference"&&v.schema.type!=="oneOf"?v.schema.generatedName=`${e.generatedRequestName}${v.schema.generatedName}`:v.schema.type==="oneOf"&&(v.schema.value.generatedName=`${e.generatedRequestName}${v.schema.value.generatedName}`)));let g={"status-code":parseInt(b)},m=Kh_({location:Py_,namespaceOverride:c});if(v.schema!=null){let E=Af({schema:v.schema,context:r,fileContainingReference:m,declarationFile:m,namespace:c,declarationDepth:0});g.type=hO(E),g.docs=v.description}r.builder.addError(m,{name:O,schema:r.isErrorUnknownSchema(parseInt(b))?{...g,type:"unknown"}:g}),l.errors==null&&(l.errors=[]);let j=r.builder.addImport({file:t,fileToImport:m});l.errors.push(j!=null?`${j}.${O}`:O),g.type!=null&&v.examples?.forEach(E=>{let D={value:HL(E.example),name:E.name,docs:E.description};r.builder.addErrorExample(m,{name:O,example:D})})}),e.examples.length>0&&(l.examples=trM({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=rrM({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[Psc,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function erM({endpoint:e,context:t}){if(e.security==null)return t.authOverrides?.auth!=null?!0:t.ir.security==null?void 0:t.ir.security.length>0?!0:void 0;if(e.security.length!==0)return JSON.stringify(e.security)===JSON.stringify(t.ir.security)?!0:e.security}function trM({endpointExamples:e,context:t}){return e.map(r=>{try{return gy_({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function rrM({retries:e}){if(e!=null)switch(e.type){case"disabled":return{disabled:e.value??void 0};default:vt(e)}}function irM({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:o,queryParameters:c,nonRequestReferencedSchemas:f,headers:s,usedNames:u,namespace:l}){if(i.type==="json"||i.type==="formUrlEncoded"){let p=i.schema.type==="reference"?i.schema.schema:void 0,_=i.schema.type==="reference"?r.getSchema(i.schema.schema,l):i.schema;if(_?.type!=="object"||p!=null&&f.includes(p)){let O=Af({schema:i.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),A={schemaIdsToExclude:[],value:{body:O}},g=Object.keys(o??{}).length>0,m=Object.keys(c??{}).length>0,j=Object.keys(s??{}).length>0;return g&&(A.value["path-parameters"]=o),m&&(A.value["query-parameters"]=c),j&&(A.value.headers=s),(g||m||j)&&(A.value.name=n??a),i.contentType!=null&&(A.value["content-type"]=i.contentType),i.description!=null&&(A.value.docs=i.description),A}let h=Object.fromEntries(_.properties.filter(O=>O.readonly==null?!0:!(Ay_(e.method)&&O.readonly)).map(O=>{let A=Af({schema:O.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:1}),g=O.nameOverride??O.key,m=ZE(O.availability);if(!u.has(g)&&O.audiences.length<=0)return u.add(g),O.nameOverride!=null?[O.key,{type:hO(A),docs:dUn(A),name:O.nameOverride,availability:m}]:[O.key,m?{...typeof A=="string"?{type:A}:A,availability:m}:A];let j={type:hO(A),docs:dUn(A)};return u.has(g)&&(j.name=O.generatedName),O.audiences.length>0&&(j.audiences=O.audiences),m!=null&&(j.availability=m),u.add(g),[O.key,j]})),y=_.allOf.map(O=>{let A=Af({schema:Zs.reference(O),fileContainingReference:t,context:r,namespace:l,declarationDepth:0});return hO(A)}).filter(O=>O!=="unknown"),b={properties:h};y.length>0&&(b.extends=y),i.additionalProperties&&(b["extra-properties"]=!0);let v={name:n??_.nameOverride??_.generatedName,"path-parameters":o,"query-parameters":c,headers:s,body:b};return i.contentType!=null&&(v["content-type"]=i.contentType),i.description!=null&&(v.docs=i.description),{schemaIdsToExclude:p!=null?[p]:[],value:v}}else if(i.type==="octetStream"){let p={body:"bytes","content-type":i.contentType??LA.APPLICATION_OCTET_STREAM,"query-parameters":c};return c!=null&&(p.name=n??a),i.description!=null&&(p.docs=i.description),{schemaIdsToExclude:[],value:p}}else if(i.type==="multipart"){let p=Object.fromEntries(i.properties.map(_=>{if(_.schema.type==="file"){let h=_.schema.isArray?"list<file>":"file";if(h=_.schema.isOptional?`optional<${h}>`:h,_.description!=null||_.contentType!=null){let y={type:h};if(_.description!=null&&(y.docs=_.description),_.contentType!=null){let b=_.contentType.split(",")[0];y["content-type"]=b}return[_.key,y]}return[_.key,h]}else{let h=Af({schema:_.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(_.contentType||_.exploded||_.encoding){let y=typeof h=="string"?{type:h}:h;_.contentType!=null&&(y["content-type"]=_.contentType),_.encoding==="form"?y.style="form":_.encoding==="json"?y.style="json":_.exploded&&(y.style="exploded"),h=y}return[_.key,h]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":o,"query-parameters":c,headers:s,body:{properties:p},"content-type":LA.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else vt(i)}function nrM({context:e,request:t}){if(!e.options.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:vt(t)}}function arM({location:e,namespaceOverride:t}){return t!=null?{...e,file:rD(Tu.of(t),e.file)}:e}function orM(e){let t=e.namespace,r=e.tags.filter(f=>f!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:Tu.of(`${No(r)}.yml`),endpointId:e.summary!=null?No(e.summary):No(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Tu.of(ob),endpointId:No(e.summary)}:{file:Tu.of(ob),endpointId:No(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Tu.of(ob),endpointId:i};let n=aja(r),a=aja(i);if(t1(n,a))return{file:Tu.of("__package__.yml"),endpointId:r};let o=crM({operationId:i,tag:r,path:e.path,method:e.method});if(o!=null)return o;let c=[];for(let f=0;f<n.length;++f){let s=n[f];if(s!=null&&s===a[f])c.push(s);else{let u=No(r);return{file:Tu.of(`${u}.yml`),endpointId:i,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:Tu.of(No(c.join("_"))+".yml"),endpointId:No(a.slice(c.length).join("_")),tag:r}}function oja(e){let t=e.tags[0];if(e.sdkName!=null){let r=osc({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Tu.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return arM({namespaceOverride:e.namespace,location:orM(e)})}function aja(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=$Oe(t),t}var urM=new RegExp("[^a-zA-Z0-9{}]+"),srM=new RegExp("[{}]","g");function crM({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(urM).join("_").replaceAll(srM,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:Tu.of(No(t)+".yml"),endpointId:No(e.slice(0,-1*a.length)),tag:t}}function jy_(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:o,file:c,tag:f}=oja(a),s=c.split(".")[0];s!=null&&t.add(s);let u;if(a.sdkName!=null){let _=e.ir.groups;for(let h of a.sdkName.groupName){let y=typeof h=="string"?h:h.name,b=_[y];if(b==null)break;if(b.summary!=null||b.description!=null){u=_[y];break}}}let l=f==null?void 0:i.tagsById[f];e.setInState(C1.Endpoint),e.setEndpointMethod(a.method);let p=my_({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(C1.Endpoint),n=[...n,...p.schemaIdsToExclude],e.builder.addEndpoint(c,{name:o,schema:p.value,source:a.source!=null?Hvi(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":u?.summary??l?.id,docs:u?.description??l?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function wy_(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?Kvi(r.groupName):void 0,n=Af({schema:Zs.primitive(r),context:e,fileContainingReference:Tu.of(ob),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:hO(n),docs:r.description??void 0}})}}function Ey_(e){for(let t of e.ir.webhooks){let r=drM({webhook:t,context:e});if(r==null)continue;let i=G3o(t.sdkName,t.namespace),n={};for(let o of t.headers)n[o.name]=vGt({header:o,context:e,fileContainingReference:r.file,namespace:i});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:n,payload:Af({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(o=>({docs:o.description,name:o.name,payload:HL(o.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function lrM({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:rD(Tu.of(t),e.file)}:e}function frM({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:Tu.of(ob),endpointId:i};let n=aja(r),a=aja(i);if(t1(n,a))return{file:Tu.of("__package__.yml"),endpointId:r};let o=[];for(let c=0;c<n.length;++c){let f=n[c];if(f!=null&&f===a[c])o.push(f);else{let s=No(r);return{file:Tu.of(`${s}.yml`),endpointId:i,tag:r}}}if(o.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:Tu.of(No(o.join("_"))+".yml"),endpointId:No(a.slice(o.length).join("_")),tag:r}}function drM({webhook:e,context:t}){return e.sdkName!=null?{file:Hh_({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:lrM({namespaceOverride:e.namespace,location:frM({webhook:e,context:t})})}var prM=Tu.of(ob);function My_(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return Sy_({namespace:e.namespace,groupName:e.groupName});case"oneOf":return Sy_({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return prM;default:vt(e)}}function Sy_({namespace:e,groupName:t}){return e!=null&&t!=null?GCi([{type:"namespace",name:e},...t]):e!=null?GCi([{type:"namespace",name:e}]):GCi(t)}var Psc="external",Py_=Tu.of(ob);function Dy_({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let o=My_(a),c=kh_({schema:a,context:i,declarationFile:o,namespace:r,declarationDepth:0});if(gCi(c.schema)){let f=hO(c.schema);if(f===(c.name??n)||f===`optional<${c.name??n}>`||f===`nullable<${c.name??n}>`||f===`optional<nullable<${c.name??n}>>`)continue}i.builder.addType(o,{name:c.name??n,schema:c.schema})}}function By_(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),dy_(e),py_(e),_y_(e),ny_(e),wy_(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(Psc);let t=jy_(e),r=t.sdkGroups;e.setInState(C1.Webhook),Ey_(e),e.unsetInState(C1.Webhook),e.setInState(C1.Channel);for(let n of Object.values(e.ir.channels)){let a=GCi(n.groupName);sy_({channel:n,context:e,declarationFile:a})}e.unsetInState(C1.Channel);let i=_rM({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});Dy_({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))Dy_({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 _rM({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}var uja=class{context;constructor(t){this.context=t}};var H3o=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[o,c]of Object.entries(i.files)){let f=n!=null?Tu.of(`${n}${"/"}${o}`):Tu.of(o);t[f]=c}let a=Object.keys(i.directories).sort();for(let o of a){let c=n!=null?`${n}${"/"}${o}`:o,f=i.directories[o];r(f,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Tu.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 qJi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new H3o,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 o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(o.service.auth=r),i!=null&&(o.service["base-path"]=i),n!=null&&(o.service["display-name"]=n),a!=null&&(o.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 nGt(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"]))Iy_(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(Iy_(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??No((fAe(r)+"/"+b9i(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Tu.of(i1))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=Puo(fAe(GDn.of(`/${t}`)),GDn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=Puo(fAe(GDn.of(`/${t}`)),GDn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===Tu.of(i1))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>t1(c,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=rD(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:rD(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,o])=>[a,{...o,path:rD(r,o.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===ob?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 Iy_(e){return e?.header!=null}var K3o=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;options;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;urlIdMap=new Map;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:o}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=o,this.globalHeaderOverrides=a,this.options=MJi({options:i}),this.enableUniqueErrorsPerEndpoint=this.options.enableUniqueErrorsPerEndpoint,this.referencedSchemaIds=this.options.onlyIncludeReferencedSchemas?new Set:void 0,this.builder=new qJi(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let f of r.endpoints)for(let[s,u]of Object.entries(f.errors)){let l=parseInt(s),p=c[l];p==null&&u.schema!=null?c[l]=u.schema:p!=null&&u.schema!=null&&nK(p,u.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}setUrlId(t,r){this.urlIdMap.set(t,r)}getUrlId(t){return this.urlIdMap.get(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.options.onlyIncludeReferencedSchemas&&this.isInAnyState(C1.Channel,C1.Endpoint,C1.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:vt(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:vt(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 jsc(e){let t=new K3o(e);return By_(t)}function hrM(e){return WKi(e,{single:t=>[typeof t=="string"?t:t.scheme],any:t=>t.any.map(r=>typeof r=="string"?r:r.scheme)})}function yrM(e,t){if(e==null)return;let r=hrM(t),i={};for(let n of r)e[n]!=null&&(i[n]=e[n]);return Object.keys(i).length>0?i:void 0}var J3o=class{args;constructor(t){this.args=t}buildAuthOverrides(t){let r=this.args.generatorsConfiguration?.api?.["auth-schemes"],i=this.args.generatorsConfiguration?.api?.auth,n=t??i;if(n==null)return;let a=yrM(r,n);return{auth:n,"auth-schemes":a}}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=jsc({taskContext:t,ir:r,options:MJi({options:i,overrides:this.args}),authOverrides:this.buildAuthOverrides(i?.auth),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:Li.dump(a.rootApiFile)},namedDefinitionFiles:{...bn(a.definitionFiles,o=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Li.dump(o),contents:o})),[Tu.of(ob)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Li.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var sja=class extends _Ft{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;groupEnvironmentsByHost;removeDiscriminantsFromSchemas;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.wrapReferencesToNullableInOptional=t.wrapReferencesToNullableInOptional,this.coerceOptionalSchemasToNullable=t.coerceOptionalSchemasToNullable,this.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.inlineAllOfSchemas=t.inlineAllOfSchemas,this.resolveAliases=t.resolveAliases,this.groupEnvironmentsByHost=t.groupEnvironmentsByHost,this.removeDiscriminantsFromSchemas=t.removeDiscriminantsFromSchemas,this.converter=new J3o(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,i){let n=await this.getDefinition({context:t},r);return new rK({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion})}};var JQ={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};var pUn={of(e){return e}};var Cy_={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},wsc={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:Cy_,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},Gi={SOURCE:pUn.of("source"),SDK_NAMESPACE:pUn.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:pUn.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:pUn.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:pUn.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",RETRIES:"x-fern-retries",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated",EXPLORER_ENABLED:"x-fern-explorer-enabled"};var brM={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!1,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!1,respectReadonlySchemas:!1,respectNullableSchemas:!0,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!0,preserveSchemaIds:!1,objectQueryParameters:!0,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!0,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!1,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1,resolveAliases:!1,groupMultiApiEnvironments:!1,groupEnvironmentsByHost:!1,wrapReferencesToNullableInOptional:!1,coerceOptionalSchemasToNullable:!1,removeDiscriminantsFromSchemas:wn.RemoveDiscriminantsFromSchemas.Always};function vrM(e){let{defaults:t,options:r,overrides:i,overrideOnly:n=new Set,undefinedIfAbsent:a=new Set}=e,o={};for(let c of Object.keys(t))n.has(c)?o[c]=i?.[c]!==void 0?i[c]:t[c]:a.has(c)?o[c]=i?.[c]!==void 0?i[c]:r?.[c]!==void 0?r[c]:void 0:o[c]=i?.[c]??r?.[c]??t[c];return o}function Y0e({options:e,overrides:t}){return vrM({defaults:brM,options:e,overrides:t,overrideOnly:new Set(["disableExamples","preserveSchemaIds"]),undefinedIfAbsent:new Set(["exampleGeneration","defaultFormParameterEncoding"])})}var qy_={naming:"v1"};function Di(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function cja(e,t,r,i,n=[]){try{let a=Di(e,t);if(a!=null)return r.parse(a)}catch{let o=$Oe(n).join(" -> ");i.error(`${o.length>0?`${o}: `:""}Failed to parse ${t}`)}}function TJi(e){let t=Di(e,"examples");if(t!=null){if(Array.isArray(t))return t;if(typeof t=="object"&&t!==null)return Object.values(t).map(r=>typeof r=="object"&&r!==null&&"value"in r?r.value:r)}return[]}function Ty_({schema:e,logger:t}){return Di(e,Gi.ENCODING)??void 0}function Ry_(e){return Di(e,Gi.FERN_ENUM)}function zy_({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let o=Di(i,Gi.SDK_NAMESPACE),c=Di(i,Gi.SDK_GROUP_NAME),f=Di(i,Gi.TYPE_DEFINITION);if(f!=null)return lja({fernType:f,nameOverride:e,generatedName:t,title:r,description:n,availability:a,namespace:o,groupName:typeof c=="string"?[c]:c})}function lja({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c}){return PB({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.base64({example:void 0})});case"BOOLEAN":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.boolean({default:void 0,example:void 0})});case"DATE":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.date({example:void 0})});case"DATE_TIME":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.datetime({example:void 0})});case"FLOAT":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.float({example:void 0})});case"DOUBLE":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.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 ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.uint({default:void 0,example:void 0})});case"INTEGER":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.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 ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.uint64({default:void 0,example:void 0})});case"LONG":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:vt(f.v1)}},unknown:()=>ri.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,namespace:o,groupName:c}),map:({keyType:f,valueType:s})=>f?.type==="primitive"&&s!=null?ri.map({nameOverride:t,generatedName:r,title:i,key:f,value:s,description:n,availability:a,namespace:o,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:f=>f!=null?ri.array({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,optional:f=>f!=null?ri.optional({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,nullable:f=>f!=null?ri.nullable({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,set:f=>f!=null?ri.array({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,literal:f=>ri.literal({nameOverride:t,generatedName:r,title:i,value:f._visit({string:s=>Fj.string(s),boolean:s=>Fj.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:o,groupName:c}),named:f=>ri.reference({schema:f,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,source:xL.openapi({file:"<memory>"})})}})}function Ny_(e){let t=Di(e,Gi.SOURCE);if(t!=null)return t.endsWith(".proto")?xL.protobuf({file:t}):xL.openapi({file:t})}function RJi(e){if(e!=null&&typeof e=="boolean")return e}function jn(e){return e?.$ref!=null}function Fy_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:f,context:s,namespace:u,groupName:l,example:p,encoding:_,source:h}){return n===void 0&&(n=s.options.additionalPropertiesDefaultsTo),Esc({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:f,description:a,availability:o,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Ln.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:typeof n=="boolean"||fja(n,s.options)?ri.unknown({...grM(n),generatedName:`${t}Value`}):Qy_(Dl(n,!1,s.options.optionalAdditionalProperties?f:!1,s,[...i,"Value"],h,u,void 0,void 0,void 0)),namespace:u,groupName:l,example:p,encoding:_})}function Qy_(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=Qy_(e.value);break;case"oneOf":e.value.inline=!0;break;default:vt(e)}return e}function Esc({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsOptional:a,wrapAsNullable:o,description:c,availability:f,namespace:s,groupName:u,example:l,encoding:p}){let _=ri.map({nameOverride:e,generatedName:t,title:r,description:c,availability:f,key:i,value:n,namespace:s,groupName:u,encoding:p,example:l,inline:void 0});return o&&(_=ri.nullable({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:f,namespace:s,groupName:u,inline:void 0})),a&&(_=ri.optional({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:f,namespace:s,groupName:u,inline:void 0})),_}function fja(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!(jn(e)||"type"in e&&e.type!=null||"oneOf"in e&&e.oneOf!=null||"anyOf"in e&&e.anyOf!=null||"allOf"in e&&e.allOf!=null||"enum"in e&&e.enum!=null)}function grM(e){let t={nameOverride:void 0,generatedName:"",title:void 0,description:void 0,availability:void 0,example:void 0,namespace:void 0,groupName:void 0};return e==null||typeof e=="boolean"||jn(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function Uy_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:f,context:s,namespace:u,groupName:l,example:p,source:_}){let h=n==null?ri.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:l}):Dl(n,!1,!1,s,[...i,"Item"],_,u);return OrM({nameOverride:e,generatedName:t,title:r,namespace:u,groupName:l,itemSchema:h,wrapAsOptional:c,wrapAsNullable:f,description:a,availability:o,example:p})}function OrM({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:f,groupName:s,example:u}){let l=ri.array({nameOverride:e,generatedName:t,title:r,value:i,description:o,availability:c,namespace:f,groupName:s,example:u,inline:void 0});return a&&(l=ri.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),n&&(l=ri.optional({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),l}function KL(e){switch(Di(e,Gi.AVAILABILITY)){case"deprecated":return bz.Deprecated;case"beta":return bz.Beta;case"generally-available":return bz.GenerallyAvailable;default:break}if(!jn(e)&&e.deprecated)return bz.Deprecated}function Ssc({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:o,required:c,wrapAsOptional:f,wrapAsNullable:s,discriminator:u,context:l,namespace:p,groupName:_,encoding:h,source:y}){let b=u.propertyName,v=Object.fromEntries(Object.entries(u.mapping??{}).map(([A,g])=>{let m=Jvi({$ref:g},!1,!1,l,[g],h,y,p);return l.markReferencedByDiscriminatedUnion({$ref:g},b,1),[A,m]})),O=Object.entries(n).filter(([A])=>A!==b).map(([A,g])=>{let m=c!=null&&c.includes(A),[j,M]=l.options.coerceOptionalSchemasToNullable?[!1,!m]:[!m,!1],E=Dl(g,j,M,l,[...i,A],y,p);return{key:A,schema:E}});return Ly_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:f,wrapAsNullable:s,properties:O,description:a,availability:o,discriminant:b,subtypes:v,namespace:p,groupName:_,source:y})}function Msc({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:o,required:c,wrapAsOptional:f,wrapAsNullable:s,discriminant:u,variants:l,context:p,namespace:_,groupName:h,encoding:y,source:b}){let v=Object.fromEntries(Object.entries(l).map(([A,g])=>{if(jn(g)){let m=Jvi(g,!1,!1,p,[g.$ref],y,b,_);return p.markReferencedByDiscriminatedUnion(g,u,1),[A,m]}else{let m=_Un(g,!1,!1,p,[...i,A],y,b,_,new Set([u]));return[A,m]}})),O=Object.entries(n).filter(([A])=>A!==u).map(([A,g])=>{let m=c!=null&&c.includes(A),[j,M]=p.options.coerceOptionalSchemasToNullable?[!1,!m]:[!m,!1],E=Dl(g,j,M,p,[...i,A],b,_);return{key:A,schema:E}});return Ly_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:f,wrapAsNullable:s,properties:O,description:a,availability:o,discriminant:u,subtypes:v,namespace:_,groupName:h,source:b})}function Ly_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,properties:a,description:o,availability:c,discriminant:f,subtypes:s,namespace:u,groupName:l,source:p}){let _=ri.oneOf(Bhe.discriminated({description:o,availability:c,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:s,commonProperties:a,namespace:u,groupName:l,encoding:void 0,source:p,inline:void 0}));return n&&(_=ri.nullable({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),i&&(_=ri.optional({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),_}function Vy_(e){if(e.proto!=null)return qQn.protobuf({typeName:e.proto.type})}function KCi({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:o,description:c,availability:f,wrapAsOptional:s,wrapAsNullable:u,namespace:l,groupName:p,context:_,source:h,inline:y}){let b=mrM(n??[]),v=new Set(a),O=Array.from(v).map((g,m)=>{let j=i?.[g],M=b[m],E=cUn.test(g),D=j?.name??M,B=E?g:lUn(g);return D!=null&&!cUn.test(D)&&(_?.logger.warn(`Enum name override ${D} is not a valid name. Falling back on ${B}.`),D=void 0),{nameOverride:D,generatedName:B,value:g,description:j?.description,availability:f,casing:{snake:j?.casing?.snake??void 0,pascal:j?.casing?.pascal??void 0,screamingSnake:j?.casing?.screamingSnake??void 0,camel:j?.casing?.camel??void 0}}}),A=o!=null?O.find(g=>g.value===o):void 0;return ArM({wrapAsOptional:s,wrapAsNullable:u,nameOverride:e,generatedName:t,title:r,values:O,_default:A,description:c,availability:f,namespace:l,groupName:p,source:h,inline:y})}function ArM({wrapAsOptional:e,wrapAsNullable:t,nameOverride:r,generatedName:i,title:n,values:a,_default:o,description:c,availability:f,namespace:s,groupName:u,source:l,inline:p}){let _=ri.enum({nameOverride:r,generatedName:i,title:n,values:a,description:c,availability:f,default:o,example:void 0,namespace:s,groupName:u,source:l,inline:p});return t&&(_=ri.nullable({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:f,namespace:s,groupName:u,inline:p})),e&&(_=ri.optional({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:f,namespace:s,groupName:u,inline:p})),_}function mrM(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 Wy_({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,description:u,availability:l,wrapAsOptional:p,wrapAsNullable:_,example:h,namespace:y,groupName:b}){return i==="int64"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint32"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint64"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}function PrM(e){return typeof e=="string"?Fj.string(e):typeof e=="boolean"?Fj.boolean(e):Fj.string(`${e}`)}function xy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,value:a,description:o,availability:c,namespace:f,groupName:s}){let u=ri.literal({nameOverride:e,generatedName:t,title:r,value:PrM(a),description:o,availability:c,namespace:f,groupName:s});return n&&(u=ri.nullable({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),i&&(u=ri.optional({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),u}function Dsc({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,description:u,availability:l,wrapAsOptional:p,wrapAsNullable:_,example:h,namespace:y,groupName:b}){return i==null||i==="double"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.double({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="float"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int32"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int64"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint32"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint64"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="time-delta"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}var jrM={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},wrM={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}}},ErM={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}}},SrM={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},MrM={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},DrM={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},BrM={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},IrM={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function dja(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[jrM,wrM,ErM,SrM,MrM,DrM,BrM,IrM],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:o,newBreadcrumbs:c}=a.applyStrategy(t);t=o,r=[...r,...c]}}while(t.join("")!==n.join(""));return r}function qC(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:QP(No(n))).join("");return/^\d/.test(i)?tja(i)??i:i}function Gy_(e){let t=e.join("_");return No(t)}function xO(e){switch(e.type){case"object":return Zs.object({allOf:e.allOf,properties:e.properties.map(t=>qrM(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:e.inline});case"array":return Zs.array({description:e.description,availability:e.availability,value:xO(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return Zs.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,source:e.source,inline:e.inline});case"literal":return Zs.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"nullable":return Zs.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:xO(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return Zs.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:xO(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return Zs.primitive({description:e.description,availability:e.availability,schema:Hy_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Zs.map({description:e.description,availability:e.availability,key:Zs.primitive({description:e.key.description,availability:e.key.availability,schema:Hy_(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:xO(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return Zs.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return Zs.oneOf(CrM(e.value));case"unknown":return Zs.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:vt(e)}}function CrM(e){switch(e.type){case"discriminated":return pGt.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:xO(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,xO(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return pGt.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>xO(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:vt(e)}}function Hy_(e){switch(e.type){case"string":return ah.string(e);case"base64":return ah.base64();case"boolean":return ah.boolean(e);case"date":return ah.date();case"datetime":return ah.datetime();case"double":return ah.double(e);case"float":return ah.float();case"int":return ah.int(e);case"int64":return ah.int64(e);case"uint":return ah.uint();case"uint64":return ah.uint64();default:vt(e)}}function qrM(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:xO(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function $3o(e,t){return nK(xO(e),xO(t))}function Ky_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:o,wrapAsOptional:c,wrapAsNullable:f,allOf:s,context:u,propertiesToExclude:l,namespace:p,groupName:_,fullExamples:h,additionalProperties:y,availability:b,source:v}){let O=[...o??[]],A={...Jy_({properties:n,breadcrumbs:i,context:u})},g=[],m=[];for(let B of s)if(!u.options.inlineAllOfSchemas&&jn(B)){let F=u.resolveSchemaReference(B);if(F.discriminator!=null&&F.discriminator.mapping!=null)continue;if(F.oneOf!=null||F.anyOf!=null){let T=F.oneOf??F.anyOf;if(T!=null){for(let R of T){let Q=jn(R)?u.resolveSchemaReference(R):R,U=Dl(Q,!1,!1,u.DUMMY,i,v,p);U.type==="object"&&g.push(...U.properties.map(H=>H.schema.type!=="optional"&&H.schema.type!=="nullable"?{...H,schema:ri.optional({nameOverride:void 0,generatedName:"",title:void 0,value:H.schema,description:void 0,availability:H.availability,namespace:void 0,groupName:void 0,inline:void 0})}:H))}continue}}let N=JCi(B);if(N==null)continue;m.push({schemaId:N,convertedSchema:Bsc(B,[N],v,u.options.preserveSchemaIds),properties:$y_({schema:B,context:u,breadcrumbs:i,source:v,namespace:p})}),u.markSchemaAsReferencedByNonRequest(N)}else if(jn(B)){let F=u.resolveSchemaReference(B),N=Dl(F,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}else{let F=B.required??[];g=g.map(T=>(T.schema.type==="optional"||T.schema.type==="nullable")&&F.includes(T.key)?{...T,schema:T.schema.value}:T);let N=Dl(B,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}let j={};for(let B of m)for(let[F,N]of Object.entries(B.properties)){let T=j[F];T!=null?(T.schemaIds.push(B.schemaId),T.schemas.some(Q=>$3o(Q,N))||T.schemas.push(N)):j[F]={schemaIds:[B.schemaId],schemas:[N]}}let M=[];for(let[B,F]of Object.entries(j))F.schemaIds.length>1&&M.push({propertyKey:B,allOfSchemaIds:F.schemaIds,conflictingTypeSignatures:F.schemas.length>1});let E=Object.fromEntries(Object.entries(A).filter(([B,F])=>!(!jn(F)&&F.type==="null"))),D=Object.entries(E).map(([B,F])=>{let N=Di(F,Gi.AUDIENCES)??[],T=KL(F),R=jn(F)?!1:F.readOnly,Q=jn(F)?!1:F.writeOnly,H=!(O.includes(B)&&!R),ue=Di(F,Gi.FERN_PROPERTY_NAME),se=[...i,B],x=Gy_(se),G=Dl(F,H,!1,u,se,v,p),Pe={};for(let ne of m){let Ee=ne.properties[B];Ee!=null&&!$3o(G,Ee)?Pe[ne.schemaId]={differentSchema:!0}:Ee!=null&&(Pe[ne.schemaId]={differentSchema:!1})}return{key:B,schema:G,nameOverride:ue,audiences:N,conflict:Pe,generatedName:x,availability:T,readonly:R,writeonly:Q}});return D.push(...g.map(B=>{let F=B.conflict;for(let N of m){let T=N.properties[B.key];T!=null&&!$3o(B.schema,T)?F[N.schemaId]={differentSchema:!0}:T!=null&&(F[N.schemaId]={differentSchema:!1})}return{...B,conflict:F}})),TrM({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:f,properties:D.filter(B=>!l.has(B.key)),description:a,allOf:m.map(B=>B.convertedSchema),allOfPropertyConflicts:M,namespace:p,groupName:_,fullExamples:h,additionalProperties:y,availability:b,source:v,context:u})}function TrM({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,properties:a,description:o,allOf:c,allOfPropertyConflicts:f,namespace:s,groupName:u,fullExamples:l,additionalProperties:p,availability:_,source:h,context:y}){let b=ri.object({description:o,properties:a,nameOverride:e,generatedName:t,title:r,allOf:c,allOfPropertyConflicts:f,namespace:s,groupName:u,fullExamples:l,additionalProperties:fja(p,y.options),availability:_,source:h,inline:void 0});return n&&(b=ri.nullable({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),i&&(b=ri.optional({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),b}function Jy_({properties:e,breadcrumbs:t,context:r}){return Object.fromEntries(Object.entries(e).filter(([i,n])=>{let a=Di(n,Gi.IGNORE);return a&&r.logger.debug(`Property ${t.join(".")}.${i} is marked with x-fern-ignore. Skipping.`),!a}))}function $y_({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[o,c]=jn(e)?[t.resolveSchemaReference(e),dja(e.$ref)]:[e,r];for(let f of o.allOf??[])a={...a,...$y_({schema:f,context:t,breadcrumbs:c,source:i,namespace:n})};for(let[f,s]of Object.entries(Jy_({properties:o.properties??{},breadcrumbs:r,context:t}))){let u=Dl(s,!1,!1,t,[...c,f],i,n);a[f]=u}return a}function $Ci({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsOptional:o,wrapAsNullable:c,context:f,subtypes:s,namespace:u,groupName:l,encoding:p,source:_,subtypeSuffixOverrides:h}){let y=NrM({schemas:s}),b=s.flatMap((O,A)=>{if(!jn(O)&&O.enum!=null&&f.options.coerceEnumsToLiterals&&O.type==="string")return O.enum.map(m=>ri.literal({nameOverride:void 0,generatedName:qC([t,m],f.options.preserveSchemaIds),title:void 0,value:Fj.string(String(m)),namespace:u,groupName:void 0,description:void 0,availability:m.availability}));let g=y[A];if(h!=null){let m=h[A];m!=null&&"name"in m&&(g=m.name)}return[Dl(O,!1,!1,f,[...i,g??`${A}`],_,u)]}),v=RrM(b);return zrM({uniqueSubtypes:v,nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:c,description:n,availability:a,namespace:u,groupName:l,context:f,encoding:p,source:_})}function RrM(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let o=e[a];if(i!=null&&o!=null&&nK(i,o)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function zrM({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:f,groupName:s,context:u,encoding:l,source:p}){if(Object.entries(e).every(([h,y])=>y.type==="literal")){let h={},y=[];return Object.entries(e).forEach(([b,v])=>{v.type==="literal"&&v.value.type==="string"&&(y.push(v.value.value),v.description!=null&&(h[v.value.value]={description:v.description}))}),KCi({nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,fernEnum:h,enumVarNames:void 0,enumValues:y,_default:void 0,namespace:f,groupName:s,context:u,source:p,inline:void 0})}if(e.length===1&&e[0]!=null&&!u.options.preserveSingleSchemaOneOf){let h=e[0];return a&&(h=ri.nullable({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),n&&(h=ri.optional({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),h}return Yy_({nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,subtypes:e,namespace:f,groupName:s,encoding:l,source:p})}function Isc({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsOptional:a,wrapAsNullable:o,context:c,namespace:f,groupName:s,discriminator:u,encoding:l,source:p}){let _=Object.entries(u.mapping??{}).map(([b,v],O)=>{let A={$ref:v},g=Jvi(A,!1,!1,c,[v],l,p,f);return c.markSchemaWithDiscriminantValue(A,u.propertyName,b),g.type==="object"&&(g.properties={[u.propertyName]:ri.literal({nameOverride:void 0,generatedName:qC([t,b],c.options.preserveSchemaIds),title:void 0,value:Fj.string(b),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...g.properties.filter(m=>m.key!==u.propertyName)}),g}),h=[];for(let b=0;b<_.length;++b){let v=_[b],O=!1;for(let A=b+1;A<_.length;++A){let g=_[A];if(v!=null&&g!=null&&nK(v,g)){O=!0;break}}v!=null&&!O&&h.push(v)}if(Object.entries(h).every(([b,v])=>v.type==="literal")){let b={},v=[];return Object.entries(h).forEach(([O,A])=>{A.type==="literal"&&A.value.type==="string"&&(v.push(A.value.value),A.description!=null&&(b[A.value.value]={description:A.description}))}),KCi({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:i,availability:n,fernEnum:b,enumVarNames:void 0,enumValues:v,_default:void 0,namespace:f,groupName:s,context:c,source:p,inline:void 0})}return h.length===1&&h[0]!=null&&!c.options.preserveSingleSchemaOneOf?h[0]:Yy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:i,availability:n,subtypes:h,namespace:f,groupName:s,encoding:l,source:p})}function NrM({schemas:e}){let t={},r=0;for(let n of e){if(!jn(n)){if(n.properties!=null&&Object.entries(n.properties).length>0){let a=Object.keys(n.properties),o={},c=a;for(let[f,s]of Object.entries(t)){let u=qro(s,a);c=qro(c,s),o[f]=u}o[r]=c,t=o}}r++}return e.map((n,a)=>{let o=t[a];if(o!=null&&o.length>0){let c=o.sort();if(c[0]!=null)return c[0]}return BJi(a)??`${a}`})}function Yy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,description:a,availability:o,subtypes:c,namespace:f,groupName:s,encoding:u,source:l}){let p=ri.oneOf(Bhe.undiscriminated({description:a,availability:o,nameOverride:e,generatedName:t,title:r,schemas:c,namespace:f,groupName:s,encoding:u,source:l,inline:void 0}));return n&&(p=ri.nullable({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:f,groupName:s,inline:void 0})),i&&(p=ri.optional({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:f,groupName:s,inline:void 0})),p}function hUn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function Y3o({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=TJi(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function Xy_({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=TJi(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function gGt({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=TJi(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function Zy_({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=TJi(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var zJi="#/components/schemas/";function tb_(e,t){let r=jn(e)?t.resolveSchemaReference(e):e;switch(r.type){case"boolean":case"number":case"integer":return!0;case"string":return r.enum==null;case"array":return tb_(r.items,t);case"object":return!1;case void 0:return!1;default:return t.logger.warn("Unhandled schema type. Will not inline this schema",JSON.stringify(r)),!1}}function FrM(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:tb_(t,r):!1}function Dl(e,t,r,i,n,a,o,c=!1,f=new Set,s){let u=Ny_(e)??a,l=HrM({schema:e,logger:i.logger});if(jn(e)){let p=JCi(e);return p!=null?FrM(p,e,i)?_Un(i.resolveSchemaReference(e),t,r,i,dja(e.$ref),l,u,o,f,c,s):(c?i.markSchemaAsReferencedByRequest(p):i.markSchemaAsReferencedByNonRequest(p),Jvi(e,t,r,i,n,l,u,o)):_Un(i.resolveSchemaReference(e),t,r,i,dja(e.$ref),l,u,o,f,c,s)}return _Un(e,t,r,i,n,l,u,o,f,c,s)}function Jvi(e,t,r,i,n,a,o,c){let f=e.$ref.includes("properties")?_Un(i.resolveSchemaReference(e),t,r,i,n,a,o,c,new Set):ri.reference(Bsc(e,n,o,i.options.preserveSchemaIds));if(r===!1){let s=i.resolveSchemaReference(e);(s.nullable===!0||Array.isArray(s.type)&&s.type.length>=2&&s.type.includes("null"))&&(r=!0)}return r&&(f=ri.nullable({title:void 0,nameOverride:void 0,generatedName:qC(n,i.options.preserveSchemaIds),value:f,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(f=ri.optional({title:void 0,nameOverride:void 0,generatedName:qC(n,i.options.preserveSchemaIds),value:f,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),f}function QrM(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function _Un(e,t,r,i,n,a,o,c,f=new Set,s=!1,u){typeof e=="string"&&(e={type:e});let l=Di(e,Gi.TYPE_NAME)??(i.options.useTitlesAsName?QrM(e.title):void 0),p=Di(e,Gi.SDK_GROUP_NAME)??Di(e,JQ.TAGS)?.[0],_=(typeof p=="string"?[p]:p)??[];_=i.resolveGroupName(_);let h=qC(n,i.options.preserveSchemaIds),y=e.title,b=e.description,v=KL(e),O=[];e.example!=null&&O.push({name:void 0,value:e.example,description:void 0});let A=Di(e,JQ.EXAMPLES);A!=null&&Object.keys(A).length>0&&O.push(...Object.entries(A).map(([j,M])=>({name:M?.summary??j,value:M.value,description:M.description})));let g=TJi(e);g!=null&&Object.keys(g).length>0&&O.push(...g.map(j=>({name:void 0,value:j,description:void 0})));let m=zy_({schema:e,description:b,title:y,nameOverride:l,generatedName:h,availability:v});if(m!=null){let j=m;return r&&(j=ri.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),t&&(j=ri.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),j}try{if(Array.isArray(e.type)){let E=e.type.indexOf("null"),D=E!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&D)e.type.splice(E,1),e.type=e.type[0],e.nullable=!0;else if(D&&(e.type.splice(E,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let B=new Set([...e.oneOf,...e.type]);e.oneOf=[...B]}}if(r=r||e.nullable===!0,"const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(e.enum=e.enum.filter(D=>D!==null),!k3o(e.enum))return q1({nameOverride:l,generatedName:h,title:y,primitive:Ln.string({default:hUn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:gGt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v});let E=Ry_(e);return i.options.coerceEnumsToLiterals&&e.enum.length===1&&e.enum[0]!=null&&E==null?xy_({nameOverride:l,generatedName:h,title:y,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:b,availability:v,namespace:c,groupName:_}):KCi({nameOverride:l,generatedName:h,title:y,fernEnum:E,enumVarNames:Di(e,[JQ.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:_,context:i,source:o,inline:void 0})}if(k3o(e.type)&&e.type.length>1){let E=e.type.includes("null"),D=e.type.filter(B=>B!=="null").map(B=>({type:B,nullable:E}));return $Ci({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:D,namespace:c,groupName:_,encoding:a,source:o})}if(e.type==="boolean"){let E=Di(e,Gi.BOOLEAN_LITERAL);return E!=null?ky_({nameOverride:l,generatedName:h,title:y,literal:Fj.boolean(E),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):q1({nameOverride:l,generatedName:h,title:y,primitive:Ln.boolean({default:UrM(e.default),example:Xy_({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_})}if(e.type==="number")return Dsc({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:RJi(e.exclusiveMinimum),exclusiveMaximum:RJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Y3o({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="integer")return Wy_({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:RJi(e.exclusiveMinimum),exclusiveMaximum:RJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Y3o({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="float")return Dsc({nameOverride:l,generatedName:h,title:y,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:RJi(e.exclusiveMinimum),exclusiveMaximum:RJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Y3o({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="string"){if(e.format==="date-time")return q1({nameOverride:l,generatedName:h,title:y,primitive:Ln.datetime({example:gGt({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_});if(e.format==="date"&&i.options.typeDatesAsStrings===!1)return q1({nameOverride:l,generatedName:h,title:y,primitive:Ln.date({example:gGt({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_});if(e.format==="json-string"){let D=ri.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:void 0});return r&&(D=ri.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),t&&(D=ri.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),D}let E=ib_(e,"const");return E!=null?ky_({nameOverride:l,generatedName:h,title:y,literal:Fj.string(E),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):q1({nameOverride:l,generatedName:h,title:y,primitive:Ln.string({default:hUn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:gGt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v})}if(e.type==="array")return Uy_({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,item:e.items,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,example:Zy_({schema:e,logger:i.logger,fallback:u}),source:o});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&X3o(e))return Fy_({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,additionalProperties:e.additionalProperties,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,example:e.example,source:o});if(e.oneOf!=null&&e.oneOf.length>0&&Di(e,Gi.IS_DISCRIMINATED)===!1)return $Ci({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf,namespace:c,groupName:_,encoding:a,source:o});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return i.options.discriminatedUnionV2?Isc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,discriminator:e.discriminator,encoding:a,source:o}):Ssc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,source:o});if(e.oneOf!=null&&e.oneOf.length>0){let E=Di(e,Gi.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return i.options.discriminatedUnionV2||E?Isc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,discriminator:e.discriminator,encoding:a,source:o}):Ssc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,source:o});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(i.options.preserveSingleSchemaOneOf)return $Ci({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf.filter(B=>jn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o});let D=Dl(e.oneOf[0],t,r,i,n,o,c,s);return OGt(D,b,c,_)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let N=e.oneOf[0],T=e.oneOf[1];if(!jn(N)&&N.type==="null"){let R=Dl(T,t,!0,i,n,o,c);return OGt(R,b,c,_)}else if(!jn(T)&&T.type==="null"){let R=Dl(N,t,!0,i,n,o,c);return OGt(R,b,c,_)}}let D=WrM({schemas:e.oneOf});if(D!=null)return KCi({nameOverride:l,generatedName:h,title:y,fernEnum:void 0,enumVarNames:void 0,enumValues:D,_default:e.default,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:_,context:i,source:o,inline:void 0});let B=eb_({schemas:e.oneOf,context:i});if(B!=null&&!i.options.discriminatedUnionV2&&!E)return Msc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},required:e.required,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,discriminant:B.discriminant,variants:B.schemas,context:i,namespace:c,groupName:_,encoding:a,source:o});let F=e.oneOf.filter(N=>!jn(N)&&N.type==="null").length>0;return $Ci({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||F,context:i,subtypes:e.oneOf.filter(N=>jn(N)||N.type!=="null"),encoding:a,namespace:c,groupName:_,source:o})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let B=Dl(e.anyOf[0],t,r,i,n,o,c,s);return OGt(B,b,c,_)}if(e.anyOf.length===2){let[B,F]=e.anyOf;if(B!=null&&F!=null){if(!jn(B)&&B.type==="null"){let N=Dl(F,t,!0,i,n,o,c);return OGt(N,b,c,_)}else if(!jn(F)&&F.type==="null"){let N=Dl(B,t,!0,i,n,o,c);return OGt(N,b,c,_)}}}let E=eb_({schemas:e.anyOf,context:i});if(E!=null&&!i.options.discriminatedUnionV2)return Msc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},required:e.required,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,discriminant:E.discriminant,variants:E.schemas,context:i,namespace:c,groupName:_,encoding:a,source:o});let D=e.anyOf.filter(B=>!jn(B)&&B.type==="null").length>0;return $Ci({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||D,context:i,subtypes:e.anyOf.filter(B=>jn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o})}if(e.allOf!=null||e.properties!=null){let E=[];for(let B of e.allOf??[])(jn(B)||Object.keys(B).length>0)&&E.push(B);if((e.properties==null||X3o(e))&&E.length===1&&E[0]!=null){let B=Dl(E[0],t,r,i,n,o,c,s);return OGt(B,b,c,_)}let D=E.filter(B=>{let F=Z3o(B);return F||i.logger.debug(`Skipping non-object allOf element: ${JSON.stringify(B)}`),F});if((e.properties==null||X3o(e))&&D.length===1&&D[0]!=null){let B=Dl(D[0],t,r,i,n,o,c,s);return OGt(B,b,c,_)}return Ky_({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},description:b,required:e.required,wrapAsOptional:t,wrapAsNullable:r,allOf:D,context:i,propertiesToExclude:f,namespace:c,groupName:_,fullExamples:O,additionalProperties:e.additionalProperties,availability:v,encoding:a,source:o})}if(e.type==="object"&&LrM(e)&&VrM(e)&&X3o(e))return Esc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,keySchema:{nameOverride:void 0,generatedName:`${h}Key`,title:void 0,description:void 0,availability:void 0,schema:Ln.string({default:hUn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:gGt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_},valueSchema:ri.unknown({nameOverride:void 0,generatedName:`${h}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:c,groupName:_}),namespace:c,groupName:_,encoding:a,example:e.example});e.type!=null&&i.logger.warn(`Failed to parse an OpenAPI schema at the following location: ${n.join("->")}. Coercing to unknown.`);let j=e.example??e.default,M=ri.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:j});return r&&(M=ri.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:M})),t&&(M=ri.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:M})),M}catch(j){return i.logger.debug(`Error converting schema: ${j.message}
1416
+ `)),{ok:!0,value:t}):i}}function CUo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var TQn=class e extends Error{errors;constructor(t){super(t.map(CUo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var RQn=class e extends Error{errors;constructor(t){super(t.map(CUo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Ym(e){return{optional:()=>Zuc(e),transform:t=>kuc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new RQn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new TQn(i.errors)}}}function Zuc(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:()=>oh.OPTIONAL};return{...t,...Ym(t)}}function kuc(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,...Ym(r)}}function dh_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:MA(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:MA(t,"bigint")}]},getType:()=>oh.BIGINT};return{...Oz(e),...Ym(e)}}var itM=/^([+-]?\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 ph_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:MA(t,"string")}]}:itM.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:MA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:MA(t,"Date object")}]},getType:()=>oh.DATE};return{...Oz(e),...Ym(e)}}function GL(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...Oz(r),...Ym(r)}}}function qUo(e){let t=new Set(e);return GL(oh.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:MA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:MA(i,"enum")}]}:{ok:!0,value:i})()}function _h_(e){let t=esc(e);return{...t,...Ym(t)}}function esc(e){return{parse:(t,r)=>zQn(e).parse(t,r),json:(t,r)=>zQn(e).json(t,r),getType:()=>zQn(e).getType()}}function zQn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function XPa(e){return Object.entries(e)}function ZPa(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function zCi(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 kPa(e){return Object.keys(e)}function hh_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function bFt(e){return{withParsedProperties:t=>tsc(e,t)}}function tsc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[f,s])=>({...c,[f]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(i,n)=>{if(!zCi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:MA(i,"object")}]};let a=new Set(Object.keys(t)),o=ZPa(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...Ym(r),...bFt(r)}}function yh_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function NCi(e){return e.isProperty}function TUo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>NCi(i)?i.rawKey:r),_getParsedProperties:()=>kPa(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of XPa(e)){let f=NCi(c)?c.rawKey:o,s=NCi(c)?c.valueSchema:c,u={rawKey:f,parsedKey:o,valueSchema:s};n[f]=u,gh_(s)&&a.push(f)}return bh_({value:r,requiredKeys:a,getProperty:o=>{let c=n[o];if(c!=null)return{transformedKey:c.parsedKey,transform:f=>c.valueSchema.parse(f,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,o]of XPa(e)){let c=NCi(o)?o.valueSchema:o;gh_(c)&&n.push(a)}return bh_({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return NCi(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>oh.OBJECT};return{...Oz(t),...Ym(t),...bFt(t),...DJi(t)}}function bh_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!zCi(e))return{ok:!1,errors:[{path:a,message:MA(e,"object")}]};let o=new Set(t),c=[],f={};for(let[s,u]of Object.entries(e)){let l=r(s);if(l!=null){o.delete(s);let p=l.transform(u);p.ok?f[l.transformedKey]=p.value:(f[s]=u,c.push(...p.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":f[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:f}:{ok:!1,errors:c}}function DJi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>vh_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>vh_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>oh.OBJECT};return{...r,...Ym(r),...bFt(r),...DJi(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:()=>oh.OBJECT};return{...t,...Ym(t),...bFt(t),...DJi(t)}}}}function vh_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=hh_(kPa(t),s=>n.has(s)),c=r(ZPa(t,o)),f=i(ZPa(t,a));return c.ok&&f.ok?{ok:!0,value:{...c.value,...f.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...f.ok?[]:f.errors]}}function gh_(e){return!ntM(e)}function ntM(e){switch(e.getType()){case oh.ANY:case oh.UNKNOWN:case oh.OPTIONAL:return!0;default:return!1}}function Oh_(e){return TUo(e)}function Ah_(e){let t={...esc(e),_getRawProperties:()=>zQn(e)._getRawProperties(),_getParsedProperties:()=>zQn(e)._getParsedProperties()};return{...t,...Ym(t),...bFt(t),...DJi(t)}}function RUo(e){let t={parse:(r,i)=>mh_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>mh_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>oh.LIST};return{...Oz(t),...Ym(t)}}function mh_(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:MA(e,"list"),path:[]}]}}function Ph_(e){return GL(oh.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:MA(r,`"${e}"`)}]})()}function jh_(e){return GL(oh.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:MA(r,`${e.toString()}`)}]})()}var wh_=GL(oh.ANY,e=>({ok:!0,value:e}));var Eh_=GL(oh.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:MA(e,"boolean")}]});var Sh_=GL(oh.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:MA(e,"number")}]});var Mh_=GL(oh.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:MA(e,"string")}]});var Dh_=GL(oh.UNKNOWN,e=>({ok:!0,value:e}));function Ih_(e,t){let r={parse:(i,n)=>Bh_({value:i,isKeyNumeric:e.getType()===oh.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>Bh_({value:i,isKeyNumeric:e.getType()===oh.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>oh.RECORD};return{...Oz(r),...Ym(r)}}function Bh_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return zCi(e)?XPa(e).reduce((a,[o,c])=>{if(c==null)return a;let f=a,s=o;if(t){let _=o.length>0?Number(o):NaN;isNaN(_)||(s=_)}let u=r(s),l=i(c,s);if(f.ok&&u.ok&&l.ok)return{ok:!0,value:{...f.value,[u.value]:l.value}};let p=[];return f.ok||p.push(...f.errors),u.ok||p.push(...u.errors),l.ok||p.push(...l.errors),{ok:!1,errors:p}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:MA(e,"object")}]}}function Ch_(e){let t=RUo(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:MA(i,"Set")}]},getType:()=>oh.SET};return{...Oz(r),...Ym(r)}}function Th_(e){let t={parse:(r,i)=>qh_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>qh_((n,a)=>n.json(r,a),e,i),getType:()=>oh.UNDISCRIMINATED_UNION};return{...Oz(t),...Ym(t)}}function qh_(e,t,r){let i=[];for(let[n,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function Rh_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Nh_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=qUo(kPa(t)),a={parse:(o,c)=>zh_({value:o,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:f=>n.parse(f,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.parse(f,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>zh_({value:o,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:f=>n.json(f,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.json(f,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>oh.UNION};return{...Oz(a),...Ym(a),...bFt(a)}}function zh_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!zCi(e))return{ok:!1,errors:[{path:c,message:MA(e,"object")}]};let{[t]:f,...s}=e;if(f==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=i(f);if(!u.ok)return{ok:!1,errors:u.errors};let l=n(u.value);if(l==null)return a?{ok:!0,value:{[r]:u.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let p=o(s,l);return p.ok?{ok:!0,value:{[r]:f,...p.value}}:p}var Gd=L.objectWithoutOptionalProperties({title:L.string().optional()});var zUo=L.objectWithoutOptionalProperties({file:L.string()});var NUo=L.objectWithoutOptionalProperties({file:L.string()});var FUo=L.union("type",{openapi:zUo,protobuf:NUo}).transform({transform:e=>{switch(e.type){case"openapi":return xL.openapi(e);case"protobuf":return xL.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var tu=L.objectWithoutOptionalProperties({source:FUo.optional()});var QUo=L.objectWithoutOptionalProperties({typeName:L.string()});var UUo=L.union("type",{protobuf:QUo}).transform({transform:e=>{switch(e.type){case"protobuf":return qQn.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var iK=L.objectWithoutOptionalProperties({encoding:UUo.optional()});var Ti=L.objectWithoutOptionalProperties({description:L.string().optional()});var LUo=L.enum_(["GenerallyAvailable","Beta","Deprecated"]);var gu=L.objectWithoutOptionalProperties({availability:LUo.optional()});var _Gt=L.number();var K0e=L.objectWithoutOptionalProperties({statusCode:_Gt.optional()});var Gl=L.objectWithoutOptionalProperties({nameOverride:L.string().optional(),generatedName:L.string()});var pO=L.objectWithoutOptionalProperties({inline:L.boolean().optional()});var vx=L.string();var gx=L.string();var VUo=L.objectWithoutOptionalProperties({id:gx}).extend(Ti);var FCi=L.string();var WUo=L.objectWithoutOptionalProperties({usernameVariableName:L.string().optional(),usernameEnvVar:L.string().optional(),passwordVariableName:L.string().optional(),passwordEnvVar:L.string().optional()});var xUo=L.objectWithoutOptionalProperties({tokenVariableName:L.string().optional(),tokenEnvVar:L.string().optional()});var GUo=L.objectWithoutOptionalProperties({headerName:L.string(),prefix:L.string().optional(),headerVariableName:L.string().optional(),headerEnvVar:L.string().optional()});var HUo=L.objectWithoutOptionalProperties({queryParameterName:L.string()});var KUo=L.objectWithoutOptionalProperties({snake:L.string().optional(),camel:L.string().optional(),screamingSnake:L.string().optional(),pascal:L.string().optional()});var QCi=L.objectWithoutOptionalProperties({nameOverride:L.string().optional(),generatedName:L.string(),value:L.string(),casing:KUo.optional()}).extend(Ti).extend(gu);var JUo=L.objectWithoutOptionalProperties({type:L.stringLiteral("namespace"),name:L.string()});var $Uo=L.undiscriminatedUnion([L.string(),JUo]);var UCi=L.list($Uo);var Hd=L.objectWithoutOptionalProperties({groupName:UCi.optional()});var Ml=L.objectWithoutOptionalProperties({namespace:L.string().optional()});var NQn=L.objectWithoutOptionalProperties({default:QCi.optional(),values:L.list(QCi)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var YUo=L.objectWithoutOptionalProperties({scopesEnum:NQn.optional()});var XUo=L.union("type",{basic:WUo,bearer:xUo,header:GUo,query:HUo,oauth:YUo}).transform({transform:e=>{switch(e.type){case"basic":return yz.basic(e);case"bearer":return yz.bearer(e);case"header":return yz.header(e);case"query":return yz.query(e);case"oauth":return yz.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var eja=L.objectWithoutOptionalProperties({name:L.string().optional(),url:L.string(),audiences:L.list(L.string()).optional()}).extend(Ti);var ZUo=L.string();var hGt=L.objectWithoutOptionalProperties({sdkMethodName:L.string().optional()});var isc={};Kt(isc,{FullExample:()=>Xm,FullObjectExample:()=>t4o,FullOneOfExample:()=>i4o,KeyValuePair:()=>r4o,LiteralExample:()=>kUo,NullExample:()=>e4o,PrimitiveExample:()=>QQn,PropertyKey:()=>FQn});var FQn=L.string();var QQn=L.union("type",{int:L.object({value:L.number()}),int64:L.object({value:L.number()}),uint:L.object({value:L.number()}),uint64:L.object({value:L.number()}),float:L.object({value:L.number()}),double:L.object({value:L.number()}),string:L.object({value:L.string()}),datetime:L.object({value:L.string()}),date:L.object({value:L.string()}),base64:L.object({value:L.string()}),boolean:L.object({value:L.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return Ha.int(e.value);case"int64":return Ha.int64(e.value);case"uint":return Ha.uint(e.value);case"uint64":return Ha.uint64(e.value);case"float":return Ha.float(e.value);case"double":return Ha.double(e.value);case"string":return Ha.string(e.value);case"datetime":return Ha.datetime(e.value);case"date":return Ha.date(e.value);case"base64":return Ha.base64(e.value);case"boolean":return Ha.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var kUo=L.union("type",{boolean:L.object({value:L.boolean()}),string:L.object({value:L.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return TCi.boolean(e.value);case"string":return TCi.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var e4o=L.objectWithoutOptionalProperties({});var Xm=L.union("type",{primitive:L.object({value:QQn}),object:L.lazyObject(()=>t4o),array:L.object({value:L.list(L.lazy(()=>Xm))}),map:L.object({value:L.list(L.lazyObject(()=>r4o))}),enum:L.object({value:L.string()}),literal:L.object({value:kUo}),oneOf:L.object({value:L.lazy(()=>i4o)}),null:e4o,unknown:L.object({value:L.lazy(()=>Xm)})}).transform({transform:e=>{switch(e.type){case"primitive":return Sl.primitive(e.value);case"object":return Sl.object(e);case"array":return Sl.array(e.value);case"map":return Sl.map(e.value);case"enum":return Sl.enum(e.value);case"literal":return Sl.literal(e.value);case"oneOf":return Sl.oneOf(e.value);case"null":return Sl.null(e);case"unknown":return Sl.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var t4o=L.objectWithoutOptionalProperties({properties:L.record(FQn,L.lazy(()=>Xm))});var r4o=L.objectWithoutOptionalProperties({key:QQn,value:L.lazy(()=>Xm)});var i4o=L.union("type",{discriminated:L.object({value:L.record(FQn,L.lazy(()=>Xm))}),undiscriminated:L.object({value:L.lazy(()=>Xm)})}).transform({transform:e=>{switch(e.type){case"discriminated":return RCi.discriminated(e.value);case"undiscriminated":return RCi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var nsc={};Kt(nsc,{AllOfPropertyConflict:()=>nUn,ArraySchema:()=>$4o,Availability:()=>LUo,BooleanSchema:()=>V4o,BytesResponse:()=>JQn,CasingOverrides:()=>KUo,CommonProperty:()=>i3o,CursorPagination:()=>w4o,CustomCodeSample:()=>P4o,CustomCodeSampleLanguage:()=>O4o,CustomCodeSampleSdk:()=>m4o,CustomPagination:()=>S4o,DiscriminatedOneOfSchema:()=>t3o,DoubleSchema:()=>U4o,Endpoint:()=>M4o,EndpointExample:()=>ZQn,EndpointResponseExample:()=>g4o,EndpointSdkName:()=>yGt,EndpointSecurity:()=>UQn,EnumSchema:()=>NQn,EnumValue:()=>QCi,ErrorExample:()=>_4o,FernExample:()=>y4o,FileResponse:()=>HQn,FileSchema:()=>o4o,FormUrlEncodedRequest:()=>f4o,FullEndpointExample:()=>j4o,GlobalHeader:()=>G4o,GlobalSecurity:()=>x4o,Header:()=>LCi,HeaderExample:()=>XQn,HttpEndpointServer:()=>$Qn,HttpError:()=>h4o,HttpMethod:()=>LQn,IdempotencyHeader:()=>H4o,IntSchema:()=>F4o,JsonRequest:()=>l4o,JsonResponse:()=>KQn,LiteralSchema:()=>iUn,LiteralSchemaValue:()=>K4o,LongSchema:()=>Q4o,MapSchema:()=>Y4o,MultipartRequest:()=>GQn,MultipartRequestProperty:()=>c4o,MultipartRequestPropertyEncoding:()=>s4o,MultipartSchema:()=>u4o,NullableSchema:()=>Z4o,ObjectProperty:()=>e3o,ObjectPropertyConflictInfo:()=>aUn,ObjectSchema:()=>J4o,OctetStreamRequest:()=>xQn,OffsetPagination:()=>E4o,OneOfSchema:()=>k4o,OpenApiIntermediateRepresentation:()=>Fh_,OptionalSchema:()=>X4o,Pagination:()=>kQn,PathParameter:()=>VQn,PathParameterExample:()=>b4o,PrimitiveSchema:()=>WCi,PrimitiveSchemaValue:()=>W4o,QueryParameter:()=>WQn,QueryParameterExample:()=>YQn,ReferencedSchema:()=>bGt,Request:()=>d4o,Response:()=>p4o,RetriesConfiguration:()=>eUn,Schema:()=>nd,Schemas:()=>N4o,SdkGroupInfo:()=>n4o,StreamingResponseExample:()=>v4o,StringSchema:()=>L4o,SupportedSdkLanguage:()=>A4o,Tags:()=>a4o,TextResponse:()=>VCi,UnDiscriminatedOneOfSchema:()=>r3o,Webhook:()=>D4o,WebhookExampleCall:()=>rUn,WebhookHttpMethod:()=>tUn,WebsocketChannel:()=>z4o,WebsocketHandshake:()=>B4o,WebsocketMessageExample:()=>T4o,WebsocketMessageOrigin:()=>I4o,WebsocketMessageSchema:()=>C4o,WebsocketServer:()=>q4o,WebsocketSessionExample:()=>R4o});var n4o=L.objectWithoutOptionalProperties({summary:L.string().optional(),description:L.string().optional()});var a4o=L.objectWithoutOptionalProperties({tagsById:L.record(gx,VUo),orderedTagIds:L.list(gx).optional()});var UQn=L.list(L.record(FCi,L.list(L.string())));var LQn=L.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var VQn=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>nd),variableReference:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var WQn=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>nd),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var LCi=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>nd),env:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var yGt=L.objectWithoutOptionalProperties({groupName:UCi,methodName:L.string()});var xQn=L.objectWithoutOptionalProperties({contentType:L.string().optional()}).extend(Ti).extend(tu);var o4o=L.objectWithoutOptionalProperties({isOptional:L.boolean(),isArray:L.boolean()}).extend(Ti);var u4o=L.union("type",{file:o4o,json:L.object({value:L.lazy(()=>nd)})}).transform({transform:e=>{switch(e.type){case"file":return dGt.file(e);case"json":return dGt.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var s4o=L.enum_(["json","form"]);var c4o=L.objectWithoutOptionalProperties({key:L.string(),schema:u4o,contentType:L.string().optional(),exploded:L.boolean().optional(),encoding:s4o.optional()}).extend(Ti);var GQn=L.objectWithoutOptionalProperties({name:L.string().optional(),properties:L.list(c4o)}).extend(Ti).extend(tu);var l4o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd),contentType:L.string().optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu);var f4o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd),contentType:L.string().optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu);var d4o=L.union("type",{octetStream:xQn,multipart:GQn,json:l4o,formUrlEncoded:f4o}).transform({transform:e=>{switch(e.type){case"octetStream":return yFt.octetStream(e);case"multipart":return yFt.multipart(e);case"json":return yFt.json(e);case"formUrlEncoded":return yFt.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var HQn=L.objectWithoutOptionalProperties({}).extend(Ti).extend(tu).extend(K0e);var KQn=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd),responseProperty:L.string().optional()}).extend(Ti).extend(tu).extend(K0e);var VCi=L.objectWithoutOptionalProperties({}).extend(Ti).extend(tu).extend(K0e);var JQn=L.objectWithoutOptionalProperties({}).extend(Ti).extend(tu).extend(K0e);var p4o=L.union("type",{file:HQn,json:KQn,text:VCi,bytes:JQn,streamingSse:KQn,streamingText:VCi,streamingJson:KQn}).transform({transform:e=>{switch(e.type){case"file":return KQ.file(e);case"json":return KQ.json(e);case"text":return KQ.text(e);case"bytes":return KQ.bytes(e);case"streamingSse":return KQ.streamingSse(e);case"streamingText":return KQ.streamingText(e);case"streamingJson":return KQ.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var _4o=L.objectWithoutOptionalProperties({name:L.string().optional(),description:L.string().optional(),example:L.lazy(()=>Xm)});var h4o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd).optional(),examples:L.list(_4o).optional()}).extend(Ti).extend(Gl).extend(tu);var $Qn=L.objectWithoutOptionalProperties({name:L.string().optional(),url:L.string().optional(),audiences:L.list(L.string()).optional()});var y4o=L.unknown();var b4o=L.objectWithoutOptionalProperties({name:L.string(),parameterNameOverride:L.string().optional(),value:L.lazy(()=>Xm)});var YQn=L.objectWithoutOptionalProperties({name:L.string(),value:L.lazy(()=>Xm)});var XQn=L.objectWithoutOptionalProperties({name:L.string(),value:L.lazy(()=>Xm)});var v4o=L.objectWithoutOptionalProperties({sse:L.boolean(),events:L.list(L.lazy(()=>Xm))});var g4o=L.union("type",{withStreaming:v4o,withoutStreaming:L.object({value:L.lazy(()=>Xm)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return H0e.withStreaming(e);case"withoutStreaming":return H0e.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var O4o=L.objectWithoutOptionalProperties({name:L.string().optional(),language:L.string(),code:L.string(),install:L.string().optional()}).extend(Ti);var A4o=L.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var m4o=L.objectWithoutOptionalProperties({name:L.string().optional(),sdk:A4o,code:L.string()}).extend(Ti);var P4o=L.union("type",{language:O4o,sdk:m4o}).transform({transform:e=>{switch(e.type){case"language":return fGt.language(e);case"sdk":return fGt.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var j4o=L.objectWithoutOptionalProperties({name:L.string().optional(),pathParameters:L.list(b4o).optional(),queryParameters:L.list(YQn).optional(),headers:L.list(XQn).optional(),request:L.lazy(()=>Xm).optional(),response:g4o.optional(),codeSamples:L.list(P4o)}).extend(Ti);var ZQn=L.union("type",{unknown:L.object({value:y4o}),full:j4o}).transform({transform:e=>{switch(e.type){case"unknown":return G0e.unknown(e.value);case"full":return G0e.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var w4o=L.objectWithoutOptionalProperties({cursor:L.string(),nextCursor:L.property("next_cursor",L.string()),results:L.string()});var E4o=L.objectWithoutOptionalProperties({offset:L.string(),results:L.string(),step:L.string().optional(),hasNextPage:L.string().optional()});var S4o=L.objectWithoutOptionalProperties({results:L.string()});var kQn=L.union("type",{cursor:w4o,offset:E4o,custom:S4o}).transform({transform:e=>{switch(e.type){case"cursor":return Dhe.cursor(e);case"offset":return Dhe.offset(e);case"custom":return Dhe.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var eUn=L.union("type",{disabled:L.object({value:L.boolean().optional()})}).transform({transform:e=>{switch(e.type){case"disabled":return YPa.disabled(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var M4o=L.objectWithoutOptionalProperties({authed:L.boolean(),security:UQn.optional(),internal:L.boolean().optional(),idempotent:L.boolean().optional(),method:LQn,audiences:L.list(L.string()),path:L.string(),summary:L.string().optional(),operationId:L.string().optional(),tags:L.list(gx),pathParameters:L.list(VQn),queryParameters:L.list(WQn),headers:L.list(LCi),sdkName:yGt.optional(),generatedRequestName:L.string(),requestNameOverride:L.string().optional(),request:d4o.optional(),response:p4o.optional(),errors:L.record(_Gt,h4o),servers:L.list($Qn),examples:L.list(ZQn),pagination:kQn.optional(),retries:eUn.optional()}).extend(Ti).extend(gu).extend(tu).extend(Ml);var tUn=L.enum_(["GET","POST"]);var rUn=L.objectWithoutOptionalProperties({name:L.string().optional(),payload:L.lazy(()=>Xm)}).extend(Ti);var D4o=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),sdkName:yGt.optional(),method:tUn,summary:L.string().optional(),operationId:L.string(),tags:L.list(gx),headers:L.list(LCi),generatedPayloadName:L.string(),payload:L.lazy(()=>nd),examples:L.list(rUn)}).extend(Ti).extend(tu).extend(Ml);var B4o=L.objectWithoutOptionalProperties({queryParameters:L.list(WQn),headers:L.list(LCi),pathParameters:L.list(VQn)});var I4o=L.enum_(["client","server"]);var C4o=L.objectWithoutOptionalProperties({name:L.string(),origin:I4o,body:L.lazy(()=>nd)});var q4o=L.objectWithoutOptionalProperties({name:L.string(),url:L.string()});var T4o=L.objectWithoutOptionalProperties({messageType:L.string(),payload:L.lazy(()=>Xm)}).extend(Ti);var R4o=L.objectWithoutOptionalProperties({name:L.string().optional(),queryParameters:L.list(YQn).optional(),headers:L.list(XQn).optional(),messages:L.list(T4o)}).extend(Ti);var z4o=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),path:L.string(),groupName:UCi,summary:L.string().optional(),handshake:B4o,messages:L.list(C4o),servers:L.list(q4o),examples:L.list(R4o)}).extend(Ti).extend(tu);var N4o=L.objectWithoutOptionalProperties({rootSchemas:L.record(vx,L.lazy(()=>nd)),namespacedSchemas:L.record(ZUo,L.record(vx,L.lazy(()=>nd)))});var F4o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional()});var Q4o=L.objectWithoutOptionalProperties({default:L.number().optional()});var U4o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional()});var L4o=L.objectWithoutOptionalProperties({default:L.string().optional(),pattern:L.string().optional(),format:L.string().optional(),minLength:L.number().optional(),maxLength:L.number().optional()});var V4o=L.objectWithoutOptionalProperties({default:L.boolean().optional()});var W4o=L.union("type",{int:F4o,int64:Q4o,uint:L.object({}),uint64:L.object({}),float:L.object({}),double:U4o,string:L4o,datetime:L.object({}),date:L.object({}),base64:L.object({}),boolean:V4o}).transform({transform:e=>{switch(e.type){case"int":return ah.int(e);case"int64":return ah.int64(e);case"uint":return ah.uint();case"uint64":return ah.uint64();case"float":return ah.float();case"double":return ah.double(e);case"string":return ah.string(e);case"datetime":return ah.datetime();case"date":return ah.date();case"base64":return ah.base64();case"boolean":return ah.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var WCi=L.objectWithoutOptionalProperties({schema:W4o}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var x4o=L.list(L.record(FCi,L.list(L.string())));var G4o=L.objectWithoutOptionalProperties({header:L.string(),name:L.string().optional(),optional:L.boolean().optional(),env:L.string().optional(),schema:L.lazy(()=>nd).optional()});var H4o=L.objectWithoutOptionalProperties({header:L.string(),name:L.string().optional(),env:L.string().optional(),schema:L.lazy(()=>nd).optional()});var Fh_=L.objectWithoutOptionalProperties({apiVersion:L.unknown().optional(),title:L.string().optional(),description:L.string().optional(),basePath:L.string().optional(),servers:L.list(eja),websocketServers:L.list(eja),groups:L.record(L.string(),n4o),tags:a4o,hasEndpointsMarkedInternal:L.boolean(),endpoints:L.list(M4o),webhooks:L.list(D4o),channels:L.record(L.string(),z4o),groupedSchemas:N4o,variables:L.record(L.string(),WCi),nonRequestReferencedSchemas:L.set(vx),securitySchemes:L.record(FCi,XUo),security:x4o.optional(),globalHeaders:L.list(G4o).optional(),idempotencyHeaders:L.list(H4o).optional()});var bGt=L.objectWithoutOptionalProperties({schema:vx}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd);var K4o=L.union("type",{boolean:L.object({value:L.boolean()}),string:L.object({value:L.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Fj.boolean(e.value);case"string":return Fj.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var iUn=L.objectWithoutOptionalProperties({value:K4o}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var nd=L.union("type",{primitive:WCi,object:L.lazyObject(()=>J4o),array:L.lazyObject(()=>$4o),map:L.lazyObject(()=>Y4o),optional:L.lazyObject(()=>X4o),enum:NQn,reference:bGt,literal:iUn,oneOf:L.object({value:L.lazy(()=>k4o)}),nullable:L.lazyObject(()=>Z4o),unknown:Gl}).transform({transform:e=>{switch(e.type){case"primitive":return Zs.primitive(e);case"object":return Zs.object(e);case"array":return Zs.array(e);case"map":return Zs.map(e);case"optional":return Zs.optional(e);case"enum":return Zs.enum(e);case"reference":return Zs.reference(e);case"literal":return Zs.literal(e);case"oneOf":return Zs.oneOf(e.value);case"nullable":return Zs.nullable(e);case"unknown":return Zs.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var nUn=L.objectWithoutOptionalProperties({propertyKey:L.string(),allOfSchemaIds:L.list(vx),conflictingTypeSignatures:L.boolean()});var J4o=L.objectWithoutOptionalProperties({allOf:L.list(bGt),properties:L.list(L.lazyObject(()=>e3o)),allOfPropertyConflicts:L.list(nUn),additionalProperties:L.boolean()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var aUn=L.objectWithoutOptionalProperties({differentSchema:L.boolean()});var e3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>nd),readonly:L.boolean().optional(),writeonly:L.boolean().optional(),conflict:L.record(vx,aUn),generatedName:L.string(),nameOverride:L.string().optional(),audiences:L.list(L.string())}).extend(gu);var $4o=L.objectWithoutOptionalProperties({value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var Y4o=L.objectWithoutOptionalProperties({key:WCi,value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(Gd).extend(pO);var X4o=L.objectWithoutOptionalProperties({value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var Z4o=L.objectWithoutOptionalProperties({value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var k4o=L.union("type",{discriminated:L.lazyObject(()=>t3o),undiscriminated:L.lazyObject(()=>r3o)}).transform({transform:e=>{switch(e.type){case"discriminated":return pGt.discriminated(e);case"undiscriminated":return pGt.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var t3o=L.objectWithoutOptionalProperties({discriminantProperty:L.string(),commonProperties:L.list(L.lazyObject(()=>i3o)),schemas:L.record(L.string(),L.lazy(()=>nd))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var i3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>nd)});var r3o=L.objectWithoutOptionalProperties({schemas:L.list(L.lazy(()=>nd))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var asc={};Kt(asc,{ArraySchemaWithExample:()=>E3o,Base64WithExample:()=>A3o,BooleanWithExample:()=>m3o,CommonPropertyWithExample:()=>R3o,DateWithExample:()=>O3o,DatetimeWithExample:()=>g3o,DiscriminatedOneOfSchemaWithExample:()=>q3o,DoubleWithExample:()=>b3o,EndpointWithExample:()=>Uh_,EnumSchemaWithExample:()=>j3o,FloatWithExample:()=>y3o,HeaderWithExample:()=>xCi,HttpErrorWithExample:()=>f3o,Int64WithExample:()=>p3o,IntWithExample:()=>d3o,JsonRequestWithExample:()=>u3o,JsonResponseWithExample:()=>uUn,MapSchemaWithExample:()=>S3o,NamedFullExample:()=>J0e,NullableSchemaWithExample:()=>D3o,ObjectPropertyWithExample:()=>C3o,ObjectSchemaWithExample:()=>B3o,OneOfSchemaWithExample:()=>I3o,OptionalSchemaWithExample:()=>M3o,ParseFormUrlEncodedRequest:()=>s3o,ParseMultipartRequest:()=>o3o,ParseOctetStreamRequest:()=>a3o,PathParameterWithExample:()=>n3o,PrimitiveSchemaValueWithExample:()=>P3o,PrimitiveSchemaWithExample:()=>sUn,QueryParameterWithExample:()=>oUn,RequestWithExample:()=>c3o,ResponseWithExample:()=>l3o,SchemaWithExample:()=>_O,StringSchemaWithExample:()=>v3o,Uint64WithExample:()=>h3o,UintWithExample:()=>_3o,UnDiscriminatedOneOfSchemaWithExample:()=>T3o,UnknownSchemaWithExample:()=>w3o,WebhookWithExample:()=>Lh_,WebsocketHandshakeWithExample:()=>Qh_});var J0e=L.objectWithoutOptionalProperties({name:L.string().optional(),value:L.unknown()}).extend(Ti);var oUn=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>_O),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var xCi=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>_O),env:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var Qh_=L.objectWithoutOptionalProperties({queryParameters:L.list(oUn),headers:L.list(xCi)});var n3o=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>_O),variableReference:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var a3o=L.objectWithoutOptionalProperties({}).extend(xQn).extend(hGt);var o3o=L.objectWithoutOptionalProperties({}).extend(GQn).extend(hGt);var u3o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>_O),contentType:L.string().optional(),fullExamples:L.list(J0e).optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu).extend(hGt);var s3o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>_O),contentType:L.string().optional(),fullExamples:L.list(J0e).optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu).extend(hGt);var c3o=L.union("type",{octetStream:a3o,multipart:o3o,json:u3o,formUrlEncoded:s3o}).transform({transform:e=>{switch(e.type){case"octetStream":return bx.octetStream(e);case"multipart":return bx.multipart(e);case"json":return bx.json(e);case"formUrlEncoded":return bx.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var uUn=L.objectWithoutOptionalProperties({schema:L.lazy(()=>_O),responseProperty:L.string().optional(),fullExamples:L.list(J0e).optional()}).extend(Ti).extend(tu).extend(K0e);var l3o=L.union("type",{file:HQn,json:uUn,text:VCi,bytes:JQn,streamingSse:uUn,streamingText:VCi,streamingJson:uUn}).transform({transform:e=>{switch(e.type){case"file":return mP.file(e);case"json":return mP.json(e);case"text":return mP.text(e);case"bytes":return mP.bytes(e);case"streamingSse":return mP.streamingSse(e);case"streamingText":return mP.streamingText(e);case"streamingJson":return mP.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var f3o=L.objectWithoutOptionalProperties({statusCode:_Gt,schema:L.lazy(()=>_O),fullExamples:L.list(J0e).optional()}).extend(Ti).extend(Gl).extend(tu);var Uh_=L.objectWithoutOptionalProperties({authed:L.boolean(),security:UQn.optional(),internal:L.boolean().optional(),idempotent:L.boolean().optional(),method:LQn,audiences:L.list(L.string()),path:L.string(),summary:L.string().optional(),operationId:L.string().optional(),tags:L.list(gx),pathParameters:L.list(n3o),queryParameters:L.list(oUn),headers:L.list(xCi),sdkName:yGt.optional(),generatedRequestName:L.string(),requestNameOverride:L.string().optional(),request:c3o.optional(),response:l3o.optional(),errors:L.record(_Gt,f3o),servers:L.list($Qn),examples:L.list(ZQn),pagination:kQn.optional(),retries:eUn.optional()}).extend(Ti).extend(gu).extend(tu).extend(Ml);var Lh_=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),sdkName:yGt.optional(),method:tUn,summary:L.string().optional(),operationId:L.string(),tags:L.list(gx),headers:L.list(xCi),generatedPayloadName:L.string(),payload:L.lazy(()=>_O),examples:L.list(rUn)}).extend(Ti).extend(tu).extend(Ml);var d3o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional(),example:L.number().optional()});var p3o=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var _3o=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var h3o=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var y3o=L.objectWithoutOptionalProperties({example:L.number().optional()});var b3o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional(),example:L.number().optional()});var v3o=L.objectWithoutOptionalProperties({default:L.string().optional(),pattern:L.string().optional(),format:L.string().optional(),minLength:L.number().optional(),maxLength:L.number().optional(),example:L.string().optional()});var g3o=L.objectWithoutOptionalProperties({example:L.string().optional()});var O3o=L.objectWithoutOptionalProperties({example:L.string().optional()});var A3o=L.objectWithoutOptionalProperties({example:L.string().optional()});var m3o=L.objectWithoutOptionalProperties({default:L.boolean().optional(),example:L.boolean().optional()});var P3o=L.union("type",{int:d3o,int64:p3o,uint:_3o,uint64:h3o,float:y3o,double:b3o,string:v3o,datetime:g3o,date:O3o,base64:A3o,boolean:m3o}).transform({transform:e=>{switch(e.type){case"int":return Ln.int(e);case"int64":return Ln.int64(e);case"uint":return Ln.uint(e);case"uint64":return Ln.uint64(e);case"float":return Ln.float(e);case"double":return Ln.double(e);case"string":return Ln.string(e);case"datetime":return Ln.datetime(e);case"date":return Ln.date(e);case"base64":return Ln.base64(e);case"boolean":return Ln.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var sUn=L.objectWithoutOptionalProperties({schema:P3o}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var j3o=L.objectWithoutOptionalProperties({default:QCi.optional(),values:L.list(QCi),example:L.string().optional()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var w3o=L.objectWithoutOptionalProperties({example:L.unknown()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var _O=L.union("type",{primitive:sUn,object:L.lazyObject(()=>B3o),array:L.lazyObject(()=>E3o),map:L.lazyObject(()=>S3o),optional:L.lazyObject(()=>M3o),enum:j3o,reference:bGt,literal:iUn,oneOf:L.object({value:L.lazy(()=>I3o)}),nullable:L.lazyObject(()=>D3o),unknown:w3o}).transform({transform:e=>{switch(e.type){case"primitive":return ri.primitive(e);case"object":return ri.object(e);case"array":return ri.array(e);case"map":return ri.map(e);case"optional":return ri.optional(e);case"enum":return ri.enum(e);case"reference":return ri.reference(e);case"literal":return ri.literal(e);case"oneOf":return ri.oneOf(e.value);case"nullable":return ri.nullable(e);case"unknown":return ri.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var E3o=L.objectWithoutOptionalProperties({value:L.lazy(()=>_O),example:L.list(L.unknown()).optional()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var S3o=L.objectWithoutOptionalProperties({key:sUn,value:L.lazy(()=>_O),example:L.unknown().optional()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(Gd).extend(pO);var M3o=L.objectWithoutOptionalProperties({value:L.lazy(()=>_O)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var D3o=L.objectWithoutOptionalProperties({value:L.lazy(()=>_O)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var B3o=L.objectWithoutOptionalProperties({allOf:L.list(bGt),properties:L.list(L.lazyObject(()=>C3o)),allOfPropertyConflicts:L.list(nUn),fullExamples:L.list(J0e).optional(),additionalProperties:L.boolean()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var C3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>_O),readonly:L.boolean().optional(),writeonly:L.boolean().optional(),audiences:L.list(L.string()),conflict:L.record(vx,aUn),nameOverride:L.string().optional(),generatedName:L.string()}).extend(gu);var I3o=L.union("type",{discriminated:L.lazyObject(()=>q3o),undiscriminated:L.lazyObject(()=>T3o)}).transform({transform:e=>{switch(e.type){case"discriminated":return Bhe.discriminated(e);case"undiscriminated":return Bhe.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var q3o=L.objectWithoutOptionalProperties({discriminantProperty:L.string(),commonProperties:L.list(L.lazyObject(()=>R3o)),schemas:L.record(L.string(),L.lazy(()=>_O))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var R3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>_O)});var T3o=L.objectWithoutOptionalProperties({schemas:L.list(L.lazy(()=>_O))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var Vh_=/^(\d+)/,cUn=/^[a-zA-Z][a-zA-Z0-9_]*$/,Wh_={"<":"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 BJi(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 o=Math.floor(e/10),c=e%10;return c===0?i[o]:`${i[o]}_${t[c]}`}if(e<1e3){let o=Math.floor(e/100),c=e%100;return c===0?`${t[o]}_hundred`:`${t[o]}_hundred_${BJi(c)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${BJi(a)}`}function tja(e){let t=e.match(Vh_);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=BJi(n);return i.length>0?`${a}_${i}`:a}}}function lUn(e){let t=tja(e),r=Wh_[e];return t!=null?QP(No(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":QP(No(e)))}function nK(e,t){return e.type==="primitive"&&t.type==="primitive"?xh_(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?atM(e.values,t.values):e.type==="array"&&t.type==="array"?nK(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"?nK(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?otM(e.value,t.value):e.type==="object"&&t.type==="object"?utM(e,t):e.type==="map"&&t.type==="map"?xh_(e.key.schema,t.key.schema)&&nK(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function xh_(e,t){return e.type===t.type}function atM(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return t1(r,i)}function otM(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:nK(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:nK(r,n)}):!1}function utM(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:nK(a,n.schema)})}function ZE(e){switch(e){case bz.Deprecated:return"deprecated";case bz.Beta:return"pre-release";case bz.GenerallyAvailable:return"generally-available";default:return}}function stM(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 Gh_(e){let t=e?stM(e):void 0;if(t==null||t.length===0)return Kxi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(No(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(No(n.name)):r.push(n.name,Kxi);break}default:vt(n.type)}else vt(n);return r.join("/")}function GCi(e){return Tu.of(`${Gh_(e)}.yml`)}function osc({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Kxi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,Gh_(r))}function Hh_({sdkName:e,namespaceOverride:t}){return Tu.of(`${osc({sdkName:e,namespaceOverride:t})}.yml`)}function Kh_({location:e,namespaceOverride:t}){return t!=null?rD(Tu.of(t),e):e}function z3o(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:vt(e.type)}}function fUn(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:vt(e)}}function hO(e){return typeof e=="string"?e:e.type}function dUn(e){if(typeof e!="string")return e.docs}function rja(e){if(typeof e!="string")return e.default}function usc(e){if(typeof e!="string")return e.validation}function $h_(e){let t=hO(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?Jh_(e):{...e,type:Jh_(e.type)}}function Jh_(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function IJi(e){return hO(e).startsWith("optional<")?e:typeof e=="string"?Yh_(e):{...e,type:Yh_(e.type)}}function Yh_(e){return e.startsWith("optional<")?e:`optional<${e}>`}var ctM=-2147483648,ltM=2147483647,ftM=-17976931348623157e292,dtM=17976931348623157e292;function Af({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 N3o(e);case"array":return lsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return fsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return csc({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return psc();case"optional":return F3o({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return dsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return AtM({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,_sc(e);case"object":return mtM({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return PtM({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:vt(e)}}function N3o(e){switch(e.schema.type){case"string":return htM({description:e.description,schema:e.schema});case"int":return ytM({description:e.description,schema:e.schema});case"float":return btM({description:e.description,schema:e.schema});case"double":return vtM({description:e.description,schema:e.schema});case"boolean":return ptM({description:e.description,schema:e.schema});case"int64":return _tM({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:ZE(e.availability)}:{}}}function ptM({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 _tM({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 htM({description:e,schema:t}){let r="string",i=gtM(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 ytM({description:e,schema:t}){let r="integer",i=Xh_(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 btM({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function vtM({description:e,schema:t}){let r="double",i=Xh_(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 gtM(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=OtM(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function OtM(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 Xh_(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:o}=e;if(r=ssc(r,t),i=ssc(i,t),n=ssc(n,t),!(r==null&&i==null&&a==null&&o==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:o,multipleOf:n}}function ssc(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[ctM,ltM]:[ftM,dtM];return e<r||e>i?void 0:e}function csc({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=jtM(n)??e.schema,o=fUn(n),c=wtM(n),s=Q3o({context:r,fileContainingReference:t,declarationFile:GCi(o),type:a});return n.type==="nullable"&&(s=r.options.wrapReferencesToNullableInOptional?`optional<${s}>`:`nullable<${s}>`),n.type==="optional"&&!s.startsWith("optional<")&&(s=`optional<${s}>`),e.description==null&&c==null?s:{type:s,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{}}}function lsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=`list<${hO(o)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{},type:c}}function fsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=N3o(e.key),c=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),f=e.encoding!=null?z3o(e.encoding):void 0,s=`map<${hO(o)}, ${hO(c)}>`;if(e.description==null&&f==null&&e.title==null)return s;let u={type:s};return e.description!=null&&(u.docs=e.description),e.encoding!=null&&(u.encoding=f),e.availability!=null&&(u.availability=ZE(e.availability)),u}function dsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.options.respectNullableSchemas)return F3o({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let o=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hO(o),f=dUn(o),s=rja(o),u=usc(o),l=$h_(c);if(i.options.wrapReferencesToNullableInOptional&&(l=IJi(l)),e.availability==null&&e.description==null&&f==null&&s==null&&u==null&&e.title==null)return l;let p=typeof l=="string"?{type:l}:l;return(e.description!=null||f!=null)&&(p.docs=e.description??f),s!=null&&(p.default=s),u!=null&&(p.validation=u),e.availability!=null&&(p.availability=ZE(e.availability)),p}function F3o({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hO(o),f=dUn(o),s=rja(o),u=usc(o),l=IJi(c);if(e.availability==null&&e.description==null&&f==null&&s==null&&u==null&&e.title==null)return l;let p=typeof l=="string"?{type:l}:l;return(e.description!=null||f!=null)&&(p.docs=e.description??f),s!=null&&(p.default=s),u!=null&&(p.validation=u),e.availability!=null&&(p.availability=ZE(e.availability)),p}function psc(){return"unknown"}function _sc(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:vt(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{}}}function AtM({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=ija(e,n),o=e.nameOverride??e.generatedName;i.builder.addType(r,{name:o,schema:a.schema});let c=Q3o({type:o,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return c;let f={type:c};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.availability!=null&&(f.availability=ZE(e.availability)),f}function mtM({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=hsc({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:o.schema});let f=Q3o({type:c,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:ZE(e.availability)}:{}}}function PtM({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=ysc({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:o.schema});let f=Q3o({type:c,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:ZE(e.availability)}:{}}}function Q3o({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 jtM(e){return Zs._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 wtM(e){return Zs._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:()=>{}})}var C1;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(C1||(C1={}));function Hvi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:vt(e)}}function kh_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=MtM(e);break;case"array":a=EtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=StM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=DtM({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=ItM(e.nameOverride,e.generatedName);break;case"optional":a=ty_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=BtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=ija(e,n);break;case"literal":a=CtM(e,e.nameOverride,e.generatedName);break;case"object":a=hsc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=ysc({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:vt(e)}return a}function hsc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(C1.Request)&&t.options.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),o=!1,c={},f=new Set;for(let _ of e.properties){if(_.readonly&&(o=!0),a&&_.readonly)continue;if(Object.keys(_.conflict).length>0){if(Object.entries(_.conflict).every(([g,m])=>!m.differentSchema))continue;Object.entries(_.conflict).forEach(([g])=>{bsc({property:_.key,schemaId:g,context:t,namespace:i}).forEach(j=>{f.add(j)})})}let h=Af({schema:_.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),y=_.audiences,b=_.nameOverride,v=ZE(_.availability),O=ztM(_);c[_.key]=RtM({typeReference:h,audiences:y,name:b,availability:v,propertyAccess:O})}let s=new Set;for(let _ of e.allOfPropertyConflicts)_.allOfSchemaIds.forEach(h=>f.add(h)),_.conflictingTypeSignatures&&s.add(_.propertyKey);let u=[];for(let _ of e.allOf){let h=ry_({schema:_.schema,context:t,namespace:i});if(h==null||f.has(_.schema)||f.has(h))continue;let y=Af({schema:Zs.reference(_),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(hO(y))}for(let _ of f){let h=vsc(t,_,i);for(let y of h.properties)c[y.key]==null&&(s.has(y.key)&&(c[y.key]="unknown"),c[y.key]=Af({schema:y.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let y of h.allOf){if(f.has(y.schema))continue;let b=Af({schema:Zs.reference(y),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(hO(b))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([_,h])=>TtM(_)?[_,typeof h=="string"?{type:h,name:`_${_}`}:{...h,name:`_${_}`}]:[_,h]))};u.length>0&&(l.extends=u),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=ZE(e.availability)),e.source!=null&&(l.source=Hvi(e.source)),l.inline=gsc(e,n);let p=e.nameOverride??e.generatedName;return{name:o&&t.options.respectReadonlySchemas&&!a?`${p}Read`:p,schema:l}}function bsc({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return bsc({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:o}=vsc(r,t,i),c=a.some(s=>s.key===e),f=[...o.flatMap(s=>bsc({property:e,context:r,schemaId:s.schema,namespace:i}))];if(c||f.length>0)return[t,...f]}return[]}function ey_(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?vsc(e,t.schema,r):t.type==="nullable"?ey_(e,t.value,r):{properties:[],allOf:[]}}function vsc(e,t,r){let i=e.getSchema(t,r);return i==null?{properties:[],allOf:[]}:ey_(e,i,r)}function EtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:lsc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function StM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:fsc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function MtM(e){let t=N3o(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 Zh_(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function ija(e,t){let r={enum:e.values.map(a=>{let o=a.nameOverride??a.generatedName,c=a.value;if(o===c&&a.description==null&&(a.casing==null||Zh_(a.casing)))return o;let f={value:a.value};if(o!==c&&(f.name=o),a.description!=null&&(f.docs=a.description),a.casing!=null&&!Zh_(a.casing)){let s={},u=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,u=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,u=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,u=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,u=!0),u&&(f.casing=s)}return f})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=gsc(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?Hvi(e.source):void 0};for(let a of r.enum){let o=typeof a=="string"?a:a.name??a.value;i.has(o.toLowerCase())||(n.enum.push(a),i.add(o.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function DtM({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:csc({schema:e,context:t,fileContainingReference:r,namespace:i})}}function BtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.options.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:dsc({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:ty_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function ty_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:F3o({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function ItM(e,t){return{name:e??t,schema:psc()}}function CtM(e,t,r){return{name:t??r,schema:_sc(e)}}function ysc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?z3o(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=Af({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let f={};for(let[s,u]of Object.entries(e.schemas))f[s]=Af({schema:u,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?ZE(e.availability):void 0,union:f,encoding:a,source:e.source!=null?Hvi(e.source):void 0}}}let o=[];for(let c of e.schemas)o.push(Af({schema:c,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:o,encoding:a,source:e.source!=null?Hvi(e.source):void 0,inline:gsc(e,n)}}}var qtM=/^[0-9]/;function TtM(e){return qtM.test(e)}function ry_({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?ry_({context:t,schema:i.schema,namespace:r}):e}function RtM({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function gsc(e,t){return e.inline===!0||t>0?!0:void 0}function ztM(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return OD.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return OD.ObjectPropertyAccess.WriteOnly}}function iy_(e){let t=e.replace(/^x-|^X-/,"");return No(t)}function ny_(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:r,schema:n}),t||(e.builder.setAuth(r),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:r,schema:n}),t||(e.builder.setAuth(r),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??iy_(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:r,schema:n}),t||(e.builder.setAuth(r),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(Tu.of("__package__.yml"),{name:"OauthScope",schema:ija(i.scopesEnum,0).schema})}}function vGt({header:e,context:t,fileContainingReference:r,namespace:i}){let n=Af({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=hO(n),o=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:No(o);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let f={type:a};return c!==e.name&&(f.name=c),e.description!=null&&(f.docs=e.description),e.env!=null&&(f.env=e.env),e.availability!=null&&(f.availability=ZE(e.availability)),f}function U3o({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=Af({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return hO(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:hO(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=ZE(e.availability)),a}function V3o({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=Osc({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=hO(n.value),o=rja(n.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return o!=null&&(c.default=o),n.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=ZE(e.availability)),NtM(n.value)&&n.value.validation!==void 0&&(c.validation=n.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function Osc({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:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:Tu.of(ob),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,f]of Object.entries(n.value.schemas))f.type==="primitive"&&f.schema.type==="string"&&(o=!0),f.type==="literal"&&f.value.type==="string"&&(cUn.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:lUn(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[c,f]=n.value.schemas;if(c!=null&&f!=null&&L3o({array:c,primitive:f}))return{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&f!=null&&L3o({array:c,primitive:f}))return{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[c,f]of Object.entries(n.value.schemas))return Osc({schema:f,context:t,fileContainingReference:r,namespace:i})}else if(t.options.objectQueryParameters)return{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let n=e.type==="optional"?Zs.optional:Zs.nullable;if(e.value.type==="reference"){let a=t.getSchema(e.value.schema,i);if(a==null)return;if(a.type==="array")return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a.value,description:e.description??a.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.options.objectQueryParameters)return{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,f]of Object.entries(e.value.value.schemas))f.type==="primitive"&&f.schema.type==="string"&&(o=!0),f.type==="literal"&&f.value.type==="string"&&(cUn.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:lUn(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[c,f]=e.value.value.schemas;if(c!=null&&f!=null&&L3o({array:c,primitive:f}))return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&f!=null&&L3o({array:f,primitive:c}))return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}if(t.options.objectQueryParameters)return{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1};for(let[c,f]of Object.entries(e.value.value.schemas))return Osc({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.options.objectQueryParameters?{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:Af({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:Af({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function L3o({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function NtM(e){return typeof e=="object"&&e!==null&&"type"in e}function ay_({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"]=FtM(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=QtM({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=HCi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function FtM(e){let t={};return e.forEach(r=>{let i=HCi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function QtM({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=HCi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function HCi(e){switch(e.type){case"primitive":return oy_(e.value);case"object":return uy_(e.properties);case"array":return UtM(e.value);case"map":return LtM(e.value);case"oneOf":return VtM(e.value);case"enum":return e.value;case"literal":return WtM(e.value);case"unknown":return HCi(e.value);case"null":return null;default:vt(e)}}function oy_(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:vt(e)}}function uy_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,HCi(r)]))}function UtM(e){return e.map(t=>HCi(t))}function LtM(e){return Object.fromEntries(e.map(t=>[oy_(t.key),HCi(t.value)]))}function VtM(e){return e.type==="discriminated"?uy_(e.value):HCi(e.value)}function WtM(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:vt(e)}}function nja(e){try{let r=new URL(e).pathname.split("/").filter(i=>i.length>0);if(r.length>0)return r[r.length-1]}catch{}}function W3o(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function x3o(e,t,r=!1){let i=nja(t);return r&&i!=null?i:e!=null&&i!=null?`${e}_${i}`:i??e??"websocket"}function Kvi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function G3o(e,t){return t??(e?.groupName!=null?Kvi(e.groupName):void 0)}function sy_({channel:e,context:t,declarationFile:r}){let i=e.servers[0],n=i!=null?t.options.groupEnvironmentsByHost?t.getUrlId(i.url)??x3o(i.name,i.url,!0):i.name:void 0;t.logger.debug(`[buildChannel] Channel path="${e.path}", server name="${i?.name}", server url="${i?.url}", resolved urlId="${n}" (from collision map: ${t.getUrlId(i?.url??"")!=null})`);let a={path:e.path,url:n,auth:!1};e.audiences!=null&&e.audiences.length>0&&(a.audiences=e.audiences),e.summary!=null&&(a["display-name"]=e.summary),e.description!=null&&(a.docs=e.description);let o=Kvi(e.groupName),c={};if(e.handshake.pathParameters.length>0)for(let u of e.handshake.pathParameters)c[u.name]=U3o({pathParameter:u,context:t,fileContainingReference:r,namespace:o});Object.keys(c).length>0&&(a["path-parameters"]=c);let f={};if(e.handshake.queryParameters.length>0)for(let u of e.handshake.queryParameters){let l=V3o({queryParameter:u,context:t,fileContainingReference:r,namespace:o});l!=null&&(f[u.name]=l)}Object.keys(f).length>0&&(a["query-parameters"]=f);let s={};if(e.handshake.headers.length>0)for(let u of e.handshake.headers){let l=vGt({header:u,context:t,fileContainingReference:r,namespace:o});s[u.name]=l}Object.keys(s).length>0&&(a.headers=s),t.builder.addChannel(r,{channel:a});for(let u of e.messages)t.builder.addChannelMessage(r,{messageId:u.name,message:{origin:u.origin,body:Af({schema:u.body,context:t,fileContainingReference:r,namespace:o,declarationDepth:0})}});for(let u of e.examples){let l=ay_({context:t,websocketExample:u});t.builder.addChannelExample(r,{example:l})}}function Asc(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var $0e="Base",fy_="Default";function cy_(e){try{return new URL(e).hostname}catch{return}}function ly_(e){return e??fy_}function xtM(e,t){let r=new Map;for(let i of e){if(Asc(i)||!("url"in i)||!i.url)continue;let n=cy_(i.url)??i.url;r.has(n)||r.set(n,{environmentName:ly_(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.httpServers.push({name:i.name,url:i.url,audiences:i.audiences})}for(let i of t){let n=cy_(i.url)??i.url;r.has(n)||r.set(n,{environmentName:ly_(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.websocketServers.push(i)}return r}function CJi(e){return Object.entries(e).reduce((t,[r,i])=>(ghe(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function dy_(e){if(e.environmentOverrides!=null){for(let[v,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:v,schema:O});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[],i=e.ir.servers.some(v=>Asc(v)),n=e.ir.servers;for(let v of n)if(Asc(v)){let O={urls:{}};for(let[A,g]of Object.entries(v.urls))O.urls[A]=g.url;v.name&&(t[v.name]=O)}else if("url"in v&&v.url){let O=v.audiences?{url:v.url,audiences:v.audiences}:v.url;if(v.name==null){r.push(O);continue}t[v.name]=O}let a={},o={},c=[];for(let v of e.ir.endpoints)for(let O of v.servers){if(O.url==null&&O.name!=null){a[O.name]||(a[O.name]=[]);continue}if(O.url==null)continue;let A=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){c.push(A);continue}a[O.name]||(a[O.name]=[]),a[O.name]?.push({url:O.url,audiences:O.audiences}),o[O.name]=A}let f={},s=[];for(let v of e.ir.websocketServers){e.logger.debug(`[buildEnvironments] Processing WebSocket server: name="${v.name}", url="${v.url}"`);let O=v.audiences?{url:v.url,audiences:v.audiences}:v.url;if(v.name==null){s.push(O);continue}f[v.name]=O}let u=Object.keys(t).length,l=u>0,p=Object.keys(o).length>0,_=Object.keys(a).some(v=>a[v]?.length===0),h=Object.keys(f).length>0;if(e.options.groupEnvironmentsByHost&&h&&(l||e.ir.servers.length>0)){let v=Object.entries(f).map(([A,g])=>({name:A,url:typeof g=="string"?g:g.url,audiences:typeof g=="string"?void 0:g.audiences})),O=xtM(n,v);if(O.size>0){let A=!0;for(let[g,m]of O.entries()){let j={},M=[...m.httpServers.map(D=>({...D,isHttp:!0})),...m.websocketServers.map(D=>({...D,isHttp:!1}))],E=new Map;for(let D of M){let B=nja(D.url),F=W3o(D.url);B&&F&&(E.has(B)||E.set(B,new Set),E.get(B)?.add(F))}if(m.httpServers.length>0){let D=m.httpServers[0];D!=null&&(j[$0e]=D.url,e.setUrlId(D.url,$0e));for(let B=1;B<m.httpServers.length;B++){let F=m.httpServers[B];if(F!=null){let N=nja(F.url),T=W3o(F.url),R=N?E.get(N):void 0,Q=R&&R.size>1,H=Q&&T!=="https"?`${N}_${T}`:N||`Http${B+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${F.url}", pathSegment="${N}", protocol="${T}", hasCollision=${Q}, urlId="${H}"`),j[H]=F.url,e.setUrlId(F.url,H)}}}for(let D of m.websocketServers){let B=nja(D.url),F=W3o(D.url),N=B?E.get(B):void 0,T=N&&N.size>1,R=T?`${B}_${F}`:x3o(D.name,D.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${D.name}", url="${D.url}", pathSegment="${B}", protocol="${F}", hasCollision=${T}, urlId="${R}"`),j[R]=D.url,e.setUrlId(D.url,R)}if(Object.keys(j).length>1)e.builder.addEnvironment({name:m.environmentName,schema:{urls:j}});else if(Object.keys(j).length===1){let D=Object.values(j)[0];D!=null&&e.builder.addEnvironment({name:m.environmentName,schema:D})}A&&(e.builder.setDefaultEnvironment(m.environmentName),Object.keys(j).length>1&&e.builder.setDefaultUrl($0e),A=!1)}return}}if(!l&&!p&&h&&e.ir.servers.length===0){for(let[v,O]of Object.entries(f))e.builder.addEnvironment({name:v,schema:O});e.builder.setDefaultEnvironment(Object.keys(f)[0]),e.builder.setDefaultUrl($0e);return}if(c.length>0&&e.logger.debug(`Skipping endpoint level servers ${c.map(v=>typeof v=="string"?v:v.url).join(", ")} because x-fern-server-name was not provided.`),!l){let v=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(v!=null){let A=O?{url:v,audiences:O}:v;t[fy_]=A}}let y=Object.values(t).map(v=>typeof v=="string"?v:ghe(v)?Object.values(v.urls)[0]:v.url),b=r.filter(v=>{let O=typeof v=="string"?v:v.url;return!y.includes(O)});if(b.length>0&&e.logger.debug(`Skipping top level servers ${b.map(v=>typeof v=="string"?v:v.url).join(", ")} because x-fern-server-name was not provided.`),i){let v=!0;for(let[O,A]of Object.entries(t))if(e.builder.addEnvironment({name:O,schema:A}),v){if(e.builder.setDefaultEnvironment(O),ghe(A)){let g=Object.keys(A.urls)[0];g&&e.builder.setDefaultUrl(g)}v=!1}return}if(!p&&!_){let v=!0;for(let[O,A]of Object.entries(t))if(v){if(h){let g=typeof A=="string"?A:ghe(A)?Object.values(A.urls)[0]:A.url;e.builder.addEnvironment({name:O,schema:{urls:{[$0e]:g??"",...CJi(f)}}})}else e.builder.addEnvironment({name:O,schema:A});e.builder.setDefaultEnvironment(O),v=!1}else if(h){let g=typeof A=="string"?A:ghe(A)?Object.values(A.urls)[0]:A.url;e.builder.addEnvironment({name:O,schema:{urls:{[$0e]:g??"",...CJi(f)}}})}else e.builder.addEnvironment({name:O,schema:A});h&&e.builder.setDefaultUrl($0e)}else if(u===1){let v=Object.keys(t)[0],O=Object.values(t)[0],A=typeof O=="string"?O:ghe(O)?Object.values(O.urls)[0]:O.url;e.builder.addEnvironment({name:v,schema:{urls:{[$0e]:A??"",...CJi(o),...CJi(f)}}}),e.builder.setDefaultEnvironment(v),e.builder.setDefaultUrl($0e)}else{let v=new Map;for(let O of e.ir.endpoints)for(let A of O.servers)if(A.url!=null&&A.name!=null){v.has(A.name)||v.set(A.name,new Map);let g=A.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",m=v.get(A.name);m&&m.set(g,A.url)}if(v.size>0){let O=!0;for(let[A,g]of Object.entries(t)){let m=typeof g=="string"?g:ghe(g)?Object.values(g.urls)[0]:g.url;if(!m)continue;let j=m.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",M={[$0e]:m};for(let[E,D]of v.entries()){let B=D.get(j)||D.get("production")||D.values().next().value;B&&(M[E]=B)}h&&Object.assign(M,CJi(f)),Object.keys(M).length>1?e.builder.addEnvironment({name:A,schema:{urls:M}}):e.builder.addEnvironment({name:A,schema:m}),O&&(e.builder.setDefaultEnvironment(A),O=!1)}v.size>0&&e.builder.setDefaultUrl($0e)}else{let O=!0;for(let[A,g]of Object.entries(t)){if(h||Object.keys(o).length>0){let m=typeof g=="string"?g:ghe(g)?Object.values(g.urls)[0]:g.url;e.builder.addEnvironment({name:A,schema:{urls:{[$0e]:m??"",...CJi(o),...CJi(f)}}})}else e.builder.addEnvironment({name:A,schema:g});O&&(e.builder.setDefaultEnvironment(A),O=!1)}}}}var msc=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},GtM=.75,HtM=new Set("authorization");function py_(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?fUn(i.schema):void 0,o=a!=null?Kvi(a):void 0,c=Tu.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?hO(Af({schema:i.schema,context:e,fileContainingReference:o?rD(Tu.of(No(o)),c):c,namespace:o,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.options.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(HtM.has(a.name.toLowerCase()))continue;let o=r[a.name];if(o==null){let c=t[a.name],f=vGt({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:Tu.of(i1),context:e,namespace:void 0});o=new msc(f),r[a.name]=o}o.increment()}let i=e.ir.endpoints.length*GtM;for(let[n,a]of Object.entries(r)){let o=t[n],c=a.count===e.ir.endpoints.length,f=a.count>=i;o==null&&(c?e.builder.addGlobalHeader({name:n,schema:a.schema}):f&&e.builder.addGlobalHeader({name:n,schema:IJi(a.schema)}))}}}function _y_(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?fUn(t.schema):void 0,i=r!=null?Kvi(r):void 0,n=vGt({header:{...t,schema:t.schema??Zs.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:ah.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:Tu.of(i1),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:IJi(n)})}}function HL(e){switch(e.type){case"primitive":return yy_(e.value);case"object":return by_(e.properties);case"array":return vy_(e.value);case"map":return JtM(e.value);case"oneOf":return $tM(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return YtM(e.value);case"unknown":return HL(e.value);case"null":return null;default:vt(e)}}function hy_(e){switch(e.type){case"withStreaming":return e.sse?{stream:KtM(e.events)}:{stream:vy_(e.events)};case"withoutStreaming":return{body:HL(e.value)};default:vt(e)}}function yy_(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:vt(e)}}function by_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,HL(r)]))}function KtM(e){return e.map(t=>({event:"",data:HL(t)}))}function vy_(e){return e.map(t=>HL(t))}function JtM(e){return Object.fromEntries(e.map(t=>[yy_(t.key),HL(t.value)]))}function $tM(e){return e.type==="discriminated"?by_(e.value):HL(e.value)}function YtM(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:vt(e)}}function gy_({endpointExample:e,context:t}){let r={};if(e.type!=="full")return e.value;e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=XtM(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=ZtM(e.queryParameters));let i=e.headers!=null&&e.headers.length>0,n=t.builder.getGlobalHeaders(),a=Object.keys(n).length>0,o=new Set(e.headers?.map(c=>c.name)??[]);if(i||a){let c=[];if(e.headers!=null)for(let f of e.headers)f.name!==t.builder.getAuthHeaderName()&&c.push(f);for(let[f,s]of Object.entries(n))if(!o.has(f))if(s!=null&&typeof s=="object"&&s.type!=null){let u=PB({type:s.type,_default:void 0,validation:void 0,visitor:{primitive:l=>l.toString(),map:l=>l.toString(),list:l=>l,optional:l=>l,nullable:l=>l,set:l=>l,named:l=>l,literal:l=>{if(l.type==="string")return l.string;if(l.type==="boolean")return l.boolean.toString()},unknown:Et}});u!=null&&c.push({name:f,value:Sl.literal(TCi.string(u))})}else c.push({name:f,value:Sl.primitive(Ha.string(f))});r.headers=ktM({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=HL(e.request)),e.response!=null&&(r.response=hy_(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(c=>c.type==="language"?{name:c.name??void 0,docs:c.description??void 0,language:c.language,code:c.code,install:c.install??void 0}:{name:c.name??void 0,docs:c.description??void 0,sdk:c.sdk,code:c.code}).filter(ps)),r}function XtM(e){let t={};return e.forEach(r=>{let i=HL(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function ZtM(e){let t={};return e.forEach(r=>{let i=HL(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function ktM({context:e,namedFullExamples:t}){let r={};return t.forEach(i=>{let n=HL(i.value);n!=null&&(r[i.name]=n)}),r}function Oy_(e){return gz._visit(e,{get:()=>OD.HttpMethodSchema.Get,post:()=>OD.HttpMethodSchema.Post,put:()=>OD.HttpMethodSchema.Put,patch:()=>OD.HttpMethodSchema.Patch,delete:()=>OD.HttpMethodSchema.Delete,head:()=>OD.HttpMethodSchema.Head,options:()=>{throw new Error("OPTIONS is unsupported")},trace:()=>{throw new Error("TRACE is unsupported")},_other:()=>{throw new Error("Unknown http method is unsupported")}})}function Ay_(e){return e==="POST"||e==="PUT"||e==="PATCH"}function my_({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,o=e.path,c=G3o(e.sdkName,e.namespace),f={};for(let b of e.pathParameters)b.parameterNameOverride&&(o=o.replace(b.name,b.parameterNameOverride)),f[b.parameterNameOverride??b.name]=U3o({pathParameter:b,context:r,fileContainingReference:t,namespace:c}),a.add(b.name);let s={};for(let b of e.queryParameters){let v=V3o({queryParameter:b,context:r,fileContainingReference:t,namespace:c});v!=null&&(s[b.name]=v,a.add(b.name))}let u;if(e.pagination!=null)switch(e.pagination.type){case"cursor":u={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":u={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":u={type:"custom",results:e.pagination.results};break;default:vt(e.pagination)}let l={path:o,method:Oy_(e.method),auth:erM({endpoint:e,context:r}),docs:e.description??void 0,pagination:u,source:e.source!=null?Hvi(e.source):void 0};!nrM({context:r,request:e.request})&&Object.keys(f).length>0&&(l["path-parameters"]=f),e.summary!=null&&(l["display-name"]=e.summary);let p={},_=r.builder.getGlobalHeaderNames(),h=r.builder.getAuthHeaderName();h!=null&&_.add(h);let y=e.headers.filter(b=>!_.has(b.name));for(let b of y){let v=vGt({header:b,context:r,fileContainingReference:t,namespace:c});p[b.name]=v,a.add(typeof v=="string"?b.name:v.name??b.name)}if(e.request!=null){r.setInState(C1.Request);let b=irM({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.options.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(p).length>0?p:void 0,usedNames:a,namespace:c});l.request=b.value,n=[...n,...b.schemaIdsToExclude??[]],r.unsetInState(C1.Request)}else{let b=r.options.inlinePathParameters&&Object.keys(f).length>0,v=Object.keys(s).length>0,O=Object.keys(p).length>0,A={};(b||v||O)&&(A.name=e.requestNameOverride??e.generatedRequestName),b&&(A["path-parameters"]=f),v&&(A["query-parameters"]=s),O&&(A.headers=p),Object.keys(A).length>0&&(l.request=A)}if(e.response!=null&&e.response._visit({json:b=>{let v=Af({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:b.description??void 0,type:hO(v)},b.statusCode!=null&&(l.response["status-code"]=b.statusCode),b.responseProperty!=null&&(l.response.property=b.responseProperty)},streamingJson:b=>{let v=Af({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:hO(v),format:"json"}},streamingSse:b=>{let v=Af({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:hO(v),format:"sse"}},file:b=>{l.response={docs:b.description??void 0,type:"file","status-code":b.statusCode}},bytes:b=>{l.response={docs:b.description??void 0,type:"bytes","status-code":b.statusCode}},streamingText:b=>{l["response-stream"]={docs:b.description??void 0,type:"text"}},text:b=>{l.response={docs:b.description??void 0,type:"text","status-code":b.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let b=r.getDefaultServerName(),v=e.servers[0];v==null?b!=null&&(l.url=b):l.url=v.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=ZE(e.availability)),Object.entries(e.errors).forEach(([b,v])=>{let O=v.generatedName,A=Tu.of(ob);r.builder.enableUniqueErrorsPerEndpoint&&(O=`${e.generatedRequestName}${v.generatedName}`,v.schema!=null&&(v.schema.type!=="reference"&&v.schema.type!=="oneOf"?v.schema.generatedName=`${e.generatedRequestName}${v.schema.generatedName}`:v.schema.type==="oneOf"&&(v.schema.value.generatedName=`${e.generatedRequestName}${v.schema.value.generatedName}`)));let g={"status-code":parseInt(b)},m=Kh_({location:Py_,namespaceOverride:c});if(v.schema!=null){let E=Af({schema:v.schema,context:r,fileContainingReference:m,declarationFile:m,namespace:c,declarationDepth:0});g.type=hO(E),g.docs=v.description}r.builder.addError(m,{name:O,schema:r.isErrorUnknownSchema(parseInt(b))?{...g,type:"unknown"}:g}),l.errors==null&&(l.errors=[]);let j=r.builder.addImport({file:t,fileToImport:m});l.errors.push(j!=null?`${j}.${O}`:O),g.type!=null&&v.examples?.forEach(E=>{let D={value:HL(E.example),name:E.name,docs:E.description};r.builder.addErrorExample(m,{name:O,example:D})})}),e.examples.length>0&&(l.examples=trM({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=rrM({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[Psc,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function erM({endpoint:e,context:t}){if(e.security==null)return t.authOverrides?.auth!=null?!0:t.ir.security==null?void 0:t.ir.security.length>0?!0:void 0;if(e.security.length!==0)return JSON.stringify(e.security)===JSON.stringify(t.ir.security)?!0:e.security}function trM({endpointExamples:e,context:t}){return e.map(r=>{try{return gy_({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function rrM({retries:e}){if(e!=null)switch(e.type){case"disabled":return{disabled:e.value??void 0};default:vt(e)}}function irM({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:o,queryParameters:c,nonRequestReferencedSchemas:f,headers:s,usedNames:u,namespace:l}){if(i.type==="json"||i.type==="formUrlEncoded"){let p=i.schema.type==="reference"?i.schema.schema:void 0,_=i.schema.type==="reference"?r.getSchema(i.schema.schema,l):i.schema;if(_?.type!=="object"||p!=null&&f.includes(p)){let O=Af({schema:i.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),A={schemaIdsToExclude:[],value:{body:O}},g=Object.keys(o??{}).length>0,m=Object.keys(c??{}).length>0,j=Object.keys(s??{}).length>0;return g&&(A.value["path-parameters"]=o),m&&(A.value["query-parameters"]=c),j&&(A.value.headers=s),(g||m||j)&&(A.value.name=n??a),i.contentType!=null&&(A.value["content-type"]=i.contentType),i.description!=null&&(A.value.docs=i.description),A}let h=Object.fromEntries(_.properties.filter(O=>O.readonly==null?!0:!(Ay_(e.method)&&O.readonly)).map(O=>{let A=Af({schema:O.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:1}),g=O.nameOverride??O.key,m=ZE(O.availability);if(!u.has(g)&&O.audiences.length<=0)return u.add(g),O.nameOverride!=null?[O.key,{type:hO(A),docs:dUn(A),name:O.nameOverride,availability:m}]:[O.key,m?{...typeof A=="string"?{type:A}:A,availability:m}:A];let j={type:hO(A),docs:dUn(A)};return u.has(g)&&(j.name=O.generatedName),O.audiences.length>0&&(j.audiences=O.audiences),m!=null&&(j.availability=m),u.add(g),[O.key,j]})),y=_.allOf.map(O=>{let A=Af({schema:Zs.reference(O),fileContainingReference:t,context:r,namespace:l,declarationDepth:0});return hO(A)}).filter(O=>O!=="unknown"),b={properties:h};y.length>0&&(b.extends=y),i.additionalProperties&&(b["extra-properties"]=!0);let v={name:n??_.nameOverride??_.generatedName,"path-parameters":o,"query-parameters":c,headers:s,body:b};return i.contentType!=null&&(v["content-type"]=i.contentType),i.description!=null&&(v.docs=i.description),{schemaIdsToExclude:p!=null?[p]:[],value:v}}else if(i.type==="octetStream"){let p={body:"bytes","content-type":i.contentType??LA.APPLICATION_OCTET_STREAM,"query-parameters":c};return c!=null&&(p.name=n??a),i.description!=null&&(p.docs=i.description),{schemaIdsToExclude:[],value:p}}else if(i.type==="multipart"){let p=Object.fromEntries(i.properties.map(_=>{if(_.schema.type==="file"){let h=_.schema.isArray?"list<file>":"file";if(h=_.schema.isOptional?`optional<${h}>`:h,_.description!=null||_.contentType!=null){let y={type:h};if(_.description!=null&&(y.docs=_.description),_.contentType!=null){let b=_.contentType.split(",")[0];y["content-type"]=b}return[_.key,y]}return[_.key,h]}else{let h=Af({schema:_.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(_.contentType||_.exploded||_.encoding){let y=typeof h=="string"?{type:h}:h;_.contentType!=null&&(y["content-type"]=_.contentType),_.encoding==="form"?y.style="form":_.encoding==="json"?y.style="json":_.exploded&&(y.style="exploded"),h=y}return[_.key,h]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":o,"query-parameters":c,headers:s,body:{properties:p},"content-type":LA.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else vt(i)}function nrM({context:e,request:t}){if(!e.options.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:vt(t)}}function arM({location:e,namespaceOverride:t}){return t!=null?{...e,file:rD(Tu.of(t),e.file)}:e}function orM(e){let t=e.namespace,r=e.tags.filter(f=>f!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:Tu.of(`${No(r)}.yml`),endpointId:e.summary!=null?No(e.summary):No(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Tu.of(ob),endpointId:No(e.summary)}:{file:Tu.of(ob),endpointId:No(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Tu.of(ob),endpointId:i};let n=aja(r),a=aja(i);if(t1(n,a))return{file:Tu.of("__package__.yml"),endpointId:r};let o=crM({operationId:i,tag:r,path:e.path,method:e.method});if(o!=null)return o;let c=[];for(let f=0;f<n.length;++f){let s=n[f];if(s!=null&&s===a[f])c.push(s);else{let u=No(r);return{file:Tu.of(`${u}.yml`),endpointId:i,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:Tu.of(No(c.join("_"))+".yml"),endpointId:No(a.slice(c.length).join("_")),tag:r}}function oja(e){let t=e.tags[0];if(e.sdkName!=null){let r=osc({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Tu.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return arM({namespaceOverride:e.namespace,location:orM(e)})}function aja(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=$Oe(t),t}var urM=new RegExp("[^a-zA-Z0-9{}]+"),srM=new RegExp("[{}]","g");function crM({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(urM).join("_").replaceAll(srM,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:Tu.of(No(t)+".yml"),endpointId:No(e.slice(0,-1*a.length)),tag:t}}function jy_(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:o,file:c,tag:f}=oja(a),s=c.split(".")[0];s!=null&&t.add(s);let u;if(a.sdkName!=null){let _=e.ir.groups;for(let h of a.sdkName.groupName){let y=typeof h=="string"?h:h.name,b=_[y];if(b==null)break;if(b.summary!=null||b.description!=null){u=_[y];break}}}let l=f==null?void 0:i.tagsById[f];e.setInState(C1.Endpoint),e.setEndpointMethod(a.method);let p=my_({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(C1.Endpoint),n=[...n,...p.schemaIdsToExclude],e.builder.addEndpoint(c,{name:o,schema:p.value,source:a.source!=null?Hvi(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":u?.summary??l?.id,docs:u?.description??l?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function wy_(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?Kvi(r.groupName):void 0,n=Af({schema:Zs.primitive(r),context:e,fileContainingReference:Tu.of(ob),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:hO(n),docs:r.description??void 0}})}}function Ey_(e){for(let t of e.ir.webhooks){let r=drM({webhook:t,context:e});if(r==null)continue;let i=G3o(t.sdkName,t.namespace),n={};for(let o of t.headers)n[o.name]=vGt({header:o,context:e,fileContainingReference:r.file,namespace:i});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:n,payload:Af({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(o=>({docs:o.description,name:o.name,payload:HL(o.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function lrM({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:rD(Tu.of(t),e.file)}:e}function frM({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:Tu.of(ob),endpointId:i};let n=aja(r),a=aja(i);if(t1(n,a))return{file:Tu.of("__package__.yml"),endpointId:r};let o=[];for(let c=0;c<n.length;++c){let f=n[c];if(f!=null&&f===a[c])o.push(f);else{let s=No(r);return{file:Tu.of(`${s}.yml`),endpointId:i,tag:r}}}if(o.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:Tu.of(No(o.join("_"))+".yml"),endpointId:No(a.slice(o.length).join("_")),tag:r}}function drM({webhook:e,context:t}){return e.sdkName!=null?{file:Hh_({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:lrM({namespaceOverride:e.namespace,location:frM({webhook:e,context:t})})}var prM=Tu.of(ob);function My_(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return Sy_({namespace:e.namespace,groupName:e.groupName});case"oneOf":return Sy_({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return prM;default:vt(e)}}function Sy_({namespace:e,groupName:t}){return e!=null&&t!=null?GCi([{type:"namespace",name:e},...t]):e!=null?GCi([{type:"namespace",name:e}]):GCi(t)}var Psc="external",Py_=Tu.of(ob);function Dy_({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let o=My_(a),c=kh_({schema:a,context:i,declarationFile:o,namespace:r,declarationDepth:0});if(gCi(c.schema)){let f=hO(c.schema);if(f===(c.name??n)||f===`optional<${c.name??n}>`||f===`nullable<${c.name??n}>`||f===`optional<nullable<${c.name??n}>>`)continue}i.builder.addType(o,{name:c.name??n,schema:c.schema})}}function By_(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),dy_(e),py_(e),_y_(e),ny_(e),wy_(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(Psc);let t=jy_(e),r=t.sdkGroups;e.setInState(C1.Webhook),Ey_(e),e.unsetInState(C1.Webhook),e.setInState(C1.Channel);for(let n of Object.values(e.ir.channels)){let a=GCi(n.groupName);sy_({channel:n,context:e,declarationFile:a})}e.unsetInState(C1.Channel);let i=_rM({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});Dy_({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))Dy_({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.optimizeServiceAuth(),e.builder.build()}function _rM({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}var uja=class{context;constructor(t){this.context=t}};var H3o=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[o,c]of Object.entries(i.files)){let f=n!=null?Tu.of(`${n}${"/"}${o}`):Tu.of(o);t[f]=c}let a=Object.keys(i.directories).sort();for(let o of a){let c=n!=null?`${n}${"/"}${o}`:o,f=i.directories[o];r(f,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Tu.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 qJi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new H3o,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 o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(o.service.auth=r),i!=null&&(o.service["base-path"]=i),n!=null&&(o.service["display-name"]=n),a!=null&&(o.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 nGt(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"]))Iy_(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(Iy_(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??No((fAe(r)+"/"+b9i(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Tu.of(i1))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=Puo(fAe(GDn.of(`/${t}`)),GDn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=Puo(fAe(GDn.of(`/${t}`)),GDn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===Tu.of(i1))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>t1(c,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=rD(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}optimizeServiceAuth(){let t=[this.packageMarkerFile,...Object.values(this.root.getAllFiles())];for(let r of t){if(r.service==null)continue;let i=Object.values(r.service.endpoints);if(i.length===0)continue;if(i.every(a=>a.auth===!0)){r.service.auth=!0;for(let a of Object.values(r.service.endpoints))delete a.auth}}}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:rD(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,o])=>[a,{...o,path:rD(r,o.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===ob?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 Iy_(e){return e?.header!=null}var K3o=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;options;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;urlIdMap=new Map;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:o}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=o,this.globalHeaderOverrides=a,this.options=MJi({options:i}),this.enableUniqueErrorsPerEndpoint=this.options.enableUniqueErrorsPerEndpoint,this.referencedSchemaIds=this.options.onlyIncludeReferencedSchemas?new Set:void 0,this.builder=new qJi(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let f of r.endpoints)for(let[s,u]of Object.entries(f.errors)){let l=parseInt(s),p=c[l];p==null&&u.schema!=null?c[l]=u.schema:p!=null&&u.schema!=null&&nK(p,u.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}setUrlId(t,r){this.urlIdMap.set(t,r)}getUrlId(t){return this.urlIdMap.get(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.options.onlyIncludeReferencedSchemas&&this.isInAnyState(C1.Channel,C1.Endpoint,C1.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:vt(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:vt(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 jsc(e){let t=new K3o(e);return By_(t)}function hrM(e){return WKi(e,{single:t=>[typeof t=="string"?t:t.scheme],any:t=>t.any.map(r=>typeof r=="string"?r:r.scheme)})}function yrM(e,t){if(e==null)return;let r=hrM(t),i={};for(let n of r)e[n]!=null&&(i[n]=e[n]);return Object.keys(i).length>0?i:void 0}var J3o=class{args;constructor(t){this.args=t}buildAuthOverrides(t){let r=this.args.generatorsConfiguration?.api?.["auth-schemes"],i=this.args.generatorsConfiguration?.api?.auth,n=t??i;if(n==null)return;let a=yrM(r,n);return{auth:n,"auth-schemes":a}}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=jsc({taskContext:t,ir:r,options:MJi({options:i,overrides:this.args}),authOverrides:this.buildAuthOverrides(i?.auth),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:Li.dump(a.rootApiFile)},namedDefinitionFiles:{...bn(a.definitionFiles,o=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Li.dump(o),contents:o})),[Tu.of(ob)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Li.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var sja=class extends _Ft{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;groupEnvironmentsByHost;removeDiscriminantsFromSchemas;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.wrapReferencesToNullableInOptional=t.wrapReferencesToNullableInOptional,this.coerceOptionalSchemasToNullable=t.coerceOptionalSchemasToNullable,this.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.inlineAllOfSchemas=t.inlineAllOfSchemas,this.resolveAliases=t.resolveAliases,this.groupEnvironmentsByHost=t.groupEnvironmentsByHost,this.removeDiscriminantsFromSchemas=t.removeDiscriminantsFromSchemas,this.converter=new J3o(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,i){let n=await this.getDefinition({context:t},r);return new rK({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion})}};var JQ={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};var pUn={of(e){return e}};var Cy_={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},wsc={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:Cy_,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},Gi={SOURCE:pUn.of("source"),SDK_NAMESPACE:pUn.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:pUn.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:pUn.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:pUn.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",RETRIES:"x-fern-retries",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated",EXPLORER_ENABLED:"x-fern-explorer-enabled"};var brM={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!1,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!1,respectReadonlySchemas:!1,respectNullableSchemas:!0,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!0,preserveSchemaIds:!1,objectQueryParameters:!0,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!0,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!1,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1,resolveAliases:!1,groupMultiApiEnvironments:!1,groupEnvironmentsByHost:!1,wrapReferencesToNullableInOptional:!1,coerceOptionalSchemasToNullable:!1,removeDiscriminantsFromSchemas:wn.RemoveDiscriminantsFromSchemas.Always};function vrM(e){let{defaults:t,options:r,overrides:i,overrideOnly:n=new Set,undefinedIfAbsent:a=new Set}=e,o={};for(let c of Object.keys(t))n.has(c)?o[c]=i?.[c]!==void 0?i[c]:t[c]:a.has(c)?o[c]=i?.[c]!==void 0?i[c]:r?.[c]!==void 0?r[c]:void 0:o[c]=i?.[c]??r?.[c]??t[c];return o}function Y0e({options:e,overrides:t}){return vrM({defaults:brM,options:e,overrides:t,overrideOnly:new Set(["disableExamples","preserveSchemaIds"]),undefinedIfAbsent:new Set(["exampleGeneration","defaultFormParameterEncoding"])})}var qy_={naming:"v1"};function Di(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function cja(e,t,r,i,n=[]){try{let a=Di(e,t);if(a!=null)return r.parse(a)}catch{let o=$Oe(n).join(" -> ");i.error(`${o.length>0?`${o}: `:""}Failed to parse ${t}`)}}function TJi(e){let t=Di(e,"examples");if(t!=null){if(Array.isArray(t))return t;if(typeof t=="object"&&t!==null)return Object.values(t).map(r=>typeof r=="object"&&r!==null&&"value"in r?r.value:r)}return[]}function Ty_({schema:e,logger:t}){return Di(e,Gi.ENCODING)??void 0}function Ry_(e){return Di(e,Gi.FERN_ENUM)}function zy_({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let o=Di(i,Gi.SDK_NAMESPACE),c=Di(i,Gi.SDK_GROUP_NAME),f=Di(i,Gi.TYPE_DEFINITION);if(f!=null)return lja({fernType:f,nameOverride:e,generatedName:t,title:r,description:n,availability:a,namespace:o,groupName:typeof c=="string"?[c]:c})}function lja({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c}){return PB({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.base64({example:void 0})});case"BOOLEAN":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.boolean({default:void 0,example:void 0})});case"DATE":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.date({example:void 0})});case"DATE_TIME":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.datetime({example:void 0})});case"FLOAT":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.float({example:void 0})});case"DOUBLE":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.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 ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.uint({default:void 0,example:void 0})});case"INTEGER":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.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 ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.uint64({default:void 0,example:void 0})});case"LONG":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:vt(f.v1)}},unknown:()=>ri.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,namespace:o,groupName:c}),map:({keyType:f,valueType:s})=>f?.type==="primitive"&&s!=null?ri.map({nameOverride:t,generatedName:r,title:i,key:f,value:s,description:n,availability:a,namespace:o,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:f=>f!=null?ri.array({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,optional:f=>f!=null?ri.optional({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,nullable:f=>f!=null?ri.nullable({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,set:f=>f!=null?ri.array({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,literal:f=>ri.literal({nameOverride:t,generatedName:r,title:i,value:f._visit({string:s=>Fj.string(s),boolean:s=>Fj.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:o,groupName:c}),named:f=>ri.reference({schema:f,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,source:xL.openapi({file:"<memory>"})})}})}function Ny_(e){let t=Di(e,Gi.SOURCE);if(t!=null)return t.endsWith(".proto")?xL.protobuf({file:t}):xL.openapi({file:t})}function RJi(e){if(e!=null&&typeof e=="boolean")return e}function jn(e){return e?.$ref!=null}function Fy_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:f,context:s,namespace:u,groupName:l,example:p,encoding:_,source:h}){return n===void 0&&(n=s.options.additionalPropertiesDefaultsTo),Esc({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:f,description:a,availability:o,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Ln.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:typeof n=="boolean"||fja(n,s.options)?ri.unknown({...grM(n),generatedName:`${t}Value`}):Qy_(Dl(n,!1,s.options.optionalAdditionalProperties?f:!1,s,[...i,"Value"],h,u,void 0,void 0,void 0)),namespace:u,groupName:l,example:p,encoding:_})}function Qy_(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=Qy_(e.value);break;case"oneOf":e.value.inline=!0;break;default:vt(e)}return e}function Esc({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsOptional:a,wrapAsNullable:o,description:c,availability:f,namespace:s,groupName:u,example:l,encoding:p}){let _=ri.map({nameOverride:e,generatedName:t,title:r,description:c,availability:f,key:i,value:n,namespace:s,groupName:u,encoding:p,example:l,inline:void 0});return o&&(_=ri.nullable({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:f,namespace:s,groupName:u,inline:void 0})),a&&(_=ri.optional({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:f,namespace:s,groupName:u,inline:void 0})),_}function fja(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!(jn(e)||"type"in e&&e.type!=null||"oneOf"in e&&e.oneOf!=null||"anyOf"in e&&e.anyOf!=null||"allOf"in e&&e.allOf!=null||"enum"in e&&e.enum!=null)}function grM(e){let t={nameOverride:void 0,generatedName:"",title:void 0,description:void 0,availability:void 0,example:void 0,namespace:void 0,groupName:void 0};return e==null||typeof e=="boolean"||jn(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function Uy_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:f,context:s,namespace:u,groupName:l,example:p,source:_}){let h=n==null?ri.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:l}):Dl(n,!1,!1,s,[...i,"Item"],_,u);return OrM({nameOverride:e,generatedName:t,title:r,namespace:u,groupName:l,itemSchema:h,wrapAsOptional:c,wrapAsNullable:f,description:a,availability:o,example:p})}function OrM({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:f,groupName:s,example:u}){let l=ri.array({nameOverride:e,generatedName:t,title:r,value:i,description:o,availability:c,namespace:f,groupName:s,example:u,inline:void 0});return a&&(l=ri.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),n&&(l=ri.optional({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),l}function KL(e){switch(Di(e,Gi.AVAILABILITY)){case"deprecated":return bz.Deprecated;case"beta":return bz.Beta;case"generally-available":return bz.GenerallyAvailable;default:break}if(!jn(e)&&e.deprecated)return bz.Deprecated}function Ssc({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:o,required:c,wrapAsOptional:f,wrapAsNullable:s,discriminator:u,context:l,namespace:p,groupName:_,encoding:h,source:y}){let b=u.propertyName,v=Object.fromEntries(Object.entries(u.mapping??{}).map(([A,g])=>{let m=Jvi({$ref:g},!1,!1,l,[g],h,y,p);return l.markReferencedByDiscriminatedUnion({$ref:g},b,1),[A,m]})),O=Object.entries(n).filter(([A])=>A!==b).map(([A,g])=>{let m=c!=null&&c.includes(A),[j,M]=l.options.coerceOptionalSchemasToNullable?[!1,!m]:[!m,!1],E=Dl(g,j,M,l,[...i,A],y,p);return{key:A,schema:E}});return Ly_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:f,wrapAsNullable:s,properties:O,description:a,availability:o,discriminant:b,subtypes:v,namespace:p,groupName:_,source:y})}function Msc({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:o,required:c,wrapAsOptional:f,wrapAsNullable:s,discriminant:u,variants:l,context:p,namespace:_,groupName:h,encoding:y,source:b}){let v=Object.fromEntries(Object.entries(l).map(([A,g])=>{if(jn(g)){let m=Jvi(g,!1,!1,p,[g.$ref],y,b,_);return p.markReferencedByDiscriminatedUnion(g,u,1),[A,m]}else{let m=_Un(g,!1,!1,p,[...i,A],y,b,_,new Set([u]));return[A,m]}})),O=Object.entries(n).filter(([A])=>A!==u).map(([A,g])=>{let m=c!=null&&c.includes(A),[j,M]=p.options.coerceOptionalSchemasToNullable?[!1,!m]:[!m,!1],E=Dl(g,j,M,p,[...i,A],b,_);return{key:A,schema:E}});return Ly_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:f,wrapAsNullable:s,properties:O,description:a,availability:o,discriminant:u,subtypes:v,namespace:_,groupName:h,source:b})}function Ly_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,properties:a,description:o,availability:c,discriminant:f,subtypes:s,namespace:u,groupName:l,source:p}){let _=ri.oneOf(Bhe.discriminated({description:o,availability:c,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:s,commonProperties:a,namespace:u,groupName:l,encoding:void 0,source:p,inline:void 0}));return n&&(_=ri.nullable({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),i&&(_=ri.optional({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),_}function Vy_(e){if(e.proto!=null)return qQn.protobuf({typeName:e.proto.type})}function KCi({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:o,description:c,availability:f,wrapAsOptional:s,wrapAsNullable:u,namespace:l,groupName:p,context:_,source:h,inline:y}){let b=mrM(n??[]),v=new Set(a),O=Array.from(v).map((g,m)=>{let j=i?.[g],M=b[m],E=cUn.test(g),D=j?.name??M,B=E?g:lUn(g);return D!=null&&!cUn.test(D)&&(_?.logger.warn(`Enum name override ${D} is not a valid name. Falling back on ${B}.`),D=void 0),{nameOverride:D,generatedName:B,value:g,description:j?.description,availability:f,casing:{snake:j?.casing?.snake??void 0,pascal:j?.casing?.pascal??void 0,screamingSnake:j?.casing?.screamingSnake??void 0,camel:j?.casing?.camel??void 0}}}),A=o!=null?O.find(g=>g.value===o):void 0;return ArM({wrapAsOptional:s,wrapAsNullable:u,nameOverride:e,generatedName:t,title:r,values:O,_default:A,description:c,availability:f,namespace:l,groupName:p,source:h,inline:y})}function ArM({wrapAsOptional:e,wrapAsNullable:t,nameOverride:r,generatedName:i,title:n,values:a,_default:o,description:c,availability:f,namespace:s,groupName:u,source:l,inline:p}){let _=ri.enum({nameOverride:r,generatedName:i,title:n,values:a,description:c,availability:f,default:o,example:void 0,namespace:s,groupName:u,source:l,inline:p});return t&&(_=ri.nullable({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:f,namespace:s,groupName:u,inline:p})),e&&(_=ri.optional({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:f,namespace:s,groupName:u,inline:p})),_}function mrM(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 Wy_({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,description:u,availability:l,wrapAsOptional:p,wrapAsNullable:_,example:h,namespace:y,groupName:b}){return i==="int64"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint32"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint64"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}function PrM(e){return typeof e=="string"?Fj.string(e):typeof e=="boolean"?Fj.boolean(e):Fj.string(`${e}`)}function xy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,value:a,description:o,availability:c,namespace:f,groupName:s}){let u=ri.literal({nameOverride:e,generatedName:t,title:r,value:PrM(a),description:o,availability:c,namespace:f,groupName:s});return n&&(u=ri.nullable({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),i&&(u=ri.optional({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),u}function Dsc({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,description:u,availability:l,wrapAsOptional:p,wrapAsNullable:_,example:h,namespace:y,groupName:b}){return i==null||i==="double"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.double({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="float"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int32"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int64"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint32"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint64"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="time-delta"?q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):q1({nameOverride:e,generatedName:t,title:r,primitive:Ln.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}var jrM={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},wrM={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}}},ErM={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}}},SrM={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},MrM={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},DrM={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},BrM={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},IrM={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function dja(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[jrM,wrM,ErM,SrM,MrM,DrM,BrM,IrM],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:o,newBreadcrumbs:c}=a.applyStrategy(t);t=o,r=[...r,...c]}}while(t.join("")!==n.join(""));return r}function qC(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:QP(No(n))).join("");return/^\d/.test(i)?tja(i)??i:i}function Gy_(e){let t=e.join("_");return No(t)}function xO(e){switch(e.type){case"object":return Zs.object({allOf:e.allOf,properties:e.properties.map(t=>qrM(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:e.inline});case"array":return Zs.array({description:e.description,availability:e.availability,value:xO(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return Zs.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,source:e.source,inline:e.inline});case"literal":return Zs.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"nullable":return Zs.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:xO(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return Zs.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:xO(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return Zs.primitive({description:e.description,availability:e.availability,schema:Hy_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Zs.map({description:e.description,availability:e.availability,key:Zs.primitive({description:e.key.description,availability:e.key.availability,schema:Hy_(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:xO(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return Zs.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return Zs.oneOf(CrM(e.value));case"unknown":return Zs.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:vt(e)}}function CrM(e){switch(e.type){case"discriminated":return pGt.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:xO(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,xO(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return pGt.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>xO(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:vt(e)}}function Hy_(e){switch(e.type){case"string":return ah.string(e);case"base64":return ah.base64();case"boolean":return ah.boolean(e);case"date":return ah.date();case"datetime":return ah.datetime();case"double":return ah.double(e);case"float":return ah.float();case"int":return ah.int(e);case"int64":return ah.int64(e);case"uint":return ah.uint();case"uint64":return ah.uint64();default:vt(e)}}function qrM(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:xO(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function $3o(e,t){return nK(xO(e),xO(t))}function Ky_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:o,wrapAsOptional:c,wrapAsNullable:f,allOf:s,context:u,propertiesToExclude:l,namespace:p,groupName:_,fullExamples:h,additionalProperties:y,availability:b,source:v}){let O=[...o??[]],A={...Jy_({properties:n,breadcrumbs:i,context:u})},g=[],m=[];for(let B of s)if(!u.options.inlineAllOfSchemas&&jn(B)){let F=u.resolveSchemaReference(B);if(F.discriminator!=null&&F.discriminator.mapping!=null)continue;if(F.oneOf!=null||F.anyOf!=null){let T=F.oneOf??F.anyOf;if(T!=null){for(let R of T){let Q=jn(R)?u.resolveSchemaReference(R):R,U=Dl(Q,!1,!1,u.DUMMY,i,v,p);U.type==="object"&&g.push(...U.properties.map(H=>H.schema.type!=="optional"&&H.schema.type!=="nullable"?{...H,schema:ri.optional({nameOverride:void 0,generatedName:"",title:void 0,value:H.schema,description:void 0,availability:H.availability,namespace:void 0,groupName:void 0,inline:void 0})}:H))}continue}}let N=JCi(B);if(N==null)continue;m.push({schemaId:N,convertedSchema:Bsc(B,[N],v,u.options.preserveSchemaIds),properties:$y_({schema:B,context:u,breadcrumbs:i,source:v,namespace:p})}),u.markSchemaAsReferencedByNonRequest(N)}else if(jn(B)){let F=u.resolveSchemaReference(B),N=Dl(F,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}else{let F=B.required??[];g=g.map(T=>(T.schema.type==="optional"||T.schema.type==="nullable")&&F.includes(T.key)?{...T,schema:T.schema.value}:T);let N=Dl(B,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}let j={};for(let B of m)for(let[F,N]of Object.entries(B.properties)){let T=j[F];T!=null?(T.schemaIds.push(B.schemaId),T.schemas.some(Q=>$3o(Q,N))||T.schemas.push(N)):j[F]={schemaIds:[B.schemaId],schemas:[N]}}let M=[];for(let[B,F]of Object.entries(j))F.schemaIds.length>1&&M.push({propertyKey:B,allOfSchemaIds:F.schemaIds,conflictingTypeSignatures:F.schemas.length>1});let E=Object.fromEntries(Object.entries(A).filter(([B,F])=>!(!jn(F)&&F.type==="null"))),D=Object.entries(E).map(([B,F])=>{let N=Di(F,Gi.AUDIENCES)??[],T=KL(F),R=jn(F)?!1:F.readOnly,Q=jn(F)?!1:F.writeOnly,H=!(O.includes(B)&&!R),ue=Di(F,Gi.FERN_PROPERTY_NAME),se=[...i,B],x=Gy_(se),G=Dl(F,H,!1,u,se,v,p),Pe={};for(let ne of m){let Ee=ne.properties[B];Ee!=null&&!$3o(G,Ee)?Pe[ne.schemaId]={differentSchema:!0}:Ee!=null&&(Pe[ne.schemaId]={differentSchema:!1})}return{key:B,schema:G,nameOverride:ue,audiences:N,conflict:Pe,generatedName:x,availability:T,readonly:R,writeonly:Q}});return D.push(...g.map(B=>{let F=B.conflict;for(let N of m){let T=N.properties[B.key];T!=null&&!$3o(B.schema,T)?F[N.schemaId]={differentSchema:!0}:T!=null&&(F[N.schemaId]={differentSchema:!1})}return{...B,conflict:F}})),TrM({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:f,properties:D.filter(B=>!l.has(B.key)),description:a,allOf:m.map(B=>B.convertedSchema),allOfPropertyConflicts:M,namespace:p,groupName:_,fullExamples:h,additionalProperties:y,availability:b,source:v,context:u})}function TrM({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,properties:a,description:o,allOf:c,allOfPropertyConflicts:f,namespace:s,groupName:u,fullExamples:l,additionalProperties:p,availability:_,source:h,context:y}){let b=ri.object({description:o,properties:a,nameOverride:e,generatedName:t,title:r,allOf:c,allOfPropertyConflicts:f,namespace:s,groupName:u,fullExamples:l,additionalProperties:fja(p,y.options),availability:_,source:h,inline:void 0});return n&&(b=ri.nullable({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),i&&(b=ri.optional({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),b}function Jy_({properties:e,breadcrumbs:t,context:r}){return Object.fromEntries(Object.entries(e).filter(([i,n])=>{let a=Di(n,Gi.IGNORE);return a&&r.logger.debug(`Property ${t.join(".")}.${i} is marked with x-fern-ignore. Skipping.`),!a}))}function $y_({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[o,c]=jn(e)?[t.resolveSchemaReference(e),dja(e.$ref)]:[e,r];for(let f of o.allOf??[])a={...a,...$y_({schema:f,context:t,breadcrumbs:c,source:i,namespace:n})};for(let[f,s]of Object.entries(Jy_({properties:o.properties??{},breadcrumbs:r,context:t}))){let u=Dl(s,!1,!1,t,[...c,f],i,n);a[f]=u}return a}function $Ci({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsOptional:o,wrapAsNullable:c,context:f,subtypes:s,namespace:u,groupName:l,encoding:p,source:_,subtypeSuffixOverrides:h}){let y=NrM({schemas:s}),b=s.flatMap((O,A)=>{if(!jn(O)&&O.enum!=null&&f.options.coerceEnumsToLiterals&&O.type==="string")return O.enum.map(m=>ri.literal({nameOverride:void 0,generatedName:qC([t,m],f.options.preserveSchemaIds),title:void 0,value:Fj.string(String(m)),namespace:u,groupName:void 0,description:void 0,availability:m.availability}));let g=y[A];if(h!=null){let m=h[A];m!=null&&"name"in m&&(g=m.name)}return[Dl(O,!1,!1,f,[...i,g??`${A}`],_,u)]}),v=RrM(b);return zrM({uniqueSubtypes:v,nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:c,description:n,availability:a,namespace:u,groupName:l,context:f,encoding:p,source:_})}function RrM(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let o=e[a];if(i!=null&&o!=null&&nK(i,o)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function zrM({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:f,groupName:s,context:u,encoding:l,source:p}){if(Object.entries(e).every(([h,y])=>y.type==="literal")){let h={},y=[];return Object.entries(e).forEach(([b,v])=>{v.type==="literal"&&v.value.type==="string"&&(y.push(v.value.value),v.description!=null&&(h[v.value.value]={description:v.description}))}),KCi({nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,fernEnum:h,enumVarNames:void 0,enumValues:y,_default:void 0,namespace:f,groupName:s,context:u,source:p,inline:void 0})}if(e.length===1&&e[0]!=null&&!u.options.preserveSingleSchemaOneOf){let h=e[0];return a&&(h=ri.nullable({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),n&&(h=ri.optional({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),h}return Yy_({nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,subtypes:e,namespace:f,groupName:s,encoding:l,source:p})}function Isc({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsOptional:a,wrapAsNullable:o,context:c,namespace:f,groupName:s,discriminator:u,encoding:l,source:p}){let _=Object.entries(u.mapping??{}).map(([b,v],O)=>{let A={$ref:v},g=Jvi(A,!1,!1,c,[v],l,p,f);return c.markSchemaWithDiscriminantValue(A,u.propertyName,b),g.type==="object"&&(g.properties={[u.propertyName]:ri.literal({nameOverride:void 0,generatedName:qC([t,b],c.options.preserveSchemaIds),title:void 0,value:Fj.string(b),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...g.properties.filter(m=>m.key!==u.propertyName)}),g}),h=[];for(let b=0;b<_.length;++b){let v=_[b],O=!1;for(let A=b+1;A<_.length;++A){let g=_[A];if(v!=null&&g!=null&&nK(v,g)){O=!0;break}}v!=null&&!O&&h.push(v)}if(Object.entries(h).every(([b,v])=>v.type==="literal")){let b={},v=[];return Object.entries(h).forEach(([O,A])=>{A.type==="literal"&&A.value.type==="string"&&(v.push(A.value.value),A.description!=null&&(b[A.value.value]={description:A.description}))}),KCi({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:i,availability:n,fernEnum:b,enumVarNames:void 0,enumValues:v,_default:void 0,namespace:f,groupName:s,context:c,source:p,inline:void 0})}return h.length===1&&h[0]!=null&&!c.options.preserveSingleSchemaOneOf?h[0]:Yy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:i,availability:n,subtypes:h,namespace:f,groupName:s,encoding:l,source:p})}function NrM({schemas:e}){let t={},r=0;for(let n of e){if(!jn(n)){if(n.properties!=null&&Object.entries(n.properties).length>0){let a=Object.keys(n.properties),o={},c=a;for(let[f,s]of Object.entries(t)){let u=qro(s,a);c=qro(c,s),o[f]=u}o[r]=c,t=o}}r++}return e.map((n,a)=>{let o=t[a];if(o!=null&&o.length>0){let c=o.sort();if(c[0]!=null)return c[0]}return BJi(a)??`${a}`})}function Yy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,description:a,availability:o,subtypes:c,namespace:f,groupName:s,encoding:u,source:l}){let p=ri.oneOf(Bhe.undiscriminated({description:a,availability:o,nameOverride:e,generatedName:t,title:r,schemas:c,namespace:f,groupName:s,encoding:u,source:l,inline:void 0}));return n&&(p=ri.nullable({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:f,groupName:s,inline:void 0})),i&&(p=ri.optional({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:f,groupName:s,inline:void 0})),p}function hUn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function Y3o({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=TJi(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function Xy_({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=TJi(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function gGt({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=TJi(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function Zy_({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=TJi(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var zJi="#/components/schemas/";function tb_(e,t){let r=jn(e)?t.resolveSchemaReference(e):e;switch(r.type){case"boolean":case"number":case"integer":return!0;case"string":return r.enum==null;case"array":return tb_(r.items,t);case"object":return!1;case void 0:return!1;default:return t.logger.warn("Unhandled schema type. Will not inline this schema",JSON.stringify(r)),!1}}function FrM(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:tb_(t,r):!1}function Dl(e,t,r,i,n,a,o,c=!1,f=new Set,s){let u=Ny_(e)??a,l=HrM({schema:e,logger:i.logger});if(jn(e)){let p=JCi(e);return p!=null?FrM(p,e,i)?_Un(i.resolveSchemaReference(e),t,r,i,dja(e.$ref),l,u,o,f,c,s):(c?i.markSchemaAsReferencedByRequest(p):i.markSchemaAsReferencedByNonRequest(p),Jvi(e,t,r,i,n,l,u,o)):_Un(i.resolveSchemaReference(e),t,r,i,dja(e.$ref),l,u,o,f,c,s)}return _Un(e,t,r,i,n,l,u,o,f,c,s)}function Jvi(e,t,r,i,n,a,o,c){let f=e.$ref.includes("properties")?_Un(i.resolveSchemaReference(e),t,r,i,n,a,o,c,new Set):ri.reference(Bsc(e,n,o,i.options.preserveSchemaIds));if(r===!1){let s=i.resolveSchemaReference(e);(s.nullable===!0||Array.isArray(s.type)&&s.type.length>=2&&s.type.includes("null"))&&(r=!0)}return r&&(f=ri.nullable({title:void 0,nameOverride:void 0,generatedName:qC(n,i.options.preserveSchemaIds),value:f,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(f=ri.optional({title:void 0,nameOverride:void 0,generatedName:qC(n,i.options.preserveSchemaIds),value:f,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),f}function QrM(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function _Un(e,t,r,i,n,a,o,c,f=new Set,s=!1,u){typeof e=="string"&&(e={type:e});let l=Di(e,Gi.TYPE_NAME)??(i.options.useTitlesAsName?QrM(e.title):void 0),p=Di(e,Gi.SDK_GROUP_NAME)??Di(e,JQ.TAGS)?.[0],_=(typeof p=="string"?[p]:p)??[];_=i.resolveGroupName(_);let h=qC(n,i.options.preserveSchemaIds),y=e.title,b=e.description,v=KL(e),O=[];e.example!=null&&O.push({name:void 0,value:e.example,description:void 0});let A=Di(e,JQ.EXAMPLES);A!=null&&Object.keys(A).length>0&&O.push(...Object.entries(A).map(([j,M])=>({name:M?.summary??j,value:M.value,description:M.description})));let g=TJi(e);g!=null&&Object.keys(g).length>0&&O.push(...g.map(j=>({name:void 0,value:j,description:void 0})));let m=zy_({schema:e,description:b,title:y,nameOverride:l,generatedName:h,availability:v});if(m!=null){let j=m;return r&&(j=ri.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),t&&(j=ri.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),j}try{if(Array.isArray(e.type)){let E=e.type.indexOf("null"),D=E!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&D)e.type.splice(E,1),e.type=e.type[0],e.nullable=!0;else if(D&&(e.type.splice(E,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let B=new Set([...e.oneOf,...e.type]);e.oneOf=[...B]}}if(r=r||e.nullable===!0,"const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(e.enum=e.enum.filter(D=>D!==null),!k3o(e.enum))return q1({nameOverride:l,generatedName:h,title:y,primitive:Ln.string({default:hUn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:gGt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v});let E=Ry_(e);return i.options.coerceEnumsToLiterals&&e.enum.length===1&&e.enum[0]!=null&&E==null?xy_({nameOverride:l,generatedName:h,title:y,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:b,availability:v,namespace:c,groupName:_}):KCi({nameOverride:l,generatedName:h,title:y,fernEnum:E,enumVarNames:Di(e,[JQ.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:_,context:i,source:o,inline:void 0})}if(k3o(e.type)&&e.type.length>1){let E=e.type.includes("null"),D=e.type.filter(B=>B!=="null").map(B=>({type:B,nullable:E}));return $Ci({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:D,namespace:c,groupName:_,encoding:a,source:o})}if(e.type==="boolean"){let E=Di(e,Gi.BOOLEAN_LITERAL);return E!=null?ky_({nameOverride:l,generatedName:h,title:y,literal:Fj.boolean(E),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):q1({nameOverride:l,generatedName:h,title:y,primitive:Ln.boolean({default:UrM(e.default),example:Xy_({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_})}if(e.type==="number")return Dsc({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:RJi(e.exclusiveMinimum),exclusiveMaximum:RJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Y3o({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="integer")return Wy_({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:RJi(e.exclusiveMinimum),exclusiveMaximum:RJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Y3o({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="float")return Dsc({nameOverride:l,generatedName:h,title:y,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:RJi(e.exclusiveMinimum),exclusiveMaximum:RJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Y3o({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="string"){if(e.format==="date-time")return q1({nameOverride:l,generatedName:h,title:y,primitive:Ln.datetime({example:gGt({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_});if(e.format==="date"&&i.options.typeDatesAsStrings===!1)return q1({nameOverride:l,generatedName:h,title:y,primitive:Ln.date({example:gGt({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_});if(e.format==="json-string"){let D=ri.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:void 0});return r&&(D=ri.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),t&&(D=ri.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),D}let E=ib_(e,"const");return E!=null?ky_({nameOverride:l,generatedName:h,title:y,literal:Fj.string(E),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):q1({nameOverride:l,generatedName:h,title:y,primitive:Ln.string({default:hUn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:gGt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v})}if(e.type==="array")return Uy_({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,item:e.items,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,example:Zy_({schema:e,logger:i.logger,fallback:u}),source:o});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&X3o(e))return Fy_({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,additionalProperties:e.additionalProperties,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,example:e.example,source:o});if(e.oneOf!=null&&e.oneOf.length>0&&Di(e,Gi.IS_DISCRIMINATED)===!1)return $Ci({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf,namespace:c,groupName:_,encoding:a,source:o});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return i.options.discriminatedUnionV2?Isc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,discriminator:e.discriminator,encoding:a,source:o}):Ssc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,source:o});if(e.oneOf!=null&&e.oneOf.length>0){let E=Di(e,Gi.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return i.options.discriminatedUnionV2||E?Isc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,discriminator:e.discriminator,encoding:a,source:o}):Ssc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,source:o});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(i.options.preserveSingleSchemaOneOf)return $Ci({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf.filter(B=>jn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o});let D=Dl(e.oneOf[0],t,r,i,n,o,c,s);return OGt(D,b,c,_)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let N=e.oneOf[0],T=e.oneOf[1];if(!jn(N)&&N.type==="null"){let R=Dl(T,t,!0,i,n,o,c);return OGt(R,b,c,_)}else if(!jn(T)&&T.type==="null"){let R=Dl(N,t,!0,i,n,o,c);return OGt(R,b,c,_)}}let D=WrM({schemas:e.oneOf});if(D!=null)return KCi({nameOverride:l,generatedName:h,title:y,fernEnum:void 0,enumVarNames:void 0,enumValues:D,_default:e.default,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:_,context:i,source:o,inline:void 0});let B=eb_({schemas:e.oneOf,context:i});if(B!=null&&!i.options.discriminatedUnionV2&&!E)return Msc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},required:e.required,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,discriminant:B.discriminant,variants:B.schemas,context:i,namespace:c,groupName:_,encoding:a,source:o});let F=e.oneOf.filter(N=>!jn(N)&&N.type==="null").length>0;return $Ci({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||F,context:i,subtypes:e.oneOf.filter(N=>jn(N)||N.type!=="null"),encoding:a,namespace:c,groupName:_,source:o})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let B=Dl(e.anyOf[0],t,r,i,n,o,c,s);return OGt(B,b,c,_)}if(e.anyOf.length===2){let[B,F]=e.anyOf;if(B!=null&&F!=null){if(!jn(B)&&B.type==="null"){let N=Dl(F,t,!0,i,n,o,c);return OGt(N,b,c,_)}else if(!jn(F)&&F.type==="null"){let N=Dl(B,t,!0,i,n,o,c);return OGt(N,b,c,_)}}}let E=eb_({schemas:e.anyOf,context:i});if(E!=null&&!i.options.discriminatedUnionV2)return Msc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},required:e.required,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,discriminant:E.discriminant,variants:E.schemas,context:i,namespace:c,groupName:_,encoding:a,source:o});let D=e.anyOf.filter(B=>!jn(B)&&B.type==="null").length>0;return $Ci({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||D,context:i,subtypes:e.anyOf.filter(B=>jn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o})}if(e.allOf!=null||e.properties!=null){let E=[];for(let B of e.allOf??[])(jn(B)||Object.keys(B).length>0)&&E.push(B);if((e.properties==null||X3o(e))&&E.length===1&&E[0]!=null){let B=Dl(E[0],t,r,i,n,o,c,s);return OGt(B,b,c,_)}let D=E.filter(B=>{let F=Z3o(B);return F||i.logger.debug(`Skipping non-object allOf element: ${JSON.stringify(B)}`),F});if((e.properties==null||X3o(e))&&D.length===1&&D[0]!=null){let B=Dl(D[0],t,r,i,n,o,c,s);return OGt(B,b,c,_)}return Ky_({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},description:b,required:e.required,wrapAsOptional:t,wrapAsNullable:r,allOf:D,context:i,propertiesToExclude:f,namespace:c,groupName:_,fullExamples:O,additionalProperties:e.additionalProperties,availability:v,encoding:a,source:o})}if(e.type==="object"&&LrM(e)&&VrM(e)&&X3o(e))return Esc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,keySchema:{nameOverride:void 0,generatedName:`${h}Key`,title:void 0,description:void 0,availability:void 0,schema:Ln.string({default:hUn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:gGt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_},valueSchema:ri.unknown({nameOverride:void 0,generatedName:`${h}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:c,groupName:_}),namespace:c,groupName:_,encoding:a,example:e.example});e.type!=null&&i.logger.warn(`Failed to parse an OpenAPI schema at the following location: ${n.join("->")}. Coercing to unknown.`);let j=e.example??e.default,M=ri.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:j});return r&&(M=ri.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:M})),t&&(M=ri.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:M})),M}catch(j){return i.logger.debug(`Error converting schema: ${j.message}
1417
1417
  Location: ${n.join("-> ")}`),ri.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:void 0})}}function UrM(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 JCi(e){if(e.$ref.startsWith(zJi))return e.$ref.replace(zJi,"")}function Bsc(e,t,r,i){let n=Di(e,Gi.TYPE_NAME),a=qC(t,i),o=e.description,c=KL(e),f=JCi(e);if(f==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return Zs.reference({generatedName:a,nameOverride:n,title:void 0,schema:f,description:o??void 0,availability:c,namespace:void 0,groupName:void 0,source:r})}function LrM(e){return e.oneOf==null||e.oneOf.length===0}function VrM(e){return e.allOf==null||e.allOf.length===0}function X3o(e){return e.properties==null||VA(e.properties)===0}function k3o(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function OGt(e,t,r,i){if(e.type==="reference")return ri.reference({...e,description:t,availability:e.availability,namespace:r,groupName:i});if(e.type==="optional"){let n=OGt(e.value,t,r,i);return ri.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0})}else if(e.type==="nullable"){let n=OGt(e.value,t,r,i);return ri.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0})}else if(e.type==="primitive"&&t!=null&&e.description==null)return ri.primitive({...e,description:t});return e}function Z3o(e){return jn(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>Z3o(t)):e.oneOf!=null?e.oneOf.every(t=>Z3o(t)):e.anyOf!=null?e.anyOf.every(t=>Z3o(t)):!1}function ky_({literal:e,wrapAsOptional:t,wrapAsNullable:r,namespace:i,groupName:n,description:a,availability:o,nameOverride:c,generatedName:f,title:s}){let u=ri.literal({nameOverride:c,generatedName:f,title:s,value:e,namespace:i,groupName:n,description:a,availability:o});return r&&(u=ri.nullable({nameOverride:c,generatedName:f,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),t&&(u=ri.optional({nameOverride:c,generatedName:f,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),u}function q1({primitive:e,wrapAsOptional:t,wrapAsNullable:r,namespace:i,groupName:n,description:a,availability:o,generatedName:c,nameOverride:f,title:s}){n=typeof n=="string"?[n]:n;let u=ri.primitive({nameOverride:f,generatedName:c,title:s,schema:e,description:a,availability:o,namespace:i,groupName:n});return r&&(u=ri.nullable({nameOverride:f,generatedName:c,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),t&&(u=ri.optional({nameOverride:f,generatedName:c,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),u}function WrM({schemas:e}){let t=new Set;for(let r of e){if(jn(r))return;if(r.enum!=null&&k3o(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function eb_({schemas:e,context:t}){let r={};for(let i of e){let n=rb_({schema:i,context:t});for(let[a,o]of Object.entries(n)){let c=r[a];c!=null?c[o]=i:r[a]={[o]:i}}}for(let[i,n]of Object.entries(r))if(Object.keys(n).length===e.length)return{discriminant:i,schemas:n}}function rb_({schema:e,context:t}){let r=jn(e)?t.resolveSchemaReference(e):e;return xrM({schema:r,context:t})}function xrM({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=rb_({schema:i,context:t});for(let[a,o]of Object.entries(n??{}))r[a]=o}return r}for(let[i,n]of Object.entries(e.properties??{})){let a=jn(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&k3o(a.enum)&&GrM(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let o=ib_(a,"const");a.type==="string"&&o!=null&&(r[i]=o),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function GrM(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 ib_(e,t){let r=e[t];if(r!=null)return r}function HrM({schema:e,logger:t}){let r=Ty_({schema:e,logger:t});if(r!=null)return Vy_(r)}var yUn=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:i,namespace:n}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=i,this.namespace=n}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let i=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};i.push(n)}return i.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(zJi))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let i=t.$ref.substring(zJi.length).split("/"),n=this.document.components;if(n==null||n.schemas==null)throw new Error("Document does not have components.schemas.");let[a,o,c]=i;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let f=n.schemas[a];if(f==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if(jn(f)&&(f=this.resolveSchemaReference(f)),o==="properties"&&c!=null){let s=f.properties?.[c];if(s==null)throw new Error(`Property "${c}" not found on "${a}". Full ref: ${t.$ref}`);jn(s)?f=this.resolveSchemaReference(s):f=s}return f}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,i){}markSchemaWithDiscriminantValue(t,r,i){}};var eLo=class extends yUn{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",i=this.document.components;if(i==null||i.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let n=t.$ref.substring(r.length),a=i.messages[n];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function bUn(e,t){let r={};if(e!=null)return{rootSchemas:r,namespacedSchemas:{[e]:t}};let i={};for(let[n,a]of Object.entries(t))switch(a.type){case"object":case"array":case"map":case"optional":case"enum":case"literal":case"reference":case"nullable":case"primitive":{if(a.namespace==null){r[n]=a;continue}let o=a.namespace;i[o]??={},i[o][n]=a;continue}case"oneOf":case"unknown":r[n]=a;continue;default:vt(a)}return{rootSchemas:r,namespacedSchemas:i}}var vUn=ae(require("fs"),1),NJi=ae(require("path"),1);function YCi(e){if(typeof e=="string")return Sl.primitive(Ha.string(e));if(typeof e=="number")return Number.isInteger(e)?Sl.primitive(Ha.int(e)):Sl.primitive(Ha.double(e));if(typeof e=="boolean")return Sl.primitive(Ha.boolean(e));if(Array.isArray(e)){let t=e.map(r=>YCi(r));return t.length===0?void 0:Sl.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=YCi(i);n!=null&&t.push({key:Ha.string(r),value:n})}return Sl.map(t)}}function pja(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function nb_(e){if(e!=null&&Array.isArray(e))return e}var XCi=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:o,skipReadonly:c}){switch(i.type){case"enum":return typeof r=="string"&&ab_({schema:i,value:r})?Sl.enum(r):i.values[0]!=null?Sl.enum(i.values[0]?.value):void 0;case"literal":return Sl.literal(i.value);case"nullable":{if(r==null&&!this.hasExample(i.value,0,a,o)&&this.exceedsMaxDepth(n,o))return Sl.null({});let f=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:o,skipReadonly:c});return f??Sl.null({})}case"optional":{if(r==null&&!this.hasExample(i.value,0,a,o)&&(o.ignoreOptionals||this.exceedsMaxDepth(n,o))||Object.is(r,null))return;let f=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:o,skipReadonly:c});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:o});return Sl.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),u=this.buildExampleHelper({example:r,schema:f,exampleId:t,visitedSchemaIds:a,depth:n,options:o,skipReadonly:s||this.context.options.respectReadonlySchemas?c:!1});return a.delete(i.schema),u}return}case"oneOf":switch(i.value.type){case"discriminated":{let f={},s={},u={},l=pja(r),p=l?.[i.value.discriminantProperty],_=i.value.schemas[p],h=[],y=this.getDiscriminatedUnionVariantSchema(i.value,l);y!=null&&h.push(y),h.push(...Object.entries(i.value.schemas));for(let b of h)if(p!=null&&_!=null&&_.type==="object"){s=this.getAllProperties(_),u=this.getAllRequiredProperties(_),f[i.value.discriminantProperty]=Sl.primitive(Ha.string(p));break}else{let v=this.buildExampleHelper({exampleId:t,schema:b[1],example:void 0,visitedSchemaIds:a,depth:n,options:o,skipReadonly:c});if(v!=null){this.mergeExampleWith(v,f),f[i.value.discriminantProperty]=Sl.primitive(Ha.string(b[0]));break}}for(let b of i.value.commonProperties){s[b.key]={schema:b.schema,readonly:!1};let v=this.getResolvedSchema(b.schema);v.type!=="optional"&&v.type!=="nullable"&&(u[b.key]=b.schema)}for(let[b,v]of Object.entries(s)){let O=b in u;if(O&&l?.[b]!=null){let A=this.buildExampleHelper({schema:v.schema,exampleId:t,example:l[b],visitedSchemaIds:a,depth:n+1,options:o,skipReadonly:c});if(A!=null)f[b]=A;else return}else{let A=this.buildExampleHelper({exampleId:t,schema:v.schema,example:l?.[b],visitedSchemaIds:a,depth:n+1,options:o,skipReadonly:c});if(A!=null)f[b]=A;else if(O)return}}return Sl.oneOf(RCi.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:o,skipReadonly:c});break}}return;case"unknown":if(r!=null){let f=YCi(r);if(f!=null)return Sl.unknown(f)}return o.ignoreOptionals||this.exceedsMaxDepth(n,o)?void 0:o.isParameter?Sl.primitive(Ha.string(o.name??"string")):Sl.map([{key:Ha.string("key"),value:Sl.primitive(Ha.string("value"))}]);case"array":{let f=nb_(r),s=[];if(f!=null&&f.length>0)for(let u of f){let l=this.buildExampleHelper({exampleId:t,example:u,schema:i.value,depth:n+1,visitedSchemaIds:a,options:o,skipReadonly:c});l!=null&&s.push(l)}else if(i.example!=null&&i.example.length>0)for(let u of i.example){let l=this.buildExampleHelper({exampleId:t,example:u,schema:i.value,depth:n+1,visitedSchemaIds:a,options:o,skipReadonly:c});l!=null&&s.push(l)}else{let u=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,depth:n+1,visitedSchemaIds:a,options:o,skipReadonly:c});u!=null&&s.push(u)}return Sl.array(s)}case"map":{let f=pja(r??i.example);if(f!=null&&Object.entries(f).length>0){let l=[];for(let[p,_]of Object.entries(f)){let h=this.buildExampleFromPrimitive({schema:i.key.schema,example:p,options:o}),y=this.buildExampleHelper({exampleId:t,example:_,schema:i.value,visitedSchemaIds:a,depth:n+1,options:o,skipReadonly:c});y!=null&&l.push({key:h,value:y})}return Sl.map(l)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return Sl.map([{key:Ha.string("key"),value:Sl.unknown(Sl.primitive(Ha.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:i.key.schema,example:void 0,options:{...o,name:"key"}}),u=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,visitedSchemaIds:a,depth:n+1,options:{...o,name:"value"},skipReadonly:c});return u!=null&&u.type!=="null"?Sl.map([{key:s,value:u}]):Sl.map([])}case"object":{let f={},s=i.fullExamples?.find(_=>_.name===t)??i.fullExamples?.find(_=>_.name==null)??i.fullExamples?.[0],u=pja(r)??(s!=null?pja(s.value):{})??{},l=this.getAllProperties(i),p=this.getAllRequiredProperties(i);for(let[_,h]of Object.entries(l)){if(c&&h.readonly||h.schema._visit({optional:m=>typeof m.availability=="string"&&m.availability==="Deprecated",primitive:()=>!1,object:()=>!1,array:()=>!1,map:()=>!1,enum:()=>!1,reference:()=>!1,literal:()=>!1,oneOf:()=>!1,nullable:()=>!1,unknown:()=>!1,_other:()=>!1}))continue;let y=_ in p,b=Object.keys(u).includes(_),v=u[_],O=this.getSchemaExample(h.schema),A=v??O,g=this.buildExampleHelper({schema:h.schema,exampleId:t,example:A,visitedSchemaIds:a,depth:n+1,options:{...o,name:_},skipReadonly:c});if(y&&g!=null)f[_]=g;else{if(y)return;(b&&g!=null||!o.ignoreOptionals&&g!=null)&&(f[_]=g)}}if(i.additionalProperties){for(let[_,h]of Object.entries(u))if(!(_ in f)){let y=this.buildExampleHelper({schema:ri.unknown({example:h,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0}),exampleId:t,example:h,visitedSchemaIds:a,depth:n+1,options:{...o,name:_},skipReadonly:c});y!=null&&(f[_]=y)}}return Sl.object({properties:f})}default:vt(i)}}mergeExampleWith(t,r){t._visit({array:Et,enum:Et,literal:Et,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:Et,unknown:Et,null:Et,_other:Et})}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){if(r==null){let a=t.schemas.find(o=>this.hasExample(o,0,new Set,{ignoreOptionals:!1,isParameter:!1}));return a??t.schemas[0]}return t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,o)=>o.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return ab_({schema:t,value:r})?5:0;case"object":{if(!Xc(r))return 0;let i=this.getAllProperties(t),n=0;for(let[a,o]of Object.entries(i))r[a]!=null?(n++,n+=this.calcExampleHeuristic(o.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(!Xc(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 o of t.properties)if(this.hasExample(o.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 o=this.hasExample(a,r,i,n);return i.delete(t.schema),o}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}getSchemaExample(t){return t._visit({primitive:r=>r.schema.example,object:r=>r.fullExamples?.[0]?.value,array:r=>r.example,map:r=>r.example,optional:r=>this.getSchemaExample(r.value),enum:r=>r.example,reference:r=>{let i=this.schemas[r.schema];return i!=null?this.getSchemaExample(i):void 0},literal:()=>{},oneOf:()=>{},nullable:r=>this.getSchemaExample(r.value),unknown:r=>r.example,_other:()=>{}})}buildExampleFromPrimitive({example:t,schema:r,options:i}){switch(r.type){case"string":return t!=null&&typeof t=="string"?Ha.string(t):r.example!=null?Ha.string(r.example):Ha.string(i.name??cu.STRING);case"base64":return t!=null&&typeof t=="string"?Ha.base64(t):r.example!=null?Ha.base64(r.example):Ha.base64(cu.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?Ha.boolean(t):r.example!=null?Ha.boolean(r.example):Ha.boolean(cu.BOOLEAN);case"date":return t!=null&&typeof t=="string"?Ha.date(t):r.example!=null?Ha.date(r.example):Ha.date(cu.DATE);case"datetime":return t!=null&&typeof t=="string"?Ha.datetime(t):r.example!=null?Ha.datetime(r.example):Ha.datetime(cu.DATE_TIME);case"double":return t!=null&&typeof t=="number"?Ha.double(t):r.example!=null?Ha.double(r.example):Ha.double(cu.DOUBLE);case"float":return t!=null&&typeof t=="number"?Ha.float(t):r.example!=null?Ha.float(r.example):Ha.float(cu.FLOAT);case"int":return t!=null&&typeof t=="number"?Ha.int(t):r.example!=null?Ha.int(r.example):Ha.int(cu.INT);case"int64":return t!=null&&typeof t=="number"?Ha.int64(t):r.example!=null?Ha.int64(r.example):Ha.int64(cu.INT64);case"uint":return t!=null&&typeof t=="number"?Ha.uint(t):r.example!=null?Ha.uint(r.example):Ha.uint(cu.UINT);case"uint64":return t!=null&&typeof t=="number"?Ha.uint64(t):r.example!=null?Ha.uint64(r.example):Ha.uint64(cu.UINT64);default:vt(r)}}};function ab_({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function vFt(e){switch(e.type){case"object":return ri.object({allOf:e.allOf,properties:e.properties.map(t=>JrM(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:void 0});case"array":return ri.array({description:e.description,availability:e.availability,value:vFt(e.value),generatedName:e.generatedName,title:e.title,namespace:e.namespace,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return ri.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,example:void 0,source:e.source,inline:void 0});case"literal":return ri.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName});case"nullable":return ri.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:vFt(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return ri.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:vFt(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return ri.primitive({description:e.description,availability:e.availability,schema:ob_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return ri.map({description:e.description,availability:e.availability,key:ri.primitive({description:e.key.description,availability:e.key.availability,schema:ob_(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:vFt(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return ri.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return ri.oneOf(KrM(e.value));case"unknown":return ri.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,namespace:void 0,groupName:void 0,description:void 0,availability:void 0});default:vt(e)}}function KrM(e){switch(e.type){case"discriminated":return Bhe.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:vFt(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,vFt(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return Bhe.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>vFt(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:vt(e)}}function ob_(e){switch(e.type){case"string":return Ln.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return Ln.base64({example:void 0});case"boolean":return Ln.boolean({default:e.default,example:void 0});case"date":return Ln.date({example:void 0});case"datetime":return Ln.datetime({example:void 0});case"double":return Ln.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 Ln.float({example:void 0});case"int":return Ln.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 Ln.int64({default:e.default,example:void 0});case"uint":return Ln.uint({default:void 0,example:void 0});case"uint64":return Ln.uint64({default:void 0,example:void 0});default:vt(e)}}function JrM(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:vFt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function tLo(e){return e.type!=="optional"&&e.type!=="nullable"}function Csc(e){return e==="POST"||e==="PUT"||e==="PATCH"}function _ja(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 rLo=class{schemas;context;globalHeaders;exampleTypeFactory;logger;missingExamples=[];constructor(t,r,i){this.schemas=t,this.context=r,this.globalHeaders=i,this.schemas=t,this.exampleTypeFactory=new XCi(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}addMissingExampleRecord(t,r,i,n,a={}){this.missingExamples.push({endpoint:t.path,method:t.method.toUpperCase(),type:r,schemaType:i,reason:n,operationSummary:t.summary,operationDescription:t.description,schemaDescription:a.schemaDescription,autoGeneratedExample:a.autoGeneratedExample})}writeMissingExamplesLog(){if(this.missingExamples.length===0)return;let t;if(this.context.source.type==="openapi"){let a=this.context.source.file,o=NJi.dirname(a),c=o;for(;c!==NJi.dirname(c);){let f=NJi.join(c,"fern");if(vUn.existsSync(f)&&vUn.statSync(f).isDirectory()){t=f;break}c=NJi.dirname(c)}t||(t=o)}else t=process.cwd();let r=t??process.cwd(),i=NJi.join(r,"schemas_missing_examples.txt"),n=["# Schemas Missing Examples Report",`# Generated on: ${new Date().toISOString()}`,`# Total missing examples: ${this.missingExamples.length}`,"",...this.missingExamples.flatMap(a=>{let o=[];if(o.push(`${a.method} ${a.endpoint} - ${a.type.toUpperCase()} (${a.schemaType}): ${a.reason}`),a.operationSummary&&o.push(` Operation: ${a.operationSummary}`),a.operationDescription&&a.operationDescription!==a.operationSummary&&o.push(` Description: ${a.operationDescription}`),a.schemaDescription&&o.push(` ${a.type==="request"?"Request":"Response"} Schema: ${a.schemaDescription}`),a.autoGeneratedExample){o.push(" Auto-generated example:");let f=JSON.stringify(a.autoGeneratedExample,null,4).split(`
1418
1418
  `).map(s=>` ${s}`).join(`
1419
1419
  `);o.push(f)}return o.push(""),o}),""].join(`