fern-api 3.24.1 → 3.24.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +4 -4
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1147,7 +1147,7 @@ ${gUp.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&c9s(th
|
|
|
1147
1147
|
`+N7i.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?N7i.default.cyan(MUp(t,this.opt.mask)):N7i.default.italic(N7i.default.dim("[hidden]")):this.opt.mask?MUp(t,this.opt.mask):N7i.default.italic(N7i.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 i0o=se(y1(),1);var M4p=se(x9s(),1),t0o=require("child_process"),oTn=require("fs"),e0o=se(require("path"),1),D4p=se(require("os"),1),B4p=require("crypto"),MGs=se(E4p(),1);var Xmo=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var Yga=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var Zmo=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var kmo=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function r0o(e="",t,r){let i=new DGs(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 S4p(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function igS(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 DGs=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=igS(t).map(n=>n.replace("\\ "," ")),i=r.shift();this.editor={args:r,bin:i}}createTemporaryFile(){try{let t=this.fileOptions.dir??D4p.default.tmpdir(),r=(0,B4p.randomUUID)(),i=S4p(this.fileOptions.prefix),n=S4p(this.fileOptions.postfix),a=`${i}${r}${n}`,o=e0o.default.resolve(t,a),c=e0o.default.resolve(t)+e0o.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,oTn.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new Xmo(t)}}readTemporaryFile(){try{let t=(0,oTn.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,M4p.detect)(t)??"utf8";MGs.default.encodingExists(r)||(r="utf8"),this.text=MGs.default.decode(t,r)}}catch(t){throw new Zmo(t)}}removeTemporaryFile(){try{(0,oTn.unlinkSync)(this.tempFile)}catch(t){throw new kmo(t)}}launchEditor(){try{let t=(0,t0o.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new Yga(t)}}launchEditorAsync(t){try{(0,t0o.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",i=>{this.lastExitStatus=i,setImmediate(t)})}catch(r){throw new Yga(r)}}};var I4p=se(Z_e(),1);var Xga=class extends b1{_run(t){this.done=t,this.editorResult=new I4p.Subject;let r=CQ(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"?i0o.default.dim("Received"):i0o.default.dim("Press <enter> to launch your preferred editor."),t&&(r=i0o.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),r0o(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 z4p=require("stream");var T4p=se(require("readline"),1),R4p=se(q4p(),1),L7i=class{constructor(t){this.rl||=T4p.default.createInterface(agS(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 agS(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 R4p.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var Zga=class extends L7i{constructor(t={}){super(t),this.log=new z4p.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return Rga(this.rl,this.bottomBar.split(`
|
|
1148
1148
|
`).length),this}updateBottomBar(t){return Rga(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+`
|
|
1149
1149
|
`}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&&wmo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var pO=se(Z_e(),1),Q4p=se(rga(),1);var n0o=se(Z_e(),1),N4p=se(rga(),1),a0o=function(e,t,r){return typeof e[t]!="function"?(0,n0o.of)(e):(0,n0o.from)((0,N4p.default)(e[t])(r).then(i=>(e[t]=i,e)))};var F4p={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}},uTn=class extends L7i{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,pO.from)(t):(0,pO.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,pO.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,pO.from)([t]),this.process=i.pipe((0,pO.concatMap)(this.processQuestion.bind(this)),(0,pO.publish)()),this.process.connect(),this.process.pipe((0,pO.reduce)((n,a)=>(F4p.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,pO.defer)(()=>(0,pO.of)(t).pipe((0,pO.concatMap)(this.setDefaultType.bind(this)),(0,pO.concatMap)(this.filterIfRunnable.bind(this)),(0,pO.concatMap)(()=>a0o(t,"message",this.answers)),(0,pO.concatMap)(()=>a0o(t,"default",this.answers)),(0,pO.concatMap)(()=>a0o(t,"choices",this.answers)),(0,pO.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,pO.defer)(()=>(0,pO.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,pO.defer)(()=>(0,pO.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&F4p.get(this.answers,t.name)!==void 0)return pO.EMPTY;if(t.when===!1)return pO.EMPTY;if(typeof t.when!="function")return(0,pO.of)(t);let{answers:r}=this;return(0,pO.defer)(()=>(0,pO.from)((0,Q4p.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,pO.filter)(i=>i!=null)))}};function U4p(e){let t=function(r,i){let n;try{n=new uTn(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",Nga),this.registerPrompt("input",z7i),this.registerPrompt("number",Fga),this.registerPrompt("confirm",Qga),this.registerPrompt("rawlist",Uga),this.registerPrompt("expand",Lga),this.registerPrompt("checkbox",Vga),this.registerPrompt("password",Wga),this.registerPrompt("editor",Xga)},t.restoreDefaultPrompts(),t}var IGs=U4p();function ugS(e,t){IGs.registerPrompt(e,t)}function sgS(){IGs.restoreDefaultPrompts()}var cgS={prompt:IGs,ui:{BottomBar:Zga,Prompt:uTn},createPromptModule:U4p,registerPrompt:ugS,restoreDefaultPrompts:sgS,Separator:jH},o0o=cgS;var OTn=require("path"),g3p=require("fs"),O3p=require("readline"),xLp="posthog-node";function zAS(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[E0o.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 E0o=class{constructor(t,r,i,n){this.name=xLp,this.name=xLp,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(zAS(t,{organization:r,projectId:c,prefix:i,severityAllowList:n}))}}};E0o.POSTHOG_ID_TAG="posthog_distinct_id";var A0o="0123456789abcdef",S0o=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+=A0o.charAt(this.bytes[r]>>>4),t+=A0o.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+=A0o.charAt(this.bytes[r]>>>4),t+=A0o.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}},h7s=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??NAS()}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 S0o.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,S0o.ofInner(t)}},NAS=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),GLp,y7s=()=>FAS().toString(),FAS=()=>(GLp||(GLp=new h7s)).generate();function QAS(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 UAS(e,t){global.process.on("uncaughtException",QAS(e,t))}function LAS(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var m0o,HLp,P0o;function VAS(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return P0o&&r.length===HLp||(HLp=r.length,P0o=r.reduce((i,n)=>{m0o||(m0o={});let a=m0o[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,m0o[n]=[s,u];break}}}return i},{})),P0o}function WAS(e){return typeof Event<"u"&&A3p(e,Event)}function xAS(e){return m3p(e,"Object")}function j7s(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return A3p(e,Error)}}function A3p(e,t){try{return e instanceof t}catch{return!1}}function GAS(e){return m3p(e,"ErrorEvent")}function m3p(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function HAS(e,t,r,i){let a=i&&i.mechanism||{handled:!0,type:"generic"},o=P3p(a,r,i);return{$exception_list:await Promise.all(o.map(async s=>{let u=await kAS(e,t,s);return u.value=u.value||"",u.type=u.type||"Error",u.mechanism=a,u}))}}function P3p(e,t,r){let i=KAS(e,t,r);return i.cause?[i,...P3p(e,i.cause,r)]:[i]}function KAS(e,t,r){if(j7s(t))return t;if(e.synthetic=!0,xAS(t)){let n=JAS(t);if(n)return n;let a=$AS(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 JAS(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(j7s(r))return r}}function $AS(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=XAS(e);if(GAS(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=YAS(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function YAS(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function XAS(e,t=40){let r=Object.keys(ZAS(e));r.sort();let i=r[0];if(!i)return"[object has no keys]";if(i.length>=t)return KLp(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:KLp(a,t)}return""}function KLp(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function ZAS(e){return j7s(e)?{message:e.message,name:e.name,stack:e.stack,...JLp(e)}:WAS(e)?{type:e.type,target:$Lp(e.target),currentTarget:$Lp(e.currentTarget),...JLp(e)}:e}function JLp(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 $Lp(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function kAS(e,t,r){let i={type:r.name||r.constructor.name,value:r.message},n=emS(e,r);for(let a of t)n=await a(n);return n.length&&(i.stacktrace={frames:n,type:"raw"}),i}function emS(e,t){return tmS(e(t.stack||"",1),e)}function tmS(e,t){let r=VAS(t);return e.forEach(i=>{i.filename&&(i.chunk_id=r[i.filename])}),e}var rmS=2e3,bTn=class e{static async captureException(t,r,i,n,a){let o={...a};n||(o.$process_person_profile=!1);let c=await HAS(this.stackParser,this.frameModifiers,r,i);t.capture({event:"$exception",distinctId:n||y7s(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(UAS(this.onException.bind(this),this.onFatalError.bind(this)),LAS(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(rmS)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function imS(e=process.argv[1]?(0,OTn.dirname)(process.argv[1]):process.cwd(),t=OTn.sep==="\\"){let r=t?YLp(e):e;return i=>{if(!i)return;let n=t?YLp(i):i,{dir:a,base:o,ext:c}=OTn.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 YLp(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var M0o=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)}}},w0o=new M0o(25),j3p=new M0o(20),w7s=7,nmS=1e3,amS=1e4;async function omS(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"||lmS(o)||fmS(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(j3p.get(n))continue;let a=t[n];if(!a)continue;a.sort((f,s)=>f-s);let o=pmS(a);if(o.every(f=>dmS(n,f)))continue;let c=_mS(w0o,n,{});i.push(umS(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&smS(e,w0o),w0o.reduce(),e}function umS(e,t,r){return new Promise(i=>{let n=(0,g3p.createReadStream)(e),a=(0,O3p.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(){j3p.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]=hmS(_,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 smS(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;cmS(r.lineno,r,i)}}function cmS(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=w3p(e);n<e;n++){let a=r[n];if(a===void 0){XLp(t);return}t.pre_context.push(a)}if(r[e]===void 0){XLp(t);return}t.context_line=r[e];let i=E3p(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 XLp(e){delete e.pre_context,delete e.context_line,delete e.post_context}function lmS(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function fmS(e){return e.lineno!==void 0&&e.lineno>amS||e.colno!==void 0&&e.colno>nmS}function dmS(e,t){let r=w0o.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 pmS(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=ZLp(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=ZLp(a)),t++}return n}function ZLp(e){return[w3p(e),E3p(e)]}function w3p(e){return Math.max(1,e-w7s)}function E3p(e){return e+w7s}function _mS(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function hmS(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 ymS="4.18.0",DH;(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"})(DH||(DH={}));var kLp;(function(e){e.Left="left",e.Right="right",e.Center="center"})(kLp||(kLp={}));var e3p;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(e3p||(e3p={}));var t3p;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(t3p||(t3p={}));var r3p;(function(e){e.Html="html",e.Text="text"})(r3p||(r3p={}));var i3p;(function(e){e.Number="number",e.Emoji="emoji"})(i3p||(i3p={}));var n3p;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(n3p||(n3p={}));var a3p;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(a3p||(a3p={}));var o3p;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(o3p||(o3p={}));var u3p;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(u3p||(u3p={}));var bmS=e=>{if("flags"in e){let t=gmS(e.flags),r=OmS(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,S3p(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,vmS(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function vmS(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 gmS=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,E7s(r)]).filter(([,t])=>t!==void 0)),OmS=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?S3p(i):void 0]}))},E7s=e=>e===void 0?void 0:e.variant??e.enabled,S3p=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},AmS=1,mmS=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"]),PmS="utf8";function jmS(e,t){if(!e||typeof e!="string"||wmS(e))throw new Error(t)}function wmS(e){return e.trim().length===0}function EmS(e){return e?.replace(/\/+$/,"")}async function SmS(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 s3p(){return new Date().getTime()}function p7s(){return new Date().toISOString()}function D0o(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function MmS(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function DmS(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 BmS(e,t=0,r){let i=DmS(e);return r?.has(i)?!1:parseInt(i,16)/4294967295<t}function c3p(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var sOa=String.fromCharCode,l3p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",j0o={};function ImS(e,t){if(!j0o[e]){j0o[e]={};for(let r=0;r<e.length;r++)j0o[e][e.charAt(r)]=r}return j0o[e][t]}var hTn={compressToBase64:function(e){if(e==null)return"";let t=hTn._compress(e,6,function(r){return l3p.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:hTn._decompress(e.length,32,function(t){return ImS(l3p,e.charAt(t))})},compress:function(e){return hTn._compress(e,16,function(t){return sOa(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:hTn._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=sOa(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=sOa(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++]=sOa(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++]=sOa(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++)}}},b7s=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)}},vTn=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()}},cOa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function f3p(e){if(e instanceof vTn){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 _7s(e){return typeof e=="object"&&(e instanceof vTn||e instanceof cOa)}function d3p(e){return typeof e=="object"&&e instanceof vTn&&e.status===413}var v7s;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(v7s||(v7s={}));var g7s=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new b7s,this._isInitialized=!1,jmS(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=EmS(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:_7s},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(DH.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(DH.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(DH.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=y7s();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=BmS(this.apiKey,AmS,mmS)?`${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=>bmS(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=E7s(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(v7s.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(DH.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(DH.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(DH.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(DH.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(DH.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=D0o(()=>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:p7s()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${s3p()}&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(hTn.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:p7s(),uuid:i?.uuid?i.uuid:y7s()};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 f3p(t)})}async flush(){let t=c3p([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),c3p([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(DH.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(DH.Queue)||[]).slice(n.length);this.setPersistedProperty(DH.Queue,_),t=_},c={api_key:this.apiKey,batch:a,sent_at:p7s()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${s3p()}&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(hTn.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:p=>d3p(p)?!1:_7s(p)};try{await this.fetchWithRetry(s,u,l)}catch(p){if(d3p(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 cOa||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,PmS)}catch{c=new TextEncoder().encode(o).length}return await SmS(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(u){throw new cOa(u)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new vTn(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(DH.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!_7s(n))throw n;await f3p(n)}};return Promise.race([new Promise((n,a)=>{D0o(()=>{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}},O7s=MmS();if(!O7s){let e=WLp();O7s=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 M3p=O7s,B0o=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()}},D3p=new B0o(async()=>{try{return await import("crypto")}catch{return}});async function CmS(){return await D3p.getValue()}var qmS=new B0o(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await D3p.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function TmS(){return await qmS.getValue()}async function RmS(e){let t=await CmS();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await TmS();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 zmS=60*1e3,NmS=1152921504606847e3,FmS=["is_not"],yTn=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)}},A7s=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||M3p,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=I3p(c,n,this.cohorts,this.debugMode):s=B3p(c,n,o),!s)return!1}if(a==null)return!0}return!(a!=null&&await p3p(t.key,r)>a/100)}async getMatchingVariant(t,r){let i=await p3p(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(zmS,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 yTn(`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 yTn(`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 yTn(`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 yTn&&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=D0o(()=>{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=D0o(()=>{a.abort()},this.timeout),i.signal=a.signal}try{return this.fetch(r,i)}finally{clearTimeout(n)}}};async function p3p(e,t,r=""){let i=await RmS(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/NmS}function B3p(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&&!FmS.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 _3p(String(n))&&String(o).match(String(n))!==null;case"not_regex":return _3p(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=QmS(String(n));if(s==null&&(s=h3p(n)),s==null)throw new v1(`Invalid date: ${n}`);let u=h3p(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new v1(`Unknown operator: ${a}`)}}function I3p(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 C3p(a,t,r,i)}function C3p(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=C3p(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=I3p(c,t,r,i):f=B3p(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 _3p(e){try{return new RegExp(e),!0}catch{return!1}}function h3p(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 QmS(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 m7s=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},UmS=100,y3p=30*1e3,LmS=50*1e3,P7s=class extends g7s{constructor(t,r={}){if(super(t,r),this._memoryStorage=new m7s,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,UmS):y3p,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 A7s({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 bTn(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||LmS}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):M3p(t,r)}getLibraryVersion(){return ymS}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=y3p){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=E7s(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");bTn.captureException(this,t,{syntheticException:n},r,i)}},b3p=/\(error: (.*)\)/,q3p=50,T3p="?";function VmS(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||T3p,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:v3p(n[3]),colno:v3p(n[4]),in_app:WmS(u||"",l),platform:"node:javascript"}}if(i.match(t))return{filename:i,platform:"node:javascript"}}}function WmS(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 v3p(e){return parseInt(e||"",10)||void 0}function xmS(e){return[90,VmS(e)]}function GmS(e){let r=[xmS(e)].sort((i,n)=>i[0]-n[0]).map(i=>i[1]);return(i,n=0)=>{let a=[],o=i.split(`
|
|
1150
|
-
`);for(let c=n;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let s=b3p.test(f)?f.replace(b3p,"$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>=q3p)break}}return HmS(a)}}function HmS(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,q3p).map(r=>({...r,filename:r.filename||KmS(t).filename,function:r.function||T3p}))}function KmS(e){return e[e.length-1]||{}}bTn.stackParser=GmS(imS());bTn.frameModifiers=[omS];var gTn=class extends P7s{getLibraryId(){return"posthog-node"}};var I0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new gTn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.24.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var lOa=class{async sendEvent(){}async identify(){}async flush(){}};var ATn=require("fs/promises"),F3p=require("os"),Q3p=require("path");var R3p=se(require("crypto")),q0o=new Uint8Array(256),C0o=q0o.length;function S7s(){return C0o>q0o.length-16&&(R3p.default.randomFillSync(q0o),C0o=0),q0o.slice(C0o,C0o+=16)}var TQ=[];for(let e=0;e<256;++e)TQ.push((e+256).toString(16).slice(1));function z3p(e,t=0){return TQ[e[t+0]]+TQ[e[t+1]]+TQ[e[t+2]]+TQ[e[t+3]]+"-"+TQ[e[t+4]]+TQ[e[t+5]]+"-"+TQ[e[t+6]]+TQ[e[t+7]]+"-"+TQ[e[t+8]]+TQ[e[t+9]]+"-"+TQ[e[t+10]]+TQ[e[t+11]]+TQ[e[t+12]]+TQ[e[t+13]]+TQ[e[t+14]]+TQ[e[t+15]]}var N3p=se(require("crypto")),M7s={randomUUID:N3p.default.randomUUID};function JmS(e,t,r){if(M7s.randomUUID&&!t&&!e)return M7s.randomUUID();e=e||{};let i=e.random||(e.rng||S7s)();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 z3p(i)}var ehe=JmS;var $mS="id",YmS=".fern",fOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new gTn(r),this.userId=t==null?void 0:$8s(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:"3.24.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Bt(Br.of((0,F3p.homedir)()),$e.of(YmS),$e.of($mS));await wi(t)||(await(0,ATn.mkdir)((0,Q3p.dirname)(t),{recursive:!0}),await(0,ATn.writeFile)(t,ehe())),this.persistedDistinctId=(await(0,ATn.readFile)(t)).toString()}return this.persistedDistinctId}};var D7s;async function mTn(){return D7s==null&&(D7s=await XmS()),D7s}async function XmS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new lOa;let r=await Yyo();return r!=null?new fOa({token:r,posthogApiKey:e}):await wqn()!=null?new I0o({posthogApiKey:e}):new fOa({token:void 0,posthogApiKey:e})}catch{return new lOa}}function dOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:ZmS}=Object.prototype,{getPrototypeOf:I7s}=Object,{iterator:R0o,toStringTag:L3p}=Symbol,z0o=(e=>t=>{let r=ZmS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),NNt=e=>(e=e.toLowerCase(),t=>z0o(t)===e),N0o=e=>t=>typeof t===e,{isArray:jTn}=Array,PTn=N0o("undefined");function pOa(e){return e!==null&&!PTn(e)&&e.constructor!==null&&!PTn(e.constructor)&&BH(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var V3p=NNt("ArrayBuffer");function kmS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&V3p(e.buffer),t}var e0S=N0o("string"),BH=N0o("function"),W3p=N0o("number"),_Oa=e=>e!==null&&typeof e=="object",t0S=e=>e===!0||e===!1,T0o=e=>{if(z0o(e)!=="object")return!1;let t=I7s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(L3p in e)&&!(R0o in e)},r0S=e=>{if(!_Oa(e)||pOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},i0S=NNt("Date"),n0S=NNt("File"),a0S=NNt("Blob"),o0S=NNt("FileList"),u0S=e=>_Oa(e)&&BH(e.pipe),s0S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||BH(e.append)&&((t=z0o(e))==="formdata"||t==="object"&&BH(e.toString)&&e.toString()==="[object FormData]"))},c0S=NNt("URLSearchParams"),[l0S,f0S,d0S,p0S]=["ReadableStream","Request","Response","Headers"].map(NNt),_0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function hOa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),jTn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(pOa(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 x3p(e,t){if(pOa(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 K7i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,G3p=e=>!PTn(e)&&e!==K7i;function B7s(){let{caseless:e,skipUndefined:t}=G3p(this)&&this||{},r={},i=(n,a)=>{let o=e&&x3p(r,a)||a;T0o(r[o])&&T0o(n)?r[o]=B7s(r[o],n):T0o(n)?r[o]=B7s({},n):jTn(n)?r[o]=n.slice():(!t||!PTn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&hOa(arguments[n],i);return r}var h0S=(e,t,r,{allOwnKeys:i}={})=>(hOa(t,(n,a)=>{r&&BH(n)?e[a]=dOa(n,r):e[a]=n},{allOwnKeys:i}),e),y0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),b0S=(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)},v0S=(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&&I7s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},g0S=(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},O0S=e=>{if(!e)return null;if(jTn(e))return e;let t=e.length;if(!W3p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},A0S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&I7s(Uint8Array)),m0S=(e,t)=>{let i=(e&&e[R0o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},P0S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},j0S=NNt("HTMLFormElement"),w0S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),U3p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),E0S=NNt("RegExp"),H3p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};hOa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},S0S=e=>{H3p(e,(t,r)=>{if(BH(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(BH(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+"'")})}})},M0S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return jTn(e)?i(e):i(String(e).split(t)),r},D0S=()=>{},B0S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function I0S(e){return!!(e&&BH(e.append)&&e[L3p]==="FormData"&&e[R0o])}var C0S=e=>{let t=new Array(10),r=(i,n)=>{if(_Oa(i)){if(t.indexOf(i)>=0)return;if(pOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=jTn(i)?[]:{};return hOa(i,(o,c)=>{let f=r(o,n+1);!PTn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},q0S=NNt("AsyncFunction"),T0S=e=>e&&(_Oa(e)||BH(e))&&BH(e.then)&&BH(e.catch),K3p=((e,t)=>e?setImmediate:t?((r,i)=>(K7i.addEventListener("message",({source:n,data:a})=>{n===K7i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),K7i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",BH(K7i.postMessage)),R0S=typeof queueMicrotask<"u"?queueMicrotask.bind(K7i):typeof process<"u"&&process.nextTick||K3p,z0S=e=>e!=null&&BH(e[R0o]),er={isArray:jTn,isArrayBuffer:V3p,isBuffer:pOa,isFormData:s0S,isArrayBufferView:kmS,isString:e0S,isNumber:W3p,isBoolean:t0S,isObject:_Oa,isPlainObject:T0o,isEmptyObject:r0S,isReadableStream:l0S,isRequest:f0S,isResponse:d0S,isHeaders:p0S,isUndefined:PTn,isDate:i0S,isFile:n0S,isBlob:a0S,isRegExp:E0S,isFunction:BH,isStream:u0S,isURLSearchParams:c0S,isTypedArray:A0S,isFileList:o0S,forEach:hOa,merge:B7s,extend:h0S,trim:_0S,stripBOM:y0S,inherits:b0S,toFlatObject:v0S,kindOf:z0o,kindOfTest:NNt,endsWith:g0S,toArray:O0S,forEachEntry:m0S,matchAll:P0S,isHTMLForm:j0S,hasOwnProperty:U3p,hasOwnProp:U3p,reduceDescriptors:H3p,freezeMethods:S0S,toObjectSet:M0S,toCamelCase:w0S,noop:D0S,toFiniteNumber:B0S,findKey:x3p,global:K7i,isContextDefined:G3p,isSpecCompliantForm:I0S,toJSONObject:C0S,isAsyncFn:q0S,isThenable:T0S,setImmediate:K3p,asap:R0S,isIterable:z0S};function wTn(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)}er.inherits(wTn,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:er.toJSONObject(this.config),code:this.code,status:this.status}}});var J3p=wTn.prototype,$3p={};["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=>{$3p[e]={value:e}});Object.defineProperties(wTn,$3p);Object.defineProperty(J3p,"isAxiosError",{value:!0});wTn.from=(e,t,r,i,n,a)=>{let o=Object.create(J3p);er.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 wTn.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 ha=wTn;var Y3p=se(IGi(),1),F0o=Y3p.default;function C7s(e){return er.isPlainObject(e)||er.isArray(e)}function Z3p(e){return er.endsWith(e,"[]")?e.slice(0,-2):e}function X3p(e,t,r){return e?e.concat(t).map(function(n,a){return n=Z3p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function N0S(e){return er.isArray(e)&&!e.some(C7s)}var F0S=er.toFlatObject(er,{},null,function(t){return/^is[A-Z]/.test(t)});function Q0S(e,t,r){if(!er.isObject(e))throw new TypeError("target must be an object");t=t||new(F0o||FormData),r=er.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!er.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&er.isSpecCompliantForm(t);if(!er.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(er.isDate(h))return h.toISOString();if(er.isBoolean(h))return h.toString();if(!f&&er.isBlob(h))throw new ha("Blob is not supported. Use a Buffer instead.");return er.isArrayBuffer(h)||er.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(er.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(er.isArray(h)&&N0S(h)||(er.isFileList(h)||er.endsWith(y,"[]"))&&(v=er.toArray(h)))return y=Z3p(y),v.forEach(function(A,g){!(er.isUndefined(A)||A===null)&&t.append(o===!0?X3p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return C7s(h)?!0:(t.append(X3p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(F0S,{defaultVisitor:u,convertValue:s,isVisitable:C7s});function _(h,y){if(!er.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),er.forEach(h,function(v,O){(!(er.isUndefined(v)||v===null)&&n.call(t,v,er.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!er.isObject(e))throw new TypeError("data must be an object");return _(e),t}var NBi=Q0S;function k3p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function e8p(e,t){this._pairs=[],e&&NBi(e,this,t)}var t8p=e8p.prototype;t8p.append=function(t,r){this._pairs.push([t,r])};t8p.toString=function(t){let r=t?function(i){return t.call(this,i,k3p)}:k3p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var r8p=e8p;function U0S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function J7i(e,t,r){if(!t)return e;let i=r&&r.encode||U0S;er.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=er.isURLSearchParams(t)?t.toString():new r8p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var q7s=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){er.forEach(this.handlers,function(i){i!==null&&t(i)})}},T7s=q7s;var ETn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var o8p=se(require("crypto"),1);var i8p=se(require("url"),1),n8p=i8p.default.URLSearchParams;var R7s="abcdefghijklmnopqrstuvwxyz",a8p="0123456789",u8p={DIGIT:a8p,ALPHA:R7s,ALPHA_DIGIT:R7s+R7s.toUpperCase()+a8p},L0S=(e=16,t=u8p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);o8p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},s8p={isNode:!0,classes:{URLSearchParams:n8p,FormData:F0o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:u8p,generateString:L0S,protocols:["http","https","file","data"]};var F7s={};Yt(F7s,{hasBrowserEnv:()=>N7s,hasStandardBrowserEnv:()=>V0S,hasStandardBrowserWebWorkerEnv:()=>W0S,navigator:()=>z7s,origin:()=>x0S});var N7s=typeof window<"u"&&typeof document<"u",z7s=typeof navigator=="object"&&navigator||void 0,V0S=N7s&&(!z7s||["ReactNative","NativeScript","NS"].indexOf(z7s.product)<0),W0S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",x0S=N7s&&window.location.href||"http://localhost";var OA={...F7s,...s8p};function Q7s(e,t){return NBi(e,new OA.classes.URLSearchParams,{visitor:function(r,i,n,a){return OA.isNode&&er.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function G0S(e){return er.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function H0S(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 K0S(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&&er.isArray(n)?n.length:o,f?(er.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!er.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&er.isArray(n[o])&&(n[o]=H0S(n[o])),!c)}if(er.isFormData(e)&&er.isFunction(e.entries)){let r={};return er.forEachEntry(e,(i,n)=>{t(G0S(i),n,r,0)}),r}return null}var Q0o=K0S;function J0S(e,t,r){if(er.isString(e))try{return(t||JSON.parse)(e),er.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var U7s={transitional:ETn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=er.isObject(t);if(a&&er.isHTMLForm(t)&&(t=new FormData(t)),er.isFormData(t))return n?JSON.stringify(Q0o(t)):t;if(er.isArrayBuffer(t)||er.isBuffer(t)||er.isStream(t)||er.isFile(t)||er.isBlob(t)||er.isReadableStream(t))return t;if(er.isArrayBufferView(t))return t.buffer;if(er.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 Q7s(t,this.formSerializer).toString();if((c=er.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return NBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),J0S(t)):t}],transformResponse:[function(t){let r=this.transitional||U7s.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(er.isResponse(t)||er.isReadableStream(t))return t;if(t&&er.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"?ha.from(c,ha.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}}};er.forEach(["delete","get","head","post","put","patch"],e=>{U7s.headers[e]={}});var STn=U7s;var $0S=er.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"]),c8p=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1150
|
+
`);for(let c=n;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let s=b3p.test(f)?f.replace(b3p,"$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>=q3p)break}}return HmS(a)}}function HmS(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,q3p).map(r=>({...r,filename:r.filename||KmS(t).filename,function:r.function||T3p}))}function KmS(e){return e[e.length-1]||{}}bTn.stackParser=GmS(imS());bTn.frameModifiers=[omS];var gTn=class extends P7s{getLibraryId(){return"posthog-node"}};var I0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new gTn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.24.2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var lOa=class{async sendEvent(){}async identify(){}async flush(){}};var ATn=require("fs/promises"),F3p=require("os"),Q3p=require("path");var R3p=se(require("crypto")),q0o=new Uint8Array(256),C0o=q0o.length;function S7s(){return C0o>q0o.length-16&&(R3p.default.randomFillSync(q0o),C0o=0),q0o.slice(C0o,C0o+=16)}var TQ=[];for(let e=0;e<256;++e)TQ.push((e+256).toString(16).slice(1));function z3p(e,t=0){return TQ[e[t+0]]+TQ[e[t+1]]+TQ[e[t+2]]+TQ[e[t+3]]+"-"+TQ[e[t+4]]+TQ[e[t+5]]+"-"+TQ[e[t+6]]+TQ[e[t+7]]+"-"+TQ[e[t+8]]+TQ[e[t+9]]+"-"+TQ[e[t+10]]+TQ[e[t+11]]+TQ[e[t+12]]+TQ[e[t+13]]+TQ[e[t+14]]+TQ[e[t+15]]}var N3p=se(require("crypto")),M7s={randomUUID:N3p.default.randomUUID};function JmS(e,t,r){if(M7s.randomUUID&&!t&&!e)return M7s.randomUUID();e=e||{};let i=e.random||(e.rng||S7s)();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 z3p(i)}var ehe=JmS;var $mS="id",YmS=".fern",fOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new gTn(r),this.userId=t==null?void 0:$8s(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:"3.24.2",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Bt(Br.of((0,F3p.homedir)()),$e.of(YmS),$e.of($mS));await wi(t)||(await(0,ATn.mkdir)((0,Q3p.dirname)(t),{recursive:!0}),await(0,ATn.writeFile)(t,ehe())),this.persistedDistinctId=(await(0,ATn.readFile)(t)).toString()}return this.persistedDistinctId}};var D7s;async function mTn(){return D7s==null&&(D7s=await XmS()),D7s}async function XmS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new lOa;let r=await Yyo();return r!=null?new fOa({token:r,posthogApiKey:e}):await wqn()!=null?new I0o({posthogApiKey:e}):new fOa({token:void 0,posthogApiKey:e})}catch{return new lOa}}function dOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:ZmS}=Object.prototype,{getPrototypeOf:I7s}=Object,{iterator:R0o,toStringTag:L3p}=Symbol,z0o=(e=>t=>{let r=ZmS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),NNt=e=>(e=e.toLowerCase(),t=>z0o(t)===e),N0o=e=>t=>typeof t===e,{isArray:jTn}=Array,PTn=N0o("undefined");function pOa(e){return e!==null&&!PTn(e)&&e.constructor!==null&&!PTn(e.constructor)&&BH(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var V3p=NNt("ArrayBuffer");function kmS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&V3p(e.buffer),t}var e0S=N0o("string"),BH=N0o("function"),W3p=N0o("number"),_Oa=e=>e!==null&&typeof e=="object",t0S=e=>e===!0||e===!1,T0o=e=>{if(z0o(e)!=="object")return!1;let t=I7s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(L3p in e)&&!(R0o in e)},r0S=e=>{if(!_Oa(e)||pOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},i0S=NNt("Date"),n0S=NNt("File"),a0S=NNt("Blob"),o0S=NNt("FileList"),u0S=e=>_Oa(e)&&BH(e.pipe),s0S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||BH(e.append)&&((t=z0o(e))==="formdata"||t==="object"&&BH(e.toString)&&e.toString()==="[object FormData]"))},c0S=NNt("URLSearchParams"),[l0S,f0S,d0S,p0S]=["ReadableStream","Request","Response","Headers"].map(NNt),_0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function hOa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),jTn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(pOa(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 x3p(e,t){if(pOa(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 K7i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,G3p=e=>!PTn(e)&&e!==K7i;function B7s(){let{caseless:e,skipUndefined:t}=G3p(this)&&this||{},r={},i=(n,a)=>{let o=e&&x3p(r,a)||a;T0o(r[o])&&T0o(n)?r[o]=B7s(r[o],n):T0o(n)?r[o]=B7s({},n):jTn(n)?r[o]=n.slice():(!t||!PTn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&hOa(arguments[n],i);return r}var h0S=(e,t,r,{allOwnKeys:i}={})=>(hOa(t,(n,a)=>{r&&BH(n)?e[a]=dOa(n,r):e[a]=n},{allOwnKeys:i}),e),y0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),b0S=(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)},v0S=(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&&I7s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},g0S=(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},O0S=e=>{if(!e)return null;if(jTn(e))return e;let t=e.length;if(!W3p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},A0S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&I7s(Uint8Array)),m0S=(e,t)=>{let i=(e&&e[R0o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},P0S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},j0S=NNt("HTMLFormElement"),w0S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),U3p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),E0S=NNt("RegExp"),H3p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};hOa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},S0S=e=>{H3p(e,(t,r)=>{if(BH(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(BH(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+"'")})}})},M0S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return jTn(e)?i(e):i(String(e).split(t)),r},D0S=()=>{},B0S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function I0S(e){return!!(e&&BH(e.append)&&e[L3p]==="FormData"&&e[R0o])}var C0S=e=>{let t=new Array(10),r=(i,n)=>{if(_Oa(i)){if(t.indexOf(i)>=0)return;if(pOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=jTn(i)?[]:{};return hOa(i,(o,c)=>{let f=r(o,n+1);!PTn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},q0S=NNt("AsyncFunction"),T0S=e=>e&&(_Oa(e)||BH(e))&&BH(e.then)&&BH(e.catch),K3p=((e,t)=>e?setImmediate:t?((r,i)=>(K7i.addEventListener("message",({source:n,data:a})=>{n===K7i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),K7i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",BH(K7i.postMessage)),R0S=typeof queueMicrotask<"u"?queueMicrotask.bind(K7i):typeof process<"u"&&process.nextTick||K3p,z0S=e=>e!=null&&BH(e[R0o]),er={isArray:jTn,isArrayBuffer:V3p,isBuffer:pOa,isFormData:s0S,isArrayBufferView:kmS,isString:e0S,isNumber:W3p,isBoolean:t0S,isObject:_Oa,isPlainObject:T0o,isEmptyObject:r0S,isReadableStream:l0S,isRequest:f0S,isResponse:d0S,isHeaders:p0S,isUndefined:PTn,isDate:i0S,isFile:n0S,isBlob:a0S,isRegExp:E0S,isFunction:BH,isStream:u0S,isURLSearchParams:c0S,isTypedArray:A0S,isFileList:o0S,forEach:hOa,merge:B7s,extend:h0S,trim:_0S,stripBOM:y0S,inherits:b0S,toFlatObject:v0S,kindOf:z0o,kindOfTest:NNt,endsWith:g0S,toArray:O0S,forEachEntry:m0S,matchAll:P0S,isHTMLForm:j0S,hasOwnProperty:U3p,hasOwnProp:U3p,reduceDescriptors:H3p,freezeMethods:S0S,toObjectSet:M0S,toCamelCase:w0S,noop:D0S,toFiniteNumber:B0S,findKey:x3p,global:K7i,isContextDefined:G3p,isSpecCompliantForm:I0S,toJSONObject:C0S,isAsyncFn:q0S,isThenable:T0S,setImmediate:K3p,asap:R0S,isIterable:z0S};function wTn(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)}er.inherits(wTn,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:er.toJSONObject(this.config),code:this.code,status:this.status}}});var J3p=wTn.prototype,$3p={};["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=>{$3p[e]={value:e}});Object.defineProperties(wTn,$3p);Object.defineProperty(J3p,"isAxiosError",{value:!0});wTn.from=(e,t,r,i,n,a)=>{let o=Object.create(J3p);er.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 wTn.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 ha=wTn;var Y3p=se(IGi(),1),F0o=Y3p.default;function C7s(e){return er.isPlainObject(e)||er.isArray(e)}function Z3p(e){return er.endsWith(e,"[]")?e.slice(0,-2):e}function X3p(e,t,r){return e?e.concat(t).map(function(n,a){return n=Z3p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function N0S(e){return er.isArray(e)&&!e.some(C7s)}var F0S=er.toFlatObject(er,{},null,function(t){return/^is[A-Z]/.test(t)});function Q0S(e,t,r){if(!er.isObject(e))throw new TypeError("target must be an object");t=t||new(F0o||FormData),r=er.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!er.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&er.isSpecCompliantForm(t);if(!er.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(er.isDate(h))return h.toISOString();if(er.isBoolean(h))return h.toString();if(!f&&er.isBlob(h))throw new ha("Blob is not supported. Use a Buffer instead.");return er.isArrayBuffer(h)||er.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(er.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(er.isArray(h)&&N0S(h)||(er.isFileList(h)||er.endsWith(y,"[]"))&&(v=er.toArray(h)))return y=Z3p(y),v.forEach(function(A,g){!(er.isUndefined(A)||A===null)&&t.append(o===!0?X3p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return C7s(h)?!0:(t.append(X3p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(F0S,{defaultVisitor:u,convertValue:s,isVisitable:C7s});function _(h,y){if(!er.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),er.forEach(h,function(v,O){(!(er.isUndefined(v)||v===null)&&n.call(t,v,er.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!er.isObject(e))throw new TypeError("data must be an object");return _(e),t}var NBi=Q0S;function k3p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function e8p(e,t){this._pairs=[],e&&NBi(e,this,t)}var t8p=e8p.prototype;t8p.append=function(t,r){this._pairs.push([t,r])};t8p.toString=function(t){let r=t?function(i){return t.call(this,i,k3p)}:k3p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var r8p=e8p;function U0S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function J7i(e,t,r){if(!t)return e;let i=r&&r.encode||U0S;er.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=er.isURLSearchParams(t)?t.toString():new r8p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var q7s=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){er.forEach(this.handlers,function(i){i!==null&&t(i)})}},T7s=q7s;var ETn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var o8p=se(require("crypto"),1);var i8p=se(require("url"),1),n8p=i8p.default.URLSearchParams;var R7s="abcdefghijklmnopqrstuvwxyz",a8p="0123456789",u8p={DIGIT:a8p,ALPHA:R7s,ALPHA_DIGIT:R7s+R7s.toUpperCase()+a8p},L0S=(e=16,t=u8p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);o8p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},s8p={isNode:!0,classes:{URLSearchParams:n8p,FormData:F0o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:u8p,generateString:L0S,protocols:["http","https","file","data"]};var F7s={};Yt(F7s,{hasBrowserEnv:()=>N7s,hasStandardBrowserEnv:()=>V0S,hasStandardBrowserWebWorkerEnv:()=>W0S,navigator:()=>z7s,origin:()=>x0S});var N7s=typeof window<"u"&&typeof document<"u",z7s=typeof navigator=="object"&&navigator||void 0,V0S=N7s&&(!z7s||["ReactNative","NativeScript","NS"].indexOf(z7s.product)<0),W0S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",x0S=N7s&&window.location.href||"http://localhost";var OA={...F7s,...s8p};function Q7s(e,t){return NBi(e,new OA.classes.URLSearchParams,{visitor:function(r,i,n,a){return OA.isNode&&er.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function G0S(e){return er.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function H0S(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 K0S(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&&er.isArray(n)?n.length:o,f?(er.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!er.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&er.isArray(n[o])&&(n[o]=H0S(n[o])),!c)}if(er.isFormData(e)&&er.isFunction(e.entries)){let r={};return er.forEachEntry(e,(i,n)=>{t(G0S(i),n,r,0)}),r}return null}var Q0o=K0S;function J0S(e,t,r){if(er.isString(e))try{return(t||JSON.parse)(e),er.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var U7s={transitional:ETn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=er.isObject(t);if(a&&er.isHTMLForm(t)&&(t=new FormData(t)),er.isFormData(t))return n?JSON.stringify(Q0o(t)):t;if(er.isArrayBuffer(t)||er.isBuffer(t)||er.isStream(t)||er.isFile(t)||er.isBlob(t)||er.isReadableStream(t))return t;if(er.isArrayBufferView(t))return t.buffer;if(er.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 Q7s(t,this.formSerializer).toString();if((c=er.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return NBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),J0S(t)):t}],transformResponse:[function(t){let r=this.transitional||U7s.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(er.isResponse(t)||er.isReadableStream(t))return t;if(t&&er.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"?ha.from(c,ha.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}}};er.forEach(["delete","get","head","post","put","patch"],e=>{U7s.headers[e]={}});var STn=U7s;var $0S=er.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"]),c8p=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1151
1151
|
`).forEach(function(o){n=o.indexOf(":"),r=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!r||t[r]&&$0S[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var l8p=Symbol("internals");function yOa(e){return e&&String(e).trim().toLowerCase()}function U0o(e){return e===!1||e==null?e:er.isArray(e)?e.map(U0o):String(e)}function Y0S(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 X0S=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function L7s(e,t,r,i,n){if(er.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!er.isString(t)){if(er.isString(i))return t.indexOf(i)!==-1;if(er.isRegExp(i))return i.test(t)}}function Z0S(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function k0S(e,t){let r=er.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 MTn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,f,s){let u=yOa(f);if(!u)throw new Error("header name must be a non-empty string");let l=er.findKey(n,u);(!l||n[l]===void 0||s===!0||s===void 0&&n[l]!==!1)&&(n[l||f]=U0o(c))}let o=(c,f)=>er.forEach(c,(s,u)=>a(s,u,f));if(er.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(er.isString(t)&&(t=t.trim())&&!X0S(t))o(c8p(t),r);else if(er.isObject(t)&&er.isIterable(t)){let c={},f,s;for(let u of t){if(!er.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[s=u[0]]=(f=c[s])?er.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=yOa(t),t){let i=er.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return Y0S(n);if(er.isFunction(r))return r.call(this,n,i);if(er.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=yOa(t),t){let i=er.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||L7s(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(o){if(o=yOa(o),o){let c=er.findKey(i,o);c&&(!r||L7s(i,i[c],c,r))&&(delete i[c],n=!0)}}return er.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||L7s(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return er.forEach(this,(n,a)=>{let o=er.findKey(i,a);if(o){r[o]=U0o(n),delete r[a];return}let c=t?Z0S(a):String(a).trim();c!==a&&delete r[a],r[c]=U0o(n),i[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return er.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&er.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(`
|
|
1152
1152
|
`)}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[l8p]=this[l8p]={accessors:{}}).accessors,n=this.prototype;function a(o){let c=yOa(o);i[c]||(k0S(n,o),i[c]=!0)}return er.isArray(t)?t.forEach(a):a(t),this}};MTn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);er.reduceDescriptors(MTn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});er.freezeMethods(MTn);var QS=MTn;function bOa(e,t){let r=this||STn,i=t||r,n=QS.from(i.headers),a=i.data;return er.forEach(e,function(c){a=c.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function vOa(e){return!!(e&&e.__CANCEL__)}function f8p(e,t,r){ha.call(this,e??"canceled",ha.ERR_CANCELED,t,r),this.name="CanceledError"}er.inherits(f8p,ha,{__CANCEL__:!0});var the=f8p;function o6t(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new ha("Request failed with status code "+r.status,[ha.ERR_BAD_REQUEST,ha.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function V7s(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function W7s(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function $7i(e,t,r){let i=!V7s(t);return e&&(i||r==!1)?W7s(e,t):t}var S8p=se(u0o(),1),M8p=se(require("http"),1),D8p=se(require("https"),1),B8p=se(require("util"),1),I8p=se(xGs(),1),Ubi=se(require("zlib"),1);var Y7i="1.12.2";function gOa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var ePS=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function x7s(e,t,r){let i=r&&r.Blob||OA.classes.Blob,n=gOa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=ePS.exec(e);if(!a)throw new ha("Invalid URL",ha.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 ha("Blob is not supported",ha.ERR_NOT_SUPPORT);return new i([s],{type:o})}return s}throw new ha("Unsupported protocol "+n,ha.ERR_NOT_SUPPORT)}var Z7i=se(require("stream"),1);var d8p=se(require("stream"),1);var G7s=Symbol("internals"),H7s=class extends d8p.default.Transform{constructor(t){t=er.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!er.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[G7s]={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[G7s];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[G7s],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)})}},K7s=H7s;var C8p=require("events");var _8p=se(require("util"),1),h8p=require("stream");var{asyncIterator:p8p}=Symbol,tPS=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[p8p]?yield*e[p8p]():yield e},L0o=tPS;var rPS=OA.ALPHABET.ALPHA_DIGIT+"-_",OOa=typeof TextEncoder=="function"?new TextEncoder:new _8p.default.TextEncoder,X7i=`\r
|
|
1153
1153
|
`,iPS=OOa.encode(X7i),nPS=2,J7s=class{constructor(t,r){let{escapeName:i}=this.constructor,n=er.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${X7i}`;n?r=OOa.encode(String(r).replace(/\r?\n|\r\n?/g,X7i)):a+=`Content-Type: ${r.type||"application/octet-stream"}${X7i}`,this.headers=OOa.encode(a+X7i),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+nPS,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;er.isTypedArray(t)?yield t:yield*L0o(t),yield iPS}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},aPS=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+OA.generateString(n,rPS)}=r||{};if(!er.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=OOa.encode("--"+a+X7i),c=OOa.encode("--"+a+"--"+X7i),f=c.byteLength,s=Array.from(e.entries()).map(([l,p])=>{let _=new J7s(l,p);return f+=_.size,_});f+=o.byteLength*s.length,f=er.toFiniteNumber(f);let u={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(u["Content-Length"]=f),t&&t(u),h8p.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},y8p=aPS;var b8p=se(require("stream"),1),$7s=class extends b8p.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=$7s;var oPS=(e,t)=>er.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,g8p=oPS;function uPS(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 O8p=uPS;function sPS(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 A8p=sPS;var Qbi=(e,t,r=3)=>{let i=0,n=O8p(50,250);return A8p(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)},DTn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},BTn=e=>(...t)=>er.asap(()=>e(...t));function Y7s(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 m8p={flush:Ubi.default.constants.Z_SYNC_FLUSH,finishFlush:Ubi.default.constants.Z_SYNC_FLUSH},cPS={flush:Ubi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:Ubi.default.constants.BROTLI_OPERATION_FLUSH},P8p=er.isFunction(Ubi.default.createBrotliDecompress),{http:lPS,https:fPS}=I8p.default,dPS=/https:?/,j8p=OA.protocols.map(e=>e+":"),w8p=(e,[t,r])=>(e.on("end",r).on("error",r),t);function pPS(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function q8p(e,t,r){let i=t;if(!i&&i!==!1){let n=S8p.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){q8p(a,t,a.href)}}var _PS=typeof process<"u"&&er.kindOf(process)==="process",hPS=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)}),yPS=({address:e,family:t})=>{if(!er.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},E8p=(e,t)=>yPS(er.isObject(e)?e:{address:e,family:t}),T8p=_PS&&function(t){return hPS(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 J=g8p(c,ue=>er.isArray(ue)?ue:[ue]);c=(ue,de,U)=>{J(ue,de,(W,Te,ce)=>{if(W)return U(W);let we=er.isArray(Te)?Te.map(Le=>E8p(Le)):[E8p(Te,ce)];de.all?U(W,we):U(W,we[0].address,we[0].family)})}}let y=new C8p.EventEmitter,b=()=>{t.cancelToken&&t.cancelToken.unsubscribe(v),t.signal&&t.signal.removeEventListener("abort",v),y.removeAllListeners()};a((J,ue)=>{p=!0,ue&&(_=!0,b())});function v(J){y.emit("abort",!J||J.type?new the(null,t,h):J)}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=$7i(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(Y7s(ue)>t.maxContentLength)return n(new ha("maxContentLength size of "+t.maxContentLength+" exceeded",ha.ERR_BAD_RESPONSE,t))}let J;if(l!=="GET")return o6t(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{J=x7s(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(ue){throw ha.from(ue,ha.ERR_BAD_REQUEST,t)}return s==="text"?(J=J.toString(u),(!u||u==="utf8")&&(J=er.stripBOM(J))):s==="stream"&&(J=Z7i.default.Readable.from(J)),o6t(i,n,{data:J,status:200,statusText:"OK",headers:new QS,config:t})}if(j8p.indexOf(g)===-1)return n(new ha("Unsupported protocol "+g,ha.ERR_BAD_REQUEST,t));let m=QS.from(t.headers).normalize();m.set("User-Agent","axios/"+Y7i,!1);let{onUploadProgress:j,onDownloadProgress:M}=t,E=t.maxRate,D,B;if(er.isSpecCompliantForm(o)){let J=m.getContentType(/boundary=([-_\w\d]{10,70})/i);o=y8p(o,ue=>{m.set(ue)},{tag:`axios-${Y7i}-boundary`,boundary:J&&J[1]||void 0})}else if(er.isFormData(o)&&er.isFunction(o.getHeaders)){if(m.set(o.getHeaders()),!m.hasContentLength())try{let J=await B8p.default.promisify(o.getLength).call(o);Number.isFinite(J)&&J>=0&&m.setContentLength(J)}catch{}}else if(er.isBlob(o)||er.isFile(o))o.size&&m.setContentType(o.type||"application/octet-stream"),m.setContentLength(o.size||0),o=Z7i.default.Readable.from(L0o(o));else if(o&&!er.isStream(o)){if(!Buffer.isBuffer(o))if(er.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(er.isString(o))o=Buffer.from(o,"utf-8");else return n(new ha("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",ha.ERR_BAD_REQUEST,t));if(m.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return n(new ha("Request body larger than maxBodyLength limit",ha.ERR_BAD_REQUEST,t))}let F=er.toFiniteNumber(m.getContentLength());er.isArray(E)?(D=E[0],B=E[1]):D=B=E,o&&(j||D)&&(er.isStream(o)||(o=Z7i.default.Readable.from(o,{objectMode:!1})),o=Z7i.default.pipeline([o,new K7s({maxRate:er.toFiniteNumber(D)})],er.noop),j&&o.on("progress",w8p(o,DTn(F,Qbi(BTn(j),!1,3)))));let N;if(t.auth){let J=t.auth.username||"",ue=t.auth.password||"";N=J+":"+ue}if(!N&&A.username){let J=A.username,ue=A.password;N=J+":"+ue}N&&m.delete("authorization");let R;try{R=J7i(A.pathname+A.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(J){let ue=new Error(J.message);return ue.config=t,ue.url=t.url,ue.exists=!0,n(ue)}m.set("Accept-Encoding","gzip, compress, deflate"+(P8p?", br":""),!1);let z={path:R,method:l,headers:m.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:N,protocol:g,family:f,beforeRedirect:pPS,beforeRedirects:{}};!er.isUndefined(c)&&(z.lookup=c),t.socketPath?z.socketPath=t.socketPath:(z.hostname=A.hostname.startsWith("[")?A.hostname.slice(1,-1):A.hostname,z.port=A.port,q8p(z,t.proxy,g+"//"+A.hostname+(A.port?":"+A.port:"")+z.path));let L,H=dPS.test(z.protocol);if(z.agent=H?t.httpsAgent:t.httpAgent,t.transport?L=t.transport:t.maxRedirects===0?L=H?D8p.default:M8p.default:(t.maxRedirects&&(z.maxRedirects=t.maxRedirects),t.beforeRedirect&&(z.beforeRedirects.config=t.beforeRedirect),L=H?fPS:lPS),t.maxBodyLength>-1?z.maxBodyLength=t.maxBodyLength:z.maxBodyLength=1/0,t.insecureHTTPParser&&(z.insecureHTTPParser=t.insecureHTTPParser),h=L.request(z,function(ue){if(h.destroyed)return;let de=[ue],U=+ue.headers["content-length"];if(M||B){let Le=new K7s({maxRate:er.toFiniteNumber(B)});M&&Le.on("progress",w8p(Le,DTn(U,Qbi(BTn(M),!0,3)))),de.push(Le)}let W=ue,Te=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":de.push(Ubi.default.createUnzip(m8p)),delete ue.headers["content-encoding"];break;case"deflate":de.push(new v8p),de.push(Ubi.default.createUnzip(m8p)),delete ue.headers["content-encoding"];break;case"br":P8p&&(de.push(Ubi.default.createBrotliDecompress(cPS)),delete ue.headers["content-encoding"])}W=de.length>1?Z7i.default.pipeline(de,er.noop):de[0];let ce=Z7i.default.finished(W,()=>{ce(),b()}),we={status:ue.statusCode,statusText:ue.statusMessage,headers:new QS(ue.headers),config:t,request:Te};if(s==="stream")we.data=W,o6t(i,n,we);else{let Le=[],le=0;W.on("data",function(Je){Le.push(Je),le+=Je.length,t.maxContentLength>-1&&le>t.maxContentLength&&(_=!0,W.destroy(),n(new ha("maxContentLength size of "+t.maxContentLength+" exceeded",ha.ERR_BAD_RESPONSE,t,Te)))}),W.on("aborted",function(){if(_)return;let Je=new ha("stream has been aborted",ha.ERR_BAD_RESPONSE,t,Te);W.destroy(Je),n(Je)}),W.on("error",function(Je){h.destroyed||n(ha.from(Je,null,t,Te))}),W.on("end",function(){try{let Je=Le.length===1?Le[0]:Buffer.concat(Le);s!=="arraybuffer"&&(Je=Je.toString(u),(!u||u==="utf8")&&(Je=er.stripBOM(Je))),we.data=Je}catch(Je){return n(ha.from(Je,null,t,we.request,we))}o6t(i,n,we)})}y.once("abort",Le=>{W.destroyed||(W.emit("error",Le),W.destroy())})}),y.once("abort",J=>{n(J),h.destroy(J)}),h.on("error",function(ue){n(ha.from(ue,null,t,h))}),h.on("socket",function(ue){ue.setKeepAlive(!0,1e3*60)}),t.timeout){let J=parseInt(t.timeout,10);if(Number.isNaN(J)){n(new ha("error trying to parse `config.timeout` to int",ha.ERR_BAD_OPTION_VALUE,t,h));return}h.setTimeout(J,function(){if(p)return;let de=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",U=t.transitional||ETn;t.timeoutErrorMessage&&(de=t.timeoutErrorMessage),n(new ha(de,U.clarifyTimeoutError?ha.ETIMEDOUT:ha.ECONNABORTED,t,h)),v()})}if(er.isStream(o)){let J=!1,ue=!1;o.on("end",()=>{J=!0}),o.once("error",de=>{ue=!0,h.destroy(de)}),o.on("close",()=>{!J&&!ue&&v(new the("Request stream has been aborted",t,h))}),o.pipe(h)}else h.end(o)})};var R8p=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 z8p=OA.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let o=[e+"="+encodeURIComponent(t)];er.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),er.isString(i)&&o.push("path="+i),er.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 N8p=e=>e instanceof QS?{...e}:e;function FNt(e,t){t=t||{};let r={};function i(s,u,l,p){return er.isPlainObject(s)&&er.isPlainObject(u)?er.merge.call({caseless:p},s,u):er.isPlainObject(u)?er.merge({},u):er.isArray(u)?u.slice():u}function n(s,u,l,p){if(er.isUndefined(u)){if(!er.isUndefined(s))return i(void 0,s,l,p)}else return i(s,u,l,p)}function a(s,u){if(!er.isUndefined(u))return i(void 0,u)}function o(s,u){if(er.isUndefined(u)){if(!er.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(N8p(s),N8p(u),l,!0)};return er.forEach(Object.keys({...e,...t}),function(u){let l=f[u]||n,p=l(e[u],t[u],u);er.isUndefined(p)&&l!==c||(r[u]=p)}),r}var V0o=e=>{let t=FNt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=QS.from(o),t.url=J7i($7i(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),er.isFormData(r)){if(OA.hasStandardBrowserEnv||OA.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(er.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&&er.isFunction(i)&&(i=i(t)),i||i!==!1&&R8p(t.url))){let f=n&&a&&z8p.read(a);f&&o.set(n,f)}return t};var bPS=typeof XMLHttpRequest<"u",F8p=bPS&&function(e){return new Promise(function(r,i){let n=V0o(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};o6t(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 ha("Request aborted",ha.ECONNABORTED,e,b)),b=null)},b.onerror=function(g){let m=g&&g.message?g.message:"Network Error",j=new ha(m,ha.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||ETn;n.timeoutErrorMessage&&(g=n.timeoutErrorMessage),i(new ha(g,m.clarifyTimeoutError?ha.ETIMEDOUT:ha.ECONNABORTED,e,b)),b=null},a===void 0&&o.setContentType(null),"setRequestHeader"in b&&er.forEach(o.toJSON(),function(g,m){b.setRequestHeader(m,g)}),er.isUndefined(n.withCredentials)||(b.withCredentials=!!n.withCredentials),c&&c!=="json"&&(b.responseType=n.responseType),s&&([p,h]=Qbi(s,!0),b.addEventListener("progress",p)),f&&b.upload&&([l,_]=Qbi(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=gOa(n.url);if(O&&OA.protocols.indexOf(O)===-1){i(new ha("Unsupported protocol "+O+":",ha.ERR_BAD_REQUEST,e));return}b.send(a||null)})};var vPS=(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 ha?u:new the(u instanceof Error?u.message:u))}},o=t&&setTimeout(()=>{o=null,a(new ha(`timeout ${t} of ms exceeded`,ha.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=()=>er.asap(c),f}},Q8p=vPS;var gPS=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},OPS=async function*(e,t){for await(let r of APS(e))yield*gPS(r,t)},APS=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()}},X7s=(e,t,r,i)=>{let n=OPS(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 U8p=64*1024,{isFunction:W0o}=er,mPS=(({Request:e,Response:t})=>({Request:e,Response:t}))(er.global),{ReadableStream:L8p,TextEncoder:V8p}=er.global,W8p=(e,...t)=>{try{return!!e(...t)}catch{return!1}},PPS=e=>{e=er.merge.call({skipUndefined:!0},mPS,e);let{fetch:t,Request:r,Response:i}=e,n=t?W0o(t):typeof fetch=="function",a=W0o(r),o=W0o(i);if(!n)return!1;let c=n&&W0o(L8p),f=n&&(typeof V8p=="function"?(h=>y=>h.encode(y))(new V8p):async h=>new Uint8Array(await new r(h).arrayBuffer())),s=a&&c&&W8p(()=>{let h=!1,y=new r(OA.origin,{body:new L8p,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!y}),u=o&&c&&W8p(()=>er.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 ha(`Response type '${h}' is not supported`,ha.ERR_NOT_SUPPORT,b)})});let p=async h=>{if(h==null)return 0;if(er.isBlob(h))return h.size;if(er.isSpecCompliantForm(h))return(await new r(OA.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(er.isArrayBufferView(h)||er.isArrayBuffer(h))return h.byteLength;if(er.isURLSearchParams(h)&&(h=h+""),er.isString(h))return(await f(h)).byteLength},_=async(h,y)=>{let b=er.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}=V0o(h),F=t||fetch;M=M?(M+"").toLowerCase():"text";let N=Q8p([O,A&&A.toAbortSignal()],g),R=null,z=N&&N.unsubscribe&&(()=>{N.unsubscribe()}),L;try{if(j&&s&&b!=="get"&&b!=="head"&&(L=await _(E,v))!==0){let W=new r(y,{method:"POST",body:v,duplex:"half"}),Te;if(er.isFormData(v)&&(Te=W.headers.get("content-type"))&&E.setContentType(Te),W.body){let[ce,we]=DTn(L,Qbi(BTn(j)));v=X7s(W.body,U8p,ce,we)}}er.isString(D)||(D=D?"include":"omit");let H=a&&"credentials"in r.prototype,J={...B,signal:N,method:b.toUpperCase(),headers:E.normalize().toJSON(),body:v,duplex:"half",credentials:H?D:void 0};R=a&&new r(y,J);let ue=await(a?F(R,B):F(y,J)),de=u&&(M==="stream"||M==="response");if(u&&(m||de&&z)){let W={};["status","statusText","headers"].forEach(Le=>{W[Le]=ue[Le]});let Te=er.toFiniteNumber(ue.headers.get("content-length")),[ce,we]=m&&DTn(Te,Qbi(BTn(m),!0))||[];ue=new i(X7s(ue.body,U8p,ce,()=>{we&&we(),z&&z()}),W)}M=M||"text";let U=await l[er.findKey(l,M)||"text"](ue,h);return!de&&z&&z(),await new Promise((W,Te)=>{o6t(W,Te,{data:U,headers:QS.from(ue.headers),status:ue.status,statusText:ue.statusText,config:h,request:R})})}catch(H){throw z&&z(),H&&H.name==="TypeError"&&/Load failed|fetch/i.test(H.message)?Object.assign(new ha("Network Error",ha.ERR_NETWORK,h,R),{cause:H.cause||H}):ha.from(H,H&&H.code,h,R)}}},jPS=new Map,Z7s=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=jPS;for(;c--;)f=a[c],s=u.get(f),s===void 0&&u.set(f,s=c?new Map:PPS(t)),u=s;return s},jg5=Z7s();var k7s={http:T8p,xhr:F8p,fetch:{get:Z7s}};er.forEach(k7s,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var x8p=e=>`- ${e}`,EPS=e=>er.isFunction(e)||e===null||e===!1,x0o={getAdapter:(e,t)=>{e=er.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,!EPS(i)&&(n=k7s[(c=String(i)).toLowerCase()],n===void 0))throw new ha(`Unknown adapter '${c}'`);if(n&&(er.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 :
|
|
@@ -1391,7 +1391,7 @@ ${g}${O}${m}${mQn}`});function CQo({message:e,error:t,logger:r,logLevel:i=$s.Err
|
|
|
1391
1391
|
Run ${Ut.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1392
1392
|
Run ${Ut.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),UBi(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function Tuc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!zf_(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+=`
|
|
1393
1393
|
${await dZS(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Ut.dim(c.currentVersion)+Ut.reset(" \u2192 ")+Ut.green(c.latestVersion);return n+=`
|
|
1394
|
-
`,i?UBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function dZS(e){let r=await new Rf_.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 pZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await Ff_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=FMi(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 Ff_({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=FMi(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 Ff_({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 Qf_(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=kH(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 zQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await pZS({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(...Qf_(s,f,t.logger));else o.push(...Qf_(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 EQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Ruc=(()=>{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})(),Uf_=typeof globalThis.AbortController=="function",Lf_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Vf_=typeof globalThis.ReadableStream=="function",Wf_=typeof globalThis.FormData=="function",NQo=["get","post","put","patch","head","delete"],_ZS=()=>{};_ZS();var xf_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},FQo=2147483647,Gf_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,QQo=Symbol("stop"),Hf_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Kf_={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 hZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=Gf_,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},Jf_=(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))}}))},$f_=(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(Jf_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},Yf_=(e,t,r)=>{if(!e.body)return e;let i=hZS(r??e.body);return new Request(e,{duplex:"half",body:Jf_(e.body,i,t)})};var SQn=e=>e!==null&&typeof e=="object";var TPa=(...e)=>{for(let t of e)if((!SQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Fuc({},...e)},zuc=(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 UQo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Fuc(e[r]??[],t[r]??[])}var Nuc=(e={},t={})=>({beforeRequest:UQo(e,t,"beforeRequest"),beforeRetry:UQo(e,t,"beforeRetry"),afterResponse:UQo(e,t,"afterResponse"),beforeError:UQo(e,t,"beforeError")}),Fuc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(SQn(n)){for(let[a,o]of Object.entries(n))SQn(o)&&a in t&&(o=Fuc(t[a],o)),t={...t,[a]:o};SQn(n.hooks)&&(i=Nuc(i,n.hooks),t.hooks=i),SQn(n.headers)&&(r=zuc(r,n.headers),t.headers=r)}return t};var Zf_=e=>NQo.includes(e)?e.toUpperCase():e,yZS=["get","put","head","delete","options","trace"],bZS=[408,413,429,500,502,503,504],vZS=[413,429,503],Xf_={limit:2,methods:yZS,statusCodes:bZS,afterStatusCodes:vZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},kf_=(e={})=>{if(typeof e=="number")return{...Xf_,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{...Xf_,...e}};async function Quc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new EQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function Uuc(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 ed_=(e,t)=>{let r={};for(let i in t)!(i in Kf_)&&!(i in Hf_)&&!(i in e)&&(r[i]=t[i]);return r},td_=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>FQo)throw new RangeError(`The \`timeout\` option cannot be greater than ${FQo}`);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(!Vf_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return $f_(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(xf_))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:zuc(this._input.headers,r.headers),hooks:Nuc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Zf_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:kf_(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(Uf_&&Lf_){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(Ruc&&(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),td_(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);(Wf_&&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(!Ruc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Yf_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof EQn)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),FQo);if(this._retryCount<1)throw r;await Uuc(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})===QQo)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=ed_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):Quc(this._originalRequest,t,this.abortController,this._options)}};var Luc=e=>{let t=(r,i)=>RPa.create(r,TPa(e,i));for(let r of NQo)t[r]=(i,n)=>RPa.create(i,TPa(e,n,{method:r}));return t.create=r=>Luc(TPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Luc(TPa(e,r))),t.stop=QQo,t},gZS=Luc(),rd_=gZS;var wd_=se(jd_(),1);function Huc(e){let t=(0,wd_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var gp_=se(vp_(),1),Op_=se(m_e(),1),asc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},osc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function usc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Huc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,gp_.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 rd_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new asc(e):l}if(t.allVersions)return s;let u=new osc(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=Op_.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 usc(e.toLowerCase(),t);return r}async function TCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:LPa(e.packageName,{version:t?"prerelease":"latest"})}var Ap_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],ZQo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new RQo(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"3.24.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Ut.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new TE}failWithoutThrowing(t,r){this.didSucceed=!1,CQo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await mTn()).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 Nf_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1394
|
+
`,i?UBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function dZS(e){let r=await new Rf_.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 pZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await Ff_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=FMi(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 Ff_({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=FMi(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 Ff_({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 Qf_(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=kH(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 zQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await pZS({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(...Qf_(s,f,t.logger));else o.push(...Qf_(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 EQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Ruc=(()=>{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})(),Uf_=typeof globalThis.AbortController=="function",Lf_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Vf_=typeof globalThis.ReadableStream=="function",Wf_=typeof globalThis.FormData=="function",NQo=["get","post","put","patch","head","delete"],_ZS=()=>{};_ZS();var xf_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},FQo=2147483647,Gf_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,QQo=Symbol("stop"),Hf_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Kf_={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 hZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=Gf_,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},Jf_=(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))}}))},$f_=(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(Jf_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},Yf_=(e,t,r)=>{if(!e.body)return e;let i=hZS(r??e.body);return new Request(e,{duplex:"half",body:Jf_(e.body,i,t)})};var SQn=e=>e!==null&&typeof e=="object";var TPa=(...e)=>{for(let t of e)if((!SQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Fuc({},...e)},zuc=(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 UQo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Fuc(e[r]??[],t[r]??[])}var Nuc=(e={},t={})=>({beforeRequest:UQo(e,t,"beforeRequest"),beforeRetry:UQo(e,t,"beforeRetry"),afterResponse:UQo(e,t,"afterResponse"),beforeError:UQo(e,t,"beforeError")}),Fuc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(SQn(n)){for(let[a,o]of Object.entries(n))SQn(o)&&a in t&&(o=Fuc(t[a],o)),t={...t,[a]:o};SQn(n.hooks)&&(i=Nuc(i,n.hooks),t.hooks=i),SQn(n.headers)&&(r=zuc(r,n.headers),t.headers=r)}return t};var Zf_=e=>NQo.includes(e)?e.toUpperCase():e,yZS=["get","put","head","delete","options","trace"],bZS=[408,413,429,500,502,503,504],vZS=[413,429,503],Xf_={limit:2,methods:yZS,statusCodes:bZS,afterStatusCodes:vZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},kf_=(e={})=>{if(typeof e=="number")return{...Xf_,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{...Xf_,...e}};async function Quc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new EQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function Uuc(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 ed_=(e,t)=>{let r={};for(let i in t)!(i in Kf_)&&!(i in Hf_)&&!(i in e)&&(r[i]=t[i]);return r},td_=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>FQo)throw new RangeError(`The \`timeout\` option cannot be greater than ${FQo}`);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(!Vf_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return $f_(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(xf_))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:zuc(this._input.headers,r.headers),hooks:Nuc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Zf_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:kf_(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(Uf_&&Lf_){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(Ruc&&(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),td_(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);(Wf_&&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(!Ruc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Yf_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof EQn)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),FQo);if(this._retryCount<1)throw r;await Uuc(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})===QQo)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=ed_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):Quc(this._originalRequest,t,this.abortController,this._options)}};var Luc=e=>{let t=(r,i)=>RPa.create(r,TPa(e,i));for(let r of NQo)t[r]=(i,n)=>RPa.create(i,TPa(e,n,{method:r}));return t.create=r=>Luc(TPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Luc(TPa(e,r))),t.stop=QQo,t},gZS=Luc(),rd_=gZS;var wd_=se(jd_(),1);function Huc(e){let t=(0,wd_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var gp_=se(vp_(),1),Op_=se(m_e(),1),asc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},osc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function usc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Huc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,gp_.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 rd_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new asc(e):l}if(t.allVersions)return s;let u=new osc(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=Op_.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 usc(e.toLowerCase(),t);return r}async function TCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:LPa(e.packageName,{version:t?"prerelease":"latest"})}var Ap_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],ZQo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new RQo(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"3.24.2"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Ut.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new TE}failWithoutThrowing(t,r){this.didSucceed=!1,CQo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await mTn()).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 Nf_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1395
1395
|
`)||(r+=`
|
|
1396
1396
|
`),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=dws(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 TE}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await mTn()).sendEvent(t)}logger=$8t((t,...r)=>this.log(t,...r));stderr=$8t((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=mp_(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?mp_(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=Ap_[this.numTasks++%Ap_.length],o=Ut.hex(a)(n);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===yj.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=>aMi.indexOf(n.level)>=aMi.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 TCi({cliEnvironment:this.environment,includePreReleases:t}),i=kH(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await zQo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await muc({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Ut.yellow("?"),style:{answer:n=>Ut.cyan(n),message:n=>Ut.bold(n),highlight:n=>Ut.cyan(n)}}})}catch(i){throw i?.name==="ExitPromptError"?(this.logger.info(`
|
|
1397
1397
|
Cancelled by user.`),new TE):i}}async getInput(t){return await vuc({message:t.message,default:t.default})}};function mp_(e){return`[${e}]:`}var hFt=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 kQo(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)=>kQo.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 Pp_(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 jp_(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 wp_=Function.bind,Ep_=wp_.bind(wp_);function Sp_(e,t,r){let i=Ep_(jp_,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]=Ep_(Pp_,null).apply(null,a)})}function w2S(){let e=Symbol("Singular"),t={registry:{}},r=kQo.bind(null,t,e);return Sp_(r,t,e),r}function E2S(){let e={registry:{}},t=kQo.bind(null,e);return Sp_(t,e),t}var Mp_={Singular:w2S,Collection:E2S};var S2S="0.0.0-development",M2S=`octokit-endpoint.js/${S2S} ${qR()}`,D2S={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":M2S},mediaType:{format:""}};function B2S(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function I2S(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 Ip_(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(i=>{I2S(t[i])?i in e?r[i]=Ip_(e[i],t[i]):Object.assign(r,{[i]:t[i]}):Object.assign(r,{[i]:t[i]})}),r}function Dp_(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function csc(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=B2S(r.headers),Dp_(r),Dp_(r.headers);let i=Ip_(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 C2S(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 q2S=/\{[^{}}]+\}/g;function T2S(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function R2S(e){let t=e.match(q2S);return t?t.map(T2S).reduce((r,i)=>r.concat(i),[]):[]}function Bp_(e,t){let r={__proto__:null};for(let i of Object.keys(e))t.indexOf(i)===-1&&(r[i]=e[i]);return r}function Cp_(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 RQn(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function VPa(e,t,r){return t=e==="+"||e==="#"?Cp_(t):RQn(t),r?RQn(r)+"="+t:t}function TQn(e){return e!=null}function ssc(e){return e===";"||e==="&"||e==="?"}function z2S(e,t,r,i){var n=e[r],a=[];if(TQn(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,ssc(t)?r:""));else if(i==="*")Array.isArray(n)?n.filter(TQn).forEach(function(o){a.push(VPa(t,o,ssc(t)?r:""))}):Object.keys(n).forEach(function(o){TQn(n[o])&&a.push(VPa(t,n[o],o))});else{let o=[];Array.isArray(n)?n.filter(TQn).forEach(function(c){o.push(VPa(t,c))}):Object.keys(n).forEach(function(c){TQn(n[c])&&(o.push(RQn(c)),o.push(VPa(t,n[c].toString())))}),ssc(t)?a.push(RQn(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?TQn(n)&&a.push(RQn(r)):n===""&&(t==="&"||t==="?")?a.push(RQn(r)+"="):n===""&&a.push("");return a}function N2S(e){return{expand:F2S.bind(null,e)}}function F2S(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(z2S(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 Cp_(a)}),e==="/"?e:e.replace(/\/$/,"")}function qp_(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),i=Object.assign({},e.headers),n,a=Bp_(e,["method","baseUrl","url","headers","request","mediaType"]),o=R2S(r);r=N2S(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(u=>o.includes(u)).concat("baseUrl"),f=Bp_(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=C2S(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 Q2S(e,t,r){return qp_(csc(e,t,r))}function Tp_(e,t){let r=csc(e,t),i=Q2S.bind(null,r);return Object.assign(i,{DEFAULTS:r,defaults:Tp_.bind(null,r),merge:csc.bind(null,r),parse:qp_})}var Rp_=Tp_(null,D2S);var Lp_=se(Qp_(),1);var yFt=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 U2S="10.0.6",L2S={headers:{"user-agent":`octokit-request.js/${U2S} ${qR()}`}};function V2S(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 Up_(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=V2S(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 yFt(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 yFt(o.statusText,c,{response:u,request:e})}if(c===304)throw u.data=await lsc(o),new yFt("Not modified",c,{response:u,request:e});if(c>=400)throw u.data=await lsc(o),new yFt(x2S(u.data),c,{response:u,request:e});return u.data=i?await lsc(o):o.body,u}async function lsc(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,Lp_.safeParse)(t);if(W2S(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 W2S(e){return e.type==="application/json"||e.type==="application/scim+json"}function x2S(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 fsc(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 Up_(r.parse(o));let c=(f,s)=>Up_(r.parse(r.merge(f,s)));return Object.assign(c,{endpoint:r,defaults:fsc.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:fsc.bind(null,r)})}var VO=fsc(Rp_,L2S);var G2S="0.0.0-development";function H2S(e){return`Request failed due to following response errors:
|
|
@@ -1408,7 +1408,7 @@ Cancelled by user.`),new TE):i}}async getInput(t){return await vuc({message:t.me
|
|
|
1408
1408
|
})
|
|
1409
1409
|
`);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",PkS.bind(null,f)),{}}nUo.VERSION=mkS;nUo.triggersNotification=u__;function s__(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=DkS(`${r}/login/oauth/authorize`,i),i}function DkS(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 d__(e){let t=e.endpoint.DEFAULTS;return/^https:\/\/(api\.)?github\.com$/.test(t.baseUrl)?"https://github.com":t.baseUrl.replace("/api/v3","")}async function aUo(e,t,r){let i={baseUrl:d__(e),headers:{accept:"application/json"},...r},n=await e(t,i);if("error"in n.data){let a=new yFt(`${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 p__({request:e=VO,...t}){let r=d__(e);return s__({...t,baseUrl:r})}async function ___(e){let t=e.request||VO,r=await aUo(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 h__(e){let t=e.request||VO,r={client_id:e.clientId};return"scopes"in e&&Array.isArray(e.scopes)&&(r.scope=e.scopes.join(" ")),aUo(t,"POST /login/device/code",r)}async function Psc(e){let t=e.request||VO,r=await aUo(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=l__(n,r.data.expires_in),i.refreshTokenExpiresAt=l__(n,r.data.refresh_token_expires_in)}delete i.scopes}return{...r,authentication:i}}function l__(e,t){return new Date(e+t*1e3).toISOString()}async function oUo(e){let r=await(e.request||VO)("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 uUo(e){let t=e.request||VO,r=await aUo(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:f__(i,r.data.expires_in),refreshTokenExpiresAt:f__(i,r.data.refresh_token_expires_in)};return{...r,authentication:n}}function f__(e,t){return new Date(e+t*1e3).toISOString()}async function y__(e){let{request:t,clientType:r,clientId:i,clientSecret:n,token:a,...o}=e,f=await(e.request||VO)("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||VO,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||VO,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||VO,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 v__(e,t){let r=BkS(e,t.auth);if(r)return r;let{data:i}=await h__({clientType:e.clientType,clientId:e.clientId,request:t.request||e.request,scopes:t.auth.scopes||e.scopes});await e.onVerification(i);let n=await jsc(t.request||e.request,e.clientId,e.clientType,i);return e.authentication=n,n}function BkS(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 b__(e){await new Promise(t=>setTimeout(t,e*1e3))}async function jsc(e,t,r,i){try{let n={clientId:t,request:e,code:i.device_code},{authentication:a}=r==="oauth-app"?await Psc({...n,clientType:"oauth-app"}):await Psc({...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 b__(i.interval),jsc(e,t,r,i);if(a==="slow_down")return await b__(i.interval+7),jsc(e,t,r,i);throw n}}async function IkS(e,t){return v__(e,{auth:t})}async function CkS(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 v__(e,{request:t,auth:{type:"oauth"}});return n.headers.authorization=`token ${a}`,t(n)}var qkS="0.0.0-development";function g__(e){let t=e.request||VO.defaults({headers:{"user-agent":`octokit-auth-oauth-device.js/${qkS} ${qR()}`}}),{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(IkS.bind(null,n),{hook:CkS.bind(null,n)})}var A__="0.0.0-development";async function O__(e){if("code"in e.strategyOptions){let{authentication:t}=await ___({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 g__({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 wsc(e,t={}){if(e.authentication||(e.authentication=e.clientType==="oauth-app"?await O__(e):await O__(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 uUo({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"?oUo: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 TkS=/\/applications\/[^/]+\/(token|grant)s?/;function JPa(e){return e&&TkS.test(e)}async function RkS(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 wsc({...e,request:t}):await wsc({...e,request:t});return n.headers.authorization="token "+a,t(n)}function G3({clientId:e,clientSecret:t,clientType:r="oauth-app",request:i=VO.defaults({headers:{"user-agent":`octokit-auth-oauth-app.js/${A__} ${qR()}`}}),onTokenCreated:n,...a}){let o=Object.assign({clientType:r,clientId:e,clientSecret:t,onTokenCreated:n,strategyOptions:a,request:i});return Object.assign(wsc.bind(null,o),{hook:RkS.bind(null,o)})}G3.VERSION=A__;async function zkS(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 G3({...r,clientType:e.clientType}):await G3({...r,clientType:e.clientType}))()}async function NkS(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 FkS="0.0.0-development";function sUo(e){let t=Object.assign({request:VO.defaults({headers:{"user-agent":`octokit-auth-oauth-app.js/${FkS} ${qR()}`}}),clientType:"oauth-app"},e);return Object.assign(zkS.bind(null,t),{hook:NkS.bind(null,t)})}async function lUo({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 a4s(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 UkS(){return new z_o(15e3,1e3*60*59)}async function LkS(e,t){let r=Esc(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 VkS(e,t,r){let i=Esc(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 Esc({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 m__({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 P__(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 WkS(e,{...t,installationId:i},n)}var cUo=new Map;function WkS(e,t,r){let i=Esc(t);if(cUo.has(i))return cUo.get(i);let n=xkS(e,t,r).finally(()=>cUo.delete(i));return cUo.set(i,n),n}async function xkS(e,t,r){if(!t.refresh){let O=await LkS(e.cache,t);if(O){let{token:A,createdAt:g,expiresAt:m,permissions:j,repositoryIds:M,repositoryNames:E,singleFileName:D,repositorySelection:B}=O;return m__({installationId:t.installationId,token:A,createdAt:g,expiresAt:m,permissions:j,repositorySelection:B,repositoryIds:M,repositoryNames:E,singleFileName:D})}}let i=await lUo(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 VkS(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}),m__(v)}async function GkS(e,t){switch(t.type){case"app":return lUo(e);case"oauth-app":return e.oauthApp({type:"oauth-app"});case"installation":return P__(e,{...t,type:"installation"});case"oauth-user":return e.oauthApp(t);default:throw new Error(`Invalid auth type: ${t.type}`)}}var HkS=["/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 KkS(e){let r=`^(?:${e.map(i=>i.split("/").map(n=>n.startsWith("{")?"(?:.+?)":n).join("/")).map(i=>`(?:${i})`).join("|")})$`;return new RegExp(r,"i")}var JkS=KkS(HkS);function $kS(e){return!!e&&JkS.test(e.split("?")[0])}var YkS=5*1e3;function XkS(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 ZkS(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($kS(a.replace(t.endpoint.DEFAULTS.baseUrl,""))){let{token:f}=await lUo(e);n.headers.authorization=`bearer ${f}`;let s;try{s=await t(n)}catch(u){if(XkS(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 lUo({...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 P__(e,{},t.defaults({baseUrl:n.baseUrl}));return n.headers.authorization=`token ${o}`,j__(e,t,n,c)}async function j__(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>=YkS)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)),j__(e,t,r,i,n)}}var kkS="8.1.2";function zQn(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||VO.defaults({headers:{"user-agent":`octokit-auth-app.js/${kkS} ${qR()}`}}),i=Object.assign({request:r,cache:UkS()},e,e.installationId?{installationId:Number(e.installationId)}:{},{log:t,oauthApp:sUo({clientType:"github-app",clientId:e.clientId||"",clientSecret:e.clientSecret||"",request:r})});return Object.assign(GkS.bind(null,i),{hook:ZkS.bind(null,i)})}async function eeM(e){return{type:"unauthenticated",reason:e}}function teM(e){return e.status!==403||!e.response?!1:e.response.headers["x-ratelimit-remaining"]==="0"}var reM=/\babuse\b/i;function ieM(e){return e.status!==403?!1:reM.test(e.message)}async function neM(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):teM(a)?(a.message=`API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${e}`,a):ieM(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 mJi=function(t){if(!t||!t.reason)throw new Error("[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth");return Object.assign(eeM.bind(null,t.reason),{hook:neM.bind(null,t.reason)})};var w__="8.0.3";function E__(e,t,r){if(Array.isArray(t)){for(let i of t)E__(e,i,r);return}e.eventHandlers[t]||(e.eventHandlers[t]=[]),e.eventHandlers[t].push(r)}var aeM=RCi.defaults({userAgent:`octokit-oauth-app.js/${w__} ${qR()}`});async function Lvi(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 oeM(e,t){return e.octokit.auth({type:"oauth-user",...t,async factory(r){let i=new e.Octokit({authStrategy:G3,auth:r}),n=await i.auth({type:"get"});return await Lvi(e,{name:"token",action:"created",token:n.token,scopes:n.scopes,authentication:n,octokit:i}),i}})}function ueM(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 p__({clientType:e.clientType,...r})}async function seM(e,t){let r=await e.octokit.auth({type:"oauth-user",...t});return await Lvi(e,{name:"token",action:"created",token:r.token,scopes:r.scopes,authentication:r,octokit:new e.Octokit({authStrategy:G3,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 ceM(e,t){let r=await oUo({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 leM(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 Lvi(e,{name:"token",action:"reset",token:a.authentication.token,scopes:a.authentication.scopes||void 0,authentication:o,octokit:new e.Octokit({authStrategy:G3,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 Lvi(e,{name:"token",action:"reset",token:i.authentication.token,authentication:n,octokit:new e.Octokit({authStrategy:G3,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:i.authentication.token}})}),{...i,authentication:n}}async function feM(e,t){if(e.clientType==="oauth-app")throw new Error("[@octokit/oauth-app] app.refreshToken() is not supported for OAuth Apps");let r=await uUo({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 Lvi(e,{name:"token",action:"refreshed",token:r.authentication.token,authentication:i,octokit:new e.Octokit({authStrategy:G3,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.authentication.token}})}),{...r,authentication:i}}async function deM(e,t){if(e.clientType==="oauth-app")throw new Error("[@octokit/oauth-app] app.scopeToken() is not supported for OAuth Apps");let r=await y__({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 Lvi(e,{name:"token",action:"scoped",token:r.authentication.token,authentication:i,octokit:new e.Octokit({authStrategy:G3,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.authentication.token}})}),{...r,authentication:i}}async function peM(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 Lvi(e,{name:"token",action:"deleted",token:t.token,octokit:new e.Octokit({authStrategy:mJi,auth:{reason:'Handling "token.deleted" event. The access for the token has been revoked.'}})}),i}async function _eM(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 Lvi(e,{name:"token",action:"deleted",token:t.token,octokit:new e.Octokit({authStrategy:mJi,auth:{reason:'Handling "token.deleted" event. The access for the token has been revoked.'}})}),await Lvi(e,{name:"authorization",action:"deleted",token:t.token,octokit:new e.Octokit({authStrategy:mJi,auth:{reason:'Handling "authorization.deleted" event. The access for the app has been revoked.'}})}),i}var fUo=class{static VERSION=w__;static defaults(e){return class extends this{constructor(...r){super({...e,...r[0]})}}}constructor(e){let t=e.Octokit||aeM;this.type=e.clientType||"oauth-app";let r=new t({authStrategy:sUo,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=E__.bind(null,i),this.octokit=r,this.getUserOctokit=oeM.bind(null,i),this.getWebFlowAuthorizationUrl=ueM.bind(null,i),this.createToken=seM.bind(null,i),this.checkToken=ceM.bind(null,i),this.resetToken=leM.bind(null,i),this.refreshToken=feM.bind(null,i),this.scopeToken=deM.bind(null,i),this.deleteToken=peM.bind(null,i),this.deleteAuthorization=_eM.bind(null,i)}type;on;octokit;getUserOctokit;getWebFlowAuthorizationUrl;createToken;checkToken;resetToken;refreshToken;scopeToken;deleteToken;deleteAuthorization};var S__=require("crypto"),D__=require("crypto"),Ssc=require("buffer"),M__="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,S__.createHmac)(r,e).update(t).digest("hex")}`}dUo.VERSION=M__;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=Ssc.Buffer.from(r),n=Ssc.Buffer.from(await dUo(e,t));return i.length!==n.length?!1:(0,D__.timingSafeEqual)(i,n)}$Pa.VERSION=M__;async function B__(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 q__=(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),heM=["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 yeM(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"&&!heM.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 Msc(e,t,r){e.hooks[t]||(e.hooks[t]=[]),e.hooks[t].push(r)}function T__(e,t,r){if(Array.isArray(t)){t.forEach(i=>T__(e,i,r));return}yeM(t,{onUnknownEventName:"warn",log:e.log}),Msc(e,t,r)}function beM(e,t){Msc(e,"*",t)}function veM(e,t){Msc(e,"error",t)}function I__(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 geM(e,t,r){let i=[e.hooks[r],e.hooks["*"]];return t&&i.unshift(e.hooks[`${r}.${t}`]),[].concat(...i.filter(Boolean))}function OeM(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=>I__(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=geM(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(`
|
|
1410
1410
|
`));throw Object.assign(o,{event:t}),r.forEach(c=>I__(c,o)),o})}function R__(e,t,r){if(Array.isArray(t)){t.forEach(i=>R__(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 AeM(e){let t={hooks:{},log:q__(e&&e.log)};return e&&e.transform&&(t.transform=e.transform),{on:T__.bind(null,t),onAny:beM.bind(null,t),onError:veM.bind(null,t),removeListener:R__.bind(null,t),receive:OeM.bind(null,t)}}async function meM(e,t){if(!await B__(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 C__=new TextDecoder("utf-8",{fatal:!1}),J7W=C__.decode.bind(C__);var z__=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:AeM(e),secret:e.secret,additionalSecrets:e.additionalSecrets,hooks:{},log:q__(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=meM.bind(null,t)}};var PeM="16.1.2";function jeM(e,t){return new z__({secret:t.secret,transform:async r=>{if(!("installation"in r.payload)||typeof r.payload.installation!="object"){let a=new e.constructor({authStrategy:mJi,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:zQn,auth:{...a,installationId:i}})}});return n.hook.before("request",a=>{a.headers["x-github-delivery"]=r.id}),{...r,octokit:n}}})}async function N__(e,t){return e.octokit.auth({type:"installation",installationId:t,factory(r){let i={...r.octokitOptions,authStrategy:zQn,auth:{...r,installationId:t}};return new r.octokit.constructor(i)}})}function weM(e){return Object.assign(EeM.bind(null,e),{iterator:F__.bind(null,e)})}async function EeM(e,t){let r=F__(e)[Symbol.asyncIterator](),i=await r.next();for(;!i.done;)await t(i.value),i=await r.next()}function F__(e){return{async*[Symbol.asyncIterator](){let t=iUo.iterator(e.octokit,"GET /app/installations");for await(let{data:r}of t)for(let i of r)yield{octokit:await N__(e,i.id),installation:i}}}}function SeM(e){return Object.assign(MeM.bind(null,e),{iterator:Q__.bind(null,e)})}async function MeM(e,t,r){let i=Q__(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 DeM(e,t){return{async*[Symbol.asyncIterator](){yield{octokit:await e.getInstallationOctokit(t)}}}}function Q__(e,t){return{async*[Symbol.asyncIterator](){let r=t?DeM(e,t.installationId):e.eachInstallation.iterator();for await(let{octokit:i}of r){let n=iUo.iterator(i,"GET /installation/repositories");for await(let{data:a}of n)for(let o of a)yield{octokit:i,repository:o}}}}}function BeM(e){let t;return async function(i={}){t||(t=IeM(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 IeM(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 U__=class{static VERSION=PeM;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||RCi,r=Object.assign({appId:e.appId,privateKey:e.privateKey},e.oauth?{clientId:e.oauth.clientId,clientSecret:e.oauth.clientSecret}:{}),i={authStrategy:zQn,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=jeM(this.octokit,e.webhooks):Object.defineProperty(this,"webhooks",{get(){throw new Error("[@octokit/app] webhooks option not set")}}),e.oauth?this.oauth=new fUo({...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=N__.bind(null,this),this.eachInstallation=weM(this),this.eachRepository=SeM(this),this.getInstallationUrl=BeM(this)}};var CeM="0.0.0-development",pUo=RCi.plugin(Osc,ysc,t__,Asc,nUo).defaults({userAgent:`octokit.js/${CeM}`,throttle:{onRateLimit:qeM,onSecondaryRateLimit:TeM}});function qeM(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 TeM(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 bHW=U__.defaults({Octokit:pUo}),vHW=fUo.defaults({Octokit:pUo});var L__=se(m_e(),1);async function Dsc({packageName:e,generatorInvocation:t}){if(t.language==null||e==null)return;let r=await ReM({packageName:e,language:t.language,githubRepository:UeM(t)});return r==null?void 0:L__.default.inc(r,"patch")??void 0}async function ReM({packageName:e,language:t,githubRepository:r}){let i;switch(t){case"typescript":i=await zeM(e);break;case"python":i=await NeM(e);break;case"csharp":case"go":case"java":case"ruby":case"php":case"swift":break}return i!=null||r!=null&&(i=await FeM(r)),i}async function zeM(e){try{return await LPa(e)}catch{return}}async function NeM(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 FeM(e){try{let{owner:t,repo:r}=QeM(e);return(await new pUo().rest.repos.listTags({owner:t,repo:r,per_page:1})).data?.[0]?.name}catch{return}}function QeM(e){let[t,r]=e.split("/");if(t==null||r==null)throw new Error(`Invalid github repository: ${e}`);return{owner:t,repo:r}}function UeM(e){if(e.outputMode.type==="githubV2")return`${e.outputMode.githubV2.owner}/${e.outputMode.githubV2.repo}`}var rK=class extends hFt{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 LeM={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:hn.RemoveDiscriminantsFromSchemas.Always};function VeM(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 PJi({options:e,overrides:t}){return VeM({defaults:LeM,options:e,overrides:t})}var H3={openapi:e=>({...e,type:"openapi",_visit:function(t){return H3._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return H3._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 NQn={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return NQn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var pz={basic:e=>({...e,type:"basic",_visit:function(t){return pz._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return pz._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return pz._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return pz._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return pz._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 Zc={primitive:e=>({value:e,type:"primitive",_visit:function(t){return Zc._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Zc._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return Zc._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return Zc._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return Zc._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return Zc._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Zc._visit(this,t)}}),null:e=>({...e,type:"null",_visit:function(t){return Zc._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return Zc._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 Ka={int:e=>({value:e,type:"int",_visit:function(t){return Ka._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return Ka._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return Ka._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return Ka._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return Ka._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return Ka._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Ka._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return Ka._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return Ka._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return Ka._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return Ka._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 zCi={boolean:e=>({value:e,type:"boolean",_visit:function(t){return zCi._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return zCi._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 NCi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return NCi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return NCi._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 _Uo={};Yt(_Uo,{Availability:()=>_z,CustomCodeSample:()=>f9t,EndpointExample:()=>K0e,EndpointResponseExample:()=>J0e,HttpMethod:()=>yz,LiteralSchemaValue:()=>Rj,MultipartRequestPropertyEncoding:()=>Csc,MultipartSchema:()=>d9t,OneOfSchema:()=>p9t,Pagination:()=>Dhe,PrimitiveSchemaValue:()=>ah,Request:()=>bFt,Response:()=>KQ,RetriesConfiguration:()=>YPa,Schema:()=>zs,SupportedSdkLanguage:()=>hz,WebhookHttpMethod:()=>Isc,WebsocketMessageOrigin:()=>Bsc});var Bsc={Client:"client",Server:"server",_visit:(e,t)=>{switch(e){case Bsc.Client:return t.client();case Bsc.Server:return t.server();default:return t._other()}}};var Isc={Get:"GET",Post:"POST",_visit:(e,t)=>{switch(e){case Isc.Get:return t.get();case Isc.Post:return t.post();default:return t._other()}}};var _z={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case _z.GenerallyAvailable:return t.generallyAvailable();case _z.Beta:return t.beta();case _z.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 f9t={language:e=>({...e,type:"language",_visit:function(t){return f9t._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return f9t._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 hz={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 hz.Curl:return t.curl();case hz.Python:return t.python();case hz.Javascript:return t.javascript();case hz.Typescript:return t.typescript();case hz.Go:return t.go();case hz.Ruby:return t.ruby();case hz.Csharp:return t.csharp();case hz.Java:return t.java();case hz.Js:return t.js();case hz.Node:return t.node();case hz.Ts:return t.ts();case hz.Nodets:return t.nodets();case hz.Golang:return t.golang();case hz.Dotnet:return t.dotnet();case hz.Jvm:return t.jvm();default:return t._other()}}};var K0e={unknown:e=>({value:e,type:"unknown",_visit:function(t){return K0e._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return K0e._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 J0e={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return J0e._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return J0e._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 yz={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case yz.Get:return t.get();case yz.Post:return t.post();case yz.Put:return t.put();case yz.Patch:return t.patch();case yz.Delete:return t.delete();case yz.Head:return t.head();case yz.Options:return t.options();case yz.Trace:return t.trace();default:return t._other()}}};var bFt={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return bFt._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return bFt._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return bFt._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return bFt._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 Csc={Json:"json",Form:"form",_visit:(e,t)=>{switch(e){case Csc.Json:return t.json();case Csc.Form:return t.form();default:return t._other()}}};var d9t={file:e=>({...e,type:"file",_visit:function(t){return d9t._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return d9t._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 Rj={boolean:e=>({value:e,type:"boolean",_visit:function(t){return Rj._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Rj._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 p9t={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return p9t._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return p9t._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 gx={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return gx._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return gx._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return gx._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return gx._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 yP={file:e=>({...e,type:"file",_visit:function(t){return yP._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return yP._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return yP._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return yP._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return yP._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return yP._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return yP._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 ni={primitive:e=>({...e,type:"primitive",_visit:function(t){return ni._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ni._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return ni._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return ni._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return ni._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ni._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return ni._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return ni._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ni._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return ni._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return ni._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 Un={int:e=>({...e,type:"int",_visit:function(t){return Un._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Un._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Un._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Un._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Un._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Un._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Un._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Un._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Un._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Un._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Un._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={};Yt(Ns,{AllOfPropertyConflict:()=>cUn,ArraySchema:()=>I4o,ArraySchemaWithExample:()=>uLo,Availability:()=>jUo,Base64WithExample:()=>rLo,BasicSecurityScheme:()=>EUo,BearerSecurityScheme:()=>SUo,BooleanSchema:()=>j4o,BooleanWithExample:()=>iLo,BytesResponse:()=>ZQn,CasingOverrides:()=>BUo,CommonProperty:()=>Q4o,CommonPropertyWithExample:()=>yLo,CursorPagination:()=>u4o,CustomCodeSample:()=>a4o,CustomCodeSampleLanguage:()=>r4o,CustomCodeSampleSdk:()=>n4o,CustomPagination:()=>c4o,DateWithExample:()=>tLo,DatetimeWithExample:()=>eLo,DiscriminatedOneOfSchema:()=>N4o,DiscriminatedOneOfSchemaWithExample:()=>_Lo,DoubleSchema:()=>m4o,DoubleWithExample:()=>Z4o,Encoding:()=>PUo,Endpoint:()=>l4o,EndpointExample:()=>iUn,EndpointResponseExample:()=>t4o,EndpointSdkName:()=>y9t,EndpointSecurity:()=>xQn,EndpointWithExample:()=>bh_,EnumSchema:()=>LQn,EnumSchemaWithExample:()=>aLo,EnumValue:()=>LCi,ErrorExample:()=>YUo,FernExample:()=>ZUo,FileResponse:()=>YQn,FileSchema:()=>WUo,FloatWithExample:()=>X4o,FormUrlEncodedRequest:()=>JUo,FullEndpointExample:()=>o4o,FullExample:()=>Ym,FullObjectExample:()=>FUo,FullOneOfExample:()=>UUo,GlobalHeader:()=>S4o,GlobalSecurity:()=>E4o,Header:()=>WCi,HeaderExample:()=>rUn,HeaderSecurityScheme:()=>MUo,HeaderWithExample:()=>HCi,HttpEndpointServer:()=>eUn,HttpError:()=>XUo,HttpErrorWithExample:()=>H4o,HttpMethod:()=>GQn,IdempotencyHeader:()=>M4o,Int64WithExample:()=>J4o,IntSchema:()=>O4o,IntWithExample:()=>K4o,JsonRequest:()=>KUo,JsonRequestWithExample:()=>W4o,JsonResponse:()=>XQn,JsonResponseWithExample:()=>dUn,KeyValuePair:()=>QUo,LiteralExample:()=>zUo,LiteralSchema:()=>sUn,LiteralSchemaValue:()=>D4o,LongSchema:()=>A4o,MapSchema:()=>C4o,MapSchemaWithExample:()=>sLo,MultipartRequest:()=>$Qn,MultipartRequestProperty:()=>HUo,MultipartRequestPropertyEncoding:()=>GUo,MultipartSchema:()=>xUo,NamedFullExample:()=>Y0e,Namespace:()=>IUo,NamespaceId:()=>RUo,NullExample:()=>NUo,NullableSchema:()=>T4o,NullableSchemaWithExample:()=>lLo,OauthSecurityScheme:()=>qUo,ObjectProperty:()=>z4o,ObjectPropertyConflictInfo:()=>lUn,ObjectPropertyWithExample:()=>pLo,ObjectSchema:()=>B4o,ObjectSchemaWithExample:()=>fLo,OctetStreamRequest:()=>JQn,OffsetPagination:()=>s4o,OneOfSchema:()=>R4o,OneOfSchemaWithExample:()=>dLo,OpenApiIntermediateRepresentation:()=>hh_,OpenApiSource:()=>gUo,OptionalSchema:()=>q4o,OptionalSchemaWithExample:()=>cLo,Pagination:()=>nUn,ParseFormUrlEncodedRequest:()=>x4o,ParseMultipartRequest:()=>V4o,ParseOctetStreamRequest:()=>L4o,PathParameter:()=>HQn,PathParameterExample:()=>kUo,PathParameterWithExample:()=>U4o,PrimitiveExample:()=>WQn,PrimitiveSchema:()=>GCi,PrimitiveSchemaValue:()=>w4o,PrimitiveSchemaValueWithExample:()=>nLo,PrimitiveSchemaWithExample:()=>_Un,PropertyKey:()=>VQn,ProtobufEncoding:()=>mUo,ProtobufSource:()=>OUo,QueryParameter:()=>KQn,QueryParameterExample:()=>tUn,QueryParameterWithExample:()=>fUn,QuerySecurityScheme:()=>DUo,ReferencedSchema:()=>b9t,Request:()=>$Uo,RequestWithExample:()=>G4o,Response:()=>kQn,ResponseWithExample:()=>pUn,RetriesConfiguration:()=>aUn,Schema:()=>nd,SchemaId:()=>Ox,SchemaWithExample:()=>hO,Schemas:()=>g4o,SdkGroup:()=>CUo,SdkGroupInfo:()=>LUo,SdkGroupName:()=>VCi,SecurityScheme:()=>TUo,SecuritySchemeId:()=>UCi,Server:()=>eja,Source:()=>AUo,StatusCode:()=>_9t,StreamingResponseExample:()=>e4o,StringSchema:()=>P4o,StringSchemaWithExample:()=>k4o,SupportedSdkLanguage:()=>i4o,Tag:()=>wUo,TagId:()=>Ax,Tags:()=>VUo,TextResponse:()=>xCi,Uint64WithExample:()=>Y4o,UintWithExample:()=>$4o,UnDiscriminatedOneOfSchema:()=>F4o,UnDiscriminatedOneOfSchemaWithExample:()=>hLo,UnknownSchemaWithExample:()=>oLo,Webhook:()=>f4o,WebhookExampleCall:()=>uUn,WebhookHttpMethod:()=>oUn,WebhookWithExample:()=>vh_,WebsocketChannel:()=>v4o,WebsocketHandshake:()=>d4o,WebsocketHandshakeWithExample:()=>yh_,WebsocketMessageExample:()=>y4o,WebsocketMessageOrigin:()=>p4o,WebsocketMessageSchema:()=>_4o,WebsocketServer:()=>h4o,WebsocketSessionExample:()=>b4o,WithAvailability:()=>vu,WithDescription:()=>Ti,WithEncoding:()=>iK,WithInline:()=>_O,WithName:()=>Gl,WithNamespace:()=>Sl,WithSdkGroupName:()=>Hd,WithSdkMethodName:()=>h9t,WithSource:()=>ru,WithStatusCode:()=>$0e,WithTitle:()=>Gd,commons:()=>Nsc,example:()=>Fsc,finalIr:()=>Qsc,parseIr:()=>Usc});var Nsc={};Yt(Nsc,{BasicSecurityScheme:()=>EUo,BearerSecurityScheme:()=>SUo,Encoding:()=>PUo,HeaderSecurityScheme:()=>MUo,Namespace:()=>IUo,NamespaceId:()=>RUo,OauthSecurityScheme:()=>qUo,OpenApiSource:()=>gUo,ProtobufEncoding:()=>mUo,ProtobufSource:()=>OUo,QuerySecurityScheme:()=>DUo,SchemaId:()=>Ox,SdkGroup:()=>CUo,SdkGroupName:()=>VCi,SecurityScheme:()=>TUo,SecuritySchemeId:()=>UCi,Server:()=>eja,Source:()=>AUo,StatusCode:()=>_9t,Tag:()=>wUo,TagId:()=>Ax,WithAvailability:()=>vu,WithDescription:()=>Ti,WithEncoding:()=>iK,WithInline:()=>_O,WithName:()=>Gl,WithNamespace:()=>Sl,WithSdkGroupName:()=>Hd,WithSdkMethodName:()=>h9t,WithSource:()=>ru,WithStatusCode:()=>$0e,WithTitle:()=>Gd});var V={};Yt(V,{JsonError:()=>FQn,ParseError:()=>QQn,any:()=>rh_,bigint:()=>W__,boolean:()=>ih_,booleanLiteral:()=>th_,date:()=>x__,discriminant:()=>dh_,enum_:()=>yUo,getObjectLikeUtils:()=>vFt,getObjectUtils:()=>jJi,getSchemaUtils:()=>$m,isProperty:()=>QCi,lazy:()=>G__,lazyObject:()=>Z__,list:()=>vUo,number:()=>nh_,object:()=>bUo,objectWithoutOptionalProperties:()=>X__,optional:()=>qsc,property:()=>K__,record:()=>sh_,set:()=>ch_,string:()=>ah_,stringLiteral:()=>eh_,transform:()=>Tsc,undiscriminatedUnion:()=>fh_,union:()=>_h_,unknown:()=>oh_,withParsedProperties:()=>zsc});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 DA(e,t){return`Expected ${t}. Received ${WeM(e)}.`}function WeM(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 bz(e){return{...e,json:V__(e.json),parse:V__(e.parse)}}function V__(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(`
|
|
1411
|
-
`)),{ok:!0,value:t}):i}}function hUo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var FQn=class e extends Error{errors;constructor(t){super(t.map(hUo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var QQn=class e extends Error{errors;constructor(t){super(t.map(hUo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function $m(e){return{optional:()=>qsc(e),transform:t=>Tsc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new QQn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new FQn(i.errors)}}}function qsc(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,...$m(t)}}function Tsc(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,...$m(r)}}function W__(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:DA(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:DA(t,"bigint")}]},getType:()=>oh.BIGINT};return{...bz(e),...$m(e)}}var xeM=/^([+-]?\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 x__(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:DA(t,"string")}]}:xeM.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:DA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:DA(t,"Date object")}]},getType:()=>oh.DATE};return{...bz(e),...$m(e)}}function K3(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...bz(r),...$m(r)}}}function yUo(e){let t=new Set(e);return K3(oh.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:DA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:DA(i,"enum")}]}:{ok:!0,value:i})()}function G__(e){let t=Rsc(e);return{...t,...$m(t)}}function Rsc(e){return{parse:(t,r)=>UQn(e).parse(t,r),json:(t,r)=>UQn(e).json(t,r),getType:()=>UQn(e).getType()}}function UQn(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 FCi(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 H__(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function vFt(e){return{withParsedProperties:t=>zsc(e,t)}}function zsc(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(!FCi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:DA(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,...$m(r),...vFt(r)}}function K__(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function QCi(e){return e.isProperty}function bUo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>QCi(i)?i.rawKey:r),_getParsedProperties:()=>kPa(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of XPa(e)){let f=QCi(c)?c.rawKey:o,s=QCi(c)?c.valueSchema:c,u={rawKey:f,parsedKey:o,valueSchema:s};n[f]=u,Y__(s)&&a.push(f)}return J__({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=QCi(o)?o.valueSchema:o;Y__(c)&&n.push(a)}return J__({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return QCi(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{...bz(t),...$m(t),...vFt(t),...jJi(t)}}function J__({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!FCi(e))return{ok:!1,errors:[{path:a,message:DA(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 jJi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>$__({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>$__({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>oh.OBJECT};return{...r,...$m(r),...vFt(r),...jJi(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,...$m(t),...vFt(t),...jJi(t)}}}}function $__({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=H__(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 Y__(e){return!GeM(e)}function GeM(e){switch(e.getType()){case oh.ANY:case oh.UNKNOWN:case oh.OPTIONAL:return!0;default:return!1}}function X__(e){return bUo(e)}function Z__(e){let t={...Rsc(e),_getRawProperties:()=>UQn(e)._getRawProperties(),_getParsedProperties:()=>UQn(e)._getParsedProperties()};return{...t,...$m(t),...vFt(t),...jJi(t)}}function vUo(e){let t={parse:(r,i)=>k__(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>k__(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>oh.LIST};return{...bz(t),...$m(t)}}function k__(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:DA(e,"list"),path:[]}]}}function eh_(e){return K3(oh.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:DA(r,`"${e}"`)}]})()}function th_(e){return K3(oh.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:DA(r,`${e.toString()}`)}]})()}var rh_=K3(oh.ANY,e=>({ok:!0,value:e}));var ih_=K3(oh.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DA(e,"boolean")}]});var nh_=K3(oh.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DA(e,"number")}]});var ah_=K3(oh.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DA(e,"string")}]});var oh_=K3(oh.UNKNOWN,e=>({ok:!0,value:e}));function sh_(e,t){let r={parse:(i,n)=>uh_({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)=>uh_({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{...bz(r),...$m(r)}}function uh_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return FCi(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:DA(e,"object")}]}}function ch_(e){let t=vUo(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:DA(i,"Set")}]},getType:()=>oh.SET};return{...bz(r),...$m(r)}}function fh_(e){let t={parse:(r,i)=>lh_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>lh_((n,a)=>n.json(r,a),e,i),getType:()=>oh.UNDISCRIMINATED_UNION};return{...bz(t),...$m(t)}}function lh_(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 dh_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function _h_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=yUo(kPa(t)),a={parse:(o,c)=>ph_({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)=>ph_({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{...bz(a),...$m(a),...vFt(a)}}function ph_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!FCi(e))return{ok:!1,errors:[{path:c,message:DA(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=V.objectWithoutOptionalProperties({title:V.string().optional()});var gUo=V.objectWithoutOptionalProperties({file:V.string()});var OUo=V.objectWithoutOptionalProperties({file:V.string()});var AUo=V.union("type",{openapi:gUo,protobuf:OUo}).transform({transform:e=>{switch(e.type){case"openapi":return H3.openapi(e);case"protobuf":return H3.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var ru=V.objectWithoutOptionalProperties({source:AUo.optional()});var mUo=V.objectWithoutOptionalProperties({typeName:V.string()});var PUo=V.union("type",{protobuf:mUo}).transform({transform:e=>{switch(e.type){case"protobuf":return NQn.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var iK=V.objectWithoutOptionalProperties({encoding:PUo.optional()});var Ti=V.objectWithoutOptionalProperties({description:V.string().optional()});var jUo=V.enum_(["GenerallyAvailable","Beta","Deprecated"]);var vu=V.objectWithoutOptionalProperties({availability:jUo.optional()});var _9t=V.number();var $0e=V.objectWithoutOptionalProperties({statusCode:_9t.optional()});var Gl=V.objectWithoutOptionalProperties({nameOverride:V.string().optional(),generatedName:V.string()});var _O=V.objectWithoutOptionalProperties({inline:V.boolean().optional()});var Ox=V.string();var Ax=V.string();var wUo=V.objectWithoutOptionalProperties({id:Ax}).extend(Ti);var UCi=V.string();var EUo=V.objectWithoutOptionalProperties({usernameVariableName:V.string().optional(),usernameEnvVar:V.string().optional(),passwordVariableName:V.string().optional(),passwordEnvVar:V.string().optional()});var SUo=V.objectWithoutOptionalProperties({tokenVariableName:V.string().optional(),tokenEnvVar:V.string().optional()});var MUo=V.objectWithoutOptionalProperties({headerName:V.string(),prefix:V.string().optional(),headerVariableName:V.string().optional(),headerEnvVar:V.string().optional()});var DUo=V.objectWithoutOptionalProperties({queryParameterName:V.string()});var BUo=V.objectWithoutOptionalProperties({snake:V.string().optional(),camel:V.string().optional(),screamingSnake:V.string().optional(),pascal:V.string().optional()});var LCi=V.objectWithoutOptionalProperties({nameOverride:V.string().optional(),generatedName:V.string(),value:V.string(),casing:BUo.optional()}).extend(Ti).extend(vu);var IUo=V.objectWithoutOptionalProperties({type:V.stringLiteral("namespace"),name:V.string()});var CUo=V.undiscriminatedUnion([V.string(),IUo]);var VCi=V.list(CUo);var Hd=V.objectWithoutOptionalProperties({groupName:VCi.optional()});var Sl=V.objectWithoutOptionalProperties({namespace:V.string().optional()});var LQn=V.objectWithoutOptionalProperties({default:LCi.optional(),values:V.list(LCi)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(ru).extend(Gd).extend(_O);var qUo=V.objectWithoutOptionalProperties({scopesEnum:LQn.optional()});var TUo=V.union("type",{basic:EUo,bearer:SUo,header:MUo,query:DUo,oauth:qUo}).transform({transform:e=>{switch(e.type){case"basic":return pz.basic(e);case"bearer":return pz.bearer(e);case"header":return pz.header(e);case"query":return pz.query(e);case"oauth":return pz.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var eja=V.objectWithoutOptionalProperties({name:V.string().optional(),url:V.string(),audiences:V.list(V.string()).optional()}).extend(Ti);var RUo=V.string();var h9t=V.objectWithoutOptionalProperties({sdkMethodName:V.string().optional()});var Fsc={};Yt(Fsc,{FullExample:()=>Ym,FullObjectExample:()=>FUo,FullOneOfExample:()=>UUo,KeyValuePair:()=>QUo,LiteralExample:()=>zUo,NullExample:()=>NUo,PrimitiveExample:()=>WQn,PropertyKey:()=>VQn});var VQn=V.string();var WQn=V.union("type",{int:V.object({value:V.number()}),int64:V.object({value:V.number()}),uint:V.object({value:V.number()}),uint64:V.object({value:V.number()}),float:V.object({value:V.number()}),double:V.object({value:V.number()}),string:V.object({value:V.string()}),datetime:V.object({value:V.string()}),date:V.object({value:V.string()}),base64:V.object({value:V.string()}),boolean:V.object({value:V.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return Ka.int(e.value);case"int64":return Ka.int64(e.value);case"uint":return Ka.uint(e.value);case"uint64":return Ka.uint64(e.value);case"float":return Ka.float(e.value);case"double":return Ka.double(e.value);case"string":return Ka.string(e.value);case"datetime":return Ka.datetime(e.value);case"date":return Ka.date(e.value);case"base64":return Ka.base64(e.value);case"boolean":return Ka.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var zUo=V.union("type",{boolean:V.object({value:V.boolean()}),string:V.object({value:V.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return zCi.boolean(e.value);case"string":return zCi.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var NUo=V.objectWithoutOptionalProperties({});var Ym=V.union("type",{primitive:V.object({value:WQn}),object:V.lazyObject(()=>FUo),array:V.object({value:V.list(V.lazy(()=>Ym))}),map:V.object({value:V.list(V.lazyObject(()=>QUo))}),enum:V.object({value:V.string()}),literal:V.object({value:zUo}),oneOf:V.object({value:V.lazy(()=>UUo)}),null:NUo,unknown:V.object({value:V.lazy(()=>Ym)})}).transform({transform:e=>{switch(e.type){case"primitive":return Zc.primitive(e.value);case"object":return Zc.object(e);case"array":return Zc.array(e.value);case"map":return Zc.map(e.value);case"enum":return Zc.enum(e.value);case"literal":return Zc.literal(e.value);case"oneOf":return Zc.oneOf(e.value);case"null":return Zc.null(e);case"unknown":return Zc.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var FUo=V.objectWithoutOptionalProperties({properties:V.record(VQn,V.lazy(()=>Ym))});var QUo=V.objectWithoutOptionalProperties({key:WQn,value:V.lazy(()=>Ym)});var UUo=V.union("type",{discriminated:V.object({value:V.record(VQn,V.lazy(()=>Ym))}),undiscriminated:V.object({value:V.lazy(()=>Ym)})}).transform({transform:e=>{switch(e.type){case"discriminated":return NCi.discriminated(e.value);case"undiscriminated":return NCi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Qsc={};Yt(Qsc,{AllOfPropertyConflict:()=>cUn,ArraySchema:()=>I4o,Availability:()=>jUo,BooleanSchema:()=>j4o,BytesResponse:()=>ZQn,CasingOverrides:()=>BUo,CommonProperty:()=>Q4o,CursorPagination:()=>u4o,CustomCodeSample:()=>a4o,CustomCodeSampleLanguage:()=>r4o,CustomCodeSampleSdk:()=>n4o,CustomPagination:()=>c4o,DiscriminatedOneOfSchema:()=>N4o,DoubleSchema:()=>m4o,Endpoint:()=>l4o,EndpointExample:()=>iUn,EndpointResponseExample:()=>t4o,EndpointSdkName:()=>y9t,EndpointSecurity:()=>xQn,EnumSchema:()=>LQn,EnumValue:()=>LCi,ErrorExample:()=>YUo,FernExample:()=>ZUo,FileResponse:()=>YQn,FileSchema:()=>WUo,FormUrlEncodedRequest:()=>JUo,FullEndpointExample:()=>o4o,GlobalHeader:()=>S4o,GlobalSecurity:()=>E4o,Header:()=>WCi,HeaderExample:()=>rUn,HttpEndpointServer:()=>eUn,HttpError:()=>XUo,HttpMethod:()=>GQn,IdempotencyHeader:()=>M4o,IntSchema:()=>O4o,JsonRequest:()=>KUo,JsonResponse:()=>XQn,LiteralSchema:()=>sUn,LiteralSchemaValue:()=>D4o,LongSchema:()=>A4o,MapSchema:()=>C4o,MultipartRequest:()=>$Qn,MultipartRequestProperty:()=>HUo,MultipartRequestPropertyEncoding:()=>GUo,MultipartSchema:()=>xUo,NullableSchema:()=>T4o,ObjectProperty:()=>z4o,ObjectPropertyConflictInfo:()=>lUn,ObjectSchema:()=>B4o,OctetStreamRequest:()=>JQn,OffsetPagination:()=>s4o,OneOfSchema:()=>R4o,OpenApiIntermediateRepresentation:()=>hh_,OptionalSchema:()=>q4o,Pagination:()=>nUn,PathParameter:()=>HQn,PathParameterExample:()=>kUo,PrimitiveSchema:()=>GCi,PrimitiveSchemaValue:()=>w4o,QueryParameter:()=>KQn,QueryParameterExample:()=>tUn,ReferencedSchema:()=>b9t,Request:()=>$Uo,Response:()=>kQn,RetriesConfiguration:()=>aUn,Schema:()=>nd,Schemas:()=>g4o,SdkGroupInfo:()=>LUo,StreamingResponseExample:()=>e4o,StringSchema:()=>P4o,SupportedSdkLanguage:()=>i4o,Tags:()=>VUo,TextResponse:()=>xCi,UnDiscriminatedOneOfSchema:()=>F4o,Webhook:()=>f4o,WebhookExampleCall:()=>uUn,WebhookHttpMethod:()=>oUn,WebsocketChannel:()=>v4o,WebsocketHandshake:()=>d4o,WebsocketMessageExample:()=>y4o,WebsocketMessageOrigin:()=>p4o,WebsocketMessageSchema:()=>_4o,WebsocketServer:()=>h4o,WebsocketSessionExample:()=>b4o});var LUo=V.objectWithoutOptionalProperties({summary:V.string().optional(),description:V.string().optional()});var VUo=V.objectWithoutOptionalProperties({tagsById:V.record(Ax,wUo),orderedTagIds:V.list(Ax).optional()});var xQn=V.list(V.record(UCi,V.list(V.string())));var GQn=V.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var HQn=V.objectWithoutOptionalProperties({name:V.string(),schema:V.lazy(()=>nd),variableReference:V.string().optional(),parameterNameOverride:V.string().optional()}).extend(Ti).extend(vu).extend(ru);var KQn=V.objectWithoutOptionalProperties({name:V.string(),schema:V.lazy(()=>nd),parameterNameOverride:V.string().optional()}).extend(Ti).extend(vu).extend(ru);var WCi=V.objectWithoutOptionalProperties({name:V.string(),schema:V.lazy(()=>nd),env:V.string().optional(),parameterNameOverride:V.string().optional()}).extend(Ti).extend(vu).extend(ru);var y9t=V.objectWithoutOptionalProperties({groupName:VCi,methodName:V.string()});var JQn=V.objectWithoutOptionalProperties({contentType:V.string().optional()}).extend(Ti).extend(ru);var WUo=V.objectWithoutOptionalProperties({isOptional:V.boolean(),isArray:V.boolean()}).extend(Ti);var xUo=V.union("type",{file:WUo,json:V.object({value:V.lazy(()=>nd)})}).transform({transform:e=>{switch(e.type){case"file":return d9t.file(e);case"json":return d9t.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var GUo=V.enum_(["json","form"]);var HUo=V.objectWithoutOptionalProperties({key:V.string(),schema:xUo,contentType:V.string().optional(),exploded:V.boolean().optional(),encoding:GUo.optional()}).extend(Ti);var $Qn=V.objectWithoutOptionalProperties({name:V.string().optional(),properties:V.list(HUo)}).extend(Ti).extend(ru);var KUo=V.objectWithoutOptionalProperties({schema:V.lazy(()=>nd),contentType:V.string().optional(),additionalProperties:V.boolean()}).extend(Ti).extend(ru);var JUo=V.objectWithoutOptionalProperties({schema:V.lazy(()=>nd),contentType:V.string().optional(),additionalProperties:V.boolean()}).extend(Ti).extend(ru);var $Uo=V.union("type",{octetStream:JQn,multipart:$Qn,json:KUo,formUrlEncoded:JUo}).transform({transform:e=>{switch(e.type){case"octetStream":return bFt.octetStream(e);case"multipart":return bFt.multipart(e);case"json":return bFt.json(e);case"formUrlEncoded":return bFt.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var YQn=V.objectWithoutOptionalProperties({}).extend(Ti).extend(ru).extend($0e);var XQn=V.objectWithoutOptionalProperties({schema:V.lazy(()=>nd),responseProperty:V.string().optional()}).extend(Ti).extend(ru).extend($0e);var xCi=V.objectWithoutOptionalProperties({}).extend(Ti).extend(ru).extend($0e);var ZQn=V.objectWithoutOptionalProperties({}).extend(Ti).extend(ru).extend($0e);var kQn=V.union("type",{file:YQn,json:XQn,text:xCi,bytes:ZQn,streamingSse:XQn,streamingText:xCi,streamingJson:XQn}).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 YUo=V.objectWithoutOptionalProperties({name:V.string().optional(),description:V.string().optional(),example:V.lazy(()=>Ym)});var XUo=V.objectWithoutOptionalProperties({schema:V.lazy(()=>nd).optional(),examples:V.list(YUo).optional()}).extend(Ti).extend(Gl).extend(ru);var eUn=V.objectWithoutOptionalProperties({name:V.string().optional(),url:V.string().optional(),audiences:V.list(V.string()).optional()});var ZUo=V.unknown();var kUo=V.objectWithoutOptionalProperties({name:V.string(),parameterNameOverride:V.string().optional(),value:V.lazy(()=>Ym)});var tUn=V.objectWithoutOptionalProperties({name:V.string(),value:V.lazy(()=>Ym)});var rUn=V.objectWithoutOptionalProperties({name:V.string(),value:V.lazy(()=>Ym)});var e4o=V.objectWithoutOptionalProperties({sse:V.boolean(),events:V.list(V.lazy(()=>Ym))});var t4o=V.union("type",{withStreaming:e4o,withoutStreaming:V.object({value:V.lazy(()=>Ym)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return J0e.withStreaming(e);case"withoutStreaming":return J0e.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var r4o=V.objectWithoutOptionalProperties({name:V.string().optional(),language:V.string(),code:V.string(),install:V.string().optional()}).extend(Ti);var i4o=V.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var n4o=V.objectWithoutOptionalProperties({name:V.string().optional(),sdk:i4o,code:V.string()}).extend(Ti);var a4o=V.union("type",{language:r4o,sdk:n4o}).transform({transform:e=>{switch(e.type){case"language":return f9t.language(e);case"sdk":return f9t.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var o4o=V.objectWithoutOptionalProperties({name:V.string().optional(),pathParameters:V.list(kUo).optional(),queryParameters:V.list(tUn).optional(),headers:V.list(rUn).optional(),request:V.lazy(()=>Ym).optional(),response:t4o.optional(),codeSamples:V.list(a4o)}).extend(Ti);var iUn=V.union("type",{unknown:V.object({value:ZUo}),full:o4o}).transform({transform:e=>{switch(e.type){case"unknown":return K0e.unknown(e.value);case"full":return K0e.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var u4o=V.objectWithoutOptionalProperties({cursor:V.string(),nextCursor:V.property("next_cursor",V.string()),results:V.string()});var s4o=V.objectWithoutOptionalProperties({offset:V.string(),results:V.string(),step:V.string().optional(),hasNextPage:V.string().optional()});var c4o=V.objectWithoutOptionalProperties({results:V.string()});var nUn=V.union("type",{cursor:u4o,offset:s4o,custom:c4o}).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 aUn=V.union("type",{disabled:V.object({value:V.boolean().optional()})}).transform({transform:e=>{switch(e.type){case"disabled":return YPa.disabled(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var l4o=V.objectWithoutOptionalProperties({authed:V.boolean(),security:xQn.optional(),internal:V.boolean().optional(),idempotent:V.boolean().optional(),method:GQn,audiences:V.list(V.string()),path:V.string(),summary:V.string().optional(),operationId:V.string().optional(),tags:V.list(Ax),pathParameters:V.list(HQn),queryParameters:V.list(KQn),headers:V.list(WCi),sdkName:y9t.optional(),generatedRequestName:V.string(),requestNameOverride:V.string().optional(),request:$Uo.optional(),response:kQn.optional(),errors:V.record(_9t,XUo),servers:V.list(eUn),examples:V.list(iUn),pagination:nUn.optional(),retries:aUn.optional()}).extend(Ti).extend(vu).extend(ru).extend(Sl);var oUn=V.enum_(["GET","POST"]);var uUn=V.objectWithoutOptionalProperties({name:V.string().optional(),payload:V.lazy(()=>Ym)}).extend(Ti);var f4o=V.objectWithoutOptionalProperties({audiences:V.list(V.string()),sdkName:y9t.optional(),method:oUn,summary:V.string().optional(),operationId:V.string(),tags:V.list(Ax),headers:V.list(WCi),generatedPayloadName:V.string(),payload:V.lazy(()=>nd),response:kQn.optional(),examples:V.list(uUn)}).extend(Ti).extend(ru).extend(Sl);var d4o=V.objectWithoutOptionalProperties({queryParameters:V.list(KQn),headers:V.list(WCi),pathParameters:V.list(HQn)});var p4o=V.enum_(["client","server"]);var _4o=V.objectWithoutOptionalProperties({name:V.string(),origin:p4o,body:V.lazy(()=>nd)});var h4o=V.objectWithoutOptionalProperties({name:V.string(),url:V.string()});var y4o=V.objectWithoutOptionalProperties({messageType:V.string(),payload:V.lazy(()=>Ym)}).extend(Ti);var b4o=V.objectWithoutOptionalProperties({name:V.string().optional(),queryParameters:V.list(tUn).optional(),headers:V.list(rUn).optional(),messages:V.list(y4o)}).extend(Ti);var v4o=V.objectWithoutOptionalProperties({audiences:V.list(V.string()),path:V.string(),groupName:VCi,summary:V.string().optional(),handshake:d4o,messages:V.list(_4o),servers:V.list(h4o),examples:V.list(b4o)}).extend(Ti).extend(ru);var g4o=V.objectWithoutOptionalProperties({rootSchemas:V.record(Ox,V.lazy(()=>nd)),namespacedSchemas:V.record(RUo,V.record(Ox,V.lazy(()=>nd)))});var O4o=V.objectWithoutOptionalProperties({default:V.number().optional(),minimum:V.number().optional(),maximum:V.number().optional(),exclusiveMinimum:V.boolean().optional(),exclusiveMaximum:V.boolean().optional(),multipleOf:V.number().optional()});var A4o=V.objectWithoutOptionalProperties({default:V.number().optional()});var m4o=V.objectWithoutOptionalProperties({default:V.number().optional(),minimum:V.number().optional(),maximum:V.number().optional(),exclusiveMinimum:V.boolean().optional(),exclusiveMaximum:V.boolean().optional(),multipleOf:V.number().optional()});var P4o=V.objectWithoutOptionalProperties({default:V.string().optional(),pattern:V.string().optional(),format:V.string().optional(),minLength:V.number().optional(),maxLength:V.number().optional()});var j4o=V.objectWithoutOptionalProperties({default:V.boolean().optional()});var w4o=V.union("type",{int:O4o,int64:A4o,uint:V.object({}),uint64:V.object({}),float:V.object({}),double:m4o,string:P4o,datetime:V.object({}),date:V.object({}),base64:V.object({}),boolean:j4o}).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 GCi=V.objectWithoutOptionalProperties({schema:w4o}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd);var E4o=V.list(V.record(UCi,V.list(V.string())));var S4o=V.objectWithoutOptionalProperties({header:V.string(),name:V.string().optional(),optional:V.boolean().optional(),env:V.string().optional(),schema:V.lazy(()=>nd).optional()});var M4o=V.objectWithoutOptionalProperties({header:V.string(),name:V.string().optional(),env:V.string().optional(),schema:V.lazy(()=>nd).optional()});var hh_=V.objectWithoutOptionalProperties({apiVersion:V.unknown().optional(),title:V.string().optional(),description:V.string().optional(),basePath:V.string().optional(),servers:V.list(eja),websocketServers:V.list(eja),groups:V.record(V.string(),LUo),tags:VUo,hasEndpointsMarkedInternal:V.boolean(),endpoints:V.list(l4o),webhooks:V.list(f4o),channels:V.record(V.string(),v4o),groupedSchemas:g4o,variables:V.record(V.string(),GCi),nonRequestReferencedSchemas:V.set(Ox),securitySchemes:V.record(UCi,TUo),security:E4o.optional(),globalHeaders:V.list(S4o).optional(),idempotencyHeaders:V.list(M4o).optional()});var b9t=V.objectWithoutOptionalProperties({schema:Ox}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(ru).extend(Gd);var D4o=V.union("type",{boolean:V.object({value:V.boolean()}),string:V.object({value:V.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Rj.boolean(e.value);case"string":return Rj.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var sUn=V.objectWithoutOptionalProperties({value:D4o}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd);var nd=V.union("type",{primitive:GCi,object:V.lazyObject(()=>B4o),array:V.lazyObject(()=>I4o),map:V.lazyObject(()=>C4o),optional:V.lazyObject(()=>q4o),enum:LQn,reference:b9t,literal:sUn,oneOf:V.object({value:V.lazy(()=>R4o)}),nullable:V.lazyObject(()=>T4o),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 cUn=V.objectWithoutOptionalProperties({propertyKey:V.string(),allOfSchemaIds:V.list(Ox),conflictingTypeSignatures:V.boolean()});var B4o=V.objectWithoutOptionalProperties({allOf:V.list(b9t),properties:V.list(V.lazyObject(()=>z4o)),allOfPropertyConflicts:V.list(cUn),additionalProperties:V.boolean()}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(ru).extend(Gd).extend(_O);var lUn=V.objectWithoutOptionalProperties({differentSchema:V.boolean()});var z4o=V.objectWithoutOptionalProperties({key:V.string(),schema:V.lazy(()=>nd),readonly:V.boolean().optional(),writeonly:V.boolean().optional(),conflict:V.record(Ox,lUn),generatedName:V.string(),nameOverride:V.string().optional(),audiences:V.list(V.string())}).extend(vu);var I4o=V.objectWithoutOptionalProperties({value:V.lazy(()=>nd)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd).extend(_O);var C4o=V.objectWithoutOptionalProperties({key:GCi,value:V.lazy(()=>nd)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(iK).extend(Gd).extend(_O);var q4o=V.objectWithoutOptionalProperties({value:V.lazy(()=>nd)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd).extend(_O);var T4o=V.objectWithoutOptionalProperties({value:V.lazy(()=>nd)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd).extend(_O);var R4o=V.union("type",{discriminated:V.lazyObject(()=>N4o),undiscriminated:V.lazyObject(()=>F4o)}).transform({transform:e=>{switch(e.type){case"discriminated":return p9t.discriminated(e);case"undiscriminated":return p9t.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var N4o=V.objectWithoutOptionalProperties({discriminantProperty:V.string(),commonProperties:V.list(V.lazyObject(()=>Q4o)),schemas:V.record(V.string(),V.lazy(()=>nd))}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(iK).extend(ru).extend(Gd).extend(_O);var Q4o=V.objectWithoutOptionalProperties({key:V.string(),schema:V.lazy(()=>nd)});var F4o=V.objectWithoutOptionalProperties({schemas:V.list(V.lazy(()=>nd))}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(iK).extend(ru).extend(Gd).extend(_O);var Usc={};Yt(Usc,{ArraySchemaWithExample:()=>uLo,Base64WithExample:()=>rLo,BooleanWithExample:()=>iLo,CommonPropertyWithExample:()=>yLo,DateWithExample:()=>tLo,DatetimeWithExample:()=>eLo,DiscriminatedOneOfSchemaWithExample:()=>_Lo,DoubleWithExample:()=>Z4o,EndpointWithExample:()=>bh_,EnumSchemaWithExample:()=>aLo,FloatWithExample:()=>X4o,HeaderWithExample:()=>HCi,HttpErrorWithExample:()=>H4o,Int64WithExample:()=>J4o,IntWithExample:()=>K4o,JsonRequestWithExample:()=>W4o,JsonResponseWithExample:()=>dUn,MapSchemaWithExample:()=>sLo,NamedFullExample:()=>Y0e,NullableSchemaWithExample:()=>lLo,ObjectPropertyWithExample:()=>pLo,ObjectSchemaWithExample:()=>fLo,OneOfSchemaWithExample:()=>dLo,OptionalSchemaWithExample:()=>cLo,ParseFormUrlEncodedRequest:()=>x4o,ParseMultipartRequest:()=>V4o,ParseOctetStreamRequest:()=>L4o,PathParameterWithExample:()=>U4o,PrimitiveSchemaValueWithExample:()=>nLo,PrimitiveSchemaWithExample:()=>_Un,QueryParameterWithExample:()=>fUn,RequestWithExample:()=>G4o,ResponseWithExample:()=>pUn,SchemaWithExample:()=>hO,StringSchemaWithExample:()=>k4o,Uint64WithExample:()=>Y4o,UintWithExample:()=>$4o,UnDiscriminatedOneOfSchemaWithExample:()=>hLo,UnknownSchemaWithExample:()=>oLo,WebhookWithExample:()=>vh_,WebsocketHandshakeWithExample:()=>yh_});var Y0e=V.objectWithoutOptionalProperties({name:V.string().optional(),value:V.unknown()}).extend(Ti);var fUn=V.objectWithoutOptionalProperties({name:V.string(),schema:V.lazy(()=>hO),parameterNameOverride:V.string().optional(),explode:V.boolean().optional()}).extend(Ti).extend(vu).extend(ru);var HCi=V.objectWithoutOptionalProperties({name:V.string(),schema:V.lazy(()=>hO),env:V.string().optional(),parameterNameOverride:V.string().optional()}).extend(Ti).extend(vu).extend(ru);var yh_=V.objectWithoutOptionalProperties({queryParameters:V.list(fUn),headers:V.list(HCi)});var U4o=V.objectWithoutOptionalProperties({name:V.string(),schema:V.lazy(()=>hO),variableReference:V.string().optional(),parameterNameOverride:V.string().optional(),explode:V.boolean().optional()}).extend(Ti).extend(vu).extend(ru);var L4o=V.objectWithoutOptionalProperties({}).extend(JQn).extend(h9t);var V4o=V.objectWithoutOptionalProperties({}).extend($Qn).extend(h9t);var W4o=V.objectWithoutOptionalProperties({schema:V.lazy(()=>hO),contentType:V.string().optional(),fullExamples:V.list(Y0e).optional(),additionalProperties:V.boolean()}).extend(Ti).extend(ru).extend(h9t);var x4o=V.objectWithoutOptionalProperties({schema:V.lazy(()=>hO),contentType:V.string().optional(),fullExamples:V.list(Y0e).optional(),additionalProperties:V.boolean()}).extend(Ti).extend(ru).extend(h9t);var G4o=V.union("type",{octetStream:L4o,multipart:V4o,json:W4o,formUrlEncoded:x4o}).transform({transform:e=>{switch(e.type){case"octetStream":return gx.octetStream(e);case"multipart":return gx.multipart(e);case"json":return gx.json(e);case"formUrlEncoded":return gx.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var dUn=V.objectWithoutOptionalProperties({schema:V.lazy(()=>hO),responseProperty:V.string().optional(),fullExamples:V.list(Y0e).optional()}).extend(Ti).extend(ru).extend($0e);var pUn=V.union("type",{file:YQn,json:dUn,text:xCi,bytes:ZQn,streamingSse:dUn,streamingText:xCi,streamingJson:dUn}).transform({transform:e=>{switch(e.type){case"file":return yP.file(e);case"json":return yP.json(e);case"text":return yP.text(e);case"bytes":return yP.bytes(e);case"streamingSse":return yP.streamingSse(e);case"streamingText":return yP.streamingText(e);case"streamingJson":return yP.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var H4o=V.objectWithoutOptionalProperties({statusCode:_9t,schema:V.lazy(()=>hO),fullExamples:V.list(Y0e).optional()}).extend(Ti).extend(Gl).extend(ru);var bh_=V.objectWithoutOptionalProperties({authed:V.boolean(),security:xQn.optional(),internal:V.boolean().optional(),idempotent:V.boolean().optional(),method:GQn,audiences:V.list(V.string()),path:V.string(),summary:V.string().optional(),operationId:V.string().optional(),tags:V.list(Ax),pathParameters:V.list(U4o),queryParameters:V.list(fUn),headers:V.list(HCi),sdkName:y9t.optional(),generatedRequestName:V.string(),requestNameOverride:V.string().optional(),request:G4o.optional(),response:pUn.optional(),errors:V.record(_9t,H4o),servers:V.list(eUn),examples:V.list(iUn),pagination:nUn.optional(),retries:aUn.optional()}).extend(Ti).extend(vu).extend(ru).extend(Sl);var vh_=V.objectWithoutOptionalProperties({audiences:V.list(V.string()),sdkName:y9t.optional(),method:oUn,summary:V.string().optional(),operationId:V.string(),tags:V.list(Ax),headers:V.list(HCi),generatedPayloadName:V.string(),payload:V.lazy(()=>hO),response:pUn.optional(),examples:V.list(uUn)}).extend(Ti).extend(ru).extend(Sl);var K4o=V.objectWithoutOptionalProperties({default:V.number().optional(),minimum:V.number().optional(),maximum:V.number().optional(),exclusiveMinimum:V.boolean().optional(),exclusiveMaximum:V.boolean().optional(),multipleOf:V.number().optional(),example:V.number().optional()});var J4o=V.objectWithoutOptionalProperties({default:V.number().optional(),example:V.number().optional()});var $4o=V.objectWithoutOptionalProperties({default:V.number().optional(),example:V.number().optional()});var Y4o=V.objectWithoutOptionalProperties({default:V.number().optional(),example:V.number().optional()});var X4o=V.objectWithoutOptionalProperties({example:V.number().optional()});var Z4o=V.objectWithoutOptionalProperties({default:V.number().optional(),minimum:V.number().optional(),maximum:V.number().optional(),exclusiveMinimum:V.boolean().optional(),exclusiveMaximum:V.boolean().optional(),multipleOf:V.number().optional(),example:V.number().optional()});var k4o=V.objectWithoutOptionalProperties({default:V.string().optional(),pattern:V.string().optional(),format:V.string().optional(),minLength:V.number().optional(),maxLength:V.number().optional(),example:V.string().optional()});var eLo=V.objectWithoutOptionalProperties({example:V.string().optional()});var tLo=V.objectWithoutOptionalProperties({example:V.string().optional()});var rLo=V.objectWithoutOptionalProperties({example:V.string().optional()});var iLo=V.objectWithoutOptionalProperties({default:V.boolean().optional(),example:V.boolean().optional()});var nLo=V.union("type",{int:K4o,int64:J4o,uint:$4o,uint64:Y4o,float:X4o,double:Z4o,string:k4o,datetime:eLo,date:tLo,base64:rLo,boolean:iLo}).transform({transform:e=>{switch(e.type){case"int":return Un.int(e);case"int64":return Un.int64(e);case"uint":return Un.uint(e);case"uint64":return Un.uint64(e);case"float":return Un.float(e);case"double":return Un.double(e);case"string":return Un.string(e);case"datetime":return Un.datetime(e);case"date":return Un.date(e);case"base64":return Un.base64(e);case"boolean":return Un.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var _Un=V.objectWithoutOptionalProperties({schema:nLo}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd);var aLo=V.objectWithoutOptionalProperties({default:LCi.optional(),values:V.list(LCi),example:V.string().optional()}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(ru).extend(Gd).extend(_O);var oLo=V.objectWithoutOptionalProperties({example:V.unknown()}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd);var hO=V.union("type",{primitive:_Un,object:V.lazyObject(()=>fLo),array:V.lazyObject(()=>uLo),map:V.lazyObject(()=>sLo),optional:V.lazyObject(()=>cLo),enum:aLo,reference:b9t,literal:sUn,oneOf:V.object({value:V.lazy(()=>dLo)}),nullable:V.lazyObject(()=>lLo),unknown:oLo}).transform({transform:e=>{switch(e.type){case"primitive":return ni.primitive(e);case"object":return ni.object(e);case"array":return ni.array(e);case"map":return ni.map(e);case"optional":return ni.optional(e);case"enum":return ni.enum(e);case"reference":return ni.reference(e);case"literal":return ni.literal(e);case"oneOf":return ni.oneOf(e.value);case"nullable":return ni.nullable(e);case"unknown":return ni.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var uLo=V.objectWithoutOptionalProperties({value:V.lazy(()=>hO),example:V.list(V.unknown()).optional()}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd).extend(_O);var sLo=V.objectWithoutOptionalProperties({key:_Un,value:V.lazy(()=>hO),example:V.unknown().optional()}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(iK).extend(Gd).extend(_O);var cLo=V.objectWithoutOptionalProperties({value:V.lazy(()=>hO)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd).extend(_O);var lLo=V.objectWithoutOptionalProperties({value:V.lazy(()=>hO)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd).extend(_O);var fLo=V.objectWithoutOptionalProperties({allOf:V.list(b9t),properties:V.list(V.lazyObject(()=>pLo)),allOfPropertyConflicts:V.list(cUn),fullExamples:V.list(Y0e).optional(),additionalProperties:V.boolean()}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(ru).extend(Gd).extend(_O);var pLo=V.objectWithoutOptionalProperties({key:V.string(),schema:V.lazy(()=>hO),readonly:V.boolean().optional(),writeonly:V.boolean().optional(),audiences:V.list(V.string()),conflict:V.record(Ox,lUn),nameOverride:V.string().optional(),generatedName:V.string()}).extend(vu);var dLo=V.union("type",{discriminated:V.lazyObject(()=>_Lo),undiscriminated:V.lazyObject(()=>hLo)}).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 _Lo=V.objectWithoutOptionalProperties({discriminantProperty:V.string(),commonProperties:V.list(V.lazyObject(()=>yLo)),schemas:V.record(V.string(),V.lazy(()=>hO))}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(iK).extend(ru).extend(Gd).extend(_O);var yLo=V.objectWithoutOptionalProperties({key:V.string(),schema:V.lazy(()=>hO)});var hLo=V.objectWithoutOptionalProperties({schemas:V.list(V.lazy(()=>hO))}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(iK).extend(ru).extend(Gd).extend(_O);var gh_=/^(\d+)/,hUn=/^[a-zA-Z][a-zA-Z0-9_]*$/,Oh_={"<":"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 wJi(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_${wJi(c)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${wJi(a)}`}function tja(e){let t=e.match(gh_);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=wJi(n);return i.length>0?`${a}_${i}`:a}}}function yUn(e){let t=tja(e),r=Oh_[e];return t!=null?TP(Fo(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":TP(Fo(e)))}function nK(e,t){return e.type==="primitive"&&t.type==="primitive"?Ah_(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?HeM(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"?KeM(e.value,t.value):e.type==="object"&&t.type==="object"?JeM(e,t):e.type==="map"&&t.type==="map"?Ah_(e.key.schema,t.key.schema)&&nK(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function Ah_(e,t){return e.type===t.type}function HeM(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return t1(r,i)}function KeM(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 JeM(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 kE(e){switch(e){case _z.Deprecated:return"deprecated";case _z.Beta:return"pre-release";case _z.GenerallyAvailable:return"generally-available";default:return}}function $eM(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 mh_(e){let t=e?$eM(e):void 0;if(t==null||t.length===0)return Jxi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(Fo(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(Fo(n.name)):r.push(n.name,Jxi);break}default:Ot(n.type)}else Ot(n);return r.join("/")}function gFt(e){return Ru.of(`${mh_(e)}.yml`)}function Lsc({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Jxi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,mh_(r))}function Ph_({sdkName:e,namespaceOverride:t}){return Ru.of(`${Lsc({sdkName:e,namespaceOverride:t})}.yml`)}function jh_({location:e,namespaceOverride:t}){return t!=null?tD(Ru.of(t),e):e}function bLo(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Ot(e.type)}}function Vvi(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:Ot(e)}}function ly(e){return typeof e=="string"?e:e.type}function bUn(e){if(typeof e!="string")return e.docs}function rja(e){if(typeof e!="string")return e.default}function Vsc(e){if(typeof e!="string")return e.validation}function vUn(e){let t=e.match(/^optional<\s*nullable<\s*(.+)\s*>\s*>$/);if(t!=null&&t[1]!=null)return t[1].trim();let r=e.match(/^nullable<\s*(.+)\s*>$/);return r!=null&&r[1]!=null?r[1].trim():e}function Eh_(e){let t=ly(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?wh_(e):{...e,type:wh_(e.type)}}function wh_(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function EJi(e){return ly(e).startsWith("optional<")?e:typeof e=="string"?Sh_(e):{...e,type:Sh_(e.type)}}function Sh_(e){return e.startsWith("optional<")?e:`optional<${e}>`}var YeM=-2147483648,XeM=2147483647,ZeM=-17976931348623157e292,keM=17976931348623157e292;function kc({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 vLo(e);case"array":return Gsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return Hsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return xsc({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return Jsc();case"optional":return gLo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return Ksc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return stM({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,$sc(e);case"object":return ctM({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return ltM({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:Ot(e)}}function vLo(e){switch(e.schema.type){case"string":return rtM({description:e.description,schema:e.schema});case"int":return itM({description:e.description,schema:e.schema});case"float":return ntM({description:e.description,schema:e.schema});case"double":return atM({description:e.description,schema:e.schema});case"boolean":return etM({description:e.description,schema:e.schema});case"int64":return ttM({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:kE(e.availability)}:{}}}function etM({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 ttM({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 rtM({description:e,schema:t}){let r="string",i=otM(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 itM({description:e,schema:t}){let r="integer",i=Mh_(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 ntM({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function atM({description:e,schema:t}){let r="double",i=Mh_(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 otM(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=utM(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function utM(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 Mh_(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:o}=e;if(r=Wsc(r,t),i=Wsc(i,t),n=Wsc(n,t),!(r==null&&i==null&&a==null&&o==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:o,multipleOf:n}}function Wsc(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[YeM,XeM]:[ZeM,keM];return e<r||e>i?void 0:e}function xsc({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=ftM(n)??e.schema,o=Vvi(n),c=dtM(n),s=OLo({context:r,fileContainingReference:t,declarationFile:gFt(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:kE(e.availability)}:{}}}function Gsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=kc({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=`list<${ly(o)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:kE(e.availability)}:{},type:c}}function Hsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=vLo(e.key),c=kc({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),f=e.encoding!=null?bLo(e.encoding):void 0,s=`map<${ly(o)}, ${ly(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=kE(e.availability)),u}function Ksc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.options.respectNullableSchemas)return gLo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let o=kc({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=ly(o),f=bUn(o),s=rja(o),u=Vsc(o),l=Eh_(c);if(i.options.wrapReferencesToNullableInOptional&&(l=EJi(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=kE(e.availability)),p}function gLo({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=kc({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=ly(o),f=bUn(o),s=rja(o),u=Vsc(o),l=EJi(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=kE(e.availability)),p}function Jsc(){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:Ot(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:kE(e.availability)}:{}}}function stM({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=OLo({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=kE(e.availability)),f}function ctM({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=OLo({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:kE(e.availability)}:{}}}function ltM({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Xsc({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=OLo({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:kE(e.availability)}:{}}}function OLo({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 ftM(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 dtM(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 q1;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(q1||(q1={}));function Wvi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Ot(e)}}function Bh_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=htM(e);break;case"array":a=ptM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=_tM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=ytM({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=vtM(e.nameOverride,e.generatedName);break;case"optional":a=Ch_({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=gtM(e,e.nameOverride,e.generatedName);break;case"object":a=Ysc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=Xsc({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:Ot(e)}return a}function Ysc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(q1.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])=>{Zsc({property:_.key,schemaId:g,context:t,namespace:i}).forEach(j=>{f.add(j)})})}let h=kc({schema:_.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),y=_.audiences,b=_.nameOverride,v=kE(_.availability),O=PtM(_);c[_.key]=mtM({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=ALo({schema:_.schema,context:t,namespace:i});if(h==null||f.has(_.schema)||f.has(h))continue;let y=kc({schema:zs.reference(_),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(vUn(ly(y)))}for(let _ of f){let h=gUn(t,_,i);for(let y of h.properties)c[y.key]==null&&(s.has(y.key)&&(c[y.key]="unknown"),c[y.key]=kc({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=kc({schema:zs.reference(y),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(vUn(ly(b)))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([_,h])=>AtM(_)?[_,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=kE(e.availability)),e.source!=null&&(l.source=Wvi(e.source)),l.inline=ksc(e,n);let p=e.nameOverride??e.generatedName;return{name:o&&t.options.respectReadonlySchemas&&!a?`${p}Read`:p,schema:l}}function Zsc({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return Zsc({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:o}=gUn(r,t,i),c=a.some(s=>s.key===e),f=[...o.flatMap(s=>Zsc({property:e,context:r,schemaId:s.schema,namespace:i}))];if(c||f.length>0)return[t,...f]}return[]}function Ih_(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?gUn(e,t.schema,r):t.type==="nullable"?Ih_(e,t.value,r):{properties:[],allOf:[]}}function gUn(e,t,r){let i=e.getSchema(t,r);return i==null?{properties:[],allOf:[]}:Ih_(e,i,r)}function ptM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:Gsc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function _tM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:Hsc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function htM(e){let t=vLo(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 Dh_(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||Dh_(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&&!Dh_(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=ksc(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?Wvi(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 ytM({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:xsc({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:Ksc({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:Ch_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function Ch_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:gLo({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function vtM(e,t){return{name:e??t,schema:Jsc()}}function gtM(e,t,r){return{name:t??r,schema:$sc(e)}}function Xsc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?bLo(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=kc({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]=kc({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?kE(e.availability):void 0,union:f,encoding:a,source:e.source!=null?Wvi(e.source):void 0}}}let o=[];for(let c of e.schemas)o.push(kc({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?Wvi(e.source):void 0,inline:ksc(e,n)}}}var OtM=/^[0-9]/;function AtM(e){return OtM.test(e)}function ALo({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?ALo({context:t,schema:i.schema,namespace:r}):e}function mtM({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 ksc(e,t){return e.inline===!0||t>0?!0:void 0}function PtM(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return mD.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return mD.ObjectPropertyAccess.WriteOnly}}function qh_(e){let t=e.replace(/^x-|^X-/,"");return Fo(t)}function Th_(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??qh_(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(Ru.of("__package__.yml"),{name:"OauthScope",schema:ija(i.scopesEnum,0).schema})}}function v9t({header:e,context:t,fileContainingReference:r,namespace:i}){let n=kc({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=ly(n),o=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:Fo(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=kE(e.availability)),f}function mLo({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=kc({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return ly(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:ly(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=kE(e.availability)),a}function jLo({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=ecc({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=ly(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=kE(e.availability)),jtM(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 ecc({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:kc({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:Ru.of(ab),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"&&(hUn.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:yUn(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&&PLo({array:c,primitive:f}))return{value:kc({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&&PLo({array:c,primitive:f}))return{value:kc({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 ecc({schema:f,context:t,fileContainingReference:r,namespace:i})}else if(t.options.objectQueryParameters)return{value:kc({schema:e,context:t,fileContainingReference:r,declarationFile:Ru.of(ab),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:kc({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:Ru.of(ab),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.options.objectQueryParameters)return{value:kc({schema:e,context:t,fileContainingReference:r,declarationFile:Ru.of(ab),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:kc({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"&&(hUn.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:yUn(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&&PLo({array:c,primitive:f}))return{value:kc({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&&PLo({array:f,primitive:c}))return{value:kc({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:kc({schema:e,context:t,fileContainingReference:r,declarationFile:Ru.of(ab),namespace:i,declarationDepth:0}),allowMultiple:!1};for(let[c,f]of Object.entries(e.value.value.schemas))return ecc({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:kc({schema:e,context:t,fileContainingReference:r,declarationFile:Ru.of(ab),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:kc({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:kc({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:kc({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function PLo({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function jtM(e){return typeof e=="object"&&e!==null&&"type"in e}function Rh_({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"]=wtM(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=EtM({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=KCi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function wtM(e){let t={};return e.forEach(r=>{let i=KCi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function EtM({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=KCi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function KCi(e){switch(e.type){case"primitive":return zh_(e.value);case"object":return Nh_(e.properties);case"array":return StM(e.value);case"map":return MtM(e.value);case"oneOf":return DtM(e.value);case"enum":return e.value;case"literal":return BtM(e.value);case"unknown":return KCi(e.value);case"null":return null;default:Ot(e)}}function zh_(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:Ot(e)}}function Nh_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,KCi(r)]))}function StM(e){return e.map(t=>KCi(t))}function MtM(e){return Object.fromEntries(e.map(t=>[zh_(t.key),KCi(t.value)]))}function DtM(e){return e.type==="discriminated"?Nh_(e.value):KCi(e.value)}function BtM(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ot(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 wLo(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function ELo(e,t,r=!1){let i=nja(t);return r&&i!=null?i:e!=null&&i!=null?`${e}_${i}`:i??e??"websocket"}function xvi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function SLo(e,t){return t??(e?.groupName!=null?xvi(e.groupName):void 0)}function Fh_({channel:e,context:t,declarationFile:r}){let i=e.servers[0],n=i!=null?t.options.groupEnvironmentsByHost?t.getUrlId(i.url)??ELo(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=xvi(e.groupName),c={};if(e.handshake.pathParameters.length>0)for(let u of e.handshake.pathParameters)c[u.name]=mLo({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=jLo({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=v9t({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:kc({schema:u.body,context:t,fileContainingReference:r,namespace:o,declarationDepth:0})}});for(let u of e.examples){let l=Rh_({context:t,websocketExample:u});t.builder.addChannelExample(r,{example:l})}}function tcc(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var X0e="Base",Lh_="Default";function Qh_(e){try{return new URL(e).hostname}catch{return}}function Uh_(e){return e??Lh_}function ItM(e,t){let r=new Map;for(let i of e){if(tcc(i)||!("url"in i)||!i.url)continue;let n=Qh_(i.url)??i.url;r.has(n)||r.set(n,{environmentName:Uh_(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=Qh_(i.url)??i.url;r.has(n)||r.set(n,{environmentName:Uh_(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.websocketServers.push(i)}return r}function SJi(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 Vh_(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=>tcc(v)),n=e.ir.servers;for(let v of n)if(tcc(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=ItM(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=wLo(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[X0e]=D.url,e.setUrlId(D.url,X0e));for(let B=1;B<m.httpServers.length;B++){let F=m.httpServers[B];if(F!=null){let N=nja(F.url),R=wLo(F.url),z=N?E.get(N):void 0,L=z&&z.size>1,J=L&&R!=="https"?`${N}_${R}`:N||`Http${B+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${F.url}", pathSegment="${N}", protocol="${R}", hasCollision=${L}, urlId="${J}"`),j[J]=F.url,e.setUrlId(F.url,J)}}}for(let D of m.websocketServers){let B=nja(D.url),F=wLo(D.url),N=B?E.get(B):void 0,R=N&&N.size>1,z=R?`${B}_${F}`:ELo(D.name,D.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${D.name}", url="${D.url}", pathSegment="${B}", protocol="${F}", hasCollision=${R}, urlId="${z}"`),j[z]=D.url,e.setUrlId(D.url,z)}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(X0e),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(X0e);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[Lh_]=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:{[X0e]:g??"",...SJi(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:{[X0e]:g??"",...SJi(f)}}})}else e.builder.addEnvironment({name:O,schema:A});h&&e.builder.setDefaultUrl(X0e)}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:{[X0e]:A??"",...SJi(o),...SJi(f)}}}),e.builder.setDefaultEnvironment(v),e.builder.setDefaultUrl(X0e)}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={[X0e]: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,SJi(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(X0e)}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:{[X0e]:m??"",...SJi(o),...SJi(f)}}})}else e.builder.addEnvironment({name:A,schema:g});O&&(e.builder.setDefaultEnvironment(A),O=!1)}}}}var rcc=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},CtM=.75,qtM=new Set("authorization");function Wh_(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?Vvi(i.schema):void 0,o=a!=null?xvi(a):void 0,c=Ru.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?ly(kc({schema:i.schema,context:e,fileContainingReference:o?tD(Ru.of(Fo(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(qtM.has(a.name.toLowerCase()))continue;let o=r[a.name];if(o==null){let c=t[a.name],f=v9t({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:Ru.of(i1),context:e,namespace:void 0});o=new rcc(f),r[a.name]=o}o.increment()}let i=e.ir.endpoints.length*CtM;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:EJi(a.schema)}))}}}function xh_(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?Vvi(t.schema):void 0,i=r!=null?xvi(r):void 0,n=v9t({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:Ru.of(i1),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:EJi(n)})}}function J3(e){switch(e.type){case"primitive":return Hh_(e.value);case"object":return Kh_(e.properties);case"array":return Jh_(e.value);case"map":return RtM(e.value);case"oneOf":return ztM(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return NtM(e.value);case"unknown":return J3(e.value);case"null":return null;default:Ot(e)}}function Gh_(e){switch(e.type){case"withStreaming":return e.sse?{stream:TtM(e.events)}:{stream:Jh_(e.events)};case"withoutStreaming":return{body:J3(e.value)};default:Ot(e)}}function Hh_(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:Ot(e)}}function Kh_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,J3(r)]))}function TtM(e){return e.map(t=>({event:"",data:J3(t)}))}function Jh_(e){return e.map(t=>J3(t))}function RtM(e){return Object.fromEntries(e.map(t=>[Hh_(t.key),J3(t.value)]))}function ztM(e){return e.type==="discriminated"?Kh_(e.value):J3(e.value)}function NtM(e){switch(e.type){case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"boolean":return e.value;default:Ot(e)}}function $h_({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"]=FtM(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=QtM(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=wB({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:Mt}});u!=null&&c.push({name:f,value:Zc.literal(zCi.string(u))})}else c.push({name:f,value:Zc.primitive(Ka.string(f))});r.headers=UtM({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=J3(e.request)),e.response!=null&&(r.response=Gh_(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(ts)),r}function FtM(e){let t={};return e.forEach(r=>{let i=J3(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function QtM(e){let t={};return e.forEach(r=>{let i=J3(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function UtM({context:e,namedFullExamples:t}){let r={};return t.forEach(i=>{let n=J3(i.value);n!=null&&(r[i.name]=n)}),r}function Yh_(e){return yz._visit(e,{get:()=>mD.HttpMethodSchema.Get,post:()=>mD.HttpMethodSchema.Post,put:()=>mD.HttpMethodSchema.Put,patch:()=>mD.HttpMethodSchema.Patch,delete:()=>mD.HttpMethodSchema.Delete,head:()=>mD.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 Xh_(e){return e==="POST"||e==="PUT"||e==="PATCH"}function Zh_({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,o=e.path,c=SLo(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]=mLo({pathParameter:b,context:r,fileContainingReference:t,namespace:c}),a.add(b.name);let s={};for(let b of e.queryParameters){let v=jLo({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:Ot(e.pagination)}let l={path:o,method:Yh_(e.method),auth:LtM({endpoint:e,context:r}),docs:e.description??void 0,pagination:u,source:e.source!=null?Wvi(e.source):void 0};!GtM({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=v9t({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(q1.Request);let b=xtM({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(q1.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=kc({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:b.description??void 0,type:ly(v)},b.statusCode!=null&&(l.response["status-code"]=b.statusCode),b.responseProperty!=null&&(l.response.property=b.responseProperty)},streamingJson:b=>{let v=kc({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:ly(v),format:"json"}},streamingSse:b=>{let v=kc({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:ly(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=kE(e.availability)),Object.entries(e.errors).forEach(([b,v])=>{let O=v.generatedName,A=Ru.of(ab);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=jh_({location:kh_,namespaceOverride:c});if(v.schema!=null){let E=kc({schema:v.schema,context:r,fileContainingReference:m,declarationFile:m,namespace:c,declarationDepth:0});g.type=ly(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:J3(E.example),name:E.name,docs:E.description};r.builder.addErrorExample(m,{name:O,example:D})})}),e.examples.length>0&&(l.examples=VtM({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=WtM({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[icc,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function LtM({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 VtM({endpointExamples:e,context:t}){return e.map(r=>{try{return $h_({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function WtM({retries:e}){if(e!=null)switch(e.type){case"disabled":return{disabled:e.value??void 0};default:Ot(e)}}function xtM({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 m=kc({schema:i.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),j={schemaIdsToExclude:[],value:{body:m}},M=Object.keys(o??{}).length>0,E=Object.keys(c??{}).length>0,D=Object.keys(s??{}).length>0;return M&&(j.value["path-parameters"]=o),E&&(j.value["query-parameters"]=c),D&&(j.value.headers=s),(M||E||D)&&(j.value.name=n??a),i.contentType!=null&&(j.value["content-type"]=i.contentType),i.description!=null&&(j.value.docs=i.description),j}let h=new Map;for(let m of _.allOf){let j=r.getSchema(m.schema,l);if(j==null)continue;let M=Vvi(j),E=gFt(M),{properties:D}=gUn(r,m.schema,l);for(let B of D)h.set(B.key,E)}let y=Object.fromEntries(_.properties.filter(m=>m.readonly==null?!0:!(Xh_(e.method)&&m.readonly)).map(m=>{let j=h.get(m.key)??t,M=kc({schema:m.schema,fileContainingReference:t,declarationFile:j,context:r,namespace:l,declarationDepth:1}),E=m.nameOverride??m.key,D=kE(m.availability);if(!u.has(E)&&m.audiences.length<=0)return u.add(E),m.nameOverride!=null?[m.key,{type:ly(M),docs:bUn(M),name:m.nameOverride,availability:D}]:[m.key,D?{...typeof M=="string"?{type:M}:M,availability:D}:M];let B={type:ly(M),docs:bUn(M)};return u.has(E)&&(B.name=m.generatedName),m.audiences.length>0&&(B.audiences=m.audiences),D!=null&&(B.availability=D),u.add(E),[m.key,B]})),b=new Set,v=new Set;for(let m of _.allOfPropertyConflicts)m.allOfSchemaIds.forEach(j=>b.add(j)),m.conflictingTypeSignatures&&v.add(m.propertyKey);let O=[];for(let m of _.allOf){let j=ALo({schema:m.schema,context:r,namespace:l});if(j==null||b.has(m.schema)||b.has(j))continue;let M=kc({schema:zs.reference(m),fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),E=vUn(ly(M));E!=="unknown"&&O.push(E)}for(let m of b){let j=gUn(r,m,l),M=r.getSchema(m,l),E=M!=null?gFt(Vvi(M)):t;for(let D of j.properties)y[D.key]==null&&(v.has(D.key)?y[D.key]="unknown":y[D.key]=kc({schema:D.schema,fileContainingReference:t,declarationFile:E,context:r,namespace:l,declarationDepth:1}));for(let D of j.allOf){if(b.has(D.schema))continue;let B=kc({schema:zs.reference(D),fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),F=vUn(ly(B));F!=="unknown"&&!O.includes(F)&&O.push(F)}}let A={properties:y};O.length>0&&(A.extends=O),i.additionalProperties&&(A["extra-properties"]=!0);let g={name:n??_.nameOverride??_.generatedName,"path-parameters":o,"query-parameters":c,headers:s,body:A};return i.contentType!=null&&(g["content-type"]=i.contentType),i.description!=null&&(g.docs=i.description),{schemaIdsToExclude:p!=null?[p]:[],value:g}}else if(i.type==="octetStream"){let p={body:"bytes","content-type":i.contentType??oO.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=kc({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":oO.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else Ot(i)}function GtM({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:Ot(t)}}function HtM({location:e,namespaceOverride:t}){return t!=null?{...e,file:tD(Ru.of(t),e.file)}:e}function KtM(e){let t=e.namespace,r=e.tags.filter(f=>f!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:Ru.of(`${Fo(r)}.yml`),endpointId:e.summary!=null?Fo(e.summary):Fo(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Ru.of(ab),endpointId:Fo(e.summary)}:{file:Ru.of(ab),endpointId:Fo(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Ru.of(ab),endpointId:i};let n=aja(r),a=aja(i);if(t1(n,a))return{file:Ru.of("__package__.yml"),endpointId:r};let o=YtM({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=Fo(r);return{file:Ru.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:Ru.of(Fo(c.join("_"))+".yml"),endpointId:Fo(a.slice(c.length).join("_")),tag:r}}function oja(e){let t=e.tags[0];if(e.sdkName!=null){let r=Lsc({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Ru.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return HtM({namespaceOverride:e.namespace,location:KtM(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=XOe(t),t}var JtM=new RegExp("[^a-zA-Z0-9{}]+"),$tM=new RegExp("[{}]","g");function YtM({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(JtM).join("_").replaceAll($tM,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:Ru.of(Fo(t)+".yml"),endpointId:Fo(e.slice(0,-1*a.length)),tag:t}}function ey_(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(q1.Endpoint),e.setEndpointMethod(a.method);let p=Zh_({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(q1.Endpoint),n=[...n,...p.schemaIdsToExclude],e.builder.addEndpoint(c,{name:o,schema:p.value,source:a.source!=null?Wvi(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 ty_(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?xvi(r.groupName):void 0,n=kc({schema:zs.primitive(r),context:e,fileContainingReference:Ru.of(ab),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:ly(n),docs:r.description??void 0}})}}function ry_(e){for(let t of e.ir.webhooks){let r=ktM({webhook:t,context:e});if(r==null)continue;let i=SLo(t.sdkName,t.namespace),n={};for(let o of t.headers)n[o.name]=v9t({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:kc({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:J3(o.payload)})):void 0};t.response!=null&&t.response._visit({json:o=>{let c=kc({schema:o.schema,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0});a.response={docs:o.description??void 0,type:ly(c)},o.statusCode!=null&&(a.response["status-code"]=o.statusCode)},file:o=>{a.response={docs:o.description??void 0,type:"file","status-code":o.statusCode}},bytes:o=>{a.response={docs:o.description??void 0,type:"bytes","status-code":o.statusCode}},text:o=>{a.response={docs:o.description??void 0,type:"text","status-code":o.statusCode}},streamingJson:o=>{let c=kc({schema:o.schema,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0});a["response-stream"]={docs:o.description??void 0,type:ly(c),format:"json"}},streamingSse:o=>{let c=kc({schema:o.schema,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0});a["response-stream"]={docs:o.description??void 0,type:ly(c),format:"sse"}},streamingText:o=>{a["response-stream"]={docs:o.description??void 0,type:"text"}},_other:()=>{throw new Error("Unrecognized Response type: "+t.response?.type)}}),e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function XtM({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:tD(Ru.of(t),e.file)}:e}function ZtM({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:Ru.of(ab),endpointId:i};let n=aja(r),a=aja(i);if(t1(n,a))return{file:Ru.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=Fo(r);return{file:Ru.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:Ru.of(Fo(o.join("_"))+".yml"),endpointId:Fo(a.slice(o.length).join("_")),tag:r}}function ktM({webhook:e,context:t}){return e.sdkName!=null?{file:Ph_({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:XtM({namespaceOverride:e.namespace,location:ZtM({webhook:e,context:t})})}var erM=Ru.of(ab);function ny_(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return iy_({namespace:e.namespace,groupName:e.groupName});case"oneOf":return iy_({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return erM;default:Ot(e)}}function iy_({namespace:e,groupName:t}){return e!=null&&t!=null?gFt([{type:"namespace",name:e},...t]):e!=null?gFt([{type:"namespace",name:e}]):gFt(t)}var icc="external",kh_=Ru.of(ab);function ay_({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let o=ny_(a),c=Bh_({schema:a,context:i,declarationFile:o,namespace:r,declarationDepth:0});if(mCi(c.schema)){let f=ly(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 oy_(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),Vh_(e),Wh_(e),xh_(e),Th_(e),ty_(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(icc);let t=ey_(e),r=t.sdkGroups;e.setInState(q1.Webhook),ry_(e),e.unsetInState(q1.Webhook),e.setInState(q1.Channel);for(let n of Object.values(e.ir.channels)){let a=gFt(n.groupName);Fh_({channel:n,context:e,declarationFile:a})}e.unsetInState(q1.Channel);let i=trM({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});ay_({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))ay_({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 trM({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 MLo=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[o,c]of Object.entries(i.files)){let f=n!=null?Ru.of(`${n}${"/"}${o}`):Ru.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[Ru.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 MJi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new MLo,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 n9t(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"]))uy_(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(uy_(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??Fo((_Ae(r)+"/"+g6i(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Ru.of(i1))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=vuo(_Ae(xDn.of(`/${t}`)),xDn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=vuo(_Ae(xDn.of(`/${t}`)),xDn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===Ru.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=tD(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:tD(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:tD(r,o.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===ab?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 uy_(e){return e?.header!=null}var DLo=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=PJi({options:i}),this.enableUniqueErrorsPerEndpoint=this.options.enableUniqueErrorsPerEndpoint,this.referencedSchemaIds=this.options.onlyIncludeReferencedSchemas?new Set:void 0,this.builder=new MJi(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(q1.Channel,q1.Endpoint,q1.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:Ot(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:Ot(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 ncc(e){let t=new DLo(e);return oy_(t)}function rrM(e){return NKi(e,{single:t=>[typeof t=="string"?t:t.scheme],any:t=>t.any.map(r=>typeof r=="string"?r:r.scheme)})}function irM(e,t){if(e==null)return;let r=rrM(t),i={};for(let n of r)e[n]!=null&&(i[n]=e[n]);return Object.keys(i).length>0?i:void 0}var BLo=class{args;constructor(t){this.args=t}buildAuthOverrides(t,r){let i=this.args.generatorsConfiguration?.api?.["auth-schemes"],n=this.args.generatorsConfiguration?.api?.auth,a=t??n;if(a==null)return;let o=r!=null||i!=null?{...i,...r}:void 0,c=irM(o,a);return{auth:a,"auth-schemes":c}}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=ncc({taskContext:t,ir:r,options:PJi({options:i,overrides:this.args}),authOverrides:this.buildAuthOverrides(i?.auth,i?.authSchemes),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:Ei.dump(a.rootApiFile)},namedDefinitionFiles:{..._n(a.definitionFiles,o=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Ei.dump(o),contents:o})),[Ru.of(ab)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Ei.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var sja=class extends hFt{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;coerceEnumsToLiterals;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;groupEnvironmentsByHost;removeDiscriminantsFromSchemas;defaultIntegerFormat;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.coerceEnumsToLiterals=t.coerceEnumsToLiterals,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.defaultIntegerFormat=t.defaultIntegerFormat,this.converter=new BLo(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 OUn={of(e){return e}};var sy_={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},acc={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:sy_,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},xi={SOURCE:OUn.of("source"),SDK_NAMESPACE:OUn.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:OUn.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:OUn.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:OUn.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 nrM={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:hn.RemoveDiscriminantsFromSchemas.Always,defaultIntegerFormat:hn.DefaultIntegerFormat.Int32};function arM(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 Z0e({options:e,overrides:t}){return arM({defaults:nrM,options:e,overrides:t,overrideOnly:new Set(["disableExamples","preserveSchemaIds"]),undefinedIfAbsent:new Set(["exampleGeneration","defaultFormParameterEncoding"])})}var cy_={naming:"v1"};function Ii(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=Ii(e,t);if(a!=null)return r.parse(a)}catch{let o=XOe(n).join(" -> ");i.error(`${o.length>0?`${o}: `:""}Failed to parse ${t}`)}}function DJi(e){let t=Ii(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 ly_({schema:e,logger:t}){return Ii(e,xi.ENCODING)??void 0}function fy_(e){return Ii(e,xi.FERN_ENUM)}function dy_({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let o=Ii(i,xi.SDK_NAMESPACE),c=Ii(i,xi.SDK_GROUP_NAME),f=Ii(i,xi.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 wB({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.base64({example:void 0})});case"BOOLEAN":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.boolean({default:void 0,example:void 0})});case"DATE":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.date({example:void 0})});case"DATE_TIME":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.datetime({example:void 0})});case"FLOAT":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.float({example:void 0})});case"DOUBLE":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.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 ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.uint({default:void 0,example:void 0})});case"INTEGER":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.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 ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.uint64({default:void 0,example:void 0})});case"LONG":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Ot(f.v1)}},unknown:()=>ni.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?ni.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?ni.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?ni.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?ni.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?ni.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=>ni.literal({nameOverride:t,generatedName:r,title:i,value:f._visit({string:s=>Rj.string(s),boolean:s=>Rj.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:o,groupName:c}),named:f=>ni.reference({schema:f,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,source:H3.openapi({file:"<memory>"})})}})}function py_(e){let t=Ii(e,xi.SOURCE);if(t!=null)return t.endsWith(".proto")?H3.protobuf({file:t}):H3.openapi({file:t})}function BJi(e){if(e!=null&&typeof e=="boolean")return e}function mn(e){return e?.$ref!=null}function _y_({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),occ({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:Un.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)?ni.unknown({...orM(n),generatedName:`${t}Value`}):hy_(Ml(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 hy_(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=hy_(e.value);break;case"oneOf":e.value.inline=!0;break;default:Ot(e)}return e}function occ({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 _=ni.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&&(_=ni.nullable({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:f,namespace:s,groupName:u,inline:void 0})),a&&(_=ni.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:!(mn(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 orM(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"||mn(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function yy_({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?ni.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:l}):Ml(n,!1,!1,s,[...i,"Item"],_,u);return urM({nameOverride:e,generatedName:t,title:r,namespace:u,groupName:l,itemSchema:h,wrapAsOptional:c,wrapAsNullable:f,description:a,availability:o,example:p})}function urM({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:f,groupName:s,example:u}){let l=ni.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=ni.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),n&&(l=ni.optional({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),l}function $3(e){switch(Ii(e,xi.AVAILABILITY)){case"deprecated":return _z.Deprecated;case"beta":return _z.Beta;case"generally-available":return _z.GenerallyAvailable;default:break}if(!mn(e)&&e.deprecated)return _z.Deprecated}function ucc({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=Gvi({$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=Ml(g,j,M,l,[...i,A],y,p);return{key:A,schema:E}});return by_({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 scc({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(mn(g)){let m=Gvi(g,!1,!1,p,[g.$ref],y,b,_);return p.markReferencedByDiscriminatedUnion(g,u,1),[A,m]}else{let m=AUn(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=Ml(g,j,M,p,[...i,A],b,_);return{key:A,schema:E}});return by_({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 by_({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 _=ni.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&&(_=ni.nullable({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),i&&(_=ni.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 NQn.protobuf({typeName:e.proto.type})}function JCi({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=crM(n??[]),v=new Set(a),O=Array.from(v).map((g,m)=>{let j=i?.[g],M=b[m],E=hUn.test(g),D=j?.name??M,B=E?g:yUn(g);return D!=null&&!hUn.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 srM({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 srM({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 _=ni.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&&(_=ni.nullable({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:f,namespace:s,groupName:u,inline:p})),e&&(_=ni.optional({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:f,namespace:s,groupName:u,inline:p})),_}function crM(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 gy_({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,defaultIntegerFormat:v=hn.DefaultIntegerFormat.Int32}){let O=i??v,A=(()=>{switch(O){case hn.DefaultIntegerFormat.Int64:return Un.int64({default:n,example:h});case hn.DefaultIntegerFormat.Uint32:return Un.uint({default:n,example:h});case hn.DefaultIntegerFormat.Uint64:return Un.uint64({default:n,example:h});default:return Un.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h})}})();return Y3({nameOverride:e,generatedName:t,title:r,primitive:A,wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}function lrM(e){return typeof e=="string"?Rj.string(e):typeof e=="boolean"?Rj.boolean(e):Rj.string(`${e}`)}function Oy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,value:a,description:o,availability:c,namespace:f,groupName:s}){let u=ni.literal({nameOverride:e,generatedName:t,title:r,value:lrM(a),description:o,availability:c,namespace:f,groupName:s});return n&&(u=ni.nullable({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),i&&(u=ni.optional({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),u}function ccc({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"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.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"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int32"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.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"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.int64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint32"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.uint({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint64"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.uint64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="time-delta"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}var frM={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},drM={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}}},prM={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}}},_rM={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},hrM={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},yrM={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:[]})},vrM={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=[frM,drM,prM,_rM,hrM,yrM,brM,vrM],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 RC(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:TP(Fo(n))).join("");return/^\d/.test(i)?tja(i)??i:i}function Ay_(e){let t=e.join("_");return Fo(t)}function WO(e){switch(e.type){case"object":return zs.object({allOf:e.allOf,properties:e.properties.map(t=>OrM(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:WO(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:WO(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:WO(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return zs.primitive({description:e.description,availability:e.availability,schema:my_(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:my_(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:WO(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(grM(e.value));case"unknown":return zs.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Ot(e)}}function grM(e){switch(e.type){case"discriminated":return p9t.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:WO(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,WO(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return p9t.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>WO(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:Ot(e)}}function my_(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:Ot(e)}}function OrM(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:WO(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function ILo(e,t){return nK(WO(e),WO(t))}function Py_({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&&mn(B)){let F=u.resolveSchemaReference(B);if(F.discriminator!=null&&F.discriminator.mapping!=null)continue;if(F.oneOf!=null||F.anyOf!=null){let R=F.oneOf??F.anyOf;if(R!=null){for(let z of R){let L=mn(z)?u.resolveSchemaReference(z):z,H=Ml(L,!1,!1,u.DUMMY,i,v,p);H.type==="object"&&g.push(...H.properties.map(J=>J.schema.type!=="optional"&&J.schema.type!=="nullable"?{...J,schema:ni.optional({nameOverride:void 0,generatedName:"",title:void 0,value:J.schema,description:void 0,availability:J.availability,namespace:void 0,groupName:void 0,inline:void 0})}:J))}continue}}let N=$Ci(B);if(N==null)continue;m.push({schemaId:N,convertedSchema:lcc(B,[N],v,u.options.preserveSchemaIds),properties:wy_({schema:B,context:u,breadcrumbs:i,source:v,namespace:p})}),u.markSchemaAsReferencedByNonRequest(N)}else if(mn(B)){let F=u.resolveSchemaReference(B),N=Ml(F,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}else{let F=B.required??[];g=g.map(R=>(R.schema.type==="optional"||R.schema.type==="nullable")&&F.includes(R.key)?{...R,schema:R.schema.value}:R);let N=Ml(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 R=j[F];R!=null?(R.schemaIds.push(B.schemaId),R.schemas.some(L=>ILo(L,N))||R.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])=>!(!mn(F)&&F.type==="null"))),D=Object.entries(E).map(([B,F])=>{let N=Ii(F,xi.AUDIENCES)??[],R=$3(F),z=mn(F)?!1:F.readOnly,L=mn(F)?!1:F.writeOnly,J=!(O.includes(B)&&!z),ue=Ii(F,xi.FERN_PROPERTY_NAME),de=[...i,B],U=Ay_(de),W=Ml(F,J,!1,u,de,v,p),Te={};for(let ce of m){let we=ce.properties[B];we!=null&&!ILo(W,we)?Te[ce.schemaId]={differentSchema:!0}:we!=null&&(Te[ce.schemaId]={differentSchema:!1})}return{key:B,schema:W,nameOverride:ue,audiences:N,conflict:Te,generatedName:U,availability:R,readonly:z,writeonly:L}});return D.push(...g.map(B=>{let F=B.conflict;for(let N of m){let R=N.properties[B.key];R!=null&&!ILo(B.schema,R)?F[N.schemaId]={differentSchema:!0}:R!=null&&(F[N.schemaId]={differentSchema:!1})}return{...B,conflict:F}})),ArM({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 ArM({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=ni.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=ni.nullable({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),i&&(b=ni.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=Ii(n,xi.IGNORE);return a&&r.logger.debug(`Property ${t.join(".")}.${i} is marked with x-fern-ignore. Skipping.`),!a}))}function wy_({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[o,c]=mn(e)?[t.resolveSchemaReference(e),dja(e.$ref)]:[e,r];for(let f of o.allOf??[])a={...a,...wy_({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=Ml(s,!1,!1,t,[...c,f],i,n);a[f]=u}return a}function YCi({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=jrM({schemas:s}),b=s.flatMap((O,A)=>{if(!mn(O)&&O.enum!=null&&f.options.coerceEnumsToLiterals&&O.type==="string")return O.enum.map(m=>ni.literal({nameOverride:void 0,generatedName:RC([t,m],f.options.preserveSchemaIds),title:void 0,value:Rj.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[Ml(O,!1,!1,f,[...i,g??`${A}`],_,u)]}),v=mrM(b);return PrM({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 mrM(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 PrM({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}))}),JCi({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=ni.nullable({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),n&&(h=ni.optional({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),h}return Ey_({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 fcc({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=Gvi(A,!1,!1,c,[v],l,p,f);return c.markSchemaWithDiscriminantValue(A,u.propertyName,b),g.type==="object"&&(g.properties={[u.propertyName]:ni.literal({nameOverride:void 0,generatedName:RC([t,b],c.options.preserveSchemaIds),title:void 0,value:Rj.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}))}),JCi({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]:Ey_({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 jrM({schemas:e}){let t={},r=0;for(let n of e){if(!mn(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=Mro(s,a);c=Mro(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 wJi(a)??`${a}`})}function Ey_({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=ni.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=ni.nullable({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:f,groupName:s,inline:void 0})),i&&(p=ni.optional({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:f,groupName:s,inline:void 0})),p}function mUn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function CLo({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=DJi(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function Sy_({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=DJi(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function g9t({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=DJi(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function My_({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=DJi(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var IJi="#/components/schemas/";function Iy_(e,t){let r=mn(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 Iy_(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 wrM(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:Iy_(t,r):!1}function Ml(e,t,r,i,n,a,o,c=!1,f=new Set,s){let u=py_(e)??a,l=TrM({schema:e,logger:i.logger}),p=s;if(mn(e)){let _=ErM(e);_!==void 0&&(p=_)}if(mn(e)){let _=$Ci(e);return _!=null?wrM(_,e,i)?AUn(i.resolveSchemaReference(e),t,r,i,dja(e.$ref),l,u,o,f,c,p):(c?i.markSchemaAsReferencedByRequest(_):i.markSchemaAsReferencedByNonRequest(_),Gvi(e,t,r,i,n,l,u,o)):AUn(i.resolveSchemaReference(e),t,r,i,dja(e.$ref),l,u,o,f,c,p)}return AUn(e,t,r,i,n,l,u,o,f,c,s)}function ErM(e){if("example"in e&&e.example!==void 0){let t=e.example;if(typeof t=="string"||typeof t=="number"||typeof t=="boolean"||Array.isArray(t))return t}if("examples"in e){let t=e.examples;if(Array.isArray(t)&&t.length>0){let r=t[0];if(typeof r=="string"||typeof r=="number"||typeof r=="boolean"||Array.isArray(r))return r}}}function Gvi(e,t,r,i,n,a,o,c){let f=e.$ref.includes("properties")?AUn(i.resolveSchemaReference(e),t,r,i,n,a,o,c,new Set):ni.reference(lcc(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=ni.nullable({title:void 0,nameOverride:void 0,generatedName:RC(n,i.options.preserveSchemaIds),value:f,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(f=ni.optional({title:void 0,nameOverride:void 0,generatedName:RC(n,i.options.preserveSchemaIds),value:f,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),f}function SrM(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function AUn(e,t,r,i,n,a,o,c,f=new Set,s=!1,u){typeof e=="string"&&(e={type:e});let l=Ii(e,xi.TYPE_NAME)??(i.options.useTitlesAsName?SrM(e.title):void 0),p=Ii(e,xi.SDK_GROUP_NAME)??Ii(e,JQ.TAGS)?.[0],_=(typeof p=="string"?[p]:p)??[];_=i.resolveGroupName(_);let h=RC(n,i.options.preserveSchemaIds),y=e.title,b=e.description,v=$3(e),O=[];e.example!=null&&O.push({name:void 0,value:e.example,description:void 0});let A=Ii(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=DJi(e);g!=null&&Object.keys(g).length>0&&O.push(...g.map(j=>({name:void 0,value:j,description:void 0})));let m=dy_({schema:e,description:b,title:y,nameOverride:l,generatedName:h,availability:v});if(m!=null){let j=m;return r&&(j=ni.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),t&&(j=ni.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),!RLo(e.enum))return Y3({nameOverride:l,generatedName:h,title:y,primitive:Un.string({default:mUn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:g9t({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v});let E=fy_(e);return i.options.coerceEnumsToLiterals&&e.enum.length===1&&e.enum[0]!=null&&E==null?Oy_({nameOverride:l,generatedName:h,title:y,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:b,availability:v,namespace:c,groupName:_}):JCi({nameOverride:l,generatedName:h,title:y,fernEnum:E,enumVarNames:Ii(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(RLo(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 YCi({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=Ii(e,xi.BOOLEAN_LITERAL);return E!=null?Dy_({nameOverride:l,generatedName:h,title:y,literal:Rj.boolean(E),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):Y3({nameOverride:l,generatedName:h,title:y,primitive:Un.boolean({default:MrM(e.default),example:Sy_({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_})}if(e.type==="number")return ccc({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:BJi(e.exclusiveMinimum),exclusiveMaximum:BJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:CLo({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="integer")return gy_({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:BJi(e.exclusiveMinimum),exclusiveMaximum:BJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:CLo({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_,defaultIntegerFormat:i.options.defaultIntegerFormat});if(e.type==="float")return ccc({nameOverride:l,generatedName:h,title:y,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:BJi(e.exclusiveMinimum),exclusiveMaximum:BJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:CLo({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="string"){if(e.format==="date-time")return Y3({nameOverride:l,generatedName:h,title:y,primitive:Un.datetime({example:g9t({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 Y3({nameOverride:l,generatedName:h,title:y,primitive:Un.date({example:g9t({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=ni.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:void 0});return r&&(D=ni.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),t&&(D=ni.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),D}let E=qy_(e,"const");return E!=null?Dy_({nameOverride:l,generatedName:h,title:y,literal:Rj.string(E),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):Y3({nameOverride:l,generatedName:h,title:y,primitive:Un.string({default:mUn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:g9t({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v})}if(e.type==="array")return yy_({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:My_({schema:e,logger:i.logger,fallback:u}),source:o});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&qLo(e))return _y_({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&&Ii(e,xi.IS_DISCRIMINATED)===!1)return YCi({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?fcc({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}):ucc({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=Ii(e,xi.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return i.options.discriminatedUnionV2||E?fcc({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}):ucc({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 YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf.filter(B=>mn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o});let D=Ml(e.oneOf[0],t,r,i,n,o,c,s);return O9t(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],R=e.oneOf[1];if(!mn(N)&&N.type==="null"){let z=Ml(R,t,!0,i,n,o,c);return O9t(z,b,c,_)}else if(!mn(R)&&R.type==="null"){let z=Ml(N,t,!0,i,n,o,c);return O9t(z,b,c,_)}}let D=IrM({schemas:e.oneOf});if(D!=null)return JCi({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=By_({schemas:e.oneOf,context:i});if(B!=null&&!i.options.discriminatedUnionV2&&!E)return scc({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=>!mn(N)&&N.type==="null").length>0;return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||F,context:i,subtypes:e.oneOf.filter(N=>mn(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=Ml(e.anyOf[0],t,r,i,n,o,c,s);return O9t(B,b,c,_)}if(e.anyOf.length===2){let[B,F]=e.anyOf;if(B!=null&&F!=null){if(!mn(B)&&B.type==="null"){let N=Ml(F,t,!0,i,n,o,c);return O9t(N,b,c,_)}else if(!mn(F)&&F.type==="null"){let N=Ml(B,t,!0,i,n,o,c);return O9t(N,b,c,_)}}}let E=By_({schemas:e.anyOf,context:i});if(E!=null&&!i.options.discriminatedUnionV2)return scc({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=>!mn(B)&&B.type==="null").length>0;return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||D,context:i,subtypes:e.anyOf.filter(B=>mn(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??[])(mn(B)||Object.keys(B).length>0)&&E.push(B);if((e.properties==null||qLo(e))&&E.length===1&&E[0]!=null){let B=Ml(E[0],t,r,i,n,o,c,s);return O9t(B,b,c,_)}let D=E.filter(B=>{let F=TLo(B);return F||i.logger.debug(`Skipping non-object allOf element: ${JSON.stringify(B)}`),F});if((e.properties==null||qLo(e))&&D.length===1&&D[0]!=null){let B=Ml(D[0],t,r,i,n,o,c,s);return O9t(B,b,c,_)}return Py_({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"&&DrM(e)&&BrM(e)&&qLo(e))return occ({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:Un.string({default:mUn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:g9t({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_},valueSchema:ni.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=ni.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:j});return r&&(M=ni.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:M})),t&&(M=ni.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}
|
|
1411
|
+
`)),{ok:!0,value:t}):i}}function hUo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var FQn=class e extends Error{errors;constructor(t){super(t.map(hUo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var QQn=class e extends Error{errors;constructor(t){super(t.map(hUo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function $m(e){return{optional:()=>qsc(e),transform:t=>Tsc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new QQn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new FQn(i.errors)}}}function qsc(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,...$m(t)}}function Tsc(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,...$m(r)}}function W__(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:DA(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:DA(t,"bigint")}]},getType:()=>oh.BIGINT};return{...bz(e),...$m(e)}}var xeM=/^([+-]?\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 x__(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:DA(t,"string")}]}:xeM.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:DA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:DA(t,"Date object")}]},getType:()=>oh.DATE};return{...bz(e),...$m(e)}}function K3(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...bz(r),...$m(r)}}}function yUo(e){let t=new Set(e);return K3(oh.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:DA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:DA(i,"enum")}]}:{ok:!0,value:i})()}function G__(e){let t=Rsc(e);return{...t,...$m(t)}}function Rsc(e){return{parse:(t,r)=>UQn(e).parse(t,r),json:(t,r)=>UQn(e).json(t,r),getType:()=>UQn(e).getType()}}function UQn(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 FCi(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 H__(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function vFt(e){return{withParsedProperties:t=>zsc(e,t)}}function zsc(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(!FCi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:DA(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,...$m(r),...vFt(r)}}function K__(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function QCi(e){return e.isProperty}function bUo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>QCi(i)?i.rawKey:r),_getParsedProperties:()=>kPa(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of XPa(e)){let f=QCi(c)?c.rawKey:o,s=QCi(c)?c.valueSchema:c,u={rawKey:f,parsedKey:o,valueSchema:s};n[f]=u,Y__(s)&&a.push(f)}return J__({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=QCi(o)?o.valueSchema:o;Y__(c)&&n.push(a)}return J__({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return QCi(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{...bz(t),...$m(t),...vFt(t),...jJi(t)}}function J__({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!FCi(e))return{ok:!1,errors:[{path:a,message:DA(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 jJi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>$__({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>$__({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>oh.OBJECT};return{...r,...$m(r),...vFt(r),...jJi(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,...$m(t),...vFt(t),...jJi(t)}}}}function $__({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=H__(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 Y__(e){return!GeM(e)}function GeM(e){switch(e.getType()){case oh.ANY:case oh.UNKNOWN:case oh.OPTIONAL:return!0;default:return!1}}function X__(e){return bUo(e)}function Z__(e){let t={...Rsc(e),_getRawProperties:()=>UQn(e)._getRawProperties(),_getParsedProperties:()=>UQn(e)._getParsedProperties()};return{...t,...$m(t),...vFt(t),...jJi(t)}}function vUo(e){let t={parse:(r,i)=>k__(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>k__(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>oh.LIST};return{...bz(t),...$m(t)}}function k__(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:DA(e,"list"),path:[]}]}}function eh_(e){return K3(oh.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:DA(r,`"${e}"`)}]})()}function th_(e){return K3(oh.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:DA(r,`${e.toString()}`)}]})()}var rh_=K3(oh.ANY,e=>({ok:!0,value:e}));var ih_=K3(oh.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DA(e,"boolean")}]});var nh_=K3(oh.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DA(e,"number")}]});var ah_=K3(oh.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DA(e,"string")}]});var oh_=K3(oh.UNKNOWN,e=>({ok:!0,value:e}));function sh_(e,t){let r={parse:(i,n)=>uh_({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)=>uh_({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{...bz(r),...$m(r)}}function uh_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return FCi(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:DA(e,"object")}]}}function ch_(e){let t=vUo(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:DA(i,"Set")}]},getType:()=>oh.SET};return{...bz(r),...$m(r)}}function fh_(e){let t={parse:(r,i)=>lh_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>lh_((n,a)=>n.json(r,a),e,i),getType:()=>oh.UNDISCRIMINATED_UNION};return{...bz(t),...$m(t)}}function lh_(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 dh_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function _h_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=yUo(kPa(t)),a={parse:(o,c)=>ph_({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)=>ph_({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{...bz(a),...$m(a),...vFt(a)}}function ph_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!FCi(e))return{ok:!1,errors:[{path:c,message:DA(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=V.objectWithoutOptionalProperties({title:V.string().optional()});var gUo=V.objectWithoutOptionalProperties({file:V.string()});var OUo=V.objectWithoutOptionalProperties({file:V.string()});var AUo=V.union("type",{openapi:gUo,protobuf:OUo}).transform({transform:e=>{switch(e.type){case"openapi":return H3.openapi(e);case"protobuf":return H3.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var ru=V.objectWithoutOptionalProperties({source:AUo.optional()});var mUo=V.objectWithoutOptionalProperties({typeName:V.string()});var PUo=V.union("type",{protobuf:mUo}).transform({transform:e=>{switch(e.type){case"protobuf":return NQn.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var iK=V.objectWithoutOptionalProperties({encoding:PUo.optional()});var Ti=V.objectWithoutOptionalProperties({description:V.string().optional()});var jUo=V.enum_(["GenerallyAvailable","Beta","Deprecated"]);var vu=V.objectWithoutOptionalProperties({availability:jUo.optional()});var _9t=V.number();var $0e=V.objectWithoutOptionalProperties({statusCode:_9t.optional()});var Gl=V.objectWithoutOptionalProperties({nameOverride:V.string().optional(),generatedName:V.string()});var _O=V.objectWithoutOptionalProperties({inline:V.boolean().optional()});var Ox=V.string();var Ax=V.string();var wUo=V.objectWithoutOptionalProperties({id:Ax}).extend(Ti);var UCi=V.string();var EUo=V.objectWithoutOptionalProperties({usernameVariableName:V.string().optional(),usernameEnvVar:V.string().optional(),passwordVariableName:V.string().optional(),passwordEnvVar:V.string().optional()});var SUo=V.objectWithoutOptionalProperties({tokenVariableName:V.string().optional(),tokenEnvVar:V.string().optional()});var MUo=V.objectWithoutOptionalProperties({headerName:V.string(),prefix:V.string().optional(),headerVariableName:V.string().optional(),headerEnvVar:V.string().optional()});var DUo=V.objectWithoutOptionalProperties({queryParameterName:V.string()});var BUo=V.objectWithoutOptionalProperties({snake:V.string().optional(),camel:V.string().optional(),screamingSnake:V.string().optional(),pascal:V.string().optional()});var LCi=V.objectWithoutOptionalProperties({nameOverride:V.string().optional(),generatedName:V.string(),value:V.string(),casing:BUo.optional()}).extend(Ti).extend(vu);var IUo=V.objectWithoutOptionalProperties({type:V.stringLiteral("namespace"),name:V.string()});var CUo=V.undiscriminatedUnion([V.string(),IUo]);var VCi=V.list(CUo);var Hd=V.objectWithoutOptionalProperties({groupName:VCi.optional()});var Sl=V.objectWithoutOptionalProperties({namespace:V.string().optional()});var LQn=V.objectWithoutOptionalProperties({default:LCi.optional(),values:V.list(LCi)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(ru).extend(Gd).extend(_O);var qUo=V.objectWithoutOptionalProperties({scopesEnum:LQn.optional()});var TUo=V.union("type",{basic:EUo,bearer:SUo,header:MUo,query:DUo,oauth:qUo}).transform({transform:e=>{switch(e.type){case"basic":return pz.basic(e);case"bearer":return pz.bearer(e);case"header":return pz.header(e);case"query":return pz.query(e);case"oauth":return pz.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var eja=V.objectWithoutOptionalProperties({name:V.string().optional(),url:V.string(),audiences:V.list(V.string()).optional()}).extend(Ti);var RUo=V.string();var h9t=V.objectWithoutOptionalProperties({sdkMethodName:V.string().optional()});var Fsc={};Yt(Fsc,{FullExample:()=>Ym,FullObjectExample:()=>FUo,FullOneOfExample:()=>UUo,KeyValuePair:()=>QUo,LiteralExample:()=>zUo,NullExample:()=>NUo,PrimitiveExample:()=>WQn,PropertyKey:()=>VQn});var VQn=V.string();var WQn=V.union("type",{int:V.object({value:V.number()}),int64:V.object({value:V.number()}),uint:V.object({value:V.number()}),uint64:V.object({value:V.number()}),float:V.object({value:V.number()}),double:V.object({value:V.number()}),string:V.object({value:V.string()}),datetime:V.object({value:V.string()}),date:V.object({value:V.string()}),base64:V.object({value:V.string()}),boolean:V.object({value:V.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return Ka.int(e.value);case"int64":return Ka.int64(e.value);case"uint":return Ka.uint(e.value);case"uint64":return Ka.uint64(e.value);case"float":return Ka.float(e.value);case"double":return Ka.double(e.value);case"string":return Ka.string(e.value);case"datetime":return Ka.datetime(e.value);case"date":return Ka.date(e.value);case"base64":return Ka.base64(e.value);case"boolean":return Ka.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var zUo=V.union("type",{boolean:V.object({value:V.boolean()}),string:V.object({value:V.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return zCi.boolean(e.value);case"string":return zCi.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var NUo=V.objectWithoutOptionalProperties({});var Ym=V.union("type",{primitive:V.object({value:WQn}),object:V.lazyObject(()=>FUo),array:V.object({value:V.list(V.lazy(()=>Ym))}),map:V.object({value:V.list(V.lazyObject(()=>QUo))}),enum:V.object({value:V.string()}),literal:V.object({value:zUo}),oneOf:V.object({value:V.lazy(()=>UUo)}),null:NUo,unknown:V.object({value:V.lazy(()=>Ym)})}).transform({transform:e=>{switch(e.type){case"primitive":return Zc.primitive(e.value);case"object":return Zc.object(e);case"array":return Zc.array(e.value);case"map":return Zc.map(e.value);case"enum":return Zc.enum(e.value);case"literal":return Zc.literal(e.value);case"oneOf":return Zc.oneOf(e.value);case"null":return Zc.null(e);case"unknown":return Zc.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var FUo=V.objectWithoutOptionalProperties({properties:V.record(VQn,V.lazy(()=>Ym))});var QUo=V.objectWithoutOptionalProperties({key:WQn,value:V.lazy(()=>Ym)});var UUo=V.union("type",{discriminated:V.object({value:V.record(VQn,V.lazy(()=>Ym))}),undiscriminated:V.object({value:V.lazy(()=>Ym)})}).transform({transform:e=>{switch(e.type){case"discriminated":return NCi.discriminated(e.value);case"undiscriminated":return NCi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Qsc={};Yt(Qsc,{AllOfPropertyConflict:()=>cUn,ArraySchema:()=>I4o,Availability:()=>jUo,BooleanSchema:()=>j4o,BytesResponse:()=>ZQn,CasingOverrides:()=>BUo,CommonProperty:()=>Q4o,CursorPagination:()=>u4o,CustomCodeSample:()=>a4o,CustomCodeSampleLanguage:()=>r4o,CustomCodeSampleSdk:()=>n4o,CustomPagination:()=>c4o,DiscriminatedOneOfSchema:()=>N4o,DoubleSchema:()=>m4o,Endpoint:()=>l4o,EndpointExample:()=>iUn,EndpointResponseExample:()=>t4o,EndpointSdkName:()=>y9t,EndpointSecurity:()=>xQn,EnumSchema:()=>LQn,EnumValue:()=>LCi,ErrorExample:()=>YUo,FernExample:()=>ZUo,FileResponse:()=>YQn,FileSchema:()=>WUo,FormUrlEncodedRequest:()=>JUo,FullEndpointExample:()=>o4o,GlobalHeader:()=>S4o,GlobalSecurity:()=>E4o,Header:()=>WCi,HeaderExample:()=>rUn,HttpEndpointServer:()=>eUn,HttpError:()=>XUo,HttpMethod:()=>GQn,IdempotencyHeader:()=>M4o,IntSchema:()=>O4o,JsonRequest:()=>KUo,JsonResponse:()=>XQn,LiteralSchema:()=>sUn,LiteralSchemaValue:()=>D4o,LongSchema:()=>A4o,MapSchema:()=>C4o,MultipartRequest:()=>$Qn,MultipartRequestProperty:()=>HUo,MultipartRequestPropertyEncoding:()=>GUo,MultipartSchema:()=>xUo,NullableSchema:()=>T4o,ObjectProperty:()=>z4o,ObjectPropertyConflictInfo:()=>lUn,ObjectSchema:()=>B4o,OctetStreamRequest:()=>JQn,OffsetPagination:()=>s4o,OneOfSchema:()=>R4o,OpenApiIntermediateRepresentation:()=>hh_,OptionalSchema:()=>q4o,Pagination:()=>nUn,PathParameter:()=>HQn,PathParameterExample:()=>kUo,PrimitiveSchema:()=>GCi,PrimitiveSchemaValue:()=>w4o,QueryParameter:()=>KQn,QueryParameterExample:()=>tUn,ReferencedSchema:()=>b9t,Request:()=>$Uo,Response:()=>kQn,RetriesConfiguration:()=>aUn,Schema:()=>nd,Schemas:()=>g4o,SdkGroupInfo:()=>LUo,StreamingResponseExample:()=>e4o,StringSchema:()=>P4o,SupportedSdkLanguage:()=>i4o,Tags:()=>VUo,TextResponse:()=>xCi,UnDiscriminatedOneOfSchema:()=>F4o,Webhook:()=>f4o,WebhookExampleCall:()=>uUn,WebhookHttpMethod:()=>oUn,WebsocketChannel:()=>v4o,WebsocketHandshake:()=>d4o,WebsocketMessageExample:()=>y4o,WebsocketMessageOrigin:()=>p4o,WebsocketMessageSchema:()=>_4o,WebsocketServer:()=>h4o,WebsocketSessionExample:()=>b4o});var LUo=V.objectWithoutOptionalProperties({summary:V.string().optional(),description:V.string().optional()});var VUo=V.objectWithoutOptionalProperties({tagsById:V.record(Ax,wUo),orderedTagIds:V.list(Ax).optional()});var xQn=V.list(V.record(UCi,V.list(V.string())));var GQn=V.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var HQn=V.objectWithoutOptionalProperties({name:V.string(),schema:V.lazy(()=>nd),variableReference:V.string().optional(),parameterNameOverride:V.string().optional()}).extend(Ti).extend(vu).extend(ru);var KQn=V.objectWithoutOptionalProperties({name:V.string(),schema:V.lazy(()=>nd),parameterNameOverride:V.string().optional()}).extend(Ti).extend(vu).extend(ru);var WCi=V.objectWithoutOptionalProperties({name:V.string(),schema:V.lazy(()=>nd),env:V.string().optional(),parameterNameOverride:V.string().optional()}).extend(Ti).extend(vu).extend(ru);var y9t=V.objectWithoutOptionalProperties({groupName:VCi,methodName:V.string()});var JQn=V.objectWithoutOptionalProperties({contentType:V.string().optional()}).extend(Ti).extend(ru);var WUo=V.objectWithoutOptionalProperties({isOptional:V.boolean(),isArray:V.boolean()}).extend(Ti);var xUo=V.union("type",{file:WUo,json:V.object({value:V.lazy(()=>nd)})}).transform({transform:e=>{switch(e.type){case"file":return d9t.file(e);case"json":return d9t.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var GUo=V.enum_(["json","form"]);var HUo=V.objectWithoutOptionalProperties({key:V.string(),schema:xUo,contentType:V.string().optional(),exploded:V.boolean().optional(),encoding:GUo.optional()}).extend(Ti);var $Qn=V.objectWithoutOptionalProperties({name:V.string().optional(),properties:V.list(HUo)}).extend(Ti).extend(ru);var KUo=V.objectWithoutOptionalProperties({schema:V.lazy(()=>nd),contentType:V.string().optional(),additionalProperties:V.boolean()}).extend(Ti).extend(ru);var JUo=V.objectWithoutOptionalProperties({schema:V.lazy(()=>nd),contentType:V.string().optional(),additionalProperties:V.boolean()}).extend(Ti).extend(ru);var $Uo=V.union("type",{octetStream:JQn,multipart:$Qn,json:KUo,formUrlEncoded:JUo}).transform({transform:e=>{switch(e.type){case"octetStream":return bFt.octetStream(e);case"multipart":return bFt.multipart(e);case"json":return bFt.json(e);case"formUrlEncoded":return bFt.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var YQn=V.objectWithoutOptionalProperties({}).extend(Ti).extend(ru).extend($0e);var XQn=V.objectWithoutOptionalProperties({schema:V.lazy(()=>nd),responseProperty:V.string().optional()}).extend(Ti).extend(ru).extend($0e);var xCi=V.objectWithoutOptionalProperties({}).extend(Ti).extend(ru).extend($0e);var ZQn=V.objectWithoutOptionalProperties({}).extend(Ti).extend(ru).extend($0e);var kQn=V.union("type",{file:YQn,json:XQn,text:xCi,bytes:ZQn,streamingSse:XQn,streamingText:xCi,streamingJson:XQn}).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 YUo=V.objectWithoutOptionalProperties({name:V.string().optional(),description:V.string().optional(),example:V.lazy(()=>Ym)});var XUo=V.objectWithoutOptionalProperties({schema:V.lazy(()=>nd).optional(),examples:V.list(YUo).optional()}).extend(Ti).extend(Gl).extend(ru);var eUn=V.objectWithoutOptionalProperties({name:V.string().optional(),url:V.string().optional(),audiences:V.list(V.string()).optional()});var ZUo=V.unknown();var kUo=V.objectWithoutOptionalProperties({name:V.string(),parameterNameOverride:V.string().optional(),value:V.lazy(()=>Ym)});var tUn=V.objectWithoutOptionalProperties({name:V.string(),value:V.lazy(()=>Ym)});var rUn=V.objectWithoutOptionalProperties({name:V.string(),value:V.lazy(()=>Ym)});var e4o=V.objectWithoutOptionalProperties({sse:V.boolean(),events:V.list(V.lazy(()=>Ym))});var t4o=V.union("type",{withStreaming:e4o,withoutStreaming:V.object({value:V.lazy(()=>Ym)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return J0e.withStreaming(e);case"withoutStreaming":return J0e.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var r4o=V.objectWithoutOptionalProperties({name:V.string().optional(),language:V.string(),code:V.string(),install:V.string().optional()}).extend(Ti);var i4o=V.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var n4o=V.objectWithoutOptionalProperties({name:V.string().optional(),sdk:i4o,code:V.string()}).extend(Ti);var a4o=V.union("type",{language:r4o,sdk:n4o}).transform({transform:e=>{switch(e.type){case"language":return f9t.language(e);case"sdk":return f9t.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var o4o=V.objectWithoutOptionalProperties({name:V.string().optional(),pathParameters:V.list(kUo).optional(),queryParameters:V.list(tUn).optional(),headers:V.list(rUn).optional(),request:V.lazy(()=>Ym).optional(),response:t4o.optional(),codeSamples:V.list(a4o)}).extend(Ti);var iUn=V.union("type",{unknown:V.object({value:ZUo}),full:o4o}).transform({transform:e=>{switch(e.type){case"unknown":return K0e.unknown(e.value);case"full":return K0e.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var u4o=V.objectWithoutOptionalProperties({cursor:V.string(),nextCursor:V.property("next_cursor",V.string()),results:V.string()});var s4o=V.objectWithoutOptionalProperties({offset:V.string(),results:V.string(),step:V.string().optional(),hasNextPage:V.string().optional()});var c4o=V.objectWithoutOptionalProperties({results:V.string()});var nUn=V.union("type",{cursor:u4o,offset:s4o,custom:c4o}).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 aUn=V.union("type",{disabled:V.object({value:V.boolean().optional()})}).transform({transform:e=>{switch(e.type){case"disabled":return YPa.disabled(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var l4o=V.objectWithoutOptionalProperties({authed:V.boolean(),security:xQn.optional(),internal:V.boolean().optional(),idempotent:V.boolean().optional(),method:GQn,audiences:V.list(V.string()),path:V.string(),summary:V.string().optional(),operationId:V.string().optional(),tags:V.list(Ax),pathParameters:V.list(HQn),queryParameters:V.list(KQn),headers:V.list(WCi),sdkName:y9t.optional(),generatedRequestName:V.string(),requestNameOverride:V.string().optional(),request:$Uo.optional(),response:kQn.optional(),errors:V.record(_9t,XUo),servers:V.list(eUn),examples:V.list(iUn),pagination:nUn.optional(),retries:aUn.optional()}).extend(Ti).extend(vu).extend(ru).extend(Sl);var oUn=V.enum_(["GET","POST"]);var uUn=V.objectWithoutOptionalProperties({name:V.string().optional(),payload:V.lazy(()=>Ym)}).extend(Ti);var f4o=V.objectWithoutOptionalProperties({audiences:V.list(V.string()),sdkName:y9t.optional(),method:oUn,summary:V.string().optional(),operationId:V.string(),tags:V.list(Ax),headers:V.list(WCi),generatedPayloadName:V.string(),payload:V.lazy(()=>nd),response:kQn.optional(),examples:V.list(uUn)}).extend(Ti).extend(ru).extend(Sl);var d4o=V.objectWithoutOptionalProperties({queryParameters:V.list(KQn),headers:V.list(WCi),pathParameters:V.list(HQn)});var p4o=V.enum_(["client","server"]);var _4o=V.objectWithoutOptionalProperties({name:V.string(),origin:p4o,body:V.lazy(()=>nd)});var h4o=V.objectWithoutOptionalProperties({name:V.string(),url:V.string()});var y4o=V.objectWithoutOptionalProperties({messageType:V.string(),payload:V.lazy(()=>Ym)}).extend(Ti);var b4o=V.objectWithoutOptionalProperties({name:V.string().optional(),queryParameters:V.list(tUn).optional(),headers:V.list(rUn).optional(),messages:V.list(y4o)}).extend(Ti);var v4o=V.objectWithoutOptionalProperties({audiences:V.list(V.string()),path:V.string(),groupName:VCi,summary:V.string().optional(),handshake:d4o,messages:V.list(_4o),servers:V.list(h4o),examples:V.list(b4o)}).extend(Ti).extend(ru);var g4o=V.objectWithoutOptionalProperties({rootSchemas:V.record(Ox,V.lazy(()=>nd)),namespacedSchemas:V.record(RUo,V.record(Ox,V.lazy(()=>nd)))});var O4o=V.objectWithoutOptionalProperties({default:V.number().optional(),minimum:V.number().optional(),maximum:V.number().optional(),exclusiveMinimum:V.boolean().optional(),exclusiveMaximum:V.boolean().optional(),multipleOf:V.number().optional()});var A4o=V.objectWithoutOptionalProperties({default:V.number().optional()});var m4o=V.objectWithoutOptionalProperties({default:V.number().optional(),minimum:V.number().optional(),maximum:V.number().optional(),exclusiveMinimum:V.boolean().optional(),exclusiveMaximum:V.boolean().optional(),multipleOf:V.number().optional()});var P4o=V.objectWithoutOptionalProperties({default:V.string().optional(),pattern:V.string().optional(),format:V.string().optional(),minLength:V.number().optional(),maxLength:V.number().optional()});var j4o=V.objectWithoutOptionalProperties({default:V.boolean().optional()});var w4o=V.union("type",{int:O4o,int64:A4o,uint:V.object({}),uint64:V.object({}),float:V.object({}),double:m4o,string:P4o,datetime:V.object({}),date:V.object({}),base64:V.object({}),boolean:j4o}).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 GCi=V.objectWithoutOptionalProperties({schema:w4o}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd);var E4o=V.list(V.record(UCi,V.list(V.string())));var S4o=V.objectWithoutOptionalProperties({header:V.string(),name:V.string().optional(),optional:V.boolean().optional(),env:V.string().optional(),schema:V.lazy(()=>nd).optional()});var M4o=V.objectWithoutOptionalProperties({header:V.string(),name:V.string().optional(),env:V.string().optional(),schema:V.lazy(()=>nd).optional()});var hh_=V.objectWithoutOptionalProperties({apiVersion:V.unknown().optional(),title:V.string().optional(),description:V.string().optional(),basePath:V.string().optional(),servers:V.list(eja),websocketServers:V.list(eja),groups:V.record(V.string(),LUo),tags:VUo,hasEndpointsMarkedInternal:V.boolean(),endpoints:V.list(l4o),webhooks:V.list(f4o),channels:V.record(V.string(),v4o),groupedSchemas:g4o,variables:V.record(V.string(),GCi),nonRequestReferencedSchemas:V.set(Ox),securitySchemes:V.record(UCi,TUo),security:E4o.optional(),globalHeaders:V.list(S4o).optional(),idempotencyHeaders:V.list(M4o).optional()});var b9t=V.objectWithoutOptionalProperties({schema:Ox}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(ru).extend(Gd);var D4o=V.union("type",{boolean:V.object({value:V.boolean()}),string:V.object({value:V.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Rj.boolean(e.value);case"string":return Rj.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var sUn=V.objectWithoutOptionalProperties({value:D4o}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd);var nd=V.union("type",{primitive:GCi,object:V.lazyObject(()=>B4o),array:V.lazyObject(()=>I4o),map:V.lazyObject(()=>C4o),optional:V.lazyObject(()=>q4o),enum:LQn,reference:b9t,literal:sUn,oneOf:V.object({value:V.lazy(()=>R4o)}),nullable:V.lazyObject(()=>T4o),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 cUn=V.objectWithoutOptionalProperties({propertyKey:V.string(),allOfSchemaIds:V.list(Ox),conflictingTypeSignatures:V.boolean()});var B4o=V.objectWithoutOptionalProperties({allOf:V.list(b9t),properties:V.list(V.lazyObject(()=>z4o)),allOfPropertyConflicts:V.list(cUn),additionalProperties:V.boolean()}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(ru).extend(Gd).extend(_O);var lUn=V.objectWithoutOptionalProperties({differentSchema:V.boolean()});var z4o=V.objectWithoutOptionalProperties({key:V.string(),schema:V.lazy(()=>nd),readonly:V.boolean().optional(),writeonly:V.boolean().optional(),conflict:V.record(Ox,lUn),generatedName:V.string(),nameOverride:V.string().optional(),audiences:V.list(V.string())}).extend(vu);var I4o=V.objectWithoutOptionalProperties({value:V.lazy(()=>nd)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd).extend(_O);var C4o=V.objectWithoutOptionalProperties({key:GCi,value:V.lazy(()=>nd)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(iK).extend(Gd).extend(_O);var q4o=V.objectWithoutOptionalProperties({value:V.lazy(()=>nd)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd).extend(_O);var T4o=V.objectWithoutOptionalProperties({value:V.lazy(()=>nd)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd).extend(_O);var R4o=V.union("type",{discriminated:V.lazyObject(()=>N4o),undiscriminated:V.lazyObject(()=>F4o)}).transform({transform:e=>{switch(e.type){case"discriminated":return p9t.discriminated(e);case"undiscriminated":return p9t.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var N4o=V.objectWithoutOptionalProperties({discriminantProperty:V.string(),commonProperties:V.list(V.lazyObject(()=>Q4o)),schemas:V.record(V.string(),V.lazy(()=>nd))}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(iK).extend(ru).extend(Gd).extend(_O);var Q4o=V.objectWithoutOptionalProperties({key:V.string(),schema:V.lazy(()=>nd)});var F4o=V.objectWithoutOptionalProperties({schemas:V.list(V.lazy(()=>nd))}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(iK).extend(ru).extend(Gd).extend(_O);var Usc={};Yt(Usc,{ArraySchemaWithExample:()=>uLo,Base64WithExample:()=>rLo,BooleanWithExample:()=>iLo,CommonPropertyWithExample:()=>yLo,DateWithExample:()=>tLo,DatetimeWithExample:()=>eLo,DiscriminatedOneOfSchemaWithExample:()=>_Lo,DoubleWithExample:()=>Z4o,EndpointWithExample:()=>bh_,EnumSchemaWithExample:()=>aLo,FloatWithExample:()=>X4o,HeaderWithExample:()=>HCi,HttpErrorWithExample:()=>H4o,Int64WithExample:()=>J4o,IntWithExample:()=>K4o,JsonRequestWithExample:()=>W4o,JsonResponseWithExample:()=>dUn,MapSchemaWithExample:()=>sLo,NamedFullExample:()=>Y0e,NullableSchemaWithExample:()=>lLo,ObjectPropertyWithExample:()=>pLo,ObjectSchemaWithExample:()=>fLo,OneOfSchemaWithExample:()=>dLo,OptionalSchemaWithExample:()=>cLo,ParseFormUrlEncodedRequest:()=>x4o,ParseMultipartRequest:()=>V4o,ParseOctetStreamRequest:()=>L4o,PathParameterWithExample:()=>U4o,PrimitiveSchemaValueWithExample:()=>nLo,PrimitiveSchemaWithExample:()=>_Un,QueryParameterWithExample:()=>fUn,RequestWithExample:()=>G4o,ResponseWithExample:()=>pUn,SchemaWithExample:()=>hO,StringSchemaWithExample:()=>k4o,Uint64WithExample:()=>Y4o,UintWithExample:()=>$4o,UnDiscriminatedOneOfSchemaWithExample:()=>hLo,UnknownSchemaWithExample:()=>oLo,WebhookWithExample:()=>vh_,WebsocketHandshakeWithExample:()=>yh_});var Y0e=V.objectWithoutOptionalProperties({name:V.string().optional(),value:V.unknown()}).extend(Ti);var fUn=V.objectWithoutOptionalProperties({name:V.string(),schema:V.lazy(()=>hO),parameterNameOverride:V.string().optional(),explode:V.boolean().optional()}).extend(Ti).extend(vu).extend(ru);var HCi=V.objectWithoutOptionalProperties({name:V.string(),schema:V.lazy(()=>hO),env:V.string().optional(),parameterNameOverride:V.string().optional()}).extend(Ti).extend(vu).extend(ru);var yh_=V.objectWithoutOptionalProperties({queryParameters:V.list(fUn),headers:V.list(HCi)});var U4o=V.objectWithoutOptionalProperties({name:V.string(),schema:V.lazy(()=>hO),variableReference:V.string().optional(),parameterNameOverride:V.string().optional(),explode:V.boolean().optional()}).extend(Ti).extend(vu).extend(ru);var L4o=V.objectWithoutOptionalProperties({}).extend(JQn).extend(h9t);var V4o=V.objectWithoutOptionalProperties({}).extend($Qn).extend(h9t);var W4o=V.objectWithoutOptionalProperties({schema:V.lazy(()=>hO),contentType:V.string().optional(),fullExamples:V.list(Y0e).optional(),additionalProperties:V.boolean()}).extend(Ti).extend(ru).extend(h9t);var x4o=V.objectWithoutOptionalProperties({schema:V.lazy(()=>hO),contentType:V.string().optional(),fullExamples:V.list(Y0e).optional(),additionalProperties:V.boolean()}).extend(Ti).extend(ru).extend(h9t);var G4o=V.union("type",{octetStream:L4o,multipart:V4o,json:W4o,formUrlEncoded:x4o}).transform({transform:e=>{switch(e.type){case"octetStream":return gx.octetStream(e);case"multipart":return gx.multipart(e);case"json":return gx.json(e);case"formUrlEncoded":return gx.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var dUn=V.objectWithoutOptionalProperties({schema:V.lazy(()=>hO),responseProperty:V.string().optional(),fullExamples:V.list(Y0e).optional()}).extend(Ti).extend(ru).extend($0e);var pUn=V.union("type",{file:YQn,json:dUn,text:xCi,bytes:ZQn,streamingSse:dUn,streamingText:xCi,streamingJson:dUn}).transform({transform:e=>{switch(e.type){case"file":return yP.file(e);case"json":return yP.json(e);case"text":return yP.text(e);case"bytes":return yP.bytes(e);case"streamingSse":return yP.streamingSse(e);case"streamingText":return yP.streamingText(e);case"streamingJson":return yP.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var H4o=V.objectWithoutOptionalProperties({statusCode:_9t,schema:V.lazy(()=>hO),fullExamples:V.list(Y0e).optional()}).extend(Ti).extend(Gl).extend(ru);var bh_=V.objectWithoutOptionalProperties({authed:V.boolean(),security:xQn.optional(),internal:V.boolean().optional(),idempotent:V.boolean().optional(),method:GQn,audiences:V.list(V.string()),path:V.string(),summary:V.string().optional(),operationId:V.string().optional(),tags:V.list(Ax),pathParameters:V.list(U4o),queryParameters:V.list(fUn),headers:V.list(HCi),sdkName:y9t.optional(),generatedRequestName:V.string(),requestNameOverride:V.string().optional(),request:G4o.optional(),response:pUn.optional(),errors:V.record(_9t,H4o),servers:V.list(eUn),examples:V.list(iUn),pagination:nUn.optional(),retries:aUn.optional()}).extend(Ti).extend(vu).extend(ru).extend(Sl);var vh_=V.objectWithoutOptionalProperties({audiences:V.list(V.string()),sdkName:y9t.optional(),method:oUn,summary:V.string().optional(),operationId:V.string(),tags:V.list(Ax),headers:V.list(HCi),generatedPayloadName:V.string(),payload:V.lazy(()=>hO),response:pUn.optional(),examples:V.list(uUn)}).extend(Ti).extend(ru).extend(Sl);var K4o=V.objectWithoutOptionalProperties({default:V.number().optional(),minimum:V.number().optional(),maximum:V.number().optional(),exclusiveMinimum:V.boolean().optional(),exclusiveMaximum:V.boolean().optional(),multipleOf:V.number().optional(),example:V.number().optional()});var J4o=V.objectWithoutOptionalProperties({default:V.number().optional(),example:V.number().optional()});var $4o=V.objectWithoutOptionalProperties({default:V.number().optional(),example:V.number().optional()});var Y4o=V.objectWithoutOptionalProperties({default:V.number().optional(),example:V.number().optional()});var X4o=V.objectWithoutOptionalProperties({example:V.number().optional()});var Z4o=V.objectWithoutOptionalProperties({default:V.number().optional(),minimum:V.number().optional(),maximum:V.number().optional(),exclusiveMinimum:V.boolean().optional(),exclusiveMaximum:V.boolean().optional(),multipleOf:V.number().optional(),example:V.number().optional()});var k4o=V.objectWithoutOptionalProperties({default:V.string().optional(),pattern:V.string().optional(),format:V.string().optional(),minLength:V.number().optional(),maxLength:V.number().optional(),example:V.string().optional()});var eLo=V.objectWithoutOptionalProperties({example:V.string().optional()});var tLo=V.objectWithoutOptionalProperties({example:V.string().optional()});var rLo=V.objectWithoutOptionalProperties({example:V.string().optional()});var iLo=V.objectWithoutOptionalProperties({default:V.boolean().optional(),example:V.boolean().optional()});var nLo=V.union("type",{int:K4o,int64:J4o,uint:$4o,uint64:Y4o,float:X4o,double:Z4o,string:k4o,datetime:eLo,date:tLo,base64:rLo,boolean:iLo}).transform({transform:e=>{switch(e.type){case"int":return Un.int(e);case"int64":return Un.int64(e);case"uint":return Un.uint(e);case"uint64":return Un.uint64(e);case"float":return Un.float(e);case"double":return Un.double(e);case"string":return Un.string(e);case"datetime":return Un.datetime(e);case"date":return Un.date(e);case"base64":return Un.base64(e);case"boolean":return Un.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var _Un=V.objectWithoutOptionalProperties({schema:nLo}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd);var aLo=V.objectWithoutOptionalProperties({default:LCi.optional(),values:V.list(LCi),example:V.string().optional()}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(ru).extend(Gd).extend(_O);var oLo=V.objectWithoutOptionalProperties({example:V.unknown()}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd);var hO=V.union("type",{primitive:_Un,object:V.lazyObject(()=>fLo),array:V.lazyObject(()=>uLo),map:V.lazyObject(()=>sLo),optional:V.lazyObject(()=>cLo),enum:aLo,reference:b9t,literal:sUn,oneOf:V.object({value:V.lazy(()=>dLo)}),nullable:V.lazyObject(()=>lLo),unknown:oLo}).transform({transform:e=>{switch(e.type){case"primitive":return ni.primitive(e);case"object":return ni.object(e);case"array":return ni.array(e);case"map":return ni.map(e);case"optional":return ni.optional(e);case"enum":return ni.enum(e);case"reference":return ni.reference(e);case"literal":return ni.literal(e);case"oneOf":return ni.oneOf(e.value);case"nullable":return ni.nullable(e);case"unknown":return ni.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var uLo=V.objectWithoutOptionalProperties({value:V.lazy(()=>hO),example:V.list(V.unknown()).optional()}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd).extend(_O);var sLo=V.objectWithoutOptionalProperties({key:_Un,value:V.lazy(()=>hO),example:V.unknown().optional()}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(iK).extend(Gd).extend(_O);var cLo=V.objectWithoutOptionalProperties({value:V.lazy(()=>hO)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd).extend(_O);var lLo=V.objectWithoutOptionalProperties({value:V.lazy(()=>hO)}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(Gd).extend(_O);var fLo=V.objectWithoutOptionalProperties({allOf:V.list(b9t),properties:V.list(V.lazyObject(()=>pLo)),allOfPropertyConflicts:V.list(cUn),fullExamples:V.list(Y0e).optional(),additionalProperties:V.boolean()}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(ru).extend(Gd).extend(_O);var pLo=V.objectWithoutOptionalProperties({key:V.string(),schema:V.lazy(()=>hO),readonly:V.boolean().optional(),writeonly:V.boolean().optional(),audiences:V.list(V.string()),conflict:V.record(Ox,lUn),nameOverride:V.string().optional(),generatedName:V.string()}).extend(vu);var dLo=V.union("type",{discriminated:V.lazyObject(()=>_Lo),undiscriminated:V.lazyObject(()=>hLo)}).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 _Lo=V.objectWithoutOptionalProperties({discriminantProperty:V.string(),commonProperties:V.list(V.lazyObject(()=>yLo)),schemas:V.record(V.string(),V.lazy(()=>hO))}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(iK).extend(ru).extend(Gd).extend(_O);var yLo=V.objectWithoutOptionalProperties({key:V.string(),schema:V.lazy(()=>hO)});var hLo=V.objectWithoutOptionalProperties({schemas:V.list(V.lazy(()=>hO))}).extend(Hd).extend(Sl).extend(Gl).extend(Ti).extend(vu).extend(iK).extend(ru).extend(Gd).extend(_O);var gh_=/^(\d+)/,hUn=/^[a-zA-Z][a-zA-Z0-9_]*$/,Oh_={"<":"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 wJi(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_${wJi(c)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${wJi(a)}`}function tja(e){let t=e.match(gh_);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=wJi(n);return i.length>0?`${a}_${i}`:a}}}function yUn(e){let t=tja(e),r=Oh_[e];return t!=null?TP(Fo(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":TP(Fo(e)))}function nK(e,t){return e.type==="primitive"&&t.type==="primitive"?Ah_(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?HeM(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"?KeM(e.value,t.value):e.type==="object"&&t.type==="object"?JeM(e,t):e.type==="map"&&t.type==="map"?Ah_(e.key.schema,t.key.schema)&&nK(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function Ah_(e,t){return e.type===t.type}function HeM(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return t1(r,i)}function KeM(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 JeM(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 kE(e){switch(e){case _z.Deprecated:return"deprecated";case _z.Beta:return"pre-release";case _z.GenerallyAvailable:return"generally-available";default:return}}function $eM(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 mh_(e){let t=e?$eM(e):void 0;if(t==null||t.length===0)return Jxi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(Fo(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(Fo(n.name)):r.push(n.name,Jxi);break}default:Ot(n.type)}else Ot(n);return r.join("/")}function gFt(e){return Ru.of(`${mh_(e)}.yml`)}function Lsc({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Jxi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,mh_(r))}function Ph_({sdkName:e,namespaceOverride:t}){return Ru.of(`${Lsc({sdkName:e,namespaceOverride:t})}.yml`)}function jh_({location:e,namespaceOverride:t}){return t!=null?tD(Ru.of(t),e):e}function bLo(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Ot(e.type)}}function Vvi(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:Ot(e)}}function ly(e){return typeof e=="string"?e:e.type}function bUn(e){if(typeof e!="string")return e.docs}function rja(e){if(typeof e!="string")return e.default}function Vsc(e){if(typeof e!="string")return e.validation}function vUn(e){let t=e.match(/^optional<\s*nullable<\s*(.+)\s*>\s*>$/);if(t!=null&&t[1]!=null)return t[1].trim();let r=e.match(/^nullable<\s*(.+)\s*>$/);return r!=null&&r[1]!=null?r[1].trim():e}function Eh_(e){let t=ly(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?wh_(e):{...e,type:wh_(e.type)}}function wh_(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function EJi(e){return ly(e).startsWith("optional<")?e:typeof e=="string"?Sh_(e):{...e,type:Sh_(e.type)}}function Sh_(e){return e.startsWith("optional<")?e:`optional<${e}>`}var YeM=-2147483648,XeM=2147483647,ZeM=-17976931348623157e292,keM=17976931348623157e292;function kc({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 vLo(e);case"array":return Gsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return Hsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return xsc({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return Jsc();case"optional":return gLo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return Ksc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return stM({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,$sc(e);case"object":return ctM({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return ltM({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:Ot(e)}}function vLo(e){switch(e.schema.type){case"string":return rtM({description:e.description,schema:e.schema});case"int":return itM({description:e.description,schema:e.schema});case"float":return ntM({description:e.description,schema:e.schema});case"double":return atM({description:e.description,schema:e.schema});case"boolean":return etM({description:e.description,schema:e.schema});case"int64":return ttM({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:kE(e.availability)}:{}}}function etM({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 ttM({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 rtM({description:e,schema:t}){let r="string",i=otM(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 itM({description:e,schema:t}){let r="integer",i=Mh_(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 ntM({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function atM({description:e,schema:t}){let r="double",i=Mh_(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 otM(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=utM(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function utM(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 Mh_(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:o}=e;if(r=Wsc(r,t),i=Wsc(i,t),n=Wsc(n,t),!(r==null&&i==null&&a==null&&o==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:o,multipleOf:n}}function Wsc(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[YeM,XeM]:[ZeM,keM];return e<r||e>i?void 0:e}function xsc({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=ftM(n)??e.schema,o=Vvi(n),c=dtM(n),s=OLo({context:r,fileContainingReference:t,declarationFile:gFt(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:kE(e.availability)}:{}}}function Gsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=kc({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=`list<${ly(o)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:kE(e.availability)}:{},type:c}}function Hsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=vLo(e.key),c=kc({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),f=e.encoding!=null?bLo(e.encoding):void 0,s=`map<${ly(o)}, ${ly(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=kE(e.availability)),u}function Ksc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.options.respectNullableSchemas)return gLo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let o=kc({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=ly(o),f=bUn(o),s=rja(o),u=Vsc(o),l=Eh_(c);if(i.options.wrapReferencesToNullableInOptional&&(l=EJi(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=kE(e.availability)),p}function gLo({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=kc({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=ly(o),f=bUn(o),s=rja(o),u=Vsc(o),l=EJi(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=kE(e.availability)),p}function Jsc(){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:Ot(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:kE(e.availability)}:{}}}function stM({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=OLo({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=kE(e.availability)),f}function ctM({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=OLo({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:kE(e.availability)}:{}}}function ltM({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Xsc({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=OLo({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:kE(e.availability)}:{}}}function OLo({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 ftM(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 dtM(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 q1;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(q1||(q1={}));function Wvi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Ot(e)}}function Bh_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=htM(e);break;case"array":a=ptM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=_tM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=ytM({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=vtM(e.nameOverride,e.generatedName);break;case"optional":a=Ch_({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=gtM(e,e.nameOverride,e.generatedName);break;case"object":a=Ysc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=Xsc({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:Ot(e)}return a}function Ysc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(q1.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])=>{Zsc({property:_.key,schemaId:g,context:t,namespace:i}).forEach(j=>{f.add(j)})})}let h=kc({schema:_.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),y=_.audiences,b=_.nameOverride,v=kE(_.availability),O=PtM(_);c[_.key]=mtM({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=ALo({schema:_.schema,context:t,namespace:i});if(h==null||f.has(_.schema)||f.has(h))continue;let y=kc({schema:zs.reference(_),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(vUn(ly(y)))}for(let _ of f){let h=gUn(t,_,i);for(let y of h.properties)c[y.key]==null&&(s.has(y.key)&&(c[y.key]="unknown"),c[y.key]=kc({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=kc({schema:zs.reference(y),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(vUn(ly(b)))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([_,h])=>AtM(_)?[_,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=kE(e.availability)),e.source!=null&&(l.source=Wvi(e.source)),l.inline=ksc(e,n);let p=e.nameOverride??e.generatedName;return{name:o&&t.options.respectReadonlySchemas&&!a?`${p}Read`:p,schema:l}}function Zsc({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return Zsc({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:o}=gUn(r,t,i),c=a.some(s=>s.key===e),f=[...o.flatMap(s=>Zsc({property:e,context:r,schemaId:s.schema,namespace:i}))];if(c||f.length>0)return[t,...f]}return[]}function Ih_(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?gUn(e,t.schema,r):t.type==="nullable"?Ih_(e,t.value,r):{properties:[],allOf:[]}}function gUn(e,t,r){let i=e.getSchema(t,r);return i==null?{properties:[],allOf:[]}:Ih_(e,i,r)}function ptM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:Gsc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function _tM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:Hsc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function htM(e){let t=vLo(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 Dh_(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||Dh_(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&&!Dh_(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=ksc(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?Wvi(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 ytM({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:xsc({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:Ksc({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:Ch_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function Ch_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:gLo({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function vtM(e,t){return{name:e??t,schema:Jsc()}}function gtM(e,t,r){return{name:t??r,schema:$sc(e)}}function Xsc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?bLo(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=kc({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]=kc({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?kE(e.availability):void 0,union:f,encoding:a,source:e.source!=null?Wvi(e.source):void 0}}}let o=[];for(let c of e.schemas)o.push(kc({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?Wvi(e.source):void 0,inline:ksc(e,n)}}}var OtM=/^[0-9]/;function AtM(e){return OtM.test(e)}function ALo({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?ALo({context:t,schema:i.schema,namespace:r}):e}function mtM({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 ksc(e,t){return e.inline===!0||t>0?!0:void 0}function PtM(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return mD.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return mD.ObjectPropertyAccess.WriteOnly}}function qh_(e){let t=e.replace(/^x-|^X-/,"");return Fo(t)}function Th_(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??qh_(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(Ru.of("__package__.yml"),{name:"OauthScope",schema:ija(i.scopesEnum,0).schema})}}function v9t({header:e,context:t,fileContainingReference:r,namespace:i}){let n=kc({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=ly(n),o=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:Fo(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=kE(e.availability)),f}function mLo({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=kc({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return ly(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:ly(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=kE(e.availability)),a}function jLo({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=ecc({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=ly(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=kE(e.availability)),jtM(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 ecc({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:kc({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:Ru.of(ab),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"&&(hUn.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:yUn(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&&PLo({array:c,primitive:f}))return{value:kc({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&&PLo({array:c,primitive:f}))return{value:kc({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 ecc({schema:f,context:t,fileContainingReference:r,namespace:i})}else if(t.options.objectQueryParameters)return{value:kc({schema:e,context:t,fileContainingReference:r,declarationFile:Ru.of(ab),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:kc({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:Ru.of(ab),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.options.objectQueryParameters)return{value:kc({schema:e,context:t,fileContainingReference:r,declarationFile:Ru.of(ab),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:kc({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"&&(hUn.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:yUn(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&&PLo({array:c,primitive:f}))return{value:kc({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&&PLo({array:f,primitive:c}))return{value:kc({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:kc({schema:e,context:t,fileContainingReference:r,declarationFile:Ru.of(ab),namespace:i,declarationDepth:0}),allowMultiple:!1};for(let[c,f]of Object.entries(e.value.value.schemas))return ecc({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:kc({schema:e,context:t,fileContainingReference:r,declarationFile:Ru.of(ab),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:kc({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:kc({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:kc({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function PLo({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function jtM(e){return typeof e=="object"&&e!==null&&"type"in e}function Rh_({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"]=wtM(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=EtM({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=KCi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function wtM(e){let t={};return e.forEach(r=>{let i=KCi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function EtM({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=KCi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function KCi(e){switch(e.type){case"primitive":return zh_(e.value);case"object":return Nh_(e.properties);case"array":return StM(e.value);case"map":return MtM(e.value);case"oneOf":return DtM(e.value);case"enum":return e.value;case"literal":return BtM(e.value);case"unknown":return KCi(e.value);case"null":return null;default:Ot(e)}}function zh_(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:Ot(e)}}function Nh_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,KCi(r)]))}function StM(e){return e.map(t=>KCi(t))}function MtM(e){return Object.fromEntries(e.map(t=>[zh_(t.key),KCi(t.value)]))}function DtM(e){return e.type==="discriminated"?Nh_(e.value):KCi(e.value)}function BtM(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ot(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 wLo(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function ELo(e,t,r=!1){let i=nja(t);return r&&i!=null?i:e!=null&&i!=null?`${e}_${i}`:i??e??"websocket"}function xvi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function SLo(e,t){return t??(e?.groupName!=null?xvi(e.groupName):void 0)}function Fh_({channel:e,context:t,declarationFile:r}){let i=e.servers[0],n=i!=null?t.options.groupEnvironmentsByHost?t.getUrlId(i.url)??ELo(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=xvi(e.groupName),c={};if(e.handshake.pathParameters.length>0)for(let u of e.handshake.pathParameters)c[u.name]=mLo({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=jLo({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=v9t({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:kc({schema:u.body,context:t,fileContainingReference:r,namespace:o,declarationDepth:0})}});for(let u of e.examples){let l=Rh_({context:t,websocketExample:u});t.builder.addChannelExample(r,{example:l})}}function tcc(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var X0e="Base",Lh_="Default";function Qh_(e){try{return new URL(e).hostname}catch{return}}function Uh_(e){return e??Lh_}function ItM(e,t){let r=new Map;for(let i of e){if(tcc(i)||!("url"in i)||!i.url)continue;let n=Qh_(i.url)??i.url;r.has(n)||r.set(n,{environmentName:Uh_(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=Qh_(i.url)??i.url;r.has(n)||r.set(n,{environmentName:Uh_(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.websocketServers.push(i)}return r}function SJi(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 Vh_(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=>tcc(v)),n=e.ir.servers;for(let v of n)if(tcc(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=ItM(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=wLo(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[X0e]=D.url,e.setUrlId(D.url,X0e));for(let B=1;B<m.httpServers.length;B++){let F=m.httpServers[B];if(F!=null){let N=nja(F.url),R=wLo(F.url),z=N?E.get(N):void 0,L=z&&z.size>1,J=L&&R!=="https"?`${N}_${R}`:N||`Http${B+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${F.url}", pathSegment="${N}", protocol="${R}", hasCollision=${L}, urlId="${J}"`),j[J]=F.url,e.setUrlId(F.url,J)}}}for(let D of m.websocketServers){let B=nja(D.url),F=wLo(D.url),N=B?E.get(B):void 0,R=N&&N.size>1,z=R?`${B}_${F}`:ELo(D.name,D.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${D.name}", url="${D.url}", pathSegment="${B}", protocol="${F}", hasCollision=${R}, urlId="${z}"`),j[z]=D.url,e.setUrlId(D.url,z)}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(X0e),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(X0e);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[Lh_]=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:{[X0e]:g??"",...SJi(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:{[X0e]:g??"",...SJi(f)}}})}else e.builder.addEnvironment({name:O,schema:A});h&&e.builder.setDefaultUrl(X0e)}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:{[X0e]:A??"",...SJi(o),...SJi(f)}}}),e.builder.setDefaultEnvironment(v),e.builder.setDefaultUrl(X0e)}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={[X0e]: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,SJi(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(X0e)}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:{[X0e]:m??"",...SJi(o),...SJi(f)}}})}else e.builder.addEnvironment({name:A,schema:g});O&&(e.builder.setDefaultEnvironment(A),O=!1)}}}}var rcc=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},CtM=.75,qtM=new Set("authorization");function Wh_(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?Vvi(i.schema):void 0,o=a!=null?xvi(a):void 0,c=Ru.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?ly(kc({schema:i.schema,context:e,fileContainingReference:o?tD(Ru.of(Fo(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(qtM.has(a.name.toLowerCase()))continue;let o=r[a.name];if(o==null){let c=t[a.name],f=v9t({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:Ru.of(i1),context:e,namespace:void 0});o=new rcc(f),r[a.name]=o}o.increment()}let i=e.ir.endpoints.length*CtM;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:EJi(a.schema)}))}}}function xh_(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?Vvi(t.schema):void 0,i=r!=null?xvi(r):void 0,n=v9t({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:Ru.of(i1),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:EJi(n)})}}function J3(e){switch(e.type){case"primitive":return Hh_(e.value);case"object":return Kh_(e.properties);case"array":return Jh_(e.value);case"map":return RtM(e.value);case"oneOf":return ztM(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return NtM(e.value);case"unknown":return J3(e.value);case"null":return null;default:Ot(e)}}function Gh_(e){switch(e.type){case"withStreaming":return e.sse?{stream:TtM(e.events)}:{stream:Jh_(e.events)};case"withoutStreaming":return{body:J3(e.value)};default:Ot(e)}}function Hh_(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:Ot(e)}}function Kh_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,J3(r)]))}function TtM(e){return e.map(t=>({event:"",data:J3(t)}))}function Jh_(e){return e.map(t=>J3(t))}function RtM(e){return Object.fromEntries(e.map(t=>[Hh_(t.key),J3(t.value)]))}function ztM(e){return e.type==="discriminated"?Kh_(e.value):J3(e.value)}function NtM(e){switch(e.type){case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"boolean":return e.value;default:Ot(e)}}function $h_({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"]=FtM(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=QtM(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=wB({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:Mt}});u!=null&&c.push({name:f,value:Zc.literal(zCi.string(u))})}else c.push({name:f,value:Zc.primitive(Ka.string(f))});r.headers=UtM({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=J3(e.request)),e.response!=null&&(r.response=Gh_(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(ts)),r}function FtM(e){let t={};return e.forEach(r=>{let i=J3(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function QtM(e){let t={};return e.forEach(r=>{let i=J3(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function UtM({context:e,namedFullExamples:t}){let r={};return t.forEach(i=>{let n=J3(i.value);n!=null&&(r[i.name]=n)}),r}function Yh_(e){return yz._visit(e,{get:()=>mD.HttpMethodSchema.Get,post:()=>mD.HttpMethodSchema.Post,put:()=>mD.HttpMethodSchema.Put,patch:()=>mD.HttpMethodSchema.Patch,delete:()=>mD.HttpMethodSchema.Delete,head:()=>mD.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 Xh_(e){return e==="POST"||e==="PUT"||e==="PATCH"}function Zh_({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,o=e.path,c=SLo(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]=mLo({pathParameter:b,context:r,fileContainingReference:t,namespace:c}),a.add(b.name);let s={};for(let b of e.queryParameters){let v=jLo({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:Ot(e.pagination)}let l={path:o,method:Yh_(e.method),auth:LtM({endpoint:e,context:r}),docs:e.description??void 0,pagination:u,source:e.source!=null?Wvi(e.source):void 0};!GtM({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=v9t({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(q1.Request);let b=xtM({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(q1.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=kc({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:b.description??void 0,type:ly(v)},b.statusCode!=null&&(l.response["status-code"]=b.statusCode),b.responseProperty!=null&&(l.response.property=b.responseProperty)},streamingJson:b=>{let v=kc({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:ly(v),format:"json"}},streamingSse:b=>{let v=kc({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:ly(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=kE(e.availability)),Object.entries(e.errors).forEach(([b,v])=>{let O=v.generatedName,A=Ru.of(ab);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=jh_({location:kh_,namespaceOverride:c});if(v.schema!=null){let E=kc({schema:v.schema,context:r,fileContainingReference:m,declarationFile:m,namespace:c,declarationDepth:0});g.type=ly(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:J3(E.example),name:E.name,docs:E.description};r.builder.addErrorExample(m,{name:O,example:D})})}),e.examples.length>0&&(l.examples=VtM({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=WtM({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[icc,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function LtM({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 VtM({endpointExamples:e,context:t}){return e.map(r=>{try{return $h_({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function WtM({retries:e}){if(e!=null)switch(e.type){case"disabled":return{disabled:e.value??void 0};default:Ot(e)}}function xtM({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 m=kc({schema:i.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),j={schemaIdsToExclude:[],value:{body:m}},M=Object.keys(o??{}).length>0,E=Object.keys(c??{}).length>0,D=Object.keys(s??{}).length>0;return M&&(j.value["path-parameters"]=o),E&&(j.value["query-parameters"]=c),D&&(j.value.headers=s),(M||E||D)&&(j.value.name=n??a),i.contentType!=null&&(j.value["content-type"]=i.contentType),i.description!=null&&(j.value.docs=i.description),j}let h=new Map;for(let m of _.allOf){let j=r.getSchema(m.schema,l);if(j==null)continue;let M=Vvi(j),E=gFt(M),{properties:D}=gUn(r,m.schema,l);for(let B of D)h.set(B.key,E)}let y=Object.fromEntries(_.properties.filter(m=>m.readonly==null?!0:!(Xh_(e.method)&&m.readonly)).map(m=>{let j=h.get(m.key)??t,M=kc({schema:m.schema,fileContainingReference:t,declarationFile:j,context:r,namespace:l,declarationDepth:1}),E=m.nameOverride??m.key,D=kE(m.availability);if(!u.has(E)&&m.audiences.length<=0)return u.add(E),m.nameOverride!=null?[m.key,{type:ly(M),docs:bUn(M),name:m.nameOverride,availability:D}]:[m.key,D?{...typeof M=="string"?{type:M}:M,availability:D}:M];let B={type:ly(M),docs:bUn(M)};return u.has(E)&&(B.name=m.generatedName),m.audiences.length>0&&(B.audiences=m.audiences),D!=null&&(B.availability=D),u.add(E),[m.key,B]})),b=new Set,v=new Set;for(let m of _.allOfPropertyConflicts)m.allOfSchemaIds.forEach(j=>b.add(j)),m.conflictingTypeSignatures&&v.add(m.propertyKey);let O=[];for(let m of _.allOf){let j=ALo({schema:m.schema,context:r,namespace:l});if(j==null||b.has(m.schema)||b.has(j))continue;let M=kc({schema:zs.reference(m),fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),E=vUn(ly(M));E!=="unknown"&&O.push(E)}for(let m of b){let j=gUn(r,m,l),M=r.getSchema(m,l),E=M!=null?gFt(Vvi(M)):t;for(let D of j.properties)y[D.key]==null&&(v.has(D.key)?y[D.key]="unknown":y[D.key]=kc({schema:D.schema,fileContainingReference:t,declarationFile:E,context:r,namespace:l,declarationDepth:1}));for(let D of j.allOf){if(b.has(D.schema))continue;let B=kc({schema:zs.reference(D),fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),F=vUn(ly(B));F!=="unknown"&&!O.includes(F)&&O.push(F)}}let A={properties:y};O.length>0&&(A.extends=O),i.additionalProperties&&(A["extra-properties"]=!0);let g={name:n??_.nameOverride??_.generatedName,"path-parameters":o,"query-parameters":c,headers:s,body:A};return i.contentType!=null&&(g["content-type"]=i.contentType),i.description!=null&&(g.docs=i.description),{schemaIdsToExclude:p!=null?[p]:[],value:g}}else if(i.type==="octetStream"){let p={body:"bytes","content-type":i.contentType??oO.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=kc({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":oO.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else Ot(i)}function GtM({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:Ot(t)}}function HtM({location:e,namespaceOverride:t}){return t!=null?{...e,file:tD(Ru.of(t),e.file)}:e}function KtM(e){let t=e.namespace,r=e.tags.filter(f=>f!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:Ru.of(`${Fo(r)}.yml`),endpointId:e.summary!=null?Fo(e.summary):Fo(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Ru.of(ab),endpointId:Fo(e.summary)}:{file:Ru.of(ab),endpointId:Fo(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Ru.of(ab),endpointId:i};let n=aja(r),a=aja(i);if(t1(n,a))return{file:Ru.of("__package__.yml"),endpointId:r};let o=YtM({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=Fo(r);return{file:Ru.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:Ru.of(Fo(c.join("_"))+".yml"),endpointId:Fo(a.slice(c.length).join("_")),tag:r}}function oja(e){let t=e.tags[0];if(e.sdkName!=null){let r=Lsc({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Ru.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return HtM({namespaceOverride:e.namespace,location:KtM(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=XOe(t),t}var JtM=new RegExp("[^a-zA-Z0-9{}]+"),$tM=new RegExp("[{}]","g");function YtM({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(JtM).join("_").replaceAll($tM,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:Ru.of(Fo(t)+".yml"),endpointId:Fo(e.slice(0,-1*a.length)),tag:t}}function ey_(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(q1.Endpoint),e.setEndpointMethod(a.method);let p=Zh_({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(q1.Endpoint),n=[...n,...p.schemaIdsToExclude],e.builder.addEndpoint(c,{name:o,schema:p.value,source:a.source!=null?Wvi(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 ty_(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?xvi(r.groupName):void 0,n=kc({schema:zs.primitive(r),context:e,fileContainingReference:Ru.of(ab),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:ly(n),docs:r.description??void 0}})}}function ry_(e){for(let t of e.ir.webhooks){let r=ktM({webhook:t,context:e});if(r==null)continue;let i=SLo(t.sdkName,t.namespace),n={};for(let o of t.headers)n[o.name]=v9t({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:kc({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:J3(o.payload)})):void 0};t.response!=null&&t.response._visit({json:o=>{let c=kc({schema:o.schema,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0});a.response={docs:o.description??void 0,type:ly(c)},o.statusCode!=null&&(a.response["status-code"]=o.statusCode)},file:o=>{a.response={docs:o.description??void 0,type:"file","status-code":o.statusCode}},bytes:o=>{a.response={docs:o.description??void 0,type:"bytes","status-code":o.statusCode}},text:o=>{a.response={docs:o.description??void 0,type:"text","status-code":o.statusCode}},streamingJson:o=>{let c=kc({schema:o.schema,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0});a["response-stream"]={docs:o.description??void 0,type:ly(c),format:"json"}},streamingSse:o=>{let c=kc({schema:o.schema,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0});a["response-stream"]={docs:o.description??void 0,type:ly(c),format:"sse"}},streamingText:o=>{a["response-stream"]={docs:o.description??void 0,type:"text"}},_other:()=>{throw new Error("Unrecognized Response type: "+t.response?.type)}}),e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function XtM({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:tD(Ru.of(t),e.file)}:e}function ZtM({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:Ru.of(ab),endpointId:i};let n=aja(r),a=aja(i);if(t1(n,a))return{file:Ru.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=Fo(r);return{file:Ru.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:Ru.of(Fo(o.join("_"))+".yml"),endpointId:Fo(a.slice(o.length).join("_")),tag:r}}function ktM({webhook:e,context:t}){return e.sdkName!=null?{file:Ph_({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:XtM({namespaceOverride:e.namespace,location:ZtM({webhook:e,context:t})})}var erM=Ru.of(ab);function ny_(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return iy_({namespace:e.namespace,groupName:e.groupName});case"oneOf":return iy_({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return erM;default:Ot(e)}}function iy_({namespace:e,groupName:t}){return e!=null&&t!=null?gFt([{type:"namespace",name:e},...t]):e!=null?gFt([{type:"namespace",name:e}]):gFt(t)}var icc="external",kh_=Ru.of(ab);function ay_({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let o=ny_(a),c=Bh_({schema:a,context:i,declarationFile:o,namespace:r,declarationDepth:0});if(mCi(c.schema)){let f=ly(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 oy_(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),Vh_(e),Wh_(e),xh_(e),Th_(e),ty_(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(icc);let t=ey_(e),r=t.sdkGroups;e.setInState(q1.Webhook),ry_(e),e.unsetInState(q1.Webhook),e.setInState(q1.Channel);for(let n of Object.values(e.ir.channels)){let a=gFt(n.groupName);Fh_({channel:n,context:e,declarationFile:a})}e.unsetInState(q1.Channel);let i=trM({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});ay_({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))ay_({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 trM({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 MLo=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[o,c]of Object.entries(i.files)){let f=n!=null?Ru.of(`${n}${"/"}${o}`):Ru.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[Ru.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 MJi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new MLo,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 n9t(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"]))uy_(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(uy_(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??Fo((_Ae(r)+"/"+g6i(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Ru.of(i1))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=vuo(_Ae(xDn.of(`/${t}`)),xDn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=vuo(_Ae(xDn.of(`/${t}`)),xDn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===Ru.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=tD(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:tD(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:tD(r,o.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===ab?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 uy_(e){return e?.header!=null}var DLo=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=PJi({options:i}),this.enableUniqueErrorsPerEndpoint=this.options.enableUniqueErrorsPerEndpoint,this.referencedSchemaIds=this.options.onlyIncludeReferencedSchemas?new Set:void 0,this.builder=new MJi(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(q1.Channel,q1.Endpoint,q1.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:Ot(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:Ot(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 ncc(e){let t=new DLo(e);return oy_(t)}function rrM(e){return NKi(e,{single:t=>[typeof t=="string"?t:t.scheme],any:t=>t.any.map(r=>typeof r=="string"?r:r.scheme)})}function irM(e,t){if(e==null)return;let r=rrM(t),i={};for(let n of r)e[n]!=null&&(i[n]=e[n]);return Object.keys(i).length>0?i:void 0}var BLo=class{args;constructor(t){this.args=t}buildAuthOverrides(t,r){let i=this.args.generatorsConfiguration?.api?.["auth-schemes"],n=this.args.generatorsConfiguration?.api?.auth,a=t??n;if(a==null)return;let o=r!=null||i!=null?{...i,...r}:void 0,c=irM(o,a);return{auth:a,"auth-schemes":c}}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=ncc({taskContext:t,ir:r,options:PJi({options:i,overrides:this.args}),authOverrides:this.buildAuthOverrides(i?.auth,i?.authSchemes),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:Ei.dump(a.rootApiFile)},namedDefinitionFiles:{..._n(a.definitionFiles,o=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Ei.dump(o),contents:o})),[Ru.of(ab)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Ei.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var sja=class extends hFt{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;coerceEnumsToLiterals;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;groupEnvironmentsByHost;removeDiscriminantsFromSchemas;defaultIntegerFormat;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.coerceEnumsToLiterals=t.coerceEnumsToLiterals,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.defaultIntegerFormat=t.defaultIntegerFormat,this.converter=new BLo(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 OUn={of(e){return e}};var sy_={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},acc={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:sy_,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},xi={SOURCE:OUn.of("source"),SDK_NAMESPACE:OUn.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:OUn.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:OUn.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:OUn.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 nrM={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:hn.RemoveDiscriminantsFromSchemas.Always,defaultIntegerFormat:hn.DefaultIntegerFormat.Int32};function arM(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 Z0e({options:e,overrides:t}){return arM({defaults:nrM,options:e,overrides:t,overrideOnly:new Set(["disableExamples","preserveSchemaIds"]),undefinedIfAbsent:new Set(["exampleGeneration","defaultFormParameterEncoding"])})}var cy_={naming:"v1"};function Ii(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=Ii(e,t);if(a!=null)return r.parse(a)}catch{let o=XOe(n).join(" -> ");i.error(`${o.length>0?`${o}: `:""}Failed to parse ${t}`)}}function DJi(e){let t=Ii(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 ly_({schema:e,logger:t}){return Ii(e,xi.ENCODING)??void 0}function fy_(e){return Ii(e,xi.FERN_ENUM)}function dy_({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let o=Ii(i,xi.SDK_NAMESPACE),c=Ii(i,xi.SDK_GROUP_NAME),f=Ii(i,xi.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 wB({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.base64({example:void 0})});case"BOOLEAN":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.boolean({default:void 0,example:void 0})});case"DATE":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.date({example:void 0})});case"DATE_TIME":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.datetime({example:void 0})});case"FLOAT":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.float({example:void 0})});case"DOUBLE":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.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 ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.uint({default:void 0,example:void 0})});case"INTEGER":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.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 ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.uint64({default:void 0,example:void 0})});case"LONG":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return ni.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Un.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Ot(f.v1)}},unknown:()=>ni.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?ni.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?ni.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?ni.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?ni.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?ni.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=>ni.literal({nameOverride:t,generatedName:r,title:i,value:f._visit({string:s=>Rj.string(s),boolean:s=>Rj.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:o,groupName:c}),named:f=>ni.reference({schema:f,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,source:H3.openapi({file:"<memory>"})})}})}function py_(e){let t=Ii(e,xi.SOURCE);if(t!=null)return t.endsWith(".proto")?H3.protobuf({file:t}):H3.openapi({file:t})}function BJi(e){if(e!=null&&typeof e=="boolean")return e}function mn(e){return e?.$ref!=null}function _y_({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),occ({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:Un.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)?ni.unknown({...orM(n),generatedName:`${t}Value`}):hy_(Ml(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 hy_(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=hy_(e.value);break;case"oneOf":e.value.inline=!0;break;default:Ot(e)}return e}function occ({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 _=ni.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&&(_=ni.nullable({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:f,namespace:s,groupName:u,inline:void 0})),a&&(_=ni.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:mn(e)||"type"in e&&e.type!=null||"oneOf"in e&&e.oneOf!=null||"anyOf"in e&&e.anyOf!=null?!1:"allOf"in e&&e.allOf!=null?!e.allOf.some(i=>mn(i)?!0:i.type!=null||i.properties!=null||i.allOf!=null||i.oneOf!=null||i.anyOf!=null||i.enum!=null||"items"in i||i.additionalProperties!=null):!("enum"in e&&e.enum!=null)}function orM(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"||mn(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function yy_({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?ni.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:l}):Ml(n,!1,!1,s,[...i,"Item"],_,u);return urM({nameOverride:e,generatedName:t,title:r,namespace:u,groupName:l,itemSchema:h,wrapAsOptional:c,wrapAsNullable:f,description:a,availability:o,example:p})}function urM({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:f,groupName:s,example:u}){let l=ni.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=ni.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),n&&(l=ni.optional({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),l}function $3(e){switch(Ii(e,xi.AVAILABILITY)){case"deprecated":return _z.Deprecated;case"beta":return _z.Beta;case"generally-available":return _z.GenerallyAvailable;default:break}if(!mn(e)&&e.deprecated)return _z.Deprecated}function ucc({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=Gvi({$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=Ml(g,j,M,l,[...i,A],y,p);return{key:A,schema:E}});return by_({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 scc({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(mn(g)){let m=Gvi(g,!1,!1,p,[g.$ref],y,b,_);return p.markReferencedByDiscriminatedUnion(g,u,1),[A,m]}else{let m=AUn(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=Ml(g,j,M,p,[...i,A],b,_);return{key:A,schema:E}});return by_({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 by_({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 _=ni.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&&(_=ni.nullable({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),i&&(_=ni.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 NQn.protobuf({typeName:e.proto.type})}function JCi({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=crM(n??[]),v=new Set(a),O=Array.from(v).map((g,m)=>{let j=i?.[g],M=b[m],E=hUn.test(g),D=j?.name??M,B=E?g:yUn(g);return D!=null&&!hUn.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 srM({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 srM({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 _=ni.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&&(_=ni.nullable({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:f,namespace:s,groupName:u,inline:p})),e&&(_=ni.optional({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:f,namespace:s,groupName:u,inline:p})),_}function crM(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 gy_({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,defaultIntegerFormat:v=hn.DefaultIntegerFormat.Int32}){let O=i??v,A=(()=>{switch(O){case hn.DefaultIntegerFormat.Int64:return Un.int64({default:n,example:h});case hn.DefaultIntegerFormat.Uint32:return Un.uint({default:n,example:h});case hn.DefaultIntegerFormat.Uint64:return Un.uint64({default:n,example:h});default:return Un.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h})}})();return Y3({nameOverride:e,generatedName:t,title:r,primitive:A,wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}function lrM(e){return typeof e=="string"?Rj.string(e):typeof e=="boolean"?Rj.boolean(e):Rj.string(`${e}`)}function Oy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,value:a,description:o,availability:c,namespace:f,groupName:s}){let u=ni.literal({nameOverride:e,generatedName:t,title:r,value:lrM(a),description:o,availability:c,namespace:f,groupName:s});return n&&(u=ni.nullable({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),i&&(u=ni.optional({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),u}function ccc({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"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.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"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int32"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.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"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.int64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint32"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.uint({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint64"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.uint64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="time-delta"?Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):Y3({nameOverride:e,generatedName:t,title:r,primitive:Un.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}var frM={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},drM={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}}},prM={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}}},_rM={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},hrM={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},yrM={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:[]})},vrM={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=[frM,drM,prM,_rM,hrM,yrM,brM,vrM],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 RC(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:TP(Fo(n))).join("");return/^\d/.test(i)?tja(i)??i:i}function Ay_(e){let t=e.join("_");return Fo(t)}function WO(e){switch(e.type){case"object":return zs.object({allOf:e.allOf,properties:e.properties.map(t=>OrM(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:WO(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:WO(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:WO(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return zs.primitive({description:e.description,availability:e.availability,schema:my_(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:my_(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:WO(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(grM(e.value));case"unknown":return zs.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Ot(e)}}function grM(e){switch(e.type){case"discriminated":return p9t.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:WO(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,WO(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return p9t.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>WO(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:Ot(e)}}function my_(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:Ot(e)}}function OrM(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:WO(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function ILo(e,t){return nK(WO(e),WO(t))}function Py_({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&&mn(B)){let F=u.resolveSchemaReference(B);if(F.discriminator!=null&&F.discriminator.mapping!=null)continue;if(F.oneOf!=null||F.anyOf!=null){let R=F.oneOf??F.anyOf;if(R!=null){for(let z of R){let L=mn(z)?u.resolveSchemaReference(z):z,H=Ml(L,!1,!1,u.DUMMY,i,v,p);H.type==="object"&&g.push(...H.properties.map(J=>J.schema.type!=="optional"&&J.schema.type!=="nullable"?{...J,schema:ni.optional({nameOverride:void 0,generatedName:"",title:void 0,value:J.schema,description:void 0,availability:J.availability,namespace:void 0,groupName:void 0,inline:void 0})}:J))}continue}}let N=$Ci(B);if(N==null)continue;m.push({schemaId:N,convertedSchema:lcc(B,[N],v,u.options.preserveSchemaIds),properties:wy_({schema:B,context:u,breadcrumbs:i,source:v,namespace:p})}),u.markSchemaAsReferencedByNonRequest(N)}else if(mn(B)){let F=u.resolveSchemaReference(B),N=Ml(F,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}else{let F=B.required??[];g=g.map(R=>(R.schema.type==="optional"||R.schema.type==="nullable")&&F.includes(R.key)?{...R,schema:R.schema.value}:R);let N=Ml(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 R=j[F];R!=null?(R.schemaIds.push(B.schemaId),R.schemas.some(L=>ILo(L,N))||R.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])=>!(!mn(F)&&F.type==="null"))),D=Object.entries(E).map(([B,F])=>{let N=Ii(F,xi.AUDIENCES)??[],R=$3(F),z=mn(F)?!1:F.readOnly,L=mn(F)?!1:F.writeOnly,J=!(O.includes(B)&&!z),ue=Ii(F,xi.FERN_PROPERTY_NAME),de=[...i,B],U=Ay_(de),W=Ml(F,J,!1,u,de,v,p),Te={};for(let ce of m){let we=ce.properties[B];we!=null&&!ILo(W,we)?Te[ce.schemaId]={differentSchema:!0}:we!=null&&(Te[ce.schemaId]={differentSchema:!1})}return{key:B,schema:W,nameOverride:ue,audiences:N,conflict:Te,generatedName:U,availability:R,readonly:z,writeonly:L}});return D.push(...g.map(B=>{let F=B.conflict;for(let N of m){let R=N.properties[B.key];R!=null&&!ILo(B.schema,R)?F[N.schemaId]={differentSchema:!0}:R!=null&&(F[N.schemaId]={differentSchema:!1})}return{...B,conflict:F}})),ArM({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 ArM({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=ni.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=ni.nullable({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),i&&(b=ni.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=Ii(n,xi.IGNORE);return a&&r.logger.debug(`Property ${t.join(".")}.${i} is marked with x-fern-ignore. Skipping.`),!a}))}function wy_({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[o,c]=mn(e)?[t.resolveSchemaReference(e),dja(e.$ref)]:[e,r];for(let f of o.allOf??[])a={...a,...wy_({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=Ml(s,!1,!1,t,[...c,f],i,n);a[f]=u}return a}function YCi({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=jrM({schemas:s}),b=s.flatMap((O,A)=>{if(!mn(O)&&O.enum!=null&&f.options.coerceEnumsToLiterals&&O.type==="string")return O.enum.map(m=>ni.literal({nameOverride:void 0,generatedName:RC([t,m],f.options.preserveSchemaIds),title:void 0,value:Rj.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[Ml(O,!1,!1,f,[...i,g??`${A}`],_,u)]}),v=mrM(b);return PrM({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 mrM(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 PrM({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}))}),JCi({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=ni.nullable({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),n&&(h=ni.optional({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),h}return Ey_({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 fcc({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=Gvi(A,!1,!1,c,[v],l,p,f);return c.markSchemaWithDiscriminantValue(A,u.propertyName,b),g.type==="object"&&(g.properties={[u.propertyName]:ni.literal({nameOverride:void 0,generatedName:RC([t,b],c.options.preserveSchemaIds),title:void 0,value:Rj.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}))}),JCi({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]:Ey_({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 jrM({schemas:e}){let t={},r=0;for(let n of e){if(!mn(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=Mro(s,a);c=Mro(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 wJi(a)??`${a}`})}function Ey_({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=ni.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=ni.nullable({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:f,groupName:s,inline:void 0})),i&&(p=ni.optional({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:f,groupName:s,inline:void 0})),p}function mUn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function CLo({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=DJi(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function Sy_({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=DJi(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function g9t({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=DJi(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function My_({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=DJi(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var IJi="#/components/schemas/";function Iy_(e,t){let r=mn(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 Iy_(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 wrM(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:Iy_(t,r):!1}function Ml(e,t,r,i,n,a,o,c=!1,f=new Set,s){let u=py_(e)??a,l=TrM({schema:e,logger:i.logger}),p=s;if(mn(e)){let _=ErM(e);_!==void 0&&(p=_)}if(mn(e)){let _=$Ci(e);return _!=null?wrM(_,e,i)?AUn(i.resolveSchemaReference(e),t,r,i,dja(e.$ref),l,u,o,f,c,p):(c?i.markSchemaAsReferencedByRequest(_):i.markSchemaAsReferencedByNonRequest(_),Gvi(e,t,r,i,n,l,u,o)):AUn(i.resolveSchemaReference(e),t,r,i,dja(e.$ref),l,u,o,f,c,p)}return AUn(e,t,r,i,n,l,u,o,f,c,s)}function ErM(e){if("example"in e&&e.example!==void 0){let t=e.example;if(typeof t=="string"||typeof t=="number"||typeof t=="boolean"||Array.isArray(t))return t}if("examples"in e){let t=e.examples;if(Array.isArray(t)&&t.length>0){let r=t[0];if(typeof r=="string"||typeof r=="number"||typeof r=="boolean"||Array.isArray(r))return r}}}function Gvi(e,t,r,i,n,a,o,c){let f=e.$ref.includes("properties")?AUn(i.resolveSchemaReference(e),t,r,i,n,a,o,c,new Set):ni.reference(lcc(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=ni.nullable({title:void 0,nameOverride:void 0,generatedName:RC(n,i.options.preserveSchemaIds),value:f,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(f=ni.optional({title:void 0,nameOverride:void 0,generatedName:RC(n,i.options.preserveSchemaIds),value:f,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),f}function SrM(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function AUn(e,t,r,i,n,a,o,c,f=new Set,s=!1,u){typeof e=="string"&&(e={type:e});let l=Ii(e,xi.TYPE_NAME)??(i.options.useTitlesAsName?SrM(e.title):void 0),p=Ii(e,xi.SDK_GROUP_NAME)??Ii(e,JQ.TAGS)?.[0],_=(typeof p=="string"?[p]:p)??[];_=i.resolveGroupName(_);let h=RC(n,i.options.preserveSchemaIds),y=e.title,b=e.description,v=$3(e),O=[];e.example!=null&&O.push({name:void 0,value:e.example,description:void 0});let A=Ii(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=DJi(e);g!=null&&Object.keys(g).length>0&&O.push(...g.map(j=>({name:void 0,value:j,description:void 0})));let m=dy_({schema:e,description:b,title:y,nameOverride:l,generatedName:h,availability:v});if(m!=null){let j=m;return r&&(j=ni.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),t&&(j=ni.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),!RLo(e.enum))return Y3({nameOverride:l,generatedName:h,title:y,primitive:Un.string({default:mUn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:g9t({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v});let E=fy_(e);return i.options.coerceEnumsToLiterals&&e.enum.length===1&&e.enum[0]!=null&&E==null?Oy_({nameOverride:l,generatedName:h,title:y,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:b,availability:v,namespace:c,groupName:_}):JCi({nameOverride:l,generatedName:h,title:y,fernEnum:E,enumVarNames:Ii(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(RLo(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 YCi({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=Ii(e,xi.BOOLEAN_LITERAL);return E!=null?Dy_({nameOverride:l,generatedName:h,title:y,literal:Rj.boolean(E),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):Y3({nameOverride:l,generatedName:h,title:y,primitive:Un.boolean({default:MrM(e.default),example:Sy_({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_})}if(e.type==="number")return ccc({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:BJi(e.exclusiveMinimum),exclusiveMaximum:BJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:CLo({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="integer")return gy_({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:BJi(e.exclusiveMinimum),exclusiveMaximum:BJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:CLo({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_,defaultIntegerFormat:i.options.defaultIntegerFormat});if(e.type==="float")return ccc({nameOverride:l,generatedName:h,title:y,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:BJi(e.exclusiveMinimum),exclusiveMaximum:BJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:CLo({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="string"){if(e.format==="date-time")return Y3({nameOverride:l,generatedName:h,title:y,primitive:Un.datetime({example:g9t({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 Y3({nameOverride:l,generatedName:h,title:y,primitive:Un.date({example:g9t({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=ni.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:void 0});return r&&(D=ni.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),t&&(D=ni.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),D}let E=qy_(e,"const");return E!=null?Dy_({nameOverride:l,generatedName:h,title:y,literal:Rj.string(E),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):Y3({nameOverride:l,generatedName:h,title:y,primitive:Un.string({default:mUn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:g9t({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v})}if(e.type==="array")return yy_({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:My_({schema:e,logger:i.logger,fallback:u}),source:o});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&qLo(e))return _y_({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&&Ii(e,xi.IS_DISCRIMINATED)===!1)return YCi({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?fcc({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}):ucc({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=Ii(e,xi.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return i.options.discriminatedUnionV2||E?fcc({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}):ucc({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 YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf.filter(B=>mn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o});let D=Ml(e.oneOf[0],t,r,i,n,o,c,s);return O9t(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],R=e.oneOf[1];if(!mn(N)&&N.type==="null"){let z=Ml(R,t,!0,i,n,o,c);return O9t(z,b,c,_)}else if(!mn(R)&&R.type==="null"){let z=Ml(N,t,!0,i,n,o,c);return O9t(z,b,c,_)}}let D=IrM({schemas:e.oneOf});if(D!=null)return JCi({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=By_({schemas:e.oneOf,context:i});if(B!=null&&!i.options.discriminatedUnionV2&&!E)return scc({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=>!mn(N)&&N.type==="null").length>0;return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||F,context:i,subtypes:e.oneOf.filter(N=>mn(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=Ml(e.anyOf[0],t,r,i,n,o,c,s);return O9t(B,b,c,_)}if(e.anyOf.length===2){let[B,F]=e.anyOf;if(B!=null&&F!=null){if(!mn(B)&&B.type==="null"){let N=Ml(F,t,!0,i,n,o,c);return O9t(N,b,c,_)}else if(!mn(F)&&F.type==="null"){let N=Ml(B,t,!0,i,n,o,c);return O9t(N,b,c,_)}}}let E=By_({schemas:e.anyOf,context:i});if(E!=null&&!i.options.discriminatedUnionV2)return scc({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=>!mn(B)&&B.type==="null").length>0;return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||D,context:i,subtypes:e.anyOf.filter(B=>mn(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??[])(mn(B)||Object.keys(B).length>0)&&E.push(B);if((e.properties==null||qLo(e))&&E.length===1&&E[0]!=null){let B=Ml(E[0],t,r,i,n,o,c,s);return O9t(B,b,c,_)}let D=E.filter(B=>{let F=TLo(B);return F||i.logger.debug(`Skipping non-object allOf element: ${JSON.stringify(B)}`),F});if((e.properties==null||qLo(e))&&D.length===1&&D[0]!=null){let B=Ml(D[0],t,r,i,n,o,c,s);return O9t(B,b,c,_)}return Py_({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"&&DrM(e)&&BrM(e)&&qLo(e))return occ({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:Un.string({default:mUn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:g9t({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_},valueSchema:ni.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=ni.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:j});return r&&(M=ni.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:M})),t&&(M=ni.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}
|
|
1412
1412
|
Location: ${n.join("-> ")}`),ni.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:void 0})}}function MrM(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 $Ci(e){if(e.$ref.startsWith(IJi))return e.$ref.replace(IJi,"")}function lcc(e,t,r,i){let n=Ii(e,xi.TYPE_NAME),a=RC(t,i),o=e.description,c=$3(e),f=$Ci(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 DrM(e){return e.oneOf==null||e.oneOf.length===0}function BrM(e){return e.allOf==null||e.allOf.length===0}function qLo(e){return e.properties==null||WA(e.properties)===0}function RLo(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function O9t(e,t,r,i){if(e.type==="reference")return ni.reference({...e,description:t,availability:e.availability,namespace:r,groupName:i});if(e.type==="optional"){let n=O9t(e.value,t,r,i);return ni.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=O9t(e.value,t,r,i);return ni.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 ni.primitive({...e,description:t});return e}function TLo(e){return mn(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>TLo(t)):e.oneOf!=null?e.oneOf.every(t=>TLo(t)):e.anyOf!=null?e.anyOf.every(t=>TLo(t)):!1}function Dy_({literal:e,wrapAsOptional:t,wrapAsNullable:r,namespace:i,groupName:n,description:a,availability:o,nameOverride:c,generatedName:f,title:s}){let u=ni.literal({nameOverride:c,generatedName:f,title:s,value:e,namespace:i,groupName:n,description:a,availability:o});return r&&(u=ni.nullable({nameOverride:c,generatedName:f,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),t&&(u=ni.optional({nameOverride:c,generatedName:f,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),u}function Y3({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=ni.primitive({nameOverride:f,generatedName:c,title:s,schema:e,description:a,availability:o,namespace:i,groupName:n});return r&&(u=ni.nullable({nameOverride:f,generatedName:c,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),t&&(u=ni.optional({nameOverride:f,generatedName:c,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),u}function IrM({schemas:e}){let t=new Set;for(let r of e){if(mn(r))return;if(r.enum!=null&&RLo(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function By_({schemas:e,context:t}){let r={};for(let i of e){let n=Cy_({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 Cy_({schema:e,context:t}){let r=mn(e)?t.resolveSchemaReference(e):e;return CrM({schema:r,context:t})}function CrM({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=Cy_({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=mn(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&RLo(a.enum)&&qrM(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let o=qy_(a,"const");a.type==="string"&&o!=null&&(r[i]=o),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function qrM(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 qy_(e,t){let r=e[t];if(r!=null)return r}function TrM({schema:e,logger:t}){let r=ly_({schema:e,logger:t});if(r!=null)return vy_(r)}var PUn=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(IJi))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let i=t.$ref.substring(IJi.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(mn(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}`);mn(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 zLo=class extends PUn{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 jUn(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:Ot(a)}return{rootSchemas:r,namespacedSchemas:i}}var wUn=se(require("fs"),1),CJi=se(require("path"),1);function XCi(e){if(typeof e=="string")return Zc.primitive(Ka.string(e));if(typeof e=="number")return Number.isInteger(e)?Zc.primitive(Ka.int(e)):Zc.primitive(Ka.double(e));if(typeof e=="boolean")return Zc.primitive(Ka.boolean(e));if(Array.isArray(e)){let t=e.map(r=>XCi(r));return t.length===0?void 0:Zc.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=XCi(i);n!=null&&t.push({key:Ka.string(r),value:n})}return Zc.map(t)}}function pja(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function Ty_(e){if(e!=null&&Array.isArray(e))return e}var ZCi=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"&&Ry_({schema:i,value:r})?Zc.enum(r):i.values[0]!=null?Zc.enum(i.values[0]?.value):void 0;case"literal":return Zc.literal(i.value);case"nullable":{if(r===null)return Zc.null({});if(r==null&&!this.hasExample(i.value,0,a,o)&&this.exceedsMaxDepth(n,o))return Zc.null({});let f=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:o,skipReadonly:c});return f??Zc.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 Zc.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]=Zc.primitive(Ka.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]=Zc.primitive(Ka.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 Zc.oneOf(NCi.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=XCi(r);if(f!=null)return Zc.unknown(f)}return o.ignoreOptionals||this.exceedsMaxDepth(n,o)?void 0:o.isParameter?Zc.primitive(Ka.string(o.name??"string")):Zc.map([{key:Ka.string("key"),value:Zc.primitive(Ka.string("value"))}]);case"array":{let f=Ty_(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 Zc.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 Zc.map(l)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return Zc.map([{key:Ka.string("key"),value:Zc.unknown(Zc.primitive(Ka.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"?Zc.map([{key:s,value:u}]):Zc.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=b?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:ni.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 Zc.object({properties:f})}default:Ot(i)}}mergeExampleWith(t,r){t._visit({array:Mt,enum:Mt,literal:Mt,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:Mt,unknown:Mt,null:Mt,_other:Mt})}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(c=>this.hasExample(c,0,new Set,{ignoreOptionals:!1,isParameter:!1}));if(a!=null)return a;let o=t.schemas.find(c=>this.hasInherentExample(c));return o??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 Ry_({schema:t,value:r})?5:0;case"object":{if(!$c(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(!$c(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}}hasInherentExample(t){switch(t.type){case"literal":return!0;case"enum":return t.values.length>0;case"optional":case"nullable":return this.hasInherentExample(t.value);case"reference":{let r=this.schemas[t.schema];return r!=null?this.hasInherentExample(r):!1}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"?Ka.string(t):r.example!=null?Ka.string(r.example):Ka.string(i.name??Tn.STRING);case"base64":return t!=null&&typeof t=="string"?Ka.base64(t):r.example!=null?Ka.base64(r.example):Ka.base64(Tn.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?Ka.boolean(t):r.example!=null?Ka.boolean(r.example):Ka.boolean(Tn.BOOLEAN);case"date":return t!=null&&typeof t=="string"?Ka.date(t):r.example!=null?Ka.date(r.example):Ka.date(Tn.DATE);case"datetime":return t!=null&&typeof t=="string"?Ka.datetime(t):r.example!=null?Ka.datetime(r.example):Ka.datetime(Tn.DATE_TIME);case"double":return t!=null&&typeof t=="number"?Ka.double(t):r.example!=null?Ka.double(r.example):Ka.double(Tn.DOUBLE);case"float":return t!=null&&typeof t=="number"?Ka.float(t):r.example!=null?Ka.float(r.example):Ka.float(Tn.FLOAT);case"int":return t!=null&&typeof t=="number"?Ka.int(t):r.example!=null?Ka.int(r.example):Ka.int(Tn.INT);case"int64":return t!=null&&typeof t=="number"?Ka.int64(t):r.example!=null?Ka.int64(r.example):Ka.int64(Tn.INT64);case"uint":return t!=null&&typeof t=="number"?Ka.uint(t):r.example!=null?Ka.uint(r.example):Ka.uint(Tn.UINT);case"uint64":return t!=null&&typeof t=="number"?Ka.uint64(t):r.example!=null?Ka.uint64(r.example):Ka.uint64(Tn.UINT64);default:Ot(r)}}};function Ry_({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function OFt(e){switch(e.type){case"object":return ni.object({allOf:e.allOf,properties:e.properties.map(t=>zrM(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 ni.array({description:e.description,availability:e.availability,value:OFt(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 ni.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 ni.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 ni.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:OFt(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return ni.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:OFt(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return ni.primitive({description:e.description,availability:e.availability,schema:zy_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return ni.map({description:e.description,availability:e.availability,key:ni.primitive({description:e.key.description,availability:e.key.availability,schema:zy_(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:OFt(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 ni.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 ni.oneOf(RrM(e.value));case"unknown":return ni.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:Ot(e)}}function RrM(e){switch(e.type){case"discriminated":return Bhe.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:OFt(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,OFt(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=>OFt(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:Ot(e)}}function zy_(e){switch(e.type){case"string":return Un.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return Un.base64({example:void 0});case"boolean":return Un.boolean({default:e.default,example:void 0});case"date":return Un.date({example:void 0});case"datetime":return Un.datetime({example:void 0});case"double":return Un.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 Un.float({example:void 0});case"int":return Un.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 Un.int64({default:e.default,example:void 0});case"uint":return Un.uint({default:void 0,example:void 0});case"uint64":return Un.uint64({default:void 0,example:void 0});default:Ot(e)}}function zrM(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:OFt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function NLo(e){return e.type!=="optional"&&e.type!=="nullable"}function dcc(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 FLo=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 ZCi(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=CJi.dirname(a),c=o;for(;c!==CJi.dirname(c);){let f=CJi.join(c,"fern");if(wUn.existsSync(f)&&wUn.statSync(f).isDirectory()){t=f;break}c=CJi.dirname(c)}t||(t=o)}else t=process.cwd();let r=t??process.cwd(),i=CJi.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(`
|
|
1413
1413
|
`).map(s=>` ${s}`).join(`
|
|
1414
1414
|
`);o.push(f)}return o.push(""),o}),""].join(`
|
|
@@ -1783,7 +1783,7 @@ A valid API configuration was not found at the path: fern/apis/${t.apiName}.
|
|
|
1783
1783
|
Learn more about project structure:
|
|
1784
1784
|
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`:`Failed to load API Definition referenced in docs.
|
|
1785
1785
|
Learn more about project structure:
|
|
1786
|
-
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`;throw new Error(r)}async toRootNode(){let t=Ct.V1.SlugGenerator.init(Ct.slugjoin(this.getDocsBasePath())),r=this.#e.get("root"),i=await this.toRootChild(t);return{type:"root",version:"v1",id:r,child:i,slug:t.get(),title:this.parsedDocsConfig.title??"Documentation",hidden:!1,icon:void 0,pointsTo:void 0,authed:void 0,viewers:void 0,orphaned:void 0,roles:this.parsedDocsConfig.roles?.map(n=>Ct.RoleId(n)),featureFlags:void 0}}async toRootChild(t){return Kxi(this.parsedDocsConfig.navigation)._visit({untabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),tabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),versioned:r=>this.toVersionedNode(r,t),productgroup:r=>this.toProductGroupNode({landingPageConfig:this.parsedDocsConfig.landingPage,productGroup:r,parentSlug:t})})}toLandingPageNode(t,r){let i=Ct.PageId(this.toRelativeFilepath(t.absolutePath)),n=r.apply({urlSlug:t.slug??Rw(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{type:"landingPage",id:this.#e.get(i),title:t.title,slug:n.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:i,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags}}async toUnversionedNode({landingPage:t,navigationConfig:r,parentSlug:i}){let n=this.#e.get("unversioned"),a=t!=null?this.toLandingPageNode(t,i):void 0,o=r.type==="tabbed"?await this.convertTabbedNavigation(n,r.items,i):await this.toSidebarRootNode(n,r.items,i);return{type:"unversioned",id:n,landingPage:a,child:o}}async toVersionedNode(t,r){let i=this.#e.get("versioned"),n=t.versions[0];if(n?.hidden===!0)throw new Error(`The default version "${n.version}" cannot be hidden. Please set a non-hidden version as the first version in your versions list, or remove the hidden flag from the default version.`);return{id:i,type:"versioned",children:await Promise.all(t.versions.map((a,o)=>this.toVersionNode(a,r,o===0)))}}async toProductGroupNode({productGroup:t,landingPageConfig:r,parentSlug:i}){let n=this.#e.get("productgroup"),a=r!=null?this.toLandingPageNode(r,i):void 0;return{id:n,type:"productgroup",landingPage:a,children:await Promise.all(t.products.map(o=>this.toProductNode(o,i)))}}async toProductNode(t,r){if(t.type==="internal"){let i=r.setProductSlug(t.slug??Rw(t.product)),n;switch(t.navigation.type){case"tabbed":n={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.convertTabbedNavigation(this.#e.get(t.product),t.navigation.items,i)};break;case"untabbed":n={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.toSidebarRootNode(this.#e.get(t.product),t.navigation.items,i)};break;case"versioned":n=await this.toVersionedNode(t.navigation,i);break;default:Ot(t.navigation)}return{type:"product",id:this.#e.get(t.product),productId:Ct.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",slug:i.get(),child:n,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,pointsTo:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,announcement:t.announcement!=null?{text:t.announcement.message}:void 0}}else return{type:"productLink",id:this.#e.get(t.product),productId:Ct.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",href:RW.Url(t.href??""),target:t.target,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,viewers:t.viewers,orphaned:t.orphaned}}async toVersionNode(t,r,i){let n=this.#e.get(t.version),a=r.setVersionSlug(t.slug??Rw(t.version)),o=t.navigation.type==="tabbed"?await this.convertTabbedNavigation(n,t.navigation.items,a):await this.toSidebarRootNode(n,t.navigation.items,a);return{type:"version",id:n,versionId:Ct.VersionId(t.version),title:t.version,slug:a.get(),child:o,default:i,availability:t.availability!=null?zFM(t.availability):void 0,landingPage:t.landingPage?this.toLandingPageNode(t.landingPage,a):void 0,hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,icon:void 0,pointsTo:void 0,featureFlags:t.featureFlags,announcement:t.announcement!=null?{text:t.announcement.message}:void 0}}async toSidebarRootNode(t,r,i){let n=this.#e.get(`${t}/root`),a=await Promise.all(r.map(c=>this.toNavigationChild({prefix:n,item:c,parentSlug:i}))),o=[];return a.forEach(c=>{if(c.type==="apiReference"){o.push(c);return}if(c.type==="section"&&!c.collapsed){o.push(c);return}let f=o.length>0?o[o.length-1]:void 0,s;f?.type==="sidebarGroup"?s=f:(s={id:this.#e.get(`${n}/group`),type:"sidebarGroup",children:[]},o.push(s)),s.children.push(c)}),{type:"sidebarRoot",id:n,children:o}}async toSidebarRootNodeWithVariants(t,r,i){let n=this.#e.get(`${t}/root`);return{type:"sidebarRoot",id:n,children:[{type:"varianted",id:n,children:await Promise.all(r.map(a=>this.toVariantNode(a,n,i)))}]}}async toVariantNode(t,r,i){let n=this.#e.get(`${r}/variant/${t.slug??Rw(t.title)}`),a=i.apply({urlSlug:t.slug??Rw(t.title),skipUrlSlug:t.skipUrlSlug}),o=await Promise.all(t.layout.map(c=>this.toVariantChild(c,n,a)));return{type:"variant",id:n,variantId:Ct.V1.VariantId(t.title),subtitle:t.subtitle??"",default:t.default??!1,image:void 0,children:o,title:t.title,slug:a.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,pointsTo:void 0}}async toVariantChild(t,r,i){return Kxi(t)._visit({page:async n=>this.toPageNode({item:n,parentSlug:i}),apiSection:async n=>this.toApiSectionNode({item:n,parentSlug:i}),section:async n=>this.toSectionNode({prefix:r,item:n,parentSlug:i}),link:async n=>this.toLinkNode(n),changelog:async n=>this.toChangelogNode(n,i)})}async toNavigationChild({prefix:t,item:r,parentSlug:i,hideChildren:n,parentAvailability:a}){return Kxi(r)._visit({page:async o=>this.toPageNode({item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),apiSection:async o=>this.toApiSectionNode({item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),section:async o=>this.toSectionNode({prefix:t,item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),link:async o=>this.toLinkNode(o),changelog:async o=>this.toChangelogNode(o,i,n)})}async toApiSectionNode({item:t,parentSlug:r,hideChildren:i,parentAvailability:n}){let a=rN_(t.snippetsConfiguration),o,c=await this.getFernWorkspaceForApiSection(t).toFernWorkspace({context:this.taskContext},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,objectQueryParameters:!0,preserveSchemaIds:!0}),f=this.parsedDocsConfig.experimental?.openapiParserV3,s=f==null||f;if(s)try{o=await this.getOpenApiWorkspaceForApiSection(t).getIntermediateRepresentation({context:this.taskContext,audiences:t.audiences,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1})}catch{}let u;if(t.tagDescriptionPages&&s)try{let b=await this.getOpenApiWorkspaceForApiSection(t).getOpenAPIIr({context:this.taskContext});b.tags.tagsById&&(u=Object.fromEntries(Object.entries(b.tags.tagsById).filter(([v,O])=>O.description&&O.description.trim().length>0).map(([v,O])=>[v,{id:String(O.id),description:O.description}])))}catch(y){this.taskContext.logger.warn("Failed to extract OpenAPI tags for tag description pages",String(y))}o==null&&(o=kw({workspace:c,audiences:t.audiences,generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},readme:void 0,version:void 0,packageName:void 0,context:this.taskContext,sourceResolver:new Zw(this.taskContext,c)})),this.docsWorkspace.config.settings?.substituteEnvVars&&(o=dR(o,{onError:y=>this.taskContext.failAndThrow(`Error substituting environment variables in API spec: ${y}`)},{substituteAsEmpty:!1}));let l=await this.registerApi({ir:o,snippetsConfig:a,playgroundConfig:{oauth:t.playground?.oauth},apiName:t.apiName,workspace:c}),p=ZEa({ir:o,apiDefinitionId:l,playgroundConfig:{oauth:t.playground?.oauth},context:this.taskContext}),_=new z9o(t,p,r,this.docsWorkspace,this.taskContext,this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,this.#e,this.collectedFileIds,c,i,n??t.availability,u),h=_.getTagDescriptionContent();for(let[y,b]of h.entries()){let v=y.split("/").pop()||y,O=$e.of(v),A=b;this.docsWorkspace.config.settings?.substituteEnvVars&&(A=dR(b,{onError:g=>this.taskContext.logger.error(`Error in tag description environment variable substitution: ${g}`)},{substituteAsEmpty:!1})),this.rawMarkdownFiles[O]=A,this.parsedDocsConfig.pages[O]=A}return _.get()}async toChangelogNode(t,r,i){return new W$i(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,t.changelog,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:r,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:i||t.hidden,slug:t.slug})}async toLinkNode(t){return{type:"link",id:this.#e.get(t.url),title:t.text,url:Ct.V1.Url(t.url),icon:this.resolveIconFileId(t.icon),target:t.target}}async toPageNode({item:t,parentSlug:r,hideChildren:i,parentAvailability:n}){let a=Ct.PageId(this.toRelativeFilepath(t.absolutePath)),o=r.apply({urlSlug:t.slug??Rw(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{id:this.#e.get(a),type:"page",slug:o.get(),title:this.markdownFilesToSidebarTitle.get(t.absolutePath)??t.title,icon:this.resolveIconFileId(t.icon),hidden:i||t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:a,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags,availability:t.availability??n}}async toSectionNode({prefix:t,item:r,parentSlug:i,hideChildren:n,parentAvailability:a}){let o=this.toRelativeFilepath(r.overviewAbsolutePath),c=o?Ct.PageId(o):void 0,f=this.#e.get(c??`${t}/section`),s=i.apply({urlSlug:r.slug??Rw(r.title),fullSlug:r.overviewAbsolutePath?this.markdownFilesToFullSlugs.get(r.overviewAbsolutePath)?.split("/"):void 0,skipUrlSlug:r.skipUrlSlug}),u=r.overviewAbsolutePath!=null?this.markdownFilesToNoIndex.get(r.overviewAbsolutePath):void 0,l=n||r.hidden;return{id:f,type:"section",overviewPageId:c,slug:s.get(),title:r.overviewAbsolutePath!=null?this.markdownFilesToSidebarTitle.get(r.overviewAbsolutePath)??r.title:r.title,icon:this.resolveIconFileId(r.icon),collapsed:r.collapsed,hidden:l,viewers:r.viewers,orphaned:r.orphaned,children:await Promise.all(r.contents.map(p=>this.toNavigationChild({prefix:f,item:p,parentSlug:s,hideChildren:l,parentAvailability:r.availability??a}))),authed:void 0,pointsTo:void 0,noindex:u,featureFlags:r.featureFlags,availability:r.availability??a}}async convertTabbedNavigation(t,r,i){let n=this.#e.get(`${t}/tabbed`);return{type:"tabbed",id:n,children:await Promise.all(r.map(a=>this.toTabChild(n,a,i)))}}async toTabChild(t,r,i){return Kxi(r.child)._visit({link:({href:n,target:a})=>this.toTabLinkNode(r,n,a),layout:({layout:n})=>this.toTabNode(t,r,n,i),changelog:({changelog:n})=>this.toTabChangelogNode(r,n,i),variants:({variants:n})=>this.toTabNodeWithVariants(t,r,n,i)})}async toTabChangelogNode(t,r,i){return new W$i(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,r,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:i,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:t.hidden,slug:t.slug})}async toTabLinkNode(t,r,i){return{type:"link",id:this.#e.get(r),title:t.title,url:Ct.V1.Url(r),target:i,icon:this.resolveIconFileId(t.icon)}}async toTabNode(t,r,i,n){let a=this.#e.get(`${t}/tab`),o=n.apply({urlSlug:r.slug??Rw(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:a,title:r.title,slug:o.get(),icon:this.resolveIconFileId(r.icon),hidden:r.hidden,authed:void 0,viewers:r.viewers,orphaned:r.orphaned,pointsTo:void 0,child:await this.toSidebarRootNode(a,i,o),featureFlags:r.featureFlags}}async toTabNodeWithVariants(t,r,i,n){let a=this.#e.get(`${t}/tab`),o=n.apply({urlSlug:r.slug??Rw(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:a,title:r.title,slug:o.get(),icon:this.resolveIconFileId(r.icon),hidden:r.hidden,authed:void 0,viewers:r.viewers,orphaned:r.orphaned,pointsTo:void 0,child:await this.toSidebarRootNodeWithVariants(a,i,o),featureFlags:r.featureFlags}}getFileId(t){if(t==null)return;let r=this.collectedFileIds.get(t);return r==null?this.taskContext.failAndThrow("Failed to locate file after uploading: "+t):RW.FileId(r)}resolveIconFileId(t){if(t!=null)return this.collectedFileIds.has(t)?`file:${this.getFileId(t)}`:t}convertPageActions(){if(this.parsedDocsConfig.pageActions!=null)return{default:this.parsedDocsConfig.pageActions.default,options:{askAi:this.parsedDocsConfig.pageActions.options.askAi,copyPage:this.parsedDocsConfig.pageActions.options.copyPage,viewAsMarkdown:this.parsedDocsConfig.pageActions.options.viewAsMarkdown,openAi:this.parsedDocsConfig.pageActions.options.openAi,claude:this.parsedDocsConfig.pageActions.options.claude,cursor:this.parsedDocsConfig.pageActions.options.cursor,vscode:this.parsedDocsConfig.pageActions.options.vscode,custom:this.parsedDocsConfig.pageActions.options.custom.map(t=>({title:t.title,subtitle:t.subtitle,url:t.url,icon:this.resolveIconFileId(t.icon),default:t.default}))}}}convertColorConfigImageReferences(){let{colors:t}=this.parsedDocsConfig;if(t!=null)return t.type==="dark"?{...t,...this.convertLogoAndBackgroundImage({theme:"dark"})}:t.type==="light"?{...t,...this.convertLogoAndBackgroundImage({theme:"light"}),type:"light"}:{...t,dark:{...t.dark,...this.convertLogoAndBackgroundImage({theme:"dark"})},light:{...t.light,...this.convertLogoAndBackgroundImage({theme:"light"})}}}convertLogoAndBackgroundImage({theme:t}){let{logo:r,backgroundImage:i}=this.parsedDocsConfig,n=r?.[t],a=i?.[t];return{logo:this.getFileId(n),backgroundImage:this.getFileId(a)}}convertDocsTypographyConfiguration(){if(this.parsedDocsConfig.typography!=null)return{headingsFont:this.convertFont(this.parsedDocsConfig.typography.headingsFont,"headings"),bodyFont:this.convertFont(this.parsedDocsConfig.typography.bodyFont,"body"),codeFont:this.convertFont(this.parsedDocsConfig.typography.codeFont,"code")}}convertFont(t,r){if(t==null||t.variants[0]==null)return;let i=this.getFileId(t.variants[0].absolutePath);return{type:"custom",name:t.name??`font:${r}:${i}`,variants:t.variants.map(n=>({fontFile:this.getFileId(n.absolutePath),weight:n.weight,style:n.style!=null?[n.style]:void 0})),display:t.display,fallback:t.fallback,fontVariationSettings:t.fontVariationSettings}}convertJavascriptConfiguration(){if(this.parsedDocsConfig.js!=null)return{files:this.parsedDocsConfig.js.files.map(({absolutePath:t,strategy:r})=>({fileId:this.getFileId(t),strategy:r})).filter(ts),remote:this.parsedDocsConfig.js.remote?.map(t=>({...t,url:RW.Url(t.url)})),inline:void 0}}convertMetadata(){if(this.parsedDocsConfig.metadata==null)return;let{"og:image":t,"og:logo":r,"twitter:image":i,...n}=this.parsedDocsConfig.metadata;return{...n,"og:image":this.convertFileIdOrUrl(t),"og:logo":this.convertFileIdOrUrl(r),"twitter:image":this.convertFileIdOrUrl(i)}}convertFileIdOrUrl(t){if(t!=null)return Kxi(t,"type")._visit({filepath:({value:r})=>({type:"fileId",value:this.getFileId(r)}),url:({value:r})=>({type:"url",value:RW.Url(r)}),_other:()=>this.taskContext.failAndThrow("Invalid metadata configuration")})}};function RFM(e,t){if(e?.github==null)return;let{owner:r,repo:i,branch:n="main",host:a="https://github.com"}=e.github;return`${F1(a)}/${r}/${i}/blob/${n}/fern/${t}?plain=1`}function zFM(e){switch(e){case"beta":return Ct.V1.NavigationV1Availability.Beta;case"deprecated":return Ct.V1.NavigationV1Availability.Deprecated;case"ga":return Ct.V1.NavigationV1Availability.GenerallyAvailable;case"stable":return Ct.V1.NavigationV1Availability.Stable;default:Ot(e)}}async function oU(e){return(await Promise.all(e.apiWorkspaces.map(async t=>t instanceof Xw?t:null))).filter(ts)}async function sgc(e,t,r){if(e instanceof F9t){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof Xw))return;let i=await e.getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1});return Rx({ir:i,snippetsConfig:{typescriptSdk:void 0,pythonSdk:void 0,javaSdk:void 0,rubySdk:void 0,goSdk:void 0,csharpSdk:void 0,phpSdk:void 0,swiftSdk:void 0,rustSdk:void 0},playgroundConfig:{oauth:!0},context:t})}var Qs={};Yt(Qs,{AlgoliaSearchIndex:()=>mN_,ApiDefinitionId:()=>WN_,ApiId:()=>KN_,Availability:()=>sF_,DocsConfigId:()=>JN_,EndpointId:()=>YN_,EndpointPathLiteral:()=>oF_,EnvironmentId:()=>$N_,FileId:()=>tF_,HttpMethod:()=>uF_,IndexSegmentId:()=>PN_,JqString:()=>iF_,OrgId:()=>GN_,PageId:()=>eF_,PayloadLocation:()=>RF_,PropertyKey:()=>nF_,PullRequestState:()=>BF_,RoleId:()=>aF_,TokenId:()=>HN_,TypeId:()=>kN_,Url:()=>rF_,VersionId:()=>xN_,WebSocketId:()=>XN_,WebhookId:()=>ZN_,algolia:()=>cgc,api:()=>ggc,commons:()=>Ogc,diff:()=>cF_,docs:()=>Dgc,generators:()=>Igc,git:()=>Cgc,navigation:()=>Rgc,sdks:()=>Ngc,snippets:()=>qF_,snippetsFactory:()=>TF_,templates:()=>Fgc,tokens:()=>zF_});var cgc={};Yt(cgc,{AlgoliaSearchIndex:()=>mN_,IndexSegmentId:()=>PN_});function mN_(e){return e}function PN_(e){return e}var ggc={};Yt(ggc,{latest:()=>dgc,v1:()=>vgc});var dgc={};Yt(dgc,{AuthSchemeId:()=>jN_,WebhookHttpMethod:()=>MN_,auth:()=>lgc,commons:()=>wN_,endpoint:()=>EN_,type_:()=>SN_,webhook:()=>fgc,websocket:()=>DN_});var lgc={};Yt(lgc,{AuthSchemeId:()=>jN_});function jN_(e){return e}var wN_={};var EN_={};var SN_={};var fgc={};Yt(fgc,{WebhookHttpMethod:()=>MN_});var MN_={Get:"GET",Post:"POST"};var DN_={};var vgc={};Yt(vgc,{SubpackageId:()=>QN_,WebSocketMessageId:()=>UN_,WebSocketMessageOrigin:()=>LN_,WebhookHttpMethod:()=>VN_,commons:()=>bgc,db:()=>pgc,read:()=>hgc,register:()=>ygc});var pgc={};Yt(pgc,{endpoint:()=>BN_});var BN_={};var hgc={};Yt(hgc,{SupportedLanguage:()=>IN_,endpoint:()=>_gc,type_:()=>CN_,webhook:()=>qN_,websocket:()=>TN_});var _gc={};Yt(_gc,{SupportedLanguage:()=>IN_});var IN_={Curl:"curl",Python:"python",Javascript:"javascript",Js:"js",Node:"node",Typescript:"typescript",Ts:"ts",Go:"go",Ruby:"ruby",Csharp:"csharp"};var CN_={};var qN_={};var TN_={};var ygc={};Yt(ygc,{SourceId:()=>NFM,endpoint:()=>RN_,type_:()=>zN_,webhook:()=>NN_,websocket:()=>FN_});var RN_={};var zN_={};var NN_={};var FN_={};function NFM(e){return e}var bgc={};Yt(bgc,{SubpackageId:()=>QN_,WebSocketMessageId:()=>UN_,WebSocketMessageOrigin:()=>LN_,WebhookHttpMethod:()=>VN_});function QN_(e){return e}function UN_(e){return e}var LN_={Client:"client",Server:"server"};var VN_={Get:"GET",Post:"POST"};var Ogc={};Yt(Ogc,{ApiDefinitionId:()=>WN_,ApiId:()=>KN_,Availability:()=>sF_,DocsConfigId:()=>JN_,EndpointId:()=>YN_,EndpointPathLiteral:()=>oF_,EnvironmentId:()=>$N_,FileId:()=>tF_,HttpMethod:()=>uF_,JqString:()=>iF_,OrgId:()=>GN_,PageId:()=>eF_,PropertyKey:()=>nF_,RoleId:()=>aF_,TokenId:()=>HN_,TypeId:()=>kN_,Url:()=>rF_,VersionId:()=>xN_,WebSocketId:()=>XN_,WebhookId:()=>ZN_});function WN_(e){return e}function xN_(e){return e}function GN_(e){return e}function HN_(e){return e}function KN_(e){return e}function JN_(e){return e}function $N_(e){return e}function YN_(e){return e}function XN_(e){return e}function ZN_(e){return e}function kN_(e){return e}function eF_(e){return e}function tF_(e){return e}function rF_(e){return e}function iF_(e){return e}function nF_(e){return e}function aF_(e){return e}function oF_(e){return e}var uF_={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE"};var sF_={Stable:"Stable",GenerallyAvailable:"GenerallyAvailable",InDevelopment:"InDevelopment",PreRelease:"PreRelease",Deprecated:"Deprecated",Beta:"Beta"};var cF_={};var Dgc={};Yt(Dgc,{latest:()=>Pgc,v1:()=>Sgc,v2:()=>Mgc});var Pgc={};Yt(Pgc,{Layout:()=>fF_,MdxEngine:()=>FFM,TwitterCardSetting:()=>dF_,commons:()=>lF_,frontmatter:()=>Agc,seo:()=>mgc});var FFM={NextMdxRemote:"next-mdx-remote",MdxBundler:"mdx-bundler"};var lF_={};var Agc={};Yt(Agc,{Layout:()=>fF_});var fF_={Guide:"guide",Overview:"overview",Reference:"reference",Page:"page",Custom:"custom"};var mgc={};Yt(mgc,{TwitterCardSetting:()=>dF_});var dF_={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var Sgc={};Yt(Sgc,{commons:()=>Egc,db:()=>pF_,read:()=>_F_,write:()=>jgc});var pF_={};var _F_={};var jgc={};Yt(jgc,{DocsRegistrationId:()=>UFM,FilePath:()=>QFM});function QFM(e){return e}function UFM(e){return e}var Egc={};Yt(Egc,{ContentAlignment:()=>vF_,FontDisplay:()=>PF_,FontStyle:()=>mF_,HeaderPosition:()=>gF_,JsScriptStrategy:()=>AF_,ProgrammingLanguage:()=>hF_,SearchbarPlacement:()=>yF_,TabsPlacement:()=>bF_,TwitterCardSetting:()=>OF_,commons:()=>wgc});var wgc={};Yt(wgc,{ContentAlignment:()=>vF_,FontDisplay:()=>PF_,FontStyle:()=>mF_,HeaderPosition:()=>gF_,JsScriptStrategy:()=>AF_,ProgrammingLanguage:()=>hF_,SearchbarPlacement:()=>yF_,TabsPlacement:()=>bF_,TwitterCardSetting:()=>OF_});var hF_={Typescript:"typescript",Javascript:"javascript",Python:"python",Java:"java",Go:"go",Ruby:"ruby",Csharp:"csharp",Nodets:"nodets",Nodejs:"nodejs",Dotnet:"dotnet",Curl:"curl",Jvm:"jvm",Ts:"ts",Js:"js"};var yF_={Header:"HEADER",HeaderTabs:"HEADER_TABS",Sidebar:"SIDEBAR"};var bF_={Header:"HEADER",Sidebar:"SIDEBAR"};var vF_={Center:"CENTER",Left:"LEFT"};var gF_={Fixed:"FIXED",Absolute:"ABSOLUTE"};var OF_={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var AF_={BeforeInteractive:"beforeInteractive",AfterInteractive:"afterInteractive",LazyOnload:"lazyOnload"};var mF_={Normal:"normal",Italic:"italic"};var PF_={Auto:"auto",Block:"block",Swap:"swap",Fallback:"fallback",Optional:"optional"};var Mgc={};Yt(Mgc,{read:()=>jF_,write:()=>wF_});var jF_={};var wF_={};var Igc={};Yt(Igc,{ChangelogEntryType:()=>SF_,GeneratorId:()=>LFM,GeneratorLanguage:()=>VFM,ReleaseType:()=>MF_,cli:()=>EF_,commons:()=>Bgc,versions:()=>DF_});var EF_={};var Bgc={};Yt(Bgc,{ChangelogEntryType:()=>SF_,ReleaseType:()=>MF_});var SF_={Fix:"fix",Feat:"feat",Chore:"chore",Break:"break",Internal:"internal"};var MF_={Ga:"GA",Rc:"RC"};var DF_={};function LFM(e){return e}var VFM={Python:"python",Go:"go",Java:"java",Typescript:"typescript",Ruby:"ruby",Csharp:"csharp",Php:"php",Swift:"swift",Rust:"rust"};var Cgc={};Yt(Cgc,{PullRequestState:()=>BF_});var BF_={Open:"open",Closed:"closed",Merged:"merged"};var Rgc={};Yt(Rgc,{latest:()=>qgc,v1:()=>Tgc});var qgc={};Yt(qgc,{NodeId:()=>GFM,ProductId:()=>HFM,Slug:()=>WFM,TabId:()=>xFM});function WFM(e){return e}function xFM(e){return e}function GFM(e){return e}function HFM(e){return e}var Tgc={};Yt(Tgc,{NavigationV1Availability:()=>XFM,NodeId:()=>$FM,ProductId:()=>YFM,Slug:()=>KFM,TabId:()=>JFM});function KFM(e){return e}function JFM(e){return e}function $FM(e){return e}function YFM(e){return e}var XFM={Stable:"stable",GenerallyAvailable:"generally-available",InDevelopment:"in-development",PreRelease:"pre-release",Beta:"beta",Deprecated:"deprecated"};var Ngc={};Yt(Ngc,{Language:()=>IF_,VersionBump:()=>CF_,versions:()=>zgc});var zgc={};Yt(zgc,{Language:()=>IF_,VersionBump:()=>CF_});var IF_={Go:"Go",TypeScript:"TypeScript",Java:"Java",Python:"Python",Csharp:"Csharp",Ruby:"Ruby"};var CF_={Major:"MAJOR",Minor:"MINOR",Patch:"PATCH"};var qF_={};var TF_={};var Fgc={};Yt(Fgc,{PayloadLocation:()=>RF_});var RF_={Body:"BODY",Query:"QUERY",Path:"PATH",Headers:"HEADERS",Relative:"RELATIVE",Auth:"AUTH"};var zF_={};var G9o=class{warnings=[];errors=[];error(t){this.errors.push(t)}warning(t){this.warnings.push(t)}};function mo(e){return e!=null}var FF_=se(pda(),1);var NF_=["PII","PHI","PCI","GDPR","CCPA","HIPAA","COPPA","FERPA","GLBA","SOX","FISMA","NIST","CIS","ISO","IEC","ITAR","EAR","CMMC","CUI","CDI","FTC","FCC","SEC","FINRA","XSS","CSRF","SSRF","XSRF","TLS","SSL","SSH","API","OAuth","OAuth1","OAuth1.0","OAuth2","OAuth2.0","SAML","OpenID","OpenID Connect","CAPTCHA","reCAPTCHA","2FA","MFA","OTP","TOTP","HOTP","U2F","FIDO","FIDO2","PKI","HMAC","AES","RSA","SHA","MD5","BCrypt","PBKDF2","Argon2","SCrypt","JWT","JWE","JWS","JWK","JWA","JOSE","SKU","SKUs","UPC","EAN","ISBN","ASIN","MPN","MSRP","MAP","RRP","MSRP","AM","PM","UTC","GMT","PST","PDT","EST","EDT","CST","CDT","MST","MDT","USA","UK","EU","UAE","APAC","EMEA","LATAM","ANZ","SEA","MEA","MENA","NATO","NA","SA","CA","EU","AU","NZ","JP","KR","CN","HK","TW","SG","MY","TH","ID","PH","VN","IN","PK","BD","LK","NP","MM","KH","LA","MM","BT","MV","USD","EUR","GBP","JPY","CNY","RUB","INR","AUD","CAD","CHF","SGD","MYR","THB","IDR","KRW","PHP","VND","HKD","TWD","MXN","BRL","ARS","CLP","COP","PEN","ZAR","NGN","EGP","AED","SAR","ILS","TRY","SEK","NOK","DKK","ISK","HUF","PLN","CZK","RON","BGN","API","APIs","SDK","SDKs","AI","OCR","REST","SOAP","JSON","XML","HTTP","HTTPS","URI","URL","CRUD","RESTful","KYB","KYC","AML","HTML","CSS","JS","SQL","DB","UI","UX","SaaS","PaaS","IaaS","IP","TCP","UDP","DNS","FTP","SMTP","IMAP","POP3","CSV","MVC","MVP","MVVM","DOM","SPA","SSR","CSR","DDoS","CDN","IoT","ML","DL","NLP","CLI","GUI","BI","ETL","RDBMS","NoSQL","IDE","CMS","CCPA","POSIX","ABI","API","AST","COBOL","DDL","DML","NN","CNN","RNN","LSTM","GRU","ANN","GAN","RL","DL","ML","NLP","NLG","NLU","BERT","GPT","SVM","PCA","AI","CV","TF","TTS","ASR","HMM","DNN","MLP","RBM","CRF","PDF","PDFs","RTF","TXT","XLS","XLSX","PPT","JPG","JPEG","PNG","GIF","GIFs","SVG","TIFF","BMP","ICO","PSD","WebP","AVIF","HEIF","HEIC","EPS","MP3","WAV","AIFF","FLAC","WMA","AAC","OGG","AVI","WMV","MOV","M4V","MP4","MPG","MPEG","FLV","SWF","MKV","WebM","GCP","AWS","VM","VPC","S3","EC2","DynamoDB","CosmosDB","BigQuery","CI/CD","SOC1","SOC2","SOC3","PCI DSS","WAF","IAM","SDN","MPLS","BGP","Vue.js","Node.js",".NET"];function X9t(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,FF_.default)(e,{special:NF_}).replace(/V\s(\d)/g,"V$1")}function QF_({endpoints:e,webhookEndpoints:t}){let r={};return Object.values({...e,...t}).forEach(i=>{let n=[];i.namespace?.forEach(a=>{let o=[...n,a],c=Qs.api.v1.SubpackageId(o.join("."));r[c]={id:c,name:a,displayName:X9t(a)},n.push(a)})}),r}var H9o=class{input;context;constructor(t,r){this.input=t,this.context=r}errors(){return this.context.errors.errors}warnings(){return this.context.errors.warnings}};function UF_(e){return`#/${e.map(t=>t.replaceAll(/~/g,"~0").replaceAll(/\//g,"~1")).join("/")}`}var $a=class extends H9o{context;accessPath;pathId;constructor({input:t,context:r,accessPath:i,pathId:n}){if(super(t,r),this.context=r,this.accessPath=[...i],this.pathId=n,n!=null){let a=Array.isArray(this.pathId)?this.pathId:[this.pathId];a.every((o,c)=>o===this.accessPath[this.accessPath.length-a.length+c])||this.accessPath.push(...a)}r.logger.debug(`Processing ${UF_(this.accessPath)}`)}safeParse(...t){try{this.parse(...t)}catch{this.context.errors.error({message:"Error converting node. Please contact support if the error persists",path:this.accessPath})}}},LB=class extends $a{},gK=class extends LB{seenSchemas;constructor(t){super(t),this.seenSchemas=new Set(t.seenSchemas)}};var LF_="x-fern-base-path",VF_="x-fern-availability",K9o="x-fern-sdk-group-name",WF_="x-fern-global-headers",xF_="x-fern-sdk-method-name";var GF_="x-fern-webhook",HF_="x-fern-access-token-locator",KF_="x-fern-basic",JF_="x-fern-username-variable-name",$F_="x-fern-password-variable-name",YF_="x-fern-bearer",XF_="x-fern-token-variable-name",ZF_="x-fern-header",kF_="x-fern-header-variable-name",eQ_="x-fern-server-name",tQ_="x-fern-examples";var J9o=class extends $a{serverName;constructor(t){super(t),this.safeParse()}parse(){this.serverName=this.input[eQ_]}convert(){if(this.serverName!=null)return this.serverName}};var $9o=class extends $a{url;serverName;constructor(t){super(t),this.safeParse()}parse(){this.url=Object.entries(this.input.variables??{}).reduce((t,[r,i])=>t.replace(`{${r}}`,i.default),this.input.url)??this.input.url,this.serverName=new J9o({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})}convert(){let t=this.serverName?.convert()??this.url;if(!(this.url==null||t==null))return{id:Qs.EnvironmentId(t),baseUrl:this.url}}};function h1i(e,t,r,i){let n=e??[],a=new Set(n.map(c=>c.url)),o=(t??[]).filter(c=>!a.has(c.url)).map((c,f)=>new $9o({input:c,context:r,accessPath:i,pathId:["servers",`${f}`]}));return[...n,...o]}function sv(e){return typeof e=="object"&&mo(e)&&"$ref"in e&&typeof e.$ref=="string"}function uU(e,t,r){let i=e.$ref.substring(2).split("/").map(a=>a.replace(/~1/g,"/")),n=t;for(let a of i){if(typeof n!="object"||n==null)return r;n=n[a]}return n==null?r:(sv(n)&&(n=uU(n,t,r)),n)}function Y9o(e,t){let r=t.components?.securitySchemes?.[e];if(r!=null)return sv(r)?uU(r,t,void 0):r}var OQ_=se(zE());var X9o=class extends $a{username;password;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[KF_];this.username=t?.username,this.password=t?.password}convert(){return{username:this.username,password:this.password}}};var Z9o=class extends $a{passwordVariableName;constructor(t){super(t),this.safeParse()}parse(){this.passwordVariableName=this.input[$F_]}convert(){return this.passwordVariableName}};var k9o=class extends $a{usernameVariableName;constructor(t){super(t),this.safeParse()}parse(){this.usernameVariableName=this.input[JF_]}convert(){return this.usernameVariableName}};var eGo=class extends $a{bearerTokenVariableName;bearerTokenEnvVar;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[YF_];this.bearerTokenVariableName=t?.name,this.bearerTokenEnvVar=t?.env}convert(){return{tokenVariableName:this.bearerTokenVariableName,tokenEnvVar:this.bearerTokenEnvVar}}};var tGo=class extends $a{tokenVariableName;constructor(t){super(t),this.safeParse()}parse(){this.tokenVariableName=this.input[XF_]}convert(){return this.tokenVariableName}};function rQ_(e){return typeof e=="object"&&e!=null&&"in"in e&&e.in==="header"}var iQ_="x-bearer-format",nQ_="x-code-samples",aQ_="x-codeSamples";var rGo=class extends $a{bearerFormat;constructor(t){super(t),this.safeParse()}parse(){this.bearerFormat=this.input[iQ_]}convert(){return this.bearerFormat}};var iGo=class extends $a{headerVariableName;headerEnvVar;headerPrefix;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[ZF_];this.headerVariableName=t?.name,this.headerEnvVar=t?.env,this.headerPrefix=t?.prefix}convert(){return{name:this.headerVariableName,env:this.headerEnvVar,prefix:this.headerPrefix}}};var nGo=class extends $a{headerVariableName;constructor(t){super(t),this.safeParse()}parse(){this.headerVariableName=this.input[kF_]}convert(){return this.headerVariableName}};function oQ_(e){return e.type==="apiKey"}var VLn=class extends $a{headerName;headerBearerFormatNode;headerAuthNode;headerVariableNameNode;constructor(t){super(t),this.safeParse()}parse(){oQ_(this.input)&&(this.headerName=this.input.name),this.headerAuthNode=new iGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerVariableNameNode=new nGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerBearerFormatNode=new rGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})}convert(){let t=this.headerAuthNode?.convert();if(t!=null)return{type:"header",nameOverride:t?.name,headerWireValue:this.headerName??"Authorization",prefix:t?.prefix??this.headerBearerFormatNode?.convert()}}};function aGo(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function WLn(e){return typeof e=="string"||typeof e=="symbol"?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function kEa(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(kEa).join(",");let t=String(e);return t==="0"&&Object.is(Number(e),-0)?"-0":t}function oGo(e){if(Array.isArray(e))return e.map(WLn);if(typeof e=="symbol")return[e];e=kEa(e);let t=[],r=e.length;if(r===0)return t;let i=0,n="",a="",o=!1;for(e.charCodeAt(0)===46&&(t.push(""),i++);i<r;){let c=e[i];a?c==="\\"&&i+1<r?(i++,n+=e[i]):c===a?a="":n+=c:o?c==='"'||c==="'"?a=c:c==="]"?(o=!1,t.push(n),n=""):n+=c:c==="["?(o=!0,n&&(t.push(n),n="")):c==="."?n&&(t.push(n),n=""):n+=c,i++}return n&&t.push(n),t}function eSa(e,t,r){if(e==null)return r;switch(typeof t){case"string":{if(pso(t))return r;let i=e[t];return i===void 0?aGo(t)?eSa(e,oGo(t),r):r:i}case"number":case"symbol":{typeof t=="number"&&(t=WLn(t));let i=e[t];return i===void 0?r:i}default:{if(Array.isArray(t))return ZFM(e,t,r);if(Object.is(t?.valueOf(),-0)?t="-0":t=String(t),pso(t))return r;let i=e[t];return i===void 0?r:i}}}function ZFM(e,t,r){if(t.length===0)return r;let i=e;for(let n=0;n<t.length;n++){if(i==null||pso(t[n]))return r;i=i[t[n]]}return i===void 0?r:i}function uQ_(e){return function(t){return eSa(t,e)}}function sQ_(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function Qgc(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function Lgc(e,t,r){return typeof r!="function"?Lgc(e,t,()=>{}):Ugc(e,t,function i(n,a,o,c,f,s){let u=r(n,a,o,c,f,s);return u!==void 0?!!u:Ugc(n,a,i,s)},new Map)}function Ugc(e,t,r,i){if(t===e)return!0;switch(typeof t){case"object":return kFM(e,t,r,i);case"function":return Object.keys(t).length>0?Ugc(e,{...t},r,i):Qgc(e,t);default:return sQ_(e)?typeof t=="string"?t==="":!0:Qgc(e,t)}}function kFM(e,t,r,i){if(t==null)return!0;if(Array.isArray(t))return cQ_(e,t,r,i);if(t instanceof Map)return eQM(e,t,r,i);if(t instanceof Set)return tQM(e,t,r,i);let n=Object.keys(t);if(e==null)return n.length===0;if(n.length===0)return!0;if(i?.has(t))return i.get(t)===e;i?.set(t,e);try{for(let a=0;a<n.length;a++){let o=n[a];if(!uso(e)&&!(o in e)||t[o]===void 0&&e[o]!==void 0||t[o]===null&&e[o]!==null||!r(e[o],t[o],o,e,t,i))return!1}return!0}finally{i?.delete(t)}}function eQM(e,t,r,i){if(t.size===0)return!0;if(!(e instanceof Map))return!1;for(let[n,a]of t.entries()){let o=e.get(n);if(r(o,a,n,e,t,i)===!1)return!1}return!0}function cQ_(e,t,r,i){if(t.length===0)return!0;if(!Array.isArray(e))return!1;let n=new Set;for(let a=0;a<t.length;a++){let o=t[a],c=!1;for(let f=0;f<e.length;f++){if(n.has(f))continue;let s=e[f],u=!1;if(r(s,o,a,e,t,i)&&(u=!0),u){n.add(f),c=!0;break}}if(!c)return!1}return!0}function tQM(e,t,r,i){return t.size===0?!0:e instanceof Set?cQ_([...e],[...t],r,i):!1}function uGo(e,t){return Lgc(e,t,()=>{})}function lQ_(e){return e=MUd(e),t=>uGo(t,e)}function fQ_(e,t){return SUd(e,(r,i,n,a)=>{let o=t?.(r,i,n,a);if(o!==void 0)return o;if(typeof e=="object")switch(Object.prototype.toString.call(e)){case lso:case cso:case fso:{let c=new e.constructor(e?.valueOf());return yzt(c,e),c}case dso:{let c={};return yzt(c,e),c.length=e.length,c[Symbol.iterator]=e[Symbol.iterator],c}default:return}})}function dQ_(e){return fQ_(e)}var rQM=/^(?:0|[1-9]\d*)$/;function pQ_(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e<t;case"symbol":return!1;case"string":return rQM.test(e)}}function _Q_(e){return e!==null&&typeof e=="object"&&sso(e)==="[object Arguments]"}function hQ_(e,t){let r;if(Array.isArray(t)?r=t:typeof t=="string"&&aGo(t)&&e?.[t]==null?r=oGo(t):r=[t],r.length===0)return!1;let i=e;for(let n=0;n<r.length;n++){let a=r[n];if((i==null||!Object.hasOwn(i,a))&&!((Array.isArray(i)||_Q_(i))&&pQ_(a)&&a<i.length))return!1;i=i[a]}return!0}function yQ_(e,t){switch(typeof e){case"object":{Object.is(e?.valueOf(),-0)&&(e="-0");break}case"number":{e=WLn(e);break}}return t=dQ_(t),function(r){let i=eSa(r,e);return i===void 0?hQ_(r,e):t===void 0?i===void 0:uGo(i,t)}}function bQ_(e){if(e==null)return rco;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&e.length===2?yQ_(e[0],e[1]):lQ_(e);case"string":case"symbol":case"number":return uQ_(e)}}function sGo(e,t=rco){return e==null?{}:rQ(e,bQ_(t))}function vQ_(e){return typeof e!="string"&&(e=kEa(e)),e.replace(/['\u2019]/g,"")}function GFt(e){return BUd(vQ_(e))}function km(e){if(e!=null)return Array.isArray(e)?e:[e]}function cGo({namespace:e,path:t,method:r,sdkMethodName:i,operationId:n,displayName:a,isWebhook:o}){if(t==null)return;let c=r!=null&&t!=null?`${r}_${t.split("/").join("_")}`:r??t.split("/").join("_");if(!(i==null&&n==null&&a==null&&c==null))return`${iQM(o)}${nQM(e)}.${aQM(i,n,a,c)}`}function iQM(e){return e?"webhook_":"endpoint_"}function nQM(e){return e!=null?km(e)?.map(t=>GFt(t)).join("/"):""}function aQM(e,t,r,i){return e||t||GFt(r??"")||GFt(i??"")}function gQ_(e){return e.length===0?!1:/^\$?(\.[\w*]+|\[['"][\w*]+['"]?\]|\[['"]?[\d*]+['"]?\]|\[[\d:]+\])*$/.test(e)}var lGo=class extends $a{accessTokenLocator;constructor(t){super(t),this.safeParse()}parse(){this.accessTokenLocator=this.input[HF_],this.accessTokenLocator!=null&&(gQ_(this.accessTokenLocator)||(this.context.errors.error({message:"Invalid access token locator, must be a valid jq path",path:this.accessPath}),this.accessTokenLocator=void 0))}convert(){return this.accessTokenLocator}};var fGo=class extends $a{authorizationUrl;headerAuthNode;accessTokenLocatorNode;constructor(t){super(t),this.safeParse()}parse(){if(this.input.flows.clientCredentials!=null){let t=this.input.flows.clientCredentials;this.authorizationUrl=t.tokenUrl,this.authorizationUrl==null&&this.context.errors.error({message:"Expected 'tokenUrl' property to be specified",path:this.accessPath}),this.headerAuthNode=new VLn({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.accessTokenLocatorNode=new lGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.authorizationUrl==null&&this.context.errors.error({message:"Expected 'tokenUrl' property to be specified",path:this.accessPath}),this.accessTokenLocatorNode?.accessTokenLocator==null&&this.context.errors.error({message:"Expected 'x-fern-access-token-locator' property to be specified",path:this.accessPath})}}convert(){let t=this.accessTokenLocatorNode?.convert();if(t==null||this.authorizationUrl==null)return{type:"bearerAuth",tokenName:void 0};let r=cGo({namespace:void 0,path:this.authorizationUrl,method:"POST",sdkMethodName:void 0,operationId:void 0,displayName:void 0,isWebhook:void 0});if(r!=null)return{type:"oAuth",value:{type:"clientCredentials",value:{type:"referencedEndpoint",endpointId:Qs.EndpointId(r),accessTokenLocator:Qs.JqString(t),headerName:this.headerAuthNode?.convert()?.headerWireValue,tokenPrefix:this.headerAuthNode?.convert()?.prefix}}}}};var xLn=class extends $a{authScheme;headerAuthNode;bearerTokenNode;bearerTokenVariableNameNode;basicAuthNode;basicUsernameVariableNameNode;basicPasswordVariableNameNode;oauth2Node;constructor(t){super(t),this.safeParse()}parse(){switch(this.input.type){case"http":switch(this.input.scheme){case"basic":{this.authScheme="basic",this.basicAuthNode=new X9o({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicUsernameVariableNameNode=new k9o({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicPasswordVariableNameNode=new Z9o({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),(this.basicAuthNode==null||this.basicAuthNode.username==null&&this.basicUsernameVariableNameNode?.usernameVariableName==null||this.basicAuthNode.password==null&&this.basicPasswordVariableNameNode?.passwordVariableName==null)&&this.context.errors.warning({message:"Basic auth should specify either a username or a username variable name",path:this.accessPath});break}case"bearer":{this.authScheme="bearer",this.bearerTokenNode=new eGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.bearerTokenVariableNameNode=new tGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});break}default:{this.context.errors.warning({message:`Unsupported HTTP auth scheme: ${this.input.scheme}`,path:this.accessPath});break}}break;case"apiKey":{rQ_(this.input)?(this.authScheme="header",this.headerAuthNode=new VLn({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})):this.context.errors.error({message:`Unsupported API key location: ${this.input.in}`,path:this.accessPath});break}case"oauth2":{this.authScheme="oauth",this.oauth2Node=new fGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});break}case"openIdConnect":{this.authScheme="bearer";break}}}convert(){switch(this.authScheme){case"basic":{let t=this.basicAuthNode?.convert();return{type:"basicAuth",usernameName:t?.username?.name??this.basicUsernameVariableNameNode?.convert(),passwordName:t?.password?.name??this.basicPasswordVariableNameNode?.convert()}}case"bearer":return{type:"bearerAuth",tokenName:this.bearerTokenNode?.convert()?.tokenVariableName??this.bearerTokenVariableNameNode?.convert()};case"header":return this.headerAuthNode?.convert();case"oauth":return this.oauth2Node?.convert();case void 0:return;default:new OQ_.UnreachableCaseError(this.authScheme);return}}};var GLn=class extends $a{authNodesMap;constructor(t){super(t),this.safeParse()}parse(){this.input.map((t,r)=>Object.keys(t).map(i=>{let n=Y9o(i,this.context.document);if(n==null){this.context.errors.warning({message:`No auth scheme found for ${i}. Inline security schemes are not supported.`,path:this.accessPath});return}let a=new xLn({input:n,context:this.context,accessPath:this.accessPath,pathId:["security",`${r}`]});a.convert()!=null?(this.authNodesMap??={},this.authNodesMap[i]=a):this.context.errors.warning({message:`No auth scheme found for ${i}`,path:this.accessPath})}))}convert(){return Object.fromEntries(Object.entries(this.authNodesMap??{}).map(([t,r])=>{let i=r.convert();if(i!=null)return[t,i]}).filter(mo))}};var dGo=class extends $a{basePath;constructor(t){super(t),this.safeParse()}parse(){this.basePath=this.input[LF_],this.basePath!=null?(this.basePath.startsWith("/")&&(this.basePath=this.basePath.slice(1)),this.basePath.endsWith("/")&&(this.basePath=this.basePath.slice(0,-1))):this.basePath=void 0}convert(){return this.basePath}};function AQ_(e){return"required"in e&&typeof e.required=="boolean"?e.required:!1}function mQ_(e,t){return{type:"alias",value:{type:"optional",shape:e,default:t}}}function HLn(e,t){return e==null?void 0:Object.entries(e).map(([i,n])=>km(n.convert())?.map(o=>((t!=null&&!t.includes(i)||t==null&&!AQ_(n))&&(o=mQ_(o,o.type==="enum"?o.default:void 0)),{key:Qs.PropertyKey(i),valueShape:o,description:n.description,availability:n.availability?.convert()})).filter(mo)).filter(mo).reduce((i,n)=>i.flatMap(a=>n.length>0?n.map(o=>[...a,o]):[[...a]]),[[]])}function pGo(e,t){return sv(e)?uU(e,t,void 0):e}function y1i(e,t){return e!=null&&e!==""?e:t!=null&&t!==""?t:void 0}function PQ_(e,t){let r={...e};for(let[i,n]of Object.entries(t??{}))r[i]=[...r[i]??[],...n];return Object.keys(r).length>0?r:void 0}function jQ_(e,t){if(e==null)return t;if(t==null)return e;let r=[];for(let i of e)for(let n of t)r.push({path:i.path??n.path,responseStatusCode:i.responseStatusCode??n.responseStatusCode,name:i.name??n.name,description:i.description??n.description,pathParameters:i.pathParameters??n.pathParameters,queryParameters:i.queryParameters??n.queryParameters,headers:i.headers??n.headers,requestBody:i.requestBody??n.requestBody,responseBody:i.responseBody??n.responseBody,snippets:{...n.snippets,...i.snippets}});return r}var wQ_=se(zE());var Vgc=["decimal","decimal128","double-int","double","float","sf-decimal"],Wgc=["int16","int32","int64","int8","sf-integer","uint8"],xgc=["base64url","binary","byte","char","commonmark","date-time","date","decimal","decimal128","duration","email","hostname","html","http-date","idn-email","idn-hostname","int64","ipv4","ipv6","iri-reference","iri","json-pointer","media-range","password","regex","relative-json-pointer","sf-binary","sf-boolean","sf-string","sf-token","time","uri-reference","uri-template","uri","uuid"],Ggc=["beta","pre-release","in-development","generally-available","deprecated"];function VB(e,t){return sv(e)?uU(e,t,{type:"unknown","x-fern-type":"unknown",additionalProperties:!1}):e}var wPe=class extends $a{availability;constructor(t){super(t),this.safeParse()}parse(){if(VB(this.input,this.context.document)?.deprecated)this.availability="deprecated";else{let r=this.input[VF_];r!=null&&(Ggc.includes(r)?this.availability=r:(this.context.errors.warning({message:`Expected one of: ${Ggc.join(", ")}. Received: ${r}`,path:this.accessPath}),this.availability=void 0))}}convert(){switch(this.availability){case"beta":case"pre-release":return Qs.Availability.Beta;case"in-development":return Qs.Availability.InDevelopment;case"generally-available":return Qs.Availability.GenerallyAvailable;case"deprecated":return Qs.Availability.Deprecated;case void 0:return;default:new wQ_.UnreachableCaseError(this.availability);return}}};var hGo=se(zE());function EQ_(e){return typeof e=="object"&&e!=null&&"language"in e}function SQ_(e){return typeof e=="object"&&e!=null&&"sdk"in e}function MQ_(e){return typeof e=="object"&&e!=null&&("error"in e||"body"in e)}function DQ_(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)}function _Go(e){return typeof e=="object"&&e!=null&&"event"in e}function Hgc(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)&&e.stream.every(_Go)}function b1i(e){return typeof e=="object"&&e!=null&&"filename"in e&&"data"in e&&typeof e.filename=="string"&&typeof e.data=="string"}function BQ_(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}var yGo=class extends $a{path;successResponseStatusCode;requestBodyByContentType;responseBodies;examples;constructor(t,r,i,n,a){super(t),this.path=r,this.successResponseStatusCode=i,this.requestBodyByContentType=n,this.responseBodies=a,this.safeParse()}parse(){this.examples=this.input[tQ_]}convertFormDataExampleRequest(t,r){if(t.fields!=null)switch(t.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(t.fields).map(([n,a])=>{let o=typeof r=="object"?r[n]:void 0;switch(a.multipartType){case"file":return b1i(o)?[n,{type:"filenameWithData",filename:o.filename,data:Qs.FileId(o.data)}]:o!=null?[n,{type:"filename",value:o}]:void 0;case"files":{if(Array.isArray(o)){if(o.every(c=>b1i(c)))return[n,{type:"filenamesWithData",value:o.map(c=>({filename:c.filename,data:Qs.FileId(c.data)}))}];if(o.every(c=>typeof c=="string"))return[n,{type:"filenames",value:o}]}return}case"property":return[n,{type:"json",value:o}];case void 0:return;default:new hGo.UnreachableCaseError(a.multipartType);return}}).filter(mo))};case"json":return{type:"json",value:r};case"bytes":return typeof r=="string"?{type:"bytes",value:{type:"base64",value:r}}:void 0;default:return}}convert(){if(this.examples==null)return;this.requestBodyByContentType!=null&&Object.keys(this.requestBodyByContentType).length>1&&this.context.logger.warn(`Multiple request bodies found for #/${[this.accessPath,this.pathId,"x-fern-examples"].join("/")}. Coercing to first request body until supported.`);let t=Object.keys(this.requestBodyByContentType??{})[0];return this.examples.flatMap(r=>(this.responseBodies??[]).map(i=>{let n=t!=null?this.requestBodyByContentType?.[t]:void 0,a;if(n!=null)switch(n.contentType){case"form-data":a=BQ_(r.request)?this.convertFormDataExampleRequest(n,r.request):void 0;break;case"json":a=r.request!=null?{type:"json",value:r.request}:void 0;break;case"bytes":a=typeof r.request=="string"&&r.request!=null?{type:"bytes",value:{type:"base64",value:r.request}}:void 0;break;case void 0:break;default:new hGo.UnreachableCaseError(n.contentType);break}let o;switch(i.contentType){case"application/json":{MQ_(r.response)&&(o={type:"json",value:r.response.body});break}case"text/event-stream":{Hgc(r.response)&&(o={type:"sse",value:r.response.stream.map(l=>({event:l.event,data:l.data}))});break}case"application/octet-stream":!Hgc(r.response)&&DQ_(r.response)&&(o={type:"stream",value:r.response.stream});break;case void 0:break;default:new hGo.UnreachableCaseError(i.contentType);break}let c={};r["code-samples"]?.forEach(l=>{EQ_(l)?l.language!=null&&(c[l.language]??=[],c[l.language]?.push({name:l.name,language:l.language,install:l.install,code:l.code,generated:!1,description:l.docs})):SQ_(l)&&l.sdk!=null&&(c[l.sdk]??=[],c[l.sdk]?.push({name:l.name,language:l.sdk,install:void 0,code:l.code,generated:!1,description:l.docs}))});let f=Object.fromEntries(Object.entries(r["path-parameters"]??{}).map(([l,p])=>[Qs.PropertyKey(l),p])),s=Object.fromEntries(Object.entries(r["query-parameters"]??{}).map(([l,p])=>[Qs.PropertyKey(l),p])),u=Object.fromEntries(Object.entries(r.headers??{}).map(([l,p])=>[Qs.PropertyKey(l),p]));return{path:this.path,responseStatusCode:this.successResponseStatusCode,name:r.name,description:r.docs,pathParameters:Object.keys(f).length>0?f:void 0,queryParameters:Object.keys(s).length>0?s:void 0,headers:Object.keys(u).length>0?u:void 0,requestBody:a,responseBody:o,snippets:c}}))}};var tSa=class extends $a{groupName;constructor(t){super(t),this.safeParse()}parse(){this.groupName=this.input[K9o]}convert(){if(this.groupName==null)return;let t;return Array.isArray(this.groupName)?t=this.groupName:t=[this.groupName],t.map(r=>Qs.api.v1.SubpackageId(GFt(r)))}};var bGo=class extends $a{sdkMethodName;constructor(t){super(t),this.safeParse()}parse(){this.sdkMethodName=this.input[xF_]}convert(){return this.sdkMethodName}};var vGo=class extends $a{isWebhook;constructor(t){super(t),this.safeParse()}parse(){this.isWebhook=this.input[GF_]}convert(){return this.isWebhook}};var gGo=class extends $a{codeSamples;constructor(t){super(t),this.safeParse()}parse(){this.codeSamples=[...this.input[nQ_]??[],...this.input[aQ_]??[]],this.codeSamples.forEach(t=>{[...Object.values(Qs.api.v1.read.SupportedLanguage),"Kotlin","Swift","PHP"].map(r=>r.toLowerCase()).includes(t.lang.toLowerCase())||this.context.errors.warning({message:`Unsupported language: ${t.lang}. This may not render correctly.`,path:this.accessPath})})}convert(){let t={};if(this.codeSamples?.forEach(r=>{t[r.lang.toLowerCase()]??=[],t[r.lang.toLowerCase()]?.push({name:r.label,language:r.lang,code:r.source,install:void 0,generated:!1,description:void 0})}),Object.keys(t).length!==0)return t}};var x$i=se(zE());function Kgc(e,t){return sv(e)?uU(e,t,void 0):e}function IQ_(e,t){return e.replace(/{(\w+)}/g,(r,i)=>t[i]!=null&&typeof t[i]=="string"||typeof t[i]=="number"||typeof t[i]=="boolean"?`${t[i]}`:r)}var Mz="",Z9t=class extends $a{path;responseStatusCode;name;shapes;resolvedRequestInput;resolvedResponseInput;summary;constructor(t,r,i,n,a){super(t),this.path=r,this.responseStatusCode=i,this.name=n,this.shapes=a,this.safeParse()}validateFormDataRequestExample(){return typeof this.resolvedRequestInput?.value!="object"?!1:Object.entries(this.shapes.requestBody?.fields??{}).reduce((t,[r,i])=>{let n=this.resolvedRequestInput?.value[r];switch(i.multipartType){case"file":return t&&(b1i(n)||typeof n=="string");case"files":return t&&Array.isArray(n)&&n.every(a=>b1i(a)||typeof a=="string");case"property":return t;case void 0:return t&&!1;default:return new x$i.UnreachableCaseError(i.multipartType),t}},!0)}parse(){let t=this.shapes.requestBody?.schema?.example({includeOptionals:!1,override:void 0});this.resolvedRequestInput=Kgc(this.input?.requestExample,this.context.document)??(t!=null?{value:t}:void 0);let r=this.shapes.responseBody?.schema?.example({includeOptionals:!1,override:void 0});if(this.resolvedResponseInput=Kgc(this.input?.responseExample,this.context.document)??(r!=null?{value:r}:void 0),this.summary=this.input?.requestExample?.summary??this.input?.responseExample?.summary,this.shapes.requestBody!=null&&this.resolvedRequestInput!=null)switch(this.shapes.requestBody?.contentType){case"json":{if(typeof this.resolvedRequestInput.value!="object"){this.context.errors.error({message:"Invalid example, expected object for json",path:this.accessPath});return}break}case"bytes":{if(typeof this.resolvedRequestInput.value!="string"){this.context.errors.error({message:"Invalid example, expected string for bytes",path:this.accessPath});return}break}case"form-data":{if(!this.validateFormDataRequestExample()){this.context.errors.error({message:"Invalid example, expected valid form-data",path:this.accessPath});return}break}case void 0:break;default:new x$i.UnreachableCaseError(this.shapes.requestBody?.contentType),this.context.errors.error({message:"Invalid example, unsupported content type",path:this.accessPath});return}if(this.shapes.responseBody!=null&&this.resolvedResponseInput!=null)switch(this.shapes.responseBody?.contentType){case"application/json":if(this.resolvedResponseInput!=null&&typeof this.resolvedResponseInput!="object"||this.resolvedResponseInput.value!=null&&typeof this.resolvedResponseInput.value!="object"){this.context.errors.error({message:"Invalid example, expected object for json",path:this.accessPath});return}break;case"text/event-stream":if(this.resolvedResponseInput.value!=null&&!Array.isArray(this.resolvedResponseInput.value)&&!this.resolvedResponseInput.value.every(_Go)){this.context.errors.error({message:"Invalid example, expected array of SSE events for event-stream",path:this.accessPath});return}break;case"application/octet-stream":if(this.resolvedResponseInput.value!=null&&typeof this.resolvedResponseInput.value!="string"&&!Array.isArray(this.resolvedResponseInput.value)){this.context.errors.error({message:"Invalid example, expected string or array for octet-stream",path:this.accessPath});return}break;case void 0:break;default:new x$i.UnreachableCaseError(this.shapes.responseBody?.contentType);return}}convertFormDataExampleRequest(){if(!(this.resolvedRequestInput==null||this.shapes.requestBody?.fields==null))switch(this.shapes.requestBody?.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(this.shapes.requestBody.fields).map(([r,i])=>{let n=this.resolvedRequestInput?.value?.[r];switch(i.multipartType){case"file":return b1i(n)?[r,{type:"filenameWithData",filename:n.filename,data:Qs.FileId(n.data)}]:[r,{type:"filename",value:n}];case"files":{if(Array.isArray(n)){if(n.every(a=>b1i(a)))return[r,{type:"filenamesWithData",value:n.map(a=>({filename:a.filename,data:Qs.FileId(a.data)}))}];if(n.every(a=>typeof a=="string"))return[r,{type:"filenames",value:n}]}return}case"property":return[r,{type:"json",value:n}];case void 0:return;default:new x$i.UnreachableCaseError(i.multipartType);return}}).filter(mo))};case"json":return{type:"json",value:this.resolvedRequestInput.value};case"bytes":return typeof this.resolvedRequestInput.value=="string"?{type:"bytes",value:{type:"base64",value:this.resolvedRequestInput.value}}:void 0;default:return}}convertDescription(){if(this.resolvedRequestInput!=null&&this.resolvedResponseInput!=null)return this.resolvedResponseInput.description;if(this.resolvedRequestInput!=null)return this.resolvedRequestInput.description;if(this.resolvedResponseInput!=null)return this.resolvedResponseInput.description}convert(){let t;if(this.shapes.requestBody!=null&&this.resolvedRequestInput!=null)switch(this.shapes.requestBody.contentType){case"form-data":t=this.convertFormDataExampleRequest();break;case"json":t={type:"json",value:this.resolvedRequestInput.value};break;case"bytes":t={type:"bytes",value:{type:"base64",value:this.resolvedRequestInput.value}};break;case void 0:break;default:new x$i.UnreachableCaseError(this.shapes.requestBody?.contentType);break}let r;if(this.shapes.responseBody!=null&&this.resolvedResponseInput!=null)switch(this.shapes.responseBody.contentType){case"application/json":{r={type:"json",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break}case"text/event-stream":r={type:"sse",value:this.resolvedResponseInput?.value};break;case"application/octet-stream":r={type:typeof this.resolvedResponseInput?.value=="string"?"filename":"stream",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break;case void 0:r={type:"json",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break;default:new x$i.UnreachableCaseError(this.shapes.responseBody?.contentType);break}let i=Object.fromEntries(Object.entries(this.shapes.pathParameters??{}).map(([o,c])=>[o,c.example({includeOptionals:!1,override:o})]));i=Object.keys(i).length>0?i:void 0;let n=Object.fromEntries(Object.entries(this.shapes.queryParameters??{}).map(([o,c])=>c.required||c.inputExample!=null?[o,c.example({includeOptionals:!1,override:o})]:void 0).filter(mo));n=Object.keys(n).length>0?n:void 0;let a=Object.fromEntries(Object.entries(this.shapes.requestHeaders??{}).map(([o,c])=>c.required||c.inputExample!=null?[o,c.example({includeOptionals:!1,override:o})]:void 0).filter(mo));if(a=Object.keys(a).length>0?a:void 0,!(this.path==null&&t==null&&r==null&&a==null&&n==null&&i==null))return{path:IQ_(this.path,i??{}),responseStatusCode:this.responseStatusCode,name:this.name!=null?X9t(this.name):this.summary!=null?X9t(this.summary):void 0,description:this.convertDescription(),pathParameters:i,queryParameters:n,headers:a,requestBody:t,responseBody:r,snippets:void 0}}};function CQ_(e,t){return sv(e)?uU(e,t,void 0):e}var GQ_=se(zE());var qQ_="#/components/schemas/";function KLn(e){if(e.$ref.startsWith(qQ_))return e.$ref.replace(qQ_,"")}function Vgi(e){if(e!=null)return{type:"alias",value:{type:"nullable",shape:e}}}function v1i(e){return typeof e.type=="string"&&e.type==="array"}function TQ_(e){return e.type==="boolean"}function RQ_(e){return e.type==="integer"}function g1i(e){return!Array.isArray(e.type)&&!v1i(e)}function zQ_(e){return e!=null&&Array.isArray(e)&&e.every(t=>t.type==="null"||g1i(t)||v1i(t))}function NQ_(e){return"nullable"in e&&typeof e.nullable=="boolean"}function FQ_(e){return e.type==="null"}function QQ_(e){return e.type==="number"}function Jgc(e){return e.type==null||typeof e.type=="string"&&e.type==="object"}function UQ_(e){return e.type==="string"}var OGo=class extends gK{item;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.item=new YP({input:this.input.items,context:this.context,accessPath:this.accessPath,pathId:"items",seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}),this.input.items==null&&this.context.errors.error({message:"Expected 'items' property to be specified",path:this.accessPath})}convert(){return km(this.item?.convert())?.map(r=>({type:"alias",value:{type:"list",itemShape:r}}))}example(t){return this.input.example??this.input.examples?.[0]??[this.item?.example(t)]}};var AGo=class extends LB{constValue;description;availability;constructor(t){super(t),this.safeParse()}parse(){this.input.const!=null&&(typeof this.input.const=="string"||typeof this.input.const=="number"||typeof this.input.const=="boolean")?this.constValue=this.input.const.toString():this.context.errors.warning({message:`Unsupported const type: ${typeof this.input}`,path:this.accessPath}),this.description=this.input.description,this.availability=new wPe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"})}convert(){if(this.constValue!=null)return{type:"enum",default:this.constValue,values:[{value:this.constValue,description:this.description,availability:this.availability?.convert()}]}}example(){return this.input.example??this.input.examples?.[0]??this.constValue}};var mGo=class extends gK{typeNodes;nullable;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.parse()}parse(){this.typeNodes=this.input.map(t=>{if(t.type==="null")this.nullable=!0;else return new YP({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName})}).filter(mo)}convert(){if(this.typeNodes==null)return;let i=this.typeNodes.map(n=>km(n.convert())?.map(o=>({displayName:n.name,shape:o,description:n.description,availability:n.availability?.convert()}))).filter(mo).reduce((n,a)=>n.flatMap(o=>a.length>0?a.map(c=>[...o,c]):[[...o]]),[[]]).map(n=>({type:"undiscriminatedUnion",variants:n}));return this.nullable?i.map(Vgi).filter(mo):i}example(t){return this.nullable?null:this.typeNodes?.[0]?.example(t)}};function PGo(e){return e!=null&&e.length>0?e:[void 0]}var JLn=class extends gK{description;extends=[];properties;extraProperties;requiredProperties;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.extends=[],this.requiredProperties=this.input.required,this.properties=Object.fromEntries(Object.entries(this.input.properties??{}).map(([t,r])=>[t,new YP({input:r,context:this.context,accessPath:this.accessPath,pathId:["properties",t],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})])),this.extraProperties=this.input.additionalProperties!=null?typeof this.input.additionalProperties=="boolean"?this.input.additionalProperties?this.input.title:void 0:new YP({input:this.input.additionalProperties,context:this.context,accessPath:this.accessPath,pathId:["additionalProperties"],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0,this.input.allOf!=null&&(this.extends=this.extends.concat(this.input.allOf.map((t,r)=>{if(sv(t))return KLn(t);this.properties={...this.properties,...Object.fromEntries(Object.entries(t.properties??{}).map(([i,n])=>[i,new YP({input:n,context:this.context,accessPath:this.accessPath,pathId:["allOf",r.toString(),"properties",i],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))}}).filter(mo))),this.description=this.input.description}convertProperties(){if(this.properties!=null)return HLn(this.properties,this.requiredProperties)}convertExtraProperties(){return this.extraProperties==null?void 0:typeof this.extraProperties=="string"?[{type:"map",keyShape:{type:"alias",value:{type:"primitive",value:{type:"string",format:void 0,regex:void 0,minLength:void 0,maxLength:void 0,default:void 0}}},valueShape:{type:"alias",value:{type:"unknown",displayName:this.extraProperties}}}]:km(this.extraProperties.convert())?.map(r=>({type:"map",keyShape:{type:"alias",value:{type:"primitive",value:{type:"string",format:void 0,regex:void 0,minLength:void 0,maxLength:void 0,default:void 0}}},valueShape:r})).filter(mo)}convert(){let t=this.convertProperties();if(t==null)return;let r=this.convertExtraProperties();return t.flatMap(i=>PGo(r).map(n=>(this.extends==null||this.extends.length===0)&&i.length===0&&n!=null?{type:"alias",value:n}:{type:"object",extends:this.extends.map(a=>Qs.TypeId(a)),properties:i,extraProperties:n}))}example({includeOptionals:t}){let r={...this.properties};return this.input.allOf?.forEach(i=>{let n=VB(i,this.context.document);n!=null&&(r={...r,...Object.fromEntries(Object.entries(n.properties??{}).map(([a,o])=>[a,new YP({input:o,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))})}),this.input.example??this.input.examples?.[0]??(!t&&this.requiredProperties!=null&&this.requiredProperties.length>0?this.requiredProperties?.reduce((i,n)=>{let a=r?.[n];return i[n]=a?.example({includeOptionals:t,override:n}),i},{}):Object.entries(r).reduce((i,[n,a])=>(i[n]=a?.example({includeOptionals:t,override:n}),i),{}))}};var jGo=class extends gK{isNullable;discriminated;discriminant;discriminatedMapping;undiscriminatedMapping;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){if(this.input.oneOf!=null||this.input.anyOf!=null)if(this.isNullable=(this.input.oneOf??this.input.anyOf)?.some(t=>VB(t,this.context.document)?.type==="null"),this.input.discriminator==null)this.discriminated=!1,this.undiscriminatedMapping=(this.input.oneOf??this.input.anyOf)?.map(t=>VB(t,this.context.document)?.type!=="null"?new YP({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0).filter(mo);else{let t=this.input.discriminator.mapping;if(t!=null){this.discriminated=!0,this.discriminant=this.input.discriminator.propertyName,this.discriminatedMapping={};let r=this.discriminatedMapping;Object.entries(t).map(([i,n])=>{let a=VB({$ref:n},this.context.document);if(a==null){this.context.errors.warning({message:`Expected schema reference. Received undefined reference: ${n}`,path:[...this.accessPath,"discriminator","mapping",i]});return}r[i]=new YP({input:a,context:this.context,accessPath:[...this.accessPath,"discriminator","mapping",i],pathId:i,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})})}}}convert(){if(!this.discriminated&&this.undiscriminatedMapping?.length===1){let n=this.undiscriminatedMapping?.flatMap(a=>a.convert()).filter(mo);return this.isNullable&&n!=null?n.map(Vgi).filter(mo):n}let t=0,r=this.discriminated&&this.discriminant!=null&&this.discriminatedMapping!=null?{type:"discriminatedUnion",discriminant:Qs.PropertyKey(this.discriminant),variants:Object.entries(this.discriminatedMapping).flatMap(([n,a])=>km(a.convert())?.map(c=>{if(!(c==null||c.type!=="object"))return{discriminantValue:n,displayName:a.name??X9t(n),availability:a.availability?.convert(),description:a.description,...c}}).filter(mo)).filter(mo)}:this.undiscriminatedMapping!=null?{type:"undiscriminatedUnion",variants:this.undiscriminatedMapping.flatMap(n=>km(n.convert())?.map(o=>{if(o==null)return;t+=1;let c=o.type==="object"?X9t(`${this.schemaName??"Variant"} ${t}`):void 0;return{displayName:n.name??(o.type==="alias"&&o.value.type==="id"?X9t(o.value.id):c),shape:o,description:n.description,availability:n.availability?.convert()}}).filter(mo)).filter(mo)}:void 0,i=this.isNullable?Vgi(r):r;return i!=null?[i]:void 0}example(t){return this.input.example??this.input.examples?.[0]??this.undiscriminatedMapping?.[0]?.example(t)??Object.values(this.discriminatedMapping??{})[0]?.example(t)}};var wGo=class extends LB{default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.input.default!=null&&typeof this.input.default!="boolean"&&this.context.errors.warning({message:`Expected default value to be a boolean. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default}convert(){return{type:"alias",value:{type:"primitive",value:{type:"boolean",default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:!1)}};var O1i=class extends LB{default;values=[];nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){if(this.input.enum!=null){let t=!0;this.values=this.input.enum.map((r,i)=>{if(t){if(sv(r)){let n=VB(r,this.context.document);r=typeof n=="string"?n:typeof n?.default=="string"?n?.default:typeof n?.example=="string"?n.example:void 0}if(typeof r!="string"){this.context.errors.error({message:`Expected enum values to be strings. Received ${r}`,path:[...this.accessPath,`enum[${i}]`]}),t=!1;return}return r}}).filter(mo),this.values=Array.from(new Set(this.values))}this.default=this.input.default}convert(){return{type:"enum",values:this.values.map(t=>({value:t,description:void 0,availability:void 0})),default:this.default}}example(){return this.input.example??this.input.examples?.[0]??this.default??this.values[0]??(this.nullable?null:void 0)}};var LQ_=se(zE());function oQM(e){return Wgc.includes(e)}var EGo=class extends LB{format;minimum;maximum;default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.minimum=this.input.minimum,this.maximum=this.input.maximum,this.input.default!=null&&typeof this.input.default!="number"&&this.context.errors.warning({message:`Expected default value to be an integer. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(oQM(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${Wgc.join(", ")}. Received ${this.input.format}`,path:this.accessPath}))}convert(){let t="integer";if(this.format!=null)switch(this.format){case"int64":t="long";break;case"int8":case"int16":case"int32":case"uint8":case"sf-integer":case void 0:t="integer";break;default:new LQ_.UnreachableCaseError(this.format);break}return{type:"alias",value:{type:"primitive",value:{type:t,minimum:this.minimum,maximum:this.maximum,default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:0)}};var SGo=class extends LB{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){this.displayName=this.input.title}convert(){return Vgi({type:"alias",value:{type:"unknown",displayName:this.displayName}})}example(){return null}};var VQ_=se(zE());function uQM(e){return Vgc.includes(e)}var MGo=class extends LB{format;minimum;maximum;default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.minimum=this.input.minimum,this.maximum=this.input.maximum,this.input.default!=null&&typeof this.input.default!="number"&&this.context.errors.warning({message:`Expected default value to be a number. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(uQM(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${Vgc.join(", ")}. Received ${this.input.format}`,path:this.accessPath}))}convert(){let t="double";if(this.format!=null)switch(this.format){case"decimal":case"decimal128":case"double-int":case"double":case"float":case"sf-decimal":case void 0:t="double";break;default:new VQ_.UnreachableCaseError(this.format);break}return{type:"alias",value:{type:"primitive",value:{type:t,minimum:this.minimum,maximum:this.maximum,default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:0)}};var WQ_=se(zE());function sQM(e){return xgc.includes(e)}var DGo=class extends LB{format;regex;default;minLength;maxLength;enum;mimeType;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}mapToFdrType(t){switch(t){case"base64url":case"binary":case"byte":case"sf-binary":return"base64";case"date-time":return"datetime";case"int64":return"bigInteger";case"date":return"date";case"uuid":return"uuid";case"char":case"commonmark":case"decimal":case"decimal128":case"duration":case"email":case"hostname":case"html":case"http-date":case"idn-email":case"idn-hostname":case"ipv4":case"ipv6":case"iri-reference":case"iri":case"json-pointer":case"media-range":case"password":case"regex":case"relative-json-pointer":case"sf-boolean":case"sf-string":case"sf-token":case"time":case"uri-reference":case"uri-template":case"uri":case void 0:return"string";default:return new WQ_.UnreachableCaseError(t),"string"}}parse(){this.regex=this.input.pattern,this.minLength=this.input.minLength,this.maxLength=this.input.maxLength,this.mimeType=this.input.contentMediaType,this.input.default!=null&&typeof this.input.default!="string"&&this.context.errors.warning({message:`Expected default value to be a string. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(sQM(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${xgc.join(", ")}. Received ${this.input.format}`,path:this.accessPath})),this.input.enum!=null&&(this.enum=new O1i({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"enum",nullable:this.nullable}))}convert(){if(this.enum!=null)return this.enum.convert();let t="string";return this.format!=null&&(t=this.mapToFdrType(this.format)),{type:"alias",value:{type:"primitive",value:t==="base64"?{type:t,mimeType:this.mimeType,default:this.default}:{type:t,format:t==="string"?this.format:void 0,regex:this.regex,minLength:this.minLength,maxLength:this.maxLength,default:this.default}}}}example({override:t}){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:t??"string")}};var xQ_=se(zE());var BGo=class extends LB{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){(0,xQ_.noop)()}convert(){return{type:"alias",value:{type:"unknown",displayName:void 0}}}example(){}};var G$i=class extends gK{description;availability;schemaId;maybeEnumConverterNode;nullable;schemaName;constructor(t){super(t),this.nullable=t.nullable,this.schemaName=t.schemaName,this.description=t.description,this.availability=t.availability,this.safeParse()}parse(){this.schemaId=KLn(this.input);let t=VB(this.input,this.context.document);t?.enum!=null&&g1i(t)&&(this.maybeEnumConverterNode=new O1i({input:t,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",nullable:this.nullable})),this.schemaId==null&&this.context.errors.error({message:`Unprocessable reference: ${this.input.$ref}`,path:this.accessPath})}convert(){if(this.schemaId!=null)return{type:"alias",value:{type:"id",id:Qs.TypeId(this.schemaId),default:this.maybeEnumConverterNode?.default!=null?{type:"enum",value:this.maybeEnumConverterNode.default}:void 0}}}example(t){let r=VB(this.input,this.context.document);if(r!=null)return new YP({input:r,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName}).example(t)}};var YP=class e extends gK{typeShapeNode;description;name;examples;availability;nullable;schemaName;constructor(t){super(t),this.nullable=t.nullable,this.schemaName=t.schemaName,this.safeParse()}parse(){if(this.description=this.input.description,this.availability=new wPe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),g1i(this.input)&&NQ_(this.input)&&(this.nullable=this.input.nullable!=null?this.input.nullable:this.nullable),sv(this.input)){let t=KLn(this.input);if(t==null){this.context.errors.error({message:"Reference object does not have a valid schema ID",path:this.accessPath});return}if(this.seenSchemas.has(t)){this.context.errors.warning({message:"Circular or deeply nested schema found, terminating",path:this.accessPath});return}this.seenSchemas.add(t),this.typeShapeNode=new G$i({input:this.input,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName,description:this.description,availability:this.availability})}else if(this.name=this.input.title,this.examples=this.input.example,this.input.const!=null)this.typeShapeNode=new AGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});else if(zQ_(this.input))this.typeShapeNode=new mGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(g1i(this.input)&&(this.input.oneOf!=null||this.input.anyOf!=null))this.typeShapeNode=new jGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(Jgc(this.input)&&this.input.allOf!=null)this.typeShapeNode=new JLn({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(g1i(this.input)&&this.input.enum!=null)this.typeShapeNode=new O1i({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable});else if(typeof this.input.type=="string"||Array.isArray(this.input.type)&&this.input.type.length===1){if(this.input.type=Array.isArray(this.input.type)?this.input.type[0]:this.input.type,!Array.isArray(this.input.type))switch(this.input.type){case"object":Jgc(this.input)&&(this.typeShapeNode=new JLn({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"array":v1i(this.input)&&(this.typeShapeNode=new OGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"boolean":TQ_(this.input)&&(this.typeShapeNode=new wGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"integer":RQ_(this.input)&&(this.typeShapeNode=new EGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"number":QQ_(this.input)&&(this.typeShapeNode=new MGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"string":UQ_(this.input)&&(this.typeShapeNode=new DGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"null":FQ_(this.input)&&(this.typeShapeNode=new SGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}));break;case void 0:break;default:new GQ_.UnreachableCaseError(this.input.type);break}}else if(Array.isArray(this.input.type)&&this.input.type.includes("null")&&this.input.type.length===2){let t=this.input.type.filter(r=>r!=="null")[0];t!=="array"&&(this.typeShapeNode=new e({input:{...this.input,type:t},context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:!0,schemaName:this.schemaName}))}else this.input.properties!=null&&(this.typeShapeNode=new JLn({input:{...this.input,type:"object"},context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));this.typeShapeNode==null&&(this.typeShapeNode=new BGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),!sv(this.input)&&(!v1i(this.input)&&this.input==null||v1i(this.input)&&this.input.items==null)&&this.context.errors.error({message:"Expected type declaration. Received: null",path:this.accessPath}))}convert(){let t=this.typeShapeNode?.convert();if(t==null)return;let r=km(t)?.map(i=>this.nullable?Vgi(i):i).filter(mo);return Array.isArray(t)&&t.length>1?r:r?.[0]}example(t){return this.availability?.availability!=="deprecated"?this.typeShapeNode?.example(t):void 0}};function A1i(e){if(e!=null)return HLn(e,Object.entries(e??{}).map(([t,r])=>r.required?t:void 0).filter(mo))}var k9t=class extends LB{availability;required;schema;description;inputExample;constructor(t){super(t),this.safeParse(t.parameterName)}parse(t){this.description=this.input.description;let r;sv(this.input)?r=this.input:this.input.schema!=null?(r=this.input.schema,this.required=this.input.required):(r={type:"string"},this.required=!1),this.availability=new wPe({input:r,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=new YP({input:r,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:t});let i=CQ_(this.input,this.context.document);this.inputExample=i?.example??Object.values(i?.examples??{})[0]}convert(){return this.schema?.convert()}example(t){return this.inputExample??this.schema?.example(t)}};function HQ_(e,t){return sv(e)?uU(e,t,void 0):e}var $gc=se(zE());function IGo(e){let{uniqueId:t,type:r,contextTypes:i,description:n,availability:a}=e;i[Qs.TypeId(t)]={name:t,shape:r,description:n,availability:a}}var KQ_=se(Xjs(),1),$Ln=class e{type;subtype;essence;parameters;mimeType;input;constructor(t,r,i,n,a,o){this.type=t,this.subtype=r,this.essence=i,this.parameters=n,this.mimeType=a,this.input=o}static APPLICATION_JSON="application/json";static APPLICATION_OCTET_STREAM="application/octet-stream";static MULTIPART_FORM_DATA="multipart/form-data";static parse(t){if(t==null)return null;let r=KQ_.default.parse(t);return r==null?null:new e(r.type,r.subtype,r.essence,r.parameters,r,t)}toString(){return this.input}isText(){return this.type==="text"}isImage(){return this.type==="image"}isAudio(){return this.type==="audio"}isVideo(){return this.type==="video"}isFont(){return this.type==="font"}isMultipart(){return this.type==="multipart"}isApplication(){return this.type==="application"}isMessage(){return this.type==="message"}isModel(){return this.type==="model"}isCSS(){return this.isText()&&this.subtype==="css"}isCSV(){return this.isText()&&this.subtype==="csv"}isMarkdown(){return this.isText()&&this.subtype==="markdown"}isPlainText(){return this.isText()&&this.subtype==="plain"}isEventStream(){return this.isText()&&this.subtype==="event-stream"}isMultiPartFormData(){return this.isMultipart()&&this.subtype==="form-data"}isJSON(){return this.isApplication()&&this.subtype==="json"}containsJSON(){return this.isApplication()&&this.subtype.includes("json")}isURLEncoded(){return this.isApplication()&&this.subtype==="x-www-form-urlencoded"}isOctetStream(){return this.isApplication()&&this.subtype==="octet-stream"}isPDF(){return this.isApplication()&&this.subtype==="pdf"}isZip(){return this.isApplication()&&this.subtype==="zip"}isGzip(){return this.isApplication()&&this.subtype==="gzip"}isTar(){return this.isApplication()&&this.subtype==="tar"}isBrotli(){return this.isApplication()&&this.subtype==="br"}isDeflate(){return this.isApplication()&&this.subtype==="deflate"}isProtobuf(){return this.isApplication()&&this.subtype==="protobuf"}isAvif(){return this.isImage()&&this.subtype==="avif"}isWebP(){return this.isImage()&&this.subtype==="webp"}isSVG(){return this.isImage()&&this.subtype==="svg+xml"}isPNG(){return this.isImage()&&this.subtype==="png"}isJPEG(){return this.isImage()&&this.subtype==="jpeg"}isGIF(){return this.isImage()&&this.subtype==="gif"}isMPEG(){return this.isAudio()&&this.subtype==="mpeg"}isWAV(){return this.isAudio()&&this.subtype==="wav"}isHTML(){return this.mimeType.isHTML()}isXML(){return this.mimeType.isXML()}isJavaScript(){return this.mimeType.isJavaScript()}};function cQM(e){return typeof e.securitySchemes=="object"&&e.securitySchemes!=null}var CGo=class extends $a{typeSchemas;securitySchemes;constructor(t){super(t),this.safeParse()}parse(){this.input.schemas!=null&&(this.typeSchemas=Object.fromEntries(Object.entries(this.input.schemas).map(([t,r])=>[t,new YP({input:r,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:new Set,nullable:void 0,schemaName:t})]))),cQM(this.input)&&this.input.securitySchemes!=null&&(this.securitySchemes=Object.fromEntries(Object.entries(this.input.securitySchemes??{}).map(([t,r],i)=>{let n;if(sv(r)?n=Y9o(r.$ref,this.context.document):n=r,n!=null)return[t,new xLn({input:n,context:this.context,accessPath:this.accessPath,pathId:["securitySchemes",`${i}`]})]}).filter(mo)))}convert(){return{auths:this.securitySchemes!=null?Object.fromEntries(Object.entries(this.securitySchemes??{}).map(([t,r])=>{let i=r.convert();if(i!=null)return[Qs.api.latest.AuthSchemeId(t),i]}).filter(mo)):void 0,types:this.typeSchemas!=null?Object.fromEntries(Object.entries(this.typeSchemas).map(([t,r])=>{let i=r.name??t,n=km(r.convert());return n==null?[t,void 0]:[Qs.TypeId(t),{name:i,shape:n[0],description:r.description,availability:void 0}]}).filter(([t,r])=>mo(r))):void 0}}};var qGo=class extends YP{multipartType;contentType;constructor(t){super(t),this.safeParse()}parse(){super.parse();let t=VB(this.input,this.context.document);if(t==null){this.context.errors.error({message:`Expected multipart form data property definition. ${sv(this.input)?`Received undefined reference: ${this.input.$ref}`:""}`,path:this.accessPath});return}if(t.type==="string"&&t.format==="binary")this.multipartType="file",this.contentType=t.contentMediaType;else if(t.type==="array"){let r=VB(t.items,this.context.document);r?.type==="string"&&r?.format==="binary"?(this.multipartType="files",this.contentType=r?.contentMediaType):(this.context.errors.warning({message:"Expected multipart form data files definition with array type with internal string type and binary format.",path:this.accessPath}),this.multipartType=void 0,this.contentType=void 0)}else this.multipartType="property",this.contentType=t.contentMediaType}};var TGo=class extends $a{description;method;path;schema;isOptional;contentType;availability;requiredFields;fields;examples;constructor(t){super(t),this.method=t.method,this.path=t.path,this.safeParse(t)}parse({contentType:t}){if(this.input.schema!=null){let i=VB(this.input.schema,this.context.document);this.availability=new wPe({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=sv(this.input.schema)?new G$i({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:!1,schemaName:"Request Body",description:this.input.schema.description,availability:this.availability}):void 0;let n=$Ln.parse(t);n?.containsJSON()?(this.contentType="json",this.schema=this.schema??new YP({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:"Request Body"})):n?.isOctetStream()?(this.contentType="bytes",this.isOptional=i?.required==null):n?.isMultiPartFormData()?(this.contentType="form-data",this.requiredFields=i?.required,this.fields=Object.fromEntries(Object.entries(i?.properties??{}).map(([a,o])=>{if(o!=null)return[a,new qGo({input:o,context:this.context,accessPath:this.accessPath,pathId:`schema.${a}`,seenSchemas:new Set,nullable:void 0,schemaName:a})]}).filter(mo))):this.context.errors.warning({message:`Expected request body of reference or object with json, streaming or form-data content types. Received: ${t}`,path:this.accessPath})}let r=this.schema?.example({includeOptionals:!0,override:void 0});this.examples={...this.input.example!=null?{[Mz]:{value:this.input.example}}:{},...this.input.examples},r!=null&&Object.keys(this.examples).length===0&&(this.examples={[Mz]:{value:r}})}convertJsonLike(){let t=this.schema?.convert();return t==null?void 0:km(t)?.map(i=>{let n=i.type;switch(n){case"object":case"alias":return i;case"enum":case"undiscriminatedUnion":case"discriminatedUnion":{let a=GFt([this.method,this.path,this.contentType,"request"].join("_"));return IGo({uniqueId:a,type:i,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:Qs.TypeId(a),default:i.type==="enum"&&i.default!=null?{type:"enum",value:i.default}:void 0}}}case void 0:return;default:new $gc.UnreachableCaseError(n);return}}).filter(mo)}convert(){if(this.schema instanceof G$i)return this.schema.convert();switch(this.contentType){case"json":return this.convertJsonLike();case"bytes":return{type:"bytes",isOptional:this.isOptional??!1,contentType:this.contentType};case"form-data":return Object.entries(this.fields??{}).map(([i,n])=>{switch(n.multipartType){case"file":return[{type:n.multipartType,key:Qs.PropertyKey(i),isOptional:this.requiredFields?.includes(i)==null,contentType:n.contentType,description:n.description,availability:n.availability?.convert()}];case"files":return[{type:n.multipartType,key:Qs.PropertyKey(i),isOptional:this.requiredFields?.includes(i)==null,contentType:n.contentType,description:n.description,availability:n.availability?.convert()}];case"property":{let a=km(n.convert()),o=n.multipartType;return a?.map(c=>({type:o,key:Qs.PropertyKey(i),contentType:n.contentType,exploded:void 0,valueShape:c,description:n.description,availability:n.availability?.convert()}))}case void 0:return[];default:return new $gc.UnreachableCaseError(n.multipartType),[]}}).filter(mo).reduce((i,n)=>i.flatMap(a=>n.length>0?n.map(o=>[...a,o]):[[...a]]),[[]]).map(i=>({type:"formData",fields:i,availability:this.availability?.convert(),description:this.description}));case void 0:return this.convertJsonLike();default:return}}};var RGo=class extends $a{description;requestBodiesByContentType;constructor(t){super(t),this.safeParse(t)}parse({method:t,path:r}){let i=HQ_(this.input,this.context.document);if(i==null){this.context.errors.error({message:"Expected request body. Received: null",path:this.accessPath});return}Object.entries(i.content).forEach(([n,a])=>{this.requestBodiesByContentType??={},this.requestBodiesByContentType[n]=new TGo({input:a,context:this.context,accessPath:this.accessPath,pathId:"content",contentType:n,method:t,path:r})})}convert(){return Object.entries(this.requestBodiesByContentType??{}).flatMap(([t,r])=>km(r.convert())?.map(n=>({description:this.description,contentType:t,body:n}))).filter(mo)}convertToWebhookPayload(){return Object.values(this.requestBodiesByContentType??{}).flatMap(t=>km(t.convert())?.map(i=>{if(!(i.type!=="alias"&&i.type!=="object"))return{description:this.description,shape:i}})).filter(mo)}webhookExample(){return{payload:this.requestBodiesByContentType?.["application/json"]?.schema?.example({includeOptionals:!0,override:void 0})}}};var JQ_={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"};function $Q_(e,t){if(sv(e)){let r=uU(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var zGo=se(zE());var YQ_="application/json";var XQ_="application/octet-stream";function ZQ_(e,t){return e===t||t===Mz||e===Mz}var rSa=class extends $a{streamingFormat;path;method;statusCode;requests;shapes;schema;contentType;unsupportedContentType;contentSubtype;examples;empty;constructor(t,r,i,n,a,o,c,f){super(t),this.streamingFormat=i,this.path=n,this.method=a,this.statusCode=o,this.requests=c,this.shapes=f,this.safeParse(r)}matchRequestResponseExamplesByName(t,r,i){for(let n of t)for(let[a,o]of Object.entries(n?.examples??{}))for(let[c,f]of Object.entries(r))for(let s of f)ZQ_(c,a)&&(i.add(c),this.examples?.push(new Z9t({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,y1i(a,c),{requestBody:n,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}matchExamplesByIndex(t,r){let i=0;for(let n of t){let a=0;for(let[o,c]of r){if(a===i){let[f,s,u]=n??[void 0,void 0,void 0];this.examples?.push(...c.map(l=>new Z9t({input:{requestExample:u,responseExample:l},context:this.context,accessPath:this.accessPath,pathId:s!=null&&s!==""?["examples",s]:"examples"},this.path,this.statusCode,y1i(s,o),{requestBody:f,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}a++}i++}if(t.length>r.length)for(let n of t.slice(r.length)){let[a,o]=r[r.length-1]??[void 0,void 0],[c,f,s]=n??[void 0,void 0,void 0];this.examples?.push(...(o??[void 0]).map(u=>new Z9t({input:{requestExample:s,responseExample:u},context:this.context,accessPath:this.accessPath,pathId:f!=null&&f!==""?["examples",f]:"examples"},this.path,this.statusCode,y1i(f,a),{requestBody:c,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}if(r.length>t.length){let[n,a,o]=t[t.length-1]??[void 0,void 0,void 0];for(let[c,f]of r.slice(t.length))this.examples?.push(...f.map(s=>new Z9t({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,y1i(a,c),{requestBody:n,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}}pushResponseExample(t,r,i,n){let a=t[Mz];if(a!=null)for(let o of a)this.examples?.push(new Z9t({input:{requestExample:n,responseExample:o},context:this.context,accessPath:this.accessPath,pathId:i!=null&&i!==""?["examples",i]:"examples"},this.path,this.statusCode,y1i(i,void 0),{requestBody:r,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders}))}addGlobalFallbackExample(t,r){if(t==null||t.length===0)this.pushResponseExample(r,void 0,void 0,void 0);else for(let i of t)if(Object.keys(i.examples??{}).length===0)this.pushResponseExample(r,i,void 0,void 0);else for(let[n,a]of Object.entries(i.examples??{}))this.pushResponseExample(r,i,n,a)}parse(t){if(t==="empty")this.empty=!0;else{let c=$Ln.parse(t);if(c?.isJSON()||c?.isEventStream())this.contentType=YQ_,this.input.schema==null?(this.streamingFormat==null||this.streamingFormat==="json")&&this.context.errors.error({message:"Expected schema for JSON response body. Received null",path:this.accessPath}):this.schema=new YP({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"type",seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"});else if(c?.isOctetStream())this.contentType=XQ_,this.contentSubtype=VB(this.input.schema,this.context.document)?.contentMediaType;else if(this.unsupportedContentType=t,this.input.schema==null){this.context.errors.error({message:"Expected schema for plain text response body. Received null",path:this.accessPath});return}else this.schema=new YP({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"})}let r={};this.input.examples!=null&&(r=sGo(this.input.examples,c=>[c])),this.input.example!=null&&Object.keys(r).length===0&&(r[Mz]??=[],r[Mz]=[{value:this.input.example}]);let i=VB(this.input.schema,this.context.document);if(i!=null&&(i.examples!=null&&Object.keys(r).length===0&&(r=sGo(i.examples,c=>[c])),i.example!=null&&Object.keys(r).length===0&&(r[Mz]??=[],r[Mz]?.push({value:i.example}))),Object.keys(r).length===0){let c=this.schema?.example({includeOptionals:!0,override:void 0});r[Mz]??=[],r[Mz]?.push(c!=null?{value:c}:void 0)}this.examples??=[];let n=new Set;this.matchRequestResponseExamplesByName(this.requests,r,n);let a=[];for(let c of this.requests)a.push(...Object.entries(c.examples??{}).filter(([f])=>!n.has(f)&&f!==Mz).map(([f,s])=>[c,f,s]));let o=Object.entries(r).filter(([c,f])=>!n.has(c)&&mo(f)&&c!==Mz);Object.keys(r).every(c=>c===Mz)||this.matchExamplesByIndex(a,o),!n.has(Mz)&&this.examples.length===0&&this.addGlobalFallbackExample(this.requests,r),this.examples.length===0&&(this.examples=void 0)}convertStreamingFormat(){switch(this.streamingFormat){case"json":return km(this.schema?.convert())?.map(r=>({type:"stream",terminator:"[DATA]",shape:r}));case"sse":return{type:"streamingText"};case void 0:return;default:new zGo.UnreachableCaseError(this.streamingFormat);return}}convertJsonLike(){return km(this.schema?.convert())?.map(r=>{let i=r.type;switch(i){case"alias":return r;case"discriminatedUnion":case"undiscriminatedUnion":case"enum":{let n=GFt([this.method,this.path,this.statusCode,"response"].join("_"));return IGo({uniqueId:n,type:r,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:Qs.TypeId(n),default:r.type==="enum"&&r.default!=null?{type:"enum",value:r.default}:void 0}}}case"object":return r;default:new zGo.UnreachableCaseError(i);return}}).filter(mo)}convert(){if(this.empty)return{type:"empty"};if(this.contentType!=null)switch(this.contentType){case"application/json":return this.streamingFormat==null?this.convertJsonLike():this.convertStreamingFormat();case"application/octet-stream":return{type:"fileDownload",contentType:this.contentSubtype};case"text/event-stream":return this.convertStreamingFormat();case void 0:return;default:new zGo.UnreachableCaseError(this.contentType);return}else return this.unsupportedContentType!=null?this.convertJsonLike():void 0}};var iSa=class extends $a{path;method;statusCode;requests;shapes;headers;responses;description;constructor(t,r,i,n,a,o){super(t),this.path=r,this.method=i,this.statusCode=n,this.requests=a,this.shapes=o,this.safeParse()}parse(t){this.description=this.input.description;let r=$Q_(this.input,this.context.document);if(r==null){this.context.errors.error({message:sv(this.input)?`Undefined reference: ${this.input.$ref}`:"Expected response, received null",path:this.accessPath});return}Object.entries(r.headers??{}).forEach(([i,n])=>{this.headers??={},this.headers[i]=new k9t({input:n,context:this.context,accessPath:this.accessPath,pathId:"headers",parameterName:i})}),r.content==null?(this.responses??=[],this.responses.push(new rSa({input:{},context:this.context,accessPath:this.accessPath,pathId:["content"]},"empty",t,this.path,this.method,this.statusCode,this.requests,this.shapes))):Object.entries(r.content??{}).forEach(([i,n])=>{this.responses??=[],this.responses.push(new rSa({input:n,context:this.context,accessPath:this.accessPath,pathId:["content",i]},i,t,this.path,this.method,this.statusCode,this.requests,this.shapes))})}convert(){return this.responses?.flatMap(t=>t.convert()).filter(mo)}};var NGo=class extends $a{path;method;requests;shapes;responsesByStatusCode;errorsByStatusCode;constructor(t,r,i,n,a){super(t),this.path=r,this.method=i,this.requests=n,this.shapes=a,this.safeParse()}parse(){let t=this.input.default;Object.entries(this.input).forEach(([r,i])=>{r!=="default"&&(parseInt(r)>=400?(this.errorsByStatusCode??={},this.errorsByStatusCode[r]=new iSa({input:{...t,...i},context:this.context,accessPath:this.accessPath,pathId:"errors"},this.path,this.method,parseInt(r),[],this.shapes)):(this.responsesByStatusCode??={},this.responsesByStatusCode[r]=new iSa({input:i,context:this.context,accessPath:this.accessPath,pathId:"responses"},this.path,this.method,parseInt(r),this.requests,this.shapes)))})}convertResponseObjectToHttpResponses(){return Object.entries(this.responsesByStatusCode??{}).flatMap(([t,r])=>{let i=r.convert();if(i!=null)return PGo(A1i(r.headers)).flatMap(n=>i?.map(a=>({headers:n,response:{statusCode:parseInt(t),body:a,description:r.description},examples:(r.responses??[]).flatMap(o=>(o.examples??[]).map(c=>c.convert()).filter(mo))})))}).filter(mo)}convertResponseObjectToErrors(){return Object.entries(this.errorsByStatusCode??{}).flatMap(([t,r])=>r.responses?.flatMap(i=>{let n=i.schema,a=km(n?.convert());if(n!=null)return a?.map(o=>({statusCode:parseInt(t),shape:o,description:r.description??n.description,availability:n.availability?.convert(),name:n.name??JQ_[parseInt(t)]??"UNKNOWN ERROR",examples:i.examples?.map(c=>{let f=c.convert();if(f!=null&&f.responseBody?.type==="json")return{name:f.name,description:f.description,responseBody:f.responseBody}}).filter(mo)})).filter(mo)})).filter(mo)}convert(){return{responses:this.convertResponseObjectToHttpResponses(),errors:this.convertResponseObjectToErrors()}}};var m1i=class extends $a{servers;globalAuth;path;method;basePath;isWebhook;endpointIds;description;displayName;operationId;pathParameters;queryParameters;requestHeaders;requests;responses;availability;auth;namespaces;xFernExamplesNode;redocExamplesNode;emptyResponseExamples;constructor(t){super(t),this.servers=t.servers,this.globalAuth=t.globalAuth,this.path=t.path,this.method=t.method,this.basePath=t.basePath,this.isWebhook=t.isWebhook,this.safeParse()}pushEmptyResponseExample(t,r,i){this.emptyResponseExamples??=[],this.emptyResponseExamples.push(new Z9t({input:{requestExample:t,responseExample:void 0},context:this.context,accessPath:this.accessPath,pathId:"examples"},this.path,200,y1i(i,void 0),{requestBody:r,pathParameters:this.pathParameters,queryParameters:this.queryParameters,requestHeaders:this.requestHeaders}))}parse(){if(this.isWebhook&&this.method!=="POST"&&this.method!=="GET"){this.context.errors.error({message:`Webhook method must be POST or GET. Received: ${this.method}`,path:this.accessPath});return}this.description=this.input.description,this.displayName=this.input.summary,this.operationId=this.input.operationId,this.availability=new wPe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),this.servers=h1i(this.servers,this.input.servers,this.context,this.accessPath),this.isWebhook=new vGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}).isWebhook||this.isWebhook,this.input.parameters?.map((i,n)=>{if(sv(i)){let a=pGo(i,this.context.document);if(a!=null)i=a;else{this.context.errors.warning({message:`Expected parameter reference to resolve to an object. Received undefined reference: ${i.$ref}`,path:[...this.accessPath,`parameters[${n}]`]});return}}i.in==="path"?i.schema!=null&&(this.pathParameters??={},this.pathParameters[i.name]=new k9t({input:i,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${n}`],parameterName:i.name})):i.in==="query"?i.schema!=null&&(this.queryParameters??={},this.queryParameters[i.name]=new k9t({input:i,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${n}`],parameterName:i.name})):i.in==="header"&&i.schema!=null&&(this.requestHeaders??={},this.requestHeaders[i.name]=new k9t({input:i,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${n}`],parameterName:i.name}))});for(let i of this.extractPathParameterIds()??[])this.pathParameters?.[i]==null&&this.context.errors.warning({message:`Path parameter not defined: ${i}`,path:[...this.accessPath,"parameters"]});if(this.redocExamplesNode=new gGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-code-samples"}),this.requests=this.input.requestBody!=null?new RGo({input:this.input.requestBody,context:this.context,accessPath:this.accessPath,pathId:"requestBody",method:this.method,path:this.path}):void 0,this.responses=this.input.responses!=null?new NGo({input:this.input.responses,context:this.context,accessPath:this.accessPath,pathId:"responses"},this.path,this.method,Object.values(this.requests?.requestBodiesByContentType??{}),{pathParameters:this.pathParameters,queryParameters:this.queryParameters,requestHeaders:this.requestHeaders}):void 0,this.responses==null){let i=this.requests?.requestBodiesByContentType;i==null||Object.keys(i).length===0?this.pushEmptyResponseExample(void 0,void 0,void 0):Object.values(i).forEach(n=>{if(Object.keys(n.examples??{}).length===0){let a=n.schema?.example({includeOptionals:!1,override:void 0});a!=null&&this.pushEmptyResponseExample({value:a},n,void 0)}else Object.entries(n.examples??{}).forEach(([a,o])=>{this.pushEmptyResponseExample(o,n,a)})})}let t=200;this.responses?.responsesByStatusCode!=null&&(t=Number(Object.keys(this.responses.responsesByStatusCode)?.filter(i=>Number(i)>=200&&Number(i)<300)[0])),this.globalAuth!=null&&(this.auth=this.globalAuth),this.input.security!=null&&(this.auth=new GLn({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"})),this.namespaces=[new tSa({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-group-name"})],this.namespaces?.every(i=>i.groupName==null)&&this.input.tags!=null&&(this.namespaces=this.input.tags.slice(0,1).map((i,n)=>new tSa({input:{[K9o]:i},context:this.context,accessPath:this.accessPath,pathId:["tags",`${n}`]})));let r=new bGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-sdk-method-name"});this.endpointIds=this.namespaces.map(i=>cGo({namespace:km(i?.groupName),path:this.path,method:this.method,sdkMethodName:r.sdkMethodName,operationId:this.input.operationId,displayName:this.displayName,isWebhook:this.isWebhook})).filter(mo),this.xFernExamplesNode=new yGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-examples"},this.path,t,this.requests?.requestBodiesByContentType,this.responses?.responsesByStatusCode?.[t]?.responses)}extractPathParameterIds(){if(this.path!=null)return this.path.split("/").map(t=>{if(t.startsWith("{")&&t.endsWith("}"))return t.slice(1,-1).trim()}).filter(mo)}convertPathToPathParts(){if(this.path===void 0)return;let t=this.path.startsWith("/")?this.path.slice(1):this.path,r=this.basePath?.convert();return(r?[r,...t.split("/")]:t.split("/")).reduce((n,a)=>(n.push({type:"literal",value:"/"}),a.startsWith("{")&&a.endsWith("}")?n.push({type:"pathParameter",value:Qs.PropertyKey(a.slice(1,-1).trim())}):n.push({type:"literal",value:a}),n),[])}convert(){if(this.path==null||this.endpointIds==null)return;let{responses:t,errors:r}=this.responses?.convert()??{responses:void 0,errors:void 0},i=this.emptyResponseExamples?.map(u=>u.convert()).filter(mo),n=jQ_(this.xFernExamplesNode?.convert(),[...i??[],...t?.flatMap(u=>u.examples)??[]])?.map(u=>({...u,snippets:PQ_(u.snippets,this.redocExamplesNode?.convert())}));if(this.isWebhook)return this.endpointIds.map((u,l)=>{if(!(this.method!=="POST"&&this.method!=="GET"))return{id:Qs.WebhookId(u),description:this.description,availability:this.availability?.convert(),displayName:this.displayName,operationId:this.operationId,namespace:this.namespaces?.[l]?.convert(),method:this.method,path:this.convertPathToPathParts()?.map(p=>p.value.toString())??[],queryParameters:A1i(this.queryParameters)?.flat(),headers:A1i(this.requestHeaders)?.flat(),payloads:this.requests?.convertToWebhookPayload(),examples:[this.requests?.webhookExample()].filter(mo)}}).filter(mo);let a=this.servers?.map(u=>u.convert()).filter(mo),o=this.convertPathToPathParts();if(o==null)return;let c,f=this.auth?.convert();f!=null&&(c=Object.keys(f));let s=t?.flatMap(u=>u.headers).filter(mo);return this.endpointIds.map((u,l)=>({id:Qs.EndpointId(u),description:this.description,availability:this.availability?.convert(),namespace:this.namespaces?.[l]?.convert()?.map(p=>Qs.api.v1.SubpackageId(p)),displayName:this.displayName,operationId:this.operationId,method:this.method,path:o,auth:c?.map(p=>Qs.api.latest.AuthSchemeId(p)),defaultEnvironment:a?.[0]?.id,environments:a,pathParameters:A1i(this.pathParameters)?.flat(),queryParameters:A1i(this.queryParameters)?.flat(),requestHeaders:A1i(this.requestHeaders)?.flat(),responseHeaders:s!=null&&s.length>0?s:void 0,requests:this.requests?.convert(),responses:t?.map(p=>p.response),errors:r,examples:n,snippetTemplates:void 0,protocol:{type:"rest"}}))}};var YLn=class extends $a{description;get;post;put;patch;delete;path;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:i,isWebhook:n}){this.description=this.input.description;let a=h1i(t,this.input.servers,this.context,this.accessPath),o=Array.isArray(this.pathId)?this.pathId.join("/"):this.pathId;this.input.get!=null&&(this.get=new m1i({input:this.input.get,context:this.context,accessPath:this.accessPath,pathId:"get",servers:a,globalAuth:r,path:o,method:"GET",basePath:i,isWebhook:n})),this.input.post!=null&&(this.post=new m1i({input:this.input.post,context:this.context,accessPath:this.accessPath,pathId:"post",servers:a,globalAuth:r,path:o,method:"POST",basePath:i,isWebhook:n})),this.input.put!=null&&(this.put=new m1i({input:this.input.put,context:this.context,accessPath:this.accessPath,pathId:"put",servers:a,globalAuth:r,path:o,method:"PUT",basePath:i,isWebhook:!1})),this.input.patch!=null&&(this.patch=new m1i({input:this.input.patch,context:this.context,accessPath:this.accessPath,pathId:"patch",servers:a,globalAuth:r,path:o,method:"PATCH",basePath:i,isWebhook:!1})),this.input.delete!=null&&(this.delete=new m1i({input:this.input.delete,context:this.context,accessPath:this.accessPath,pathId:"delete",servers:a,globalAuth:r,path:o,method:"DELETE",basePath:i,isWebhook:!1}))}convert(){return[...this.get?.convert()??[],...this.post?.convert()??[],...this.put?.convert()??[],...this.patch?.convert()??[],...this.delete?.convert()??[]].filter(mo)}};function FGo(e){return"payloads"in e}var QGo=class extends $a{paths;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:i}){this.paths=Object.entries(this.input).map(([n,a])=>{if(a!=null)return new YLn({input:a,context:this.context,accessPath:this.accessPath,pathId:n,servers:h1i(t,a.servers,this.context,this.accessPath),globalAuth:r,basePath:i,isWebhook:void 0})}).filter(mo)}convert(){if(this.paths==null)return;let t={},r={};return this.paths.forEach(i=>{let n=i.convert();n?.forEach(a=>{FGo(a)?r[Qs.WebhookId(a.id)]=a:t[Qs.EndpointId(a.id)]=a})}),{endpoints:t,webhookEndpoints:r}}};var UGo=class extends $a{globalHeaders;requiredProperties;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[WF_]?.map(r=>{let{header:i,...n}=r;return(n.optional!=null&&!n.optional||pGo(n,this.context.document)?.required)&&(this.requiredProperties??=[],this.requiredProperties?.push(i)),[i,new k9t({input:n,context:this.context,accessPath:this.accessPath,pathId:this.pathId,parameterName:i})]});t!=null&&(this.globalHeaders=Object.fromEntries(t))}convert(){return HLn(this.globalHeaders,this.requiredProperties)?.flat()}};function kQ_(e,t){if(sv(e)){let r=uU(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var LGo=class extends $a{webhooks;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:i}){this.webhooks=Object.entries(this.input??{}).map(([n,a])=>{let o=kQ_(a,this.context.document);if(o!=null)return new YLn({input:o,context:this.context,accessPath:this.accessPath,pathId:n,servers:t,globalAuth:r,basePath:i,isWebhook:!0})}).filter(mo)}convert(){return this.webhooks?.reduce((t,r)=>(r.convert()?.forEach(i=>{FGo(i)&&(t[Qs.WebhookId(i.id)]=i)}),t),{})}};var VGo=class extends $a{paths;webhooks;components;auth;globalHeaders;constructor(t){super(t),this.safeParse()}parse(){let t=h1i(void 0,this.input.servers,this.context,this.accessPath);this.input.security!=null&&(this.auth=new GLn({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"}));let r=new dGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});this.input.paths==null&&this.input.webhooks==null&&this.context.errors.warning({message:"Expected 'paths' or 'webhooks' property to be specified",path:this.accessPath}),this.input.paths!=null&&(this.paths=new QGo({input:this.input.paths,context:this.context,accessPath:this.accessPath,pathId:"paths",basePath:r,servers:t,globalAuth:this.auth})),this.input.webhooks!=null&&(this.webhooks=new LGo({input:this.input.webhooks,context:this.context,accessPath:this.accessPath,pathId:"webhooks",basePath:r,servers:t,globalAuth:this.auth})),this.input.components!=null&&(this.components=new CGo({input:this.input.components,context:this.context,accessPath:this.accessPath,pathId:"components"})),this.globalHeaders=new UGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-global-headers"})}convert(){let t=ehe(),{webhookEndpoints:r,endpoints:i}=this.paths?.convert()??{},n={...this.webhooks?.convert()??{},...r??{}},a=QF_({endpoints:i,webhookEndpoints:n}),{types:o,auths:c}=this.components?.convert()??{};return{id:Qs.ApiDefinitionId(t),endpoints:i??{},websockets:{},webhooks:n,types:{...o,...this.context.generatedTypes},subpackages:a,auths:{...c,...this.auth?.convert()??{}},globalHeaders:this.globalHeaders?.convert(),snippetsConfiguration:void 0}}};async function Ygc(e,t){if(e instanceof F9t){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof Xw))return;let r=new RFt(e.absoluteFilePath),i=await yPe({context:t,specs:e.specs}),n=await r.loadDocuments({context:t,specs:i}),a;for(let o of n){if(o.type!=="openapi")continue;let c={document:o.value,logger:t.logger,errors:new G9o,generatedTypes:{}},f=new VGo({input:o.value,context:c,accessPath:[],pathId:e.workspaceName??"openapi parser"});a=pws(a,f.convert())}return a}var bG_=se(kgc(),1),vG_=se(B7o(),1),gG_=require("fs/promises"),OG_=se(require("http"),1),AG_=se(require("path"),1);var iV_=require("events"),R7o=se(require("fs"),1),tYi=se(require("path"),1);var Q8_=se(require("os"),1),U8_=300,D1i=20,ESa=1e7,L8_=Q8_.default.platform();var I5M=L8_==="darwin",gAc=L8_==="win32",B1i=I5M||gAc,V8_=3e3,W8_=2e4,OAc=1250;var iGt;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(iGt||(iGt={}));var eYi;(function(e){e.CHANGE="change",e.RENAME="rename"})(eYi||(eYi={}));var SSa;(function(e){e.CHANGE="change",e.ERROR="error"})(SSa||(SSa={}));var Il;(function(e){e.ADD="add",e.ADD_DIR="addDir",e.CHANGE="change",e.RENAME="rename",e.RENAME_DIR="renameDir",e.UNLINK="unlink",e.UNLINK_DIR="unlinkDir"})(Il||(Il={}));var Fx;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(Fx||(Fx={}));var C5M=(e,t=1,r)=>{t=Math.max(1,t);let i=r?.leading??!1,n=r?.trailing??!0,a=Math.max(r?.maxWait??1/0,t),o,c,f=0,s=0,u=()=>{let g=Date.now(),m=g-f,j=g-s,M=m>=t||j>=a;return[g,M]},l=g=>{if(s=g,!o)return;let m=o;o=void 0,e.apply(void 0,m)},p=()=>{O(0)},_=()=>{c&&(p(),l(Date.now()))},h=g=>{if(s=g,i)return l(g)},y=g=>{if(n&&o)return l(g);o=void 0},b=()=>{c=void 0;let[g,m]=u();return m?y(g):v(g)},v=g=>{let m=g-f,j=g-s,M=t-m,E=a-j,D=Math.min(M,E);return O(D)},O=g=>{c&&clearTimeout(c),!(g<=0)&&(c=setTimeout(b,g))},A=(...g)=>{let[m,j]=u(),M=!!c;if(o=g,f=m,(j||!c)&&O(t),j)return M?l(m):h(m)};return A.cancel=p,A.flush=_,A},I7o=C5M;var jAc=se(require("fs"),1),q7o=se(require("path"),1);var bO=se(require("fs"),1),sU=require("util");var xgi=(e,t)=>function(...i){return e.apply(void 0,i).catch(t)},nGt=(e,t)=>function(...i){try{return e.apply(void 0,i)}catch(n){return t(n)}};var AAc=se(require("process"),1),x8_=AAc.default.getuid?!AAc.default.getuid():!1,G8_=1e4,PK=()=>{};var MSa={isChangeErrorOk:e=>{if(!MSa.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!x8_&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!MSa.isNodeError(e))return!1;let{code:t}=e;return t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM"},onChangeError:e=>{if(!MSa.isNodeError(e))throw e;if(!MSa.isChangeErrorOk(e))throw e}},WB=MSa;var mAc=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=G8_,this.queueActive=new Set,this.queueWaiting=new Set,this.init=()=>{this.intervalId||(this.intervalId=setInterval(this.tick,this.interval))},this.reset=()=>{this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId)},this.add=t=>{this.queueWaiting.add(t),this.queueActive.size<this.limit/2?this.tick():this.init()},this.remove=t=>{this.queueWaiting.delete(t),this.queueActive.delete(t)},this.schedule=()=>new Promise(t=>{let r=()=>this.remove(i),i=()=>t(r);this.add(i)}),this.tick=()=>{if(!(this.queueActive.size>=this.limit)){if(!this.queueWaiting.size)return this.reset();for(let t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t),this.queueActive.add(t),t()}}}}},H8_=new mAc;var Ggi=(e,t)=>function(i){return function n(...a){return H8_.schedule().then(o=>{let c=s=>(o(),s),f=s=>{if(o(),Date.now()>=i)throw s;if(t(s)){let u=Math.round(100*Math.random());return new Promise(p=>setTimeout(p,u)).then(()=>n.apply(void 0,a))}throw s};return e.apply(void 0,a).then(c,f)})}},Hgi=(e,t)=>function(i){return function n(...a){try{return e.apply(void 0,a)}catch(o){if(Date.now()>i)throw o;if(t(o))return n.apply(void 0,a);throw o}}};var q5M={attempt:{chmod:xgi((0,sU.promisify)(bO.default.chmod),WB.onChangeError),chown:xgi((0,sU.promisify)(bO.default.chown),WB.onChangeError),close:xgi((0,sU.promisify)(bO.default.close),PK),fsync:xgi((0,sU.promisify)(bO.default.fsync),PK),mkdir:xgi((0,sU.promisify)(bO.default.mkdir),PK),realpath:xgi((0,sU.promisify)(bO.default.realpath),PK),stat:xgi((0,sU.promisify)(bO.default.stat),PK),unlink:xgi((0,sU.promisify)(bO.default.unlink),PK),chmodSync:nGt(bO.default.chmodSync,WB.onChangeError),chownSync:nGt(bO.default.chownSync,WB.onChangeError),closeSync:nGt(bO.default.closeSync,PK),existsSync:nGt(bO.default.existsSync,PK),fsyncSync:nGt(bO.default.fsync,PK),mkdirSync:nGt(bO.default.mkdirSync,PK),realpathSync:nGt(bO.default.realpathSync,PK),statSync:nGt(bO.default.statSync,PK),unlinkSync:nGt(bO.default.unlinkSync,PK)},retry:{close:Ggi((0,sU.promisify)(bO.default.close),WB.isRetriableError),fsync:Ggi((0,sU.promisify)(bO.default.fsync),WB.isRetriableError),open:Ggi((0,sU.promisify)(bO.default.open),WB.isRetriableError),readFile:Ggi((0,sU.promisify)(bO.default.readFile),WB.isRetriableError),rename:Ggi((0,sU.promisify)(bO.default.rename),WB.isRetriableError),stat:Ggi((0,sU.promisify)(bO.default.stat),WB.isRetriableError),write:Ggi((0,sU.promisify)(bO.default.write),WB.isRetriableError),writeFile:Ggi((0,sU.promisify)(bO.default.writeFile),WB.isRetriableError),closeSync:Hgi(bO.default.closeSync,WB.isRetriableError),fsyncSync:Hgi(bO.default.fsyncSync,WB.isRetriableError),openSync:Hgi(bO.default.openSync,WB.isRetriableError),readFileSync:Hgi(bO.default.readFileSync,WB.isRetriableError),renameSync:Hgi(bO.default.renameSync,WB.isRetriableError),statSync:Hgi(bO.default.statSync,WB.isRetriableError),writeSync:Hgi(bO.default.writeSync,WB.isRetriableError),writeFileSync:Hgi(bO.default.writeFileSync,WB.isRetriableError)}},K8_=q5M;var C7o=se(require("fs"),1),DSa=se(require("path"),1);var PAc=()=>{};var T5M=()=>{let e=PAc,t=PAc,r=!1,i=!1;return{promise:new Promise((f,s)=>{e=u=>(r=!0,f(u)),t=u=>(i=!0,s(u))}),resolve:e,reject:t,isPending:()=>!r&&!i,isResolved:()=>r,isRejected:()=>i}},J8_=T5M;var R5M=()=>{let{promise:e,resolve:t,isPending:r}=J8_(),i=0,n=()=>{i+=1},a=()=>{i-=1,!i&&t()};return(()=>{n(),queueMicrotask(a)})(),{promise:e,isPending:r,increment:n,decrement:a}},$8_=R5M;var Y8_={then:e=>{e()}};var X8_=e=>Array.isArray(e)?e:[e],Z8_=e=>typeof e=="function";var z5M=(e,t)=>{let r=t?.followSymlinks??!1,i=t?.depth??1/0,n=t?.limit??1/0,a=t?.ignore??[],o=X8_(a).map(U=>Z8_(U)?U:W=>U.test(W)),c=U=>o.some(W=>W(U)),f=t?.signal??{aborted:!1},s=t?.onDirents||(()=>{}),u=[],l=new Set,p={},_=[],h=new Set,y={},b=[],v=new Set,O={},A={},g=new Set,m={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},j={directories:u,directoriesNames:l,directoriesNamesToPaths:p,files:_,filesNames:h,filesNamesToPaths:y,symlinks:b,symlinksNames:v,symlinksNamesToPaths:O,map:A},{promise:M,increment:E,decrement:D}=$8_(),B=0,F=(U,W,Te,ce)=>{g.has(W)||B>=n||(B+=1,U.directories.push(W),U.directoriesNames.add(Te),u.push(W),l.add(Te),p.propertyIsEnumerable(Te)||(p[Te]=[]),p[Te].push(W),g.add(W),!(ce>=i)&&(B>=n||J(W,ce+1)))},N=(U,W,Te)=>{g.has(W)||B>=n||(B+=1,U.files.push(W),U.filesNames.add(Te),_.push(W),h.add(Te),y.propertyIsEnumerable(Te)||(y[Te]=[]),y[Te].push(W),g.add(W))},R=(U,W,Te,ce)=>{g.has(W)||B>=n||(B+=1,U.symlinks.push(W),U.symlinksNames.add(Te),b.push(W),v.add(Te),O.propertyIsEnumerable(Te)||(O[Te]=[]),O[Te].push(W),g.add(W),r&&(ce>=i||B>=n||ue(W,ce+1)))},z=(U,W,Te,ce,we)=>{f.aborted||c(W)||(ce.isDirectory()?F(U,W,Te,we):ce.isFile()?N(U,W,Te):ce.isSymbolicLink()&&R(U,W,Te,we))},L=(U,W,Te,ce)=>{if(f.aborted)return;let we=W===DSa.default.sep?"":DSa.default.sep,Le=Te.name,le=`${W}${we}${Le}`;c(le)||(Te.isDirectory()?F(U,le,Le,ce):Te.isFile()?N(U,le,Le):Te.isSymbolicLink()&&R(U,le,Le,ce))},H=(U,W,Te,ce)=>{for(let we=0,Le=Te.length;we<Le;we++)L(U,W,Te[we],ce)},J=(U,W)=>{f.aborted||W>i||B>=n||(E(),C7o.default.readdir(U,{withFileTypes:!0},(Te,ce)=>{if(Te||f.aborted||!ce.length)return D();(s(ce)||Y8_).then(()=>{let Le=A[U]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};H(Le,U,ce,W),D()})}))},ue=(U,W)=>{E(),C7o.default.realpath(U,(Te,ce)=>{if(Te||f.aborted)return D();C7o.default.stat(ce,(we,Le)=>{if(we||f.aborted)return D();let le=DSa.default.basename(ce),ne=A[U]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};z(ne,ce,le,Le,W),D()})})};return(async(U,W=1)=>(U=DSa.default.normalize(U),g.add(U),J(U,W),await M,f.aborted?m:j))(e)},k8_=z5M;var aGt={lang:{debounce:I7o,attempt:e=>{try{return e()}catch(t){return aGt.lang.castError(t)}},castArray:e=>aGt.lang.isArray(e)?e:[e],castError:e=>aGt.lang.isError(e)?e:aGt.lang.isString(e)?new Error(e):new Error("Unknown error"),defer:e=>setTimeout(e,0),isArray:e=>Array.isArray(e),isError:e=>e instanceof Error,isFunction:e=>typeof e=="function",isNaN:e=>Number.isNaN(e),isNumber:e=>typeof e=="number",isPrimitive:e=>{if(e===null)return!0;let t=typeof e;return t!=="object"&&t!=="function"},isShallowEqual:(e,t)=>{if(e===t)return!0;if(aGt.lang.isNaN(e))return aGt.lang.isNaN(t);if(aGt.lang.isPrimitive(e)||aGt.lang.isPrimitive(t))return e===t;for(let r in e)if(!(r in t))return!1;for(let r in t)if(e[r]!==t[r])return!1;return!0},isSet:e=>e instanceof Set,isString:e=>typeof e=="string",isUndefined:e=>e===void 0,noop:()=>{},uniq:e=>e.length<2?e:Array.from(new Set(e))},fs:{getDepth:e=>Math.max(0,e.split(q7o.default.sep).length-1),getRealPath:(e,t)=>{try{return t?jAc.default.realpathSync.native(e):jAc.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===q7o.default.sep&&t.length-e.length>q7o.default.sep.length,poll:(e,t=W8_)=>K8_.retry.stat(t)(e,{bigint:!0}).catch(aGt.lang.noop),readdir:async(e,t,r=1/0,i=1/0,n,a)=>{if(a&&r===1&&e in a){let o=a[e];return[o.directories,o.files]}else{let o=await k8_(e,{depth:r,limit:i,ignore:t,signal:n});return[o.directories,o.files]}}}},cp=aGt;var T7o=se(require("path"),1);var wAc=class{constructor(t,r,i){this.base=i,this.watcher=t,this.handler=r.handler,this.fswatcher=r.watcher,this.options=r.options,this.folderPath=r.folderPath,this.filePath=r.filePath,this.handlerBatched=this.base?this.base.onWatcherEvent.bind(this.base):this._makeHandlerBatched(this.options.debounce)}_isSubRoot(t){return this.filePath?t===this.filePath:t===this.folderPath||cp.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=U8_){return(()=>{let r=this.watcher._readyWait,i=[],n=new Set,a=async(c,f)=>{let s=this.options.ignoreInitial?[]:c,u=await this.eventsPopulate([...f]),l=this.eventsDeduplicate([...s,...u]);this.onTargetEvents(l)},o=cp.lang.debounce(()=>{this.watcher.isClosed()||(r=a(i,n),i=[],n=new Set)},t);return async(c,f="",s=!1)=>{s?await this.eventsPopulate([f],i,!0):n.add(f),r.then(o)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((i,n)=>{let[a,o]=n,c=r[o];return a===c||a===Il.CHANGE&&c===Il.ADD||(r[o]=a,i.push(n)),i},[])}async eventsPopulate(t,r=[],i=!1){return await Promise.all(t.map(async n=>{let a=await this.watcher._poller.update(n,this.options.pollingTimeout);await Promise.all(a.map(async o=>{r.push([o,n]),o===Il.ADD_DIR?await this.eventsPopulateAddDir(t,n,r,i):o===Il.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,n,r,i)}))})),r}async eventsPopulateAddDir(t,r,i=[],n=!1){if(n)return i;let a=this.options.recursive?this.options.depth??D1i:Math.min(1,this.options.depth??D1i),o=this.options.limit??ESa,[c,f]=await cp.fs.readdir(r,this.options.ignore,a,o,this.watcher._closeSignal),s=[...c,...f];return await Promise.all(s.map(u=>{if(!this.watcher.isIgnored(u,this.options.ignore)&&!t.includes(u))return this.eventsPopulate([u],i,!0)})),i}async eventsPopulateUnlinkDir(t,r,i=[],n=!1){if(n)return i;for(let a of this.watcher._poller.stats.keys())cp.fs.isSubPath(r,a)&&(t.includes(a)||await this.eventsPopulate([a],i,!0));return i}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(Il.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!B1i&&this.options.native!==!1&&this.watcher.watchDirectory(t,this.options,this.handler,void 0,this.base||this),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAddDir(t,this.options.renameTimeout):this.watcher.event(Il.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(Il.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(T7o.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(Il.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(T7o.default.dirname(t),t,!1),this.watcher.watchersClose(t),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlinkDir(t,this.options.renameTimeout):this.watcher.event(Il.UNLINK_DIR,t))}onTargetEvent(t){let[r,i]=t;r===Il.ADD?this.onTargetAdd(i):r===Il.ADD_DIR?this.onTargetAddDir(i):r===Il.CHANGE?this.onTargetChange(i):r===Il.UNLINK?this.onTargetUnlink(i):r===Il.UNLINK_DIR&&this.onTargetUnlinkDir(i)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,i=!1){return this.handlerBatched(t,r,i)}onWatcherChange(t=eYi.CHANGE,r){if(this.watcher.isClosed())return;let i=T7o.default.resolve(this.folderPath,r||"");this.filePath&&i!==this.folderPath&&i!==this.filePath||this.watcher.isIgnored(i,this.options.ignore)||this.onWatcherEvent(t,i)}onWatcherError(t){gAc&&t.code==="EPERM"?this.onWatcherChange(eYi.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(SSa.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(SSa.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(eYi.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&B1i&&this.options.native!==!1?this.options.depth??D1i:Math.min(1,this.options.depth??D1i),i=this.options.limit??ESa,[n,a]=await cp.fs.readdir(this.folderPath,this.options.ignore,r,i,this.watcher._closeSignal,this.options.readdirMap),o=[this.folderPath,...n,...a];await Promise.all(o.map(c=>{if(!this.watcher._poller.stats.has(c)&&!this.watcher.isIgnored(c,this.options.ignore))return this.onWatcherEvent(eYi.CHANGE,c,t)}))}}},eV_=wAc;var Qx={interval:100,intervalId:void 0,fns:new Map,init:()=>{Qx.intervalId||(Qx.intervalId=setInterval(Qx.resolve,Qx.interval))},reset:()=>{Qx.intervalId&&(clearInterval(Qx.intervalId),delete Qx.intervalId)},add:(e,t)=>{Qx.fns.set(e,Date.now()+t),Qx.init()},remove:e=>{Qx.fns.delete(e)},resolve:()=>{if(!Qx.fns.size)return Qx.reset();let e=Date.now();for(let[t,r]of Qx.fns)r>=e||(Qx.remove(t),t())}},BSa=Qx;var ISa=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=OAc){let{ino:i,targetPath:n,events:a,locks:o}=t,c=()=>{let l=this._watcher._poller.paths.find(i||-1,p=>p!==n);if(l&&l!==n){if(cp.fs.getRealPath(n,!0)===l)return;this._watcher.event(a.rename,l,n)}else this._watcher.event(a.add,n)};if(!i)return c();let f=()=>{o.add.delete(i),BSa.remove(s)},s=()=>{f(),c()};BSa.add(s,r);let u=()=>{let l=o.unlink.get(i);if(!l)return;f();let p=l();n===p?a.change&&this._watcher._poller.stats.has(n)&&this._watcher.event(a.change,n):this._watcher.event(a.rename,p,n)};o.add.set(i,u),u()}getLockUnlink(t,r=OAc){let{ino:i,targetPath:n,events:a,locks:o}=t,c=()=>{this._watcher.event(a.unlink,n)};if(!i)return c();let f=()=>{o.unlink.delete(i),BSa.remove(s)},s=()=>{f(),c()};BSa.add(s,r);let u=()=>(f(),n);o.unlink.set(i,u),o.add.get(i)?.()}getLockTargetAdd(t,r){let i=this._watcher._poller.getIno(t,Il.ADD,iGt.FILE);return this.getLockAdd({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let i=this._watcher._poller.getIno(t,Il.ADD_DIR,iGt.DIR);return this.getLockAdd({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let i=this._watcher._poller.getIno(t,Il.UNLINK,iGt.FILE);return this.getLockUnlink({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let i=this._watcher._poller.getIno(t,Il.UNLINK_DIR,iGt.DIR);return this.getLockUnlink({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}reset(){this._locksAdd=new Map,this._locksAddDir=new Map,this._locksUnlink=new Map,this._locksUnlinkDir=new Map,this._locksDir={add:this._locksAddDir,unlink:this._locksUnlinkDir},this._locksFile={add:this._locksAdd,unlink:this._locksUnlink}}};ISa.DIR_EVENTS={add:Il.ADD_DIR,rename:Il.RENAME_DIR,unlink:Il.UNLINK_DIR};ISa.FILE_EVENTS={add:Il.ADD,change:Il.CHANGE,rename:Il.RENAME,unlink:Il.UNLINK};var tV_=ISa;var EAc=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(cp.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let i=this.map.get(t);if(cp.lang.isSet(i)){let n=i.delete(r);return i.size||this.map.delete(t),n}else if(i===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let i=this.map.get(t);if(cp.lang.isSet(i))return Array.from(i).find(r);if(r(i))return i}}get(t){return this.map.get(t)}has(t,r){if(cp.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let i=this.map.get(t);return cp.lang.isSet(i)?i.has(r):i===r}return!1}set(t,r){if(this.map.has(t)){let i=this.map.get(t);cp.lang.isSet(i)?i.add(r):i!==r&&this.map.set(t,new Set([i,r]))}else this.map.set(t,r);return this}},SAc=EAc;var MAc=class{constructor(t){this.ino=t.ino<=Number.MAX_SAFE_INTEGER?Number(t.ino):t.ino,this.size=Number(t.size),this.atimeMs=Number(t.atimeMs),this.mtimeMs=Number(t.mtimeMs),this.ctimeMs=Number(t.ctimeMs),this.birthtimeMs=Number(t.birthtimeMs),this._isFile=t.isFile(),this._isDirectory=t.isDirectory(),this._isSymbolicLink=t.isSymbolicLink()}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isSymbolicLink(){return this._isSymbolicLink}},rV_=MAc;var DAc=class{constructor(){this.inos={},this.paths=new SAc,this.stats=new Map}getIno(t,r,i){let n=this.inos[r];if(!n)return;let a=n[t];if(a&&!(i&&a[1]!==i))return a[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let i=await cp.fs.poll(t,r);if(!(!i||!(i.isFile()||i.isDirectory())))return new rV_(i)}reset(){this.inos={},this.paths=new SAc,this.stats=new Map}async update(t,r){let i=this.getStats(t),n=await this.poll(t,r);if(this.updateStats(t,n),!i&&n){if(n.isFile())return this.updateIno(t,Il.ADD,n),[Il.ADD];if(n.isDirectory())return this.updateIno(t,Il.ADD_DIR,n),[Il.ADD_DIR]}else if(i&&!n){if(i.isFile())return this.updateIno(t,Il.UNLINK,i),[Il.UNLINK];if(i.isDirectory())return this.updateIno(t,Il.UNLINK_DIR,i),[Il.UNLINK_DIR]}else if(i&&n){if(i.isFile()){if(n.isFile())return i.ino===n.ino&&!i.size&&!n.size?[]:(this.updateIno(t,Il.CHANGE,n),[Il.CHANGE]);if(n.isDirectory())return this.updateIno(t,Il.UNLINK,i),this.updateIno(t,Il.ADD_DIR,n),[Il.UNLINK,Il.ADD_DIR]}else if(i.isDirectory()){if(n.isFile())return this.updateIno(t,Il.UNLINK_DIR,i),this.updateIno(t,Il.ADD,n),[Il.UNLINK_DIR,Il.ADD];if(n.isDirectory())return i.ino===n.ino?[]:(this.updateIno(t,Il.UNLINK_DIR,i),this.updateIno(t,Il.ADD_DIR,n),[Il.UNLINK_DIR,Il.ADD_DIR])}}return[]}updateIno(t,r,i){let n=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=i.isFile()?iGt.FILE:iGt.DIR;n[t]=[i.ino,a]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let i=this.stats.get(t)?.ino||-1;this.paths.delete(i,t),this.stats.delete(t)}}},BAc=DAc;var IAc=class e extends iV_.EventEmitter{constructor(t,r,i){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(Fx.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(n=>this.on(Fx.CLOSE,n)),this._readyWait=new Promise(n=>this.on(Fx.READY,n)),this._locker=new tV_(this),this._roots=new Set,this._poller=new BAc,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,i)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(cp.lang.isFunction(r)?!!r(t):r.test(t))}isReady(){return this._ready}close(){return this._locker.reset(),this._poller.reset(),this._roots.clear(),this.watchersClose(),this.isClosed()?!1:(this._closed=!0,this.emit(Fx.CLOSE))}error(t){if(this.isClosed())return!1;let r=cp.lang.castError(t);return this.emit(Fx.ERROR,r)}event(t,r,i){return this.isClosed()?!1:(this.emit(Fx.ALL,t,r,i),this.emit(t,r,i))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(Fx.READY))}pollerExists(t,r){for(let i of this._pollers)if(i.targetPath===t&&cp.lang.isShallowEqual(i.options,r))return!0;return!1}subwatcherExists(t,r){for(let i of this._subwatchers)if(i.targetPath===t&&cp.lang.isShallowEqual(i.options,r))return!0;return!1}watchersClose(t,r,i=!0){if(t){let n=this._watchers[t];if(n)for(let a of[...n])r&&a.filePath!==r||this.watcherClose(a);if(i)for(let a in this._watchers)cp.fs.isSubPath(t,a)&&this.watchersClose(a,r,!1)}else for(let n in this._watchers)this.watchersClose(n,r,!1)}watchersLock(t){return this._watchersLock.then(()=>this._watchersLock=new Promise(async r=>{await t(),r()}))}watchersRestore(){delete this._watchersRestoreTimeout;let t=Object.entries(this._watchersRestorable);this._watchersRestorable={};for(let[r,i]of t)this.watchPath(r,i.options,i.handler)}async watcherAdd(t,r){let{folderPath:i}=t;(this._watchers[i]=this._watchers[i]||[]).push(t);let a=new eV_(this,t,r);return await a.init(),a}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let a=r.indexOf(t);r.splice(a,1),r.length||delete this._watchers[t.folderPath]}let i=t.filePath||t.folderPath;this._roots.has(i)&&(this._watchersRestorable[i]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=cp.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,i,n){if(this._watchers[t]?.find(c=>c.handler===i&&(!c.filePath||c.filePath===n)&&c.options.ignore===r.ignore&&!!c.options.native==!!r.native&&(!r.recursive||c.options.recursive)))return!0;let o=tYi.default.dirname(t);for(let c=1;c<1/0;c++){if(this._watchers[o]?.find(u=>(c===1||u.options.recursive&&c<=(u.options.depth??D1i))&&u.handler===i&&(!u.filePath||u.filePath===n)&&u.options.ignore===r.ignore&&!!u.options.native==!!r.native&&(!r.recursive||u.options.recursive&&B1i&&u.options.native!==!1)))return!0;if(!B1i)break;let s=tYi.default.dirname(t);if(o===s)break;o=s}return!1}async watchDirectories(t,r,i,n,a){if(this.isClosed())return;t=cp.lang.uniq(t).sort();let o;for(let c of t)if(!this.isIgnored(c,r.ignore)&&!this.watcherExists(c,r,i,n))try{let f=!r.recursive||B1i&&r.native!==!1?r:{...r,recursive:!1},u={watcher:R7o.default.watch(c,f),handler:i,options:r,folderPath:c,filePath:n},l=o=await this.watcherAdd(u,a);if(this._roots.has(n||c)){let _={...r,ignoreInitial:!0,recursive:!1},h=tYi.default.dirname(c),y=c;await this.watchDirectories([h],_,i,y,l)}}catch(f){this.error(f)}return o}async watchDirectory(t,r,i,n,a){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||B1i&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,i,n,a));{r={...r,recursive:!0};let o=r.depth??D1i,c=r.limit??ESa,[f]=await cp.fs.readdir(t,r.ignore,o,c,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let s=await this.watchDirectories([t],r,i,n,a);if(f.length){let u=cp.fs.getDepth(t);for(let l of f){let p=cp.fs.getDepth(l),_=Math.max(0,o-(p-u)),h={...r,depth:_};await this.watchDirectories([l],h,i,n,a||s)}}})}}}async watchFileOnce(t,r,i){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let n={targetPath:t,options:r},a=(s,u)=>{u===t&&(f(),i())},o=new e(a),c=()=>{this._subwatchers.add(n),this.on(Fx.CLOSE,f),o.watchFile(t,r,a)},f=()=>{this._subwatchers.delete(n),this.removeListener(Fx.CLOSE,f),o.close()};return c()}async watchFile(t,r,i){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let n=tYi.default.dirname(t);return this.watchDirectory(n,r,i,t)}async watchPollingOnce(t,r,i){if(this.isClosed())return;let n=!1,a=new BAc,o=await this.watchPolling(t,r,async()=>{n||!(await a.update(t,r.pollingTimeout)).length||n||(n=!0,o(),i())})}async watchPolling(t,r,i){if(this.isClosed())return cp.lang.noop;if(this.pollerExists(t,r))return cp.lang.noop;let n={...r,interval:r.pollingInterval??V8_},a={targetPath:t,options:r},o=()=>{this._pollers.add(a),this.on(Fx.CLOSE,c),R7o.default.watchFile(t,n,i)},c=()=>{this._pollers.delete(a),this.removeListener(Fx.CLOSE,c),R7o.default.unwatchFile(t,i)};return cp.lang.attempt(o),()=>cp.lang.attempt(c)}async watchUnknownChild(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchFileOnce(t,r,n)}async watchUnknownTarget(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchPollingOnce(t,r,n)}async watchPaths(t,r,i){if(this.isClosed())return;if(t=cp.lang.uniq(t).sort(),t.every((a,o)=>t.every((c,f)=>f===o||!cp.fs.isSubPath(a,c))))await Promise.all(t.map(a=>this.watchPath(a,r,i)));else for(let a of t)await this.watchPath(a,r,i)}async watchPath(t,r,i){if(this.isClosed()||(t=tYi.default.resolve(t),this.isIgnored(t,r.ignore)))return;let n=await cp.fs.poll(t,r.pollingTimeout);if(n){if(n.isFile())return this.watchFile(t,r,i);if(n.isDirectory())return this.watchDirectory(t,r,i);this.error(`"${t}" is not supported`)}else{let a=tYi.default.dirname(t);return(await cp.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,i):this.watchUnknownTarget(t,r,i)}}async watch(t,r,i=cp.lang.noop){if(cp.lang.isFunction(t))return this.watch([],{},t);if(cp.lang.isUndefined(t))return this.watch([],r,i);if(cp.lang.isFunction(r))return this.watch(t,{},r);if(cp.lang.isUndefined(r))return this.watch(t,{},i);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let n=cp.lang.castArray(t);n.forEach(a=>this._roots.add(a)),await this.watchPaths(n,r,i),!this.isClosed()&&(i!==cp.lang.noop&&this.on(Fx.ALL,i),r.readdirMap=void 0,this.ready())}},z7o=IAc;CMo();var d3n=require("fs/promises"),nV_=require("os"),aV_=se(require("path"),1),N5M=".fern",F5M="app-preview",Q5M="logs";function U5M(){return"cli@3.24.1"}var CSa=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=Bt(Br.of((0,nV_.homedir)()),$e.of(N5M)),r=Bt(t,$e.of(F5M)),i=Bt(r,$e.of(Q5M));await wi(i)||await(0,d3n.mkdir)(i,{recursive:!0});let a=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=Bt(i,$e.of(a));let o=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${aV_.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
1786
|
+
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`;throw new Error(r)}async toRootNode(){let t=Ct.V1.SlugGenerator.init(Ct.slugjoin(this.getDocsBasePath())),r=this.#e.get("root"),i=await this.toRootChild(t);return{type:"root",version:"v1",id:r,child:i,slug:t.get(),title:this.parsedDocsConfig.title??"Documentation",hidden:!1,icon:void 0,pointsTo:void 0,authed:void 0,viewers:void 0,orphaned:void 0,roles:this.parsedDocsConfig.roles?.map(n=>Ct.RoleId(n)),featureFlags:void 0}}async toRootChild(t){return Kxi(this.parsedDocsConfig.navigation)._visit({untabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),tabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),versioned:r=>this.toVersionedNode(r,t),productgroup:r=>this.toProductGroupNode({landingPageConfig:this.parsedDocsConfig.landingPage,productGroup:r,parentSlug:t})})}toLandingPageNode(t,r){let i=Ct.PageId(this.toRelativeFilepath(t.absolutePath)),n=r.apply({urlSlug:t.slug??Rw(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{type:"landingPage",id:this.#e.get(i),title:t.title,slug:n.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:i,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags}}async toUnversionedNode({landingPage:t,navigationConfig:r,parentSlug:i}){let n=this.#e.get("unversioned"),a=t!=null?this.toLandingPageNode(t,i):void 0,o=r.type==="tabbed"?await this.convertTabbedNavigation(n,r.items,i):await this.toSidebarRootNode(n,r.items,i);return{type:"unversioned",id:n,landingPage:a,child:o}}async toVersionedNode(t,r){let i=this.#e.get("versioned"),n=t.versions[0];if(n?.hidden===!0)throw new Error(`The default version "${n.version}" cannot be hidden. Please set a non-hidden version as the first version in your versions list, or remove the hidden flag from the default version.`);return{id:i,type:"versioned",children:await Promise.all(t.versions.map((a,o)=>this.toVersionNode(a,r,o===0)))}}async toProductGroupNode({productGroup:t,landingPageConfig:r,parentSlug:i}){let n=this.#e.get("productgroup"),a=r!=null?this.toLandingPageNode(r,i):void 0;return{id:n,type:"productgroup",landingPage:a,children:await Promise.all(t.products.map(o=>this.toProductNode(o,i)))}}async toProductNode(t,r){if(t.type==="internal"){let i=r.setProductSlug(t.slug??Rw(t.product)),n;switch(t.navigation.type){case"tabbed":n={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.convertTabbedNavigation(this.#e.get(t.product),t.navigation.items,i)};break;case"untabbed":n={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.toSidebarRootNode(this.#e.get(t.product),t.navigation.items,i)};break;case"versioned":n=await this.toVersionedNode(t.navigation,i);break;default:Ot(t.navigation)}return{type:"product",id:this.#e.get(t.product),productId:Ct.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",slug:i.get(),child:n,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,pointsTo:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,announcement:t.announcement!=null?{text:t.announcement.message}:void 0}}else return{type:"productLink",id:this.#e.get(t.product),productId:Ct.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",href:RW.Url(t.href??""),target:t.target,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,viewers:t.viewers,orphaned:t.orphaned}}async toVersionNode(t,r,i){let n=this.#e.get(t.version),a=r.setVersionSlug(t.slug??Rw(t.version)),o=t.navigation.type==="tabbed"?await this.convertTabbedNavigation(n,t.navigation.items,a):await this.toSidebarRootNode(n,t.navigation.items,a);return{type:"version",id:n,versionId:Ct.VersionId(t.version),title:t.version,slug:a.get(),child:o,default:i,availability:t.availability!=null?zFM(t.availability):void 0,landingPage:t.landingPage?this.toLandingPageNode(t.landingPage,a):void 0,hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,icon:void 0,pointsTo:void 0,featureFlags:t.featureFlags,announcement:t.announcement!=null?{text:t.announcement.message}:void 0}}async toSidebarRootNode(t,r,i){let n=this.#e.get(`${t}/root`),a=await Promise.all(r.map(c=>this.toNavigationChild({prefix:n,item:c,parentSlug:i}))),o=[];return a.forEach(c=>{if(c.type==="apiReference"){o.push(c);return}if(c.type==="section"&&!c.collapsed){o.push(c);return}let f=o.length>0?o[o.length-1]:void 0,s;f?.type==="sidebarGroup"?s=f:(s={id:this.#e.get(`${n}/group`),type:"sidebarGroup",children:[]},o.push(s)),s.children.push(c)}),{type:"sidebarRoot",id:n,children:o}}async toSidebarRootNodeWithVariants(t,r,i){let n=this.#e.get(`${t}/root`);return{type:"sidebarRoot",id:n,children:[{type:"varianted",id:n,children:await Promise.all(r.map(a=>this.toVariantNode(a,n,i)))}]}}async toVariantNode(t,r,i){let n=this.#e.get(`${r}/variant/${t.slug??Rw(t.title)}`),a=i.apply({urlSlug:t.slug??Rw(t.title),skipUrlSlug:t.skipUrlSlug}),o=await Promise.all(t.layout.map(c=>this.toVariantChild(c,n,a)));return{type:"variant",id:n,variantId:Ct.V1.VariantId(t.title),subtitle:t.subtitle??"",default:t.default??!1,image:void 0,children:o,title:t.title,slug:a.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,pointsTo:void 0}}async toVariantChild(t,r,i){return Kxi(t)._visit({page:async n=>this.toPageNode({item:n,parentSlug:i}),apiSection:async n=>this.toApiSectionNode({item:n,parentSlug:i}),section:async n=>this.toSectionNode({prefix:r,item:n,parentSlug:i}),link:async n=>this.toLinkNode(n),changelog:async n=>this.toChangelogNode(n,i)})}async toNavigationChild({prefix:t,item:r,parentSlug:i,hideChildren:n,parentAvailability:a}){return Kxi(r)._visit({page:async o=>this.toPageNode({item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),apiSection:async o=>this.toApiSectionNode({item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),section:async o=>this.toSectionNode({prefix:t,item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),link:async o=>this.toLinkNode(o),changelog:async o=>this.toChangelogNode(o,i,n)})}async toApiSectionNode({item:t,parentSlug:r,hideChildren:i,parentAvailability:n}){let a=rN_(t.snippetsConfiguration),o,c=await this.getFernWorkspaceForApiSection(t).toFernWorkspace({context:this.taskContext},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,objectQueryParameters:!0,preserveSchemaIds:!0}),f=this.parsedDocsConfig.experimental?.openapiParserV3,s=f==null||f;if(s)try{o=await this.getOpenApiWorkspaceForApiSection(t).getIntermediateRepresentation({context:this.taskContext,audiences:t.audiences,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1})}catch{}let u;if(t.tagDescriptionPages&&s)try{let b=await this.getOpenApiWorkspaceForApiSection(t).getOpenAPIIr({context:this.taskContext});b.tags.tagsById&&(u=Object.fromEntries(Object.entries(b.tags.tagsById).filter(([v,O])=>O.description&&O.description.trim().length>0).map(([v,O])=>[v,{id:String(O.id),description:O.description}])))}catch(y){this.taskContext.logger.warn("Failed to extract OpenAPI tags for tag description pages",String(y))}o==null&&(o=kw({workspace:c,audiences:t.audiences,generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},readme:void 0,version:void 0,packageName:void 0,context:this.taskContext,sourceResolver:new Zw(this.taskContext,c)})),this.docsWorkspace.config.settings?.substituteEnvVars&&(o=dR(o,{onError:y=>this.taskContext.failAndThrow(`Error substituting environment variables in API spec: ${y}`)},{substituteAsEmpty:!1}));let l=await this.registerApi({ir:o,snippetsConfig:a,playgroundConfig:{oauth:t.playground?.oauth},apiName:t.apiName,workspace:c}),p=ZEa({ir:o,apiDefinitionId:l,playgroundConfig:{oauth:t.playground?.oauth},context:this.taskContext}),_=new z9o(t,p,r,this.docsWorkspace,this.taskContext,this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,this.#e,this.collectedFileIds,c,i,n??t.availability,u),h=_.getTagDescriptionContent();for(let[y,b]of h.entries()){let v=y.split("/").pop()||y,O=$e.of(v),A=b;this.docsWorkspace.config.settings?.substituteEnvVars&&(A=dR(b,{onError:g=>this.taskContext.logger.error(`Error in tag description environment variable substitution: ${g}`)},{substituteAsEmpty:!1})),this.rawMarkdownFiles[O]=A,this.parsedDocsConfig.pages[O]=A}return _.get()}async toChangelogNode(t,r,i){return new W$i(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,t.changelog,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:r,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:i||t.hidden,slug:t.slug})}async toLinkNode(t){return{type:"link",id:this.#e.get(t.url),title:t.text,url:Ct.V1.Url(t.url),icon:this.resolveIconFileId(t.icon),target:t.target}}async toPageNode({item:t,parentSlug:r,hideChildren:i,parentAvailability:n}){let a=Ct.PageId(this.toRelativeFilepath(t.absolutePath)),o=r.apply({urlSlug:t.slug??Rw(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{id:this.#e.get(a),type:"page",slug:o.get(),title:this.markdownFilesToSidebarTitle.get(t.absolutePath)??t.title,icon:this.resolveIconFileId(t.icon),hidden:i||t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:a,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags,availability:t.availability??n}}async toSectionNode({prefix:t,item:r,parentSlug:i,hideChildren:n,parentAvailability:a}){let o=this.toRelativeFilepath(r.overviewAbsolutePath),c=o?Ct.PageId(o):void 0,f=this.#e.get(c??`${t}/section`),s=i.apply({urlSlug:r.slug??Rw(r.title),fullSlug:r.overviewAbsolutePath?this.markdownFilesToFullSlugs.get(r.overviewAbsolutePath)?.split("/"):void 0,skipUrlSlug:r.skipUrlSlug}),u=r.overviewAbsolutePath!=null?this.markdownFilesToNoIndex.get(r.overviewAbsolutePath):void 0,l=n||r.hidden;return{id:f,type:"section",overviewPageId:c,slug:s.get(),title:r.overviewAbsolutePath!=null?this.markdownFilesToSidebarTitle.get(r.overviewAbsolutePath)??r.title:r.title,icon:this.resolveIconFileId(r.icon),collapsed:r.collapsed,hidden:l,viewers:r.viewers,orphaned:r.orphaned,children:await Promise.all(r.contents.map(p=>this.toNavigationChild({prefix:f,item:p,parentSlug:s,hideChildren:l,parentAvailability:r.availability??a}))),authed:void 0,pointsTo:void 0,noindex:u,featureFlags:r.featureFlags,availability:r.availability??a}}async convertTabbedNavigation(t,r,i){let n=this.#e.get(`${t}/tabbed`);return{type:"tabbed",id:n,children:await Promise.all(r.map(a=>this.toTabChild(n,a,i)))}}async toTabChild(t,r,i){return Kxi(r.child)._visit({link:({href:n,target:a})=>this.toTabLinkNode(r,n,a),layout:({layout:n})=>this.toTabNode(t,r,n,i),changelog:({changelog:n})=>this.toTabChangelogNode(r,n,i),variants:({variants:n})=>this.toTabNodeWithVariants(t,r,n,i)})}async toTabChangelogNode(t,r,i){return new W$i(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,r,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:i,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:t.hidden,slug:t.slug})}async toTabLinkNode(t,r,i){return{type:"link",id:this.#e.get(r),title:t.title,url:Ct.V1.Url(r),target:i,icon:this.resolveIconFileId(t.icon)}}async toTabNode(t,r,i,n){let a=this.#e.get(`${t}/tab`),o=n.apply({urlSlug:r.slug??Rw(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:a,title:r.title,slug:o.get(),icon:this.resolveIconFileId(r.icon),hidden:r.hidden,authed:void 0,viewers:r.viewers,orphaned:r.orphaned,pointsTo:void 0,child:await this.toSidebarRootNode(a,i,o),featureFlags:r.featureFlags}}async toTabNodeWithVariants(t,r,i,n){let a=this.#e.get(`${t}/tab`),o=n.apply({urlSlug:r.slug??Rw(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:a,title:r.title,slug:o.get(),icon:this.resolveIconFileId(r.icon),hidden:r.hidden,authed:void 0,viewers:r.viewers,orphaned:r.orphaned,pointsTo:void 0,child:await this.toSidebarRootNodeWithVariants(a,i,o),featureFlags:r.featureFlags}}getFileId(t){if(t==null)return;let r=this.collectedFileIds.get(t);return r==null?this.taskContext.failAndThrow("Failed to locate file after uploading: "+t):RW.FileId(r)}resolveIconFileId(t){if(t!=null)return this.collectedFileIds.has(t)?`file:${this.getFileId(t)}`:t}convertPageActions(){if(this.parsedDocsConfig.pageActions!=null)return{default:this.parsedDocsConfig.pageActions.default,options:{askAi:this.parsedDocsConfig.pageActions.options.askAi,copyPage:this.parsedDocsConfig.pageActions.options.copyPage,viewAsMarkdown:this.parsedDocsConfig.pageActions.options.viewAsMarkdown,openAi:this.parsedDocsConfig.pageActions.options.openAi,claude:this.parsedDocsConfig.pageActions.options.claude,cursor:this.parsedDocsConfig.pageActions.options.cursor,vscode:this.parsedDocsConfig.pageActions.options.vscode,custom:this.parsedDocsConfig.pageActions.options.custom.map(t=>({title:t.title,subtitle:t.subtitle,url:t.url,icon:this.resolveIconFileId(t.icon),default:t.default}))}}}convertColorConfigImageReferences(){let{colors:t}=this.parsedDocsConfig;if(t!=null)return t.type==="dark"?{...t,...this.convertLogoAndBackgroundImage({theme:"dark"})}:t.type==="light"?{...t,...this.convertLogoAndBackgroundImage({theme:"light"}),type:"light"}:{...t,dark:{...t.dark,...this.convertLogoAndBackgroundImage({theme:"dark"})},light:{...t.light,...this.convertLogoAndBackgroundImage({theme:"light"})}}}convertLogoAndBackgroundImage({theme:t}){let{logo:r,backgroundImage:i}=this.parsedDocsConfig,n=r?.[t],a=i?.[t];return{logo:this.getFileId(n),backgroundImage:this.getFileId(a)}}convertDocsTypographyConfiguration(){if(this.parsedDocsConfig.typography!=null)return{headingsFont:this.convertFont(this.parsedDocsConfig.typography.headingsFont,"headings"),bodyFont:this.convertFont(this.parsedDocsConfig.typography.bodyFont,"body"),codeFont:this.convertFont(this.parsedDocsConfig.typography.codeFont,"code")}}convertFont(t,r){if(t==null||t.variants[0]==null)return;let i=this.getFileId(t.variants[0].absolutePath);return{type:"custom",name:t.name??`font:${r}:${i}`,variants:t.variants.map(n=>({fontFile:this.getFileId(n.absolutePath),weight:n.weight,style:n.style!=null?[n.style]:void 0})),display:t.display,fallback:t.fallback,fontVariationSettings:t.fontVariationSettings}}convertJavascriptConfiguration(){if(this.parsedDocsConfig.js!=null)return{files:this.parsedDocsConfig.js.files.map(({absolutePath:t,strategy:r})=>({fileId:this.getFileId(t),strategy:r})).filter(ts),remote:this.parsedDocsConfig.js.remote?.map(t=>({...t,url:RW.Url(t.url)})),inline:void 0}}convertMetadata(){if(this.parsedDocsConfig.metadata==null)return;let{"og:image":t,"og:logo":r,"twitter:image":i,...n}=this.parsedDocsConfig.metadata;return{...n,"og:image":this.convertFileIdOrUrl(t),"og:logo":this.convertFileIdOrUrl(r),"twitter:image":this.convertFileIdOrUrl(i)}}convertFileIdOrUrl(t){if(t!=null)return Kxi(t,"type")._visit({filepath:({value:r})=>({type:"fileId",value:this.getFileId(r)}),url:({value:r})=>({type:"url",value:RW.Url(r)}),_other:()=>this.taskContext.failAndThrow("Invalid metadata configuration")})}};function RFM(e,t){if(e?.github==null)return;let{owner:r,repo:i,branch:n="main",host:a="https://github.com"}=e.github;return`${F1(a)}/${r}/${i}/blob/${n}/fern/${t}?plain=1`}function zFM(e){switch(e){case"beta":return Ct.V1.NavigationV1Availability.Beta;case"deprecated":return Ct.V1.NavigationV1Availability.Deprecated;case"ga":return Ct.V1.NavigationV1Availability.GenerallyAvailable;case"stable":return Ct.V1.NavigationV1Availability.Stable;default:Ot(e)}}async function oU(e){return(await Promise.all(e.apiWorkspaces.map(async t=>t instanceof Xw?t:null))).filter(ts)}async function sgc(e,t,r){if(e instanceof F9t){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof Xw))return;let i=await e.getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1});return Rx({ir:i,snippetsConfig:{typescriptSdk:void 0,pythonSdk:void 0,javaSdk:void 0,rubySdk:void 0,goSdk:void 0,csharpSdk:void 0,phpSdk:void 0,swiftSdk:void 0,rustSdk:void 0},playgroundConfig:{oauth:!0},context:t})}var Qs={};Yt(Qs,{AlgoliaSearchIndex:()=>mN_,ApiDefinitionId:()=>WN_,ApiId:()=>KN_,Availability:()=>sF_,DocsConfigId:()=>JN_,EndpointId:()=>YN_,EndpointPathLiteral:()=>oF_,EnvironmentId:()=>$N_,FileId:()=>tF_,HttpMethod:()=>uF_,IndexSegmentId:()=>PN_,JqString:()=>iF_,OrgId:()=>GN_,PageId:()=>eF_,PayloadLocation:()=>RF_,PropertyKey:()=>nF_,PullRequestState:()=>BF_,RoleId:()=>aF_,TokenId:()=>HN_,TypeId:()=>kN_,Url:()=>rF_,VersionId:()=>xN_,WebSocketId:()=>XN_,WebhookId:()=>ZN_,algolia:()=>cgc,api:()=>ggc,commons:()=>Ogc,diff:()=>cF_,docs:()=>Dgc,generators:()=>Igc,git:()=>Cgc,navigation:()=>Rgc,sdks:()=>Ngc,snippets:()=>qF_,snippetsFactory:()=>TF_,templates:()=>Fgc,tokens:()=>zF_});var cgc={};Yt(cgc,{AlgoliaSearchIndex:()=>mN_,IndexSegmentId:()=>PN_});function mN_(e){return e}function PN_(e){return e}var ggc={};Yt(ggc,{latest:()=>dgc,v1:()=>vgc});var dgc={};Yt(dgc,{AuthSchemeId:()=>jN_,WebhookHttpMethod:()=>MN_,auth:()=>lgc,commons:()=>wN_,endpoint:()=>EN_,type_:()=>SN_,webhook:()=>fgc,websocket:()=>DN_});var lgc={};Yt(lgc,{AuthSchemeId:()=>jN_});function jN_(e){return e}var wN_={};var EN_={};var SN_={};var fgc={};Yt(fgc,{WebhookHttpMethod:()=>MN_});var MN_={Get:"GET",Post:"POST"};var DN_={};var vgc={};Yt(vgc,{SubpackageId:()=>QN_,WebSocketMessageId:()=>UN_,WebSocketMessageOrigin:()=>LN_,WebhookHttpMethod:()=>VN_,commons:()=>bgc,db:()=>pgc,read:()=>hgc,register:()=>ygc});var pgc={};Yt(pgc,{endpoint:()=>BN_});var BN_={};var hgc={};Yt(hgc,{SupportedLanguage:()=>IN_,endpoint:()=>_gc,type_:()=>CN_,webhook:()=>qN_,websocket:()=>TN_});var _gc={};Yt(_gc,{SupportedLanguage:()=>IN_});var IN_={Curl:"curl",Python:"python",Javascript:"javascript",Js:"js",Node:"node",Typescript:"typescript",Ts:"ts",Go:"go",Ruby:"ruby",Csharp:"csharp"};var CN_={};var qN_={};var TN_={};var ygc={};Yt(ygc,{SourceId:()=>NFM,endpoint:()=>RN_,type_:()=>zN_,webhook:()=>NN_,websocket:()=>FN_});var RN_={};var zN_={};var NN_={};var FN_={};function NFM(e){return e}var bgc={};Yt(bgc,{SubpackageId:()=>QN_,WebSocketMessageId:()=>UN_,WebSocketMessageOrigin:()=>LN_,WebhookHttpMethod:()=>VN_});function QN_(e){return e}function UN_(e){return e}var LN_={Client:"client",Server:"server"};var VN_={Get:"GET",Post:"POST"};var Ogc={};Yt(Ogc,{ApiDefinitionId:()=>WN_,ApiId:()=>KN_,Availability:()=>sF_,DocsConfigId:()=>JN_,EndpointId:()=>YN_,EndpointPathLiteral:()=>oF_,EnvironmentId:()=>$N_,FileId:()=>tF_,HttpMethod:()=>uF_,JqString:()=>iF_,OrgId:()=>GN_,PageId:()=>eF_,PropertyKey:()=>nF_,RoleId:()=>aF_,TokenId:()=>HN_,TypeId:()=>kN_,Url:()=>rF_,VersionId:()=>xN_,WebSocketId:()=>XN_,WebhookId:()=>ZN_});function WN_(e){return e}function xN_(e){return e}function GN_(e){return e}function HN_(e){return e}function KN_(e){return e}function JN_(e){return e}function $N_(e){return e}function YN_(e){return e}function XN_(e){return e}function ZN_(e){return e}function kN_(e){return e}function eF_(e){return e}function tF_(e){return e}function rF_(e){return e}function iF_(e){return e}function nF_(e){return e}function aF_(e){return e}function oF_(e){return e}var uF_={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE"};var sF_={Stable:"Stable",GenerallyAvailable:"GenerallyAvailable",InDevelopment:"InDevelopment",PreRelease:"PreRelease",Deprecated:"Deprecated",Beta:"Beta"};var cF_={};var Dgc={};Yt(Dgc,{latest:()=>Pgc,v1:()=>Sgc,v2:()=>Mgc});var Pgc={};Yt(Pgc,{Layout:()=>fF_,MdxEngine:()=>FFM,TwitterCardSetting:()=>dF_,commons:()=>lF_,frontmatter:()=>Agc,seo:()=>mgc});var FFM={NextMdxRemote:"next-mdx-remote",MdxBundler:"mdx-bundler"};var lF_={};var Agc={};Yt(Agc,{Layout:()=>fF_});var fF_={Guide:"guide",Overview:"overview",Reference:"reference",Page:"page",Custom:"custom"};var mgc={};Yt(mgc,{TwitterCardSetting:()=>dF_});var dF_={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var Sgc={};Yt(Sgc,{commons:()=>Egc,db:()=>pF_,read:()=>_F_,write:()=>jgc});var pF_={};var _F_={};var jgc={};Yt(jgc,{DocsRegistrationId:()=>UFM,FilePath:()=>QFM});function QFM(e){return e}function UFM(e){return e}var Egc={};Yt(Egc,{ContentAlignment:()=>vF_,FontDisplay:()=>PF_,FontStyle:()=>mF_,HeaderPosition:()=>gF_,JsScriptStrategy:()=>AF_,ProgrammingLanguage:()=>hF_,SearchbarPlacement:()=>yF_,TabsPlacement:()=>bF_,TwitterCardSetting:()=>OF_,commons:()=>wgc});var wgc={};Yt(wgc,{ContentAlignment:()=>vF_,FontDisplay:()=>PF_,FontStyle:()=>mF_,HeaderPosition:()=>gF_,JsScriptStrategy:()=>AF_,ProgrammingLanguage:()=>hF_,SearchbarPlacement:()=>yF_,TabsPlacement:()=>bF_,TwitterCardSetting:()=>OF_});var hF_={Typescript:"typescript",Javascript:"javascript",Python:"python",Java:"java",Go:"go",Ruby:"ruby",Csharp:"csharp",Nodets:"nodets",Nodejs:"nodejs",Dotnet:"dotnet",Curl:"curl",Jvm:"jvm",Ts:"ts",Js:"js"};var yF_={Header:"HEADER",HeaderTabs:"HEADER_TABS",Sidebar:"SIDEBAR"};var bF_={Header:"HEADER",Sidebar:"SIDEBAR"};var vF_={Center:"CENTER",Left:"LEFT"};var gF_={Fixed:"FIXED",Absolute:"ABSOLUTE"};var OF_={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var AF_={BeforeInteractive:"beforeInteractive",AfterInteractive:"afterInteractive",LazyOnload:"lazyOnload"};var mF_={Normal:"normal",Italic:"italic"};var PF_={Auto:"auto",Block:"block",Swap:"swap",Fallback:"fallback",Optional:"optional"};var Mgc={};Yt(Mgc,{read:()=>jF_,write:()=>wF_});var jF_={};var wF_={};var Igc={};Yt(Igc,{ChangelogEntryType:()=>SF_,GeneratorId:()=>LFM,GeneratorLanguage:()=>VFM,ReleaseType:()=>MF_,cli:()=>EF_,commons:()=>Bgc,versions:()=>DF_});var EF_={};var Bgc={};Yt(Bgc,{ChangelogEntryType:()=>SF_,ReleaseType:()=>MF_});var SF_={Fix:"fix",Feat:"feat",Chore:"chore",Break:"break",Internal:"internal"};var MF_={Ga:"GA",Rc:"RC"};var DF_={};function LFM(e){return e}var VFM={Python:"python",Go:"go",Java:"java",Typescript:"typescript",Ruby:"ruby",Csharp:"csharp",Php:"php",Swift:"swift",Rust:"rust"};var Cgc={};Yt(Cgc,{PullRequestState:()=>BF_});var BF_={Open:"open",Closed:"closed",Merged:"merged"};var Rgc={};Yt(Rgc,{latest:()=>qgc,v1:()=>Tgc});var qgc={};Yt(qgc,{NodeId:()=>GFM,ProductId:()=>HFM,Slug:()=>WFM,TabId:()=>xFM});function WFM(e){return e}function xFM(e){return e}function GFM(e){return e}function HFM(e){return e}var Tgc={};Yt(Tgc,{NavigationV1Availability:()=>XFM,NodeId:()=>$FM,ProductId:()=>YFM,Slug:()=>KFM,TabId:()=>JFM});function KFM(e){return e}function JFM(e){return e}function $FM(e){return e}function YFM(e){return e}var XFM={Stable:"stable",GenerallyAvailable:"generally-available",InDevelopment:"in-development",PreRelease:"pre-release",Beta:"beta",Deprecated:"deprecated"};var Ngc={};Yt(Ngc,{Language:()=>IF_,VersionBump:()=>CF_,versions:()=>zgc});var zgc={};Yt(zgc,{Language:()=>IF_,VersionBump:()=>CF_});var IF_={Go:"Go",TypeScript:"TypeScript",Java:"Java",Python:"Python",Csharp:"Csharp",Ruby:"Ruby"};var CF_={Major:"MAJOR",Minor:"MINOR",Patch:"PATCH"};var qF_={};var TF_={};var Fgc={};Yt(Fgc,{PayloadLocation:()=>RF_});var RF_={Body:"BODY",Query:"QUERY",Path:"PATH",Headers:"HEADERS",Relative:"RELATIVE",Auth:"AUTH"};var zF_={};var G9o=class{warnings=[];errors=[];error(t){this.errors.push(t)}warning(t){this.warnings.push(t)}};function mo(e){return e!=null}var FF_=se(pda(),1);var NF_=["PII","PHI","PCI","GDPR","CCPA","HIPAA","COPPA","FERPA","GLBA","SOX","FISMA","NIST","CIS","ISO","IEC","ITAR","EAR","CMMC","CUI","CDI","FTC","FCC","SEC","FINRA","XSS","CSRF","SSRF","XSRF","TLS","SSL","SSH","API","OAuth","OAuth1","OAuth1.0","OAuth2","OAuth2.0","SAML","OpenID","OpenID Connect","CAPTCHA","reCAPTCHA","2FA","MFA","OTP","TOTP","HOTP","U2F","FIDO","FIDO2","PKI","HMAC","AES","RSA","SHA","MD5","BCrypt","PBKDF2","Argon2","SCrypt","JWT","JWE","JWS","JWK","JWA","JOSE","SKU","SKUs","UPC","EAN","ISBN","ASIN","MPN","MSRP","MAP","RRP","MSRP","AM","PM","UTC","GMT","PST","PDT","EST","EDT","CST","CDT","MST","MDT","USA","UK","EU","UAE","APAC","EMEA","LATAM","ANZ","SEA","MEA","MENA","NATO","NA","SA","CA","EU","AU","NZ","JP","KR","CN","HK","TW","SG","MY","TH","ID","PH","VN","IN","PK","BD","LK","NP","MM","KH","LA","MM","BT","MV","USD","EUR","GBP","JPY","CNY","RUB","INR","AUD","CAD","CHF","SGD","MYR","THB","IDR","KRW","PHP","VND","HKD","TWD","MXN","BRL","ARS","CLP","COP","PEN","ZAR","NGN","EGP","AED","SAR","ILS","TRY","SEK","NOK","DKK","ISK","HUF","PLN","CZK","RON","BGN","API","APIs","SDK","SDKs","AI","OCR","REST","SOAP","JSON","XML","HTTP","HTTPS","URI","URL","CRUD","RESTful","KYB","KYC","AML","HTML","CSS","JS","SQL","DB","UI","UX","SaaS","PaaS","IaaS","IP","TCP","UDP","DNS","FTP","SMTP","IMAP","POP3","CSV","MVC","MVP","MVVM","DOM","SPA","SSR","CSR","DDoS","CDN","IoT","ML","DL","NLP","CLI","GUI","BI","ETL","RDBMS","NoSQL","IDE","CMS","CCPA","POSIX","ABI","API","AST","COBOL","DDL","DML","NN","CNN","RNN","LSTM","GRU","ANN","GAN","RL","DL","ML","NLP","NLG","NLU","BERT","GPT","SVM","PCA","AI","CV","TF","TTS","ASR","HMM","DNN","MLP","RBM","CRF","PDF","PDFs","RTF","TXT","XLS","XLSX","PPT","JPG","JPEG","PNG","GIF","GIFs","SVG","TIFF","BMP","ICO","PSD","WebP","AVIF","HEIF","HEIC","EPS","MP3","WAV","AIFF","FLAC","WMA","AAC","OGG","AVI","WMV","MOV","M4V","MP4","MPG","MPEG","FLV","SWF","MKV","WebM","GCP","AWS","VM","VPC","S3","EC2","DynamoDB","CosmosDB","BigQuery","CI/CD","SOC1","SOC2","SOC3","PCI DSS","WAF","IAM","SDN","MPLS","BGP","Vue.js","Node.js",".NET"];function X9t(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,FF_.default)(e,{special:NF_}).replace(/V\s(\d)/g,"V$1")}function QF_({endpoints:e,webhookEndpoints:t}){let r={};return Object.values({...e,...t}).forEach(i=>{let n=[];i.namespace?.forEach(a=>{let o=[...n,a],c=Qs.api.v1.SubpackageId(o.join("."));r[c]={id:c,name:a,displayName:X9t(a)},n.push(a)})}),r}var H9o=class{input;context;constructor(t,r){this.input=t,this.context=r}errors(){return this.context.errors.errors}warnings(){return this.context.errors.warnings}};function UF_(e){return`#/${e.map(t=>t.replaceAll(/~/g,"~0").replaceAll(/\//g,"~1")).join("/")}`}var $a=class extends H9o{context;accessPath;pathId;constructor({input:t,context:r,accessPath:i,pathId:n}){if(super(t,r),this.context=r,this.accessPath=[...i],this.pathId=n,n!=null){let a=Array.isArray(this.pathId)?this.pathId:[this.pathId];a.every((o,c)=>o===this.accessPath[this.accessPath.length-a.length+c])||this.accessPath.push(...a)}r.logger.debug(`Processing ${UF_(this.accessPath)}`)}safeParse(...t){try{this.parse(...t)}catch{this.context.errors.error({message:"Error converting node. Please contact support if the error persists",path:this.accessPath})}}},LB=class extends $a{},gK=class extends LB{seenSchemas;constructor(t){super(t),this.seenSchemas=new Set(t.seenSchemas)}};var LF_="x-fern-base-path",VF_="x-fern-availability",K9o="x-fern-sdk-group-name",WF_="x-fern-global-headers",xF_="x-fern-sdk-method-name";var GF_="x-fern-webhook",HF_="x-fern-access-token-locator",KF_="x-fern-basic",JF_="x-fern-username-variable-name",$F_="x-fern-password-variable-name",YF_="x-fern-bearer",XF_="x-fern-token-variable-name",ZF_="x-fern-header",kF_="x-fern-header-variable-name",eQ_="x-fern-server-name",tQ_="x-fern-examples";var J9o=class extends $a{serverName;constructor(t){super(t),this.safeParse()}parse(){this.serverName=this.input[eQ_]}convert(){if(this.serverName!=null)return this.serverName}};var $9o=class extends $a{url;serverName;constructor(t){super(t),this.safeParse()}parse(){this.url=Object.entries(this.input.variables??{}).reduce((t,[r,i])=>t.replace(`{${r}}`,i.default),this.input.url)??this.input.url,this.serverName=new J9o({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})}convert(){let t=this.serverName?.convert()??this.url;if(!(this.url==null||t==null))return{id:Qs.EnvironmentId(t),baseUrl:this.url}}};function h1i(e,t,r,i){let n=e??[],a=new Set(n.map(c=>c.url)),o=(t??[]).filter(c=>!a.has(c.url)).map((c,f)=>new $9o({input:c,context:r,accessPath:i,pathId:["servers",`${f}`]}));return[...n,...o]}function sv(e){return typeof e=="object"&&mo(e)&&"$ref"in e&&typeof e.$ref=="string"}function uU(e,t,r){let i=e.$ref.substring(2).split("/").map(a=>a.replace(/~1/g,"/")),n=t;for(let a of i){if(typeof n!="object"||n==null)return r;n=n[a]}return n==null?r:(sv(n)&&(n=uU(n,t,r)),n)}function Y9o(e,t){let r=t.components?.securitySchemes?.[e];if(r!=null)return sv(r)?uU(r,t,void 0):r}var OQ_=se(zE());var X9o=class extends $a{username;password;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[KF_];this.username=t?.username,this.password=t?.password}convert(){return{username:this.username,password:this.password}}};var Z9o=class extends $a{passwordVariableName;constructor(t){super(t),this.safeParse()}parse(){this.passwordVariableName=this.input[$F_]}convert(){return this.passwordVariableName}};var k9o=class extends $a{usernameVariableName;constructor(t){super(t),this.safeParse()}parse(){this.usernameVariableName=this.input[JF_]}convert(){return this.usernameVariableName}};var eGo=class extends $a{bearerTokenVariableName;bearerTokenEnvVar;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[YF_];this.bearerTokenVariableName=t?.name,this.bearerTokenEnvVar=t?.env}convert(){return{tokenVariableName:this.bearerTokenVariableName,tokenEnvVar:this.bearerTokenEnvVar}}};var tGo=class extends $a{tokenVariableName;constructor(t){super(t),this.safeParse()}parse(){this.tokenVariableName=this.input[XF_]}convert(){return this.tokenVariableName}};function rQ_(e){return typeof e=="object"&&e!=null&&"in"in e&&e.in==="header"}var iQ_="x-bearer-format",nQ_="x-code-samples",aQ_="x-codeSamples";var rGo=class extends $a{bearerFormat;constructor(t){super(t),this.safeParse()}parse(){this.bearerFormat=this.input[iQ_]}convert(){return this.bearerFormat}};var iGo=class extends $a{headerVariableName;headerEnvVar;headerPrefix;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[ZF_];this.headerVariableName=t?.name,this.headerEnvVar=t?.env,this.headerPrefix=t?.prefix}convert(){return{name:this.headerVariableName,env:this.headerEnvVar,prefix:this.headerPrefix}}};var nGo=class extends $a{headerVariableName;constructor(t){super(t),this.safeParse()}parse(){this.headerVariableName=this.input[kF_]}convert(){return this.headerVariableName}};function oQ_(e){return e.type==="apiKey"}var VLn=class extends $a{headerName;headerBearerFormatNode;headerAuthNode;headerVariableNameNode;constructor(t){super(t),this.safeParse()}parse(){oQ_(this.input)&&(this.headerName=this.input.name),this.headerAuthNode=new iGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerVariableNameNode=new nGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerBearerFormatNode=new rGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})}convert(){let t=this.headerAuthNode?.convert();if(t!=null)return{type:"header",nameOverride:t?.name,headerWireValue:this.headerName??"Authorization",prefix:t?.prefix??this.headerBearerFormatNode?.convert()}}};function aGo(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function WLn(e){return typeof e=="string"||typeof e=="symbol"?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function kEa(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(kEa).join(",");let t=String(e);return t==="0"&&Object.is(Number(e),-0)?"-0":t}function oGo(e){if(Array.isArray(e))return e.map(WLn);if(typeof e=="symbol")return[e];e=kEa(e);let t=[],r=e.length;if(r===0)return t;let i=0,n="",a="",o=!1;for(e.charCodeAt(0)===46&&(t.push(""),i++);i<r;){let c=e[i];a?c==="\\"&&i+1<r?(i++,n+=e[i]):c===a?a="":n+=c:o?c==='"'||c==="'"?a=c:c==="]"?(o=!1,t.push(n),n=""):n+=c:c==="["?(o=!0,n&&(t.push(n),n="")):c==="."?n&&(t.push(n),n=""):n+=c,i++}return n&&t.push(n),t}function eSa(e,t,r){if(e==null)return r;switch(typeof t){case"string":{if(pso(t))return r;let i=e[t];return i===void 0?aGo(t)?eSa(e,oGo(t),r):r:i}case"number":case"symbol":{typeof t=="number"&&(t=WLn(t));let i=e[t];return i===void 0?r:i}default:{if(Array.isArray(t))return ZFM(e,t,r);if(Object.is(t?.valueOf(),-0)?t="-0":t=String(t),pso(t))return r;let i=e[t];return i===void 0?r:i}}}function ZFM(e,t,r){if(t.length===0)return r;let i=e;for(let n=0;n<t.length;n++){if(i==null||pso(t[n]))return r;i=i[t[n]]}return i===void 0?r:i}function uQ_(e){return function(t){return eSa(t,e)}}function sQ_(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function Qgc(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function Lgc(e,t,r){return typeof r!="function"?Lgc(e,t,()=>{}):Ugc(e,t,function i(n,a,o,c,f,s){let u=r(n,a,o,c,f,s);return u!==void 0?!!u:Ugc(n,a,i,s)},new Map)}function Ugc(e,t,r,i){if(t===e)return!0;switch(typeof t){case"object":return kFM(e,t,r,i);case"function":return Object.keys(t).length>0?Ugc(e,{...t},r,i):Qgc(e,t);default:return sQ_(e)?typeof t=="string"?t==="":!0:Qgc(e,t)}}function kFM(e,t,r,i){if(t==null)return!0;if(Array.isArray(t))return cQ_(e,t,r,i);if(t instanceof Map)return eQM(e,t,r,i);if(t instanceof Set)return tQM(e,t,r,i);let n=Object.keys(t);if(e==null)return n.length===0;if(n.length===0)return!0;if(i?.has(t))return i.get(t)===e;i?.set(t,e);try{for(let a=0;a<n.length;a++){let o=n[a];if(!uso(e)&&!(o in e)||t[o]===void 0&&e[o]!==void 0||t[o]===null&&e[o]!==null||!r(e[o],t[o],o,e,t,i))return!1}return!0}finally{i?.delete(t)}}function eQM(e,t,r,i){if(t.size===0)return!0;if(!(e instanceof Map))return!1;for(let[n,a]of t.entries()){let o=e.get(n);if(r(o,a,n,e,t,i)===!1)return!1}return!0}function cQ_(e,t,r,i){if(t.length===0)return!0;if(!Array.isArray(e))return!1;let n=new Set;for(let a=0;a<t.length;a++){let o=t[a],c=!1;for(let f=0;f<e.length;f++){if(n.has(f))continue;let s=e[f],u=!1;if(r(s,o,a,e,t,i)&&(u=!0),u){n.add(f),c=!0;break}}if(!c)return!1}return!0}function tQM(e,t,r,i){return t.size===0?!0:e instanceof Set?cQ_([...e],[...t],r,i):!1}function uGo(e,t){return Lgc(e,t,()=>{})}function lQ_(e){return e=MUd(e),t=>uGo(t,e)}function fQ_(e,t){return SUd(e,(r,i,n,a)=>{let o=t?.(r,i,n,a);if(o!==void 0)return o;if(typeof e=="object")switch(Object.prototype.toString.call(e)){case lso:case cso:case fso:{let c=new e.constructor(e?.valueOf());return yzt(c,e),c}case dso:{let c={};return yzt(c,e),c.length=e.length,c[Symbol.iterator]=e[Symbol.iterator],c}default:return}})}function dQ_(e){return fQ_(e)}var rQM=/^(?:0|[1-9]\d*)$/;function pQ_(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e<t;case"symbol":return!1;case"string":return rQM.test(e)}}function _Q_(e){return e!==null&&typeof e=="object"&&sso(e)==="[object Arguments]"}function hQ_(e,t){let r;if(Array.isArray(t)?r=t:typeof t=="string"&&aGo(t)&&e?.[t]==null?r=oGo(t):r=[t],r.length===0)return!1;let i=e;for(let n=0;n<r.length;n++){let a=r[n];if((i==null||!Object.hasOwn(i,a))&&!((Array.isArray(i)||_Q_(i))&&pQ_(a)&&a<i.length))return!1;i=i[a]}return!0}function yQ_(e,t){switch(typeof e){case"object":{Object.is(e?.valueOf(),-0)&&(e="-0");break}case"number":{e=WLn(e);break}}return t=dQ_(t),function(r){let i=eSa(r,e);return i===void 0?hQ_(r,e):t===void 0?i===void 0:uGo(i,t)}}function bQ_(e){if(e==null)return rco;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&e.length===2?yQ_(e[0],e[1]):lQ_(e);case"string":case"symbol":case"number":return uQ_(e)}}function sGo(e,t=rco){return e==null?{}:rQ(e,bQ_(t))}function vQ_(e){return typeof e!="string"&&(e=kEa(e)),e.replace(/['\u2019]/g,"")}function GFt(e){return BUd(vQ_(e))}function km(e){if(e!=null)return Array.isArray(e)?e:[e]}function cGo({namespace:e,path:t,method:r,sdkMethodName:i,operationId:n,displayName:a,isWebhook:o}){if(t==null)return;let c=r!=null&&t!=null?`${r}_${t.split("/").join("_")}`:r??t.split("/").join("_");if(!(i==null&&n==null&&a==null&&c==null))return`${iQM(o)}${nQM(e)}.${aQM(i,n,a,c)}`}function iQM(e){return e?"webhook_":"endpoint_"}function nQM(e){return e!=null?km(e)?.map(t=>GFt(t)).join("/"):""}function aQM(e,t,r,i){return e||t||GFt(r??"")||GFt(i??"")}function gQ_(e){return e.length===0?!1:/^\$?(\.[\w*]+|\[['"][\w*]+['"]?\]|\[['"]?[\d*]+['"]?\]|\[[\d:]+\])*$/.test(e)}var lGo=class extends $a{accessTokenLocator;constructor(t){super(t),this.safeParse()}parse(){this.accessTokenLocator=this.input[HF_],this.accessTokenLocator!=null&&(gQ_(this.accessTokenLocator)||(this.context.errors.error({message:"Invalid access token locator, must be a valid jq path",path:this.accessPath}),this.accessTokenLocator=void 0))}convert(){return this.accessTokenLocator}};var fGo=class extends $a{authorizationUrl;headerAuthNode;accessTokenLocatorNode;constructor(t){super(t),this.safeParse()}parse(){if(this.input.flows.clientCredentials!=null){let t=this.input.flows.clientCredentials;this.authorizationUrl=t.tokenUrl,this.authorizationUrl==null&&this.context.errors.error({message:"Expected 'tokenUrl' property to be specified",path:this.accessPath}),this.headerAuthNode=new VLn({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.accessTokenLocatorNode=new lGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.authorizationUrl==null&&this.context.errors.error({message:"Expected 'tokenUrl' property to be specified",path:this.accessPath}),this.accessTokenLocatorNode?.accessTokenLocator==null&&this.context.errors.error({message:"Expected 'x-fern-access-token-locator' property to be specified",path:this.accessPath})}}convert(){let t=this.accessTokenLocatorNode?.convert();if(t==null||this.authorizationUrl==null)return{type:"bearerAuth",tokenName:void 0};let r=cGo({namespace:void 0,path:this.authorizationUrl,method:"POST",sdkMethodName:void 0,operationId:void 0,displayName:void 0,isWebhook:void 0});if(r!=null)return{type:"oAuth",value:{type:"clientCredentials",value:{type:"referencedEndpoint",endpointId:Qs.EndpointId(r),accessTokenLocator:Qs.JqString(t),headerName:this.headerAuthNode?.convert()?.headerWireValue,tokenPrefix:this.headerAuthNode?.convert()?.prefix}}}}};var xLn=class extends $a{authScheme;headerAuthNode;bearerTokenNode;bearerTokenVariableNameNode;basicAuthNode;basicUsernameVariableNameNode;basicPasswordVariableNameNode;oauth2Node;constructor(t){super(t),this.safeParse()}parse(){switch(this.input.type){case"http":switch(this.input.scheme){case"basic":{this.authScheme="basic",this.basicAuthNode=new X9o({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicUsernameVariableNameNode=new k9o({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicPasswordVariableNameNode=new Z9o({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),(this.basicAuthNode==null||this.basicAuthNode.username==null&&this.basicUsernameVariableNameNode?.usernameVariableName==null||this.basicAuthNode.password==null&&this.basicPasswordVariableNameNode?.passwordVariableName==null)&&this.context.errors.warning({message:"Basic auth should specify either a username or a username variable name",path:this.accessPath});break}case"bearer":{this.authScheme="bearer",this.bearerTokenNode=new eGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.bearerTokenVariableNameNode=new tGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});break}default:{this.context.errors.warning({message:`Unsupported HTTP auth scheme: ${this.input.scheme}`,path:this.accessPath});break}}break;case"apiKey":{rQ_(this.input)?(this.authScheme="header",this.headerAuthNode=new VLn({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})):this.context.errors.error({message:`Unsupported API key location: ${this.input.in}`,path:this.accessPath});break}case"oauth2":{this.authScheme="oauth",this.oauth2Node=new fGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});break}case"openIdConnect":{this.authScheme="bearer";break}}}convert(){switch(this.authScheme){case"basic":{let t=this.basicAuthNode?.convert();return{type:"basicAuth",usernameName:t?.username?.name??this.basicUsernameVariableNameNode?.convert(),passwordName:t?.password?.name??this.basicPasswordVariableNameNode?.convert()}}case"bearer":return{type:"bearerAuth",tokenName:this.bearerTokenNode?.convert()?.tokenVariableName??this.bearerTokenVariableNameNode?.convert()};case"header":return this.headerAuthNode?.convert();case"oauth":return this.oauth2Node?.convert();case void 0:return;default:new OQ_.UnreachableCaseError(this.authScheme);return}}};var GLn=class extends $a{authNodesMap;constructor(t){super(t),this.safeParse()}parse(){this.input.map((t,r)=>Object.keys(t).map(i=>{let n=Y9o(i,this.context.document);if(n==null){this.context.errors.warning({message:`No auth scheme found for ${i}. Inline security schemes are not supported.`,path:this.accessPath});return}let a=new xLn({input:n,context:this.context,accessPath:this.accessPath,pathId:["security",`${r}`]});a.convert()!=null?(this.authNodesMap??={},this.authNodesMap[i]=a):this.context.errors.warning({message:`No auth scheme found for ${i}`,path:this.accessPath})}))}convert(){return Object.fromEntries(Object.entries(this.authNodesMap??{}).map(([t,r])=>{let i=r.convert();if(i!=null)return[t,i]}).filter(mo))}};var dGo=class extends $a{basePath;constructor(t){super(t),this.safeParse()}parse(){this.basePath=this.input[LF_],this.basePath!=null?(this.basePath.startsWith("/")&&(this.basePath=this.basePath.slice(1)),this.basePath.endsWith("/")&&(this.basePath=this.basePath.slice(0,-1))):this.basePath=void 0}convert(){return this.basePath}};function AQ_(e){return"required"in e&&typeof e.required=="boolean"?e.required:!1}function mQ_(e,t){return{type:"alias",value:{type:"optional",shape:e,default:t}}}function HLn(e,t){return e==null?void 0:Object.entries(e).map(([i,n])=>km(n.convert())?.map(o=>((t!=null&&!t.includes(i)||t==null&&!AQ_(n))&&(o=mQ_(o,o.type==="enum"?o.default:void 0)),{key:Qs.PropertyKey(i),valueShape:o,description:n.description,availability:n.availability?.convert()})).filter(mo)).filter(mo).reduce((i,n)=>i.flatMap(a=>n.length>0?n.map(o=>[...a,o]):[[...a]]),[[]])}function pGo(e,t){return sv(e)?uU(e,t,void 0):e}function y1i(e,t){return e!=null&&e!==""?e:t!=null&&t!==""?t:void 0}function PQ_(e,t){let r={...e};for(let[i,n]of Object.entries(t??{}))r[i]=[...r[i]??[],...n];return Object.keys(r).length>0?r:void 0}function jQ_(e,t){if(e==null)return t;if(t==null)return e;let r=[];for(let i of e)for(let n of t)r.push({path:i.path??n.path,responseStatusCode:i.responseStatusCode??n.responseStatusCode,name:i.name??n.name,description:i.description??n.description,pathParameters:i.pathParameters??n.pathParameters,queryParameters:i.queryParameters??n.queryParameters,headers:i.headers??n.headers,requestBody:i.requestBody??n.requestBody,responseBody:i.responseBody??n.responseBody,snippets:{...n.snippets,...i.snippets}});return r}var wQ_=se(zE());var Vgc=["decimal","decimal128","double-int","double","float","sf-decimal"],Wgc=["int16","int32","int64","int8","sf-integer","uint8"],xgc=["base64url","binary","byte","char","commonmark","date-time","date","decimal","decimal128","duration","email","hostname","html","http-date","idn-email","idn-hostname","int64","ipv4","ipv6","iri-reference","iri","json-pointer","media-range","password","regex","relative-json-pointer","sf-binary","sf-boolean","sf-string","sf-token","time","uri-reference","uri-template","uri","uuid"],Ggc=["beta","pre-release","in-development","generally-available","deprecated"];function VB(e,t){return sv(e)?uU(e,t,{type:"unknown","x-fern-type":"unknown",additionalProperties:!1}):e}var wPe=class extends $a{availability;constructor(t){super(t),this.safeParse()}parse(){if(VB(this.input,this.context.document)?.deprecated)this.availability="deprecated";else{let r=this.input[VF_];r!=null&&(Ggc.includes(r)?this.availability=r:(this.context.errors.warning({message:`Expected one of: ${Ggc.join(", ")}. Received: ${r}`,path:this.accessPath}),this.availability=void 0))}}convert(){switch(this.availability){case"beta":case"pre-release":return Qs.Availability.Beta;case"in-development":return Qs.Availability.InDevelopment;case"generally-available":return Qs.Availability.GenerallyAvailable;case"deprecated":return Qs.Availability.Deprecated;case void 0:return;default:new wQ_.UnreachableCaseError(this.availability);return}}};var hGo=se(zE());function EQ_(e){return typeof e=="object"&&e!=null&&"language"in e}function SQ_(e){return typeof e=="object"&&e!=null&&"sdk"in e}function MQ_(e){return typeof e=="object"&&e!=null&&("error"in e||"body"in e)}function DQ_(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)}function _Go(e){return typeof e=="object"&&e!=null&&"event"in e}function Hgc(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)&&e.stream.every(_Go)}function b1i(e){return typeof e=="object"&&e!=null&&"filename"in e&&"data"in e&&typeof e.filename=="string"&&typeof e.data=="string"}function BQ_(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}var yGo=class extends $a{path;successResponseStatusCode;requestBodyByContentType;responseBodies;examples;constructor(t,r,i,n,a){super(t),this.path=r,this.successResponseStatusCode=i,this.requestBodyByContentType=n,this.responseBodies=a,this.safeParse()}parse(){this.examples=this.input[tQ_]}convertFormDataExampleRequest(t,r){if(t.fields!=null)switch(t.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(t.fields).map(([n,a])=>{let o=typeof r=="object"?r[n]:void 0;switch(a.multipartType){case"file":return b1i(o)?[n,{type:"filenameWithData",filename:o.filename,data:Qs.FileId(o.data)}]:o!=null?[n,{type:"filename",value:o}]:void 0;case"files":{if(Array.isArray(o)){if(o.every(c=>b1i(c)))return[n,{type:"filenamesWithData",value:o.map(c=>({filename:c.filename,data:Qs.FileId(c.data)}))}];if(o.every(c=>typeof c=="string"))return[n,{type:"filenames",value:o}]}return}case"property":return[n,{type:"json",value:o}];case void 0:return;default:new hGo.UnreachableCaseError(a.multipartType);return}}).filter(mo))};case"json":return{type:"json",value:r};case"bytes":return typeof r=="string"?{type:"bytes",value:{type:"base64",value:r}}:void 0;default:return}}convert(){if(this.examples==null)return;this.requestBodyByContentType!=null&&Object.keys(this.requestBodyByContentType).length>1&&this.context.logger.warn(`Multiple request bodies found for #/${[this.accessPath,this.pathId,"x-fern-examples"].join("/")}. Coercing to first request body until supported.`);let t=Object.keys(this.requestBodyByContentType??{})[0];return this.examples.flatMap(r=>(this.responseBodies??[]).map(i=>{let n=t!=null?this.requestBodyByContentType?.[t]:void 0,a;if(n!=null)switch(n.contentType){case"form-data":a=BQ_(r.request)?this.convertFormDataExampleRequest(n,r.request):void 0;break;case"json":a=r.request!=null?{type:"json",value:r.request}:void 0;break;case"bytes":a=typeof r.request=="string"&&r.request!=null?{type:"bytes",value:{type:"base64",value:r.request}}:void 0;break;case void 0:break;default:new hGo.UnreachableCaseError(n.contentType);break}let o;switch(i.contentType){case"application/json":{MQ_(r.response)&&(o={type:"json",value:r.response.body});break}case"text/event-stream":{Hgc(r.response)&&(o={type:"sse",value:r.response.stream.map(l=>({event:l.event,data:l.data}))});break}case"application/octet-stream":!Hgc(r.response)&&DQ_(r.response)&&(o={type:"stream",value:r.response.stream});break;case void 0:break;default:new hGo.UnreachableCaseError(i.contentType);break}let c={};r["code-samples"]?.forEach(l=>{EQ_(l)?l.language!=null&&(c[l.language]??=[],c[l.language]?.push({name:l.name,language:l.language,install:l.install,code:l.code,generated:!1,description:l.docs})):SQ_(l)&&l.sdk!=null&&(c[l.sdk]??=[],c[l.sdk]?.push({name:l.name,language:l.sdk,install:void 0,code:l.code,generated:!1,description:l.docs}))});let f=Object.fromEntries(Object.entries(r["path-parameters"]??{}).map(([l,p])=>[Qs.PropertyKey(l),p])),s=Object.fromEntries(Object.entries(r["query-parameters"]??{}).map(([l,p])=>[Qs.PropertyKey(l),p])),u=Object.fromEntries(Object.entries(r.headers??{}).map(([l,p])=>[Qs.PropertyKey(l),p]));return{path:this.path,responseStatusCode:this.successResponseStatusCode,name:r.name,description:r.docs,pathParameters:Object.keys(f).length>0?f:void 0,queryParameters:Object.keys(s).length>0?s:void 0,headers:Object.keys(u).length>0?u:void 0,requestBody:a,responseBody:o,snippets:c}}))}};var tSa=class extends $a{groupName;constructor(t){super(t),this.safeParse()}parse(){this.groupName=this.input[K9o]}convert(){if(this.groupName==null)return;let t;return Array.isArray(this.groupName)?t=this.groupName:t=[this.groupName],t.map(r=>Qs.api.v1.SubpackageId(GFt(r)))}};var bGo=class extends $a{sdkMethodName;constructor(t){super(t),this.safeParse()}parse(){this.sdkMethodName=this.input[xF_]}convert(){return this.sdkMethodName}};var vGo=class extends $a{isWebhook;constructor(t){super(t),this.safeParse()}parse(){this.isWebhook=this.input[GF_]}convert(){return this.isWebhook}};var gGo=class extends $a{codeSamples;constructor(t){super(t),this.safeParse()}parse(){this.codeSamples=[...this.input[nQ_]??[],...this.input[aQ_]??[]],this.codeSamples.forEach(t=>{[...Object.values(Qs.api.v1.read.SupportedLanguage),"Kotlin","Swift","PHP"].map(r=>r.toLowerCase()).includes(t.lang.toLowerCase())||this.context.errors.warning({message:`Unsupported language: ${t.lang}. This may not render correctly.`,path:this.accessPath})})}convert(){let t={};if(this.codeSamples?.forEach(r=>{t[r.lang.toLowerCase()]??=[],t[r.lang.toLowerCase()]?.push({name:r.label,language:r.lang,code:r.source,install:void 0,generated:!1,description:void 0})}),Object.keys(t).length!==0)return t}};var x$i=se(zE());function Kgc(e,t){return sv(e)?uU(e,t,void 0):e}function IQ_(e,t){return e.replace(/{(\w+)}/g,(r,i)=>t[i]!=null&&typeof t[i]=="string"||typeof t[i]=="number"||typeof t[i]=="boolean"?`${t[i]}`:r)}var Mz="",Z9t=class extends $a{path;responseStatusCode;name;shapes;resolvedRequestInput;resolvedResponseInput;summary;constructor(t,r,i,n,a){super(t),this.path=r,this.responseStatusCode=i,this.name=n,this.shapes=a,this.safeParse()}validateFormDataRequestExample(){return typeof this.resolvedRequestInput?.value!="object"?!1:Object.entries(this.shapes.requestBody?.fields??{}).reduce((t,[r,i])=>{let n=this.resolvedRequestInput?.value[r];switch(i.multipartType){case"file":return t&&(b1i(n)||typeof n=="string");case"files":return t&&Array.isArray(n)&&n.every(a=>b1i(a)||typeof a=="string");case"property":return t;case void 0:return t&&!1;default:return new x$i.UnreachableCaseError(i.multipartType),t}},!0)}parse(){let t=this.shapes.requestBody?.schema?.example({includeOptionals:!1,override:void 0});this.resolvedRequestInput=Kgc(this.input?.requestExample,this.context.document)??(t!=null?{value:t}:void 0);let r=this.shapes.responseBody?.schema?.example({includeOptionals:!1,override:void 0});if(this.resolvedResponseInput=Kgc(this.input?.responseExample,this.context.document)??(r!=null?{value:r}:void 0),this.summary=this.input?.requestExample?.summary??this.input?.responseExample?.summary,this.shapes.requestBody!=null&&this.resolvedRequestInput!=null)switch(this.shapes.requestBody?.contentType){case"json":{if(typeof this.resolvedRequestInput.value!="object"){this.context.errors.error({message:"Invalid example, expected object for json",path:this.accessPath});return}break}case"bytes":{if(typeof this.resolvedRequestInput.value!="string"){this.context.errors.error({message:"Invalid example, expected string for bytes",path:this.accessPath});return}break}case"form-data":{if(!this.validateFormDataRequestExample()){this.context.errors.error({message:"Invalid example, expected valid form-data",path:this.accessPath});return}break}case void 0:break;default:new x$i.UnreachableCaseError(this.shapes.requestBody?.contentType),this.context.errors.error({message:"Invalid example, unsupported content type",path:this.accessPath});return}if(this.shapes.responseBody!=null&&this.resolvedResponseInput!=null)switch(this.shapes.responseBody?.contentType){case"application/json":if(this.resolvedResponseInput!=null&&typeof this.resolvedResponseInput!="object"||this.resolvedResponseInput.value!=null&&typeof this.resolvedResponseInput.value!="object"){this.context.errors.error({message:"Invalid example, expected object for json",path:this.accessPath});return}break;case"text/event-stream":if(this.resolvedResponseInput.value!=null&&!Array.isArray(this.resolvedResponseInput.value)&&!this.resolvedResponseInput.value.every(_Go)){this.context.errors.error({message:"Invalid example, expected array of SSE events for event-stream",path:this.accessPath});return}break;case"application/octet-stream":if(this.resolvedResponseInput.value!=null&&typeof this.resolvedResponseInput.value!="string"&&!Array.isArray(this.resolvedResponseInput.value)){this.context.errors.error({message:"Invalid example, expected string or array for octet-stream",path:this.accessPath});return}break;case void 0:break;default:new x$i.UnreachableCaseError(this.shapes.responseBody?.contentType);return}}convertFormDataExampleRequest(){if(!(this.resolvedRequestInput==null||this.shapes.requestBody?.fields==null))switch(this.shapes.requestBody?.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(this.shapes.requestBody.fields).map(([r,i])=>{let n=this.resolvedRequestInput?.value?.[r];switch(i.multipartType){case"file":return b1i(n)?[r,{type:"filenameWithData",filename:n.filename,data:Qs.FileId(n.data)}]:[r,{type:"filename",value:n}];case"files":{if(Array.isArray(n)){if(n.every(a=>b1i(a)))return[r,{type:"filenamesWithData",value:n.map(a=>({filename:a.filename,data:Qs.FileId(a.data)}))}];if(n.every(a=>typeof a=="string"))return[r,{type:"filenames",value:n}]}return}case"property":return[r,{type:"json",value:n}];case void 0:return;default:new x$i.UnreachableCaseError(i.multipartType);return}}).filter(mo))};case"json":return{type:"json",value:this.resolvedRequestInput.value};case"bytes":return typeof this.resolvedRequestInput.value=="string"?{type:"bytes",value:{type:"base64",value:this.resolvedRequestInput.value}}:void 0;default:return}}convertDescription(){if(this.resolvedRequestInput!=null&&this.resolvedResponseInput!=null)return this.resolvedResponseInput.description;if(this.resolvedRequestInput!=null)return this.resolvedRequestInput.description;if(this.resolvedResponseInput!=null)return this.resolvedResponseInput.description}convert(){let t;if(this.shapes.requestBody!=null&&this.resolvedRequestInput!=null)switch(this.shapes.requestBody.contentType){case"form-data":t=this.convertFormDataExampleRequest();break;case"json":t={type:"json",value:this.resolvedRequestInput.value};break;case"bytes":t={type:"bytes",value:{type:"base64",value:this.resolvedRequestInput.value}};break;case void 0:break;default:new x$i.UnreachableCaseError(this.shapes.requestBody?.contentType);break}let r;if(this.shapes.responseBody!=null&&this.resolvedResponseInput!=null)switch(this.shapes.responseBody.contentType){case"application/json":{r={type:"json",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break}case"text/event-stream":r={type:"sse",value:this.resolvedResponseInput?.value};break;case"application/octet-stream":r={type:typeof this.resolvedResponseInput?.value=="string"?"filename":"stream",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break;case void 0:r={type:"json",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break;default:new x$i.UnreachableCaseError(this.shapes.responseBody?.contentType);break}let i=Object.fromEntries(Object.entries(this.shapes.pathParameters??{}).map(([o,c])=>[o,c.example({includeOptionals:!1,override:o})]));i=Object.keys(i).length>0?i:void 0;let n=Object.fromEntries(Object.entries(this.shapes.queryParameters??{}).map(([o,c])=>c.required||c.inputExample!=null?[o,c.example({includeOptionals:!1,override:o})]:void 0).filter(mo));n=Object.keys(n).length>0?n:void 0;let a=Object.fromEntries(Object.entries(this.shapes.requestHeaders??{}).map(([o,c])=>c.required||c.inputExample!=null?[o,c.example({includeOptionals:!1,override:o})]:void 0).filter(mo));if(a=Object.keys(a).length>0?a:void 0,!(this.path==null&&t==null&&r==null&&a==null&&n==null&&i==null))return{path:IQ_(this.path,i??{}),responseStatusCode:this.responseStatusCode,name:this.name!=null?X9t(this.name):this.summary!=null?X9t(this.summary):void 0,description:this.convertDescription(),pathParameters:i,queryParameters:n,headers:a,requestBody:t,responseBody:r,snippets:void 0}}};function CQ_(e,t){return sv(e)?uU(e,t,void 0):e}var GQ_=se(zE());var qQ_="#/components/schemas/";function KLn(e){if(e.$ref.startsWith(qQ_))return e.$ref.replace(qQ_,"")}function Vgi(e){if(e!=null)return{type:"alias",value:{type:"nullable",shape:e}}}function v1i(e){return typeof e.type=="string"&&e.type==="array"}function TQ_(e){return e.type==="boolean"}function RQ_(e){return e.type==="integer"}function g1i(e){return!Array.isArray(e.type)&&!v1i(e)}function zQ_(e){return e!=null&&Array.isArray(e)&&e.every(t=>t.type==="null"||g1i(t)||v1i(t))}function NQ_(e){return"nullable"in e&&typeof e.nullable=="boolean"}function FQ_(e){return e.type==="null"}function QQ_(e){return e.type==="number"}function Jgc(e){return e.type==null||typeof e.type=="string"&&e.type==="object"}function UQ_(e){return e.type==="string"}var OGo=class extends gK{item;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.item=new YP({input:this.input.items,context:this.context,accessPath:this.accessPath,pathId:"items",seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}),this.input.items==null&&this.context.errors.error({message:"Expected 'items' property to be specified",path:this.accessPath})}convert(){return km(this.item?.convert())?.map(r=>({type:"alias",value:{type:"list",itemShape:r}}))}example(t){return this.input.example??this.input.examples?.[0]??[this.item?.example(t)]}};var AGo=class extends LB{constValue;description;availability;constructor(t){super(t),this.safeParse()}parse(){this.input.const!=null&&(typeof this.input.const=="string"||typeof this.input.const=="number"||typeof this.input.const=="boolean")?this.constValue=this.input.const.toString():this.context.errors.warning({message:`Unsupported const type: ${typeof this.input}`,path:this.accessPath}),this.description=this.input.description,this.availability=new wPe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"})}convert(){if(this.constValue!=null)return{type:"enum",default:this.constValue,values:[{value:this.constValue,description:this.description,availability:this.availability?.convert()}]}}example(){return this.input.example??this.input.examples?.[0]??this.constValue}};var mGo=class extends gK{typeNodes;nullable;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.parse()}parse(){this.typeNodes=this.input.map(t=>{if(t.type==="null")this.nullable=!0;else return new YP({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName})}).filter(mo)}convert(){if(this.typeNodes==null)return;let i=this.typeNodes.map(n=>km(n.convert())?.map(o=>({displayName:n.name,shape:o,description:n.description,availability:n.availability?.convert()}))).filter(mo).reduce((n,a)=>n.flatMap(o=>a.length>0?a.map(c=>[...o,c]):[[...o]]),[[]]).map(n=>({type:"undiscriminatedUnion",variants:n}));return this.nullable?i.map(Vgi).filter(mo):i}example(t){return this.nullable?null:this.typeNodes?.[0]?.example(t)}};function PGo(e){return e!=null&&e.length>0?e:[void 0]}var JLn=class extends gK{description;extends=[];properties;extraProperties;requiredProperties;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.extends=[],this.requiredProperties=this.input.required,this.properties=Object.fromEntries(Object.entries(this.input.properties??{}).map(([t,r])=>[t,new YP({input:r,context:this.context,accessPath:this.accessPath,pathId:["properties",t],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})])),this.extraProperties=this.input.additionalProperties!=null?typeof this.input.additionalProperties=="boolean"?this.input.additionalProperties?this.input.title:void 0:new YP({input:this.input.additionalProperties,context:this.context,accessPath:this.accessPath,pathId:["additionalProperties"],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0,this.input.allOf!=null&&(this.extends=this.extends.concat(this.input.allOf.map((t,r)=>{if(sv(t))return KLn(t);this.properties={...this.properties,...Object.fromEntries(Object.entries(t.properties??{}).map(([i,n])=>[i,new YP({input:n,context:this.context,accessPath:this.accessPath,pathId:["allOf",r.toString(),"properties",i],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))}}).filter(mo))),this.description=this.input.description}convertProperties(){if(this.properties!=null)return HLn(this.properties,this.requiredProperties)}convertExtraProperties(){return this.extraProperties==null?void 0:typeof this.extraProperties=="string"?[{type:"map",keyShape:{type:"alias",value:{type:"primitive",value:{type:"string",format:void 0,regex:void 0,minLength:void 0,maxLength:void 0,default:void 0}}},valueShape:{type:"alias",value:{type:"unknown",displayName:this.extraProperties}}}]:km(this.extraProperties.convert())?.map(r=>({type:"map",keyShape:{type:"alias",value:{type:"primitive",value:{type:"string",format:void 0,regex:void 0,minLength:void 0,maxLength:void 0,default:void 0}}},valueShape:r})).filter(mo)}convert(){let t=this.convertProperties();if(t==null)return;let r=this.convertExtraProperties();return t.flatMap(i=>PGo(r).map(n=>(this.extends==null||this.extends.length===0)&&i.length===0&&n!=null?{type:"alias",value:n}:{type:"object",extends:this.extends.map(a=>Qs.TypeId(a)),properties:i,extraProperties:n}))}example({includeOptionals:t}){let r={...this.properties};return this.input.allOf?.forEach(i=>{let n=VB(i,this.context.document);n!=null&&(r={...r,...Object.fromEntries(Object.entries(n.properties??{}).map(([a,o])=>[a,new YP({input:o,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))})}),this.input.example??this.input.examples?.[0]??(!t&&this.requiredProperties!=null&&this.requiredProperties.length>0?this.requiredProperties?.reduce((i,n)=>{let a=r?.[n];return i[n]=a?.example({includeOptionals:t,override:n}),i},{}):Object.entries(r).reduce((i,[n,a])=>(i[n]=a?.example({includeOptionals:t,override:n}),i),{}))}};var jGo=class extends gK{isNullable;discriminated;discriminant;discriminatedMapping;undiscriminatedMapping;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){if(this.input.oneOf!=null||this.input.anyOf!=null)if(this.isNullable=(this.input.oneOf??this.input.anyOf)?.some(t=>VB(t,this.context.document)?.type==="null"),this.input.discriminator==null)this.discriminated=!1,this.undiscriminatedMapping=(this.input.oneOf??this.input.anyOf)?.map(t=>VB(t,this.context.document)?.type!=="null"?new YP({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0).filter(mo);else{let t=this.input.discriminator.mapping;if(t!=null){this.discriminated=!0,this.discriminant=this.input.discriminator.propertyName,this.discriminatedMapping={};let r=this.discriminatedMapping;Object.entries(t).map(([i,n])=>{let a=VB({$ref:n},this.context.document);if(a==null){this.context.errors.warning({message:`Expected schema reference. Received undefined reference: ${n}`,path:[...this.accessPath,"discriminator","mapping",i]});return}r[i]=new YP({input:a,context:this.context,accessPath:[...this.accessPath,"discriminator","mapping",i],pathId:i,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})})}}}convert(){if(!this.discriminated&&this.undiscriminatedMapping?.length===1){let n=this.undiscriminatedMapping?.flatMap(a=>a.convert()).filter(mo);return this.isNullable&&n!=null?n.map(Vgi).filter(mo):n}let t=0,r=this.discriminated&&this.discriminant!=null&&this.discriminatedMapping!=null?{type:"discriminatedUnion",discriminant:Qs.PropertyKey(this.discriminant),variants:Object.entries(this.discriminatedMapping).flatMap(([n,a])=>km(a.convert())?.map(c=>{if(!(c==null||c.type!=="object"))return{discriminantValue:n,displayName:a.name??X9t(n),availability:a.availability?.convert(),description:a.description,...c}}).filter(mo)).filter(mo)}:this.undiscriminatedMapping!=null?{type:"undiscriminatedUnion",variants:this.undiscriminatedMapping.flatMap(n=>km(n.convert())?.map(o=>{if(o==null)return;t+=1;let c=o.type==="object"?X9t(`${this.schemaName??"Variant"} ${t}`):void 0;return{displayName:n.name??(o.type==="alias"&&o.value.type==="id"?X9t(o.value.id):c),shape:o,description:n.description,availability:n.availability?.convert()}}).filter(mo)).filter(mo)}:void 0,i=this.isNullable?Vgi(r):r;return i!=null?[i]:void 0}example(t){return this.input.example??this.input.examples?.[0]??this.undiscriminatedMapping?.[0]?.example(t)??Object.values(this.discriminatedMapping??{})[0]?.example(t)}};var wGo=class extends LB{default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.input.default!=null&&typeof this.input.default!="boolean"&&this.context.errors.warning({message:`Expected default value to be a boolean. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default}convert(){return{type:"alias",value:{type:"primitive",value:{type:"boolean",default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:!1)}};var O1i=class extends LB{default;values=[];nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){if(this.input.enum!=null){let t=!0;this.values=this.input.enum.map((r,i)=>{if(t){if(sv(r)){let n=VB(r,this.context.document);r=typeof n=="string"?n:typeof n?.default=="string"?n?.default:typeof n?.example=="string"?n.example:void 0}if(typeof r!="string"){this.context.errors.error({message:`Expected enum values to be strings. Received ${r}`,path:[...this.accessPath,`enum[${i}]`]}),t=!1;return}return r}}).filter(mo),this.values=Array.from(new Set(this.values))}this.default=this.input.default}convert(){return{type:"enum",values:this.values.map(t=>({value:t,description:void 0,availability:void 0})),default:this.default}}example(){return this.input.example??this.input.examples?.[0]??this.default??this.values[0]??(this.nullable?null:void 0)}};var LQ_=se(zE());function oQM(e){return Wgc.includes(e)}var EGo=class extends LB{format;minimum;maximum;default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.minimum=this.input.minimum,this.maximum=this.input.maximum,this.input.default!=null&&typeof this.input.default!="number"&&this.context.errors.warning({message:`Expected default value to be an integer. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(oQM(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${Wgc.join(", ")}. Received ${this.input.format}`,path:this.accessPath}))}convert(){let t="integer";if(this.format!=null)switch(this.format){case"int64":t="long";break;case"int8":case"int16":case"int32":case"uint8":case"sf-integer":case void 0:t="integer";break;default:new LQ_.UnreachableCaseError(this.format);break}return{type:"alias",value:{type:"primitive",value:{type:t,minimum:this.minimum,maximum:this.maximum,default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:0)}};var SGo=class extends LB{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){this.displayName=this.input.title}convert(){return Vgi({type:"alias",value:{type:"unknown",displayName:this.displayName}})}example(){return null}};var VQ_=se(zE());function uQM(e){return Vgc.includes(e)}var MGo=class extends LB{format;minimum;maximum;default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.minimum=this.input.minimum,this.maximum=this.input.maximum,this.input.default!=null&&typeof this.input.default!="number"&&this.context.errors.warning({message:`Expected default value to be a number. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(uQM(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${Vgc.join(", ")}. Received ${this.input.format}`,path:this.accessPath}))}convert(){let t="double";if(this.format!=null)switch(this.format){case"decimal":case"decimal128":case"double-int":case"double":case"float":case"sf-decimal":case void 0:t="double";break;default:new VQ_.UnreachableCaseError(this.format);break}return{type:"alias",value:{type:"primitive",value:{type:t,minimum:this.minimum,maximum:this.maximum,default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:0)}};var WQ_=se(zE());function sQM(e){return xgc.includes(e)}var DGo=class extends LB{format;regex;default;minLength;maxLength;enum;mimeType;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}mapToFdrType(t){switch(t){case"base64url":case"binary":case"byte":case"sf-binary":return"base64";case"date-time":return"datetime";case"int64":return"bigInteger";case"date":return"date";case"uuid":return"uuid";case"char":case"commonmark":case"decimal":case"decimal128":case"duration":case"email":case"hostname":case"html":case"http-date":case"idn-email":case"idn-hostname":case"ipv4":case"ipv6":case"iri-reference":case"iri":case"json-pointer":case"media-range":case"password":case"regex":case"relative-json-pointer":case"sf-boolean":case"sf-string":case"sf-token":case"time":case"uri-reference":case"uri-template":case"uri":case void 0:return"string";default:return new WQ_.UnreachableCaseError(t),"string"}}parse(){this.regex=this.input.pattern,this.minLength=this.input.minLength,this.maxLength=this.input.maxLength,this.mimeType=this.input.contentMediaType,this.input.default!=null&&typeof this.input.default!="string"&&this.context.errors.warning({message:`Expected default value to be a string. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(sQM(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${xgc.join(", ")}. Received ${this.input.format}`,path:this.accessPath})),this.input.enum!=null&&(this.enum=new O1i({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"enum",nullable:this.nullable}))}convert(){if(this.enum!=null)return this.enum.convert();let t="string";return this.format!=null&&(t=this.mapToFdrType(this.format)),{type:"alias",value:{type:"primitive",value:t==="base64"?{type:t,mimeType:this.mimeType,default:this.default}:{type:t,format:t==="string"?this.format:void 0,regex:this.regex,minLength:this.minLength,maxLength:this.maxLength,default:this.default}}}}example({override:t}){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:t??"string")}};var xQ_=se(zE());var BGo=class extends LB{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){(0,xQ_.noop)()}convert(){return{type:"alias",value:{type:"unknown",displayName:void 0}}}example(){}};var G$i=class extends gK{description;availability;schemaId;maybeEnumConverterNode;nullable;schemaName;constructor(t){super(t),this.nullable=t.nullable,this.schemaName=t.schemaName,this.description=t.description,this.availability=t.availability,this.safeParse()}parse(){this.schemaId=KLn(this.input);let t=VB(this.input,this.context.document);t?.enum!=null&&g1i(t)&&(this.maybeEnumConverterNode=new O1i({input:t,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",nullable:this.nullable})),this.schemaId==null&&this.context.errors.error({message:`Unprocessable reference: ${this.input.$ref}`,path:this.accessPath})}convert(){if(this.schemaId!=null)return{type:"alias",value:{type:"id",id:Qs.TypeId(this.schemaId),default:this.maybeEnumConverterNode?.default!=null?{type:"enum",value:this.maybeEnumConverterNode.default}:void 0}}}example(t){let r=VB(this.input,this.context.document);if(r!=null)return new YP({input:r,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName}).example(t)}};var YP=class e extends gK{typeShapeNode;description;name;examples;availability;nullable;schemaName;constructor(t){super(t),this.nullable=t.nullable,this.schemaName=t.schemaName,this.safeParse()}parse(){if(this.description=this.input.description,this.availability=new wPe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),g1i(this.input)&&NQ_(this.input)&&(this.nullable=this.input.nullable!=null?this.input.nullable:this.nullable),sv(this.input)){let t=KLn(this.input);if(t==null){this.context.errors.error({message:"Reference object does not have a valid schema ID",path:this.accessPath});return}if(this.seenSchemas.has(t)){this.context.errors.warning({message:"Circular or deeply nested schema found, terminating",path:this.accessPath});return}this.seenSchemas.add(t),this.typeShapeNode=new G$i({input:this.input,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName,description:this.description,availability:this.availability})}else if(this.name=this.input.title,this.examples=this.input.example,this.input.const!=null)this.typeShapeNode=new AGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});else if(zQ_(this.input))this.typeShapeNode=new mGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(g1i(this.input)&&(this.input.oneOf!=null||this.input.anyOf!=null))this.typeShapeNode=new jGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(Jgc(this.input)&&this.input.allOf!=null)this.typeShapeNode=new JLn({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(g1i(this.input)&&this.input.enum!=null)this.typeShapeNode=new O1i({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable});else if(typeof this.input.type=="string"||Array.isArray(this.input.type)&&this.input.type.length===1){if(this.input.type=Array.isArray(this.input.type)?this.input.type[0]:this.input.type,!Array.isArray(this.input.type))switch(this.input.type){case"object":Jgc(this.input)&&(this.typeShapeNode=new JLn({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"array":v1i(this.input)&&(this.typeShapeNode=new OGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"boolean":TQ_(this.input)&&(this.typeShapeNode=new wGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"integer":RQ_(this.input)&&(this.typeShapeNode=new EGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"number":QQ_(this.input)&&(this.typeShapeNode=new MGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"string":UQ_(this.input)&&(this.typeShapeNode=new DGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"null":FQ_(this.input)&&(this.typeShapeNode=new SGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}));break;case void 0:break;default:new GQ_.UnreachableCaseError(this.input.type);break}}else if(Array.isArray(this.input.type)&&this.input.type.includes("null")&&this.input.type.length===2){let t=this.input.type.filter(r=>r!=="null")[0];t!=="array"&&(this.typeShapeNode=new e({input:{...this.input,type:t},context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:!0,schemaName:this.schemaName}))}else this.input.properties!=null&&(this.typeShapeNode=new JLn({input:{...this.input,type:"object"},context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));this.typeShapeNode==null&&(this.typeShapeNode=new BGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),!sv(this.input)&&(!v1i(this.input)&&this.input==null||v1i(this.input)&&this.input.items==null)&&this.context.errors.error({message:"Expected type declaration. Received: null",path:this.accessPath}))}convert(){let t=this.typeShapeNode?.convert();if(t==null)return;let r=km(t)?.map(i=>this.nullable?Vgi(i):i).filter(mo);return Array.isArray(t)&&t.length>1?r:r?.[0]}example(t){return this.availability?.availability!=="deprecated"?this.typeShapeNode?.example(t):void 0}};function A1i(e){if(e!=null)return HLn(e,Object.entries(e??{}).map(([t,r])=>r.required?t:void 0).filter(mo))}var k9t=class extends LB{availability;required;schema;description;inputExample;constructor(t){super(t),this.safeParse(t.parameterName)}parse(t){this.description=this.input.description;let r;sv(this.input)?r=this.input:this.input.schema!=null?(r=this.input.schema,this.required=this.input.required):(r={type:"string"},this.required=!1),this.availability=new wPe({input:r,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=new YP({input:r,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:t});let i=CQ_(this.input,this.context.document);this.inputExample=i?.example??Object.values(i?.examples??{})[0]}convert(){return this.schema?.convert()}example(t){return this.inputExample??this.schema?.example(t)}};function HQ_(e,t){return sv(e)?uU(e,t,void 0):e}var $gc=se(zE());function IGo(e){let{uniqueId:t,type:r,contextTypes:i,description:n,availability:a}=e;i[Qs.TypeId(t)]={name:t,shape:r,description:n,availability:a}}var KQ_=se(Xjs(),1),$Ln=class e{type;subtype;essence;parameters;mimeType;input;constructor(t,r,i,n,a,o){this.type=t,this.subtype=r,this.essence=i,this.parameters=n,this.mimeType=a,this.input=o}static APPLICATION_JSON="application/json";static APPLICATION_OCTET_STREAM="application/octet-stream";static MULTIPART_FORM_DATA="multipart/form-data";static parse(t){if(t==null)return null;let r=KQ_.default.parse(t);return r==null?null:new e(r.type,r.subtype,r.essence,r.parameters,r,t)}toString(){return this.input}isText(){return this.type==="text"}isImage(){return this.type==="image"}isAudio(){return this.type==="audio"}isVideo(){return this.type==="video"}isFont(){return this.type==="font"}isMultipart(){return this.type==="multipart"}isApplication(){return this.type==="application"}isMessage(){return this.type==="message"}isModel(){return this.type==="model"}isCSS(){return this.isText()&&this.subtype==="css"}isCSV(){return this.isText()&&this.subtype==="csv"}isMarkdown(){return this.isText()&&this.subtype==="markdown"}isPlainText(){return this.isText()&&this.subtype==="plain"}isEventStream(){return this.isText()&&this.subtype==="event-stream"}isMultiPartFormData(){return this.isMultipart()&&this.subtype==="form-data"}isJSON(){return this.isApplication()&&this.subtype==="json"}containsJSON(){return this.isApplication()&&this.subtype.includes("json")}isURLEncoded(){return this.isApplication()&&this.subtype==="x-www-form-urlencoded"}isOctetStream(){return this.isApplication()&&this.subtype==="octet-stream"}isPDF(){return this.isApplication()&&this.subtype==="pdf"}isZip(){return this.isApplication()&&this.subtype==="zip"}isGzip(){return this.isApplication()&&this.subtype==="gzip"}isTar(){return this.isApplication()&&this.subtype==="tar"}isBrotli(){return this.isApplication()&&this.subtype==="br"}isDeflate(){return this.isApplication()&&this.subtype==="deflate"}isProtobuf(){return this.isApplication()&&this.subtype==="protobuf"}isAvif(){return this.isImage()&&this.subtype==="avif"}isWebP(){return this.isImage()&&this.subtype==="webp"}isSVG(){return this.isImage()&&this.subtype==="svg+xml"}isPNG(){return this.isImage()&&this.subtype==="png"}isJPEG(){return this.isImage()&&this.subtype==="jpeg"}isGIF(){return this.isImage()&&this.subtype==="gif"}isMPEG(){return this.isAudio()&&this.subtype==="mpeg"}isWAV(){return this.isAudio()&&this.subtype==="wav"}isHTML(){return this.mimeType.isHTML()}isXML(){return this.mimeType.isXML()}isJavaScript(){return this.mimeType.isJavaScript()}};function cQM(e){return typeof e.securitySchemes=="object"&&e.securitySchemes!=null}var CGo=class extends $a{typeSchemas;securitySchemes;constructor(t){super(t),this.safeParse()}parse(){this.input.schemas!=null&&(this.typeSchemas=Object.fromEntries(Object.entries(this.input.schemas).map(([t,r])=>[t,new YP({input:r,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:new Set,nullable:void 0,schemaName:t})]))),cQM(this.input)&&this.input.securitySchemes!=null&&(this.securitySchemes=Object.fromEntries(Object.entries(this.input.securitySchemes??{}).map(([t,r],i)=>{let n;if(sv(r)?n=Y9o(r.$ref,this.context.document):n=r,n!=null)return[t,new xLn({input:n,context:this.context,accessPath:this.accessPath,pathId:["securitySchemes",`${i}`]})]}).filter(mo)))}convert(){return{auths:this.securitySchemes!=null?Object.fromEntries(Object.entries(this.securitySchemes??{}).map(([t,r])=>{let i=r.convert();if(i!=null)return[Qs.api.latest.AuthSchemeId(t),i]}).filter(mo)):void 0,types:this.typeSchemas!=null?Object.fromEntries(Object.entries(this.typeSchemas).map(([t,r])=>{let i=r.name??t,n=km(r.convert());return n==null?[t,void 0]:[Qs.TypeId(t),{name:i,shape:n[0],description:r.description,availability:void 0}]}).filter(([t,r])=>mo(r))):void 0}}};var qGo=class extends YP{multipartType;contentType;constructor(t){super(t),this.safeParse()}parse(){super.parse();let t=VB(this.input,this.context.document);if(t==null){this.context.errors.error({message:`Expected multipart form data property definition. ${sv(this.input)?`Received undefined reference: ${this.input.$ref}`:""}`,path:this.accessPath});return}if(t.type==="string"&&t.format==="binary")this.multipartType="file",this.contentType=t.contentMediaType;else if(t.type==="array"){let r=VB(t.items,this.context.document);r?.type==="string"&&r?.format==="binary"?(this.multipartType="files",this.contentType=r?.contentMediaType):(this.context.errors.warning({message:"Expected multipart form data files definition with array type with internal string type and binary format.",path:this.accessPath}),this.multipartType=void 0,this.contentType=void 0)}else this.multipartType="property",this.contentType=t.contentMediaType}};var TGo=class extends $a{description;method;path;schema;isOptional;contentType;availability;requiredFields;fields;examples;constructor(t){super(t),this.method=t.method,this.path=t.path,this.safeParse(t)}parse({contentType:t}){if(this.input.schema!=null){let i=VB(this.input.schema,this.context.document);this.availability=new wPe({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=sv(this.input.schema)?new G$i({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:!1,schemaName:"Request Body",description:this.input.schema.description,availability:this.availability}):void 0;let n=$Ln.parse(t);n?.containsJSON()?(this.contentType="json",this.schema=this.schema??new YP({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:"Request Body"})):n?.isOctetStream()?(this.contentType="bytes",this.isOptional=i?.required==null):n?.isMultiPartFormData()?(this.contentType="form-data",this.requiredFields=i?.required,this.fields=Object.fromEntries(Object.entries(i?.properties??{}).map(([a,o])=>{if(o!=null)return[a,new qGo({input:o,context:this.context,accessPath:this.accessPath,pathId:`schema.${a}`,seenSchemas:new Set,nullable:void 0,schemaName:a})]}).filter(mo))):this.context.errors.warning({message:`Expected request body of reference or object with json, streaming or form-data content types. Received: ${t}`,path:this.accessPath})}let r=this.schema?.example({includeOptionals:!0,override:void 0});this.examples={...this.input.example!=null?{[Mz]:{value:this.input.example}}:{},...this.input.examples},r!=null&&Object.keys(this.examples).length===0&&(this.examples={[Mz]:{value:r}})}convertJsonLike(){let t=this.schema?.convert();return t==null?void 0:km(t)?.map(i=>{let n=i.type;switch(n){case"object":case"alias":return i;case"enum":case"undiscriminatedUnion":case"discriminatedUnion":{let a=GFt([this.method,this.path,this.contentType,"request"].join("_"));return IGo({uniqueId:a,type:i,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:Qs.TypeId(a),default:i.type==="enum"&&i.default!=null?{type:"enum",value:i.default}:void 0}}}case void 0:return;default:new $gc.UnreachableCaseError(n);return}}).filter(mo)}convert(){if(this.schema instanceof G$i)return this.schema.convert();switch(this.contentType){case"json":return this.convertJsonLike();case"bytes":return{type:"bytes",isOptional:this.isOptional??!1,contentType:this.contentType};case"form-data":return Object.entries(this.fields??{}).map(([i,n])=>{switch(n.multipartType){case"file":return[{type:n.multipartType,key:Qs.PropertyKey(i),isOptional:this.requiredFields?.includes(i)==null,contentType:n.contentType,description:n.description,availability:n.availability?.convert()}];case"files":return[{type:n.multipartType,key:Qs.PropertyKey(i),isOptional:this.requiredFields?.includes(i)==null,contentType:n.contentType,description:n.description,availability:n.availability?.convert()}];case"property":{let a=km(n.convert()),o=n.multipartType;return a?.map(c=>({type:o,key:Qs.PropertyKey(i),contentType:n.contentType,exploded:void 0,valueShape:c,description:n.description,availability:n.availability?.convert()}))}case void 0:return[];default:return new $gc.UnreachableCaseError(n.multipartType),[]}}).filter(mo).reduce((i,n)=>i.flatMap(a=>n.length>0?n.map(o=>[...a,o]):[[...a]]),[[]]).map(i=>({type:"formData",fields:i,availability:this.availability?.convert(),description:this.description}));case void 0:return this.convertJsonLike();default:return}}};var RGo=class extends $a{description;requestBodiesByContentType;constructor(t){super(t),this.safeParse(t)}parse({method:t,path:r}){let i=HQ_(this.input,this.context.document);if(i==null){this.context.errors.error({message:"Expected request body. Received: null",path:this.accessPath});return}Object.entries(i.content).forEach(([n,a])=>{this.requestBodiesByContentType??={},this.requestBodiesByContentType[n]=new TGo({input:a,context:this.context,accessPath:this.accessPath,pathId:"content",contentType:n,method:t,path:r})})}convert(){return Object.entries(this.requestBodiesByContentType??{}).flatMap(([t,r])=>km(r.convert())?.map(n=>({description:this.description,contentType:t,body:n}))).filter(mo)}convertToWebhookPayload(){return Object.values(this.requestBodiesByContentType??{}).flatMap(t=>km(t.convert())?.map(i=>{if(!(i.type!=="alias"&&i.type!=="object"))return{description:this.description,shape:i}})).filter(mo)}webhookExample(){return{payload:this.requestBodiesByContentType?.["application/json"]?.schema?.example({includeOptionals:!0,override:void 0})}}};var JQ_={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"};function $Q_(e,t){if(sv(e)){let r=uU(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var zGo=se(zE());var YQ_="application/json";var XQ_="application/octet-stream";function ZQ_(e,t){return e===t||t===Mz||e===Mz}var rSa=class extends $a{streamingFormat;path;method;statusCode;requests;shapes;schema;contentType;unsupportedContentType;contentSubtype;examples;empty;constructor(t,r,i,n,a,o,c,f){super(t),this.streamingFormat=i,this.path=n,this.method=a,this.statusCode=o,this.requests=c,this.shapes=f,this.safeParse(r)}matchRequestResponseExamplesByName(t,r,i){for(let n of t)for(let[a,o]of Object.entries(n?.examples??{}))for(let[c,f]of Object.entries(r))for(let s of f)ZQ_(c,a)&&(i.add(c),this.examples?.push(new Z9t({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,y1i(a,c),{requestBody:n,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}matchExamplesByIndex(t,r){let i=0;for(let n of t){let a=0;for(let[o,c]of r){if(a===i){let[f,s,u]=n??[void 0,void 0,void 0];this.examples?.push(...c.map(l=>new Z9t({input:{requestExample:u,responseExample:l},context:this.context,accessPath:this.accessPath,pathId:s!=null&&s!==""?["examples",s]:"examples"},this.path,this.statusCode,y1i(s,o),{requestBody:f,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}a++}i++}if(t.length>r.length)for(let n of t.slice(r.length)){let[a,o]=r[r.length-1]??[void 0,void 0],[c,f,s]=n??[void 0,void 0,void 0];this.examples?.push(...(o??[void 0]).map(u=>new Z9t({input:{requestExample:s,responseExample:u},context:this.context,accessPath:this.accessPath,pathId:f!=null&&f!==""?["examples",f]:"examples"},this.path,this.statusCode,y1i(f,a),{requestBody:c,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}if(r.length>t.length){let[n,a,o]=t[t.length-1]??[void 0,void 0,void 0];for(let[c,f]of r.slice(t.length))this.examples?.push(...f.map(s=>new Z9t({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,y1i(a,c),{requestBody:n,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}}pushResponseExample(t,r,i,n){let a=t[Mz];if(a!=null)for(let o of a)this.examples?.push(new Z9t({input:{requestExample:n,responseExample:o},context:this.context,accessPath:this.accessPath,pathId:i!=null&&i!==""?["examples",i]:"examples"},this.path,this.statusCode,y1i(i,void 0),{requestBody:r,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders}))}addGlobalFallbackExample(t,r){if(t==null||t.length===0)this.pushResponseExample(r,void 0,void 0,void 0);else for(let i of t)if(Object.keys(i.examples??{}).length===0)this.pushResponseExample(r,i,void 0,void 0);else for(let[n,a]of Object.entries(i.examples??{}))this.pushResponseExample(r,i,n,a)}parse(t){if(t==="empty")this.empty=!0;else{let c=$Ln.parse(t);if(c?.isJSON()||c?.isEventStream())this.contentType=YQ_,this.input.schema==null?(this.streamingFormat==null||this.streamingFormat==="json")&&this.context.errors.error({message:"Expected schema for JSON response body. Received null",path:this.accessPath}):this.schema=new YP({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"type",seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"});else if(c?.isOctetStream())this.contentType=XQ_,this.contentSubtype=VB(this.input.schema,this.context.document)?.contentMediaType;else if(this.unsupportedContentType=t,this.input.schema==null){this.context.errors.error({message:"Expected schema for plain text response body. Received null",path:this.accessPath});return}else this.schema=new YP({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"})}let r={};this.input.examples!=null&&(r=sGo(this.input.examples,c=>[c])),this.input.example!=null&&Object.keys(r).length===0&&(r[Mz]??=[],r[Mz]=[{value:this.input.example}]);let i=VB(this.input.schema,this.context.document);if(i!=null&&(i.examples!=null&&Object.keys(r).length===0&&(r=sGo(i.examples,c=>[c])),i.example!=null&&Object.keys(r).length===0&&(r[Mz]??=[],r[Mz]?.push({value:i.example}))),Object.keys(r).length===0){let c=this.schema?.example({includeOptionals:!0,override:void 0});r[Mz]??=[],r[Mz]?.push(c!=null?{value:c}:void 0)}this.examples??=[];let n=new Set;this.matchRequestResponseExamplesByName(this.requests,r,n);let a=[];for(let c of this.requests)a.push(...Object.entries(c.examples??{}).filter(([f])=>!n.has(f)&&f!==Mz).map(([f,s])=>[c,f,s]));let o=Object.entries(r).filter(([c,f])=>!n.has(c)&&mo(f)&&c!==Mz);Object.keys(r).every(c=>c===Mz)||this.matchExamplesByIndex(a,o),!n.has(Mz)&&this.examples.length===0&&this.addGlobalFallbackExample(this.requests,r),this.examples.length===0&&(this.examples=void 0)}convertStreamingFormat(){switch(this.streamingFormat){case"json":return km(this.schema?.convert())?.map(r=>({type:"stream",terminator:"[DATA]",shape:r}));case"sse":return{type:"streamingText"};case void 0:return;default:new zGo.UnreachableCaseError(this.streamingFormat);return}}convertJsonLike(){return km(this.schema?.convert())?.map(r=>{let i=r.type;switch(i){case"alias":return r;case"discriminatedUnion":case"undiscriminatedUnion":case"enum":{let n=GFt([this.method,this.path,this.statusCode,"response"].join("_"));return IGo({uniqueId:n,type:r,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:Qs.TypeId(n),default:r.type==="enum"&&r.default!=null?{type:"enum",value:r.default}:void 0}}}case"object":return r;default:new zGo.UnreachableCaseError(i);return}}).filter(mo)}convert(){if(this.empty)return{type:"empty"};if(this.contentType!=null)switch(this.contentType){case"application/json":return this.streamingFormat==null?this.convertJsonLike():this.convertStreamingFormat();case"application/octet-stream":return{type:"fileDownload",contentType:this.contentSubtype};case"text/event-stream":return this.convertStreamingFormat();case void 0:return;default:new zGo.UnreachableCaseError(this.contentType);return}else return this.unsupportedContentType!=null?this.convertJsonLike():void 0}};var iSa=class extends $a{path;method;statusCode;requests;shapes;headers;responses;description;constructor(t,r,i,n,a,o){super(t),this.path=r,this.method=i,this.statusCode=n,this.requests=a,this.shapes=o,this.safeParse()}parse(t){this.description=this.input.description;let r=$Q_(this.input,this.context.document);if(r==null){this.context.errors.error({message:sv(this.input)?`Undefined reference: ${this.input.$ref}`:"Expected response, received null",path:this.accessPath});return}Object.entries(r.headers??{}).forEach(([i,n])=>{this.headers??={},this.headers[i]=new k9t({input:n,context:this.context,accessPath:this.accessPath,pathId:"headers",parameterName:i})}),r.content==null?(this.responses??=[],this.responses.push(new rSa({input:{},context:this.context,accessPath:this.accessPath,pathId:["content"]},"empty",t,this.path,this.method,this.statusCode,this.requests,this.shapes))):Object.entries(r.content??{}).forEach(([i,n])=>{this.responses??=[],this.responses.push(new rSa({input:n,context:this.context,accessPath:this.accessPath,pathId:["content",i]},i,t,this.path,this.method,this.statusCode,this.requests,this.shapes))})}convert(){return this.responses?.flatMap(t=>t.convert()).filter(mo)}};var NGo=class extends $a{path;method;requests;shapes;responsesByStatusCode;errorsByStatusCode;constructor(t,r,i,n,a){super(t),this.path=r,this.method=i,this.requests=n,this.shapes=a,this.safeParse()}parse(){let t=this.input.default;Object.entries(this.input).forEach(([r,i])=>{r!=="default"&&(parseInt(r)>=400?(this.errorsByStatusCode??={},this.errorsByStatusCode[r]=new iSa({input:{...t,...i},context:this.context,accessPath:this.accessPath,pathId:"errors"},this.path,this.method,parseInt(r),[],this.shapes)):(this.responsesByStatusCode??={},this.responsesByStatusCode[r]=new iSa({input:i,context:this.context,accessPath:this.accessPath,pathId:"responses"},this.path,this.method,parseInt(r),this.requests,this.shapes)))})}convertResponseObjectToHttpResponses(){return Object.entries(this.responsesByStatusCode??{}).flatMap(([t,r])=>{let i=r.convert();if(i!=null)return PGo(A1i(r.headers)).flatMap(n=>i?.map(a=>({headers:n,response:{statusCode:parseInt(t),body:a,description:r.description},examples:(r.responses??[]).flatMap(o=>(o.examples??[]).map(c=>c.convert()).filter(mo))})))}).filter(mo)}convertResponseObjectToErrors(){return Object.entries(this.errorsByStatusCode??{}).flatMap(([t,r])=>r.responses?.flatMap(i=>{let n=i.schema,a=km(n?.convert());if(n!=null)return a?.map(o=>({statusCode:parseInt(t),shape:o,description:r.description??n.description,availability:n.availability?.convert(),name:n.name??JQ_[parseInt(t)]??"UNKNOWN ERROR",examples:i.examples?.map(c=>{let f=c.convert();if(f!=null&&f.responseBody?.type==="json")return{name:f.name,description:f.description,responseBody:f.responseBody}}).filter(mo)})).filter(mo)})).filter(mo)}convert(){return{responses:this.convertResponseObjectToHttpResponses(),errors:this.convertResponseObjectToErrors()}}};var m1i=class extends $a{servers;globalAuth;path;method;basePath;isWebhook;endpointIds;description;displayName;operationId;pathParameters;queryParameters;requestHeaders;requests;responses;availability;auth;namespaces;xFernExamplesNode;redocExamplesNode;emptyResponseExamples;constructor(t){super(t),this.servers=t.servers,this.globalAuth=t.globalAuth,this.path=t.path,this.method=t.method,this.basePath=t.basePath,this.isWebhook=t.isWebhook,this.safeParse()}pushEmptyResponseExample(t,r,i){this.emptyResponseExamples??=[],this.emptyResponseExamples.push(new Z9t({input:{requestExample:t,responseExample:void 0},context:this.context,accessPath:this.accessPath,pathId:"examples"},this.path,200,y1i(i,void 0),{requestBody:r,pathParameters:this.pathParameters,queryParameters:this.queryParameters,requestHeaders:this.requestHeaders}))}parse(){if(this.isWebhook&&this.method!=="POST"&&this.method!=="GET"){this.context.errors.error({message:`Webhook method must be POST or GET. Received: ${this.method}`,path:this.accessPath});return}this.description=this.input.description,this.displayName=this.input.summary,this.operationId=this.input.operationId,this.availability=new wPe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),this.servers=h1i(this.servers,this.input.servers,this.context,this.accessPath),this.isWebhook=new vGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}).isWebhook||this.isWebhook,this.input.parameters?.map((i,n)=>{if(sv(i)){let a=pGo(i,this.context.document);if(a!=null)i=a;else{this.context.errors.warning({message:`Expected parameter reference to resolve to an object. Received undefined reference: ${i.$ref}`,path:[...this.accessPath,`parameters[${n}]`]});return}}i.in==="path"?i.schema!=null&&(this.pathParameters??={},this.pathParameters[i.name]=new k9t({input:i,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${n}`],parameterName:i.name})):i.in==="query"?i.schema!=null&&(this.queryParameters??={},this.queryParameters[i.name]=new k9t({input:i,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${n}`],parameterName:i.name})):i.in==="header"&&i.schema!=null&&(this.requestHeaders??={},this.requestHeaders[i.name]=new k9t({input:i,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${n}`],parameterName:i.name}))});for(let i of this.extractPathParameterIds()??[])this.pathParameters?.[i]==null&&this.context.errors.warning({message:`Path parameter not defined: ${i}`,path:[...this.accessPath,"parameters"]});if(this.redocExamplesNode=new gGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-code-samples"}),this.requests=this.input.requestBody!=null?new RGo({input:this.input.requestBody,context:this.context,accessPath:this.accessPath,pathId:"requestBody",method:this.method,path:this.path}):void 0,this.responses=this.input.responses!=null?new NGo({input:this.input.responses,context:this.context,accessPath:this.accessPath,pathId:"responses"},this.path,this.method,Object.values(this.requests?.requestBodiesByContentType??{}),{pathParameters:this.pathParameters,queryParameters:this.queryParameters,requestHeaders:this.requestHeaders}):void 0,this.responses==null){let i=this.requests?.requestBodiesByContentType;i==null||Object.keys(i).length===0?this.pushEmptyResponseExample(void 0,void 0,void 0):Object.values(i).forEach(n=>{if(Object.keys(n.examples??{}).length===0){let a=n.schema?.example({includeOptionals:!1,override:void 0});a!=null&&this.pushEmptyResponseExample({value:a},n,void 0)}else Object.entries(n.examples??{}).forEach(([a,o])=>{this.pushEmptyResponseExample(o,n,a)})})}let t=200;this.responses?.responsesByStatusCode!=null&&(t=Number(Object.keys(this.responses.responsesByStatusCode)?.filter(i=>Number(i)>=200&&Number(i)<300)[0])),this.globalAuth!=null&&(this.auth=this.globalAuth),this.input.security!=null&&(this.auth=new GLn({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"})),this.namespaces=[new tSa({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-group-name"})],this.namespaces?.every(i=>i.groupName==null)&&this.input.tags!=null&&(this.namespaces=this.input.tags.slice(0,1).map((i,n)=>new tSa({input:{[K9o]:i},context:this.context,accessPath:this.accessPath,pathId:["tags",`${n}`]})));let r=new bGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-sdk-method-name"});this.endpointIds=this.namespaces.map(i=>cGo({namespace:km(i?.groupName),path:this.path,method:this.method,sdkMethodName:r.sdkMethodName,operationId:this.input.operationId,displayName:this.displayName,isWebhook:this.isWebhook})).filter(mo),this.xFernExamplesNode=new yGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-examples"},this.path,t,this.requests?.requestBodiesByContentType,this.responses?.responsesByStatusCode?.[t]?.responses)}extractPathParameterIds(){if(this.path!=null)return this.path.split("/").map(t=>{if(t.startsWith("{")&&t.endsWith("}"))return t.slice(1,-1).trim()}).filter(mo)}convertPathToPathParts(){if(this.path===void 0)return;let t=this.path.startsWith("/")?this.path.slice(1):this.path,r=this.basePath?.convert();return(r?[r,...t.split("/")]:t.split("/")).reduce((n,a)=>(n.push({type:"literal",value:"/"}),a.startsWith("{")&&a.endsWith("}")?n.push({type:"pathParameter",value:Qs.PropertyKey(a.slice(1,-1).trim())}):n.push({type:"literal",value:a}),n),[])}convert(){if(this.path==null||this.endpointIds==null)return;let{responses:t,errors:r}=this.responses?.convert()??{responses:void 0,errors:void 0},i=this.emptyResponseExamples?.map(u=>u.convert()).filter(mo),n=jQ_(this.xFernExamplesNode?.convert(),[...i??[],...t?.flatMap(u=>u.examples)??[]])?.map(u=>({...u,snippets:PQ_(u.snippets,this.redocExamplesNode?.convert())}));if(this.isWebhook)return this.endpointIds.map((u,l)=>{if(!(this.method!=="POST"&&this.method!=="GET"))return{id:Qs.WebhookId(u),description:this.description,availability:this.availability?.convert(),displayName:this.displayName,operationId:this.operationId,namespace:this.namespaces?.[l]?.convert(),method:this.method,path:this.convertPathToPathParts()?.map(p=>p.value.toString())??[],queryParameters:A1i(this.queryParameters)?.flat(),headers:A1i(this.requestHeaders)?.flat(),payloads:this.requests?.convertToWebhookPayload(),examples:[this.requests?.webhookExample()].filter(mo)}}).filter(mo);let a=this.servers?.map(u=>u.convert()).filter(mo),o=this.convertPathToPathParts();if(o==null)return;let c,f=this.auth?.convert();f!=null&&(c=Object.keys(f));let s=t?.flatMap(u=>u.headers).filter(mo);return this.endpointIds.map((u,l)=>({id:Qs.EndpointId(u),description:this.description,availability:this.availability?.convert(),namespace:this.namespaces?.[l]?.convert()?.map(p=>Qs.api.v1.SubpackageId(p)),displayName:this.displayName,operationId:this.operationId,method:this.method,path:o,auth:c?.map(p=>Qs.api.latest.AuthSchemeId(p)),defaultEnvironment:a?.[0]?.id,environments:a,pathParameters:A1i(this.pathParameters)?.flat(),queryParameters:A1i(this.queryParameters)?.flat(),requestHeaders:A1i(this.requestHeaders)?.flat(),responseHeaders:s!=null&&s.length>0?s:void 0,requests:this.requests?.convert(),responses:t?.map(p=>p.response),errors:r,examples:n,snippetTemplates:void 0,protocol:{type:"rest"}}))}};var YLn=class extends $a{description;get;post;put;patch;delete;path;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:i,isWebhook:n}){this.description=this.input.description;let a=h1i(t,this.input.servers,this.context,this.accessPath),o=Array.isArray(this.pathId)?this.pathId.join("/"):this.pathId;this.input.get!=null&&(this.get=new m1i({input:this.input.get,context:this.context,accessPath:this.accessPath,pathId:"get",servers:a,globalAuth:r,path:o,method:"GET",basePath:i,isWebhook:n})),this.input.post!=null&&(this.post=new m1i({input:this.input.post,context:this.context,accessPath:this.accessPath,pathId:"post",servers:a,globalAuth:r,path:o,method:"POST",basePath:i,isWebhook:n})),this.input.put!=null&&(this.put=new m1i({input:this.input.put,context:this.context,accessPath:this.accessPath,pathId:"put",servers:a,globalAuth:r,path:o,method:"PUT",basePath:i,isWebhook:!1})),this.input.patch!=null&&(this.patch=new m1i({input:this.input.patch,context:this.context,accessPath:this.accessPath,pathId:"patch",servers:a,globalAuth:r,path:o,method:"PATCH",basePath:i,isWebhook:!1})),this.input.delete!=null&&(this.delete=new m1i({input:this.input.delete,context:this.context,accessPath:this.accessPath,pathId:"delete",servers:a,globalAuth:r,path:o,method:"DELETE",basePath:i,isWebhook:!1}))}convert(){return[...this.get?.convert()??[],...this.post?.convert()??[],...this.put?.convert()??[],...this.patch?.convert()??[],...this.delete?.convert()??[]].filter(mo)}};function FGo(e){return"payloads"in e}var QGo=class extends $a{paths;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:i}){this.paths=Object.entries(this.input).map(([n,a])=>{if(a!=null)return new YLn({input:a,context:this.context,accessPath:this.accessPath,pathId:n,servers:h1i(t,a.servers,this.context,this.accessPath),globalAuth:r,basePath:i,isWebhook:void 0})}).filter(mo)}convert(){if(this.paths==null)return;let t={},r={};return this.paths.forEach(i=>{let n=i.convert();n?.forEach(a=>{FGo(a)?r[Qs.WebhookId(a.id)]=a:t[Qs.EndpointId(a.id)]=a})}),{endpoints:t,webhookEndpoints:r}}};var UGo=class extends $a{globalHeaders;requiredProperties;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[WF_]?.map(r=>{let{header:i,...n}=r;return(n.optional!=null&&!n.optional||pGo(n,this.context.document)?.required)&&(this.requiredProperties??=[],this.requiredProperties?.push(i)),[i,new k9t({input:n,context:this.context,accessPath:this.accessPath,pathId:this.pathId,parameterName:i})]});t!=null&&(this.globalHeaders=Object.fromEntries(t))}convert(){return HLn(this.globalHeaders,this.requiredProperties)?.flat()}};function kQ_(e,t){if(sv(e)){let r=uU(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var LGo=class extends $a{webhooks;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:i}){this.webhooks=Object.entries(this.input??{}).map(([n,a])=>{let o=kQ_(a,this.context.document);if(o!=null)return new YLn({input:o,context:this.context,accessPath:this.accessPath,pathId:n,servers:t,globalAuth:r,basePath:i,isWebhook:!0})}).filter(mo)}convert(){return this.webhooks?.reduce((t,r)=>(r.convert()?.forEach(i=>{FGo(i)&&(t[Qs.WebhookId(i.id)]=i)}),t),{})}};var VGo=class extends $a{paths;webhooks;components;auth;globalHeaders;constructor(t){super(t),this.safeParse()}parse(){let t=h1i(void 0,this.input.servers,this.context,this.accessPath);this.input.security!=null&&(this.auth=new GLn({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"}));let r=new dGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});this.input.paths==null&&this.input.webhooks==null&&this.context.errors.warning({message:"Expected 'paths' or 'webhooks' property to be specified",path:this.accessPath}),this.input.paths!=null&&(this.paths=new QGo({input:this.input.paths,context:this.context,accessPath:this.accessPath,pathId:"paths",basePath:r,servers:t,globalAuth:this.auth})),this.input.webhooks!=null&&(this.webhooks=new LGo({input:this.input.webhooks,context:this.context,accessPath:this.accessPath,pathId:"webhooks",basePath:r,servers:t,globalAuth:this.auth})),this.input.components!=null&&(this.components=new CGo({input:this.input.components,context:this.context,accessPath:this.accessPath,pathId:"components"})),this.globalHeaders=new UGo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-global-headers"})}convert(){let t=ehe(),{webhookEndpoints:r,endpoints:i}=this.paths?.convert()??{},n={...this.webhooks?.convert()??{},...r??{}},a=QF_({endpoints:i,webhookEndpoints:n}),{types:o,auths:c}=this.components?.convert()??{};return{id:Qs.ApiDefinitionId(t),endpoints:i??{},websockets:{},webhooks:n,types:{...o,...this.context.generatedTypes},subpackages:a,auths:{...c,...this.auth?.convert()??{}},globalHeaders:this.globalHeaders?.convert(),snippetsConfiguration:void 0}}};async function Ygc(e,t){if(e instanceof F9t){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof Xw))return;let r=new RFt(e.absoluteFilePath),i=await yPe({context:t,specs:e.specs}),n=await r.loadDocuments({context:t,specs:i}),a;for(let o of n){if(o.type!=="openapi")continue;let c={document:o.value,logger:t.logger,errors:new G9o,generatedTypes:{}},f=new VGo({input:o.value,context:c,accessPath:[],pathId:e.workspaceName??"openapi parser"});a=pws(a,f.convert())}return a}var bG_=se(kgc(),1),vG_=se(B7o(),1),gG_=require("fs/promises"),OG_=se(require("http"),1),AG_=se(require("path"),1);var iV_=require("events"),R7o=se(require("fs"),1),tYi=se(require("path"),1);var Q8_=se(require("os"),1),U8_=300,D1i=20,ESa=1e7,L8_=Q8_.default.platform();var I5M=L8_==="darwin",gAc=L8_==="win32",B1i=I5M||gAc,V8_=3e3,W8_=2e4,OAc=1250;var iGt;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(iGt||(iGt={}));var eYi;(function(e){e.CHANGE="change",e.RENAME="rename"})(eYi||(eYi={}));var SSa;(function(e){e.CHANGE="change",e.ERROR="error"})(SSa||(SSa={}));var Il;(function(e){e.ADD="add",e.ADD_DIR="addDir",e.CHANGE="change",e.RENAME="rename",e.RENAME_DIR="renameDir",e.UNLINK="unlink",e.UNLINK_DIR="unlinkDir"})(Il||(Il={}));var Fx;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(Fx||(Fx={}));var C5M=(e,t=1,r)=>{t=Math.max(1,t);let i=r?.leading??!1,n=r?.trailing??!0,a=Math.max(r?.maxWait??1/0,t),o,c,f=0,s=0,u=()=>{let g=Date.now(),m=g-f,j=g-s,M=m>=t||j>=a;return[g,M]},l=g=>{if(s=g,!o)return;let m=o;o=void 0,e.apply(void 0,m)},p=()=>{O(0)},_=()=>{c&&(p(),l(Date.now()))},h=g=>{if(s=g,i)return l(g)},y=g=>{if(n&&o)return l(g);o=void 0},b=()=>{c=void 0;let[g,m]=u();return m?y(g):v(g)},v=g=>{let m=g-f,j=g-s,M=t-m,E=a-j,D=Math.min(M,E);return O(D)},O=g=>{c&&clearTimeout(c),!(g<=0)&&(c=setTimeout(b,g))},A=(...g)=>{let[m,j]=u(),M=!!c;if(o=g,f=m,(j||!c)&&O(t),j)return M?l(m):h(m)};return A.cancel=p,A.flush=_,A},I7o=C5M;var jAc=se(require("fs"),1),q7o=se(require("path"),1);var bO=se(require("fs"),1),sU=require("util");var xgi=(e,t)=>function(...i){return e.apply(void 0,i).catch(t)},nGt=(e,t)=>function(...i){try{return e.apply(void 0,i)}catch(n){return t(n)}};var AAc=se(require("process"),1),x8_=AAc.default.getuid?!AAc.default.getuid():!1,G8_=1e4,PK=()=>{};var MSa={isChangeErrorOk:e=>{if(!MSa.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!x8_&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!MSa.isNodeError(e))return!1;let{code:t}=e;return t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM"},onChangeError:e=>{if(!MSa.isNodeError(e))throw e;if(!MSa.isChangeErrorOk(e))throw e}},WB=MSa;var mAc=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=G8_,this.queueActive=new Set,this.queueWaiting=new Set,this.init=()=>{this.intervalId||(this.intervalId=setInterval(this.tick,this.interval))},this.reset=()=>{this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId)},this.add=t=>{this.queueWaiting.add(t),this.queueActive.size<this.limit/2?this.tick():this.init()},this.remove=t=>{this.queueWaiting.delete(t),this.queueActive.delete(t)},this.schedule=()=>new Promise(t=>{let r=()=>this.remove(i),i=()=>t(r);this.add(i)}),this.tick=()=>{if(!(this.queueActive.size>=this.limit)){if(!this.queueWaiting.size)return this.reset();for(let t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t),this.queueActive.add(t),t()}}}}},H8_=new mAc;var Ggi=(e,t)=>function(i){return function n(...a){return H8_.schedule().then(o=>{let c=s=>(o(),s),f=s=>{if(o(),Date.now()>=i)throw s;if(t(s)){let u=Math.round(100*Math.random());return new Promise(p=>setTimeout(p,u)).then(()=>n.apply(void 0,a))}throw s};return e.apply(void 0,a).then(c,f)})}},Hgi=(e,t)=>function(i){return function n(...a){try{return e.apply(void 0,a)}catch(o){if(Date.now()>i)throw o;if(t(o))return n.apply(void 0,a);throw o}}};var q5M={attempt:{chmod:xgi((0,sU.promisify)(bO.default.chmod),WB.onChangeError),chown:xgi((0,sU.promisify)(bO.default.chown),WB.onChangeError),close:xgi((0,sU.promisify)(bO.default.close),PK),fsync:xgi((0,sU.promisify)(bO.default.fsync),PK),mkdir:xgi((0,sU.promisify)(bO.default.mkdir),PK),realpath:xgi((0,sU.promisify)(bO.default.realpath),PK),stat:xgi((0,sU.promisify)(bO.default.stat),PK),unlink:xgi((0,sU.promisify)(bO.default.unlink),PK),chmodSync:nGt(bO.default.chmodSync,WB.onChangeError),chownSync:nGt(bO.default.chownSync,WB.onChangeError),closeSync:nGt(bO.default.closeSync,PK),existsSync:nGt(bO.default.existsSync,PK),fsyncSync:nGt(bO.default.fsync,PK),mkdirSync:nGt(bO.default.mkdirSync,PK),realpathSync:nGt(bO.default.realpathSync,PK),statSync:nGt(bO.default.statSync,PK),unlinkSync:nGt(bO.default.unlinkSync,PK)},retry:{close:Ggi((0,sU.promisify)(bO.default.close),WB.isRetriableError),fsync:Ggi((0,sU.promisify)(bO.default.fsync),WB.isRetriableError),open:Ggi((0,sU.promisify)(bO.default.open),WB.isRetriableError),readFile:Ggi((0,sU.promisify)(bO.default.readFile),WB.isRetriableError),rename:Ggi((0,sU.promisify)(bO.default.rename),WB.isRetriableError),stat:Ggi((0,sU.promisify)(bO.default.stat),WB.isRetriableError),write:Ggi((0,sU.promisify)(bO.default.write),WB.isRetriableError),writeFile:Ggi((0,sU.promisify)(bO.default.writeFile),WB.isRetriableError),closeSync:Hgi(bO.default.closeSync,WB.isRetriableError),fsyncSync:Hgi(bO.default.fsyncSync,WB.isRetriableError),openSync:Hgi(bO.default.openSync,WB.isRetriableError),readFileSync:Hgi(bO.default.readFileSync,WB.isRetriableError),renameSync:Hgi(bO.default.renameSync,WB.isRetriableError),statSync:Hgi(bO.default.statSync,WB.isRetriableError),writeSync:Hgi(bO.default.writeSync,WB.isRetriableError),writeFileSync:Hgi(bO.default.writeFileSync,WB.isRetriableError)}},K8_=q5M;var C7o=se(require("fs"),1),DSa=se(require("path"),1);var PAc=()=>{};var T5M=()=>{let e=PAc,t=PAc,r=!1,i=!1;return{promise:new Promise((f,s)=>{e=u=>(r=!0,f(u)),t=u=>(i=!0,s(u))}),resolve:e,reject:t,isPending:()=>!r&&!i,isResolved:()=>r,isRejected:()=>i}},J8_=T5M;var R5M=()=>{let{promise:e,resolve:t,isPending:r}=J8_(),i=0,n=()=>{i+=1},a=()=>{i-=1,!i&&t()};return(()=>{n(),queueMicrotask(a)})(),{promise:e,isPending:r,increment:n,decrement:a}},$8_=R5M;var Y8_={then:e=>{e()}};var X8_=e=>Array.isArray(e)?e:[e],Z8_=e=>typeof e=="function";var z5M=(e,t)=>{let r=t?.followSymlinks??!1,i=t?.depth??1/0,n=t?.limit??1/0,a=t?.ignore??[],o=X8_(a).map(U=>Z8_(U)?U:W=>U.test(W)),c=U=>o.some(W=>W(U)),f=t?.signal??{aborted:!1},s=t?.onDirents||(()=>{}),u=[],l=new Set,p={},_=[],h=new Set,y={},b=[],v=new Set,O={},A={},g=new Set,m={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},j={directories:u,directoriesNames:l,directoriesNamesToPaths:p,files:_,filesNames:h,filesNamesToPaths:y,symlinks:b,symlinksNames:v,symlinksNamesToPaths:O,map:A},{promise:M,increment:E,decrement:D}=$8_(),B=0,F=(U,W,Te,ce)=>{g.has(W)||B>=n||(B+=1,U.directories.push(W),U.directoriesNames.add(Te),u.push(W),l.add(Te),p.propertyIsEnumerable(Te)||(p[Te]=[]),p[Te].push(W),g.add(W),!(ce>=i)&&(B>=n||J(W,ce+1)))},N=(U,W,Te)=>{g.has(W)||B>=n||(B+=1,U.files.push(W),U.filesNames.add(Te),_.push(W),h.add(Te),y.propertyIsEnumerable(Te)||(y[Te]=[]),y[Te].push(W),g.add(W))},R=(U,W,Te,ce)=>{g.has(W)||B>=n||(B+=1,U.symlinks.push(W),U.symlinksNames.add(Te),b.push(W),v.add(Te),O.propertyIsEnumerable(Te)||(O[Te]=[]),O[Te].push(W),g.add(W),r&&(ce>=i||B>=n||ue(W,ce+1)))},z=(U,W,Te,ce,we)=>{f.aborted||c(W)||(ce.isDirectory()?F(U,W,Te,we):ce.isFile()?N(U,W,Te):ce.isSymbolicLink()&&R(U,W,Te,we))},L=(U,W,Te,ce)=>{if(f.aborted)return;let we=W===DSa.default.sep?"":DSa.default.sep,Le=Te.name,le=`${W}${we}${Le}`;c(le)||(Te.isDirectory()?F(U,le,Le,ce):Te.isFile()?N(U,le,Le):Te.isSymbolicLink()&&R(U,le,Le,ce))},H=(U,W,Te,ce)=>{for(let we=0,Le=Te.length;we<Le;we++)L(U,W,Te[we],ce)},J=(U,W)=>{f.aborted||W>i||B>=n||(E(),C7o.default.readdir(U,{withFileTypes:!0},(Te,ce)=>{if(Te||f.aborted||!ce.length)return D();(s(ce)||Y8_).then(()=>{let Le=A[U]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};H(Le,U,ce,W),D()})}))},ue=(U,W)=>{E(),C7o.default.realpath(U,(Te,ce)=>{if(Te||f.aborted)return D();C7o.default.stat(ce,(we,Le)=>{if(we||f.aborted)return D();let le=DSa.default.basename(ce),ne=A[U]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};z(ne,ce,le,Le,W),D()})})};return(async(U,W=1)=>(U=DSa.default.normalize(U),g.add(U),J(U,W),await M,f.aborted?m:j))(e)},k8_=z5M;var aGt={lang:{debounce:I7o,attempt:e=>{try{return e()}catch(t){return aGt.lang.castError(t)}},castArray:e=>aGt.lang.isArray(e)?e:[e],castError:e=>aGt.lang.isError(e)?e:aGt.lang.isString(e)?new Error(e):new Error("Unknown error"),defer:e=>setTimeout(e,0),isArray:e=>Array.isArray(e),isError:e=>e instanceof Error,isFunction:e=>typeof e=="function",isNaN:e=>Number.isNaN(e),isNumber:e=>typeof e=="number",isPrimitive:e=>{if(e===null)return!0;let t=typeof e;return t!=="object"&&t!=="function"},isShallowEqual:(e,t)=>{if(e===t)return!0;if(aGt.lang.isNaN(e))return aGt.lang.isNaN(t);if(aGt.lang.isPrimitive(e)||aGt.lang.isPrimitive(t))return e===t;for(let r in e)if(!(r in t))return!1;for(let r in t)if(e[r]!==t[r])return!1;return!0},isSet:e=>e instanceof Set,isString:e=>typeof e=="string",isUndefined:e=>e===void 0,noop:()=>{},uniq:e=>e.length<2?e:Array.from(new Set(e))},fs:{getDepth:e=>Math.max(0,e.split(q7o.default.sep).length-1),getRealPath:(e,t)=>{try{return t?jAc.default.realpathSync.native(e):jAc.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===q7o.default.sep&&t.length-e.length>q7o.default.sep.length,poll:(e,t=W8_)=>K8_.retry.stat(t)(e,{bigint:!0}).catch(aGt.lang.noop),readdir:async(e,t,r=1/0,i=1/0,n,a)=>{if(a&&r===1&&e in a){let o=a[e];return[o.directories,o.files]}else{let o=await k8_(e,{depth:r,limit:i,ignore:t,signal:n});return[o.directories,o.files]}}}},cp=aGt;var T7o=se(require("path"),1);var wAc=class{constructor(t,r,i){this.base=i,this.watcher=t,this.handler=r.handler,this.fswatcher=r.watcher,this.options=r.options,this.folderPath=r.folderPath,this.filePath=r.filePath,this.handlerBatched=this.base?this.base.onWatcherEvent.bind(this.base):this._makeHandlerBatched(this.options.debounce)}_isSubRoot(t){return this.filePath?t===this.filePath:t===this.folderPath||cp.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=U8_){return(()=>{let r=this.watcher._readyWait,i=[],n=new Set,a=async(c,f)=>{let s=this.options.ignoreInitial?[]:c,u=await this.eventsPopulate([...f]),l=this.eventsDeduplicate([...s,...u]);this.onTargetEvents(l)},o=cp.lang.debounce(()=>{this.watcher.isClosed()||(r=a(i,n),i=[],n=new Set)},t);return async(c,f="",s=!1)=>{s?await this.eventsPopulate([f],i,!0):n.add(f),r.then(o)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((i,n)=>{let[a,o]=n,c=r[o];return a===c||a===Il.CHANGE&&c===Il.ADD||(r[o]=a,i.push(n)),i},[])}async eventsPopulate(t,r=[],i=!1){return await Promise.all(t.map(async n=>{let a=await this.watcher._poller.update(n,this.options.pollingTimeout);await Promise.all(a.map(async o=>{r.push([o,n]),o===Il.ADD_DIR?await this.eventsPopulateAddDir(t,n,r,i):o===Il.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,n,r,i)}))})),r}async eventsPopulateAddDir(t,r,i=[],n=!1){if(n)return i;let a=this.options.recursive?this.options.depth??D1i:Math.min(1,this.options.depth??D1i),o=this.options.limit??ESa,[c,f]=await cp.fs.readdir(r,this.options.ignore,a,o,this.watcher._closeSignal),s=[...c,...f];return await Promise.all(s.map(u=>{if(!this.watcher.isIgnored(u,this.options.ignore)&&!t.includes(u))return this.eventsPopulate([u],i,!0)})),i}async eventsPopulateUnlinkDir(t,r,i=[],n=!1){if(n)return i;for(let a of this.watcher._poller.stats.keys())cp.fs.isSubPath(r,a)&&(t.includes(a)||await this.eventsPopulate([a],i,!0));return i}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(Il.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!B1i&&this.options.native!==!1&&this.watcher.watchDirectory(t,this.options,this.handler,void 0,this.base||this),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAddDir(t,this.options.renameTimeout):this.watcher.event(Il.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(Il.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(T7o.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(Il.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(T7o.default.dirname(t),t,!1),this.watcher.watchersClose(t),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlinkDir(t,this.options.renameTimeout):this.watcher.event(Il.UNLINK_DIR,t))}onTargetEvent(t){let[r,i]=t;r===Il.ADD?this.onTargetAdd(i):r===Il.ADD_DIR?this.onTargetAddDir(i):r===Il.CHANGE?this.onTargetChange(i):r===Il.UNLINK?this.onTargetUnlink(i):r===Il.UNLINK_DIR&&this.onTargetUnlinkDir(i)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,i=!1){return this.handlerBatched(t,r,i)}onWatcherChange(t=eYi.CHANGE,r){if(this.watcher.isClosed())return;let i=T7o.default.resolve(this.folderPath,r||"");this.filePath&&i!==this.folderPath&&i!==this.filePath||this.watcher.isIgnored(i,this.options.ignore)||this.onWatcherEvent(t,i)}onWatcherError(t){gAc&&t.code==="EPERM"?this.onWatcherChange(eYi.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(SSa.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(SSa.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(eYi.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&B1i&&this.options.native!==!1?this.options.depth??D1i:Math.min(1,this.options.depth??D1i),i=this.options.limit??ESa,[n,a]=await cp.fs.readdir(this.folderPath,this.options.ignore,r,i,this.watcher._closeSignal,this.options.readdirMap),o=[this.folderPath,...n,...a];await Promise.all(o.map(c=>{if(!this.watcher._poller.stats.has(c)&&!this.watcher.isIgnored(c,this.options.ignore))return this.onWatcherEvent(eYi.CHANGE,c,t)}))}}},eV_=wAc;var Qx={interval:100,intervalId:void 0,fns:new Map,init:()=>{Qx.intervalId||(Qx.intervalId=setInterval(Qx.resolve,Qx.interval))},reset:()=>{Qx.intervalId&&(clearInterval(Qx.intervalId),delete Qx.intervalId)},add:(e,t)=>{Qx.fns.set(e,Date.now()+t),Qx.init()},remove:e=>{Qx.fns.delete(e)},resolve:()=>{if(!Qx.fns.size)return Qx.reset();let e=Date.now();for(let[t,r]of Qx.fns)r>=e||(Qx.remove(t),t())}},BSa=Qx;var ISa=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=OAc){let{ino:i,targetPath:n,events:a,locks:o}=t,c=()=>{let l=this._watcher._poller.paths.find(i||-1,p=>p!==n);if(l&&l!==n){if(cp.fs.getRealPath(n,!0)===l)return;this._watcher.event(a.rename,l,n)}else this._watcher.event(a.add,n)};if(!i)return c();let f=()=>{o.add.delete(i),BSa.remove(s)},s=()=>{f(),c()};BSa.add(s,r);let u=()=>{let l=o.unlink.get(i);if(!l)return;f();let p=l();n===p?a.change&&this._watcher._poller.stats.has(n)&&this._watcher.event(a.change,n):this._watcher.event(a.rename,p,n)};o.add.set(i,u),u()}getLockUnlink(t,r=OAc){let{ino:i,targetPath:n,events:a,locks:o}=t,c=()=>{this._watcher.event(a.unlink,n)};if(!i)return c();let f=()=>{o.unlink.delete(i),BSa.remove(s)},s=()=>{f(),c()};BSa.add(s,r);let u=()=>(f(),n);o.unlink.set(i,u),o.add.get(i)?.()}getLockTargetAdd(t,r){let i=this._watcher._poller.getIno(t,Il.ADD,iGt.FILE);return this.getLockAdd({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let i=this._watcher._poller.getIno(t,Il.ADD_DIR,iGt.DIR);return this.getLockAdd({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let i=this._watcher._poller.getIno(t,Il.UNLINK,iGt.FILE);return this.getLockUnlink({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let i=this._watcher._poller.getIno(t,Il.UNLINK_DIR,iGt.DIR);return this.getLockUnlink({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}reset(){this._locksAdd=new Map,this._locksAddDir=new Map,this._locksUnlink=new Map,this._locksUnlinkDir=new Map,this._locksDir={add:this._locksAddDir,unlink:this._locksUnlinkDir},this._locksFile={add:this._locksAdd,unlink:this._locksUnlink}}};ISa.DIR_EVENTS={add:Il.ADD_DIR,rename:Il.RENAME_DIR,unlink:Il.UNLINK_DIR};ISa.FILE_EVENTS={add:Il.ADD,change:Il.CHANGE,rename:Il.RENAME,unlink:Il.UNLINK};var tV_=ISa;var EAc=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(cp.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let i=this.map.get(t);if(cp.lang.isSet(i)){let n=i.delete(r);return i.size||this.map.delete(t),n}else if(i===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let i=this.map.get(t);if(cp.lang.isSet(i))return Array.from(i).find(r);if(r(i))return i}}get(t){return this.map.get(t)}has(t,r){if(cp.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let i=this.map.get(t);return cp.lang.isSet(i)?i.has(r):i===r}return!1}set(t,r){if(this.map.has(t)){let i=this.map.get(t);cp.lang.isSet(i)?i.add(r):i!==r&&this.map.set(t,new Set([i,r]))}else this.map.set(t,r);return this}},SAc=EAc;var MAc=class{constructor(t){this.ino=t.ino<=Number.MAX_SAFE_INTEGER?Number(t.ino):t.ino,this.size=Number(t.size),this.atimeMs=Number(t.atimeMs),this.mtimeMs=Number(t.mtimeMs),this.ctimeMs=Number(t.ctimeMs),this.birthtimeMs=Number(t.birthtimeMs),this._isFile=t.isFile(),this._isDirectory=t.isDirectory(),this._isSymbolicLink=t.isSymbolicLink()}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isSymbolicLink(){return this._isSymbolicLink}},rV_=MAc;var DAc=class{constructor(){this.inos={},this.paths=new SAc,this.stats=new Map}getIno(t,r,i){let n=this.inos[r];if(!n)return;let a=n[t];if(a&&!(i&&a[1]!==i))return a[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let i=await cp.fs.poll(t,r);if(!(!i||!(i.isFile()||i.isDirectory())))return new rV_(i)}reset(){this.inos={},this.paths=new SAc,this.stats=new Map}async update(t,r){let i=this.getStats(t),n=await this.poll(t,r);if(this.updateStats(t,n),!i&&n){if(n.isFile())return this.updateIno(t,Il.ADD,n),[Il.ADD];if(n.isDirectory())return this.updateIno(t,Il.ADD_DIR,n),[Il.ADD_DIR]}else if(i&&!n){if(i.isFile())return this.updateIno(t,Il.UNLINK,i),[Il.UNLINK];if(i.isDirectory())return this.updateIno(t,Il.UNLINK_DIR,i),[Il.UNLINK_DIR]}else if(i&&n){if(i.isFile()){if(n.isFile())return i.ino===n.ino&&!i.size&&!n.size?[]:(this.updateIno(t,Il.CHANGE,n),[Il.CHANGE]);if(n.isDirectory())return this.updateIno(t,Il.UNLINK,i),this.updateIno(t,Il.ADD_DIR,n),[Il.UNLINK,Il.ADD_DIR]}else if(i.isDirectory()){if(n.isFile())return this.updateIno(t,Il.UNLINK_DIR,i),this.updateIno(t,Il.ADD,n),[Il.UNLINK_DIR,Il.ADD];if(n.isDirectory())return i.ino===n.ino?[]:(this.updateIno(t,Il.UNLINK_DIR,i),this.updateIno(t,Il.ADD_DIR,n),[Il.UNLINK_DIR,Il.ADD_DIR])}}return[]}updateIno(t,r,i){let n=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=i.isFile()?iGt.FILE:iGt.DIR;n[t]=[i.ino,a]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let i=this.stats.get(t)?.ino||-1;this.paths.delete(i,t),this.stats.delete(t)}}},BAc=DAc;var IAc=class e extends iV_.EventEmitter{constructor(t,r,i){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(Fx.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(n=>this.on(Fx.CLOSE,n)),this._readyWait=new Promise(n=>this.on(Fx.READY,n)),this._locker=new tV_(this),this._roots=new Set,this._poller=new BAc,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,i)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(cp.lang.isFunction(r)?!!r(t):r.test(t))}isReady(){return this._ready}close(){return this._locker.reset(),this._poller.reset(),this._roots.clear(),this.watchersClose(),this.isClosed()?!1:(this._closed=!0,this.emit(Fx.CLOSE))}error(t){if(this.isClosed())return!1;let r=cp.lang.castError(t);return this.emit(Fx.ERROR,r)}event(t,r,i){return this.isClosed()?!1:(this.emit(Fx.ALL,t,r,i),this.emit(t,r,i))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(Fx.READY))}pollerExists(t,r){for(let i of this._pollers)if(i.targetPath===t&&cp.lang.isShallowEqual(i.options,r))return!0;return!1}subwatcherExists(t,r){for(let i of this._subwatchers)if(i.targetPath===t&&cp.lang.isShallowEqual(i.options,r))return!0;return!1}watchersClose(t,r,i=!0){if(t){let n=this._watchers[t];if(n)for(let a of[...n])r&&a.filePath!==r||this.watcherClose(a);if(i)for(let a in this._watchers)cp.fs.isSubPath(t,a)&&this.watchersClose(a,r,!1)}else for(let n in this._watchers)this.watchersClose(n,r,!1)}watchersLock(t){return this._watchersLock.then(()=>this._watchersLock=new Promise(async r=>{await t(),r()}))}watchersRestore(){delete this._watchersRestoreTimeout;let t=Object.entries(this._watchersRestorable);this._watchersRestorable={};for(let[r,i]of t)this.watchPath(r,i.options,i.handler)}async watcherAdd(t,r){let{folderPath:i}=t;(this._watchers[i]=this._watchers[i]||[]).push(t);let a=new eV_(this,t,r);return await a.init(),a}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let a=r.indexOf(t);r.splice(a,1),r.length||delete this._watchers[t.folderPath]}let i=t.filePath||t.folderPath;this._roots.has(i)&&(this._watchersRestorable[i]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=cp.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,i,n){if(this._watchers[t]?.find(c=>c.handler===i&&(!c.filePath||c.filePath===n)&&c.options.ignore===r.ignore&&!!c.options.native==!!r.native&&(!r.recursive||c.options.recursive)))return!0;let o=tYi.default.dirname(t);for(let c=1;c<1/0;c++){if(this._watchers[o]?.find(u=>(c===1||u.options.recursive&&c<=(u.options.depth??D1i))&&u.handler===i&&(!u.filePath||u.filePath===n)&&u.options.ignore===r.ignore&&!!u.options.native==!!r.native&&(!r.recursive||u.options.recursive&&B1i&&u.options.native!==!1)))return!0;if(!B1i)break;let s=tYi.default.dirname(t);if(o===s)break;o=s}return!1}async watchDirectories(t,r,i,n,a){if(this.isClosed())return;t=cp.lang.uniq(t).sort();let o;for(let c of t)if(!this.isIgnored(c,r.ignore)&&!this.watcherExists(c,r,i,n))try{let f=!r.recursive||B1i&&r.native!==!1?r:{...r,recursive:!1},u={watcher:R7o.default.watch(c,f),handler:i,options:r,folderPath:c,filePath:n},l=o=await this.watcherAdd(u,a);if(this._roots.has(n||c)){let _={...r,ignoreInitial:!0,recursive:!1},h=tYi.default.dirname(c),y=c;await this.watchDirectories([h],_,i,y,l)}}catch(f){this.error(f)}return o}async watchDirectory(t,r,i,n,a){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||B1i&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,i,n,a));{r={...r,recursive:!0};let o=r.depth??D1i,c=r.limit??ESa,[f]=await cp.fs.readdir(t,r.ignore,o,c,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let s=await this.watchDirectories([t],r,i,n,a);if(f.length){let u=cp.fs.getDepth(t);for(let l of f){let p=cp.fs.getDepth(l),_=Math.max(0,o-(p-u)),h={...r,depth:_};await this.watchDirectories([l],h,i,n,a||s)}}})}}}async watchFileOnce(t,r,i){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let n={targetPath:t,options:r},a=(s,u)=>{u===t&&(f(),i())},o=new e(a),c=()=>{this._subwatchers.add(n),this.on(Fx.CLOSE,f),o.watchFile(t,r,a)},f=()=>{this._subwatchers.delete(n),this.removeListener(Fx.CLOSE,f),o.close()};return c()}async watchFile(t,r,i){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let n=tYi.default.dirname(t);return this.watchDirectory(n,r,i,t)}async watchPollingOnce(t,r,i){if(this.isClosed())return;let n=!1,a=new BAc,o=await this.watchPolling(t,r,async()=>{n||!(await a.update(t,r.pollingTimeout)).length||n||(n=!0,o(),i())})}async watchPolling(t,r,i){if(this.isClosed())return cp.lang.noop;if(this.pollerExists(t,r))return cp.lang.noop;let n={...r,interval:r.pollingInterval??V8_},a={targetPath:t,options:r},o=()=>{this._pollers.add(a),this.on(Fx.CLOSE,c),R7o.default.watchFile(t,n,i)},c=()=>{this._pollers.delete(a),this.removeListener(Fx.CLOSE,c),R7o.default.unwatchFile(t,i)};return cp.lang.attempt(o),()=>cp.lang.attempt(c)}async watchUnknownChild(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchFileOnce(t,r,n)}async watchUnknownTarget(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchPollingOnce(t,r,n)}async watchPaths(t,r,i){if(this.isClosed())return;if(t=cp.lang.uniq(t).sort(),t.every((a,o)=>t.every((c,f)=>f===o||!cp.fs.isSubPath(a,c))))await Promise.all(t.map(a=>this.watchPath(a,r,i)));else for(let a of t)await this.watchPath(a,r,i)}async watchPath(t,r,i){if(this.isClosed()||(t=tYi.default.resolve(t),this.isIgnored(t,r.ignore)))return;let n=await cp.fs.poll(t,r.pollingTimeout);if(n){if(n.isFile())return this.watchFile(t,r,i);if(n.isDirectory())return this.watchDirectory(t,r,i);this.error(`"${t}" is not supported`)}else{let a=tYi.default.dirname(t);return(await cp.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,i):this.watchUnknownTarget(t,r,i)}}async watch(t,r,i=cp.lang.noop){if(cp.lang.isFunction(t))return this.watch([],{},t);if(cp.lang.isUndefined(t))return this.watch([],r,i);if(cp.lang.isFunction(r))return this.watch(t,{},r);if(cp.lang.isUndefined(r))return this.watch(t,{},i);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let n=cp.lang.castArray(t);n.forEach(a=>this._roots.add(a)),await this.watchPaths(n,r,i),!this.isClosed()&&(i!==cp.lang.noop&&this.on(Fx.ALL,i),r.readdirMap=void 0,this.ready())}},z7o=IAc;CMo();var d3n=require("fs/promises"),nV_=require("os"),aV_=se(require("path"),1),N5M=".fern",F5M="app-preview",Q5M="logs";function U5M(){return"cli@3.24.2"}var CSa=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=Bt(Br.of((0,nV_.homedir)()),$e.of(N5M)),r=Bt(t,$e.of(F5M)),i=Bt(r,$e.of(Q5M));await wi(i)||await(0,d3n.mkdir)(i,{recursive:!0});let a=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=Bt(i,$e.of(a));let o=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${aV_.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
1787
1787
|
`);await(0,d3n.writeFile)(this.logFilePath,o,"utf-8"),this.initialized=!0}getLogFilePath(){return this.logFilePath}async writeEntry(t){if(!this.initialized||!this.logFilePath)return;let r=JSON.stringify(t)+`
|
|
1788
1788
|
`;try{await(0,d3n.appendFile)(this.logFilePath,r,"utf-8")}catch{}}async logFrontendMetrics(t){let r={timestamp:t.timestamp,source:t.source,level:t.level,eventType:this.getEventType(t.payload,t.isAggregate),isAggregate:t.isAggregate,data:t.payload};await this.writeEntry(r)}async logCliMetric(t,r="info"){let i={timestamp:t.timestamp,source:U5M(),level:r,eventType:t.type,data:{durationMs:t.durationMs,metadata:t.metadata}};await this.writeEntry(i)}async logCliMemory(){let t=process.memoryUsage(),r={type:"cli_memory",timestamp:new Date().toISOString(),metadata:{heapUsed:t.heapUsed,heapTotal:t.heapTotal,external:t.external,rss:t.rss,heapUsedMB:Math.round(t.heapUsed/1024/1024*100)/100,heapTotalMB:Math.round(t.heapTotal/1024/1024*100)/100,rssMB:Math.round(t.rss/1024/1024*100)/100}};await this.logCliMetric(r)}async logCliReloadStart(){let t={type:"cli_reload_start",timestamp:new Date().toISOString()};await this.logCliMetric(t)}async logCliReloadFinish(t,r){let i={type:"cli_reload_finish",timestamp:new Date().toISOString(),durationMs:t,metadata:r};await this.logCliMetric(i)}async logCliDocsGeneration(t,r){let i={type:"cli_docs_generation",timestamp:new Date().toISOString(),durationMs:t,metadata:r};await this.logCliMetric(i)}async logCliValidation(t,r){let i={type:"cli_validation",timestamp:new Date().toISOString(),durationMs:t,metadata:{success:r}};await this.logCliMetric(i)}getEventType(t,r){return r?"aggregate_summary":"type"in t&&typeof t.type=="string"?t.type:"unknown"}static isMetricsMessage(t){if(typeof t!="object"||t===null)return!1;let r=t;return r.type==="metrics"&&typeof r.timestamp=="string"&&typeof r.source=="string"}};var n0c=se(UAc(),1),Y9_=se(SHo(),1),jK=require("fs/promises"),X9_=require("os"),Z9_=se(IW(),1),k9_=se($9_(),1),xHo=process.platform==="win32",i0c=Ut.cyan("[docs]:"),oGM="etag",uGM="preview",sGM="app-preview",cGM="bundle",lGM=".next",fGM="standalone",dGM=".fern",pGM="packages/fern-docs/bundle/.next/server/instrumentation.js",_GM=".npmrc",hGM=".pnpmfile.cjs",yGM="pnpm-workspace.yaml",bGM='Cannot find matching keyid: {"signatures":';function vGM(){return Bt(Br.of((0,X9_.homedir)()),$e.of(dGM))}function GHo({app:e=!1}){return Bt(vGM(),$e.of(e?sGM:uGM))}function Q1i({app:e=!1}){return Bt(GHo({app:e}),$e.of(e?lGM:cGM))}function rMa({app:e=!1}){return Bt(Q1i({app:e}),$e.of(fGM))}function gGM({app:e=!1}){return Bt(rMa({app:e}),$e.of(pGM))}function OGM({app:e=!1}){return Bt(rMa({app:e}),$e.of(yGM))}function AGM({app:e=!1}){return Bt(rMa({app:e}),$e.of(hGM))}function mGM({app:e=!1}){return Bt(rMa({app:e}),$e.of(_GM))}function sYi(e){return new Error(`${e}. Please reach out to support@buildwithfern.com.`)}function PGM({app:e=!1}){return Bt(GHo({app:e}),$e.of(oGM))}var jGM=`module.exports = {
|
|
1789
1789
|
hooks: {
|