fern-api 3.21.0 → 3.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.cjs +3 -3
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -1147,7 +1147,7 @@ ${oUp.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&e9s(th
1147
1147
  `+q7i.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?q7i.default.cyan(hUp(t,this.opt.mask)):q7i.default.italic(q7i.default.dim("[hidden]")):this.opt.mask?hUp(t,this.opt.mask):q7i.default.italic(q7i.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 Zmo=ue(y1(),1);var h4p=ue(R9s(),1),Ymo=require("child_process"),tTn=require("fs"),$mo=ue(require("path"),1),y4p=ue(require("os"),1),b4p=require("crypto"),gGs=ue(p4p(),1);var Hmo=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var Gga=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var Kmo=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var Jmo=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function Xmo(e="",t,r){let i=new OGs(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 _4p(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function xvS(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 OGs=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=xvS(t).map(n=>n.replace("\\ "," ")),i=r.shift();this.editor={args:r,bin:i}}createTemporaryFile(){try{let t=this.fileOptions.dir??y4p.default.tmpdir(),r=(0,b4p.randomUUID)(),i=_4p(this.fileOptions.prefix),n=_4p(this.fileOptions.postfix),a=`${i}${r}${n}`,o=$mo.default.resolve(t,a),c=$mo.default.resolve(t)+$mo.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,tTn.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new Hmo(t)}}readTemporaryFile(){try{let t=(0,tTn.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,h4p.detect)(t)??"utf8";gGs.default.encodingExists(r)||(r="utf8"),this.text=gGs.default.decode(t,r)}}catch(t){throw new Kmo(t)}}removeTemporaryFile(){try{(0,tTn.unlinkSync)(this.tempFile)}catch(t){throw new Jmo(t)}}launchEditor(){try{let t=(0,Ymo.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new Gga(t)}}launchEditorAsync(t){try{(0,Ymo.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",i=>{this.lastExitStatus=i,setImmediate(t)})}catch(r){throw new Gga(r)}}};var v4p=ue(X_e(),1);var Hga=class extends b1{_run(t){this.done=t,this.editorResult=new v4p.Subject;let r=qQ(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?Zmo.default.dim("Received"):Zmo.default.dim("Press <enter> to launch your preferred editor."),t&&(r=Zmo.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),Xmo(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 P4p=require("stream");var A4p=ue(require("readline"),1),m4p=ue(O4p(),1),N7i=class{constructor(t){this.rl||=A4p.default.createInterface(HvS(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 HvS(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 m4p.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var Kga=class extends N7i{constructor(t={}){super(t),this.log=new P4p.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return Bga(this.rl,this.bottomBar.split(`
1148
1148
  `).length),this}updateBottomBar(t){return Bga(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&&Omo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var pO=ue(X_e(),1),E4p=ue(Xva(),1);var kmo=ue(X_e(),1),j4p=ue(Xva(),1),e0o=function(e,t,r){return typeof e[t]!="function"?(0,kmo.of)(e):(0,kmo.from)((0,j4p.default)(e[t])(r).then(i=>(e[t]=i,e)))};var w4p={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}},rTn=class extends N7i{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)=>(w4p.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)(()=>e0o(t,"message",this.answers)),(0,pO.concatMap)(()=>e0o(t,"default",this.answers)),(0,pO.concatMap)(()=>e0o(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&&w4p.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,E4p.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,pO.filter)(i=>i!=null)))}};function S4p(e){let t=function(r,i){let n;try{n=new rTn(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",Cga),this.registerPrompt("input",C7i),this.registerPrompt("number",qga),this.registerPrompt("confirm",Tga),this.registerPrompt("rawlist",Rga),this.registerPrompt("expand",zga),this.registerPrompt("checkbox",Nga),this.registerPrompt("password",Fga),this.registerPrompt("editor",Hga)},t.restoreDefaultPrompts(),t}var mGs=S4p();function JvS(e,t){mGs.registerPrompt(e,t)}function $vS(){mGs.restoreDefaultPrompts()}var YvS={prompt:mGs,ui:{BottomBar:Kga,Prompt:rTn},createPromptModule:S4p,registerPrompt:JvS,restoreDefaultPrompts:$vS,Separator:PH},t0o=YvS;var hTn=require("path"),o3p=require("fs"),u3p=require("readline"),ILp="posthog-node";function PAS(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[A0o.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 A0o=class{constructor(t,r,i,n){this.name=ILp,this.name=ILp,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(PAS(t,{organization:r,projectId:c,prefix:i,severityAllowList:n}))}}};A0o.POSTHOG_ID_TAG="posthog_distinct_id";var y0o="0123456789abcdef",m0o=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+=y0o.charAt(this.bytes[r]>>>4),t+=y0o.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+=y0o.charAt(this.bytes[r]>>>4),t+=y0o.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}},o7s=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??jAS()}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 m0o.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,m0o.ofInner(t)}},jAS=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),CLp,u7s=()=>wAS().toString(),wAS=()=>(CLp||(CLp=new o7s)).generate();function EAS(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 SAS(e,t){global.process.on("uncaughtException",EAS(e,t))}function MAS(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var b0o,qLp,v0o;function DAS(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return v0o&&r.length===qLp||(qLp=r.length,v0o=r.reduce((i,n)=>{b0o||(b0o={});let a=b0o[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,b0o[n]=[s,u];break}}}return i},{})),v0o}function BAS(e){return typeof Event<"u"&&s3p(e,Event)}function IAS(e){return c3p(e,"Object")}function h7s(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return s3p(e,Error)}}function s3p(e,t){try{return e instanceof t}catch{return!1}}function CAS(e){return c3p(e,"ErrorEvent")}function c3p(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function qAS(e,t,r,i){let a=i&&i.mechanism||{handled:!0,type:"generic"},o=l3p(a,r,i);return{$exception_list:await Promise.all(o.map(async s=>{let u=await UAS(e,t,s);return u.value=u.value||"",u.type=u.type||"Error",u.mechanism=a,u}))}}function l3p(e,t,r){let i=TAS(e,t,r);return i.cause?[i,...l3p(e,i.cause,r)]:[i]}function TAS(e,t,r){if(h7s(t))return t;if(e.synthetic=!0,IAS(t)){let n=RAS(t);if(n)return n;let a=zAS(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 RAS(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(h7s(r))return r}}function zAS(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=FAS(e);if(CAS(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=NAS(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function NAS(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function FAS(e,t=40){let r=Object.keys(QAS(e));r.sort();let i=r[0];if(!i)return"[object has no keys]";if(i.length>=t)return TLp(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:TLp(a,t)}return""}function TLp(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function QAS(e){return h7s(e)?{message:e.message,name:e.name,stack:e.stack,...RLp(e)}:BAS(e)?{type:e.type,target:zLp(e.target),currentTarget:zLp(e.currentTarget),...RLp(e)}:e}function RLp(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 zLp(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function UAS(e,t,r){let i={type:r.name||r.constructor.name,value:r.message},n=LAS(e,r);for(let a of t)n=await a(n);return n.length&&(i.stacktrace={frames:n,type:"raw"}),i}function LAS(e,t){return VAS(e(t.stack||"",1),e)}function VAS(e,t){let r=DAS(t);return e.forEach(i=>{i.filename&&(i.chunk_id=r[i.filename])}),e}var WAS=2e3,dTn=class e{static async captureException(t,r,i,n,a){let o={...a};n||(o.$process_person_profile=!1);let c=await qAS(this.stackParser,this.frameModifiers,r,i);t.capture({event:"$exception",distinctId:n||u7s(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(SAS(this.onException.bind(this),this.onFatalError.bind(this)),MAS(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(WAS)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function xAS(e=process.argv[1]?(0,hTn.dirname)(process.argv[1]):process.cwd(),t=hTn.sep==="\\"){let r=t?NLp(e):e;return i=>{if(!i)return;let n=t?NLp(i):i,{dir:a,base:o,ext:c}=hTn.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 NLp(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var P0o=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)}}},O0o=new P0o(25),f3p=new P0o(20),y7s=7,GAS=1e3,HAS=1e4;async function KAS(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"||XAS(o)||ZAS(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(f3p.get(n))continue;let a=t[n];if(!a)continue;a.sort((f,s)=>f-s);let o=emS(a);if(o.every(f=>kAS(n,f)))continue;let c=tmS(O0o,n,{});i.push(JAS(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&$AS(e,O0o),O0o.reduce(),e}function JAS(e,t,r){return new Promise(i=>{let n=(0,o3p.createReadStream)(e),a=(0,u3p.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(){f3p.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]=rmS(_,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 $AS(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;YAS(r.lineno,r,i)}}function YAS(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=d3p(e);n<e;n++){let a=r[n];if(a===void 0){FLp(t);return}t.pre_context.push(a)}if(r[e]===void 0){FLp(t);return}t.context_line=r[e];let i=p3p(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 FLp(e){delete e.pre_context,delete e.context_line,delete e.post_context}function XAS(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function ZAS(e){return e.lineno!==void 0&&e.lineno>HAS||e.colno!==void 0&&e.colno>GAS}function kAS(e,t){let r=O0o.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 emS(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=QLp(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+y7s:(n.push(i),i=QLp(a)),t++}return n}function QLp(e){return[d3p(e),p3p(e)]}function d3p(e){return Math.max(1,e-y7s)}function p3p(e){return e+y7s}function tmS(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function rmS(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 imS="4.18.0",MH;(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"})(MH||(MH={}));var ULp;(function(e){e.Left="left",e.Right="right",e.Center="center"})(ULp||(ULp={}));var LLp;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(LLp||(LLp={}));var VLp;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(VLp||(VLp={}));var WLp;(function(e){e.Html="html",e.Text="text"})(WLp||(WLp={}));var xLp;(function(e){e.Number="number",e.Emoji="emoji"})(xLp||(xLp={}));var GLp;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(GLp||(GLp={}));var HLp;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(HLp||(HLp={}));var KLp;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(KLp||(KLp={}));var JLp;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(JLp||(JLp={}));var nmS=e=>{if("flags"in e){let t=omS(e.flags),r=umS(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,_3p(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,amS(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function amS(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 omS=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,b7s(r)]).filter(([,t])=>t!==void 0)),umS=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?_3p(i):void 0]}))},b7s=e=>e===void 0?void 0:e.variant??e.enabled,_3p=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},smS=1,cmS=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"]),lmS="utf8";function fmS(e,t){if(!e||typeof e!="string"||dmS(e))throw new Error(t)}function dmS(e){return e.trim().length===0}function pmS(e){return e?.replace(/\/+$/,"")}async function _mS(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 $Lp(){return new Date().getTime()}function n7s(){return new Date().toISOString()}function j0o(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function hmS(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function ymS(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=ymS(e);return r?.has(i)?!1:parseInt(i,16)/4294967295<t}function YLp(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var iOa=String.fromCharCode,XLp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",g0o={};function vmS(e,t){if(!g0o[e]){g0o[e]={};for(let r=0;r<e.length;r++)g0o[e][e.charAt(r)]=r}return g0o[e][t]}var lTn={compressToBase64:function(e){if(e==null)return"";let t=lTn._compress(e,6,function(r){return XLp.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:lTn._decompress(e.length,32,function(t){return vmS(XLp,e.charAt(t))})},compress:function(e){return lTn._compress(e,16,function(t){return iOa(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:lTn._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=iOa(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=iOa(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++]=iOa(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++]=iOa(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++)}}},s7s=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)}},pTn=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()}},nOa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function ZLp(e){if(e instanceof pTn){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 a7s(e){return typeof e=="object"&&(e instanceof pTn||e instanceof nOa)}function kLp(e){return typeof e=="object"&&e instanceof pTn&&e.status===413}var c7s;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(c7s||(c7s={}));var l7s=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new s7s,this._isInitialized=!1,fmS(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=pmS(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:a7s},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(MH.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(MH.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(MH.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=u7s();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,smS,cmS)?`${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=>nmS(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=b7s(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(c7s.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(MH.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(MH.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(MH.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(MH.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(MH.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=j0o(()=>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:n7s()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${$Lp()}&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(lTn.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:n7s(),uuid:i?.uuid?i.uuid:u7s()};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 ZLp(t)})}async flush(){let t=YLp([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),YLp([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(MH.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(MH.Queue)||[]).slice(n.length);this.setPersistedProperty(MH.Queue,_),t=_},c={api_key:this.apiKey,batch:a,sent_at:n7s()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${$Lp()}&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(lTn.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:p=>kLp(p)?!1:a7s(p)};try{await this.fetchWithRetry(s,u,l)}catch(p){if(kLp(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 nOa||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,lmS)}catch{c=new TextEncoder().encode(o).length}return await _mS(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(u){throw new nOa(u)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new pTn(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(MH.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!a7s(n))throw n;await ZLp(n)}};return Promise.race([new Promise((n,a)=>{j0o(()=>{this.logMsgIfDebug(()=>console.error("Timed out while shutting down PostHog")),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),i()])}async shutdown(t=3e4){return this.shutdownPromise?this.logMsgIfDebug(()=>console.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup")):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}},f7s=hmS();if(!f7s){let e=BLp();f7s=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var h3p=f7s,w0o=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()}},y3p=new w0o(async()=>{try{return await import("crypto")}catch{return}});async function gmS(){return await y3p.getValue()}var OmS=new w0o(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await y3p.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function AmS(){return await OmS.getValue()}async function mmS(e){let t=await gmS();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await AmS();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 PmS=60*1e3,jmS=1152921504606847e3,wmS=["is_not"],fTn=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)}},d7s=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||h3p,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=v3p(c,n,this.cohorts,this.debugMode):s=b3p(c,n,o),!s)return!1}if(a==null)return!0}return!(a!=null&&await e3p(t.key,r)>a/100)}async getMatchingVariant(t,r){let i=await e3p(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(PmS,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 fTn(`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 fTn(`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 fTn(`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 fTn&&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=j0o(()=>{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=j0o(()=>{a.abort()},this.timeout),i.signal=a.signal}try{return this.fetch(r,i)}finally{clearTimeout(n)}}};async function e3p(e,t,r=""){let i=await mmS(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/jmS}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&&!wmS.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 t3p(String(n))&&String(o).match(String(n))!==null;case"not_regex":return t3p(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=EmS(String(n));if(s==null&&(s=r3p(n)),s==null)throw new v1(`Invalid date: ${n}`);let u=r3p(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new v1(`Unknown operator: ${a}`)}}function v3p(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 g3p(a,t,r,i)}function g3p(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=g3p(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=v3p(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 t3p(e){try{return new RegExp(e),!0}catch{return!1}}function r3p(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 EmS(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 p7s=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},SmS=100,i3p=30*1e3,MmS=50*1e3,_7s=class extends l7s{constructor(t,r={}){if(super(t,r),this._memoryStorage=new p7s,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,SmS):i3p,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 d7s({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 dTn(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||MmS}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):h3p(t,r)}getLibraryVersion(){return imS}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=i3p){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=b7s(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");dTn.captureException(this,t,{syntheticException:n},r,i)}},n3p=/\(error: (.*)\)/,O3p=50,A3p="?";function DmS(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||A3p,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:a3p(n[3]),colno:a3p(n[4]),in_app:BmS(u||"",l),platform:"node:javascript"}}if(i.match(t))return{filename:i,platform:"node:javascript"}}}function BmS(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 a3p(e){return parseInt(e||"",10)||void 0}function ImS(e){return[90,DmS(e)]}function CmS(e){let r=[ImS(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=n3p.test(f)?f.replace(n3p,"$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>=O3p)break}}return qmS(a)}}function qmS(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,O3p).map(r=>({...r,filename:r.filename||TmS(t).filename,function:r.function||A3p}))}function TmS(e){return e[e.length-1]||{}}dTn.stackParser=CmS(xAS());dTn.frameModifiers=[KAS];var _Tn=class extends _7s{getLibraryId(){return"posthog-node"}};var E0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new _Tn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.21.0",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var aOa=class{async sendEvent(){}async identify(){}async flush(){}};var yTn=require("fs/promises"),w3p=require("os"),E3p=require("path");var m3p=ue(require("crypto")),M0o=new Uint8Array(256),S0o=M0o.length;function v7s(){return S0o>M0o.length-16&&(m3p.default.randomFillSync(M0o),S0o=0),M0o.slice(S0o,S0o+=16)}var RQ=[];for(let e=0;e<256;++e)RQ.push((e+256).toString(16).slice(1));function P3p(e,t=0){return RQ[e[t+0]]+RQ[e[t+1]]+RQ[e[t+2]]+RQ[e[t+3]]+"-"+RQ[e[t+4]]+RQ[e[t+5]]+"-"+RQ[e[t+6]]+RQ[e[t+7]]+"-"+RQ[e[t+8]]+RQ[e[t+9]]+"-"+RQ[e[t+10]]+RQ[e[t+11]]+RQ[e[t+12]]+RQ[e[t+13]]+RQ[e[t+14]]+RQ[e[t+15]]}var j3p=ue(require("crypto")),g7s={randomUUID:j3p.default.randomUUID};function RmS(e,t,r){if(g7s.randomUUID&&!t&&!e)return g7s.randomUUID();e=e||{};let i=e.random||(e.rng||v7s)();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 P3p(i)}var k_e=RmS;var zmS="id",NmS=".fern",oOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new _Tn(r),this.userId=t==null?void 0:U8s(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.21.0",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Nt(Fr.of((0,w3p.homedir)()),Ze.of(NmS),Ze.of(zmS));await qi(t)||(await(0,yTn.mkdir)((0,E3p.dirname)(t),{recursive:!0}),await(0,yTn.writeFile)(t,k_e())),this.persistedDistinctId=(await(0,yTn.readFile)(t)).toString()}return this.persistedDistinctId}};var O7s;async function bTn(){return O7s==null&&(O7s=await FmS()),O7s}async function FmS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new aOa;let r=await Gyo();return r!=null?new oOa({token:r,posthogApiKey:e}):await Oqn()!=null?new E0o({posthogApiKey:e}):new oOa({token:void 0,posthogApiKey:e})}catch{return new aOa}}function uOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:QmS}=Object.prototype,{getPrototypeOf:m7s}=Object,{iterator:B0o,toStringTag:M3p}=Symbol,I0o=(e=>t=>{let r=QmS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),zNt=e=>(e=e.toLowerCase(),t=>I0o(t)===e),C0o=e=>t=>typeof t===e,{isArray:gTn}=Array,vTn=C0o("undefined");function sOa(e){return e!==null&&!vTn(e)&&e.constructor!==null&&!vTn(e.constructor)&&DH(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var D3p=zNt("ArrayBuffer");function UmS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&D3p(e.buffer),t}var LmS=C0o("string"),DH=C0o("function"),B3p=C0o("number"),cOa=e=>e!==null&&typeof e=="object",VmS=e=>e===!0||e===!1,D0o=e=>{if(I0o(e)!=="object")return!1;let t=m7s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(M3p in e)&&!(B0o in e)},WmS=e=>{if(!cOa(e)||sOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},xmS=zNt("Date"),GmS=zNt("File"),HmS=zNt("Blob"),KmS=zNt("FileList"),JmS=e=>cOa(e)&&DH(e.pipe),$mS=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||DH(e.append)&&((t=I0o(e))==="formdata"||t==="object"&&DH(e.toString)&&e.toString()==="[object FormData]"))},YmS=zNt("URLSearchParams"),[XmS,ZmS,kmS,e0S]=["ReadableStream","Request","Response","Headers"].map(zNt),t0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function lOa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),gTn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(sOa(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 I3p(e,t){if(sOa(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 W7i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,C3p=e=>!vTn(e)&&e!==W7i;function A7s(){let{caseless:e,skipUndefined:t}=C3p(this)&&this||{},r={},i=(n,a)=>{let o=e&&I3p(r,a)||a;D0o(r[o])&&D0o(n)?r[o]=A7s(r[o],n):D0o(n)?r[o]=A7s({},n):gTn(n)?r[o]=n.slice():(!t||!vTn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&lOa(arguments[n],i);return r}var r0S=(e,t,r,{allOwnKeys:i}={})=>(lOa(t,(n,a)=>{r&&DH(n)?e[a]=uOa(n,r):e[a]=n},{allOwnKeys:i}),e),i0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),n0S=(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)},a0S=(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&&m7s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},o0S=(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},u0S=e=>{if(!e)return null;if(gTn(e))return e;let t=e.length;if(!B3p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},s0S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&m7s(Uint8Array)),c0S=(e,t)=>{let i=(e&&e[B0o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},l0S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},f0S=zNt("HTMLFormElement"),d0S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),S3p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),p0S=zNt("RegExp"),q3p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};lOa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},_0S=e=>{q3p(e,(t,r)=>{if(DH(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(DH(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+"'")})}})},h0S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return gTn(e)?i(e):i(String(e).split(t)),r},y0S=()=>{},b0S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function v0S(e){return!!(e&&DH(e.append)&&e[M3p]==="FormData"&&e[B0o])}var g0S=e=>{let t=new Array(10),r=(i,n)=>{if(cOa(i)){if(t.indexOf(i)>=0)return;if(sOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=gTn(i)?[]:{};return lOa(i,(o,c)=>{let f=r(o,n+1);!vTn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},O0S=zNt("AsyncFunction"),A0S=e=>e&&(cOa(e)||DH(e))&&DH(e.then)&&DH(e.catch),T3p=((e,t)=>e?setImmediate:t?((r,i)=>(W7i.addEventListener("message",({source:n,data:a})=>{n===W7i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),W7i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",DH(W7i.postMessage)),m0S=typeof queueMicrotask<"u"?queueMicrotask.bind(W7i):typeof process<"u"&&process.nextTick||T3p,P0S=e=>e!=null&&DH(e[B0o]),er={isArray:gTn,isArrayBuffer:D3p,isBuffer:sOa,isFormData:$mS,isArrayBufferView:UmS,isString:LmS,isNumber:B3p,isBoolean:VmS,isObject:cOa,isPlainObject:D0o,isEmptyObject:WmS,isReadableStream:XmS,isRequest:ZmS,isResponse:kmS,isHeaders:e0S,isUndefined:vTn,isDate:xmS,isFile:GmS,isBlob:HmS,isRegExp:p0S,isFunction:DH,isStream:JmS,isURLSearchParams:YmS,isTypedArray:s0S,isFileList:KmS,forEach:lOa,merge:A7s,extend:r0S,trim:t0S,stripBOM:i0S,inherits:n0S,toFlatObject:a0S,kindOf:I0o,kindOfTest:zNt,endsWith:o0S,toArray:u0S,forEachEntry:c0S,matchAll:l0S,isHTMLForm:f0S,hasOwnProperty:S3p,hasOwnProp:S3p,reduceDescriptors:q3p,freezeMethods:_0S,toObjectSet:h0S,toCamelCase:d0S,noop:y0S,toFiniteNumber:b0S,findKey:I3p,global:W7i,isContextDefined:C3p,isSpecCompliantForm:v0S,toJSONObject:g0S,isAsyncFn:O0S,isThenable:A0S,setImmediate:T3p,asap:m0S,isIterable:P0S};function OTn(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(OTn,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 R3p=OTn.prototype,z3p={};["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=>{z3p[e]={value:e}});Object.defineProperties(OTn,z3p);Object.defineProperty(R3p,"isAxiosError",{value:!0});OTn.from=(e,t,r,i,n,a)=>{let o=Object.create(R3p);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 OTn.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=OTn;var N3p=ue(SGi(),1),q0o=N3p.default;function P7s(e){return er.isPlainObject(e)||er.isArray(e)}function Q3p(e){return er.endsWith(e,"[]")?e.slice(0,-2):e}function F3p(e,t,r){return e?e.concat(t).map(function(n,a){return n=Q3p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function j0S(e){return er.isArray(e)&&!e.some(P7s)}var w0S=er.toFlatObject(er,{},null,function(t){return/^is[A-Z]/.test(t)});function E0S(e,t,r){if(!er.isObject(e))throw new TypeError("target must be an object");t=t||new(q0o||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)&&j0S(h)||(er.isFileList(h)||er.endsWith(y,"[]"))&&(v=er.toArray(h)))return y=Q3p(y),v.forEach(function(A,g){!(er.isUndefined(A)||A===null)&&t.append(o===!0?F3p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return P7s(h)?!0:(t.append(F3p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(w0S,{defaultVisitor:u,convertValue:s,isVisitable:P7s});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 qBi=E0S;function U3p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function L3p(e,t){this._pairs=[],e&&qBi(e,this,t)}var V3p=L3p.prototype;V3p.append=function(t,r){this._pairs.push([t,r])};V3p.toString=function(t){let r=t?function(i){return t.call(this,i,U3p)}:U3p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var W3p=L3p;function S0S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function x7i(e,t,r){if(!t)return e;let i=r&&r.encode||S0S;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 W3p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var j7s=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)})}},w7s=j7s;var ATn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var K3p=ue(require("crypto"),1);var x3p=ue(require("url"),1),G3p=x3p.default.URLSearchParams;var E7s="abcdefghijklmnopqrstuvwxyz",H3p="0123456789",J3p={DIGIT:H3p,ALPHA:E7s,ALPHA_DIGIT:E7s+E7s.toUpperCase()+H3p},M0S=(e=16,t=J3p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);K3p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},$3p={isNode:!0,classes:{URLSearchParams:G3p,FormData:q0o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:J3p,generateString:M0S,protocols:["http","https","file","data"]};var D7s={};Yt(D7s,{hasBrowserEnv:()=>M7s,hasStandardBrowserEnv:()=>D0S,hasStandardBrowserWebWorkerEnv:()=>B0S,navigator:()=>S7s,origin:()=>I0S});var M7s=typeof window<"u"&&typeof document<"u",S7s=typeof navigator=="object"&&navigator||void 0,D0S=M7s&&(!S7s||["ReactNative","NativeScript","NS"].indexOf(S7s.product)<0),B0S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",I0S=M7s&&window.location.href||"http://localhost";var OA={...D7s,...$3p};function B7s(e,t){return qBi(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 C0S(e){return er.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function q0S(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 T0S(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]=q0S(n[o])),!c)}if(er.isFormData(e)&&er.isFunction(e.entries)){let r={};return er.forEachEntry(e,(i,n)=>{t(C0S(i),n,r,0)}),r}return null}var T0o=T0S;function R0S(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 I7s={transitional:ATn,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(T0o(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 B7s(t,this.formSerializer).toString();if((c=er.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return qBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),R0S(t)):t}],transformResponse:[function(t){let r=this.transitional||I7s.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=>{I7s.headers[e]={}});var mTn=I7s;var z0S=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"]),Y3p=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=n3p.test(f)?f.replace(n3p,"$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>=O3p)break}}return qmS(a)}}function qmS(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,O3p).map(r=>({...r,filename:r.filename||TmS(t).filename,function:r.function||A3p}))}function TmS(e){return e[e.length-1]||{}}dTn.stackParser=CmS(xAS());dTn.frameModifiers=[KAS];var _Tn=class extends _7s{getLibraryId(){return"posthog-node"}};var E0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new _Tn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.21.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var aOa=class{async sendEvent(){}async identify(){}async flush(){}};var yTn=require("fs/promises"),w3p=require("os"),E3p=require("path");var m3p=ue(require("crypto")),M0o=new Uint8Array(256),S0o=M0o.length;function v7s(){return S0o>M0o.length-16&&(m3p.default.randomFillSync(M0o),S0o=0),M0o.slice(S0o,S0o+=16)}var RQ=[];for(let e=0;e<256;++e)RQ.push((e+256).toString(16).slice(1));function P3p(e,t=0){return RQ[e[t+0]]+RQ[e[t+1]]+RQ[e[t+2]]+RQ[e[t+3]]+"-"+RQ[e[t+4]]+RQ[e[t+5]]+"-"+RQ[e[t+6]]+RQ[e[t+7]]+"-"+RQ[e[t+8]]+RQ[e[t+9]]+"-"+RQ[e[t+10]]+RQ[e[t+11]]+RQ[e[t+12]]+RQ[e[t+13]]+RQ[e[t+14]]+RQ[e[t+15]]}var j3p=ue(require("crypto")),g7s={randomUUID:j3p.default.randomUUID};function RmS(e,t,r){if(g7s.randomUUID&&!t&&!e)return g7s.randomUUID();e=e||{};let i=e.random||(e.rng||v7s)();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 P3p(i)}var k_e=RmS;var zmS="id",NmS=".fern",oOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new _Tn(r),this.userId=t==null?void 0:U8s(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.21.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Nt(Fr.of((0,w3p.homedir)()),Ze.of(NmS),Ze.of(zmS));await qi(t)||(await(0,yTn.mkdir)((0,E3p.dirname)(t),{recursive:!0}),await(0,yTn.writeFile)(t,k_e())),this.persistedDistinctId=(await(0,yTn.readFile)(t)).toString()}return this.persistedDistinctId}};var O7s;async function bTn(){return O7s==null&&(O7s=await FmS()),O7s}async function FmS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new aOa;let r=await Gyo();return r!=null?new oOa({token:r,posthogApiKey:e}):await Oqn()!=null?new E0o({posthogApiKey:e}):new oOa({token:void 0,posthogApiKey:e})}catch{return new aOa}}function uOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:QmS}=Object.prototype,{getPrototypeOf:m7s}=Object,{iterator:B0o,toStringTag:M3p}=Symbol,I0o=(e=>t=>{let r=QmS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),zNt=e=>(e=e.toLowerCase(),t=>I0o(t)===e),C0o=e=>t=>typeof t===e,{isArray:gTn}=Array,vTn=C0o("undefined");function sOa(e){return e!==null&&!vTn(e)&&e.constructor!==null&&!vTn(e.constructor)&&DH(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var D3p=zNt("ArrayBuffer");function UmS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&D3p(e.buffer),t}var LmS=C0o("string"),DH=C0o("function"),B3p=C0o("number"),cOa=e=>e!==null&&typeof e=="object",VmS=e=>e===!0||e===!1,D0o=e=>{if(I0o(e)!=="object")return!1;let t=m7s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(M3p in e)&&!(B0o in e)},WmS=e=>{if(!cOa(e)||sOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},xmS=zNt("Date"),GmS=zNt("File"),HmS=zNt("Blob"),KmS=zNt("FileList"),JmS=e=>cOa(e)&&DH(e.pipe),$mS=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||DH(e.append)&&((t=I0o(e))==="formdata"||t==="object"&&DH(e.toString)&&e.toString()==="[object FormData]"))},YmS=zNt("URLSearchParams"),[XmS,ZmS,kmS,e0S]=["ReadableStream","Request","Response","Headers"].map(zNt),t0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function lOa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),gTn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(sOa(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 I3p(e,t){if(sOa(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 W7i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,C3p=e=>!vTn(e)&&e!==W7i;function A7s(){let{caseless:e,skipUndefined:t}=C3p(this)&&this||{},r={},i=(n,a)=>{let o=e&&I3p(r,a)||a;D0o(r[o])&&D0o(n)?r[o]=A7s(r[o],n):D0o(n)?r[o]=A7s({},n):gTn(n)?r[o]=n.slice():(!t||!vTn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&lOa(arguments[n],i);return r}var r0S=(e,t,r,{allOwnKeys:i}={})=>(lOa(t,(n,a)=>{r&&DH(n)?e[a]=uOa(n,r):e[a]=n},{allOwnKeys:i}),e),i0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),n0S=(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)},a0S=(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&&m7s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},o0S=(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},u0S=e=>{if(!e)return null;if(gTn(e))return e;let t=e.length;if(!B3p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},s0S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&m7s(Uint8Array)),c0S=(e,t)=>{let i=(e&&e[B0o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},l0S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},f0S=zNt("HTMLFormElement"),d0S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),S3p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),p0S=zNt("RegExp"),q3p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};lOa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},_0S=e=>{q3p(e,(t,r)=>{if(DH(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(DH(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+"'")})}})},h0S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return gTn(e)?i(e):i(String(e).split(t)),r},y0S=()=>{},b0S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function v0S(e){return!!(e&&DH(e.append)&&e[M3p]==="FormData"&&e[B0o])}var g0S=e=>{let t=new Array(10),r=(i,n)=>{if(cOa(i)){if(t.indexOf(i)>=0)return;if(sOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=gTn(i)?[]:{};return lOa(i,(o,c)=>{let f=r(o,n+1);!vTn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},O0S=zNt("AsyncFunction"),A0S=e=>e&&(cOa(e)||DH(e))&&DH(e.then)&&DH(e.catch),T3p=((e,t)=>e?setImmediate:t?((r,i)=>(W7i.addEventListener("message",({source:n,data:a})=>{n===W7i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),W7i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",DH(W7i.postMessage)),m0S=typeof queueMicrotask<"u"?queueMicrotask.bind(W7i):typeof process<"u"&&process.nextTick||T3p,P0S=e=>e!=null&&DH(e[B0o]),er={isArray:gTn,isArrayBuffer:D3p,isBuffer:sOa,isFormData:$mS,isArrayBufferView:UmS,isString:LmS,isNumber:B3p,isBoolean:VmS,isObject:cOa,isPlainObject:D0o,isEmptyObject:WmS,isReadableStream:XmS,isRequest:ZmS,isResponse:kmS,isHeaders:e0S,isUndefined:vTn,isDate:xmS,isFile:GmS,isBlob:HmS,isRegExp:p0S,isFunction:DH,isStream:JmS,isURLSearchParams:YmS,isTypedArray:s0S,isFileList:KmS,forEach:lOa,merge:A7s,extend:r0S,trim:t0S,stripBOM:i0S,inherits:n0S,toFlatObject:a0S,kindOf:I0o,kindOfTest:zNt,endsWith:o0S,toArray:u0S,forEachEntry:c0S,matchAll:l0S,isHTMLForm:f0S,hasOwnProperty:S3p,hasOwnProp:S3p,reduceDescriptors:q3p,freezeMethods:_0S,toObjectSet:h0S,toCamelCase:d0S,noop:y0S,toFiniteNumber:b0S,findKey:I3p,global:W7i,isContextDefined:C3p,isSpecCompliantForm:v0S,toJSONObject:g0S,isAsyncFn:O0S,isThenable:A0S,setImmediate:T3p,asap:m0S,isIterable:P0S};function OTn(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(OTn,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 R3p=OTn.prototype,z3p={};["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=>{z3p[e]={value:e}});Object.defineProperties(OTn,z3p);Object.defineProperty(R3p,"isAxiosError",{value:!0});OTn.from=(e,t,r,i,n,a)=>{let o=Object.create(R3p);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 OTn.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=OTn;var N3p=ue(SGi(),1),q0o=N3p.default;function P7s(e){return er.isPlainObject(e)||er.isArray(e)}function Q3p(e){return er.endsWith(e,"[]")?e.slice(0,-2):e}function F3p(e,t,r){return e?e.concat(t).map(function(n,a){return n=Q3p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function j0S(e){return er.isArray(e)&&!e.some(P7s)}var w0S=er.toFlatObject(er,{},null,function(t){return/^is[A-Z]/.test(t)});function E0S(e,t,r){if(!er.isObject(e))throw new TypeError("target must be an object");t=t||new(q0o||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)&&j0S(h)||(er.isFileList(h)||er.endsWith(y,"[]"))&&(v=er.toArray(h)))return y=Q3p(y),v.forEach(function(A,g){!(er.isUndefined(A)||A===null)&&t.append(o===!0?F3p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return P7s(h)?!0:(t.append(F3p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(w0S,{defaultVisitor:u,convertValue:s,isVisitable:P7s});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 qBi=E0S;function U3p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function L3p(e,t){this._pairs=[],e&&qBi(e,this,t)}var V3p=L3p.prototype;V3p.append=function(t,r){this._pairs.push([t,r])};V3p.toString=function(t){let r=t?function(i){return t.call(this,i,U3p)}:U3p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var W3p=L3p;function S0S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function x7i(e,t,r){if(!t)return e;let i=r&&r.encode||S0S;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 W3p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var j7s=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)})}},w7s=j7s;var ATn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var K3p=ue(require("crypto"),1);var x3p=ue(require("url"),1),G3p=x3p.default.URLSearchParams;var E7s="abcdefghijklmnopqrstuvwxyz",H3p="0123456789",J3p={DIGIT:H3p,ALPHA:E7s,ALPHA_DIGIT:E7s+E7s.toUpperCase()+H3p},M0S=(e=16,t=J3p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);K3p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},$3p={isNode:!0,classes:{URLSearchParams:G3p,FormData:q0o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:J3p,generateString:M0S,protocols:["http","https","file","data"]};var D7s={};Yt(D7s,{hasBrowserEnv:()=>M7s,hasStandardBrowserEnv:()=>D0S,hasStandardBrowserWebWorkerEnv:()=>B0S,navigator:()=>S7s,origin:()=>I0S});var M7s=typeof window<"u"&&typeof document<"u",S7s=typeof navigator=="object"&&navigator||void 0,D0S=M7s&&(!S7s||["ReactNative","NativeScript","NS"].indexOf(S7s.product)<0),B0S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",I0S=M7s&&window.location.href||"http://localhost";var OA={...D7s,...$3p};function B7s(e,t){return qBi(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 C0S(e){return er.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function q0S(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 T0S(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]=q0S(n[o])),!c)}if(er.isFormData(e)&&er.isFunction(e.entries)){let r={};return er.forEachEntry(e,(i,n)=>{t(C0S(i),n,r,0)}),r}return null}var T0o=T0S;function R0S(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 I7s={transitional:ATn,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(T0o(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 B7s(t,this.formSerializer).toString();if((c=er.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return qBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),R0S(t)):t}],transformResponse:[function(t){let r=this.transitional||I7s.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=>{I7s.headers[e]={}});var mTn=I7s;var z0S=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"]),Y3p=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]&&z0S[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var X3p=Symbol("internals");function fOa(e){return e&&String(e).trim().toLowerCase()}function R0o(e){return e===!1||e==null?e:er.isArray(e)?e.map(R0o):String(e)}function N0S(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 F0S=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function C7s(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 Q0S(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function U0S(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 PTn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,f,s){let u=fOa(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]=R0o(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())&&!F0S(t))o(Y3p(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=fOa(t),t){let i=er.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return N0S(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=fOa(t),t){let i=er.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||C7s(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(o){if(o=fOa(o),o){let c=er.findKey(i,o);c&&(!r||C7s(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||C7s(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]=R0o(n),delete r[a];return}let c=t?Q0S(a):String(a).trim();c!==a&&delete r[a],r[c]=R0o(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[X3p]=this[X3p]={accessors:{}}).accessors,n=this.prototype;function a(o){let c=fOa(o);i[c]||(U0S(n,o),i[c]=!0)}return er.isArray(t)?t.forEach(a):a(t),this}};PTn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);er.reduceDescriptors(PTn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});er.freezeMethods(PTn);var QS=PTn;function dOa(e,t){let r=this||mTn,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 pOa(e){return!!(e&&e.__CANCEL__)}function Z3p(e,t,r){ha.call(this,e??"canceled",ha.ERR_CANCELED,t,r),this.name="CanceledError"}er.inherits(Z3p,ha,{__CANCEL__:!0});var ehe=Z3p;function n6t(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 q7s(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function T7s(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function G7i(e,t,r){let i=!q7s(t);return e&&(i||r==!1)?T7s(e,t):t}var _8p=ue(r0o(),1),h8p=ue(require("http"),1),y8p=ue(require("https"),1),b8p=ue(require("util"),1),v8p=ue(RGs(),1),Fbi=ue(require("zlib"),1);var H7i="1.12.2";function _Oa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var L0S=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function R7s(e,t,r){let i=r&&r.Blob||OA.classes.Blob,n=_Oa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=L0S.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 J7i=ue(require("stream"),1);var k3p=ue(require("stream"),1);var z7s=Symbol("internals"),N7s=class extends k3p.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[z7s]={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[z7s];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[z7s],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)})}},F7s=N7s;var g8p=require("events");var t8p=ue(require("util"),1),r8p=require("stream");var{asyncIterator:e8p}=Symbol,V0S=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[e8p]?yield*e[e8p]():yield e},z0o=V0S;var W0S=OA.ALPHABET.ALPHA_DIGIT+"-_",hOa=typeof TextEncoder=="function"?new TextEncoder:new t8p.default.TextEncoder,K7i=`\r
1153
1153
  `,x0S=hOa.encode(K7i),G0S=2,Q7s=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)}"`:""}${K7i}`;n?r=hOa.encode(String(r).replace(/\r?\n|\r\n?/g,K7i)):a+=`Content-Type: ${r.type||"application/octet-stream"}${K7i}`,this.headers=hOa.encode(a+K7i),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+G0S,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;er.isTypedArray(t)?yield t:yield*z0o(t),yield x0S}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},H0S=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+OA.generateString(n,W0S)}=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=hOa.encode("--"+a+K7i),c=hOa.encode("--"+a+"--"+K7i),f=c.byteLength,s=Array.from(e.entries()).map(([l,p])=>{let _=new Q7s(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),r8p.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},i8p=H0S;var n8p=ue(require("stream"),1),U7s=class extends n8p.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)}},a8p=U7s;var K0S=(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,o8p=K0S;function J0S(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 u8p=J0S;function $0S(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 s8p=$0S;var Nbi=(e,t,r=3)=>{let i=0,n=u8p(50,250);return s8p(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)},jTn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},wTn=e=>(...t)=>er.asap(()=>e(...t));function L7s(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 c8p={flush:Fbi.default.constants.Z_SYNC_FLUSH,finishFlush:Fbi.default.constants.Z_SYNC_FLUSH},Y0S={flush:Fbi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:Fbi.default.constants.BROTLI_OPERATION_FLUSH},l8p=er.isFunction(Fbi.default.createBrotliDecompress),{http:X0S,https:Z0S}=v8p.default,k0S=/https:?/,f8p=OA.protocols.map(e=>e+":"),d8p=(e,[t,r])=>(e.on("end",r).on("error",r),t);function ePS(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function O8p(e,t,r){let i=t;if(!i&&i!==!1){let n=_8p.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){O8p(a,t,a.href)}}var tPS=typeof process<"u"&&er.kindOf(process)==="process",rPS=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)}),iPS=({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)}},p8p=(e,t)=>iPS(er.isObject(e)?e:{address:e,family:t}),A8p=tPS&&function(t){return rPS(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 K=o8p(c,fe=>er.isArray(fe)?fe:[fe]);c=(fe,pe,L)=>{K(fe,pe,(G,Re,le)=>{if(G)return L(G);let De=er.isArray(Re)?Re.map(Ke=>p8p(Ke)):[p8p(Re,le)];pe.all?L(G,De):L(G,De[0].address,De[0].family)})}}let y=new g8p.EventEmitter,b=()=>{t.cancelToken&&t.cancelToken.unsubscribe(v),t.signal&&t.signal.removeEventListener("abort",v),y.removeAllListeners()};a((K,fe)=>{p=!0,fe&&(_=!0,b())});function v(K){y.emit("abort",!K||K.type?new ehe(null,t,h):K)}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=G7i(t.baseURL,t.url,t.allowAbsoluteUrls),A=new URL(O,OA.hasBrowserEnv?OA.origin:void 0),g=A.protocol||f8p[0];if(g==="data:"){if(t.maxContentLength>-1){let fe=String(t.url||O||"");if(L7s(fe)>t.maxContentLength)return n(new ha("maxContentLength size of "+t.maxContentLength+" exceeded",ha.ERR_BAD_RESPONSE,t))}let K;if(l!=="GET")return n6t(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{K=R7s(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(fe){throw ha.from(fe,ha.ERR_BAD_REQUEST,t)}return s==="text"?(K=K.toString(u),(!u||u==="utf8")&&(K=er.stripBOM(K))):s==="stream"&&(K=J7i.default.Readable.from(K)),n6t(i,n,{data:K,status:200,statusText:"OK",headers:new QS,config:t})}if(f8p.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/"+H7i,!1);let{onUploadProgress:j,onDownloadProgress:M}=t,E=t.maxRate,D,B;if(er.isSpecCompliantForm(o)){let K=m.getContentType(/boundary=([-_\w\d]{10,70})/i);o=i8p(o,fe=>{m.set(fe)},{tag:`axios-${H7i}-boundary`,boundary:K&&K[1]||void 0})}else if(er.isFormData(o)&&er.isFunction(o.getHeaders)){if(m.set(o.getHeaders()),!m.hasContentLength())try{let K=await b8p.default.promisify(o.getLength).call(o);Number.isFinite(K)&&K>=0&&m.setContentLength(K)}catch{}}else if(er.isBlob(o)||er.isFile(o))o.size&&m.setContentType(o.type||"application/octet-stream"),m.setContentLength(o.size||0),o=J7i.default.Readable.from(z0o(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=J7i.default.Readable.from(o,{objectMode:!1})),o=J7i.default.pipeline([o,new F7s({maxRate:er.toFiniteNumber(D)})],er.noop),j&&o.on("progress",d8p(o,jTn(F,Nbi(wTn(j),!1,3)))));let N;if(t.auth){let K=t.auth.username||"",fe=t.auth.password||"";N=K+":"+fe}if(!N&&A.username){let K=A.username,fe=A.password;N=K+":"+fe}N&&m.delete("authorization");let R;try{R=x7i(A.pathname+A.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(K){let fe=new Error(K.message);return fe.config=t,fe.url=t.url,fe.exists=!0,n(fe)}m.set("Accept-Encoding","gzip, compress, deflate"+(l8p?", 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:ePS,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,O8p(z,t.proxy,g+"//"+A.hostname+(A.port?":"+A.port:"")+z.path));let U,W=k0S.test(z.protocol);if(z.agent=W?t.httpsAgent:t.httpAgent,t.transport?U=t.transport:t.maxRedirects===0?U=W?y8p.default:h8p.default:(t.maxRedirects&&(z.maxRedirects=t.maxRedirects),t.beforeRedirect&&(z.beforeRedirects.config=t.beforeRedirect),U=W?Z0S:X0S),t.maxBodyLength>-1?z.maxBodyLength=t.maxBodyLength:z.maxBodyLength=1/0,t.insecureHTTPParser&&(z.insecureHTTPParser=t.insecureHTTPParser),h=U.request(z,function(fe){if(h.destroyed)return;let pe=[fe],L=+fe.headers["content-length"];if(M||B){let Ke=new F7s({maxRate:er.toFiniteNumber(B)});M&&Ke.on("progress",d8p(Ke,jTn(L,Nbi(wTn(M),!0,3)))),pe.push(Ke)}let G=fe,Re=fe.req||h;if(t.decompress!==!1&&fe.headers["content-encoding"])switch((l==="HEAD"||fe.statusCode===204)&&delete fe.headers["content-encoding"],(fe.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":pe.push(Fbi.default.createUnzip(c8p)),delete fe.headers["content-encoding"];break;case"deflate":pe.push(new a8p),pe.push(Fbi.default.createUnzip(c8p)),delete fe.headers["content-encoding"];break;case"br":l8p&&(pe.push(Fbi.default.createBrotliDecompress(Y0S)),delete fe.headers["content-encoding"])}G=pe.length>1?J7i.default.pipeline(pe,er.noop):pe[0];let le=J7i.default.finished(G,()=>{le(),b()}),De={status:fe.statusCode,statusText:fe.statusMessage,headers:new QS(fe.headers),config:t,request:Re};if(s==="stream")De.data=G,n6t(i,n,De);else{let Ke=[],se=0;G.on("data",function(Je){Ke.push(Je),se+=Je.length,t.maxContentLength>-1&&se>t.maxContentLength&&(_=!0,G.destroy(),n(new ha("maxContentLength size of "+t.maxContentLength+" exceeded",ha.ERR_BAD_RESPONSE,t,Re)))}),G.on("aborted",function(){if(_)return;let Je=new ha("stream has been aborted",ha.ERR_BAD_RESPONSE,t,Re);G.destroy(Je),n(Je)}),G.on("error",function(Je){h.destroyed||n(ha.from(Je,null,t,Re))}),G.on("end",function(){try{let Je=Ke.length===1?Ke[0]:Buffer.concat(Ke);s!=="arraybuffer"&&(Je=Je.toString(u),(!u||u==="utf8")&&(Je=er.stripBOM(Je))),De.data=Je}catch(Je){return n(ha.from(Je,null,t,De.request,De))}n6t(i,n,De)})}y.once("abort",Ke=>{G.destroyed||(G.emit("error",Ke),G.destroy())})}),y.once("abort",K=>{n(K),h.destroy(K)}),h.on("error",function(fe){n(ha.from(fe,null,t,h))}),h.on("socket",function(fe){fe.setKeepAlive(!0,1e3*60)}),t.timeout){let K=parseInt(t.timeout,10);if(Number.isNaN(K)){n(new ha("error trying to parse `config.timeout` to int",ha.ERR_BAD_OPTION_VALUE,t,h));return}h.setTimeout(K,function(){if(p)return;let pe=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",L=t.transitional||ATn;t.timeoutErrorMessage&&(pe=t.timeoutErrorMessage),n(new ha(pe,L.clarifyTimeoutError?ha.ETIMEDOUT:ha.ECONNABORTED,t,h)),v()})}if(er.isStream(o)){let K=!1,fe=!1;o.on("end",()=>{K=!0}),o.once("error",pe=>{fe=!0,h.destroy(pe)}),o.on("close",()=>{!K&&!fe&&v(new ehe("Request stream has been aborted",t,h))}),o.pipe(h)}else h.end(o)})};var m8p=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 P8p=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 j8p=e=>e instanceof QS?{...e}:e;function NNt(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(j8p(s),j8p(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 N0o=e=>{let t=NNt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=QS.from(o),t.url=x7i(G7i(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&&m8p(t.url))){let f=n&&a&&P8p.read(a);f&&o.set(n,f)}return t};var nPS=typeof XMLHttpRequest<"u",w8p=nPS&&function(e){return new Promise(function(r,i){let n=N0o(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};n6t(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||ATn;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]=Nbi(s,!0),b.addEventListener("progress",p)),f&&b.upload&&([l,_]=Nbi(f),b.upload.addEventListener("progress",l),b.upload.addEventListener("loadend",_)),(n.cancelToken||n.signal)&&(u=A=>{b&&(i(!A||A.type?new ehe(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=_Oa(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 aPS=(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 ehe(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}},E8p=aPS;var oPS=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},uPS=async function*(e,t){for await(let r of sPS(e))yield*oPS(r,t)},sPS=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()}},V7s=(e,t,r,i)=>{let n=uPS(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 S8p=64*1024,{isFunction:F0o}=er,cPS=(({Request:e,Response:t})=>({Request:e,Response:t}))(er.global),{ReadableStream:M8p,TextEncoder:D8p}=er.global,B8p=(e,...t)=>{try{return!!e(...t)}catch{return!1}},lPS=e=>{e=er.merge.call({skipUndefined:!0},cPS,e);let{fetch:t,Request:r,Response:i}=e,n=t?F0o(t):typeof fetch=="function",a=F0o(r),o=F0o(i);if(!n)return!1;let c=n&&F0o(M8p),f=n&&(typeof D8p=="function"?(h=>y=>h.encode(y))(new D8p):async h=>new Uint8Array(await new r(h).arrayBuffer())),s=a&&c&&B8p(()=>{let h=!1,y=new r(OA.origin,{body:new M8p,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!y}),u=o&&c&&B8p(()=>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}=N0o(h),F=t||fetch;M=M?(M+"").toLowerCase():"text";let N=E8p([O,A&&A.toAbortSignal()],g),R=null,z=N&&N.unsubscribe&&(()=>{N.unsubscribe()}),U;try{if(j&&s&&b!=="get"&&b!=="head"&&(U=await _(E,v))!==0){let G=new r(y,{method:"POST",body:v,duplex:"half"}),Re;if(er.isFormData(v)&&(Re=G.headers.get("content-type"))&&E.setContentType(Re),G.body){let[le,De]=jTn(U,Nbi(wTn(j)));v=V7s(G.body,S8p,le,De)}}er.isString(D)||(D=D?"include":"omit");let W=a&&"credentials"in r.prototype,K={...B,signal:N,method:b.toUpperCase(),headers:E.normalize().toJSON(),body:v,duplex:"half",credentials:W?D:void 0};R=a&&new r(y,K);let fe=await(a?F(R,B):F(y,K)),pe=u&&(M==="stream"||M==="response");if(u&&(m||pe&&z)){let G={};["status","statusText","headers"].forEach(Ke=>{G[Ke]=fe[Ke]});let Re=er.toFiniteNumber(fe.headers.get("content-length")),[le,De]=m&&jTn(Re,Nbi(wTn(m),!0))||[];fe=new i(V7s(fe.body,S8p,le,()=>{De&&De(),z&&z()}),G)}M=M||"text";let L=await l[er.findKey(l,M)||"text"](fe,h);return!pe&&z&&z(),await new Promise((G,Re)=>{n6t(G,Re,{data:L,headers:QS.from(fe.headers),status:fe.status,statusText:fe.statusText,config:h,request:R})})}catch(W){throw z&&z(),W&&W.name==="TypeError"&&/Load failed|fetch/i.test(W.message)?Object.assign(new ha("Network Error",ha.ERR_NETWORK,h,R),{cause:W.cause||W}):ha.from(W,W&&W.code,h,R)}}},fPS=new Map,W7s=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=fPS;for(;c--;)f=a[c],s=u.get(f),s===void 0&&u.set(f,s=c?new Map:lPS(t)),u=s;return s},Xv5=W7s();var x7s={http:A8p,xhr:w8p,fetch:{get:W7s}};er.forEach(x7s,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var I8p=e=>`- ${e}`,pPS=e=>er.isFunction(e)||e===null||e===!1,Q0o={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,!pPS(i)&&(n=x7s[(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 :
@@ -1349,7 +1349,7 @@ For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides
1349
1349
  `)),super.launch(t)}async computeLaunchArguments(t={}){let{ignoreDefaultArgs:r=!1,args:i=[],pipe:n=!1,debuggingPort:a,channel:o,executablePath:c}=t,f=[];r?Array.isArray(r)?f.push(...this.defaultArgs(t).filter(_=>!r.includes(_))):f.push(...i):f.push(...this.defaultArgs(t)),f.some(_=>_.startsWith("--remote-debugging-"))||(n?(Ei(!a,"Browser should be launched with either pipe or debugging port - not both."),f.push("--remote-debugging-pipe")):f.push(`--remote-debugging-port=${a||0}`));let s=!1,u=f.findIndex(_=>_.startsWith("--user-data-dir"));u<0&&(s=!0,f.push(`--user-data-dir=${await(0,Rr_.mkdtemp)(this.getProfilePath())}`),u=f.length-1);let l=f[u].split("=",2)[1];Ei(typeof l=="string","`--user-data-dir` is malformed");let p=c;return p||(Ei(o||!this.puppeteer._isPuppeteerCore,"An `executablePath` or `channel` must be specified for `puppeteer-core`"),p=o?this.executablePath(o):this.resolveExecutablePath(t.headless??!0)),{executablePath:p,args:f,isTempUserDataDir:s,userDataDir:l}}async cleanUserDataDir(t,r){if(r.isTemp)try{await DBo(t)}catch(i){throw zi(i),i}}defaultArgs(t={}){let r=qr_("--disable-features",t.args);t.args&&r.length>0&&Tr_(t.args,"--disable-features");let n=["Translate","AcceptCHFrame","MediaRouter","OptimizationHints","RenderDocument",...process.env.PUPPETEER_TEST_EXPERIMENTAL_CHROME_FEATURES==="true"?[]:["ProcessPerSiteUpToMainFrameThreshold","IsolateSandboxedIframes"],...r].filter(_=>_!==""),a=qr_("--enable-features",t.args);t.args&&a.length>0&&Tr_(t.args,"--enable-features");let o=["PdfOopif",...a].filter(_=>_!==""),c=["--allow-pre-commit-input","--disable-background-networking","--disable-background-timer-throttling","--disable-backgrounding-occluded-windows","--disable-breakpad","--disable-client-side-phishing-detection","--disable-component-extensions-with-background-pages","--disable-crash-reporter","--disable-default-apps","--disable-dev-shm-usage","--disable-hang-monitor","--disable-infobars","--disable-ipc-flooding-protection","--disable-popup-blocking","--disable-prompt-on-repost","--disable-renderer-backgrounding","--disable-search-engine-choice-screen","--disable-sync","--enable-automation","--export-tagged-pdf","--force-color-profile=srgb","--generate-pdf-document-outline","--metrics-recording-only","--no-first-run","--password-store=basic","--use-mock-keychain",`--disable-features=${n.join(",")}`,`--enable-features=${o.join(",")}`].filter(_=>_!==""),{devtools:f=!1,headless:s=!f,args:u=[],userDataDir:l,enableExtensions:p=!1}=t;return l&&c.push(`--user-data-dir=${Nr_.default.resolve(l)}`),f&&c.push("--auto-open-devtools-for-tabs"),s&&c.push(s==="shell"?"--headless":"--headless=new","--hide-scrollbars","--mute-audio"),c.push(p?"--enable-unsafe-extension-debugging":"--disable-extensions"),u.every(_=>_.startsWith("-"))&&c.push("about:blank"),c.push(...u),c}executablePath(t,r=!0){return t?wBo({browser:fc.CHROME,channel:SGS(t)}):this.resolveExecutablePath(void 0,r)}};function SGS(e){switch(e){case"chrome":return Cv.STABLE;case"chrome-dev":return Cv.DEV;case"chrome-beta":return Cv.BETA;case"chrome-canary":return Cv.CANARY}}function qr_(e,t=[]){return t.filter(r=>r.startsWith(e.endsWith("=")?e:`${e}=`)).map(r=>r.split(new RegExp(`${e}=\\s*`))[1]?.trim()).filter(r=>r)}function Tr_(e,t){let r=new RegExp(`^${t}=.*`),i=0;for(;i<e.length;)r.test(e[i])?e.splice(i,1):i++;return e}var Fr_=ue(require("fs"),1),vNn=require("fs/promises"),Qr_=ue(require("os"),1),Krc=ue(require("path"),1);Yf();ZA();var IBo=class e extends bNn{constructor(t){super(t,"firefox")}static getPreferences(t){return{...t,"fission.webContentIsolationStrategy":0}}async computeLaunchArguments(t={}){let{ignoreDefaultArgs:r=!1,args:i=[],executablePath:n,pipe:a=!1,extraPrefsFirefox:o={},debuggingPort:c=null}=t,f=[];r?Array.isArray(r)?f.push(...this.defaultArgs(t).filter(_=>!r.includes(_))):f.push(...i):f.push(...this.defaultArgs(t)),f.some(_=>_.startsWith("--remote-debugging-"))||(a&&Ei(c===null,"Browser should be launched with either pipe or debugging port - not both."),f.push(`--remote-debugging-port=${c||0}`));let s,u=!0,l=f.findIndex(_=>["-profile","--profile"].includes(_));if(l!==-1){if(s=f[l+1],!s)throw new Error("Missing value for profile command line argument");u=!1}else s=await(0,vNn.mkdtemp)(this.getProfilePath()),f.push("--profile"),f.push(s);await zrc(fc.FIREFOX,{path:s,preferences:e.getPreferences(o)});let p;return this.puppeteer._isPuppeteerCore||n?(Ei(n,"An `executablePath` must be specified for `puppeteer-core`"),p=n):p=this.executablePath(void 0),{isTempUserDataDir:u,userDataDir:s,args:f,executablePath:p}}async cleanUserDataDir(t,r){if(r.isTemp)try{await DBo(t)}catch(i){throw zi(i),i}else try{let i=".puppeteer",n=["prefs.js","user.js"],a=await Promise.allSettled(n.map(async o=>{let c=Krc.default.join(t,o+i);if(Fr_.default.existsSync(c)){let f=Krc.default.join(t,o);await(0,vNn.unlink)(f),await(0,vNn.rename)(c,f)}}));for(let o of a)if(o.status==="rejected")throw o.reason}catch(i){zi(i)}}executablePath(t,r=!0){return this.resolveExecutablePath(void 0,r)}defaultArgs(t={}){let{devtools:r=!1,headless:i=!r,args:n=[],userDataDir:a=null}=t,o=[];switch(Qr_.default.platform()){case"darwin":o.push("--foreground");break;case"win32":o.push("--wait-for-browser");break}return a&&(o.push("--profile"),o.push(a)),i&&o.push("--headless"),r&&o.push("--devtools"),n.every(c=>c.startsWith("-"))&&o.push("about:blank"),o.push(...n),o}};var gNn=class extends MMo{#e;#t;defaultBrowserRevision;configuration={};constructor(t){let{configuration:r,...i}=t;switch(super(i),r&&(this.configuration=r),this.configuration.defaultBrowser){case"firefox":this.defaultBrowserRevision=Mzn.firefox;break;default:this.configuration.defaultBrowser="chrome",this.defaultBrowserRevision=Mzn.chrome;break}this.connect=this.connect.bind(this),this.launch=this.launch.bind(this),this.executablePath=this.executablePath.bind(this),this.defaultArgs=this.defaultArgs.bind(this),this.trimCache=this.trimCache.bind(this)}connect(t){return super.connect(t)}launch(t={}){let{browser:r=this.defaultBrowser}=t;switch(this.#t=r,r){case"chrome":this.defaultBrowserRevision=Mzn.chrome;break;case"firefox":this.defaultBrowserRevision=Mzn.firefox;break;default:throw new Error(`Unknown product: ${r}`)}return this.#e=this.#r(r),this.#e.launch(t)}#r(t){if(this.#e&&this.#e.browser===t)return this.#e;switch(t){case"chrome":return new BBo(this);case"firefox":return new IBo(this);default:throw new Error(`Unknown product: ${t}`)}}executablePath(t){return t===void 0?this.#r(this.lastLaunchedBrowser).executablePath(void 0,!1):typeof t=="string"?this.#r("chrome").executablePath(t,!1):this.#r(t.browser??this.lastLaunchedBrowser).resolveExecutablePath(t.headless,!1)}get browserVersion(){return this.configuration?.[this.lastLaunchedBrowser]?.version??this.defaultBrowserRevision}get defaultDownloadPath(){return this.configuration.cacheDirectory}get lastLaunchedBrowser(){return this.#t??this.defaultBrowser}get defaultBrowser(){return this.configuration.defaultBrowser??"chrome"}get product(){return this.lastLaunchedBrowser}defaultArgs(t={}){return this.#r(t.browser??this.lastLaunchedBrowser).defaultArgs(t)}async trimCache(){let t=ZNt();if(!t)throw new Error("The current platform is not supported.");let r=this.configuration.cacheDirectory,i=await Hrc({cacheDir:r}),n=[{product:"chrome",browser:fc.CHROME,currentBuildId:""},{product:"firefox",browser:fc.FIREFOX,currentBuildId:""}];for(let c of n){let f=this.configuration?.[c.product]?.version??Mzn[c.product];c.currentBuildId=await gBo(c.browser,t,f)}let a=new Set(n.map(c=>`${c.browser}_${c.currentBuildId}`)),o=new Set(n.map(c=>c.browser));for(let c of i)o.has(c.browser)&&(a.has(`${c.browser}_${c.buildId}`)||await Grc({browser:c.browser,platform:t,cacheDir:r,buildId:c.buildId}))}};var CBo=require("child_process"),Vr_=ue(require("fs"),1),Wr_=ue(require("os"),1),xr_=require("path"),Gr_=require("stream"),Hr_=ue(zS(),1);r0e();NH();Yf();gB();XA();var MGS=function(e,t,r){for(var i=arguments.length>2,n=0;n<t.length;n++)r=i?t[n].call(e,r):t[n].call(e);return i?r:void 0},Ur_=function(e,t,r,i,n,a){function o(v){if(v!==void 0&&typeof v!="function")throw new TypeError("Function expected");return v}for(var c=i.kind,f=c==="getter"?"get":c==="setter"?"set":"value",s=!t&&e?i.static?e:e.prototype:null,u=t||(s?Object.getOwnPropertyDescriptor(s,i.name):{}),l,p=!1,_=r.length-1;_>=0;_--){var h={};for(var y in i)h[y]=y==="access"?{}:i[y];for(var y in i.access)h.access[y]=i.access[y];h.addInitializer=function(v){if(p)throw new TypeError("Cannot add initializers after decoration has completed");a.push(o(v||null))};var b=(0,r[_])(c==="accessor"?{get:u.get,set:u.set}:u[f],h);if(c==="accessor"){if(b===void 0)continue;if(b===null||typeof b!="object")throw new TypeError("Object expected");(l=o(b.get))&&(u.get=l),(l=o(b.set))&&(u.set=l),(l=o(b.init))&&n.unshift(l)}else(l=o(b))&&(c==="field"?n.unshift(l):u[f]=l)}s&&Object.defineProperty(s,i.name,u),p=!0},DGS=function(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})},BGS=30,Lr_=30,IGS=(0,Hr_.default)("puppeteer:ffmpeg"),Kr_=(()=>{let e=Gr_.PassThrough,t=[],r,i,n;return class extends e{static{let o=typeof Symbol=="function"&&Symbol.metadata?Object.create(e[Symbol.metadata]??null):void 0;Ur_(this,i={value:DGS(async function(c){let f=await new Promise(s=>{this.#t.stdin.write(c,s)});f&&console.log(`ffmpeg failed to write: ${f.message}.`)},"#writeFrame")},r,{kind:"method",name:"#writeFrame",static:!1,private:!0,access:{has:c=>#o in c,get:c=>c.#o},metadata:o},null,t),Ur_(this,null,n,{kind:"method",name:"stop",static:!1,private:!1,access:{has:c=>"stop"in c,get:c=>c.stop},metadata:o},null,t),o&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})}#e=MGS(this,t);#t;#r=new AbortController;#i;#n;constructor(o,c,f,{ffmpegPath:s,speed:u,scale:l,crop:p,format:_,fps:h,loop:y,delay:b,quality:v,colors:O,path:A,overwrite:g}={}){super({allowHalfOpen:!1}),s??="ffmpeg",_??="webm",h??=Lr_,y||=-1,b??=-1,v??=BGS,O??=256,g??=!0,this.#n=h;let{error:m}=(0,CBo.spawnSync)(s);if(m)throw m;let j=[`crop='min(${c},iw):min(${f},ih):0:0'`,`pad=${c}:${f}:0:0`];u&&j.push(`setpts=${1/u}*PTS`),p&&j.push(`crop=${p.width}:${p.height}:${p.x}:${p.y}`),l&&j.push(`scale=iw*${l}:-1:flags=lanczos`);let M=this.#a(_,h,y,b,v,O),E=M.indexOf("-vf");E!==-1&&j.push(M.splice(E,2).at(-1)??""),A&&Vr_.default.mkdirSync((0,xr_.dirname)(A),{recursive:g}),this.#t=(0,CBo.spawn)(s,[["-loglevel","error"],["-avioflags","direct"],["-fpsprobesize","0","-probesize","32","-analyzeduration","0","-fflags","nobuffer"],["-f","image2pipe","-vcodec","png","-i","pipe:0"],["-an"],["-threads","1"],["-framerate",`${h}`],["-b:v","0"],M,["-vf",j.join()],[g?"-y":"-n"],"pipe:1"].flat(),{stdio:["pipe","pipe","pipe"]}),this.#t.stdout.pipe(this),this.#t.stderr.on("data",B=>{IGS(B.toString("utf8"))}),this.#e=o;let{client:D}=this.#e.mainFrame();D.once(iv.Disconnected,()=>{this.stop().catch(zi)}),this.#i=LKp(Bv(D,"Page.screencastFrame").pipe(BHi(B=>{D.send("Page.screencastFrameAck",{sessionId:B.sessionId})}),ahe(B=>B.metadata.timestamp!==void 0),YA(B=>({buffer:Buffer.from(B.data,"base64"),timestamp:B.metadata.timestamp})),HKp(2,1),KKp(([{timestamp:B,buffer:F},{timestamp:N}])=>td(Array(Math.round(h*Math.max(N-B,0))).fill(F))),YA(B=>(this.#o(B),[B,performance.now()])),Owo(_Rn(this.#r.signal,"abort"))),{defaultValue:[Buffer.from([]),performance.now()]})}#a(o,c,f,s,u,l){let p=[["-vcodec","vp9"],["-crf",`${u}`],["-deadline","realtime","-cpu-used",`${Math.min(Wr_.default.cpus().length/2,8)}`]];switch(o){case"webm":return[...p,["-f","webm"]].flat();case"gif":return c=Lr_===c?20:"source_fps",f===1/0&&(f=0),s!==-1&&(s/=10),[["-vf",`fps=${c},split[s0][s1];[s0]palettegen=stats_mode=diff:max_colors=${l}[p];[s1][p]paletteuse=dither=bayer`],["-loop",`${f}`],["-final_delay",`${s}`],["-f","gif"]].flat();case"mp4":return[...p,["-movflags","hybrid_fragmented"],["-f","mp4"]].flat()}}get#o(){return i.value}async stop(){if(this.#r.signal.aborted)return;await this.#e._stopScreencast().catch(zi),this.#r.abort();let[o,c]=await this.#i;await Promise.all(Array(Math.max(1,Math.round(this.#n*(performance.now()-c)/1e3))).fill(o).map(this.#o.bind(this))),this.#t.stdin.end(),await new Promise(f=>{this.#t.once("close",f)})}async[(r=[ema()],n=[ema()],bB)](){await this.stop()}}})();var Jr_=ue(require("fs"),1),$r_=ue(require("path"),1);avi();ox.value={fs:Jr_.default,path:$r_.default,ScreenRecorder:Kr_};var qGS=new gNn({isPuppeteerCore:!0}),{connect:SX5,defaultArgs:MX5,executablePath:DX5,launch:BX5}=qGS;var Sa_=require("os"),Ma_=require("path"),Da_=ue(Ea_(),1);function kic(e){let t=process.env[e];if(t!==void 0)switch(t.toLowerCase()){case"":case"0":case"false":case"off":return!1;default:return!0}}function lJS(e){switch(e){case"chrome":case"firefox":return!0;default:return!1}}function fJS(e){if(e&&!lJS(e))throw new Error(`Unsupported browser ${e}`);switch(e){case"firefox":return"firefox";default:return"chrome"}}function dJS(e){switch(e){case"silent":return"silent";case"error":return"error";default:return"warn"}}function Zic(e,t,r={}){if(t.skipDownload)return{skipDownload:!0};let i={},n=e.replaceAll("-","_").toUpperCase();return i.version=process.env[`PUPPETEER_${n}_VERSION`]??t[e]?.version??r.version,i.downloadBaseUrl=process.env[`PUPPETEER_${n}_DOWNLOAD_BASE_URL`]??t[e]?.downloadBaseUrl??r.downloadBaseUrl,i.skipDownload=kic(`PUPPETEER_${n}_SKIP_DOWNLOAD`)??kic(`PUPPETEER_SKIP_${n}_DOWNLOAD`)??t[e]?.skipDownload??r.skipDownload,i}var Ba_=()=>{let e=(0,Da_.cosmiconfigSync)("puppeteer",{searchStrategy:"global"}).search(),t=e?e.config:{};return t.logLevel=dJS(process.env.PUPPETEER_LOGLEVEL??t.logLevel),t.defaultBrowser=fJS(process.env.PUPPETEER_BROWSER??t.defaultBrowser),t.executablePath=process.env.PUPPETEER_EXECUTABLE_PATH??t.executablePath,t.executablePath&&(t.skipDownload=!0),t.skipDownload=kic("PUPPETEER_SKIP_DOWNLOAD")??t.skipDownload,t.chrome=Zic("chrome",t),t["chrome-headless-shell"]=Zic("chrome-headless-shell",t),t.firefox=Zic("firefox",t,{skipDownload:!0}),t.cacheDirectory=process.env.PUPPETEER_CACHE_DIR??t.cacheDirectory??(0,Ma_.join)((0,Sa_.homedir)(),".cache","puppeteer"),t.temporaryDirectory=process.env.PUPPETEER_TMP_DIR??t.temporaryDirectory,t.experiments??={},t};var pJS=Ba_(),_JS=new gNn({isPuppeteerCore:!1,configuration:pJS}),{connect:IZ5,defaultArgs:CZ5,executablePath:qZ5,launch:Ia_,trimCache:TZ5}=_JS;var hJS="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",yJS={"Accept-Language":"en-US,en;q=0.9",Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36","Accept-Encoding":"gzip, deflate, br, zstd",Connection:"keep-alive"};async function R0a(e,t=3,r=1e3,i=2){try{return await e()}catch(n){if(t>0)return await new Promise(a=>setTimeout(a,r)),R0a(e,t-1,r*i,i);throw n}}async function Ca_(){try{return await Ia_({headless:!0,args:["--ignore-certificate-errors"]})}catch{throw new Error("Could not create a Puppeteer instance")}}async function bJS(e,t){try{let r=await e.newPage();await r.setViewport({width:3072,height:2048,deviceScaleFactor:2,isMobile:!1,hasTouch:!1,isLandscape:!0}),await r.setExtraHTTPHeaders(yJS),await r.setUserAgent(hJS),await r.setJavaScriptEnabled(!0),await R0a(()=>r.goto(t.toString(),{waitUntil:"networkidle2",timeout:3e4}));let i=await R0a(()=>r.content());return await r.close(),i}catch{throw new Error("Failed to download page from Puppeteer")}}async function vJS(e){try{let t=await fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return await t.text()}catch{throw new Error("Failed to fetch page from source")}}async function enc({url:e,browser:t}){try{let r;if(t?r=await bJS(t,e):r=await R0a(()=>vJS(e)),r)return r;throw new Error("An unknown error occurred.")}catch{throw new Error(`Error retrieving HTML for ${e.toString()}`)}}async function qa_(e){try{let t=await R0a(()=>fetch(e));if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);let r=await t.arrayBuffer();return new Uint8Array(r)}catch{throw new Error(`Failed to retrieve image from source url ${e}`)}}var gJS=["png","jpeg","jpg","webp","avif","svg","ico","jfif","pjpeg","pjp","svgz","bmp"];async function Ta_(e){if(!e)return{success:!1,data:void 0};if(e.startsWith("data:image/"))return{success:!0,data:[e,e]};let t=(0,BNn.join)(process.cwd(),"fern");try{let r=await OJS(e,(0,BNn.join)(t,"images"));return r=r.replace(t,""),{success:!0,data:[e,r]}}catch{return{success:!1,data:void 0}}}async function OJS(e,t){let r=mJS(e),i=(0,BNn.join)(t,r);if(!AJS(r))throw new Error(`${r} - file extension not supported`);if((0,YBo.existsSync)(i))return i;try{(0,YBo.mkdirSync)((0,BNn.dirname)(i),{recursive:!0})}catch{throw new Error(`${i} - failed to create directory`)}try{let n=await qa_(e);return k7p(i,n),i}catch{throw new Error(`${i}: failed to download file from source`)}}function AJS(e){if(!e)return!1;let t=e.lastIndexOf(".")+1,r=e.substring(t);if(e===r)return!1;let i=r.toLowerCase();return!(i&&!gJS.includes(i))}function mJS(e){e.startsWith("http")&&(e=new URL(e).pathname);let t=e.split("#");if(t.length===0)return"image";let r=t[0];if(!r)return"image";let i=r.split("?");if(i.length===0)return"image";let n=i[0];return n&&decodeURIComponent(n.replace(/[/]{2,}/g,"/")).replace(/(?:_{2,}|[\s%#&{}\\<>*?$!'":@+`|=])/g,"-")||"image"}function PJS(e){let t=[];return Ni(e,"element",r=>{r.tagName==="img"&&Array.isArray(r.properties.className)&&r.properties.className.includes("rm-Logo-img")&&t.push(r)}),t.length>0?t:void 0}async function Ra_(e,t){let r=dRn(e),i=PJS(r);if(i!=null){let n=await Promise.all(i.map(async a=>{let o=await Ta_(a.properties.src);return o.success&&o.data?o.data[1]:""}));t.push(...n)}for(let n=t.length-1;n>=0;n--)t[n]||t.splice(n,1)}var za_=28;async function Na_(e,t){e=new URL(e);let r=[];if(t){let n=[];try{let a=await t.newPage();await a.goto(e.toString(),{waitUntil:"networkidle2"}),n.push(await a.content()),await a.click(".rm-ThemeToggle"),n.push(await a.content())}catch{}await Promise.all(n.map(async a=>await Ra_(a,r)))}let i=[...new Set(r).values()];if(i.length!==0){if(i.length===1&&i[0]!=null){let n=Ze.of(RL(i[0]));return{light:n,dark:n,height:za_}}if(i[0]!=null&&i[1]!=null){let n=Ze.of(RL(i[0])),a=Ze.of(RL(i[1]));return{light:n,dark:a,height:za_}}}}var XBo=class extends tHi{url;logger;absolutePathToFernDirectory;constructor(t){super({context:t.context}),this.url=typeof t.url=="string"?new URL(t.url):t.url,this.logger=t.context.logger,this.absolutePathToFernDirectory=t.absolutePathToFernDirectory}async import({args:t,builder:r}){r.setLayout({layout:kOa});let i=await this.getHastForUrl(this.url),n=fKp(i)??[];if(n.length===0)this.logger.debug("No tabs found on the page");else{this.logger.debug(`Found ${n.length} tabs:`);for(let u of n)this.logger.debug(` - Tab: ${u.name} (${u.url})`)}for(let u of n){let l=await this.scrapeTab({name:u.name,url:u.url});if(!l)continue;let p=r.getNavigationBuilder({tabId:this.kebabCaseWithoutEmojis(u.name),tabConfig:{slug:u.url,displayName:u.name}}),_=Nt(this.absolutePathToFernDirectory,Ze.of(this.kebabCaseWithoutEmojis(u.name)));await this.downloadMarkdownPages({absolutePathToOutputDirectory:_,sections:l});let h=await this.getNavigationItems({absolutePathToOutputDirectory:_,sections:l});for(let y of h)p.addItem({item:y})}let a=await Ca_(),o=await Na_(this.url,a);o!=null&&r.setLogo({logo:o});let c=await Uxp(i);r.setTitle({title:c});let f=await zxp(i);if(f!=null){let u=await this.getAndCreateAssetsDirectory(),l=await fetch(f);if(l.ok){let p=Buffer.from(await l.arrayBuffer()),_=Nt(u,Ze.of("favicon"));await(0,GIi.writeFile)(_,new Uint8Array(p)),r.setFavicon({favicon:P7(this.absolutePathToFernDirectory,_)})}}let s=await pKp(i);r.setColors({colors:s}),a&&await a.close(),r.build({outputDirectory:this.absolutePathToFernDirectory})}async getAndCreateAssetsDirectory(){let t=Nt(this.absolutePathToFernDirectory,Ze.of("assets"));return await(0,GIi.mkdir)(t,{recursive:!0}),t}async scrapeTab({name:t,url:r}){try{this.logger.debug(`Scraping tab: ${t} (${r})`);let i=new URL(r,this.url),n=await this.getHastForUrl(i),a=sKp(n);if(!a){this.logger.debug(`No sidebar element found for tab: ${t} (${r})`);return}let o=cKp(a);return this.logger.debug(`Successfully scraped tab: ${t}`),o}catch(i){this.logger.error(`Failed to scrape tab ${t}: ${i instanceof Error?i.message:String(i)}`),i instanceof Error&&i.stack&&this.logger.error(`Stack trace: ${i.stack}`)}}async getHastForUrl(t){let r=await enc({url:t});return dRn(r)}async downloadMarkdownPages({absolutePathToOutputDirectory:t,sections:r}){for(let i of r){this.logger.debug(`Processing section: ${i.group}`);let n=this.getAbsolutePathToOutputDirectoryForSection({absolutePathToOutputDirectory:t,section:i});await(0,GIi.mkdir)(n,{recursive:!0}),await Promise.all(i.pages.filter(a=>a.type==="page").map(async a=>{let o=new URL(a.slug.toString(),this.url);this.logger.debug(`Fetching page: ${o.toString()}`);let c=await enc({url:o}),f=await uKp({logger:this.logger,html:c,url:o});if(f.success&&f.data){let s=this.getAbsolutePathToOutputFileForPage({absolutePathToOutputDirectoryForSection:n,page:a.slug});await(0,GIi.writeFile)(s,f.data.mdx),f.data.images.imageURLs.length>0&&(this.logger.debug(`Found ${f.data.images.imageURLs.length} images to download for ${o.toString()}`),await Promise.all(Object.entries(f.data.images.imageURLToFilename).map(async([u,l])=>{try{let p=await fetch(u);if(!p.ok){this.logger.warn(`Failed to download image ${u}, status: ${p.status}`);return}let _=Buffer.from(await p.arrayBuffer()),h=Nt(n,Ze.of(l)),y=Zi(h);await(0,GIi.mkdir)(y,{recursive:!0}),await(0,GIi.writeFile)(h,new Uint8Array(_)),this.logger.debug(`Saved image to ${h}`)}catch(p){this.logger.warn(`Error downloading image ${u}: ${p}`)}})))}else this.logger.warn(`Failed to parse page ${o.toString()}, skipping`)})),await Promise.all(i.pages.filter(a=>a.type==="group").map(async a=>{this.logger.debug(`Processing nested group: ${a.group}`),await this.downloadMarkdownPages({absolutePathToOutputDirectory:n,sections:[{type:"group",group:a.group,pages:a.pages}]})}))}}async getNavigationItems({absolutePathToOutputDirectory:t,sections:r}){let i=[];for(let n of r){let a=this.getAbsolutePathToOutputDirectoryForSection({absolutePathToOutputDirectory:t,section:n}),o={section:n.group,contents:[],slug:this.kebabCaseWithoutEmojis(n.group)};for(let c of n.pages)if(c.type==="page")o.contents.push({page:c.page,path:P7(this.absolutePathToFernDirectory,this.getAbsolutePathToOutputFileForPage({absolutePathToOutputDirectoryForSection:a,page:c.slug}))});else{let f=await this.getNavigationItems({absolutePathToOutputDirectory:a,sections:[c]});o.contents.push(...f)}i.push(o)}return i}getAbsolutePathToOutputFileForPage({absolutePathToOutputDirectoryForSection:t,page:r}){return Nt(t,Ze.of(`${this.kebabCaseWithoutEmojis(r.split("/").pop()||r)}.mdx`))}getAbsolutePathToOutputDirectoryForSection({absolutePathToOutputDirectory:t,section:r}){return Nt(t,Ze.of(this.kebabCaseWithoutEmojis(r.group)))}kebabCaseWithoutEmojis(t){return t.replace(/[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/gu,"").toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}};var Fa_=require("fs/promises");async function tnc({readmeUrl:e,outputPath:t,taskContext:r,versionOfCli:i,organization:n}){let a=new rHi;a.setInstance({companyName:n}),await new XBo({url:e,context:r,builder:a,absolutePathToFernDirectory:Nt(Fr.of(process.cwd()),Ze.of("fern"))}).import({args:{},builder:a}),await a.build({outputDirectory:t}),await(0,Fa_.writeFile)(Nt(Fr.of(t),Ze.of(r1),Ze.of(YF)),JSON.stringify({version:i,organization:n},void 0,4))}var rnc=async({readmeUrl:e,organization:t,taskContext:r,versionOfCli:i})=>{if(!e||!h6i(e)){r.failAndThrow("Provide a URL to a readme-generated site");return}let n=Fr.of(fA());await tnc({readmeUrl:e,outputPath:n,taskContext:r,versionOfCli:i,organization:t})};var Qa_="0.0.0";var Ua_={[hn.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,TP(e)])),[hn.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[hn.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[hn.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all","kwargs"]),[hn.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","vendor","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[hn.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime","object_id","hash","eql?","equal?","method","send","respond_to?","respond_to_missing?","instance_of?","kind_of?","is_a?","extend","singleton_class","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","remove_instance_variable","public_methods","private_methods","protected_methods","singleton_methods"]),[hn.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[hn.GenerationLanguage.RUST]:new Set(["as","async","await","break","const","continue","crate","dyn","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","union","unsafe","use","where","while","abstract","become","box","do","final","macro","override","priv","try","typeof","unsized","virtual","yield","bool","char","f32","f64","i8","i16","i32","i64","i128","isize","str","u8","u16","u32","u64","u128","usize","String","Vec","Option","Result","Box","Rc","Arc","Cell","RefCell","HashMap","HashSet","BTreeMap","BTreeSet"]),[hn.GenerationLanguage.SWIFT]:new Set([])};var wJS=["go","ruby"];function _x({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let o=TJS(n),c=p=>({unsafeName:p,safeName:EJS({name:p,keywords:SJS({generationLanguage:e,keywords:t})})}),f=Fo(o),s=TP(f),u=Bxi(o),l=Exi(f);return r&&(!BJS(l)&&(e==null||wJS.includes(e))&&(f=l.map((p,_)=>{if(_>0){let h=ZBo(p);if(h!=null)return h;if(kBo(p))return p.toUpperCase()}return p}).join(""),s=TP(l.map((p,_)=>{let h=ZBo(p);return h??(kBo(p)?p.toUpperCase():_===0?TP(p):p)}).join(""))),u=o.split(" ").map(p=>p.split(/(\d+)/).map(Bxi).join("")).join("_")),{originalName:n,camelCase:c(a?.casingOverrides?.camel??f),snakeCase:c(a?.casingOverrides?.snake??u),screamingSnakeCase:c(a?.casingOverrides?.["screaming-snake"]??u.toUpperCase()),pascalCase:c(a?.casingOverrides?.pascal??s)}},generateNameAndWireValue:({name:n,wireValue:a,opts:o})=>({name:i.generateName(n,o),wireValue:a})};return i}function EJS({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":DJS(e)?"_"+e:e}function SJS({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return Ua_[e]}var MJS=/^[0-9]/;function DJS(e){return MJS.test(e)}function BJS(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=ZBo(i)!=null||kBo(i),a=ZBo(t)!=null||kBo(t);return n&&a})}function ZBo(e){return CJS.get(e.toUpperCase())}function kBo(e){return IJS.has(e.toUpperCase())}var IJS=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),CJS=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]),qJS=[[/\[\]/g,"Array"]];function TJS(e){return qJS.reduce((t,[r,i])=>t.replace(r,i),e)}var vr={};Yt(vr,{ApiDefinitionSource:()=>$H,ApiVersionScheme:()=>$Ii,AuthScheme:()=>wA,AuthSchemesRequirement:()=>I3,AvailabilityStatus:()=>IC,ContainerType:()=>ns,Environments:()=>$E,ErrorDeclarationDiscriminantValue:()=>JIi,ErrorDiscriminationStrategy:()=>hhe,ExampleCodeSample:()=>phe,ExampleContainer:()=>op,ExampleEndpointSuccessResponse:()=>xP,ExamplePrimitive:()=>Sn,ExampleQueryParameterShape:()=>M1,ExampleRequestBody:()=>T3,ExampleResponse:()=>L0,ExampleSingleUnionTypeProperties:()=>jB,ExampleStyle:()=>iIo,ExampleTypeReferenceShape:()=>lu,ExampleTypeShape:()=>Bh,ExampleWebSocketMessageBody:()=>yhe,FileProperty:()=>KH,FileUploadBodyPropertyEncoding:()=>z0a,FileUploadRequestProperty:()=>qC,HttpEndpointSource:()=>C3,HttpMethod:()=>WP,HttpRequestBody:()=>UO,HttpResponseBody:()=>Xf,JsonResponse:()=>mB,Literal:()=>iz,NamedTypeDefault:()=>INn,NonStreamHttpResponseBody:()=>UQ,OAuthConfiguration:()=>HIi,ObjectPropertyAccess:()=>G6t,Pagination:()=>q3,PathParameterLocation:()=>P0e,PrimitiveTypeV1:()=>Su,PrimitiveTypeV2:()=>bn,ProtobufMethodType:()=>eFt,ProtobufType:()=>Dh,PublishTarget:()=>PB,PublishingConfig:()=>x6t,RequestPropertyValue:()=>JH,ResolvedTypeReference:()=>LQ,SdkRequestBodyType:()=>kNt,SdkRequestShape:()=>j0e,ShapeType:()=>tFt,SingleUnionTypeProperties:()=>rz,Source:()=>Dvi,StreamingResponse:()=>OD,SupportedSdkLanguage:()=>_he,Transport:()=>m0e,Type:()=>Yc,TypeReference:()=>ii,V2AuthValues:()=>A0e,V2EndpointLocationHttpMethod:()=>W6t,V2HttpEndpointResponseBody:()=>CC,WebSocketMessageBody:()=>nz,WebSocketMessageOrigin:()=>aIo,WebhookHttpMethod:()=>nIo,WebhookPayload:()=>VQ,WellKnownProtobufType:()=>sn,audience:()=>La_,auth:()=>inc,commons:()=>nnc,constants:()=>Va_,dynamic:()=>Kt,environment:()=>dnc,errors:()=>pnc,examples:()=>_nc,generatorExec:()=>Qc,http:()=>ync,ir:()=>bnc,proto:()=>vnc,publish:()=>gnc,types:()=>Onc,variables:()=>fo_,webhooks:()=>Anc,websocket:()=>mnc});var La_={};var inc={};Yt(inc,{AuthScheme:()=>wA,AuthSchemesRequirement:()=>I3,OAuthConfiguration:()=>HIi});var I3={All:"ALL",Any:"ANY",_visit:(e,t)=>{switch(e){case I3.All:return t.all();case I3.Any:return t.any();default:return t._other()}}};var wA={bearer:e=>({...e,type:"bearer",_visit:function(t){return wA._visit(this,t)}}),basic:e=>({...e,type:"basic",_visit:function(t){return wA._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return wA._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return wA._visit(this,t)}}),inferred:e=>({...e,type:"inferred",_visit:function(t){return wA._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"bearer":return t.bearer(e);case"basic":return t.basic(e);case"header":return t.header(e);case"oauth":return t.oauth(e);case"inferred":return t.inferred(e);default:return t._other(e)}}};var HIi={clientCredentials:e=>({...e,type:"clientCredentials",_visit:function(t){return HIi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"clientCredentials":return t.clientCredentials(e);default:return t._other(e)}}};var nnc={};Yt(nnc,{AvailabilityStatus:()=>IC});var IC={InDevelopment:"IN_DEVELOPMENT",PreRelease:"PRE_RELEASE",GeneralAvailability:"GENERAL_AVAILABILITY",Deprecated:"DEPRECATED",_visit:(e,t)=>{switch(e){case IC.InDevelopment:return t.inDevelopment();case IC.PreRelease:return t.preRelease();case IC.GeneralAvailability:return t.generalAvailability();case IC.Deprecated:return t.deprecated();default:return t._other()}}};var Va_={};var Kt={};Yt(Kt,{Auth:()=>Wa_,AuthValues:()=>xa_,Environments:()=>Za_,ErrorSeverity:()=>eIo,FileUploadRequestBodyProperty:()=>Xa_,GeneratorOutputConfig:()=>ka_,HttpMethod:()=>KIi,InlinedRequestBody:()=>$a_,LiteralType:()=>no_,NamedType:()=>to_,ObjectPropertyAccess:()=>tIo,PrimitiveTypeV1:()=>hx,PublishInfo:()=>eo_,ReferencedRequestBodyType:()=>Ya_,Request:()=>Ka_,Response:()=>Ja_,SingleDiscriminatedUnionType:()=>io_,TypeReference:()=>ro_,auth:()=>anc,commons:()=>Ga_,declaration:()=>Ha_,endpoints:()=>onc,environment:()=>unc,http:()=>snc,ir:()=>cnc,snippets:()=>lnc,types:()=>fnc,variables:()=>ao_});var anc={};Yt(anc,{Auth:()=>Wa_,AuthValues:()=>xa_});var Wa_={basic:e=>({...e,type:"basic",_visit:function(t){return Kt.Auth._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Kt.Auth._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Kt.Auth._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Kt.Auth._visit(this,t)}}),inferred:e=>({...e,type:"inferred",_visit:function(t){return Kt.Auth._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"oauth":return t.oauth(e);case"inferred":return t.inferred(e);default:return t._other(e)}}};var xa_={basic:e=>({...e,type:"basic",_visit:function(t){return Kt.AuthValues._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Kt.AuthValues._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Kt.AuthValues._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Kt.AuthValues._visit(this,t)}}),inferred:e=>({...e,type:"inferred",_visit:function(t){return Kt.AuthValues._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"oauth":return t.oauth(e);case"inferred":return t.inferred(e);default:return t._other(e)}}};var Ga_={};var Ha_={};var onc={};Yt(onc,{FileUploadRequestBodyProperty:()=>Xa_,InlinedRequestBody:()=>$a_,ReferencedRequestBodyType:()=>Ya_,Request:()=>Ka_,Response:()=>Ja_});var Ka_={body:e=>({...e,type:"body",_visit:function(t){return Kt.Request._visit(this,t)}}),inlined:e=>({...e,type:"inlined",_visit:function(t){return Kt.Request._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"body":return t.body(e);case"inlined":return t.inlined(e);default:return t._other(e)}}};var Ja_={json:()=>({type:"json",_visit:function(e){return Kt.Response._visit(this,e)}}),streaming:()=>({type:"streaming",_visit:function(e){return Kt.Response._visit(this,e)}}),streamParameter:()=>({type:"streamParameter",_visit:function(e){return Kt.Response._visit(this,e)}}),fileDownload:()=>({type:"fileDownload",_visit:function(e){return Kt.Response._visit(this,e)}}),text:()=>({type:"text",_visit:function(e){return Kt.Response._visit(this,e)}}),bytes:()=>({type:"bytes",_visit:function(e){return Kt.Response._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json();case"streaming":return t.streaming();case"streamParameter":return t.streamParameter();case"fileDownload":return t.fileDownload();case"text":return t.text();case"bytes":return t.bytes();default:return t._other(e)}}};var $a_={properties:e=>({value:e,type:"properties",_visit:function(t){return Kt.InlinedRequestBody._visit(this,t)}}),referenced:e=>({...e,type:"referenced",_visit:function(t){return Kt.InlinedRequestBody._visit(this,t)}}),fileUpload:e=>({...e,type:"fileUpload",_visit:function(t){return Kt.InlinedRequestBody._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"properties":return t.properties(e.value);case"referenced":return t.referenced(e);case"fileUpload":return t.fileUpload(e);default:return t._other(e)}}};var Ya_={bytes:()=>({type:"bytes",_visit:function(e){return Kt.ReferencedRequestBodyType._visit(this,e)}}),typeReference:e=>({value:e,type:"typeReference",_visit:function(t){return Kt.ReferencedRequestBodyType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"bytes":return t.bytes();case"typeReference":return t.typeReference(e.value);default:return t._other(e)}}};var Xa_={file:e=>({...e,type:"file",_visit:function(t){return Kt.FileUploadRequestBodyProperty._visit(this,t)}}),fileArray:e=>({...e,type:"fileArray",_visit:function(t){return Kt.FileUploadRequestBodyProperty._visit(this,t)}}),bodyProperty:e=>({...e,type:"bodyProperty",_visit:function(t){return Kt.FileUploadRequestBodyProperty._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"fileArray":return t.fileArray(e);case"bodyProperty":return t.bodyProperty(e);default:return t._other(e)}}};var unc={};Yt(unc,{Environments:()=>Za_});var Za_={singleBaseUrl:e=>({...e,type:"singleBaseUrl",_visit:function(t){return Kt.Environments._visit(this,t)}}),multipleBaseUrls:e=>({...e,type:"multipleBaseUrls",_visit:function(t){return Kt.Environments._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"singleBaseUrl":return t.singleBaseUrl(e);case"multipleBaseUrls":return t.multipleBaseUrls(e);default:return t._other(e)}}};var snc={};Yt(snc,{HttpMethod:()=>KIi});var KIi={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",_visit:(e,t)=>{switch(e){case KIi.Get:return t.get();case KIi.Post:return t.post();case KIi.Put:return t.put();case KIi.Patch:return t.patch();case KIi.Delete:return t.delete();case KIi.Head:return t.head();default:return t._other()}}};var cnc={};Yt(cnc,{GeneratorOutputConfig:()=>ka_,PublishInfo:()=>eo_});var ka_={publish:e=>({value:e,type:"publish",_visit:function(t){return Kt.GeneratorOutputConfig._visit(this,t)}}),local:()=>({type:"local",_visit:function(e){return Kt.GeneratorOutputConfig._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"publish":return t.publish(e.value);case"local":return t.local();default:return t._other(e)}}};var eo_={go:e=>({...e,type:"go",_visit:function(t){return Kt.PublishInfo._visit(this,t)}}),swift:e=>({...e,type:"swift",_visit:function(t){return Kt.PublishInfo._visit(this,t)}}),maven:e=>({...e,type:"maven",_visit:function(t){return Kt.PublishInfo._visit(this,t)}}),npm:e=>({...e,type:"npm",_visit:function(t){return Kt.PublishInfo._visit(this,t)}}),nuget:e=>({...e,type:"nuget",_visit:function(t){return Kt.PublishInfo._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return Kt.PublishInfo._visit(this,t)}}),rubygems:e=>({...e,type:"rubygems",_visit:function(t){return Kt.PublishInfo._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return Kt.PublishInfo._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"go":return t.go(e);case"swift":return t.swift(e);case"maven":return t.maven(e);case"npm":return t.npm(e);case"nuget":return t.nuget(e);case"pypi":return t.pypi(e);case"rubygems":return t.rubygems(e);case"crates":return t.crates(e);default:return t._other(e)}}};var lnc={};Yt(lnc,{ErrorSeverity:()=>eIo});var eIo={Critical:"CRITICAL",Warning:"WARNING",_visit:(e,t)=>{switch(e){case eIo.Critical:return t.critical();case eIo.Warning:return t.warning();default:return t._other()}}};var fnc={};Yt(fnc,{LiteralType:()=>no_,NamedType:()=>to_,ObjectPropertyAccess:()=>tIo,PrimitiveTypeV1:()=>hx,SingleDiscriminatedUnionType:()=>io_,TypeReference:()=>ro_});var to_={alias:e=>({...e,type:"alias",_visit:function(t){return Kt.NamedType._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Kt.NamedType._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Kt.NamedType._visit(this,t)}}),discriminatedUnion:e=>({...e,type:"discriminatedUnion",_visit:function(t){return Kt.NamedType._visit(this,t)}}),undiscriminatedUnion:e=>({...e,type:"undiscriminatedUnion",_visit:function(t){return Kt.NamedType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"alias":return t.alias(e);case"enum":return t.enum(e);case"object":return t.object(e);case"discriminatedUnion":return t.discriminatedUnion(e);case"undiscriminatedUnion":return t.undiscriminatedUnion(e);default:return t._other(e)}}};var ro_={list:e=>({value:e,type:"list",_visit:function(t){return Kt.TypeReference._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return Kt.TypeReference._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Kt.TypeReference._visit(this,t)}}),named:e=>({value:e,type:"named",_visit:function(t){return Kt.TypeReference._visit(this,t)}}),nullable:e=>({value:e,type:"nullable",_visit:function(t){return Kt.TypeReference._visit(this,t)}}),optional:e=>({value:e,type:"optional",_visit:function(t){return Kt.TypeReference._visit(this,t)}}),primitive:e=>({value:e,type:"primitive",_visit:function(t){return Kt.TypeReference._visit(this,t)}}),set:e=>({value:e,type:"set",_visit:function(t){return Kt.TypeReference._visit(this,t)}}),unknown:()=>({type:"unknown",_visit:function(e){return Kt.TypeReference._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"list":return t.list(e.value);case"literal":return t.literal(e.value);case"map":return t.map(e);case"named":return t.named(e.value);case"nullable":return t.nullable(e.value);case"optional":return t.optional(e.value);case"primitive":return t.primitive(e.value);case"set":return t.set(e.value);case"unknown":return t.unknown();default:return t._other(e)}}};var io_={samePropertiesAsObject:e=>({...e,type:"samePropertiesAsObject",_visit:function(t){return Kt.SingleDiscriminatedUnionType._visit(this,t)}}),singleProperty:e=>({...e,type:"singleProperty",_visit:function(t){return Kt.SingleDiscriminatedUnionType._visit(this,t)}}),noProperties:e=>({...e,type:"noProperties",_visit:function(t){return Kt.SingleDiscriminatedUnionType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"samePropertiesAsObject":return t.samePropertiesAsObject(e);case"singleProperty":return t.singleProperty(e);case"noProperties":return t.noProperties(e);default:return t._other(e)}}};var no_={boolean:e=>({value:e,type:"boolean",_visit:function(t){return Kt.LiteralType._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Kt.LiteralType._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 tIo={ReadOnly:"READ_ONLY",WriteOnly:"WRITE_ONLY",_visit:(e,t)=>{switch(e){case tIo.ReadOnly:return t.readOnly();case tIo.WriteOnly:return t.writeOnly();default:return t._other()}}};var hx={Integer:"INTEGER",Long:"LONG",Uint:"UINT",Uint64:"UINT_64",Float:"FLOAT",Double:"DOUBLE",Boolean:"BOOLEAN",String:"STRING",Date:"DATE",DateTime:"DATE_TIME",Uuid:"UUID",Base64:"BASE_64",BigInteger:"BIG_INTEGER",_visit:(e,t)=>{switch(e){case hx.Integer:return t.integer();case hx.Long:return t.long();case hx.Uint:return t.uint();case hx.Uint64:return t.uint64();case hx.Float:return t.float();case hx.Double:return t.double();case hx.Boolean:return t.boolean();case hx.String:return t.string();case hx.Date:return t.date();case hx.DateTime:return t.dateTime();case hx.Uuid:return t.uuid();case hx.Base64:return t.base64();case hx.BigInteger:return t.bigInteger();default:return t._other()}}};var ao_={};var dnc={};Yt(dnc,{Environments:()=>$E});var $E={singleBaseUrl:e=>({...e,type:"singleBaseUrl",_visit:function(t){return $E._visit(this,t)}}),multipleBaseUrls:e=>({...e,type:"multipleBaseUrls",_visit:function(t){return $E._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"singleBaseUrl":return t.singleBaseUrl(e);case"multipleBaseUrls":return t.multipleBaseUrls(e);default:return t._other(e)}}};var pnc={};Yt(pnc,{ErrorDeclarationDiscriminantValue:()=>JIi});var JIi={property:e=>({...e,type:"property",_visit:function(t){return JIi._visit(this,t)}}),statusCode:()=>({type:"statusCode",_visit:function(e){return JIi._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"property":return t.property(e);case"statusCode":return t.statusCode();default:return t._other(e)}}};var _nc={};Yt(_nc,{V2AuthValues:()=>A0e,V2EndpointLocationHttpMethod:()=>W6t,V2HttpEndpointResponseBody:()=>CC});var CC={error:e=>({value:e,type:"error",_visit:function(t){return CC._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return CC._visit(this,t)}}),stream:e=>({value:e,type:"stream",_visit:function(t){return CC._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"error":return t.error(e.value);case"json":return t.json(e.value);case"stream":return t.stream(e.value);default:return t._other(e)}}};var W6t={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",_visit:(e,t)=>{switch(e){case W6t.Get:return t.get();case W6t.Post:return t.post();case W6t.Put:return t.put();case W6t.Patch:return t.patch();case W6t.Delete:return t.delete();case W6t.Head:return t.head();default:return t._other()}}};var A0e={basic:e=>({...e,type:"basic",_visit:function(t){return A0e._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return A0e._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return A0e._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return A0e._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"oauth":return t.oauth(e);default:return t._other(e)}}};var Qc={};Yt(Qc,{GeneratorEnvironment:()=>lo_,GeneratorPublishTarget:()=>co_,GithubPublishInfo:()=>so_,LicenseConfig:()=>oo_,LicenseId:()=>rIo,OutputMode:()=>uo_,config:()=>hnc});var hnc={};Yt(hnc,{GeneratorEnvironment:()=>lo_,GeneratorPublishTarget:()=>co_,GithubPublishInfo:()=>so_,LicenseConfig:()=>oo_,LicenseId:()=>rIo,OutputMode:()=>uo_});var oo_={basic:e=>({...e,type:"basic",_visit:function(t){return Qc.LicenseConfig._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return Qc.LicenseConfig._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"custom":return t.custom(e);default:return t._other(e)}}};var rIo={Mit:"MIT",Apache2:"Apache-2.0",_visit:(e,t)=>{switch(e){case rIo.Mit:return t.mit();case rIo.Apache2:return t.apache2();default:return t._other()}}};var uo_={publish:e=>({...e,type:"publish",_visit:function(t){return Qc.OutputMode._visit(this,t)}}),downloadFiles:()=>({type:"downloadFiles",_visit:function(e){return Qc.OutputMode._visit(this,e)}}),github:e=>({...e,type:"github",_visit:function(t){return Qc.OutputMode._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"publish":return t.publish(e);case"downloadFiles":return t.downloadFiles();case"github":return t.github(e);default:return t._other(e)}}};var so_={npm:e=>({...e,type:"npm",_visit:function(t){return Qc.GithubPublishInfo._visit(this,t)}}),maven:e=>({...e,type:"maven",_visit:function(t){return Qc.GithubPublishInfo._visit(this,t)}}),postman:e=>({...e,type:"postman",_visit:function(t){return Qc.GithubPublishInfo._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return Qc.GithubPublishInfo._visit(this,t)}}),rubygems:e=>({...e,type:"rubygems",_visit:function(t){return Qc.GithubPublishInfo._visit(this,t)}}),nuget:e=>({...e,type:"nuget",_visit:function(t){return Qc.GithubPublishInfo._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return Qc.GithubPublishInfo._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"npm":return t.npm(e);case"maven":return t.maven(e);case"postman":return t.postman(e);case"pypi":return t.pypi(e);case"rubygems":return t.rubygems(e);case"nuget":return t.nuget(e);case"crates":return t.crates(e);default:return t._other(e)}}};var co_={maven:e=>({...e,type:"maven",_visit:function(t){return Qc.GeneratorPublishTarget._visit(this,t)}}),npm:e=>({...e,type:"npm",_visit:function(t){return Qc.GeneratorPublishTarget._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return Qc.GeneratorPublishTarget._visit(this,t)}}),postman:e=>({...e,type:"postman",_visit:function(t){return Qc.GeneratorPublishTarget._visit(this,t)}}),rubygems:e=>({...e,type:"rubygems",_visit:function(t){return Qc.GeneratorPublishTarget._visit(this,t)}}),nuget:e=>({...e,type:"nuget",_visit:function(t){return Qc.GeneratorPublishTarget._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return Qc.GeneratorPublishTarget._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"maven":return t.maven(e);case"npm":return t.npm(e);case"pypi":return t.pypi(e);case"postman":return t.postman(e);case"rubygems":return t.rubygems(e);case"nuget":return t.nuget(e);case"crates":return t.crates(e);default:return t._other(e)}}};var lo_={local:()=>({type:"local",_visit:function(e){return Qc.GeneratorEnvironment._visit(this,e)}}),remote:e=>({...e,type:"remote",_visit:function(t){return Qc.GeneratorEnvironment._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"local":return t.local();case"remote":return t.remote(e);default:return t._other(e)}}};var ync={};Yt(ync,{ExampleCodeSample:()=>phe,ExampleEndpointSuccessResponse:()=>xP,ExampleQueryParameterShape:()=>M1,ExampleRequestBody:()=>T3,ExampleResponse:()=>L0,FileProperty:()=>KH,FileUploadBodyPropertyEncoding:()=>z0a,FileUploadRequestProperty:()=>qC,HttpEndpointSource:()=>C3,HttpMethod:()=>WP,HttpRequestBody:()=>UO,HttpResponseBody:()=>Xf,JsonResponse:()=>mB,NonStreamHttpResponseBody:()=>UQ,Pagination:()=>q3,PathParameterLocation:()=>P0e,RequestPropertyValue:()=>JH,SdkRequestBodyType:()=>kNt,SdkRequestShape:()=>j0e,StreamingResponse:()=>OD,SupportedSdkLanguage:()=>_he,Transport:()=>m0e});var m0e={http:()=>({type:"http",_visit:function(e){return m0e._visit(this,e)}}),grpc:e=>({...e,type:"grpc",_visit:function(t){return m0e._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"http":return t.http();case"grpc":return t.grpc(e);default:return t._other(e)}}};var C3={proto:e=>({...e,type:"proto",_visit:function(t){return C3._visit(this,t)}}),openapi:()=>({type:"openapi",_visit:function(e){return C3._visit(this,e)}}),openrpc:()=>({type:"openrpc",_visit:function(e){return C3._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"proto":return t.proto(e);case"openapi":return t.openapi();case"openrpc":return t.openrpc();default:return t._other(e)}}};var WP={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",_visit:(e,t)=>{switch(e){case WP.Get:return t.get();case WP.Post:return t.post();case WP.Put:return t.put();case WP.Patch:return t.patch();case WP.Delete:return t.delete();case WP.Head:return t.head();default:return t._other()}}};var P0e={Root:"ROOT",Service:"SERVICE",Endpoint:"ENDPOINT",_visit:(e,t)=>{switch(e){case P0e.Root:return t.root();case P0e.Service:return t.service();case P0e.Endpoint:return t.endpoint();default:return t._other()}}};var UO={inlinedRequestBody:e=>({...e,type:"inlinedRequestBody",_visit:function(t){return UO._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return UO._visit(this,t)}}),fileUpload:e=>({...e,type:"fileUpload",_visit:function(t){return UO._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return UO._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedRequestBody":return t.inlinedRequestBody(e);case"reference":return t.reference(e);case"fileUpload":return t.fileUpload(e);case"bytes":return t.bytes(e);default:return t._other(e)}}};var qC={file:e=>({value:e,type:"file",_visit:function(t){return qC._visit(this,t)}}),bodyProperty:e=>({...e,type:"bodyProperty",_visit:function(t){return qC._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e.value);case"bodyProperty":return t.bodyProperty(e);default:return t._other(e)}}};var z0a={Exploded:"exploded",Json:"json",Form:"form",_visit:(e,t)=>{switch(e){case z0a.Exploded:return t.exploded();case z0a.Json:return t.json();case z0a.Form:return t.form();default:return t._other()}}};var KH={file:e=>({...e,type:"file",_visit:function(t){return KH._visit(this,t)}}),fileArray:e=>({...e,type:"fileArray",_visit:function(t){return KH._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"fileArray":return t.fileArray(e);default:return t._other(e)}}};var kNt={typeReference:e=>({...e,type:"typeReference",_visit:function(t){return kNt._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return kNt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"typeReference":return t.typeReference(e);case"bytes":return t.bytes(e);default:return t._other(e)}}};var j0e={justRequestBody:e=>({value:e,type:"justRequestBody",_visit:function(t){return j0e._visit(this,t)}}),wrapper:e=>({...e,type:"wrapper",_visit:function(t){return j0e._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"justRequestBody":return t.justRequestBody(e.value);case"wrapper":return t.wrapper(e);default:return t._other(e)}}};var UQ={json:e=>({value:e,type:"json",_visit:function(t){return UQ._visit(this,t)}}),fileDownload:e=>({...e,type:"fileDownload",_visit:function(t){return UQ._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return UQ._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return UQ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json(e.value);case"fileDownload":return t.fileDownload(e);case"text":return t.text(e);case"bytes":return t.bytes(e);default:return t._other(e)}}};var Xf={json:e=>({value:e,type:"json",_visit:function(t){return Xf._visit(this,t)}}),fileDownload:e=>({...e,type:"fileDownload",_visit:function(t){return Xf._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Xf._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return Xf._visit(this,t)}}),streaming:e=>({value:e,type:"streaming",_visit:function(t){return Xf._visit(this,t)}}),streamParameter:e=>({...e,type:"streamParameter",_visit:function(t){return Xf._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json(e.value);case"fileDownload":return t.fileDownload(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streaming":return t.streaming(e.value);case"streamParameter":return t.streamParameter(e);default:return t._other(e)}}};var mB={response:e=>({...e,type:"response",_visit:function(t){return mB._visit(this,t)}}),nestedPropertyAsResponse:e=>({...e,type:"nestedPropertyAsResponse",_visit:function(t){return mB._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"response":return t.response(e);case"nestedPropertyAsResponse":return t.nestedPropertyAsResponse(e);default:return t._other(e)}}};var OD={json:e=>({...e,type:"json",_visit:function(t){return OD._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return OD._visit(this,t)}}),sse:e=>({...e,type:"sse",_visit:function(t){return OD._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json(e);case"text":return t.text(e);case"sse":return t.sse(e);default:return t._other(e)}}};var q3={cursor:e=>({...e,type:"cursor",_visit:function(t){return q3._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return q3._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return q3._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 JH={query:e=>({...e,type:"query",_visit:function(t){return JH._visit(this,t)}}),body:e=>({...e,type:"body",_visit:function(t){return JH._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"query":return t.query(e);case"body":return t.body(e);default:return t._other(e)}}};var phe={language:e=>({...e,type:"language",_visit:function(t){return phe._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return phe._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 _he={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Php:"php",Rust:"rust",Swift:"swift",_visit:(e,t)=>{switch(e){case _he.Curl:return t.curl();case _he.Python:return t.python();case _he.Javascript:return t.javascript();case _he.Typescript:return t.typescript();case _he.Go:return t.go();case _he.Ruby:return t.ruby();case _he.Csharp:return t.csharp();case _he.Java:return t.java();case _he.Php:return t.php();case _he.Rust:return t.rust();case _he.Swift:return t.swift();default:return t._other()}}};var M1={single:()=>({type:"single",_visit:function(e){return M1._visit(this,e)}}),exploded:()=>({type:"exploded",_visit:function(e){return M1._visit(this,e)}}),commaSeparated:()=>({type:"commaSeparated",_visit:function(e){return M1._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"single":return t.single();case"exploded":return t.exploded();case"commaSeparated":return t.commaSeparated();default:return t._other(e)}}};var T3={inlinedRequestBody:e=>({...e,type:"inlinedRequestBody",_visit:function(t){return T3._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return T3._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedRequestBody":return t.inlinedRequestBody(e);case"reference":return t.reference(e);default:return t._other(e)}}};var L0={ok:e=>({value:e,type:"ok",_visit:function(t){return L0._visit(this,t)}}),error:e=>({...e,type:"error",_visit:function(t){return L0._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"ok":return t.ok(e.value);case"error":return t.error(e);default:return t._other(e)}}};var xP={body:e=>({value:e,type:"body",_visit:function(t){return xP._visit(this,t)}}),stream:e=>({value:e,type:"stream",_visit:function(t){return xP._visit(this,t)}}),sse:e=>({value:e,type:"sse",_visit:function(t){return xP._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"body":return t.body(e.value);case"stream":return t.stream(e.value);case"sse":return t.sse(e.value);default:return t._other(e)}}};var bnc={};Yt(bnc,{ApiDefinitionSource:()=>$H,ApiVersionScheme:()=>$Ii,ErrorDiscriminationStrategy:()=>hhe,ExampleStyle:()=>iIo});var iIo={Minimal:"minimal",Comprehensive:"comprehensive",_visit:(e,t)=>{switch(e){case iIo.Minimal:return t.minimal();case iIo.Comprehensive:return t.comprehensive();default:return t._other()}}};var $H={proto:e=>({...e,type:"proto",_visit:function(t){return $H._visit(this,t)}}),openapi:()=>({type:"openapi",_visit:function(e){return $H._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"proto":return t.proto(e);case"openapi":return t.openapi();default:return t._other(e)}}};var $Ii={header:e=>({...e,type:"header",_visit:function(t){return $Ii._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"header":return t.header(e);default:return t._other(e)}}};var hhe={statusCode:()=>({type:"statusCode",_visit:function(e){return hhe._visit(this,e)}}),property:e=>({...e,type:"property",_visit:function(t){return hhe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"statusCode":return t.statusCode();case"property":return t.property(e);default:return t._other(e)}}};var vnc={};Yt(vnc,{ProtobufMethodType:()=>eFt,ProtobufType:()=>Dh,WellKnownProtobufType:()=>sn});var Dh={wellKnown:e=>({value:e,type:"wellKnown",_visit:function(t){return Dh._visit(this,t)}}),userDefined:e=>({...e,type:"userDefined",_visit:function(t){return Dh._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"wellKnown":return t.wellKnown(e.value);case"userDefined":return t.userDefined(e);default:return t._other(e)}}};var sn={any:()=>({type:"any",_visit:function(e){return sn._visit(this,e)}}),api:()=>({type:"api",_visit:function(e){return sn._visit(this,e)}}),boolValue:()=>({type:"boolValue",_visit:function(e){return sn._visit(this,e)}}),bytesValue:()=>({type:"bytesValue",_visit:function(e){return sn._visit(this,e)}}),doubleValue:()=>({type:"doubleValue",_visit:function(e){return sn._visit(this,e)}}),duration:()=>({type:"duration",_visit:function(e){return sn._visit(this,e)}}),empty:()=>({type:"empty",_visit:function(e){return sn._visit(this,e)}}),enum:()=>({type:"enum",_visit:function(e){return sn._visit(this,e)}}),enumValue:()=>({type:"enumValue",_visit:function(e){return sn._visit(this,e)}}),field:()=>({type:"field",_visit:function(e){return sn._visit(this,e)}}),fieldCardinality:()=>({type:"fieldCardinality",_visit:function(e){return sn._visit(this,e)}}),fieldKind:()=>({type:"fieldKind",_visit:function(e){return sn._visit(this,e)}}),fieldMask:()=>({type:"fieldMask",_visit:function(e){return sn._visit(this,e)}}),floatValue:()=>({type:"floatValue",_visit:function(e){return sn._visit(this,e)}}),int32Value:()=>({type:"int32Value",_visit:function(e){return sn._visit(this,e)}}),int64Value:()=>({type:"int64Value",_visit:function(e){return sn._visit(this,e)}}),listValue:()=>({type:"listValue",_visit:function(e){return sn._visit(this,e)}}),method:()=>({type:"method",_visit:function(e){return sn._visit(this,e)}}),mixin:()=>({type:"mixin",_visit:function(e){return sn._visit(this,e)}}),nullValue:()=>({type:"nullValue",_visit:function(e){return sn._visit(this,e)}}),option:()=>({type:"option",_visit:function(e){return sn._visit(this,e)}}),sourceContext:()=>({type:"sourceContext",_visit:function(e){return sn._visit(this,e)}}),stringValue:()=>({type:"stringValue",_visit:function(e){return sn._visit(this,e)}}),struct:()=>({type:"struct",_visit:function(e){return sn._visit(this,e)}}),syntax:()=>({type:"syntax",_visit:function(e){return sn._visit(this,e)}}),timestamp:()=>({type:"timestamp",_visit:function(e){return sn._visit(this,e)}}),type:()=>({type:"type",_visit:function(e){return sn._visit(this,e)}}),uint32Value:()=>({type:"uint32Value",_visit:function(e){return sn._visit(this,e)}}),uint64Value:()=>({type:"uint64Value",_visit:function(e){return sn._visit(this,e)}}),value:()=>({type:"value",_visit:function(e){return sn._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"any":return t.any();case"api":return t.api();case"boolValue":return t.boolValue();case"bytesValue":return t.bytesValue();case"doubleValue":return t.doubleValue();case"duration":return t.duration();case"empty":return t.empty();case"enum":return t.enum();case"enumValue":return t.enumValue();case"field":return t.field();case"fieldCardinality":return t.fieldCardinality();case"fieldKind":return t.fieldKind();case"fieldMask":return t.fieldMask();case"floatValue":return t.floatValue();case"int32Value":return t.int32Value();case"int64Value":return t.int64Value();case"listValue":return t.listValue();case"method":return t.method();case"mixin":return t.mixin();case"nullValue":return t.nullValue();case"option":return t.option();case"sourceContext":return t.sourceContext();case"stringValue":return t.stringValue();case"struct":return t.struct();case"syntax":return t.syntax();case"timestamp":return t.timestamp();case"type":return t.type();case"uint32Value":return t.uint32Value();case"uint64Value":return t.uint64Value();case"value":return t.value();default:return t._other(e)}}};var eFt={Unary:"UNARY",ClientStream:"CLIENT_STREAM",ServerStream:"SERVER_STREAM",BidirectionalStream:"BIDIRECTIONAL_STREAM",_visit:(e,t)=>{switch(e){case eFt.Unary:return t.unary();case eFt.ClientStream:return t.clientStream();case eFt.ServerStream:return t.serverStream();case eFt.BidirectionalStream:return t.bidirectionalStream();default:return t._other()}}};var gnc={};Yt(gnc,{PublishTarget:()=>PB,PublishingConfig:()=>x6t});var x6t={github:e=>({...e,type:"github",_visit:function(t){return x6t._visit(this,t)}}),direct:e=>({...e,type:"direct",_visit:function(t){return x6t._visit(this,t)}}),filesystem:e=>({...e,type:"filesystem",_visit:function(t){return x6t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"github":return t.github(e);case"direct":return t.direct(e);case"filesystem":return t.filesystem(e);default:return t._other(e)}}};var PB={postman:e=>({...e,type:"postman",_visit:function(t){return PB._visit(this,t)}}),npm:e=>({...e,type:"npm",_visit:function(t){return PB._visit(this,t)}}),maven:e=>({...e,type:"maven",_visit:function(t){return PB._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return PB._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return PB._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"postman":return t.postman(e);case"npm":return t.npm(e);case"maven":return t.maven(e);case"pypi":return t.pypi(e);case"crates":return t.crates(e);default:return t._other(e)}}};var Onc={};Yt(Onc,{ContainerType:()=>ns,ExampleContainer:()=>op,ExamplePrimitive:()=>Sn,ExampleSingleUnionTypeProperties:()=>jB,ExampleTypeReferenceShape:()=>lu,ExampleTypeShape:()=>Bh,Literal:()=>iz,NamedTypeDefault:()=>INn,ObjectPropertyAccess:()=>G6t,PrimitiveTypeV1:()=>Su,PrimitiveTypeV2:()=>bn,ResolvedTypeReference:()=>LQ,ShapeType:()=>tFt,SingleUnionTypeProperties:()=>rz,Source:()=>Dvi,Type:()=>Yc,TypeReference:()=>ii});var Dvi={proto:e=>({value:e,type:"proto",_visit:function(t){return Dvi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"proto":return t.proto(e.value);default:return t._other(e)}}};var Yc={alias:e=>({...e,type:"alias",_visit:function(t){return Yc._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Yc._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Yc._visit(this,t)}}),union:e=>({...e,type:"union",_visit:function(t){return Yc._visit(this,t)}}),undiscriminatedUnion:e=>({...e,type:"undiscriminatedUnion",_visit:function(t){return Yc._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"alias":return t.alias(e);case"enum":return t.enum(e);case"object":return t.object(e);case"union":return t.union(e);case"undiscriminatedUnion":return t.undiscriminatedUnion(e);default:return t._other(e)}}};var LQ={container:e=>({container:e,type:"container",_visit:function(t){return LQ._visit(this,t)}}),named:e=>({...e,type:"named",_visit:function(t){return LQ._visit(this,t)}}),primitive:e=>({primitive:e,type:"primitive",_visit:function(t){return LQ._visit(this,t)}}),unknown:()=>({type:"unknown",_visit:function(e){return LQ._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"container":return t.container(e.container);case"named":return t.named(e);case"primitive":return t.primitive(e.primitive);case"unknown":return t.unknown();default:return t._other(e)}}};var tFt={Enum:"ENUM",Object:"OBJECT",Union:"UNION",UndiscriminatedUnion:"UNDISCRIMINATED_UNION",_visit:(e,t)=>{switch(e){case tFt.Enum:return t.enum();case tFt.Object:return t.object();case tFt.Union:return t.union();case tFt.UndiscriminatedUnion:return t.undiscriminatedUnion();default:return t._other()}}};var G6t={ReadOnly:"READ_ONLY",WriteOnly:"WRITE_ONLY",_visit:(e,t)=>{switch(e){case G6t.ReadOnly:return t.readOnly();case G6t.WriteOnly:return t.writeOnly();default:return t._other()}}};var rz={samePropertiesAsObject:e=>({...e,propertiesType:"samePropertiesAsObject",_visit:function(t){return rz._visit(this,t)}}),singleProperty:e=>({...e,propertiesType:"singleProperty",_visit:function(t){return rz._visit(this,t)}}),noProperties:()=>({propertiesType:"noProperties",_visit:function(e){return rz._visit(this,e)}}),_visit:(e,t)=>{switch(e.propertiesType){case"samePropertiesAsObject":return t.samePropertiesAsObject(e);case"singleProperty":return t.singleProperty(e);case"noProperties":return t.noProperties();default:return t._other(e)}}};var ii={container:e=>({container:e,type:"container",_visit:function(t){return ii._visit(this,t)}}),named:e=>({...e,type:"named",_visit:function(t){return ii._visit(this,t)}}),primitive:e=>({primitive:e,type:"primitive",_visit:function(t){return ii._visit(this,t)}}),unknown:()=>({type:"unknown",_visit:function(e){return ii._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"container":return t.container(e.container);case"named":return t.named(e);case"primitive":return t.primitive(e.primitive);case"unknown":return t.unknown();default:return t._other(e)}}};var INn={enum:e=>({...e,type:"enum",_visit:function(t){return INn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"enum":return t.enum(e);default:return t._other(e)}}};var ns={list:e=>({list:e,type:"list",_visit:function(t){return ns._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return ns._visit(this,t)}}),nullable:e=>({nullable:e,type:"nullable",_visit:function(t){return ns._visit(this,t)}}),optional:e=>({optional:e,type:"optional",_visit:function(t){return ns._visit(this,t)}}),set:e=>({set:e,type:"set",_visit:function(t){return ns._visit(this,t)}}),literal:e=>({literal:e,type:"literal",_visit:function(t){return ns._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"list":return t.list(e.list);case"map":return t.map(e);case"nullable":return t.nullable(e.nullable);case"optional":return t.optional(e.optional);case"set":return t.set(e.set);case"literal":return t.literal(e.literal);default:return t._other(e)}}};var Su={Integer:"INTEGER",Long:"LONG",Uint:"UINT",Uint64:"UINT_64",Float:"FLOAT",Double:"DOUBLE",Boolean:"BOOLEAN",String:"STRING",Date:"DATE",DateTime:"DATE_TIME",Uuid:"UUID",Base64:"BASE_64",BigInteger:"BIG_INTEGER",_visit:(e,t)=>{switch(e){case Su.Integer:return t.integer();case Su.Long:return t.long();case Su.Uint:return t.uint();case Su.Uint64:return t.uint64();case Su.Float:return t.float();case Su.Double:return t.double();case Su.Boolean:return t.boolean();case Su.String:return t.string();case Su.Date:return t.date();case Su.DateTime:return t.dateTime();case Su.Uuid:return t.uuid();case Su.Base64:return t.base64();case Su.BigInteger:return t.bigInteger();default:return t._other()}}};var bn={integer:e=>({...e,type:"integer",_visit:function(t){return bn._visit(this,t)}}),long:e=>({...e,type:"long",_visit:function(t){return bn._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return bn._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return bn._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return bn._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return bn._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return bn._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return bn._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return bn._visit(this,t)}}),dateTime:e=>({...e,type:"dateTime",_visit:function(t){return bn._visit(this,t)}}),uuid:e=>({...e,type:"uuid",_visit:function(t){return bn._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return bn._visit(this,t)}}),bigInteger:e=>({...e,type:"bigInteger",_visit:function(t){return bn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"integer":return t.integer(e);case"long":return t.long(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"boolean":return t.boolean(e);case"string":return t.string(e);case"date":return t.date(e);case"dateTime":return t.dateTime(e);case"uuid":return t.uuid(e);case"base64":return t.base64(e);case"bigInteger":return t.bigInteger(e);default:return t._other(e)}}};var iz={string:e=>({string:e,type:"string",_visit:function(t){return iz._visit(this,t)}}),boolean:e=>({boolean:e,type:"boolean",_visit:function(t){return iz._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"string":return t.string(e.string);case"boolean":return t.boolean(e.boolean);default:return t._other(e)}}};var Bh={alias:e=>({...e,type:"alias",_visit:function(t){return Bh._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Bh._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Bh._visit(this,t)}}),union:e=>({...e,type:"union",_visit:function(t){return Bh._visit(this,t)}}),undiscriminatedUnion:e=>({...e,type:"undiscriminatedUnion",_visit:function(t){return Bh._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"alias":return t.alias(e);case"enum":return t.enum(e);case"object":return t.object(e);case"union":return t.union(e);case"undiscriminatedUnion":return t.undiscriminatedUnion(e);default:return t._other(e)}}};var jB={samePropertiesAsObject:e=>({...e,type:"samePropertiesAsObject",_visit:function(t){return jB._visit(this,t)}}),singleProperty:e=>({...e,type:"singleProperty",_visit:function(t){return jB._visit(this,t)}}),noProperties:()=>({type:"noProperties",_visit:function(e){return jB._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"samePropertiesAsObject":return t.samePropertiesAsObject(e);case"singleProperty":return t.singleProperty(e);case"noProperties":return t.noProperties();default:return t._other(e)}}};var lu={primitive:e=>({primitive:e,type:"primitive",_visit:function(t){return lu._visit(this,t)}}),container:e=>({container:e,type:"container",_visit:function(t){return lu._visit(this,t)}}),unknown:e=>({unknown:e,type:"unknown",_visit:function(t){return lu._visit(this,t)}}),named:e=>({...e,type:"named",_visit:function(t){return lu._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.primitive);case"container":return t.container(e.container);case"unknown":return t.unknown(e.unknown);case"named":return t.named(e);default:return t._other(e)}}};var op={list:e=>({...e,type:"list",_visit:function(t){return op._visit(this,t)}}),set:e=>({...e,type:"set",_visit:function(t){return op._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return op._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return op._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return op._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return op._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"list":return t.list(e);case"set":return t.set(e);case"optional":return t.optional(e);case"nullable":return t.nullable(e);case"map":return t.map(e);case"literal":return t.literal(e);default:return t._other(e)}}};var Sn={integer:e=>({integer:e,type:"integer",_visit:function(t){return Sn._visit(this,t)}}),long:e=>({long:e,type:"long",_visit:function(t){return Sn._visit(this,t)}}),uint:e=>({uint:e,type:"uint",_visit:function(t){return Sn._visit(this,t)}}),uint64:e=>({uint64:e,type:"uint64",_visit:function(t){return Sn._visit(this,t)}}),float:e=>({float:e,type:"float",_visit:function(t){return Sn._visit(this,t)}}),double:e=>({double:e,type:"double",_visit:function(t){return Sn._visit(this,t)}}),boolean:e=>({boolean:e,type:"boolean",_visit:function(t){return Sn._visit(this,t)}}),string:e=>({string:e,type:"string",_visit:function(t){return Sn._visit(this,t)}}),date:e=>({date:e,type:"date",_visit:function(t){return Sn._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Sn._visit(this,t)}}),uuid:e=>({uuid:e,type:"uuid",_visit:function(t){return Sn._visit(this,t)}}),base64:e=>({base64:e,type:"base64",_visit:function(t){return Sn._visit(this,t)}}),bigInteger:e=>({bigInteger:e,type:"bigInteger",_visit:function(t){return Sn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"integer":return t.integer(e.integer);case"long":return t.long(e.long);case"uint":return t.uint(e.uint);case"uint64":return t.uint64(e.uint64);case"float":return t.float(e.float);case"double":return t.double(e.double);case"boolean":return t.boolean(e.boolean);case"string":return t.string(e.string);case"date":return t.date(e.date);case"datetime":return t.datetime(e);case"uuid":return t.uuid(e.uuid);case"base64":return t.base64(e.base64);case"bigInteger":return t.bigInteger(e.bigInteger);default:return t._other(e)}}};var fo_={};var Anc={};Yt(Anc,{WebhookHttpMethod:()=>nIo,WebhookPayload:()=>VQ});var VQ={inlinedPayload:e=>({...e,type:"inlinedPayload",_visit:function(t){return VQ._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return VQ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedPayload":return t.inlinedPayload(e);case"reference":return t.reference(e);default:return t._other(e)}}};var nIo={Get:"GET",Post:"POST",_visit:(e,t)=>{switch(e){case nIo.Get:return t.get();case nIo.Post:return t.post();default:return t._other()}}};var mnc={};Yt(mnc,{ExampleWebSocketMessageBody:()=>yhe,WebSocketMessageBody:()=>nz,WebSocketMessageOrigin:()=>aIo});var aIo={Client:"client",Server:"server",_visit:(e,t)=>{switch(e){case aIo.Client:return t.client();case aIo.Server:return t.server();default:return t._other()}}};var nz={inlinedBody:e=>({...e,type:"inlinedBody",_visit:function(t){return nz._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return nz._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedBody":return t.inlinedBody(e);case"reference":return t.reference(e);default:return t._other(e)}}};var yhe={inlinedBody:e=>({...e,type:"inlinedBody",_visit:function(t){return yhe._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return yhe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedBody":return t.inlinedBody(e);case"reference":return t.reference(e);default:return t._other(e)}}};var Cn={};Yt(Cn,{AliasTypeDeclaration:()=>yTo,ApiAuth:()=>DIo,ApiDefinitionSource:()=>lRo,ApiDefinitionSourceId:()=>sRo,ApiVersionScheme:()=>J1o,AudienceDefinition:()=>lIo,AudienceReference:()=>RNn,AuthScheme:()=>MIo,AuthSchemeKey:()=>zNn,AuthSchemesRequirement:()=>dIo,AuthScope:()=>fIo,AutogeneratedEndpointExample:()=>q1o,Availability:()=>J6t,AvailabilityStatus:()=>yIo,Base64Type:()=>dTo,BaseAuthScheme:()=>E0e,BasicAuthScheme:()=>_Io,BasicAuthValues:()=>tqo,BearerAuthScheme:()=>pIo,BearerAuthValues:()=>rqo,BigIntegerType:()=>pTo,BooleanType:()=>oTo,BytesRequest:()=>aFn,BytesResponse:()=>lFn,Constants:()=>CIo,ContainerType:()=>AFn,CratesPublishTarget:()=>yRo,CsharpProtobufFileOptions:()=>T1o,CursorPagination:()=>b1o,CustomPagination:()=>g1o,DateTimeType:()=>lTo,DateType:()=>cTo,Declaration:()=>TC,DeclaredErrorName:()=>sCi,DeclaredServiceName:()=>Lqo,DeclaredTypeName:()=>qj,DirectPublish:()=>vRo,DisplayName:()=>rCi,DoubleType:()=>aTo,DoubleValidationRules:()=>nTo,Encoding:()=>vFn,EndpointId:()=>Bvi,EndpointName:()=>Wqo,EndpointReference:()=>ZIi,EnumTypeDeclaration:()=>gFn,EnumTypeReference:()=>Go_,EnumValue:()=>Ivi,EnvironmentBaseUrlId:()=>bhe,EnvironmentBaseUrlWithId:()=>GCo,EnvironmentId:()=>X6t,EnvironmentUrl:()=>uCi,EnvironmentVariable:()=>w0e,Environments:()=>JCo,EnvironmentsConfig:()=>$Co,ErrorDeclaration:()=>XCo,ErrorDeclarationDiscriminantValue:()=>Vo_,ErrorDiscriminationByPropertyStrategy:()=>ZTo,ErrorDiscriminationStrategy:()=>kTo,ErrorId:()=>iCi,EscapedString:()=>BIo,ExampleAliasType:()=>SRo,ExampleCodeSample:()=>P1o,ExampleCodeSampleLanguage:()=>A1o,ExampleCodeSampleSdk:()=>m1o,ExampleContainer:()=>NRo,ExampleDatetime:()=>zRo,ExampleEndpointCall:()=>hFn,ExampleEndpointErrorResponse:()=>B1o,ExampleEndpointSuccessResponse:()=>D1o,ExampleEnumType:()=>ERo,ExampleError:()=>YCo,ExampleExtraObjectProperty:()=>BRo,ExampleHeader:()=>wKi,ExampleInlinedRequestBody:()=>_Fn,ExampleInlinedRequestBodyExtraProperty:()=>E1o,ExampleInlinedRequestBodyProperty:()=>w1o,ExampleKeyValuePair:()=>GRo,ExampleListContainer:()=>URo,ExampleLiteralContainer:()=>QRo,ExampleMapContainer:()=>xRo,ExampleNamedType:()=>FRo,ExampleNullableContainer:()=>WRo,ExampleObjectProperty:()=>EFn,ExampleObjectType:()=>wFn,ExampleObjectTypeWithTypeId:()=>TRo,ExampleOptionalContainer:()=>VRo,ExamplePathParameter:()=>lCi,ExamplePrimitive:()=>SFn,ExampleQueryParameter:()=>pFn,ExampleQueryParameterShape:()=>j1o,ExampleRequestBody:()=>S1o,ExampleResponse:()=>I1o,ExampleServerSideEvent:()=>M1o,ExampleSetContainer:()=>LRo,ExampleSingleUnionType:()=>CRo,ExampleSingleUnionTypeProperties:()=>qRo,ExampleStyle:()=>oRo,ExampleType:()=>G0a,ExampleTypeReference:()=>xl,ExampleTypeReferenceShape:()=>RRo,ExampleTypeShape:()=>mFn,ExampleUndiscriminatedUnionType:()=>DRo,ExampleUnionBaseProperty:()=>IRo,ExampleUnionType:()=>MRo,ExampleWebSocketMessage:()=>KTo,ExampleWebSocketMessageBody:()=>HTo,ExampleWebSocketSession:()=>JTo,ExampleWebhookCall:()=>zTo,FeatureId:()=>L0a,FernFilepath:()=>S0e,FileDownloadResponse:()=>sFn,FileProperty:()=>$qo,FilePropertyArray:()=>Jqo,FilePropertySingle:()=>Kqo,FileUploadBodyProperty:()=>Xqo,FileUploadBodyPropertyEncoding:()=>Yqo,FileUploadRequest:()=>kqo,FileUploadRequestProperty:()=>Zqo,Filesystem:()=>gRo,FloatType:()=>iTo,GenerationMetadata:()=>ARo,GithubPublish:()=>bRo,GrpcTransport:()=>N1o,HeaderApiVersionScheme:()=>K1o,HeaderAuthScheme:()=>hIo,HeaderAuthValues:()=>iqo,HttpEndpoint:()=>W1o,HttpEndpointSecurityItem:()=>y1o,HttpEndpointSource:()=>U1o,HttpHeader:()=>GQ,HttpMethod:()=>xqo,HttpPath:()=>D0e,HttpPathPart:()=>Vqo,HttpRequestBody:()=>oFn,HttpRequestBodyReference:()=>nFn,HttpResponse:()=>cCi,HttpResponseBody:()=>d1o,HttpService:()=>H1o,InferredAuthScheme:()=>SIo,InferredAuthSchemeTokenEndpoint:()=>EIo,InferredAuthenticatedRequestHeader:()=>wIo,InlinedRequestBody:()=>Hqo,InlinedRequestBodyProperty:()=>iFn,InlinedWebSocketMessageBody:()=>VTo,InlinedWebSocketMessageBodyProperty:()=>LTo,InlinedWebhookPayload:()=>qTo,InlinedWebhookPayloadProperty:()=>CTo,IntegerType:()=>k1o,IntegerValidationRules:()=>Z1o,IntermediateRepresentation:()=>xo_,JsonEncoding:()=>x1o,JsonResponse:()=>uFn,JsonResponseBody:()=>a1o,JsonResponseBodyWithProperty:()=>o1o,JsonStreamChunk:()=>u1o,Literal:()=>jRo,LongType:()=>eTo,MapType:()=>wRo,MavenPublishTarget:()=>_Ro,MultipleBaseUrlsEnvironment:()=>HCo,MultipleBaseUrlsEnvironments:()=>KCo,MultipleEnvironmentUrlValues:()=>eqo,Name:()=>ga,NameAndWireValue:()=>jc,NamedType:()=>PRo,NamedTypeDefault:()=>mRo,NonStreamHttpResponseBody:()=>l1o,NpmPublishTarget:()=>pRo,OAuthAccessTokenRequestProperties:()=>vIo,OAuthAccessTokenResponseProperties:()=>FNn,OAuthClientCredentials:()=>mIo,OAuthConfiguration:()=>PIo,OAuthRefreshEndpoint:()=>AIo,OAuthRefreshTokenRequestProperties:()=>OIo,OAuthScheme:()=>jIo,OAuthTokenEndpoint:()=>gIo,OAuthValues:()=>nqo,ObjectProperty:()=>yx,ObjectPropertyAccess:()=>eCi,ObjectTypeDeclaration:()=>bTo,OffsetPagination:()=>v1o,Package:()=>jFn,PackageNavigationConfig:()=>YTo,Pagination:()=>O1o,PathParameter:()=>iFt,PathParameterLocation:()=>Gqo,PlatformHeaders:()=>tRo,PostmanPublishTarget:()=>dRo,PrimitiveType:()=>OFn,PrimitiveTypeV1:()=>X1o,PrimitiveTypeV2:()=>_To,PropertyPathItem:()=>NNn,ProtoEncoding:()=>G1o,ProtoSource:()=>cRo,ProtoSourceInfo:()=>Q1o,ProtobufFile:()=>yFn,ProtobufFileOptions:()=>R1o,ProtobufMethodType:()=>F1o,ProtobufService:()=>z1o,ProtobufType:()=>STo,PublishTarget:()=>fCi,PublishingConfig:()=>ORo,PypiPublishTarget:()=>hRo,QueryParameter:()=>kIi,ReadmeConfig:()=>uRo,ReadmeCustomSection:()=>aRo,RequestProperty:()=>z3,RequestPropertyValue:()=>bIo,ResolvedNamedType:()=>Y1o,ResolvedTypeReference:()=>hTo,ResponseError:()=>_1o,ResponseErrors:()=>h1o,ResponseProperty:()=>uz,RetriesConfiguration:()=>V1o,RetriesDisabledSchema:()=>L1o,SafeAndUnsafeString:()=>PKi,SdkConfig:()=>rRo,SdkRequest:()=>n1o,SdkRequestBodyType:()=>t1o,SdkRequestShape:()=>i1o,SdkRequestWrapper:()=>r1o,ServiceId:()=>H6t,ServiceTypeReferenceInfo:()=>nRo,ShapeType:()=>$1o,SingleBaseUrlEnvironment:()=>WCo,SingleBaseUrlEnvironments:()=>xCo,SingleUnionType:()=>OTo,SingleUnionTypeProperties:()=>gTo,SingleUnionTypeProperty:()=>vTo,Source:()=>MTo,SourceConfig:()=>fRo,SseStreamChunk:()=>c1o,StreamParameterResponse:()=>f1o,StreamingResponse:()=>fFn,StringType:()=>sTo,StringValidationRules:()=>uTo,Subpackage:()=>XTo,SubpackageId:()=>K6t,SupportedSdkLanguage:()=>dFn,TextResponse:()=>cFn,TextStreamChunk:()=>s1o,Transport:()=>bFn,Type:()=>jTo,TypeDeclaration:()=>DTo,TypeId:()=>WQ,TypeReference:()=>as,Uint64Type:()=>rTo,UintType:()=>tTo,UndiscriminatedUnionMember:()=>mTo,UndiscriminatedUnionTypeDeclaration:()=>PTo,UnionTypeDeclaration:()=>ATo,UserAgent:()=>eRo,UserDefinedProtobufType:()=>ETo,UserSpecifiedEndpointExample:()=>C1o,UuidType:()=>fTo,V2AuthValues:()=>HNn,V2EndpointLocation:()=>kCo,V2EndpointLocationHttpMethod:()=>ZCo,V2EnvironmentValues:()=>GNn,V2HttpEndpointCodeSample:()=>sqo,V2HttpEndpointExample:()=>V0a,V2HttpEndpointExamples:()=>cqo,V2HttpEndpointRequest:()=>aqo,V2HttpEndpointResponse:()=>uqo,V2HttpEndpointResponseBody:()=>oqo,V2HttpRequestBodies:()=>e1o,V2HttpResponses:()=>p1o,V2SchemaExample:()=>U0a,V2SchemaExamples:()=>oz,V2ValueExamples:()=>Z6t,V2WebSocketEndpointLocation:()=>lqo,V2WebSocketMessageExample:()=>fqo,V2WebSocketSessionExample:()=>W0a,V2WebSocketSessionExamples:()=>dqo,V2WebhookExample:()=>x0a,V2WebhookExamples:()=>pqo,VariableDeclaration:()=>iRo,VariableId:()=>rFn,WebSocketChannel:()=>$To,WebSocketChannelId:()=>UNn,WebSocketMessage:()=>GTo,WebSocketMessageBody:()=>xTo,WebSocketMessageBodyReference:()=>WTo,WebSocketMessageId:()=>PFn,WebSocketMessageOrigin:()=>UTo,WebSocketName:()=>QTo,Webhook:()=>NTo,WebhookGroup:()=>FTo,WebhookGroupId:()=>QNn,WebhookHttpMethod:()=>ITo,WebhookId:()=>IIo,WebhookName:()=>BTo,WebhookPayload:()=>RTo,WebhookPayloadReference:()=>TTo,WellKnownProtobufType:()=>wTo,WithContentType:()=>M0e,WithDocs:()=>Nn,WithDocsAndAvailability:()=>tCi,WithJsonExample:()=>$6t,WithV2Examples:()=>Cj,audience:()=>Snc,auth:()=>Mnc,commons:()=>Dnc,constants:()=>Bnc,dynamic:()=>YE,environment:()=>Lnc,errors:()=>Vnc,examples:()=>Wnc,generatorExec:()=>Gnc,http:()=>Hnc,ir:()=>Knc,proto:()=>Jnc,publish:()=>$nc,types:()=>Ync,variables:()=>Xnc,webhooks:()=>Znc,websocket:()=>knc});var Snc={};Yt(Snc,{AudienceDefinition:()=>lIo,AudienceReference:()=>RNn});var S={};Yt(S,{JsonError:()=>CNn,ParseError:()=>qNn,any:()=>Eo_,bigint:()=>po_,boolean:()=>So_,booleanLiteral:()=>wo_,date:()=>_o_,discriminant:()=>zo_,enum_:()=>uIo,getObjectLikeUtils:()=>rFt,getObjectUtils:()=>mKi,getSchemaUtils:()=>Km,isProperty:()=>XIi,lazy:()=>ho_,lazyObject:()=>mo_,list:()=>cIo,number:()=>Mo_,object:()=>sIo,objectWithoutOptionalProperties:()=>Ao_,optional:()=>Pnc,property:()=>bo_,record:()=>Co_,set:()=>qo_,string:()=>Do_,stringLiteral:()=>jo_,transform:()=>jnc,undiscriminatedUnion:()=>Ro_,union:()=>Fo_,unknown:()=>Bo_,withParsedProperties:()=>Enc});var rh={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 EA(e,t){return`Expected ${t}. Received ${RJS(e)}.`}function RJS(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 az(e){return{...e,json:do_(e.json),parse:do_(e.parse)}}function do_(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(`
1350
1350
  `)),{ok:!0,value:t}):i}}function oIo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var CNn=class e extends Error{errors;constructor(t){super(t.map(oIo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var qNn=class e extends Error{errors;constructor(t){super(t.map(oIo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Km(e){return{optional:()=>Pnc(e),transform:t=>jnc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new qNn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new CNn(i.errors)}}}function Pnc(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:()=>rh.OPTIONAL};return{...t,...Km(t)}}function jnc(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,...Km(r)}}function po_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:EA(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:EA(t,"bigint")}]},getType:()=>rh.BIGINT};return{...az(e),...Km(e)}}var zJS=/^([+-]?\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 _o_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:EA(t,"string")}]}:zJS.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:EA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:EA(t,"Date object")}]},getType:()=>rh.DATE};return{...az(e),...Km(e)}}function R3(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...az(r),...Km(r)}}}function uIo(e){let t=new Set(e);return R3(rh.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:EA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:EA(i,"enum")}]}:{ok:!0,value:i})()}function ho_(e){let t=wnc(e);return{...t,...Km(t)}}function wnc(e){return{parse:(t,r)=>TNn(e).parse(t,r),json:(t,r)=>TNn(e).json(t,r),getType:()=>TNn(e).getType()}}function TNn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function N0a(e){return Object.entries(e)}function F0a(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function YIi(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 Q0a(e){return Object.keys(e)}function yo_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function rFt(e){return{withParsedProperties:t=>Enc(e,t)}}function Enc(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(!YIi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:EA(i,"object")}]};let a=new Set(Object.keys(t)),o=F0a(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...Km(r),...rFt(r)}}function bo_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function XIi(e){return e.isProperty}function sIo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>XIi(i)?i.rawKey:r),_getParsedProperties:()=>Q0a(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of N0a(e)){let f=XIi(c)?c.rawKey:o,s=XIi(c)?c.valueSchema:c,u={rawKey:f,parsedKey:o,valueSchema:s};n[f]=u,Oo_(s)&&a.push(f)}return vo_({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 N0a(e)){let c=XIi(o)?o.valueSchema:o;Oo_(c)&&n.push(a)}return vo_({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return XIi(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:()=>rh.OBJECT};return{...az(t),...Km(t),...rFt(t),...mKi(t)}}function vo_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!YIi(e))return{ok:!1,errors:[{path:a,message:EA(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 mKi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>go_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>go_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>rh.OBJECT};return{...r,...Km(r),...rFt(r),...mKi(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:()=>rh.OBJECT};return{...t,...Km(t),...rFt(t),...mKi(t)}}}}function go_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=yo_(Q0a(t),s=>n.has(s)),c=r(F0a(t,o)),f=i(F0a(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 Oo_(e){return!NJS(e)}function NJS(e){switch(e.getType()){case rh.ANY:case rh.UNKNOWN:case rh.OPTIONAL:return!0;default:return!1}}function Ao_(e){return sIo(e)}function mo_(e){let t={...wnc(e),_getRawProperties:()=>TNn(e)._getRawProperties(),_getParsedProperties:()=>TNn(e)._getParsedProperties()};return{...t,...Km(t),...rFt(t),...mKi(t)}}function cIo(e){let t={parse:(r,i)=>Po_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Po_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>rh.LIST};return{...az(t),...Km(t)}}function Po_(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:EA(e,"list"),path:[]}]}}function jo_(e){return R3(rh.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:EA(r,`"${e}"`)}]})()}function wo_(e){return R3(rh.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:EA(r,`${e.toString()}`)}]})()}var Eo_=R3(rh.ANY,e=>({ok:!0,value:e}));var So_=R3(rh.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:EA(e,"boolean")}]});var Mo_=R3(rh.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:EA(e,"number")}]});var Do_=R3(rh.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:EA(e,"string")}]});var Bo_=R3(rh.UNKNOWN,e=>({ok:!0,value:e}));function Co_(e,t){let r={parse:(i,n)=>Io_({value:i,isKeyNumeric:e.getType()===rh.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)=>Io_({value:i,isKeyNumeric:e.getType()===rh.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:()=>rh.RECORD};return{...az(r),...Km(r)}}function Io_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return YIi(e)?N0a(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:EA(e,"object")}]}}function qo_(e){let t=cIo(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:EA(i,"Set")}]},getType:()=>rh.SET};return{...az(r),...Km(r)}}function Ro_(e){let t={parse:(r,i)=>To_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>To_((n,a)=>n.json(r,a),e,i),getType:()=>rh.UNDISCRIMINATED_UNION};return{...az(t),...Km(t)}}function To_(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 zo_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Fo_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=uIo(Q0a(t)),a={parse:(o,c)=>No_({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)=>No_({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:()=>rh.UNION};return{...az(a),...Km(a),...rFt(a)}}function No_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!YIi(e))return{ok:!1,errors:[{path:c,message:EA(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 lIo=S.string();var RNn=S.string();var Mnc={};Yt(Mnc,{ApiAuth:()=>DIo,AuthScheme:()=>MIo,AuthSchemeKey:()=>zNn,AuthSchemesRequirement:()=>dIo,AuthScope:()=>fIo,BaseAuthScheme:()=>E0e,BasicAuthScheme:()=>_Io,BearerAuthScheme:()=>pIo,EnvironmentVariable:()=>w0e,HeaderAuthScheme:()=>hIo,InferredAuthScheme:()=>SIo,InferredAuthSchemeTokenEndpoint:()=>EIo,InferredAuthenticatedRequestHeader:()=>wIo,OAuthAccessTokenRequestProperties:()=>vIo,OAuthAccessTokenResponseProperties:()=>FNn,OAuthClientCredentials:()=>mIo,OAuthConfiguration:()=>PIo,OAuthRefreshEndpoint:()=>AIo,OAuthRefreshTokenRequestProperties:()=>OIo,OAuthScheme:()=>jIo,OAuthTokenEndpoint:()=>gIo});var w0e=S.string();var zNn=S.string();var fIo=S.string();var dIo=S.enum_(["ALL","ANY"]);var PKi=S.objectWithoutOptionalProperties({unsafeName:S.string(),safeName:S.string()});var ga=S.objectWithoutOptionalProperties({originalName:S.string(),camelCase:PKi,pascalCase:PKi,snakeCase:PKi,screamingSnakeCase:PKi});var Nn=S.objectWithoutOptionalProperties({docs:S.string().optional()});var E0e=S.objectWithoutOptionalProperties({key:zNn}).extend(Nn);var pIo=S.objectWithoutOptionalProperties({token:ga,tokenEnvVar:w0e.optional()}).extend(E0e);var _Io=S.objectWithoutOptionalProperties({username:ga,usernameEnvVar:w0e.optional(),password:ga,passwordEnvVar:w0e.optional()}).extend(E0e);var jc=S.objectWithoutOptionalProperties({wireValue:S.string(),name:ga});var hIo=S.objectWithoutOptionalProperties({name:jc,valueType:S.lazy(()=>as),prefix:S.string().optional(),headerEnvVar:w0e.optional()}).extend(E0e);var Bvi=S.string();var H6t=S.string();var K6t=S.string();var ZIi=S.objectWithoutOptionalProperties({endpointId:Bvi,serviceId:H6t,subpackageId:K6t.optional()});var NNn=S.objectWithoutOptionalProperties({name:ga,type:S.lazy(()=>as)});var U0a=S.unknown();var oz=S.objectWithoutOptionalProperties({userSpecifiedExamples:S.record(S.string(),U0a),autogeneratedExamples:S.record(S.string(),U0a)});var yIo=S.enum_(["IN_DEVELOPMENT","PRE_RELEASE","GENERAL_AVAILABILITY","DEPRECATED"]);var J6t=S.objectWithoutOptionalProperties({status:yIo,message:S.string().optional()});var TC=S.objectWithoutOptionalProperties({availability:J6t.optional()}).extend(Nn);var kIi=S.objectWithoutOptionalProperties({name:jc,valueType:S.lazy(()=>as),allowMultiple:S.boolean(),v2Examples:oz.optional(),explode:S.boolean().optional()}).extend(TC);var eCi=S.enum_(["READ_ONLY","WRITE_ONLY"]);var yx=S.objectWithoutOptionalProperties({name:jc,valueType:S.lazy(()=>as),propertyAccess:eCi.optional(),v2Examples:oz.optional()}).extend(TC);var bIo=S.union("type",{query:kIi,body:yx}).transform({transform:e=>{switch(e.type){case"query":return JH.query(e);case"body":return JH.body(e);default:return e}},untransform:({_visit:e,...t})=>t});var z3=S.objectWithoutOptionalProperties({propertyPath:S.list(NNn).optional(),property:bIo});var vIo=S.objectWithoutOptionalProperties({clientId:z3,clientSecret:z3,scopes:z3.optional(),customProperties:S.list(z3).optional()});var uz=S.objectWithoutOptionalProperties({propertyPath:S.list(NNn).optional(),property:yx});var FNn=S.objectWithoutOptionalProperties({accessToken:uz,expiresIn:uz.optional(),refreshToken:uz.optional()});var gIo=S.objectWithoutOptionalProperties({endpointReference:ZIi,requestProperties:vIo,responseProperties:FNn});var OIo=S.objectWithoutOptionalProperties({refreshToken:z3});var AIo=S.objectWithoutOptionalProperties({endpointReference:ZIi,requestProperties:OIo,responseProperties:FNn});var mIo=S.objectWithoutOptionalProperties({clientIdEnvVar:w0e.optional(),clientSecretEnvVar:w0e.optional(),tokenPrefix:S.string().optional(),tokenHeader:S.string().optional(),scopes:S.list(S.string()).optional(),tokenEndpoint:gIo,refreshEndpoint:AIo.optional()});var PIo=S.union("type",{clientCredentials:mIo}).transform({transform:e=>{switch(e.type){case"clientCredentials":return HIi.clientCredentials(e);default:return e}},untransform:({_visit:e,...t})=>t});var jIo=S.objectWithoutOptionalProperties({configuration:PIo}).extend(E0e);var wIo=S.objectWithoutOptionalProperties({responseProperty:uz,headerName:S.string(),valuePrefix:S.string().optional()});var EIo=S.objectWithoutOptionalProperties({endpoint:ZIi,expiryProperty:uz.optional(),authenticatedRequestHeaders:S.list(wIo)});var SIo=S.objectWithoutOptionalProperties({tokenEndpoint:EIo}).extend(E0e);var MIo=S.union(S.discriminant("type","_type"),{bearer:pIo,basic:_Io,header:hIo,oauth:jIo,inferred:SIo}).transform({transform:e=>{switch(e.type){case"bearer":return wA.bearer(e);case"basic":return wA.basic(e);case"header":return wA.header(e);case"oauth":return wA.oauth(e);case"inferred":return wA.inferred(e);default:return e}},untransform:({_visit:e,...t})=>t});var DIo=S.objectWithoutOptionalProperties({requirement:dIo,schemes:S.list(MIo)}).extend(Nn);var Dnc={};Yt(Dnc,{Availability:()=>J6t,AvailabilityStatus:()=>yIo,Declaration:()=>TC,DisplayName:()=>rCi,EndpointId:()=>Bvi,EndpointReference:()=>ZIi,ErrorId:()=>iCi,EscapedString:()=>BIo,FeatureId:()=>L0a,FernFilepath:()=>S0e,Name:()=>ga,NameAndWireValue:()=>jc,SafeAndUnsafeString:()=>PKi,ServiceId:()=>H6t,SubpackageId:()=>K6t,TypeId:()=>WQ,WebSocketChannelId:()=>UNn,WebhookGroupId:()=>QNn,WebhookId:()=>IIo,WithContentType:()=>M0e,WithDocs:()=>Nn,WithDocsAndAvailability:()=>tCi,WithJsonExample:()=>$6t});var tCi=S.objectWithoutOptionalProperties({availability:J6t.optional()}).extend(Nn);var S0e=S.objectWithoutOptionalProperties({allParts:S.list(ga),packagePath:S.list(ga),file:ga.optional()});var rCi=S.string();var BIo=S.objectWithoutOptionalProperties({original:S.string()});var $6t=S.objectWithoutOptionalProperties({jsonExample:S.unknown()});var M0e=S.objectWithoutOptionalProperties({contentType:S.string().optional()});var WQ=S.string();var iCi=S.string();var QNn=S.string();var IIo=S.string();var UNn=S.string();var L0a=S.string();var Bnc={};Yt(Bnc,{Constants:()=>CIo});var CIo=S.objectWithoutOptionalProperties({errorInstanceIdKey:jc});var YE={};Yt(YE,{AliasType:()=>yCo,Auth:()=>QIo,AuthValues:()=>GIo,BasicAuth:()=>qIo,BasicAuthValues:()=>UIo,BearerAuth:()=>TIo,BearerAuthValues:()=>LIo,BodyRequest:()=>$Io,CratesPublishInfo:()=>TCo,Declaration:()=>N3,DiscriminatedUnionType:()=>PCo,DynamicIntermediateRepresentation:()=>FCo,Endpoint:()=>sCo,EndpointExample:()=>uCo,EndpointId:()=>KIo,EndpointLocation:()=>VNn,EndpointSnippetRequest:()=>oCo,EndpointSnippetResponse:()=>Qo_,EnumType:()=>bCo,EnvironmentBaseUrlId:()=>aCi,EnvironmentBaseUrlWithId:()=>fCo,EnvironmentId:()=>Y6t,EnvironmentUrl:()=>oCi,EnvironmentValues:()=>aCo,Environments:()=>_Co,EnvironmentsConfig:()=>hCo,ErrorSeverity:()=>QCo,Error_:()=>UCo,FernFilepath:()=>HIo,FileUploadRequestBody:()=>ZIo,FileUploadRequestBodyProperty:()=>XIo,GeneratorConfig:()=>NCo,GeneratorOutputConfig:()=>zCo,GoPublishInfo:()=>SCo,HeaderAuth:()=>zIo,HeaderAuthValues:()=>VIo,HttpMethod:()=>JIo,InferredAuth:()=>FIo,InferredAuthValues:()=>xIo,InlinedRequest:()=>tCo,InlinedRequestBody:()=>kIo,InlinedRequestMetadata:()=>eCo,LiteralType:()=>LCo,MapType:()=>Lo_,MavenPublishInfo:()=>DCo,MultipleBaseUrlsEnvironment:()=>dCo,MultipleBaseUrlsEnvironments:()=>pCo,MultipleEnvironmentUrlValues:()=>nCo,Name:()=>Ij,NameAndWireValue:()=>xQ,NamedParameter:()=>GP,NamedType:()=>wCo,NpmPublishInfo:()=>BCo,NugetPublishInfo:()=>ICo,OAuth:()=>NIo,OAuthValues:()=>WIo,ObjectPropertyAccess:()=>RIo,ObjectType:()=>vCo,PrimitiveTypeV1:()=>VCo,PublishInfo:()=>RCo,PypiPublishInfo:()=>CCo,ReferencedRequestBody:()=>YIo,ReferencedRequestBodyType:()=>WNn,Request:()=>rCo,Response:()=>iCo,RubyGemsPublishInfo:()=>qCo,SafeAndUnsafeString:()=>jKi,SingleBaseUrlEnvironment:()=>cCo,SingleBaseUrlEnvironments:()=>lCo,SingleDiscriminatedUnionType:()=>mCo,SingleDiscriminatedUnionTypeNoProperties:()=>ACo,SingleDiscriminatedUnionTypeObject:()=>gCo,SingleDiscriminatedUnionTypeSingleProperty:()=>OCo,SwiftPublishInfo:()=>MCo,TypeId:()=>nCi,TypeReference:()=>Uo_,UndiscriminatedUnionType:()=>jCo,Values:()=>xNn,VariableDeclaration:()=>ECo,WithDocs:()=>LNn,auth:()=>Inc,commons:()=>Cnc,declaration:()=>qnc,endpoints:()=>Tnc,environment:()=>Rnc,http:()=>znc,ir:()=>Nnc,snippets:()=>Fnc,types:()=>Qnc,variables:()=>Unc});var Inc={};Yt(Inc,{Auth:()=>QIo,AuthValues:()=>GIo,BasicAuth:()=>qIo,BasicAuthValues:()=>UIo,BearerAuth:()=>TIo,BearerAuthValues:()=>LIo,HeaderAuth:()=>zIo,HeaderAuthValues:()=>VIo,InferredAuth:()=>FIo,InferredAuthValues:()=>xIo,OAuth:()=>NIo,OAuthValues:()=>WIo});var jKi=S.objectWithoutOptionalProperties({unsafeName:S.string(),safeName:S.string()});var Ij=S.objectWithoutOptionalProperties({originalName:S.string(),camelCase:jKi,pascalCase:jKi,snakeCase:jKi,screamingSnakeCase:jKi});var qIo=S.objectWithoutOptionalProperties({username:Ij,password:Ij});var TIo=S.objectWithoutOptionalProperties({token:Ij});var xQ=S.objectWithoutOptionalProperties({wireValue:S.string(),name:Ij});var RIo=S.enum_(["READ_ONLY","WRITE_ONLY"]);var GP=S.objectWithoutOptionalProperties({name:xQ,typeReference:S.lazy(()=>YE.TypeReference),propertyAccess:RIo.optional(),variable:S.string().optional()});var zIo=S.objectWithoutOptionalProperties({header:GP});var NIo=S.objectWithoutOptionalProperties({clientId:Ij,clientSecret:Ij});var FIo=S.objectWithoutOptionalProperties({parameters:S.list(GP).optional()});var QIo=S.union("type",{basic:qIo,bearer:TIo,header:zIo,oauth:NIo,inferred:FIo}).transform({transform:e=>{switch(e.type){case"basic":return Kt.Auth.basic(e);case"bearer":return Kt.Auth.bearer(e);case"header":return Kt.Auth.header(e);case"oauth":return Kt.Auth.oauth(e);case"inferred":return Kt.Auth.inferred(e);default:return e}},untransform:({_visit:e,...t})=>t});var UIo=S.objectWithoutOptionalProperties({username:S.string(),password:S.string()});var LIo=S.objectWithoutOptionalProperties({token:S.string()});var VIo=S.objectWithoutOptionalProperties({value:S.unknown()});var WIo=S.objectWithoutOptionalProperties({clientId:S.string(),clientSecret:S.string()});var xIo=S.objectWithoutOptionalProperties({values:S.record(S.string(),S.unknown()).optional()});var GIo=S.union("type",{basic:UIo,bearer:LIo,header:VIo,oauth:WIo,inferred:xIo}).transform({transform:e=>{switch(e.type){case"basic":return Kt.AuthValues.basic(e);case"bearer":return Kt.AuthValues.bearer(e);case"header":return Kt.AuthValues.header(e);case"oauth":return Kt.AuthValues.oauth(e);case"inferred":return Kt.AuthValues.inferred(e);default:return e}},untransform:({_visit:e,...t})=>t});var Cnc={};Yt(Cnc,{EndpointId:()=>KIo,FernFilepath:()=>HIo,Name:()=>Ij,NameAndWireValue:()=>xQ,SafeAndUnsafeString:()=>jKi,TypeId:()=>nCi,WithDocs:()=>LNn});var LNn=S.objectWithoutOptionalProperties({docs:S.string().optional()});var HIo=S.objectWithoutOptionalProperties({allParts:S.list(Ij),packagePath:S.list(Ij),file:Ij.optional()});var KIo=S.string();var nCi=S.string();var qnc={};Yt(qnc,{Declaration:()=>N3});var N3=S.objectWithoutOptionalProperties({fernFilepath:HIo,name:Ij});var Tnc={};Yt(Tnc,{BodyRequest:()=>$Io,Endpoint:()=>sCo,EndpointExample:()=>uCo,EndpointLocation:()=>VNn,FileUploadRequestBody:()=>ZIo,FileUploadRequestBodyProperty:()=>XIo,InlinedRequest:()=>tCo,InlinedRequestBody:()=>kIo,InlinedRequestMetadata:()=>eCo,ReferencedRequestBody:()=>YIo,ReferencedRequestBodyType:()=>WNn,Request:()=>rCo,Response:()=>iCo});var JIo=S.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD"]);var VNn=S.objectWithoutOptionalProperties({method:JIo,path:S.string()});var WNn=S.union("type",{bytes:S.object({}),typeReference:S.object({value:S.lazy(()=>YE.TypeReference)})}).transform({transform:e=>{switch(e.type){case"bytes":return Kt.ReferencedRequestBodyType.bytes();case"typeReference":return Kt.ReferencedRequestBodyType.typeReference(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var $Io=S.objectWithoutOptionalProperties({pathParameters:S.list(GP).optional(),body:WNn.optional()});var YIo=S.objectWithoutOptionalProperties({bodyKey:Ij,bodyType:WNn});var XIo=S.union("type",{file:xQ,fileArray:xQ,bodyProperty:GP}).transform({transform:e=>{switch(e.type){case"file":return Kt.FileUploadRequestBodyProperty.file(e);case"fileArray":return Kt.FileUploadRequestBodyProperty.fileArray(e);case"bodyProperty":return Kt.FileUploadRequestBodyProperty.bodyProperty(e);default:return e}},untransform:({_visit:e,...t})=>t});var ZIo=S.objectWithoutOptionalProperties({properties:S.list(XIo)});var kIo=S.union("type",{properties:S.object({value:S.list(GP)}),referenced:YIo,fileUpload:ZIo}).transform({transform:e=>{switch(e.type){case"properties":return Kt.InlinedRequestBody.properties(e.value);case"referenced":return Kt.InlinedRequestBody.referenced(e);case"fileUpload":return Kt.InlinedRequestBody.fileUpload(e);default:return e}},untransform:({_visit:e,...t})=>t});var eCo=S.objectWithoutOptionalProperties({includePathParameters:S.boolean(),onlyPathParameters:S.boolean()});var tCo=S.objectWithoutOptionalProperties({declaration:N3,pathParameters:S.list(GP).optional(),queryParameters:S.list(GP).optional(),headers:S.list(GP).optional(),body:kIo.optional(),metadata:eCo.optional()});var rCo=S.union("type",{body:$Io,inlined:tCo}).transform({transform:e=>{switch(e.type){case"body":return Kt.Request.body(e);case"inlined":return Kt.Request.inlined(e);default:return e}},untransform:({_visit:e,...t})=>t});var iCo=S.union("type",{json:S.object({}),streaming:S.object({}),streamParameter:S.object({}),fileDownload:S.object({}),text:S.object({}),bytes:S.object({})}).transform({transform:e=>{switch(e.type){case"json":return Kt.Response.json();case"streaming":return Kt.Response.streaming();case"streamParameter":return Kt.Response.streamParameter();case"fileDownload":return Kt.Response.fileDownload();case"text":return Kt.Response.text();case"bytes":return Kt.Response.bytes();default:return e}},untransform:({_visit:e,...t})=>t});var Y6t=S.string();var aCi=S.string();var oCi=S.string();var nCo=S.record(aCi,oCi);var aCo=S.undiscriminatedUnion([Y6t,nCo]);var xNn=S.record(S.string(),S.unknown());var oCo=S.objectWithoutOptionalProperties({endpoint:VNn,baseUrl:S.property("baseURL",S.string().optional()),environment:aCo.optional(),auth:GIo.optional(),pathParameters:xNn.optional(),queryParameters:xNn.optional(),headers:xNn.optional(),requestBody:S.unknown().optional()});var uCo=S.objectWithoutOptionalProperties({id:S.string(),name:S.string().optional()}).extend(oCo);var sCo=S.objectWithoutOptionalProperties({auth:QIo.optional(),declaration:N3,location:VNn,request:rCo,response:iCo,examples:S.list(uCo).optional()});var Rnc={};Yt(Rnc,{EnvironmentBaseUrlId:()=>aCi,EnvironmentBaseUrlWithId:()=>fCo,EnvironmentId:()=>Y6t,EnvironmentUrl:()=>oCi,EnvironmentValues:()=>aCo,Environments:()=>_Co,EnvironmentsConfig:()=>hCo,MultipleBaseUrlsEnvironment:()=>dCo,MultipleBaseUrlsEnvironments:()=>pCo,MultipleEnvironmentUrlValues:()=>nCo,SingleBaseUrlEnvironment:()=>cCo,SingleBaseUrlEnvironments:()=>lCo});var cCo=S.objectWithoutOptionalProperties({id:Y6t,name:Ij,url:oCi}).extend(LNn);var lCo=S.objectWithoutOptionalProperties({environments:S.list(cCo)});var fCo=S.objectWithoutOptionalProperties({id:aCi,name:Ij});var dCo=S.objectWithoutOptionalProperties({id:Y6t,name:Ij,urls:S.record(aCi,oCi)}).extend(LNn);var pCo=S.objectWithoutOptionalProperties({baseUrls:S.list(fCo),environments:S.list(dCo)});var _Co=S.union("type",{singleBaseUrl:lCo,multipleBaseUrls:pCo}).transform({transform:e=>{switch(e.type){case"singleBaseUrl":return Kt.Environments.singleBaseUrl(e);case"multipleBaseUrls":return Kt.Environments.multipleBaseUrls(e);default:return e}},untransform:({_visit:e,...t})=>t});var hCo=S.objectWithoutOptionalProperties({defaultEnvironment:Y6t.optional(),environments:_Co});var znc={};Yt(znc,{HttpMethod:()=>JIo});var Nnc={};Yt(Nnc,{CratesPublishInfo:()=>TCo,DynamicIntermediateRepresentation:()=>FCo,GeneratorConfig:()=>NCo,GeneratorOutputConfig:()=>zCo,GoPublishInfo:()=>SCo,MavenPublishInfo:()=>DCo,NpmPublishInfo:()=>BCo,NugetPublishInfo:()=>ICo,PublishInfo:()=>RCo,PypiPublishInfo:()=>CCo,RubyGemsPublishInfo:()=>qCo,SwiftPublishInfo:()=>MCo});var yCo=S.objectWithoutOptionalProperties({declaration:N3,typeReference:S.lazy(()=>YE.TypeReference)});var bCo=S.objectWithoutOptionalProperties({declaration:N3,values:S.list(xQ)});var vCo=S.objectWithoutOptionalProperties({declaration:N3,properties:S.list(GP),additionalProperties:S.boolean().optional()});var gCo=S.objectWithoutOptionalProperties({typeId:nCi,discriminantValue:xQ,properties:S.list(GP)});var OCo=S.objectWithoutOptionalProperties({typeReference:S.lazy(()=>YE.TypeReference),discriminantValue:xQ,properties:S.list(GP).optional()});var ACo=S.objectWithoutOptionalProperties({discriminantValue:xQ,properties:S.list(GP).optional()});var mCo=S.union("type",{samePropertiesAsObject:gCo,singleProperty:OCo,noProperties:ACo}).transform({transform:e=>{switch(e.type){case"samePropertiesAsObject":return Kt.SingleDiscriminatedUnionType.samePropertiesAsObject(e);case"singleProperty":return Kt.SingleDiscriminatedUnionType.singleProperty(e);case"noProperties":return Kt.SingleDiscriminatedUnionType.noProperties(e);default:return e}},untransform:({_visit:e,...t})=>t});var PCo=S.objectWithoutOptionalProperties({declaration:N3,discriminant:xQ,types:S.record(S.string(),mCo)});var jCo=S.objectWithoutOptionalProperties({declaration:N3,types:S.list(S.lazy(()=>YE.TypeReference))});var wCo=S.union("type",{alias:yCo,enum:bCo,object:vCo,discriminatedUnion:PCo,undiscriminatedUnion:jCo}).transform({transform:e=>{switch(e.type){case"alias":return Kt.NamedType.alias(e);case"enum":return Kt.NamedType.enum(e);case"object":return Kt.NamedType.object(e);case"discriminatedUnion":return Kt.NamedType.discriminatedUnion(e);case"undiscriminatedUnion":return Kt.NamedType.undiscriminatedUnion(e);default:return e}},untransform:({_visit:e,...t})=>t});var ECo=S.objectWithoutOptionalProperties({id:S.string(),name:ga,typeReference:S.lazy(()=>YE.TypeReference)});var SCo=S.objectWithoutOptionalProperties({version:S.string(),repoUrl:S.string()});var MCo=S.objectWithoutOptionalProperties({version:S.string(),repoUrl:S.string()});var DCo=S.objectWithoutOptionalProperties({version:S.string(),coordinate:S.string(),repoUrl:S.string().optional()});var BCo=S.objectWithoutOptionalProperties({version:S.string(),packageName:S.string(),repoUrl:S.string().optional()});var ICo=S.objectWithoutOptionalProperties({version:S.string(),packageName:S.string(),repoUrl:S.string().optional()});var CCo=S.objectWithoutOptionalProperties({version:S.string(),packageName:S.string(),repoUrl:S.string().optional()});var qCo=S.objectWithoutOptionalProperties({version:S.string(),packageName:S.string(),repoUrl:S.string().optional()});var TCo=S.objectWithoutOptionalProperties({version:S.string(),packageName:S.string(),repoUrl:S.string().optional()});var RCo=S.union("type",{go:SCo,swift:MCo,maven:DCo,npm:BCo,nuget:ICo,pypi:CCo,rubygems:qCo,crates:TCo}).transform({transform:e=>{switch(e.type){case"go":return Kt.PublishInfo.go(e);case"swift":return Kt.PublishInfo.swift(e);case"maven":return Kt.PublishInfo.maven(e);case"npm":return Kt.PublishInfo.npm(e);case"nuget":return Kt.PublishInfo.nuget(e);case"pypi":return Kt.PublishInfo.pypi(e);case"rubygems":return Kt.PublishInfo.rubygems(e);case"crates":return Kt.PublishInfo.crates(e);default:return e}},untransform:({_visit:e,...t})=>t});var zCo=S.union("type",{publish:S.object({value:RCo}),local:S.object({})}).transform({transform:e=>{switch(e.type){case"publish":return Kt.GeneratorOutputConfig.publish(e.value);case"local":return Kt.GeneratorOutputConfig.local();default:return e}},untransform:({_visit:e,...t})=>t});var NCo=S.objectWithoutOptionalProperties({apiName:S.string(),organization:S.string(),customConfig:S.unknown(),outputConfig:zCo});var FCo=S.objectWithoutOptionalProperties({version:S.stringLiteral("1.0.0"),types:S.record(nCi,wCo),endpoints:S.record(KIo,sCo),environments:hCo.optional(),headers:S.list(GP).optional(),pathParameters:S.list(GP).optional(),variables:S.list(ECo).optional(),generatorConfig:NCo.optional()});var Fnc={};Yt(Fnc,{EndpointSnippetRequest:()=>oCo,EndpointSnippetResponse:()=>Qo_,ErrorSeverity:()=>QCo,Error_:()=>UCo,Values:()=>xNn});var QCo=S.enum_(["CRITICAL","WARNING"]);var UCo=S.objectWithoutOptionalProperties({severity:QCo,message:S.string()});var Qo_=S.objectWithoutOptionalProperties({snippet:S.string(),errors:S.list(UCo).optional()});var Qnc={};Yt(Qnc,{AliasType:()=>yCo,DiscriminatedUnionType:()=>PCo,EnumType:()=>bCo,LiteralType:()=>LCo,MapType:()=>Lo_,NamedParameter:()=>GP,NamedType:()=>wCo,ObjectPropertyAccess:()=>RIo,ObjectType:()=>vCo,PrimitiveTypeV1:()=>VCo,SingleDiscriminatedUnionType:()=>mCo,SingleDiscriminatedUnionTypeNoProperties:()=>ACo,SingleDiscriminatedUnionTypeObject:()=>gCo,SingleDiscriminatedUnionTypeSingleProperty:()=>OCo,TypeReference:()=>Uo_,UndiscriminatedUnionType:()=>jCo});var LCo=S.union("type",{boolean:S.object({value:S.boolean()}),string:S.object({value:S.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Kt.LiteralType.boolean(e.value);case"string":return Kt.LiteralType.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var VCo=S.enum_(["INTEGER","LONG","UINT","UINT_64","FLOAT","DOUBLE","BOOLEAN","STRING","DATE","DATE_TIME","UUID","BASE_64","BIG_INTEGER"]);var Uo_=S.union("type",{list:S.object({value:S.lazy(()=>YE.TypeReference)}),literal:S.object({value:LCo}),map:S.lazyObject(()=>YE.MapType),named:S.object({value:nCi}),nullable:S.object({value:S.lazy(()=>YE.TypeReference)}),optional:S.object({value:S.lazy(()=>YE.TypeReference)}),primitive:S.object({value:VCo}),set:S.object({value:S.lazy(()=>YE.TypeReference)}),unknown:S.object({})}).transform({transform:e=>{switch(e.type){case"list":return Kt.TypeReference.list(e.value);case"literal":return Kt.TypeReference.literal(e.value);case"map":return Kt.TypeReference.map(e);case"named":return Kt.TypeReference.named(e.value);case"nullable":return Kt.TypeReference.nullable(e.value);case"optional":return Kt.TypeReference.optional(e.value);case"primitive":return Kt.TypeReference.primitive(e.value);case"set":return Kt.TypeReference.set(e.value);case"unknown":return Kt.TypeReference.unknown();default:return e}},untransform:({_visit:e,...t})=>t});var Lo_=S.objectWithoutOptionalProperties({key:S.lazy(()=>YE.TypeReference),value:S.lazy(()=>YE.TypeReference)});var Unc={};Yt(Unc,{VariableDeclaration:()=>ECo});var Lnc={};Yt(Lnc,{EnvironmentBaseUrlId:()=>bhe,EnvironmentBaseUrlWithId:()=>GCo,EnvironmentId:()=>X6t,EnvironmentUrl:()=>uCi,Environments:()=>JCo,EnvironmentsConfig:()=>$Co,MultipleBaseUrlsEnvironment:()=>HCo,MultipleBaseUrlsEnvironments:()=>KCo,SingleBaseUrlEnvironment:()=>WCo,SingleBaseUrlEnvironments:()=>xCo});var X6t=S.string();var bhe=S.string();var uCi=S.string();var WCo=S.objectWithoutOptionalProperties({id:X6t,name:ga,url:uCi}).extend(Nn);var xCo=S.objectWithoutOptionalProperties({environments:S.list(WCo)});var GCo=S.objectWithoutOptionalProperties({id:bhe,name:ga});var HCo=S.objectWithoutOptionalProperties({id:X6t,name:ga,urls:S.record(bhe,uCi)}).extend(Nn);var KCo=S.objectWithoutOptionalProperties({baseUrls:S.list(GCo),environments:S.list(HCo)});var JCo=S.union("type",{singleBaseUrl:xCo,multipleBaseUrls:KCo}).transform({transform:e=>{switch(e.type){case"singleBaseUrl":return $E.singleBaseUrl(e);case"multipleBaseUrls":return $E.multipleBaseUrls(e);default:return e}},untransform:({_visit:e,...t})=>t});var $Co=S.objectWithoutOptionalProperties({defaultEnvironment:X6t.optional(),environments:JCo});var Vnc={};Yt(Vnc,{DeclaredErrorName:()=>sCi,ErrorDeclaration:()=>XCo,ErrorDeclarationDiscriminantValue:()=>Vo_,ExampleError:()=>YCo});var sCi=S.objectWithoutOptionalProperties({errorId:iCi,fernFilepath:S0e,name:ga});var YCo=S.objectWithoutOptionalProperties({name:ga.optional(),shape:S.lazyObject(()=>xl)}).extend($6t).extend(Nn);var GQ=S.objectWithoutOptionalProperties({name:jc,valueType:S.lazy(()=>as),env:S.string().optional(),v2Examples:oz.optional()}).extend(TC);var XCo=S.objectWithoutOptionalProperties({name:sCi,displayName:S.string().optional(),discriminantValue:jc,type:S.lazy(()=>as).optional(),statusCode:S.number(),isWildcardStatusCode:S.boolean().optional(),examples:S.list(YCo),v2Examples:oz.optional(),headers:S.list(GQ).optional()}).extend(Nn);var Vo_=S.union("type",{property:jc,statusCode:S.object({})}).transform({transform:e=>{switch(e.type){case"property":return JIi.property(e);case"statusCode":return JIi.statusCode();default:return e}},untransform:({_visit:e,...t})=>t});var Wnc={};Yt(Wnc,{BasicAuthValues:()=>tqo,BearerAuthValues:()=>rqo,HeaderAuthValues:()=>iqo,MultipleEnvironmentUrlValues:()=>eqo,OAuthValues:()=>nqo,V2AuthValues:()=>HNn,V2EndpointLocation:()=>kCo,V2EndpointLocationHttpMethod:()=>ZCo,V2EnvironmentValues:()=>GNn,V2HttpEndpointCodeSample:()=>sqo,V2HttpEndpointExample:()=>V0a,V2HttpEndpointExamples:()=>cqo,V2HttpEndpointRequest:()=>aqo,V2HttpEndpointResponse:()=>uqo,V2HttpEndpointResponseBody:()=>oqo,V2SchemaExample:()=>U0a,V2SchemaExamples:()=>oz,V2ValueExamples:()=>Z6t,V2WebSocketEndpointLocation:()=>lqo,V2WebSocketMessageExample:()=>fqo,V2WebSocketSessionExample:()=>W0a,V2WebSocketSessionExamples:()=>dqo,V2WebhookExample:()=>x0a,V2WebhookExamples:()=>pqo,WithV2Examples:()=>Cj});var Cj=S.objectWithoutOptionalProperties({v2Examples:oz.optional()});var ZCo=S.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD"]);var kCo=S.objectWithoutOptionalProperties({method:ZCo,path:S.string()});var eqo=S.record(bhe,uCi);var GNn=S.undiscriminatedUnion([X6t,eqo]);var tqo=S.objectWithoutOptionalProperties({username:S.string(),password:S.string()});var rqo=S.objectWithoutOptionalProperties({token:S.string()});var iqo=S.objectWithoutOptionalProperties({value:S.unknown()});var nqo=S.objectWithoutOptionalProperties({clientId:S.string(),clientSecret:S.string()});var HNn=S.union("type",{basic:tqo,bearer:rqo,header:iqo,oauth:nqo}).transform({transform:e=>{switch(e.type){case"basic":return A0e.basic(e);case"bearer":return A0e.bearer(e);case"header":return A0e.header(e);case"oauth":return A0e.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var Z6t=S.record(S.string(),S.unknown());var aqo=S.objectWithoutOptionalProperties({endpoint:kCo,baseUrl:S.property("baseURL",S.string().optional()),environment:GNn.optional(),auth:HNn.optional(),pathParameters:Z6t.optional(),queryParameters:Z6t.optional(),headers:Z6t.optional(),requestBody:S.unknown().optional()}).extend(Nn);var oqo=S.union("type",{error:S.object({value:S.unknown()}),json:S.object({value:S.unknown()}),stream:S.object({value:S.list(S.unknown())})}).transform({transform:e=>{switch(e.type){case"error":return CC.error(e.value);case"json":return CC.json(e.value);case"stream":return CC.stream(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var uqo=S.objectWithoutOptionalProperties({statusCode:S.number().optional(),body:oqo.optional()}).extend(Nn);var sqo=S.objectWithoutOptionalProperties({name:S.string().optional(),language:S.string(),code:S.string()}).extend(Nn);var V0a=S.objectWithoutOptionalProperties({displayName:S.string().optional(),request:aqo.optional(),response:uqo.optional(),codeSamples:S.list(sqo).optional()});var cqo=S.objectWithoutOptionalProperties({userSpecifiedExamples:S.record(S.string(),V0a),autogeneratedExamples:S.record(S.string(),V0a)});var lqo=S.objectWithoutOptionalProperties({path:S.string()});var fqo=S.objectWithoutOptionalProperties({type:S.string(),body:S.unknown()});var W0a=S.objectWithoutOptionalProperties({channel:lqo,baseUrl:S.property("baseURL",S.string().optional()),environment:GNn.optional(),auth:HNn.optional(),pathParameters:Z6t.optional(),queryParameters:Z6t.optional(),headers:Z6t.optional(),messages:S.list(fqo).optional()});var dqo=S.objectWithoutOptionalProperties({autogeneratedExamples:S.record(S.string(),W0a),userSpecifiedExamples:S.record(S.string(),W0a)});var x0a=S.objectWithoutOptionalProperties({name:S.string().optional(),payload:S.unknown()});var pqo=S.objectWithoutOptionalProperties({userSpecifiedExamples:S.record(S.string(),x0a),autogeneratedExamples:S.record(S.string(),x0a)});var Gnc={};Yt(Gnc,{BasicLicense:()=>hqo,CratesGithubPublishInfo:()=>Tqo,CratesRegistryConfig:()=>eFn,CustomLicense:()=>yqo,EnvironmentVariable:()=>WS,GeneratorConfig:()=>Wo_,GeneratorEnvironment:()=>Uqo,GeneratorOutputConfig:()=>Fqo,GeneratorPublishConfig:()=>tFn,GeneratorPublishTarget:()=>Eqo,GeneratorRegistriesConfig:()=>Aqo,GeneratorRegistriesConfigV2:()=>jqo,GithubOutputMode:()=>zqo,GithubPublishInfo:()=>Rqo,LicenseConfig:()=>bqo,LicenseId:()=>_qo,MavenCentralSignature:()=>KNn,MavenCentralSignatureGithubInfo:()=>Mqo,MavenGithubPublishInfo:()=>Dqo,MavenRegistryConfig:()=>gqo,MavenRegistryConfigV2:()=>JNn,NpmGithubPublishInfo:()=>Sqo,NpmRegistryConfig:()=>Oqo,NpmRegistryConfigV2:()=>$Nn,NugetGithubPublishInfo:()=>qqo,NugetRegistryConfig:()=>kNn,OutputMetadata:()=>Pqo,OutputMetadataAuthor:()=>mqo,OutputMode:()=>Nqo,PostmanConfig:()=>wqo,PostmanGithubPublishInfo:()=>Bqo,PublishingMetadata:()=>vqo,PypiGithubPublishInfo:()=>Iqo,PypiMetadata:()=>YNn,PypiRegistryConfig:()=>XNn,RemoteGeneratorEnvironment:()=>Qqo,RubyGemsGithubPublishInfo:()=>Cqo,RubyGemsRegistryConfig:()=>ZNn,config:()=>xnc});var xnc={};Yt(xnc,{BasicLicense:()=>hqo,CratesGithubPublishInfo:()=>Tqo,CratesRegistryConfig:()=>eFn,CustomLicense:()=>yqo,EnvironmentVariable:()=>WS,GeneratorConfig:()=>Wo_,GeneratorEnvironment:()=>Uqo,GeneratorOutputConfig:()=>Fqo,GeneratorPublishConfig:()=>tFn,GeneratorPublishTarget:()=>Eqo,GeneratorRegistriesConfig:()=>Aqo,GeneratorRegistriesConfigV2:()=>jqo,GithubOutputMode:()=>zqo,GithubPublishInfo:()=>Rqo,LicenseConfig:()=>bqo,LicenseId:()=>_qo,MavenCentralSignature:()=>KNn,MavenCentralSignatureGithubInfo:()=>Mqo,MavenGithubPublishInfo:()=>Dqo,MavenRegistryConfig:()=>gqo,MavenRegistryConfigV2:()=>JNn,NpmGithubPublishInfo:()=>Sqo,NpmRegistryConfig:()=>Oqo,NpmRegistryConfigV2:()=>$Nn,NugetGithubPublishInfo:()=>qqo,NugetRegistryConfig:()=>kNn,OutputMetadata:()=>Pqo,OutputMetadataAuthor:()=>mqo,OutputMode:()=>Nqo,PostmanConfig:()=>wqo,PostmanGithubPublishInfo:()=>Bqo,PublishingMetadata:()=>vqo,PypiGithubPublishInfo:()=>Iqo,PypiMetadata:()=>YNn,PypiRegistryConfig:()=>XNn,RemoteGeneratorEnvironment:()=>Qqo,RubyGemsGithubPublishInfo:()=>Cqo,RubyGemsRegistryConfig:()=>ZNn});var _qo=S.enum_(["MIT","Apache-2.0"]);var hqo=S.objectWithoutOptionalProperties({id:_qo});var yqo=S.objectWithoutOptionalProperties({filename:S.string()});var bqo=S.union("type",{basic:hqo,custom:yqo}).transform({transform:e=>{switch(e.type){case"basic":return Qc.LicenseConfig.basic(e);case"custom":return Qc.LicenseConfig.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var vqo=S.objectWithoutOptionalProperties({packageDescription:S.property("package_description",S.string().optional()),publisherEmail:S.property("publisher_email",S.string().optional()),referenceUrl:S.property("reference_url",S.string().optional()),publisherName:S.property("publisher_name",S.string().optional())});var KNn=S.objectWithoutOptionalProperties({keyId:S.string(),password:S.string(),secretKey:S.string()});var gqo=S.objectWithoutOptionalProperties({registryUrl:S.string(),username:S.string(),password:S.string(),group:S.string(),signature:KNn.optional()});var Oqo=S.objectWithoutOptionalProperties({registryUrl:S.string(),token:S.string(),scope:S.string()});var Aqo=S.objectWithoutOptionalProperties({maven:gqo,npm:Oqo});var JNn=S.objectWithoutOptionalProperties({registryUrl:S.string(),username:S.string(),password:S.string(),coordinate:S.string(),signature:KNn.optional()});var $Nn=S.objectWithoutOptionalProperties({registryUrl:S.string(),token:S.string(),packageName:S.string()});var mqo=S.objectWithoutOptionalProperties({name:S.string(),email:S.string()});var Pqo=S.objectWithoutOptionalProperties({description:S.string().optional(),authors:S.list(mqo).optional()});var YNn=S.objectWithoutOptionalProperties({keywords:S.list(S.string()).optional(),documentationLink:S.string().optional(),homepageLink:S.string().optional()}).extend(Pqo);var XNn=S.objectWithoutOptionalProperties({registryUrl:S.string(),username:S.string(),password:S.string(),packageName:S.string(),pypiMetadata:YNn.optional()});var ZNn=S.objectWithoutOptionalProperties({registryUrl:S.string(),apiKey:S.string(),packageName:S.string()});var kNn=S.objectWithoutOptionalProperties({registryUrl:S.string(),apiKey:S.string(),packageName:S.string()});var eFn=S.objectWithoutOptionalProperties({registryUrl:S.string(),token:S.string(),packageName:S.string()});var jqo=S.objectWithoutOptionalProperties({maven:JNn,npm:$Nn,pypi:XNn,rubygems:ZNn,nuget:kNn,crates:eFn});var wqo=S.objectWithoutOptionalProperties({apiKey:S.string(),workspaceId:S.string()});var Eqo=S.union("type",{maven:JNn,npm:$Nn,pypi:XNn,postman:wqo,rubygems:ZNn,nuget:kNn,crates:eFn}).transform({transform:e=>{switch(e.type){case"maven":return Qc.GeneratorPublishTarget.maven(e);case"npm":return Qc.GeneratorPublishTarget.npm(e);case"pypi":return Qc.GeneratorPublishTarget.pypi(e);case"postman":return Qc.GeneratorPublishTarget.postman(e);case"rubygems":return Qc.GeneratorPublishTarget.rubygems(e);case"nuget":return Qc.GeneratorPublishTarget.nuget(e);case"crates":return Qc.GeneratorPublishTarget.crates(e);default:return e}},untransform:({_visit:e,...t})=>t});var tFn=S.objectWithoutOptionalProperties({registries:Aqo,registriesV2:jqo,publishTarget:Eqo.optional(),version:S.string()});var WS=S.string();var Sqo=S.objectWithoutOptionalProperties({registryUrl:S.string(),packageName:S.string(),tokenEnvironmentVariable:WS,shouldGeneratePublishWorkflow:S.boolean().optional()});var Mqo=S.objectWithoutOptionalProperties({keyIdEnvironmentVariable:WS,passwordEnvironmentVariable:WS,secretKeyEnvironmentVariable:WS});var Dqo=S.objectWithoutOptionalProperties({registryUrl:S.string(),coordinate:S.string(),usernameEnvironmentVariable:WS,passwordEnvironmentVariable:WS,signature:Mqo.optional(),shouldGeneratePublishWorkflow:S.boolean().optional()});var Bqo=S.objectWithoutOptionalProperties({apiKeyEnvironmentVariable:WS,workspaceIdEnvironmentVariable:WS});var Iqo=S.objectWithoutOptionalProperties({registryUrl:S.string(),packageName:S.string(),usernameEnvironmentVariable:WS,passwordEnvironmentVariable:WS,pypiMetadata:YNn.optional(),shouldGeneratePublishWorkflow:S.boolean().optional()});var Cqo=S.objectWithoutOptionalProperties({registryUrl:S.string(),packageName:S.string(),apiKeyEnvironmentVariable:WS,shouldGeneratePublishWorkflow:S.boolean().optional()});var qqo=S.objectWithoutOptionalProperties({registryUrl:S.string(),packageName:S.string(),apiKeyEnvironmentVariable:WS,shouldGeneratePublishWorkflow:S.boolean().optional()});var Tqo=S.objectWithoutOptionalProperties({registryUrl:S.string(),packageName:S.string(),tokenEnvironmentVariable:WS,shouldGeneratePublishWorkflow:S.boolean().optional()});var Rqo=S.union("type",{npm:Sqo,maven:Dqo,postman:Bqo,pypi:Iqo,rubygems:Cqo,nuget:qqo,crates:Tqo}).transform({transform:e=>{switch(e.type){case"npm":return Qc.GithubPublishInfo.npm(e);case"maven":return Qc.GithubPublishInfo.maven(e);case"postman":return Qc.GithubPublishInfo.postman(e);case"pypi":return Qc.GithubPublishInfo.pypi(e);case"rubygems":return Qc.GithubPublishInfo.rubygems(e);case"nuget":return Qc.GithubPublishInfo.nuget(e);case"crates":return Qc.GithubPublishInfo.crates(e);default:return e}},untransform:({_visit:e,...t})=>t});var zqo=S.objectWithoutOptionalProperties({version:S.string(),repoUrl:S.string(),installationToken:S.string().optional(),branch:S.string().optional(),publishInfo:Rqo.optional()});var Nqo=S.union("type",{publish:tFn,downloadFiles:S.object({}),github:zqo}).transform({transform:e=>{switch(e.type){case"publish":return Qc.OutputMode.publish(e);case"downloadFiles":return Qc.OutputMode.downloadFiles();case"github":return Qc.OutputMode.github(e);default:return e}},untransform:({_visit:e,...t})=>t});var Fqo=S.objectWithoutOptionalProperties({path:S.string(),snippetFilepath:S.string().optional(),snippetTemplateFilepath:S.string().optional(),publishingMetadata:vqo.optional(),mode:Nqo});var Qqo=S.objectWithoutOptionalProperties({coordinatorUrl:S.string(),coordinatorUrlV2:S.string(),id:S.string()});var Uqo=S.union(S.discriminant("type","_type"),{local:S.object({}),remote:Qqo}).transform({transform:e=>{switch(e.type){case"local":return Qc.GeneratorEnvironment.local();case"remote":return Qc.GeneratorEnvironment.remote(e);default:return e}},untransform:({_visit:e,...t})=>t});var Wo_=S.objectWithoutOptionalProperties({dryRun:S.boolean(),irFilepath:S.string(),originalReadmeFilepath:S.string().optional(),license:bqo.optional(),output:Fqo,publish:tFn.optional(),workspaceName:S.string(),organization:S.string(),customConfig:S.unknown(),environment:Uqo,whitelabel:S.boolean(),writeUnitTests:S.boolean(),generatePaginatedClients:S.boolean().optional(),generateOauthClients:S.boolean()});var Hnc={};Yt(Hnc,{AutogeneratedEndpointExample:()=>q1o,BytesRequest:()=>aFn,BytesResponse:()=>lFn,CursorPagination:()=>b1o,CustomPagination:()=>g1o,DeclaredServiceName:()=>Lqo,EndpointName:()=>Wqo,ExampleCodeSample:()=>P1o,ExampleCodeSampleLanguage:()=>A1o,ExampleCodeSampleSdk:()=>m1o,ExampleEndpointCall:()=>hFn,ExampleEndpointErrorResponse:()=>B1o,ExampleEndpointSuccessResponse:()=>D1o,ExampleHeader:()=>wKi,ExampleInlinedRequestBody:()=>_Fn,ExampleInlinedRequestBodyExtraProperty:()=>E1o,ExampleInlinedRequestBodyProperty:()=>w1o,ExamplePathParameter:()=>lCi,ExampleQueryParameter:()=>pFn,ExampleQueryParameterShape:()=>j1o,ExampleRequestBody:()=>S1o,ExampleResponse:()=>I1o,ExampleServerSideEvent:()=>M1o,FileDownloadResponse:()=>sFn,FileProperty:()=>$qo,FilePropertyArray:()=>Jqo,FilePropertySingle:()=>Kqo,FileUploadBodyProperty:()=>Xqo,FileUploadBodyPropertyEncoding:()=>Yqo,FileUploadRequest:()=>kqo,FileUploadRequestProperty:()=>Zqo,GrpcTransport:()=>N1o,HttpEndpoint:()=>W1o,HttpEndpointSecurityItem:()=>y1o,HttpEndpointSource:()=>U1o,HttpHeader:()=>GQ,HttpMethod:()=>xqo,HttpPath:()=>D0e,HttpPathPart:()=>Vqo,HttpRequestBody:()=>oFn,HttpRequestBodyReference:()=>nFn,HttpResponse:()=>cCi,HttpResponseBody:()=>d1o,HttpService:()=>H1o,InlinedRequestBody:()=>Hqo,InlinedRequestBodyProperty:()=>iFn,JsonResponse:()=>uFn,JsonResponseBody:()=>a1o,JsonResponseBodyWithProperty:()=>o1o,JsonStreamChunk:()=>u1o,NonStreamHttpResponseBody:()=>l1o,OffsetPagination:()=>v1o,Pagination:()=>O1o,PathParameter:()=>iFt,PathParameterLocation:()=>Gqo,PropertyPathItem:()=>NNn,ProtoSourceInfo:()=>Q1o,QueryParameter:()=>kIi,RequestProperty:()=>z3,RequestPropertyValue:()=>bIo,ResponseError:()=>_1o,ResponseErrors:()=>h1o,ResponseProperty:()=>uz,RetriesConfiguration:()=>V1o,RetriesDisabledSchema:()=>L1o,SdkRequest:()=>n1o,SdkRequestBodyType:()=>t1o,SdkRequestShape:()=>i1o,SdkRequestWrapper:()=>r1o,SseStreamChunk:()=>c1o,StreamParameterResponse:()=>f1o,StreamingResponse:()=>fFn,SupportedSdkLanguage:()=>dFn,TextResponse:()=>cFn,TextStreamChunk:()=>s1o,Transport:()=>bFn,UserSpecifiedEndpointExample:()=>C1o,V2HttpRequestBodies:()=>e1o,V2HttpResponses:()=>p1o});var Lqo=S.objectWithoutOptionalProperties({fernFilepath:S0e});var Vqo=S.objectWithoutOptionalProperties({pathParameter:S.string(),tail:S.string()});var D0e=S.objectWithoutOptionalProperties({head:S.string(),parts:S.list(Vqo)});var Wqo=ga;var xqo=S.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD"]);var Gqo=S.enum_(["ROOT","SERVICE","ENDPOINT"]);var rFn=S.string();var iFt=S.objectWithoutOptionalProperties({name:ga,valueType:S.lazy(()=>as),location:Gqo,variable:rFn.optional(),v2Examples:oz.optional(),explode:S.boolean().optional()}).extend(Nn);var qj=S.objectWithoutOptionalProperties({typeId:WQ,fernFilepath:S0e,name:ga,displayName:rCi.optional()});var iFn=S.objectWithoutOptionalProperties({name:jc,valueType:S.lazy(()=>as),v2Examples:oz.optional(),propertyAccess:eCi.optional()}).extend(tCi);var Hqo=S.objectWithoutOptionalProperties({name:ga,extends:S.list(qj),properties:S.list(iFn),extendedProperties:S.list(yx).optional(),extraProperties:S.property("extra-properties",S.boolean())}).extend(Nn).extend(Cj).extend(M0e);var nFn=S.objectWithoutOptionalProperties({requestBodyType:S.lazy(()=>as)}).extend(Nn).extend(M0e).extend(Cj);var Kqo=S.objectWithoutOptionalProperties({key:jc,isOptional:S.boolean(),contentType:S.string().optional()}).extend(Nn);var Jqo=S.objectWithoutOptionalProperties({key:jc,isOptional:S.boolean(),contentType:S.string().optional()}).extend(Nn);var $qo=S.union("type",{file:Kqo,fileArray:Jqo}).transform({transform:e=>{switch(e.type){case"file":return KH.file(e);case"fileArray":return KH.fileArray(e);default:return e}},untransform:({_visit:e,...t})=>t});var Yqo=S.enum_(["exploded","json","form"]);var Xqo=S.objectWithoutOptionalProperties({style:Yqo.optional()}).extend(iFn).extend(M0e);var Zqo=S.union("type",{file:S.object({value:$qo}),bodyProperty:Xqo}).transform({transform:e=>{switch(e.type){case"file":return qC.file(e.value);case"bodyProperty":return qC.bodyProperty(e);default:return e}},untransform:({_visit:e,...t})=>t});var kqo=S.objectWithoutOptionalProperties({name:ga,properties:S.list(Zqo)}).extend(Nn).extend(Cj).extend(M0e);var aFn=S.objectWithoutOptionalProperties({isOptional:S.boolean()}).extend(Nn).extend(Cj).extend(M0e);var oFn=S.union("type",{inlinedRequestBody:Hqo,reference:nFn,fileUpload:kqo,bytes:aFn}).transform({transform:e=>{switch(e.type){case"inlinedRequestBody":return UO.inlinedRequestBody(e);case"reference":return UO.reference(e);case"fileUpload":return UO.fileUpload(e);case"bytes":return UO.bytes(e);default:return e}},untransform:({_visit:e,...t})=>t});var e1o=S.objectWithoutOptionalProperties({requestBodies:S.list(oFn).optional()});var t1o=S.union("type",{typeReference:nFn,bytes:aFn}).transform({transform:e=>{switch(e.type){case"typeReference":return kNt.typeReference(e);case"bytes":return kNt.bytes(e);default:return e}},untransform:({_visit:e,...t})=>t});var r1o=S.objectWithoutOptionalProperties({wrapperName:ga,bodyKey:ga,includePathParameters:S.boolean().optional(),onlyPathParameters:S.boolean().optional()});var i1o=S.union("type",{justRequestBody:S.object({value:t1o}),wrapper:r1o}).transform({transform:e=>{switch(e.type){case"justRequestBody":return j0e.justRequestBody(e.value);case"wrapper":return j0e.wrapper(e);default:return e}},untransform:({_visit:e,...t})=>t});var n1o=S.objectWithoutOptionalProperties({streamParameter:z3.optional(),requestParameterName:ga,shape:i1o});var a1o=S.objectWithoutOptionalProperties({responseBodyType:S.lazy(()=>as)}).extend(Nn).extend(Cj);var o1o=S.objectWithoutOptionalProperties({responseBodyType:S.lazy(()=>as),responseProperty:yx.optional()}).extend(Nn).extend(Cj);var uFn=S.union("type",{response:a1o,nestedPropertyAsResponse:o1o}).transform({transform:e=>{switch(e.type){case"response":return mB.response(e);case"nestedPropertyAsResponse":return mB.nestedPropertyAsResponse(e);default:return e}},untransform:({_visit:e,...t})=>t});var sFn=S.objectWithoutOptionalProperties({}).extend(Nn).extend(Cj);var cFn=S.objectWithoutOptionalProperties({}).extend(Nn).extend(Cj);var lFn=S.objectWithoutOptionalProperties({}).extend(Nn).extend(Cj);var u1o=S.objectWithoutOptionalProperties({payload:S.lazy(()=>as),terminator:S.string().optional()}).extend(Nn).extend(Cj);var s1o=S.objectWithoutOptionalProperties({}).extend(Nn).extend(Cj);var c1o=S.objectWithoutOptionalProperties({payload:S.lazy(()=>as),terminator:S.string().optional()}).extend(Nn).extend(Cj);var fFn=S.union("type",{json:u1o,text:s1o,sse:c1o}).transform({transform:e=>{switch(e.type){case"json":return OD.json(e);case"text":return OD.text(e);case"sse":return OD.sse(e);default:return e}},untransform:({_visit:e,...t})=>t});var l1o=S.union("type",{json:S.object({value:uFn}),fileDownload:sFn,text:cFn,bytes:lFn}).transform({transform:e=>{switch(e.type){case"json":return UQ.json(e.value);case"fileDownload":return UQ.fileDownload(e);case"text":return UQ.text(e);case"bytes":return UQ.bytes(e);default:return e}},untransform:({_visit:e,...t})=>t});var f1o=S.objectWithoutOptionalProperties({nonStreamResponse:l1o,streamResponse:fFn});var d1o=S.union("type",{json:S.object({value:uFn}),fileDownload:sFn,text:cFn,bytes:lFn,streaming:S.object({value:fFn}),streamParameter:f1o}).transform({transform:e=>{switch(e.type){case"json":return Xf.json(e.value);case"fileDownload":return Xf.fileDownload(e);case"text":return Xf.text(e);case"bytes":return Xf.bytes(e);case"streaming":return Xf.streaming(e.value);case"streamParameter":return Xf.streamParameter(e);default:return e}},untransform:({_visit:e,...t})=>t});var cCi=S.objectWithoutOptionalProperties({statusCode:S.property("status-code",S.number().optional()),isWildcardStatusCode:S.boolean().optional(),body:d1o.optional()}).extend(Nn);var p1o=S.objectWithoutOptionalProperties({responses:S.list(cCi).optional()});var _1o=S.objectWithoutOptionalProperties({error:sCi}).extend(Nn);var h1o=S.list(_1o);var y1o=S.record(zNn,S.list(fIo));var b1o=S.objectWithoutOptionalProperties({page:z3,next:uz,results:uz});var v1o=S.objectWithoutOptionalProperties({page:z3,results:uz,hasNextPage:uz.optional(),step:z3.optional()});var g1o=S.objectWithoutOptionalProperties({results:uz});var O1o=S.union("type",{cursor:b1o,offset:v1o,custom:g1o}).transform({transform:e=>{switch(e.type){case"cursor":return q3.cursor(e);case"offset":return q3.offset(e);case"custom":return q3.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var A1o=S.objectWithoutOptionalProperties({name:ga.optional(),language:S.string(),code:S.string(),install:S.string().optional()}).extend(Nn);var dFn=S.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","php","rust","swift"]);var m1o=S.objectWithoutOptionalProperties({name:ga.optional(),sdk:dFn,code:S.string()}).extend(Nn);var P1o=S.union("type",{language:A1o,sdk:m1o}).transform({transform:e=>{switch(e.type){case"language":return phe.language(e);case"sdk":return phe.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var lCi=S.objectWithoutOptionalProperties({name:ga,value:S.lazyObject(()=>xl)});var wKi=S.objectWithoutOptionalProperties({name:jc,value:S.lazyObject(()=>xl)});var j1o=S.union("type",{single:S.object({}),exploded:S.object({}),commaSeparated:S.object({})}).transform({transform:e=>{switch(e.type){case"single":return M1.single();case"exploded":return M1.exploded();case"commaSeparated":return M1.commaSeparated();default:return e}},untransform:({_visit:e,...t})=>t});var pFn=S.objectWithoutOptionalProperties({name:jc,value:S.lazyObject(()=>xl),shape:j1o.optional()});var w1o=S.objectWithoutOptionalProperties({name:jc,value:S.lazyObject(()=>xl),originalTypeDeclaration:qj.optional()});var E1o=S.objectWithoutOptionalProperties({name:jc,value:S.lazyObject(()=>xl)});var _Fn=S.objectWithoutOptionalProperties({properties:S.list(w1o),extraProperties:S.list(E1o).optional()}).extend($6t);var S1o=S.union("type",{inlinedRequestBody:_Fn,reference:S.lazyObject(()=>xl)}).transform({transform:e=>{switch(e.type){case"inlinedRequestBody":return T3.inlinedRequestBody(e);case"reference":return T3.reference(e);default:return e}},untransform:({_visit:e,...t})=>t});var M1o=S.objectWithoutOptionalProperties({event:S.string(),data:S.lazyObject(()=>xl)});var D1o=S.union("type",{body:S.object({value:S.lazyObject(()=>xl).optional()}),stream:S.object({value:S.list(S.lazyObject(()=>xl))}),sse:S.object({value:S.list(M1o)})}).transform({transform:e=>{switch(e.type){case"body":return xP.body(e.value);case"stream":return xP.stream(e.value);case"sse":return xP.sse(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var B1o=S.objectWithoutOptionalProperties({error:sCi,body:S.lazyObject(()=>xl).optional()});var I1o=S.union("type",{ok:S.object({value:D1o}),error:B1o}).transform({transform:e=>{switch(e.type){case"ok":return L0.ok(e.value);case"error":return L0.error(e);default:return e}},untransform:({_visit:e,...t})=>t});var hFn=S.objectWithoutOptionalProperties({id:S.string().optional(),name:ga.optional(),url:S.string(),rootPathParameters:S.list(lCi),servicePathParameters:S.list(lCi),endpointPathParameters:S.list(lCi),serviceHeaders:S.list(wKi),endpointHeaders:S.list(wKi),queryParameters:S.list(pFn),request:S1o.optional(),response:I1o}).extend(Nn);var C1o=S.objectWithoutOptionalProperties({codeSamples:S.list(P1o).optional(),example:hFn.optional()});var q1o=S.objectWithoutOptionalProperties({example:hFn});var T1o=S.objectWithoutOptionalProperties({namespace:S.string()});var R1o=S.objectWithoutOptionalProperties({csharp:T1o.optional()});var yFn=S.objectWithoutOptionalProperties({filepath:S.string(),packageName:S.string().optional(),options:R1o.optional()});var z1o=S.objectWithoutOptionalProperties({file:yFn,name:ga});var N1o=S.objectWithoutOptionalProperties({service:z1o});var bFn=S.union("type",{http:S.object({}),grpc:N1o}).transform({transform:e=>{switch(e.type){case"http":return m0e.http();case"grpc":return m0e.grpc(e);default:return e}},untransform:({_visit:e,...t})=>t});var F1o=S.enum_(["UNARY","CLIENT_STREAM","SERVER_STREAM","BIDIRECTIONAL_STREAM"]);var Q1o=S.objectWithoutOptionalProperties({methodType:F1o.optional()});var U1o=S.union("type",{proto:Q1o,openapi:S.object({}),openrpc:S.object({})}).transform({transform:e=>{switch(e.type){case"proto":return C3.proto(e);case"openapi":return C3.openapi();case"openrpc":return C3.openrpc();default:return e}},untransform:({_visit:e,...t})=>t});var L1o=S.objectWithoutOptionalProperties({disabled:S.boolean().optional()});var V1o=S.undiscriminatedUnion([L1o]);var W1o=S.objectWithoutOptionalProperties({id:Bvi,name:Wqo,displayName:S.string().optional(),method:xqo,headers:S.list(GQ),baseUrl:bhe.optional(),v2BaseUrls:S.list(bhe).optional(),basePath:D0e.optional(),path:D0e,fullPath:D0e,pathParameters:S.list(iFt),allPathParameters:S.list(iFt),queryParameters:S.list(kIi),requestBody:oFn.optional(),v2RequestBodies:e1o.optional(),sdkRequest:n1o.optional(),response:cCi.optional(),v2Responses:p1o.optional(),errors:h1o,auth:S.boolean(),security:S.list(y1o).optional(),idempotent:S.boolean(),pagination:O1o.optional(),userSpecifiedExamples:S.list(C1o),autogeneratedExamples:S.list(q1o),v2Examples:cqo.optional(),transport:bFn.optional(),source:U1o.optional(),audiences:S.list(RNn).optional(),retries:V1o.optional(),apiPlayground:S.boolean().optional()}).extend(TC);var x1o=S.objectWithoutOptionalProperties({});var G1o=S.objectWithoutOptionalProperties({});var vFn=S.objectWithoutOptionalProperties({json:x1o.optional(),proto:G1o.optional()});var H1o=S.objectWithoutOptionalProperties({availability:J6t.optional(),name:Lqo,displayName:S.string().optional(),basePath:D0e,endpoints:S.list(W1o),headers:S.list(GQ),pathParameters:S.list(iFt),encoding:vFn.optional(),transport:bFn.optional(),audiences:S.list(RNn).optional()});var Knc={};Yt(Knc,{ApiDefinitionSource:()=>lRo,ApiDefinitionSourceId:()=>sRo,ApiVersionScheme:()=>J1o,ErrorDiscriminationByPropertyStrategy:()=>ZTo,ErrorDiscriminationStrategy:()=>kTo,ExampleStyle:()=>oRo,GenerationMetadata:()=>ARo,HeaderApiVersionScheme:()=>K1o,IntermediateRepresentation:()=>xo_,Package:()=>jFn,PackageNavigationConfig:()=>YTo,PlatformHeaders:()=>tRo,ProtoSource:()=>cRo,ReadmeConfig:()=>uRo,ReadmeCustomSection:()=>aRo,SdkConfig:()=>rRo,ServiceTypeReferenceInfo:()=>nRo,SourceConfig:()=>fRo,Subpackage:()=>XTo,UserAgent:()=>eRo});var Ivi=S.objectWithoutOptionalProperties({name:jc}).extend(TC);var gFn=S.objectWithoutOptionalProperties({default:Ivi.optional(),values:S.list(Ivi)});var K1o=S.objectWithoutOptionalProperties({header:GQ,value:gFn});var J1o=S.union("type",{header:K1o}).transform({transform:e=>{switch(e.type){case"header":return $Ii.header(e);default:return e}},untransform:({_visit:e,...t})=>t});var $1o=S.enum_(["ENUM","OBJECT","UNION","UNDISCRIMINATED_UNION"]);var Y1o=S.objectWithoutOptionalProperties({name:qj,shape:$1o});var X1o=S.enum_(["INTEGER","LONG","UINT","UINT_64","FLOAT","DOUBLE","BOOLEAN","STRING","DATE","DATE_TIME","UUID","BASE_64","BIG_INTEGER"]);var Z1o=S.objectWithoutOptionalProperties({min:S.number().optional(),max:S.number().optional(),exclusiveMin:S.boolean().optional(),exclusiveMax:S.boolean().optional(),multipleOf:S.number().optional()});var k1o=S.objectWithoutOptionalProperties({default:S.number().optional(),validation:Z1o.optional()});var eTo=S.objectWithoutOptionalProperties({default:S.number().optional()});var tTo=S.objectWithoutOptionalProperties({});var rTo=S.objectWithoutOptionalProperties({});var iTo=S.objectWithoutOptionalProperties({});var nTo=S.objectWithoutOptionalProperties({min:S.number().optional(),max:S.number().optional(),exclusiveMin:S.boolean().optional(),exclusiveMax:S.boolean().optional(),multipleOf:S.number().optional()});var aTo=S.objectWithoutOptionalProperties({default:S.number().optional(),validation:nTo.optional()});var oTo=S.objectWithoutOptionalProperties({default:S.boolean().optional()});var uTo=S.objectWithoutOptionalProperties({format:S.string().optional(),pattern:S.string().optional(),minLength:S.number().optional(),maxLength:S.number().optional()});var sTo=S.objectWithoutOptionalProperties({default:S.string().optional(),validation:uTo.optional()});var cTo=S.objectWithoutOptionalProperties({});var lTo=S.objectWithoutOptionalProperties({});var fTo=S.objectWithoutOptionalProperties({});var dTo=S.objectWithoutOptionalProperties({});var pTo=S.objectWithoutOptionalProperties({default:S.string().optional()});var _To=S.union("type",{integer:k1o,long:eTo,uint:tTo,uint64:rTo,float:iTo,double:aTo,boolean:oTo,string:sTo,date:cTo,dateTime:lTo,uuid:fTo,base64:dTo,bigInteger:pTo}).transform({transform:e=>{switch(e.type){case"integer":return bn.integer(e);case"long":return bn.long(e);case"uint":return bn.uint(e);case"uint64":return bn.uint64(e);case"float":return bn.float(e);case"double":return bn.double(e);case"boolean":return bn.boolean(e);case"string":return bn.string(e);case"date":return bn.date(e);case"dateTime":return bn.dateTime(e);case"uuid":return bn.uuid(e);case"base64":return bn.base64(e);case"bigInteger":return bn.bigInteger(e);default:return e}},untransform:({_visit:e,...t})=>t});var OFn=S.objectWithoutOptionalProperties({v1:X1o,v2:_To.optional()});var hTo=S.union(S.discriminant("type","_type"),{container:S.object({container:S.lazy(()=>AFn)}),named:Y1o,primitive:S.object({primitive:OFn}),unknown:S.object({})}).transform({transform:e=>{switch(e.type){case"container":return LQ.container(e.container);case"named":return LQ.named(e);case"primitive":return LQ.primitive(e.primitive);case"unknown":return LQ.unknown();default:return e}},untransform:({_visit:e,...t})=>t});var yTo=S.objectWithoutOptionalProperties({aliasOf:S.lazy(()=>as),resolvedType:hTo});var bTo=S.objectWithoutOptionalProperties({extends:S.list(qj),properties:S.list(yx),extendedProperties:S.list(yx).optional(),extraProperties:S.property("extra-properties",S.boolean())});var vTo=S.objectWithoutOptionalProperties({name:jc,type:S.lazy(()=>as)});var gTo=S.union(S.discriminant("propertiesType","_type"),{samePropertiesAsObject:qj,singleProperty:vTo,noProperties:S.object({})}).transform({transform:e=>{switch(e.propertiesType){case"samePropertiesAsObject":return rz.samePropertiesAsObject(e);case"singleProperty":return rz.singleProperty(e);case"noProperties":return rz.noProperties();default:return e}},untransform:({_visit:e,...t})=>t});var OTo=S.objectWithoutOptionalProperties({discriminantValue:jc,shape:gTo,displayName:S.string().optional(),availability:J6t.optional()}).extend(Nn);var ATo=S.objectWithoutOptionalProperties({discriminant:jc,extends:S.list(qj),types:S.list(OTo),baseProperties:S.list(yx)});var mTo=S.objectWithoutOptionalProperties({type:S.lazy(()=>as)}).extend(Nn);var PTo=S.objectWithoutOptionalProperties({members:S.list(mTo)});var jTo=S.union(S.discriminant("type","_type"),{alias:yTo,enum:gFn,object:bTo,union:ATo,undiscriminatedUnion:PTo}).transform({transform:e=>{switch(e.type){case"alias":return Yc.alias(e);case"enum":return Yc.enum(e);case"object":return Yc.object(e);case"union":return Yc.union(e);case"undiscriminatedUnion":return Yc.undiscriminatedUnion(e);default:return e}},untransform:({_visit:e,...t})=>t});var G0a=S.objectWithoutOptionalProperties({name:ga.optional(),shape:S.lazy(()=>mFn)}).extend($6t).extend(Nn);var wTo=S.union("type",{any:S.object({}),api:S.object({}),boolValue:S.object({}),bytesValue:S.object({}),doubleValue:S.object({}),duration:S.object({}),empty:S.object({}),enum:S.object({}),enumValue:S.object({}),field:S.object({}),fieldCardinality:S.object({}),fieldKind:S.object({}),fieldMask:S.object({}),floatValue:S.object({}),int32Value:S.object({}),int64Value:S.object({}),listValue:S.object({}),method:S.object({}),mixin:S.object({}),nullValue:S.object({}),option:S.object({}),sourceContext:S.object({}),stringValue:S.object({}),struct:S.object({}),syntax:S.object({}),timestamp:S.object({}),type:S.object({}),uint32Value:S.object({}),uint64Value:S.object({}),value:S.object({})}).transform({transform:e=>{switch(e.type){case"any":return sn.any();case"api":return sn.api();case"boolValue":return sn.boolValue();case"bytesValue":return sn.bytesValue();case"doubleValue":return sn.doubleValue();case"duration":return sn.duration();case"empty":return sn.empty();case"enum":return sn.enum();case"enumValue":return sn.enumValue();case"field":return sn.field();case"fieldCardinality":return sn.fieldCardinality();case"fieldKind":return sn.fieldKind();case"fieldMask":return sn.fieldMask();case"floatValue":return sn.floatValue();case"int32Value":return sn.int32Value();case"int64Value":return sn.int64Value();case"listValue":return sn.listValue();case"method":return sn.method();case"mixin":return sn.mixin();case"nullValue":return sn.nullValue();case"option":return sn.option();case"sourceContext":return sn.sourceContext();case"stringValue":return sn.stringValue();case"struct":return sn.struct();case"syntax":return sn.syntax();case"timestamp":return sn.timestamp();case"type":return sn.type();case"uint32Value":return sn.uint32Value();case"uint64Value":return sn.uint64Value();case"value":return sn.value();default:return e}},untransform:({_visit:e,...t})=>t});var ETo=S.objectWithoutOptionalProperties({file:yFn,name:ga});var STo=S.union("type",{wellKnown:S.object({value:wTo}),userDefined:ETo}).transform({transform:e=>{switch(e.type){case"wellKnown":return Dh.wellKnown(e.value);case"userDefined":return Dh.userDefined(e);default:return e}},untransform:({_visit:e,...t})=>t});var MTo=S.union("type",{proto:S.object({value:STo})}).transform({transform:e=>{switch(e.type){case"proto":return Dvi.proto(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var DTo=S.objectWithoutOptionalProperties({name:qj,shape:jTo,autogeneratedExamples:S.list(G0a),userProvidedExamples:S.list(G0a),v2Examples:oz.optional(),referencedTypes:S.set(WQ),encoding:vFn.optional(),source:MTo.optional(),inline:S.boolean().optional()}).extend(TC);var BTo=ga;var ITo=S.enum_(["GET","POST"]);var CTo=S.objectWithoutOptionalProperties({name:jc,valueType:S.lazy(()=>as)}).extend(tCi);var qTo=S.objectWithoutOptionalProperties({name:ga,extends:S.list(qj),properties:S.list(CTo)});var TTo=S.objectWithoutOptionalProperties({payloadType:S.lazy(()=>as)}).extend(Nn);var RTo=S.union("type",{inlinedPayload:qTo,reference:TTo}).transform({transform:e=>{switch(e.type){case"inlinedPayload":return VQ.inlinedPayload(e);case"reference":return VQ.reference(e);default:return e}},untransform:({_visit:e,...t})=>t});var zTo=S.objectWithoutOptionalProperties({name:ga.optional(),payload:S.lazyObject(()=>xl)}).extend(Nn);var NTo=S.objectWithoutOptionalProperties({id:IIo,name:BTo,displayName:S.string().optional(),method:ITo,headers:S.list(GQ),payload:RTo,responses:S.list(cCi).optional(),examples:S.list(zTo).optional(),v2Examples:pqo.optional()}).extend(TC);var FTo=S.list(NTo);var QTo=ga;var PFn=S.string();var UTo=S.enum_(["client","server"]);var LTo=S.objectWithoutOptionalProperties({name:jc,valueType:S.lazy(()=>as)}).extend(tCi);var VTo=S.objectWithoutOptionalProperties({name:ga,extends:S.list(qj),properties:S.list(LTo)});var WTo=S.objectWithoutOptionalProperties({bodyType:S.lazy(()=>as)}).extend(Nn);var xTo=S.union("type",{inlinedBody:VTo,reference:WTo}).transform({transform:e=>{switch(e.type){case"inlinedBody":return nz.inlinedBody(e);case"reference":return nz.reference(e);default:return e}},untransform:({_visit:e,...t})=>t});var GTo=S.objectWithoutOptionalProperties({type:PFn,displayName:S.string().optional(),origin:UTo,body:xTo}).extend(TC);var HTo=S.union("type",{inlinedBody:_Fn,reference:S.lazyObject(()=>xl)}).transform({transform:e=>{switch(e.type){case"inlinedBody":return yhe.inlinedBody(e);case"reference":return yhe.reference(e);default:return e}},untransform:({_visit:e,...t})=>t});var KTo=S.objectWithoutOptionalProperties({type:PFn,body:HTo});var JTo=S.objectWithoutOptionalProperties({name:ga.optional(),url:S.string(),pathParameters:S.list(lCi),headers:S.list(wKi),queryParameters:S.list(pFn),messages:S.list(KTo)}).extend(Nn);var $To=S.objectWithoutOptionalProperties({name:QTo,displayName:S.string().optional(),baseUrl:bhe.optional(),path:D0e,auth:S.boolean(),headers:S.list(GQ),queryParameters:S.list(kIi),pathParameters:S.list(iFt),messages:S.list(GTo),examples:S.list(JTo),v2Examples:dqo.optional()}).extend(TC);var YTo=S.objectWithoutOptionalProperties({pointsTo:K6t});var jFn=S.objectWithoutOptionalProperties({fernFilepath:S0e,service:H6t.optional(),types:S.list(WQ),errors:S.list(iCi),webhooks:QNn.optional(),websocket:UNn.optional(),subpackages:S.list(K6t),hasEndpointsInTree:S.boolean(),navigationConfig:YTo.optional()}).extend(Nn);var XTo=S.objectWithoutOptionalProperties({name:ga,displayName:rCi.optional()}).extend(jFn);var ZTo=S.objectWithoutOptionalProperties({discriminant:jc,contentProperty:jc});var kTo=S.union("type",{statusCode:S.object({}),property:ZTo}).transform({transform:e=>{switch(e.type){case"statusCode":return hhe.statusCode();case"property":return hhe.property(e);default:return e}},untransform:({_visit:e,...t})=>t});var eRo=S.objectWithoutOptionalProperties({header:S.stringLiteral("User-Agent"),value:S.string()});var tRo=S.objectWithoutOptionalProperties({language:S.string(),sdkName:S.string(),sdkVersion:S.string(),userAgent:eRo.optional()});var rRo=S.objectWithoutOptionalProperties({isAuthMandatory:S.boolean(),hasStreamingEndpoints:S.boolean(),hasPaginatedEndpoints:S.boolean(),hasFileDownloadEndpoints:S.boolean(),platformHeaders:tRo});var iRo=S.objectWithoutOptionalProperties({id:rFn,name:ga,type:S.lazy(()=>as)}).extend(Nn);var nRo=S.objectWithoutOptionalProperties({typesReferencedOnlyByService:S.record(H6t,S.list(WQ)),sharedTypes:S.list(WQ)});var aRo=S.objectWithoutOptionalProperties({title:S.string(),language:dFn,content:S.string()});var oRo=S.enum_(["minimal","comprehensive"]);var uRo=S.objectWithoutOptionalProperties({defaultEndpoint:Bvi.optional(),bannerLink:S.string().optional(),introduction:S.string().optional(),apiReferenceLink:S.string().optional(),apiName:S.string().optional(),disabledFeatures:S.list(L0a).optional(),whiteLabel:S.boolean().optional(),features:S.record(L0a,S.list(Bvi)).optional(),customSections:S.list(aRo).optional(),exampleStyle:oRo.optional()});var sRo=S.string();var cRo=S.objectWithoutOptionalProperties({id:sRo,protoRootUrl:S.string()});var lRo=S.union("type",{proto:cRo,openapi:S.object({})}).transform({transform:e=>{switch(e.type){case"proto":return $H.proto(e);case"openapi":return $H.openapi();default:return e}},untransform:({_visit:e,...t})=>t});var fRo=S.objectWithoutOptionalProperties({sources:S.list(lRo)});var dRo=S.objectWithoutOptionalProperties({apiKey:S.string(),workspaceId:S.string(),collectionId:S.string().optional()});var pRo=S.objectWithoutOptionalProperties({version:S.string().optional(),packageName:S.string().optional(),tokenEnvironmentVariable:S.string()});var _Ro=S.objectWithoutOptionalProperties({coordinate:S.string().optional(),version:S.string().optional(),usernameEnvironmentVariable:S.string(),passwordEnvironmentVariable:S.string(),mavenUrlEnvironmentVariable:S.string()});var hRo=S.objectWithoutOptionalProperties({version:S.string().optional(),packageName:S.string().optional()});var yRo=S.objectWithoutOptionalProperties({version:S.string().optional(),packageName:S.string().optional()});var fCi=S.union("type",{postman:dRo,npm:pRo,maven:_Ro,pypi:hRo,crates:yRo}).transform({transform:e=>{switch(e.type){case"postman":return PB.postman(e);case"npm":return PB.npm(e);case"maven":return PB.maven(e);case"pypi":return PB.pypi(e);case"crates":return PB.crates(e);default:return e}},untransform:({_visit:e,...t})=>t});var bRo=S.objectWithoutOptionalProperties({owner:S.string(),repo:S.string(),uri:S.string().optional(),token:S.string().optional(),mode:S.stringLiteral("pull-request").optional(),branch:S.string().optional(),target:fCi});var vRo=S.objectWithoutOptionalProperties({target:fCi});var gRo=S.objectWithoutOptionalProperties({generateFullProject:S.boolean(),publishTarget:fCi.optional()});var ORo=S.union("type",{github:bRo,direct:vRo,filesystem:gRo}).transform({transform:e=>{switch(e.type){case"github":return x6t.github(e);case"direct":return x6t.direct(e);case"filesystem":return x6t.filesystem(e);default:return e}},untransform:({_visit:e,...t})=>t});var ARo=S.objectWithoutOptionalProperties({cliVersion:S.string(),generatorName:S.string(),generatorVersion:S.string(),generatorConfig:S.unknown().optional()});var xo_=S.objectWithoutOptionalProperties({fdrApiDefinitionId:S.string().optional(),apiVersion:J1o.optional(),apiName:ga,apiDisplayName:S.string().optional(),apiDocs:S.string().optional(),auth:DIo,headers:S.list(GQ),idempotencyHeaders:S.list(GQ),types:S.record(WQ,DTo),services:S.record(H6t,H1o),webhookGroups:S.record(QNn,FTo),websocketChannels:S.record(UNn,$To).optional(),errors:S.record(iCi,XCo),subpackages:S.record(K6t,XTo),rootPackage:jFn,constants:CIo,environments:$Co.optional(),basePath:D0e.optional(),pathParameters:S.list(iFt),errorDiscriminationStrategy:kTo,sdkConfig:rRo,variables:S.list(iRo),serviceTypeReferenceInfo:nRo,readmeConfig:uRo.optional(),sourceConfig:fRo.optional(),publishConfig:ORo.optional(),dynamic:FCo.optional(),selfHosted:S.boolean().optional(),audiences:S.list(lIo).optional(),generationMetadata:ARo.optional(),apiPlayground:S.boolean().optional()});var Jnc={};Yt(Jnc,{CsharpProtobufFileOptions:()=>T1o,ProtobufFile:()=>yFn,ProtobufFileOptions:()=>R1o,ProtobufMethodType:()=>F1o,ProtobufService:()=>z1o,ProtobufType:()=>STo,UserDefinedProtobufType:()=>ETo,WellKnownProtobufType:()=>wTo});var $nc={};Yt($nc,{CratesPublishTarget:()=>yRo,DirectPublish:()=>vRo,Filesystem:()=>gRo,GithubPublish:()=>bRo,MavenPublishTarget:()=>_Ro,NpmPublishTarget:()=>pRo,PostmanPublishTarget:()=>dRo,PublishTarget:()=>fCi,PublishingConfig:()=>ORo,PypiPublishTarget:()=>hRo});var Ync={};Yt(Ync,{AliasTypeDeclaration:()=>yTo,Base64Type:()=>dTo,BigIntegerType:()=>pTo,BooleanType:()=>oTo,ContainerType:()=>AFn,DateTimeType:()=>lTo,DateType:()=>cTo,DeclaredTypeName:()=>qj,DoubleType:()=>aTo,DoubleValidationRules:()=>nTo,Encoding:()=>vFn,EnumTypeDeclaration:()=>gFn,EnumTypeReference:()=>Go_,EnumValue:()=>Ivi,ExampleAliasType:()=>SRo,ExampleContainer:()=>NRo,ExampleDatetime:()=>zRo,ExampleEnumType:()=>ERo,ExampleExtraObjectProperty:()=>BRo,ExampleKeyValuePair:()=>GRo,ExampleListContainer:()=>URo,ExampleLiteralContainer:()=>QRo,ExampleMapContainer:()=>xRo,ExampleNamedType:()=>FRo,ExampleNullableContainer:()=>WRo,ExampleObjectProperty:()=>EFn,ExampleObjectType:()=>wFn,ExampleObjectTypeWithTypeId:()=>TRo,ExampleOptionalContainer:()=>VRo,ExamplePrimitive:()=>SFn,ExampleSetContainer:()=>LRo,ExampleSingleUnionType:()=>CRo,ExampleSingleUnionTypeProperties:()=>qRo,ExampleType:()=>G0a,ExampleTypeReference:()=>xl,ExampleTypeReferenceShape:()=>RRo,ExampleTypeShape:()=>mFn,ExampleUndiscriminatedUnionType:()=>DRo,ExampleUnionBaseProperty:()=>IRo,ExampleUnionType:()=>MRo,FloatType:()=>iTo,IntegerType:()=>k1o,IntegerValidationRules:()=>Z1o,JsonEncoding:()=>x1o,Literal:()=>jRo,LongType:()=>eTo,MapType:()=>wRo,NamedType:()=>PRo,NamedTypeDefault:()=>mRo,ObjectProperty:()=>yx,ObjectPropertyAccess:()=>eCi,ObjectTypeDeclaration:()=>bTo,PrimitiveType:()=>OFn,PrimitiveTypeV1:()=>X1o,PrimitiveTypeV2:()=>_To,ProtoEncoding:()=>G1o,ResolvedNamedType:()=>Y1o,ResolvedTypeReference:()=>hTo,ShapeType:()=>$1o,SingleUnionType:()=>OTo,SingleUnionTypeProperties:()=>gTo,SingleUnionTypeProperty:()=>vTo,Source:()=>MTo,StringType:()=>sTo,StringValidationRules:()=>uTo,Type:()=>jTo,TypeDeclaration:()=>DTo,TypeReference:()=>as,Uint64Type:()=>rTo,UintType:()=>tTo,UndiscriminatedUnionMember:()=>mTo,UndiscriminatedUnionTypeDeclaration:()=>PTo,UnionTypeDeclaration:()=>ATo,UuidType:()=>fTo});var mRo=S.union("type",{enum:Ivi}).transform({transform:e=>{switch(e.type){case"enum":return INn.enum(e);default:return e}},untransform:({_visit:e,...t})=>t});var PRo=S.objectWithoutOptionalProperties({typeId:WQ,fernFilepath:S0e,name:ga,displayName:rCi.optional(),default:mRo.optional(),inline:S.boolean().optional()});var as=S.union(S.discriminant("type","_type"),{container:S.object({container:S.lazy(()=>AFn)}),named:PRo,primitive:S.object({primitive:OFn}),unknown:S.object({})}).transform({transform:e=>{switch(e.type){case"container":return ii.container(e.container);case"named":return ii.named(e);case"primitive":return ii.primitive(e.primitive);case"unknown":return ii.unknown();default:return e}},untransform:({_visit:e,...t})=>t});var Go_=S.objectWithoutOptionalProperties({default:Ivi.optional(),name:qj});var jRo=S.union("type",{string:S.object({string:S.string()}),boolean:S.object({boolean:S.boolean()})}).transform({transform:e=>{switch(e.type){case"string":return iz.string(e.string);case"boolean":return iz.boolean(e.boolean);default:return e}},untransform:({_visit:e,...t})=>t});var AFn=S.union(S.discriminant("type","_type"),{list:S.object({list:S.lazy(()=>as)}),map:S.lazyObject(()=>wRo),nullable:S.object({nullable:S.lazy(()=>as)}),optional:S.object({optional:S.lazy(()=>as)}),set:S.object({set:S.lazy(()=>as)}),literal:S.object({literal:jRo})}).transform({transform:e=>{switch(e.type){case"list":return ns.list(e.list);case"map":return ns.map(e);case"nullable":return ns.nullable(e.nullable);case"optional":return ns.optional(e.optional);case"set":return ns.set(e.set);case"literal":return ns.literal(e.literal);default:return e}},untransform:({_visit:e,...t})=>t});var wRo=S.objectWithoutOptionalProperties({keyType:S.lazy(()=>as),valueType:S.lazy(()=>as)});var ERo=S.objectWithoutOptionalProperties({value:jc});var mFn=S.union("type",{alias:S.lazyObject(()=>SRo),enum:ERo,object:S.lazyObject(()=>wFn),union:S.lazyObject(()=>MRo),undiscriminatedUnion:S.lazyObject(()=>DRo)}).transform({transform:e=>{switch(e.type){case"alias":return Bh.alias(e);case"enum":return Bh.enum(e);case"object":return Bh.object(e);case"union":return Bh.union(e);case"undiscriminatedUnion":return Bh.undiscriminatedUnion(e);default:return e}},untransform:({_visit:e,...t})=>t});var SRo=S.objectWithoutOptionalProperties({value:S.lazyObject(()=>xl)});var wFn=S.objectWithoutOptionalProperties({properties:S.list(S.lazyObject(()=>EFn)),extraProperties:S.list(S.lazyObject(()=>BRo)).optional()});var EFn=S.objectWithoutOptionalProperties({name:jc,value:S.lazyObject(()=>xl),propertyAccess:eCi.optional(),originalTypeDeclaration:qj});var BRo=S.objectWithoutOptionalProperties({name:jc,value:S.lazyObject(()=>xl)});var MRo=S.objectWithoutOptionalProperties({discriminant:jc,singleUnionType:S.lazyObject(()=>CRo),extendProperties:S.list(S.lazyObject(()=>EFn)).optional(),baseProperties:S.list(S.lazyObject(()=>IRo)).optional()});var IRo=S.objectWithoutOptionalProperties({name:jc,value:S.lazyObject(()=>xl)});var DRo=S.objectWithoutOptionalProperties({index:S.number(),singleUnionType:S.lazyObject(()=>xl)});var CRo=S.objectWithoutOptionalProperties({wireDiscriminantValue:jc,shape:S.lazy(()=>qRo)});var qRo=S.union("type",{samePropertiesAsObject:S.lazyObject(()=>TRo),singleProperty:S.lazyObject(()=>xl),noProperties:S.object({})}).transform({transform:e=>{switch(e.type){case"samePropertiesAsObject":return jB.samePropertiesAsObject(e);case"singleProperty":return jB.singleProperty(e);case"noProperties":return jB.noProperties();default:return e}},untransform:({_visit:e,...t})=>t});var xl=S.objectWithoutOptionalProperties({shape:S.lazy(()=>RRo)}).extend($6t);var zRo=S.objectWithoutOptionalProperties({datetime:S.date(),raw:S.string().optional()});var SFn=S.union("type",{integer:S.object({integer:S.number()}),long:S.object({long:S.number()}),uint:S.object({uint:S.number()}),uint64:S.object({uint64:S.number()}),float:S.object({float:S.number()}),double:S.object({double:S.number()}),boolean:S.object({boolean:S.boolean()}),string:S.object({string:BIo}),date:S.object({date:S.string()}),datetime:zRo,uuid:S.object({uuid:S.string()}),base64:S.object({base64:S.string()}),bigInteger:S.object({bigInteger:S.string()})}).transform({transform:e=>{switch(e.type){case"integer":return Sn.integer(e.integer);case"long":return Sn.long(e.long);case"uint":return Sn.uint(e.uint);case"uint64":return Sn.uint64(e.uint64);case"float":return Sn.float(e.float);case"double":return Sn.double(e.double);case"boolean":return Sn.boolean(e.boolean);case"string":return Sn.string(e.string);case"date":return Sn.date(e.date);case"datetime":return Sn.datetime(e);case"uuid":return Sn.uuid(e.uuid);case"base64":return Sn.base64(e.base64);case"bigInteger":return Sn.bigInteger(e.bigInteger);default:return e}},untransform:({_visit:e,...t})=>t});var RRo=S.union("type",{primitive:S.object({primitive:SFn}),container:S.object({container:S.lazy(()=>NRo)}),unknown:S.object({unknown:S.unknown()}),named:S.lazyObject(()=>FRo)}).transform({transform:e=>{switch(e.type){case"primitive":return lu.primitive(e.primitive);case"container":return lu.container(e.container);case"unknown":return lu.unknown(e.unknown);case"named":return lu.named(e);default:return e}},untransform:({_visit:e,...t})=>t});var QRo=S.objectWithoutOptionalProperties({literal:SFn});var NRo=S.union("type",{list:S.lazyObject(()=>URo),set:S.lazyObject(()=>LRo),optional:S.lazyObject(()=>VRo),nullable:S.lazyObject(()=>WRo),map:S.lazyObject(()=>xRo),literal:QRo}).transform({transform:e=>{switch(e.type){case"list":return op.list(e);case"set":return op.set(e);case"optional":return op.optional(e);case"nullable":return op.nullable(e);case"map":return op.map(e);case"literal":return op.literal(e);default:return e}},untransform:({_visit:e,...t})=>t});var URo=S.objectWithoutOptionalProperties({list:S.list(S.lazyObject(()=>xl)),itemType:S.lazy(()=>as)});var LRo=S.objectWithoutOptionalProperties({set:S.list(S.lazyObject(()=>xl)),itemType:S.lazy(()=>as)});var VRo=S.objectWithoutOptionalProperties({optional:S.lazyObject(()=>xl).optional(),valueType:S.lazy(()=>as)});var WRo=S.objectWithoutOptionalProperties({nullable:S.lazyObject(()=>xl).optional(),valueType:S.lazy(()=>as)});var xRo=S.objectWithoutOptionalProperties({map:S.list(S.lazyObject(()=>GRo)),keyType:S.lazy(()=>as),valueType:S.lazy(()=>as)});var GRo=S.objectWithoutOptionalProperties({key:S.lazyObject(()=>xl),value:S.lazyObject(()=>xl)});var FRo=S.objectWithoutOptionalProperties({typeName:qj,shape:S.lazy(()=>mFn)});var TRo=S.objectWithoutOptionalProperties({typeId:WQ,object:S.lazyObject(()=>wFn)});var Xnc={};Yt(Xnc,{VariableDeclaration:()=>iRo,VariableId:()=>rFn});var Znc={};Yt(Znc,{ExampleWebhookCall:()=>zTo,InlinedWebhookPayload:()=>qTo,InlinedWebhookPayloadProperty:()=>CTo,Webhook:()=>NTo,WebhookGroup:()=>FTo,WebhookHttpMethod:()=>ITo,WebhookName:()=>BTo,WebhookPayload:()=>RTo,WebhookPayloadReference:()=>TTo});var knc={};Yt(knc,{ExampleWebSocketMessage:()=>KTo,ExampleWebSocketMessageBody:()=>HTo,ExampleWebSocketSession:()=>JTo,InlinedWebSocketMessageBody:()=>VTo,InlinedWebSocketMessageBodyProperty:()=>LTo,WebSocketChannel:()=>$To,WebSocketMessage:()=>GTo,WebSocketMessageBody:()=>xTo,WebSocketMessageBodyReference:()=>WTo,WebSocketMessageId:()=>PFn,WebSocketMessageOrigin:()=>UTo,WebSocketName:()=>QTo});var AD={};Yt(AD,{AvailabilityStatusSchema:()=>Ko_,FernDefinitionError:()=>$0a,FernDefinitionTimeoutError:()=>Y0a,FormDataBodyEncodingStyle:()=>iu_,HttpMethodSchema:()=>ru_,ObjectPropertyAccess:()=>ou_,StreamFormat:()=>nu_,SupportedSdkLanguageSchema:()=>Zo_,WebSocketOrigin:()=>fu_,WebhookMethodSchema:()=>lu_,auth:()=>Ho_,availability:()=>tac,commons:()=>Jo_,encoding:()=>$o_,environments:()=>Yo_,errors:()=>Xo_,examples:()=>rac,file:()=>ko_,pagination:()=>eu_,products:()=>tu_,serialization:()=>Dac,service:()=>iac,source:()=>au_,types:()=>nac,validation:()=>uu_,variables:()=>su_,versioning:()=>cu_,webhooks:()=>aac,websocket:()=>oac});var Ho_={};var tac={};Yt(tac,{AvailabilityStatusSchema:()=>Ko_});var Ko_={InDevelopment:"in-development",PreRelease:"pre-release",Deprecated:"deprecated",GenerallyAvailable:"generally-available"};var Jo_={};var $o_={};var Yo_={};var Xo_={};var rac={};Yt(rac,{SupportedSdkLanguageSchema:()=>Zo_});var Zo_={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",Csharp2:"c#"};var ko_={};var eu_={};var tu_={};var iac={};Yt(iac,{FormDataBodyEncodingStyle:()=>iu_,HttpMethodSchema:()=>ru_,StreamFormat:()=>nu_});var ru_={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD"};var iu_={Json:"json",Exploded:"exploded",Form:"form"};var nu_={Sse:"sse",Json:"json"};var au_={};var nac={};Yt(nac,{ObjectPropertyAccess:()=>ou_});var ou_={ReadOnly:"read-only",WriteOnly:"write-only"};var uu_={};var su_={};var cu_={};var aac={};Yt(aac,{WebhookMethodSchema:()=>lu_});var lu_={Post:"POST",Get:"GET"};var oac={};Yt(oac,{WebSocketOrigin:()=>fu_});var fu_={Client:"client",Server:"server"};var Dac={};Yt(Dac,{AliasSchema:()=>uNo,AnyAuthItem:()=>YRo,AnyAuthSchemesSchema:()=>XRo,ApiAuthSchema:()=>ZRo,AuthSchemeDeclarationSchema:()=>_zo,AuthSchemeKey:()=>IFn,AuthSchemeReferenceSchema:()=>qFn,AuthScope:()=>CFn,AuthVariable:()=>SKi,AvailabilitySchema:()=>yzo,AvailabilityStatusSchema:()=>RFn,AvailabilityUnionSchema:()=>bzo,BaseTypeDeclarationSchema:()=>C0e,BaseTypeReferenceSchema:()=>QFn,BasicAuthSchemeSchema:()=>uzo,BearerAuthSchemeSchema:()=>pzo,CasingOverridesSchema:()=>Hzo,CursorPaginationSchema:()=>CNo,CustomPaginationSchema:()=>TNo,DeclarationSchema:()=>k6t,DeclarationWithNameSchema:()=>Qu_,DeclarationWithoutDocsSchema:()=>Azo,DefinitionFileSchema:()=>XNo,DiscriminatedUnionSchema:()=>iNo,EncodingSchema:()=>zFn,EnumSchema:()=>$zo,EnumValue:()=>Jzo,EnumValueSchema:()=>Kzo,EnvironmentSchema:()=>wzo,ErrorDeclarationSchema:()=>Mzo,ErrorDiscriminationSchema:()=>nFo,ExampleBodyResponseSchema:()=>Izo,ExampleCodeSampleSchema:()=>Qzo,ExampleCodeSampleSchemaLanguage:()=>Fzo,ExampleCodeSampleSchemaSdk:()=>Nzo,ExampleEndpointCallArraySchema:()=>Uu_,ExampleEndpointCallSchema:()=>FFn,ExampleResponseSchema:()=>Rzo,ExampleSseEventSchema:()=>qzo,ExampleSseResponseSchema:()=>Tzo,ExampleStreamResponseSchema:()=>Czo,ExampleTypeReferenceSchema:()=>D1,ExampleTypeSchema:()=>NFn,ExampleTypeValueSchema:()=>Szo,ExampleWebSocketMessage:()=>Dzo,ExampleWebSocketSession:()=>Bzo,ExampleWebhookCallSchema:()=>Uzo,Export:()=>eFo,ExportDetailed:()=>kNo,FormDataBodyEncodingStyle:()=>gNo,GrpcTransport:()=>cNo,HeaderAuthSchemeSchema:()=>ozo,HttpEndpointAuth:()=>_No,HttpEndpointSchema:()=>FNo,HttpEndpointSecurity:()=>pNo,HttpEndpointSecurityItem:()=>dNo,HttpHeaderSchema:()=>q0e,HttpInlineFileRequestBodyPropertySchema:()=>ONo,HttpInlineRequestBodyPropertySchema:()=>ANo,HttpInlineRequestBodySchema:()=>mNo,HttpMethodSchema:()=>lNo,HttpPathParameterSchema:()=>e9t,HttpQueryParameterSchema:()=>LFn,HttpReferencedRequestBodySchema:()=>vNo,HttpRequest:()=>wNo,HttpRequestBodySchema:()=>PNo,HttpRequestSchema:()=>jNo,HttpResponseSchema:()=>VFn,HttpResponseSchemaDetailed:()=>ENo,HttpResponseStreamSchema:()=>WFn,HttpResponseStreamSchemaDetailed:()=>MNo,HttpServiceSchema:()=>QNo,InferredAuthenticatedRequestHeader:()=>czo,InferredBearerAuthSchema:()=>dzo,InferredGetTokenEndpointSchema:()=>fzo,InferredGetTokenEndpointSchemaObject:()=>lzo,MultipleBaseUrlsEnvironmentSchema:()=>jzo,Navigation:()=>ZNo,NumberValidationSchema:()=>gzo,OAuthAccessTokenRequestPropertiesSchema:()=>kRo,OAuthAccessTokenResponsePropertiesSchema:()=>ezo,OAuthGetTokenEndpointSchema:()=>tzo,OAuthRefreshTokenEndpointSchema:()=>nzo,OAuthRefreshTokenRequestPropertiesSchema:()=>rzo,OAuthRefreshTokenResponsePropertiesSchema:()=>izo,OAuthSchemeSchema:()=>azo,ObjectExtendsSchema:()=>B0e,ObjectPropertyAccess:()=>Lzo,ObjectPropertySchema:()=>hCi,ObjectPropertyWithAccessSchema:()=>Vzo,ObjectSchema:()=>Gzo,OffsetPaginationSchema:()=>qNo,OpenApiSourceSchema:()=>Wzo,PackageMarkerFileSchema:()=>Lu_,Pagination:()=>RNo,PaginationSchema:()=>xFn,ProductDeclarationHeaderObjectSchema:()=>pFo,ProductDeclarationHeaderSchema:()=>_Fo,ProductDeclarationSchema:()=>hFo,ProductValue:()=>dFo,ProductValueDetailed:()=>fFo,PropertyBasedErrorDiscrimination:()=>rFo,ProtobufSourceSchema:()=>xzo,ProtobufTypeSchema:()=>mzo,QueryParameterTypeReferenceDetailed:()=>hNo,ResponseError:()=>BNo,ResponseErrorWithDocsSchema:()=>DNo,ResponseErrorsSchema:()=>INo,RetriesConfiguration:()=>NNo,RetriesDisabledSchema:()=>zNo,RootApiFileSchema:()=>Vu_,ServiceTransport:()=>UFn,SingleBaseUrlEnvironmentSchema:()=>Pzo,SingleUndiscriminatedUnionTypeDetailedSchema:()=>nNo,SingleUndiscriminatedUnionTypeSchema:()=>aNo,SingleUnionTypeDetailedSchema:()=>tNo,SingleUnionTypeKey:()=>eNo,SingleUnionTypeKeySchema:()=>kzo,SingleUnionTypeSchema:()=>rNo,SourceSchema:()=>yCi,StatusCodeBasedErrorDiscrimination:()=>iFo,StreamFormat:()=>SNo,StringValidationSchema:()=>vzo,SupportedSdkLanguageSchema:()=>zzo,TokenBearerAuthSchema:()=>szo,TypeDeclarationSchema:()=>sNo,TypeReferenceDeclarationWithEnvOverride:()=>bNo,TypeReferenceDeclarationWithEnvOverrideSchema:()=>yNo,TypeReferenceDeclarationWithName:()=>I0e,TypeReferenceDeclarationWithNameSchema:()=>Wu_,TypeReferenceDetailedSchema:()=>Zzo,TypeReferenceSchema:()=>Cvi,UndiscriminatedUnionSchema:()=>oNo,UnionDiscriminant:()=>Xzo,UnionDiscriminantSchema:()=>Yzo,ValidationSchema:()=>_Ci,VariableDeclarationDetailed:()=>aFo,VariableDeclarationSchema:()=>oFo,VariableReferenceSchema:()=>fNo,VersionDeclarationHeaderObjectSchema:()=>cFo,VersionDeclarationHeaderSchema:()=>lFo,VersionDeclarationSchema:()=>GFn,VersionValue:()=>sFo,VersionValueDetailed:()=>uFo,WebSocketChannelInlinedMessageSchema:()=>KNo,WebSocketChannelMessageBodySchema:()=>JNo,WebSocketChannelMessageSchema:()=>$No,WebSocketChannelReferencedMessageSchema:()=>HNo,WebSocketChannelSchema:()=>YNo,WebSocketOrigin:()=>GNo,WebhookInlinedPayloadSchema:()=>VNo,WebhookMethodSchema:()=>UNo,WebhookPayloadSchema:()=>WNo,WebhookReferencedPayloadSchema:()=>LNo,WebhookSchema:()=>xNo,WithAudiences:()=>lz,WithAuthSchema:()=>hzo,WithAvailability:()=>Q3,WithDisplayName:()=>cz,WithDocsSchema:()=>Na,WithEnvironmentVariable:()=>TFn,WithEnvironmentsSchema:()=>Ezo,WithHeadersSchema:()=>tFo,WithName:()=>fb,WithValidation:()=>Ozo,auth:()=>fac,availability:()=>dac,commons:()=>pac,encoding:()=>_ac,environments:()=>hac,errors:()=>yac,examples:()=>bac,file:()=>vac,pagination:()=>gac,products:()=>Oac,service:()=>Aac,source:()=>mac,types:()=>Pac,validation:()=>jac,variables:()=>wac,versioning:()=>Eac,webhooks:()=>Sac,websocket:()=>Mac});var fac={};Yt(fac,{AnyAuthItem:()=>YRo,AnyAuthSchemesSchema:()=>XRo,ApiAuthSchema:()=>ZRo,AuthSchemeDeclarationSchema:()=>_zo,AuthSchemeKey:()=>IFn,AuthSchemeReferenceSchema:()=>qFn,AuthScope:()=>CFn,AuthVariable:()=>SKi,BasicAuthSchemeSchema:()=>uzo,BearerAuthSchemeSchema:()=>pzo,HeaderAuthSchemeSchema:()=>ozo,InferredAuthenticatedRequestHeader:()=>czo,InferredBearerAuthSchema:()=>dzo,InferredGetTokenEndpointSchema:()=>fzo,InferredGetTokenEndpointSchemaObject:()=>lzo,OAuthAccessTokenRequestPropertiesSchema:()=>kRo,OAuthAccessTokenResponsePropertiesSchema:()=>ezo,OAuthGetTokenEndpointSchema:()=>tzo,OAuthRefreshTokenEndpointSchema:()=>nzo,OAuthRefreshTokenRequestPropertiesSchema:()=>rzo,OAuthRefreshTokenResponsePropertiesSchema:()=>izo,OAuthSchemeSchema:()=>azo,TokenBearerAuthSchema:()=>szo,WithAuthSchema:()=>hzo,WithEnvironmentVariable:()=>TFn});var ie={};Yt(ie,{JsonError:()=>MFn,ParseError:()=>DFn,any:()=>Eu_,bigint:()=>pu_,boolean:()=>Su_,booleanLiteral:()=>wu_,date:()=>_u_,discriminant:()=>zu_,enum_:()=>KRo,getObjectLikeUtils:()=>nFt,getObjectUtils:()=>EKi,getSchemaUtils:()=>Jm,isProperty:()=>pCi,lazy:()=>hu_,lazyObject:()=>mu_,list:()=>$Ro,number:()=>Mu_,object:()=>JRo,objectWithoutOptionalProperties:()=>Au_,optional:()=>uac,property:()=>bu_,record:()=>Cu_,set:()=>qu_,string:()=>Du_,stringLiteral:()=>ju_,transform:()=>sac,undiscriminatedUnion:()=>Ru_,union:()=>Fu_,unknown:()=>Bu_,withParsedProperties:()=>lac});var ih={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 SA(e,t){return`Expected ${t}. Received ${FJS(e)}.`}function FJS(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 sz(e){return{...e,json:du_(e.json),parse:du_(e.parse)}}function du_(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(`
1351
1351
  `)),{ok:!0,value:t}):i}}function HRo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var MFn=class e extends Error{errors;constructor(t){super(t.map(HRo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var DFn=class e extends Error{errors;constructor(t){super(t.map(HRo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Jm(e){return{optional:()=>uac(e),transform:t=>sac(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new DFn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new MFn(i.errors)}}}function uac(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:()=>ih.OPTIONAL};return{...t,...Jm(t)}}function sac(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,...Jm(r)}}function pu_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:SA(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:SA(t,"bigint")}]},getType:()=>ih.BIGINT};return{...sz(e),...Jm(e)}}var QJS=/^([+-]?\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 _u_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:SA(t,"string")}]}:QJS.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:SA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:SA(t,"Date object")}]},getType:()=>ih.DATE};return{...sz(e),...Jm(e)}}function F3(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...sz(r),...Jm(r)}}}function KRo(e){let t=new Set(e);return F3(ih.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:SA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:SA(i,"enum")}]}:{ok:!0,value:i})()}function hu_(e){let t=cac(e);return{...t,...Jm(t)}}function cac(e){return{parse:(t,r)=>BFn(e).parse(t,r),json:(t,r)=>BFn(e).json(t,r),getType:()=>BFn(e).getType()}}function BFn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function H0a(e){return Object.entries(e)}function K0a(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function dCi(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 J0a(e){return Object.keys(e)}function yu_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function nFt(e){return{withParsedProperties:t=>lac(e,t)}}function lac(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(!dCi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:SA(i,"object")}]};let a=new Set(Object.keys(t)),o=K0a(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...Jm(r),...nFt(r)}}function bu_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function pCi(e){return e.isProperty}function JRo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>pCi(i)?i.rawKey:r),_getParsedProperties:()=>J0a(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of H0a(e)){let f=pCi(c)?c.rawKey:o,s=pCi(c)?c.valueSchema:c,u={rawKey:f,parsedKey:o,valueSchema:s};n[f]=u,Ou_(s)&&a.push(f)}return vu_({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 H0a(e)){let c=pCi(o)?o.valueSchema:o;Ou_(c)&&n.push(a)}return vu_({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return pCi(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:()=>ih.OBJECT};return{...sz(t),...Jm(t),...nFt(t),...EKi(t)}}function vu_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!dCi(e))return{ok:!1,errors:[{path:a,message:SA(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 EKi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>gu_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>gu_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>ih.OBJECT};return{...r,...Jm(r),...nFt(r),...EKi(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:()=>ih.OBJECT};return{...t,...Jm(t),...nFt(t),...EKi(t)}}}}function gu_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=yu_(J0a(t),s=>n.has(s)),c=r(K0a(t,o)),f=i(K0a(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 Ou_(e){return!UJS(e)}function UJS(e){switch(e.getType()){case ih.ANY:case ih.UNKNOWN:case ih.OPTIONAL:return!0;default:return!1}}function Au_(e){return JRo(e)}function mu_(e){let t={...cac(e),_getRawProperties:()=>BFn(e)._getRawProperties(),_getParsedProperties:()=>BFn(e)._getParsedProperties()};return{...t,...Jm(t),...nFt(t),...EKi(t)}}function $Ro(e){let t={parse:(r,i)=>Pu_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Pu_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>ih.LIST};return{...sz(t),...Jm(t)}}function Pu_(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:SA(e,"list"),path:[]}]}}function ju_(e){return F3(ih.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:SA(r,`"${e}"`)}]})()}function wu_(e){return F3(ih.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:SA(r,`${e.toString()}`)}]})()}var Eu_=F3(ih.ANY,e=>({ok:!0,value:e}));var Su_=F3(ih.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:SA(e,"boolean")}]});var Mu_=F3(ih.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:SA(e,"number")}]});var Du_=F3(ih.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:SA(e,"string")}]});var Bu_=F3(ih.UNKNOWN,e=>({ok:!0,value:e}));function Cu_(e,t){let r={parse:(i,n)=>Iu_({value:i,isKeyNumeric:e.getType()===ih.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)=>Iu_({value:i,isKeyNumeric:e.getType()===ih.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:()=>ih.RECORD};return{...sz(r),...Jm(r)}}function Iu_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return dCi(e)?H0a(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:SA(e,"object")}]}}function qu_(e){let t=$Ro(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:SA(i,"Set")}]},getType:()=>ih.SET};return{...sz(r),...Jm(r)}}function Ru_(e){let t={parse:(r,i)=>Tu_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>Tu_((n,a)=>n.json(r,a),e,i),getType:()=>ih.UNDISCRIMINATED_UNION};return{...sz(t),...Jm(t)}}function Tu_(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 zu_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Fu_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=KRo(J0a(t)),a={parse:(o,c)=>Nu_({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)=>Nu_({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:()=>ih.UNION};return{...sz(a),...Jm(a),...nFt(a)}}function Nu_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!dCi(e))return{ok:!1,errors:[{path:c,message:SA(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 IFn=ie.string();var CFn=ie.string();var Na=ie.object({docs:ie.string().optional()});var qFn=ie.object({scheme:ie.string()}).extend(Na);var YRo=ie.undiscriminatedUnion([ie.string(),qFn]);var XRo=ie.object({any:ie.list(YRo)}).extend(Na);var ZRo=ie.undiscriminatedUnion([ie.string(),qFn,XRo]);var kRo=ie.object({"client-id":ie.string().optional(),"client-secret":ie.string().optional(),scopes:ie.string().optional()});var ezo=ie.object({"access-token":ie.string().optional(),"expires-in":ie.string().optional(),"refresh-token":ie.string().optional()});var tzo=ie.object({endpoint:ie.string(),"request-properties":kRo.optional(),"response-properties":ezo.optional()});var rzo=ie.object({"refresh-token":ie.string()});var izo=ie.object({"access-token":ie.string().optional(),"expires-in":ie.string().optional(),"refresh-token":ie.string().optional()});var nzo=ie.object({endpoint:ie.string(),"request-properties":rzo.optional(),"response-properties":izo.optional()});var azo=ie.object({scheme:ie.stringLiteral("oauth"),type:ie.stringLiteral("client-credentials"),scopes:ie.list(CFn).optional(),"client-id-env":ie.string().optional(),"client-secret-env":ie.string().optional(),"token-prefix":ie.string().optional(),"token-header":ie.string().optional(),"get-token":tzo,"refresh-token":nzo.optional()}).extend(Na);var TFn=ie.object({env:ie.string().optional()});var fb=ie.object({name:ie.string().optional()});var ozo=ie.object({header:ie.string(),type:ie.string().optional(),prefix:ie.string().optional()}).extend(TFn).extend(fb).extend(Na);var SKi=ie.object({}).extend(TFn).extend(fb);var uzo=ie.object({scheme:ie.stringLiteral("basic"),username:SKi.optional(),password:SKi.optional()}).extend(Na);var szo=ie.object({scheme:ie.stringLiteral("bearer"),token:SKi.optional()}).extend(Na);var czo=ie.object({"response-property":ie.string(),"header-name":ie.string(),"value-prefix":ie.string().optional()});var lzo=ie.object({endpoint:ie.string(),"expiry-response-property":ie.string().optional(),"authenticated-request-headers":ie.list(czo).optional()});var fzo=ie.undiscriminatedUnion([ie.string(),lzo]);var dzo=ie.object({scheme:ie.stringLiteral("bearer"),"get-token":fzo}).extend(Na);var pzo=ie.undiscriminatedUnion([szo,dzo]);var _zo=ie.undiscriminatedUnion([azo,ozo,uzo,pzo]);var hzo=ie.object({auth:ZRo.optional(),"auth-schemes":ie.record(IFn,_zo).optional()});var dac={};Yt(dac,{AvailabilitySchema:()=>yzo,AvailabilityStatusSchema:()=>RFn,AvailabilityUnionSchema:()=>bzo});var RFn=ie.enum_(["in-development","pre-release","deprecated","generally-available"]);var yzo=ie.object({status:RFn,message:ie.string().optional()});var bzo=ie.undiscriminatedUnion([RFn,yzo]);var pac={};Yt(pac,{DeclarationSchema:()=>k6t,DeclarationWithNameSchema:()=>Qu_,DeclarationWithoutDocsSchema:()=>Azo,WithAudiences:()=>lz,WithAvailability:()=>Q3,WithDisplayName:()=>cz,WithDocsSchema:()=>Na,WithName:()=>fb,WithValidation:()=>Ozo});var Q3=ie.object({availability:bzo.optional()});var cz=ie.object({"display-name":ie.string().optional()});var vzo=ie.object({minLength:ie.number().optional(),maxLength:ie.number().optional(),pattern:ie.string().optional(),format:ie.string().optional()});var gzo=ie.object({min:ie.number().optional(),max:ie.number().optional(),exclusiveMin:ie.boolean().optional(),exclusiveMax:ie.boolean().optional(),multipleOf:ie.number().optional()});var _Ci=ie.undiscriminatedUnion([vzo,gzo]);var Ozo=ie.object({validation:_Ci.optional()});var lz=ie.object({audiences:ie.list(ie.string()).optional()});var k6t=ie.object({}).extend(Na).extend(Q3).extend(lz);var Azo=ie.object({}).extend(Q3).extend(lz);var Qu_=ie.object({}).extend(k6t).extend(fb);var _ac={};Yt(_ac,{EncodingSchema:()=>zFn,ProtobufTypeSchema:()=>mzo});var mzo=ie.object({type:ie.string()});var zFn=ie.object({proto:mzo.optional()});var hac={};Yt(hac,{EnvironmentSchema:()=>wzo,MultipleBaseUrlsEnvironmentSchema:()=>jzo,SingleBaseUrlEnvironmentSchema:()=>Pzo,WithEnvironmentsSchema:()=>Ezo});var Pzo=ie.object({url:ie.string()}).extend(lz).extend(Na);var jzo=ie.object({urls:ie.record(ie.string(),ie.string())}).extend(lz).extend(Na);var wzo=ie.undiscriminatedUnion([ie.string(),Pzo,jzo]);var Ezo=ie.object({"default-url":ie.string().optional(),"default-environment":ie.string().optional(),environments:ie.record(ie.string(),wzo).optional()});var yac={};Yt(yac,{ErrorDeclarationSchema:()=>Mzo});var Szo=ie.unknown();var NFn=ie.object({value:Szo}).extend(fb).extend(Na);var Mzo=ie.object({"status-code":ie.number(),type:ie.string().optional(),examples:ie.list(NFn).optional()}).extend(Na);var bac={};Yt(bac,{ExampleBodyResponseSchema:()=>Izo,ExampleCodeSampleSchema:()=>Qzo,ExampleCodeSampleSchemaLanguage:()=>Fzo,ExampleCodeSampleSchemaSdk:()=>Nzo,ExampleEndpointCallArraySchema:()=>Uu_,ExampleEndpointCallSchema:()=>FFn,ExampleResponseSchema:()=>Rzo,ExampleSseEventSchema:()=>qzo,ExampleSseResponseSchema:()=>Tzo,ExampleStreamResponseSchema:()=>Czo,ExampleTypeReferenceSchema:()=>D1,ExampleTypeSchema:()=>NFn,ExampleTypeValueSchema:()=>Szo,ExampleWebSocketMessage:()=>Dzo,ExampleWebSocketSession:()=>Bzo,ExampleWebhookCallSchema:()=>Uzo,SupportedSdkLanguageSchema:()=>zzo});var D1=ie.unknown();var Dzo=ie.object({type:ie.string(),body:ie.unknown()});var Bzo=ie.object({"path-parameters":ie.record(ie.string(),D1).optional(),"query-parameters":ie.record(ie.string(),D1).optional(),headers:ie.record(ie.string(),D1).optional(),messages:ie.list(Dzo)}).extend(fb).extend(Na);var Izo=ie.object({error:ie.string().optional(),body:D1.optional()});var Czo=ie.object({stream:ie.list(D1)});var qzo=ie.object({event:ie.string(),data:D1.optional()});var Tzo=ie.object({stream:ie.list(qzo)});var Rzo=ie.undiscriminatedUnion([Izo,Czo,Tzo]);var zzo=ie.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]);var Nzo=ie.object({sdk:zzo,code:ie.string()}).extend(Na).extend(fb);var Fzo=ie.object({language:ie.string(),code:ie.string(),install:ie.string().optional()}).extend(Na).extend(fb);var Qzo=ie.undiscriminatedUnion([Nzo,Fzo]);var FFn=ie.object({id:ie.string().optional(),"path-parameters":ie.record(ie.string(),D1).optional(),"query-parameters":ie.record(ie.string(),D1).optional(),headers:ie.record(ie.string(),D1).optional(),request:D1.optional(),response:Rzo.optional(),"code-samples":ie.list(Qzo).optional()}).extend(fb).extend(Na);var Uu_=ie.list(FFn);var Uzo=ie.object({id:ie.string().optional(),payload:D1}).extend(fb).extend(Na);var vac={};Yt(vac,{DefinitionFileSchema:()=>XNo,ErrorDiscriminationSchema:()=>nFo,Export:()=>eFo,ExportDetailed:()=>kNo,Navigation:()=>ZNo,PackageMarkerFileSchema:()=>Lu_,PropertyBasedErrorDiscrimination:()=>rFo,RootApiFileSchema:()=>Vu_,StatusCodeBasedErrorDiscrimination:()=>iFo,WithHeadersSchema:()=>tFo});var B0e=ie.undiscriminatedUnion([ie.string(),ie.list(ie.string())]);var Lzo=ie.enum_(["read-only","write-only"]);var QFn=ie.object({default:ie.unknown().optional(),encoding:zFn.optional(),validation:_Ci.optional()}).extend(Na).extend(Q3);var I0e=ie.object({type:ie.string()}).extend(QFn).extend(fb).extend(lz);var Vzo=ie.object({access:Lzo.optional()}).extend(I0e);var hCi=ie.undiscriminatedUnion([ie.string(),Vzo]);var Wzo=ie.object({openapi:ie.string()});var xzo=ie.object({proto:ie.string()});var yCi=ie.undiscriminatedUnion([Wzo,xzo]);var C0e=ie.object({examples:ie.list(NFn).optional(),encoding:zFn.optional(),source:yCi.optional(),inline:ie.boolean().optional()}).extend(Na).extend(Q3).extend(lz);var Gzo=ie.object({extends:B0e.optional(),properties:ie.record(ie.string(),hCi).optional(),"extra-properties":ie.boolean().optional()}).extend(C0e);var Hzo=ie.object({camel:ie.string().optional(),snake:ie.string().optional(),pascal:ie.string().optional(),"screaming-snake":ie.string().optional()});var Kzo=ie.object({value:ie.string(),casing:Hzo.optional()}).extend(Na).extend(fb);var Jzo=ie.undiscriminatedUnion([ie.string(),Kzo]);var $zo=ie.object({default:ie.string().optional(),enum:ie.list(Jzo)}).extend(C0e);var Yzo=ie.object({value:ie.string()}).extend(fb);var Xzo=ie.undiscriminatedUnion([ie.string(),Yzo]);var Zzo=ie.object({type:ie.string()}).extend(QFn).extend(fb).extend(lz);var Cvi=ie.undiscriminatedUnion([ie.string(),Zzo]);var kzo=ie.object({value:ie.string()}).extend(fb);var eNo=ie.undiscriminatedUnion([ie.string(),kzo]);var tNo=ie.object({type:ie.string().optional(),key:eNo.optional()}).extend(Na).extend(fb).extend(Q3).extend(cz);var rNo=ie.undiscriminatedUnion([ie.string(),tNo]);var iNo=ie.object({discriminant:Xzo.optional(),extends:B0e.optional(),"base-properties":ie.record(ie.string(),Cvi).optional(),union:ie.record(ie.string(),rNo)}).extend(C0e);var nNo=ie.object({type:ie.string()}).extend(Na).extend(cz).extend(Ozo);var aNo=ie.undiscriminatedUnion([ie.string(),nNo]);var oNo=ie.object({discriminated:ie.booleanLiteral(!1),union:ie.list(aNo)}).extend(C0e);var uNo=ie.object({type:ie.string(),validation:_Ci.optional()}).extend(C0e);var sNo=ie.undiscriminatedUnion([ie.string(),Gzo,$zo,iNo,oNo,uNo]);var cNo=ie.object({"service-name":ie.string()});var UFn=ie.object({grpc:cNo.optional()});var lNo=ie.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD"]);var fNo=ie.object({variable:ie.string()}).extend(Q3).extend(Na);var e9t=ie.undiscriminatedUnion([Cvi,fNo]);var dNo=ie.record(IFn,ie.list(CFn));var pNo=ie.list(dNo);var _No=ie.undiscriminatedUnion([ie.boolean(),pNo]);var hNo=ie.object({"allow-multiple":ie.boolean().optional()}).extend(I0e);var LFn=ie.undiscriminatedUnion([ie.string(),hNo]);var yNo=ie.object({env:ie.string().optional()}).extend(I0e);var bNo=ie.undiscriminatedUnion([ie.string(),yNo]);var q0e=bNo;var vNo=ie.object({type:ie.string()}).extend(Na);var gNo=ie.enum_(["json","exploded","form"]);var ONo=ie.object({style:gNo.optional(),"content-type":ie.string().optional()}).extend(I0e);var ANo=ie.undiscriminatedUnion([ie.string(),ONo]);var mNo=ie.object({extends:B0e.optional(),"extra-properties":ie.boolean().optional(),properties:ie.record(ie.string(),ANo).optional()});var PNo=ie.undiscriminatedUnion([ie.string(),vNo,mNo]);var jNo=ie.object({"content-type":ie.string().optional(),"path-parameters":ie.record(ie.string(),e9t).optional(),"query-parameters":ie.record(ie.string(),LFn).optional(),headers:ie.record(ie.string(),q0e).optional(),body:PNo.optional()}).extend(fb).extend(Na);var wNo=ie.undiscriminatedUnion([ie.string(),jNo]);var ENo=ie.object({type:ie.string().optional(),property:ie.string().optional(),"status-code":ie.number().optional()}).extend(Na);var VFn=ie.undiscriminatedUnion([ie.string(),ENo]);var SNo=ie.enum_(["sse","json"]);var MNo=ie.object({type:ie.string(),format:SNo.optional(),terminator:ie.string().optional()}).extend(Na);var WFn=ie.undiscriminatedUnion([ie.string(),MNo]);var DNo=ie.object({error:ie.string()}).extend(Na);var BNo=ie.undiscriminatedUnion([ie.string(),DNo]);var INo=ie.list(BNo);var CNo=ie.object({cursor:ie.string(),next_cursor:ie.string(),results:ie.string()});var qNo=ie.object({offset:ie.string(),results:ie.string(),step:ie.string().optional(),"has-next-page":ie.string().optional()});var TNo=ie.object({type:ie.stringLiteral("custom"),results:ie.string()});var xFn=ie.undiscriminatedUnion([CNo,qNo,TNo]);var RNo=ie.undiscriminatedUnion([xFn,ie.boolean()]);var zNo=ie.object({disabled:ie.boolean().optional()});var NNo=ie.undiscriminatedUnion([zNo]);var FNo=ie.object({method:lNo.optional(),"base-path":ie.string().optional(),path:ie.string(),url:ie.string().optional(),"path-parameters":ie.record(ie.string(),e9t).optional(),auth:_No.optional(),idempotent:ie.boolean().optional(),"stream-condition":ie.string().optional(),request:wNo.optional(),response:VFn.optional(),"response-stream":WFn.optional(),errors:INo.optional(),examples:ie.list(FFn).optional(),pagination:RNo.optional(),transport:UFn.optional(),source:yCi.optional(),retries:NNo.optional()}).extend(cz).extend(k6t);var QNo=ie.object({auth:ie.boolean(),url:ie.string().optional(),"base-path":ie.string(),"path-parameters":ie.record(ie.string(),Cvi).optional(),idempotent:ie.boolean().optional(),headers:ie.record(ie.string(),Cvi).optional(),transport:UFn.optional(),source:yCi.optional(),endpoints:ie.record(ie.string(),FNo)}).extend(Azo).extend(cz);var UNo=ie.enum_(["POST","GET"]);var LNo=ie.object({type:ie.string()}).extend(Na);var VNo=ie.object({name:ie.string(),extends:B0e.optional(),properties:ie.record(ie.string(),hCi).optional()});var WNo=ie.undiscriminatedUnion([ie.string(),LNo,VNo]);var xNo=ie.object({method:UNo,headers:ie.record(ie.string(),q0e).optional(),payload:WNo,response:VFn.optional(),"response-stream":WFn.optional(),examples:ie.list(Uzo).optional()}).extend(Q3).extend(lz).extend(Na).extend(cz);var GNo=ie.enum_(["client","server"]);var HNo=ie.object({type:ie.string()}).extend(Na);var KNo=ie.object({name:ie.string(),extends:B0e.optional(),properties:ie.record(ie.string(),hCi).optional()});var JNo=ie.undiscriminatedUnion([ie.string(),HNo,KNo]);var $No=ie.object({origin:GNo,body:JNo}).extend(k6t).extend(cz);var YNo=ie.object({auth:ie.boolean(),url:ie.string().optional(),path:ie.string(),headers:ie.record(ie.string(),q0e).optional(),"path-parameters":ie.record(ie.string(),e9t).optional(),"query-parameters":ie.record(ie.string(),LFn).optional(),messages:ie.record(ie.string(),$No).optional(),examples:ie.list(Bzo).optional()}).extend(k6t).extend(cz);var XNo=ie.object({imports:ie.record(ie.string(),ie.string()).optional(),types:ie.record(ie.string(),sNo).optional(),service:QNo.optional(),errors:ie.record(ie.string(),Mzo).optional(),webhooks:ie.record(ie.string(),xNo).optional(),channel:YNo.optional()}).extend(Na);var ZNo=ie.undiscriminatedUnion([ie.string(),ie.list(ie.string())]);var kNo=ie.object({dependency:ie.string(),url:ie.string().optional()});var eFo=ie.undiscriminatedUnion([ie.string(),kNo]);var Lu_=ie.object({navigation:ZNo.optional(),export:eFo.optional()}).extend(XNo);var tFo=ie.object({headers:ie.record(ie.string(),q0e).optional()});var rFo=ie.object({strategy:ie.stringLiteral("property"),"property-name":ie.string()});var iFo=ie.object({strategy:ie.stringLiteral("status-code")});var nFo=ie.undiscriminatedUnion([rFo,iFo]);var aFo=ie.object({type:ie.string()}).extend(Na);var oFo=ie.undiscriminatedUnion([ie.string(),aFo]);var uFo=ie.object({value:ie.string()}).extend(Na).extend(fb);var sFo=ie.undiscriminatedUnion([ie.string(),uFo]);var cFo=ie.object({name:ie.string().optional(),env:ie.string().optional(),value:ie.string()});var lFo=ie.undiscriminatedUnion([ie.string(),cFo]);var GFn=ie.object({default:ie.string().optional(),values:ie.list(sFo),header:lFo});var fFo=ie.object({value:ie.string(),versions:GFn.optional()}).extend(Na).extend(fb);var dFo=ie.undiscriminatedUnion([ie.string(),fFo]);var pFo=ie.object({name:ie.string().optional(),env:ie.string().optional(),value:ie.string()});var _Fo=ie.undiscriminatedUnion([ie.string(),pFo]);var hFo=ie.object({default:ie.string().optional(),values:ie.list(dFo),header:_Fo});var Vu_=ie.object({name:ie.string(),imports:ie.record(ie.string(),ie.string()).optional(),"error-discrimination":nFo.optional(),audiences:ie.list(ie.string()).optional(),errors:ie.list(ie.string()).optional(),"base-path":ie.string().optional(),"path-parameters":ie.record(ie.string(),e9t).optional(),"idempotency-headers":ie.record(ie.string(),q0e).optional(),variables:ie.record(ie.string(),oFo).optional(),pagination:xFn.optional(),product:hFo.optional(),version:GFn.optional()}).extend(Na).extend(cz).extend(Ezo).extend(hzo).extend(tFo);var gac={};Yt(gac,{CursorPaginationSchema:()=>CNo,CustomPaginationSchema:()=>TNo,OffsetPaginationSchema:()=>qNo,PaginationSchema:()=>xFn});var Oac={};Yt(Oac,{ProductDeclarationHeaderObjectSchema:()=>pFo,ProductDeclarationHeaderSchema:()=>_Fo,ProductDeclarationSchema:()=>hFo,ProductValue:()=>dFo,ProductValueDetailed:()=>fFo});var Aac={};Yt(Aac,{FormDataBodyEncodingStyle:()=>gNo,GrpcTransport:()=>cNo,HttpEndpointAuth:()=>_No,HttpEndpointSchema:()=>FNo,HttpEndpointSecurity:()=>pNo,HttpEndpointSecurityItem:()=>dNo,HttpHeaderSchema:()=>q0e,HttpInlineFileRequestBodyPropertySchema:()=>ONo,HttpInlineRequestBodyPropertySchema:()=>ANo,HttpInlineRequestBodySchema:()=>mNo,HttpMethodSchema:()=>lNo,HttpPathParameterSchema:()=>e9t,HttpQueryParameterSchema:()=>LFn,HttpReferencedRequestBodySchema:()=>vNo,HttpRequest:()=>wNo,HttpRequestBodySchema:()=>PNo,HttpRequestSchema:()=>jNo,HttpResponseSchema:()=>VFn,HttpResponseSchemaDetailed:()=>ENo,HttpResponseStreamSchema:()=>WFn,HttpResponseStreamSchemaDetailed:()=>MNo,HttpServiceSchema:()=>QNo,Pagination:()=>RNo,QueryParameterTypeReferenceDetailed:()=>hNo,ResponseError:()=>BNo,ResponseErrorWithDocsSchema:()=>DNo,ResponseErrorsSchema:()=>INo,RetriesConfiguration:()=>NNo,RetriesDisabledSchema:()=>zNo,ServiceTransport:()=>UFn,StreamFormat:()=>SNo,TypeReferenceDeclarationWithEnvOverride:()=>bNo,TypeReferenceDeclarationWithEnvOverrideSchema:()=>yNo});var mac={};Yt(mac,{OpenApiSourceSchema:()=>Wzo,ProtobufSourceSchema:()=>xzo,SourceSchema:()=>yCi});var Pac={};Yt(Pac,{AliasSchema:()=>uNo,BaseTypeDeclarationSchema:()=>C0e,BaseTypeReferenceSchema:()=>QFn,CasingOverridesSchema:()=>Hzo,DiscriminatedUnionSchema:()=>iNo,EnumSchema:()=>$zo,EnumValue:()=>Jzo,EnumValueSchema:()=>Kzo,ObjectExtendsSchema:()=>B0e,ObjectPropertyAccess:()=>Lzo,ObjectPropertySchema:()=>hCi,ObjectPropertyWithAccessSchema:()=>Vzo,ObjectSchema:()=>Gzo,SingleUndiscriminatedUnionTypeDetailedSchema:()=>nNo,SingleUndiscriminatedUnionTypeSchema:()=>aNo,SingleUnionTypeDetailedSchema:()=>tNo,SingleUnionTypeKey:()=>eNo,SingleUnionTypeKeySchema:()=>kzo,SingleUnionTypeSchema:()=>rNo,TypeDeclarationSchema:()=>sNo,TypeReferenceDeclarationWithName:()=>I0e,TypeReferenceDeclarationWithNameSchema:()=>Wu_,TypeReferenceDetailedSchema:()=>Zzo,TypeReferenceSchema:()=>Cvi,UndiscriminatedUnionSchema:()=>oNo,UnionDiscriminant:()=>Xzo,UnionDiscriminantSchema:()=>Yzo});var Wu_=ie.undiscriminatedUnion([ie.string(),I0e]);var jac={};Yt(jac,{NumberValidationSchema:()=>gzo,StringValidationSchema:()=>vzo,ValidationSchema:()=>_Ci});var wac={};Yt(wac,{VariableDeclarationDetailed:()=>aFo,VariableDeclarationSchema:()=>oFo,VariableReferenceSchema:()=>fNo});var Eac={};Yt(Eac,{VersionDeclarationHeaderObjectSchema:()=>cFo,VersionDeclarationHeaderSchema:()=>lFo,VersionDeclarationSchema:()=>GFn,VersionValue:()=>sFo,VersionValueDetailed:()=>uFo});var Sac={};Yt(Sac,{WebhookInlinedPayloadSchema:()=>VNo,WebhookMethodSchema:()=>UNo,WebhookPayloadSchema:()=>WNo,WebhookReferencedPayloadSchema:()=>LNo,WebhookSchema:()=>xNo});var Mac={};Yt(Mac,{WebSocketChannelInlinedMessageSchema:()=>KNo,WebSocketChannelMessageBodySchema:()=>JNo,WebSocketChannelMessageSchema:()=>$No,WebSocketChannelReferencedMessageSchema:()=>HNo,WebSocketChannelSchema:()=>YNo,WebSocketOrigin:()=>GNo});var $0a=class e extends Error{statusCode;body;constructor({message:t,statusCode:r,body:i}){super(LJS({message:t,statusCode:r,body:i})),Object.setPrototypeOf(this,e.prototype),r!=null&&(this.statusCode=r),i!==void 0&&(this.body=i)}};function LJS({message:e,statusCode:t,body:r}){let i=[];return e!=null&&i.push(e),t!=null&&i.push(`Status code: ${t.toString()}`),r!=null&&i.push(`Body: ${JSON.stringify(r,void 0,2)}`),i.join(`
1352
- `)}var Y0a=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function Bac(e){return e.scheme==="oauth"}var VJS={optional:"optional",nullable:"nullable",set:"set",list:"list",map:"map",literal:"literal"},xu_=new Set(Object.values(VJS));function xS(e){let t=e.match(/([\w.]+)<([\w,\s]+)>/);if(t?.[0]!=null&&t[1]!=null&&t[2]!=null&&!xu_.has(t[1].trim()))return{name:t[1].trim(),arguments:t[2].split(",").map(r=>r.trim())}}function T0e(e){return xS(e)!=null}function Iac(e){if(e.request!=null)return typeof e.request=="string"?e.request:e.request.body}var MKi=class{REFERENCE_REGEX=/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/;validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let i=t.match(this.REFERENCE_REGEX);if(!(i==null||i[1]==null||i[2]==null))return{method:i[1],path:i[2]}}};function HP(e){return typeof e=="string"?!1:e?.extends!=null||e?.properties!=null}function t9t(e){return e?e.proto!=null:!1}var WJS="text";function bCi(e){return e===WJS}var bx={integer:"integer",long:"long",uint:"uint",uint64:"uint64",float:"float",double:"double",boolean:"boolean",string:"string",datetime:"datetime",base64:"base64",uuid:"uuid",date:"date",bigint:"bigint",unknown:"unknown"};var YH={MAP:/^map<\s*([^,]*)\s*,\s*(.*)\s*>$/,LIST:/^list<\s*(.*)\s*>$/,SET:/^set<\s*(.*)\s*>$/,OPTIONAL:/^optional<\s*(.*)\s*>$/,NULLABLE:/^nullable<\s*(.*)\s*>$/,LITERAL:/^literal<\s*(?:"(.*)"|(true|false))\s*>$/};function DKi({type:e,_default:t,validation:r,visitor:i}){switch(e){case bx.integer:{let u=r??void 0;return i.primitive({v1:Su.Integer,v2:bn.integer({default:t??void 0,validation:u!=null?{min:u.min,max:u.max,exclusiveMin:u.exclusiveMin,exclusiveMax:u.exclusiveMax,multipleOf:u.multipleOf}:void 0})})}case bx.double:{let u=r??void 0;return i.primitive({v1:Su.Double,v2:bn.double({default:t??void 0,validation:u!=null?{min:u.min,max:u.max,exclusiveMin:u.exclusiveMin,exclusiveMax:u.exclusiveMax,multipleOf:u.multipleOf}:void 0})})}case bx.string:{let u=r??void 0;return i.primitive({v1:Su.String,v2:bn.string({default:t??void 0,validation:u!=null?{format:u.format,pattern:u.pattern,minLength:u.minLength,maxLength:u.maxLength}:void 0})})}case bx.float:return i.primitive({v1:Su.Float,v2:void 0});case bx.long:return i.primitive({v1:Su.Long,v2:bn.long({default:t??void 0})});case bx.boolean:return i.primitive({v1:Su.Boolean,v2:bn.boolean({default:t??void 0})});case bx.datetime:return i.primitive({v1:Su.DateTime,v2:void 0});case bx.date:return i.primitive({v1:Su.Date,v2:void 0});case bx.uuid:return i.primitive({v1:Su.Uuid,v2:void 0});case bx.base64:return i.primitive({v1:Su.Base64,v2:void 0});case bx.bigint:return i.primitive({v1:Su.BigInteger,v2:bn.bigInteger({default:t??void 0})});case bx.uint:return i.primitive({v1:Su.Uint,v2:void 0});case bx.uint64:return i.primitive({v1:Su.Uint64,v2:void 0});case bx.unknown:return i.unknown()}let n=e.match(YH.MAP);if(n?.[1]!=null&&n[2]!=null)return i.map({keyType:n[1],valueType:n[2]});let a=e.match(YH.LIST);if(a?.[1]!=null)return i.list(a[1]);let o=e.match(YH.SET);if(o?.[1]!=null)return i.set(o[1]);let c=e.match(YH.OPTIONAL);if(c?.[1]!=null)return i.optional(c[1]);let f=e.match(YH.NULLABLE);if(f?.[1]!=null)return i.nullable(f[1]);let s=e.match(YH.LITERAL);if(s?.[1]!=null)return i.literal(iz.string(s[1]));if(s?.[2]!=null){let u=s[2];switch(u){case"false":return i.literal(iz.boolean(!1));case"true":return i.literal(iz.boolean(!0));default:throw new Error(`Unsupported literal value: ${u}`)}}return i.named(e)}var Gu_="bytes";function R0e(e){if(e===Gu_)return{isOptional:!1};if(e.match(YH.OPTIONAL)?.[1]===Gu_)return{isOptional:!0}}function X0a(e){let t=typeof e=="string"?e:typeof e.body=="string"?e.body:void 0;if(t!=null)return R0e(t)}function Cac({input:e,typeName:t}){for(let r of e.arguments)if(typeof r=="string"){if(r===t)return!0}else if(Cac({input:r,typeName:t}))return!0;return!1}function Hu_(e){return Cac({input:e,typeName:"file"})}function Ku_(e){let t=0,r=0;function i(){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t>=e.length)return;let a="";for(;t<e.length&&e[t]!=="<"&&e[t]!==","&&e[t]!==">";)a+=e[t++];if(a.trim()){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t<e.length&&e[t]==="<"){if(t++,r++,r>128)throw new Error("Internal error; Exceeded maximum recursion depth while parsing generics.");let o={name:a.trim(),arguments:[]};for(;t<e.length&&e[t]!==">";){for(;t<e.length&&/[\s,]/.test(e[t]);)t++;if(t<e.length&&e[t]!==">"){let c=i();c&&o.arguments.push(c)}}if(t<e.length&&e[t]===">")t++,r--;else throw new Error("Malformed input: missing closing '>' for generic arguments.");return o}else return a.trim()}}let n=i();if(typeof n=="object")return n}var qac="file";function Ju_(e){return e.match(YH.LIST)?.[1]===qac}function XH(e){if(e===qac)return{isOptional:!1,isArray:!1};let t=e.match(YH.OPTIONAL);if(t?.[1]!==void 0){if(t[1]===qac)return{isOptional:!0,isArray:!1};if(Ju_(t[1]))return{isOptional:!0,isArray:!0}}if(Ju_(e))return{isOptional:!1,isArray:!0}}function xJS(e){return typeof e=="string"?!1:oO.parse(e["content-type"])?.isMultiPartFormData()??!1?!0:e.body==null?!1:!!(HP(e.body)&&Object.values(e.body.properties??[]).some(HJS))}function BKi(e){if(!(!xJS(e)||e.body==null)&&e.name!=null&&e.body!=null&&HP(e.body))return GJS(e.name,e.body)}function GJS(e,t){let r=Object.entries(t.properties??[]).reduce((i,[n,a])=>{let o=typeof a!="string"?a.docs:void 0,c=typeof a!="string"?a["content-type"]:void 0,f=typeof a!="string"?a.style:void 0,s=XH(typeof a=="string"?a:a.type);return s!=null?i.push({isFile:!0,key:n,docs:o,isOptional:s.isOptional,isArray:s.isArray,contentType:c,style:f}):i.push({isFile:!1,key:n,propertyType:a,docs:o,contentType:c,style:f}),i},[]);return t["extra-properties"],{name:e,extends:t.extends,properties:r}}function HJS(e){let t=typeof e=="string"?e:e.type;if(t==="file")return!0;if(!t.includes("file"))return!1;let r=Ku_(t);return r==null?!1:Hu_(r)}var $u_="text";function IKi(e){if(e===$u_)return{isOptional:!1};if(e.match(YH.OPTIONAL)?.[1]===$u_)return{isOptional:!0}}function wB({type:e,_default:t,validation:r,visitor:i}){return DKi({type:e,_default:t,validation:r,visitor:{primitive:i.primitive,map:({keyType:n,valueType:a})=>i.map({keyType:wB({type:n,_default:void 0,validation:void 0,visitor:i}),valueType:wB({type:a,_default:void 0,validation:void 0,visitor:i})}),list:n=>i.list(wB({type:n,_default:void 0,validation:void 0,visitor:i})),set:n=>i.set(wB({type:n,_default:void 0,validation:void 0,visitor:i})),optional:n=>i.optional(wB({type:n,_default:t,validation:r,visitor:i})),nullable:n=>i.nullable(wB({type:n,_default:t,validation:r,visitor:i})),literal:i.literal,named:i.named,unknown:i.unknown}})}function Tac(e,t){if(KJS(e))return t.sdk(e);if(JJS(e))return t.language(e);Ot(e)}function KJS(e){return e.sdk!=null}function JJS(e){return e.language!=null}function Yu_(e){return e["response-stream"]!=null&&(typeof e["response-stream"]=="string"||e["response-stream"].format==null||e["response-stream"].format==="json")}function Xu_(e){return e["response-stream"]!=null&&typeof e["response-stream"]!="string"&&e["response-stream"].format==="sse"}function CKi(e,t,r){return $JS(e,t)?r.stream(t):YJS(e,t)?r.events(t):r.body(t)}function $JS(e,t){return t.stream!==void 0&&Yu_(e)}function YJS(e,t){return t.stream!==void 0&&Xu_(e)}function qKi(e,t){if(Zu_(e))return t.single(e);if(ku_(e))return t.any(e);Ot(e)}function Zu_(e){return typeof e=="string"||e.scheme!=null}function ku_(e){let[t,...r]=Object.keys(e);return t==="any"&&r.length===0}function Z0a(e,t){if(es_(e))return t.header(e);switch(e.scheme){case"basic":return t.basic(e);case"bearer":return"get-token"in e?t.inferredBearer(e):t.tokenBearer(e);case"oauth":return t.oauth(e);default:Ot(e)}}function es_(e){return e.header!=null}function r9t(e,t){if(ts_(e))return t.singleBaseUrl(e);if(vhe(e))return t.multipleBaseUrls(e);Ot(e)}function ts_(e){return typeof e=="string"||"url"in e}function vhe(e){return typeof e!="string"&&"urls"in e}function HFn(e){return typeof e=="string"?e.startsWith("$"):"variable"in e}function EB(e,t){if(vCi(e))return t.alias(e);if(gCi(e))return t.discriminatedUnion(e);if(db(e))return t.object(e);if(KFn(e))return t.undiscriminatedUnion(e);if(aFt(e))return t.enum(e);Ot(e)}function vCi(e){return typeof e=="string"||e.type!=null}function db(e){return e.extends!=null||e.properties!=null}function gCi(e){return e.union!=null&&e.discriminated==null}function KFn(e){let t=e;return t.union!=null&&t.discriminated!=null}function aFt(e){return e.enum!=null}function Rac({rawApiFileSchema:e,casingsGenerator:t}){if(e.auth==null)return{docs:void 0,requirement:I3.All,schemes:[]};let r=typeof e.auth!="string"?e.auth.docs:void 0;return qKi(e.auth,{single:i=>{let n=rs_({reference:i,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t});return{docs:r,requirement:I3.All,schemes:[n]}},any:({any:i})=>({docs:r,requirement:I3.Any,schemes:i.map(n=>rs_({reference:n,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t}))})})}function rs_({reference:e,authSchemeDeclarations:t,casingsGenerator:r}){let i=(a,o)=>{let c=t?.[a];if(c==null)throw new Error("Unknown auth scheme: "+a);return Z0a(c,{header:f=>wA.header({key:a,docs:o,name:r.generateNameAndWireValue({name:f.name??a,wireValue:f.header}),valueType:ii.primitive({v1:Su.String,v2:bn.string({default:void 0,validation:void 0})}),prefix:f.prefix,headerEnvVar:f.env}),basic:f=>is_({key:a,casingsGenerator:r,docs:o,rawScheme:f}),tokenBearer:f=>yFo({key:a,casingsGenerator:r,docs:o,rawScheme:f}),inferredBearer(f){return yFo({key:a,casingsGenerator:r,docs:o,rawScheme:void 0})},oauth:f=>yFo({key:a,casingsGenerator:r,docs:o,rawScheme:void 0})})},n=typeof e=="string"?e:e.scheme;switch(n){case"bearer":case"oauth":return yFo({key:n,casingsGenerator:r,docs:void 0,rawScheme:void 0});case"basic":return is_({key:n,casingsGenerator:r,docs:void 0,rawScheme:void 0});default:return i(n,typeof e!="string"?e.docs:void 0)}}function yFo({key:e,casingsGenerator:t,docs:r,rawScheme:i}){return wA.bearer({key:e,docs:r,token:t.generateName(i?.token?.name??"token"),tokenEnvVar:i?.token?.env})}function is_({key:e,casingsGenerator:t,docs:r,rawScheme:i}){return wA.basic({key:e,docs:r,username:t.generateName(i?.username?.name??"username"),usernameEnvVar:i?.username?.env,password:t.generateName(i?.password?.name??"password"),passwordEnvVar:i?.password?.env})}function mD(e){let t=ZJS(e),{value:r,done:i}=zac(t,"{");return i?{head:r,parts:[]}:{head:r,parts:[...XJS(t)]}}function*XJS(e){let t;do{let{value:r}=zac(e,"}"),i=zac(e,"{");t=i.done,yield{pathParameter:r,tail:i.value}}while(!t)}function*ZJS(e){for(let t of e)yield t}function zac(e,t){let r="",i=e.next();for(;i.done!==!0&&i.value!==t;)r+=i.value,i=e.next();return{value:r,done:i.done??!1}}function k0a({rawApiFileSchema:{"default-environment":e,environments:t},casingsGenerator:r}){if(t==null)return;let i=Object.values(t)[0];if(i!=null)return{environmentsConfig:{defaultEnvironment:e??void 0,environments:r9t(i,{singleBaseUrl:()=>$E.singleBaseUrl(kJS({environments:t,casingsGenerator:r})),multipleBaseUrls:n=>$E.multipleBaseUrls(e$S({baseUrls:Object.keys(n.urls),environments:t,casingsGenerator:r}))})},audiences:{...Object.fromEntries(Object.entries(t).map(([n,a])=>[n,r9t(a,{singleBaseUrl:o=>[...typeof o=="string"?[]:o.audiences??[]],multipleBaseUrls:o=>[...o.audiences??[]]})]))}}}function kJS({environments:e,casingsGenerator:t}){return{environments:Object.entries(e).map(([r,i])=>r9t(i,{singleBaseUrl:n=>({docs:typeof n=="string"?void 0:n.docs,id:r,name:t.generateName(r),url:ns_(typeof n=="string"?n:n.url)}),multipleBaseUrls:()=>{throw new Error(`Environment ${r} has multiple base URLs`)}}))}}function e$S({baseUrls:e,environments:t,casingsGenerator:r}){return{baseUrls:e.map(i=>({id:i,name:r.generateName(i)})),environments:Object.entries(t).map(([i,n])=>r9t(n,{multipleBaseUrls:a=>({docs:a.docs,id:i,name:r.generateName(i),urls:_n(a.urls,o=>ns_(o))}),singleBaseUrl:()=>{throw new Error(`Environment ${i} does not have multiple base URLs`)}}))}}function ns_(e){return e.endsWith("/")?e.slice(0,-1):e}function OCi(e){let t=2166136261;function r(n,a){if(typeof n=="object"&&n!=null){if(a>64){i("[MaxDepthExceeded]");return}if(Array.isArray(n)){i("[");for(let o=0;o<n.length;o++)o>0&&i(","),r(n[o],a+1);i("]")}else i("{"),Object.keys(n).sort().forEach((c,f)=>{f>0&&i(","),i(c),i(":"),r(n[c],a+1)}),i("}")}else i(String(n))}function i(n){for(let a=0;a<n.length;a++){let o=n.charCodeAt(a);t^=o,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24),t>>>=0}}return r(e,0),t.toString(16)}function i9t({typeReference:e,typeDeclarations:t}){if(e.type==="container"&&e.container.type==="optional")return!0;if(e.type==="named"){let r=t?.[e.typeId];if(r?.shape.type==="alias"&&r?.shape.resolvedType.type==="container"&&r?.shape.resolvedType.container.type==="optional")return!0}return!1}function as_({fieldName:e,containerType:t,maxDepth:r,currentDepth:i,typeDeclarations:n,skipOptionalProperties:a}){if(i>=r)return n9t({containerType:t});switch(t.type){case"list":{let o=MA({fieldName:e,typeReference:t.list,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?n9t({containerType:t}):{type:"success",example:op.list({list:[o.example,o.example],itemType:t.list}),jsonExample:[o.jsonExample,o.jsonExample]}}case"literal":return{type:"success",example:op.literal({literal:t.literal._visit({boolean:o=>Sn.boolean(o),string:o=>Sn.string({original:o}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:t.literal._visit({boolean:o=>o,string:o=>o,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":{if(a)return n9t({containerType:t});let o=MA({fieldName:e,typeReference:t.optional,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?n9t({containerType:t}):{type:"success",example:op.optional({optional:o.example,valueType:t.optional}),jsonExample:o.jsonExample}}case"nullable":{if(a)return n9t({containerType:t});let o=MA({fieldName:e,typeReference:t.nullable,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?n9t({containerType:t}):{type:"success",example:op.nullable({nullable:o.example,valueType:t.nullable}),jsonExample:o.jsonExample}}case"set":{let o=MA({fieldName:e,typeReference:t.set,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?n9t({containerType:t}):{type:"success",example:op.set({set:[o.example],itemType:t.set}),jsonExample:[o.jsonExample]}}case"map":{let o=MA({fieldName:e,typeReference:t.keyType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a}),c=MA({fieldName:e,typeReference:t.valueType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"||c.type==="failure"?n9t({containerType:t}):{type:"success",example:op.map({map:[{key:o.example,value:c.example}],keyType:t.keyType,valueType:t.valueType}),jsonExample:{[o.jsonExample]:c.jsonExample}}}default:Ot(t)}}function n9t({containerType:e}){switch(e.type){case"list":return{type:"success",example:op.list({list:[],itemType:e.list}),jsonExample:[]};case"literal":return{type:"success",example:op.literal({literal:e.literal._visit({boolean:t=>Sn.boolean(t),string:t=>Sn.string({original:t}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:e.literal._visit({boolean:t=>t,string:t=>t,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":return{type:"success",example:op.optional({optional:void 0,valueType:e.optional}),jsonExample:void 0};case"nullable":return{type:"success",example:op.nullable({nullable:void 0,valueType:e.nullable}),jsonExample:void 0};case"set":return{type:"success",example:op.set({set:[],itemType:e.set}),jsonExample:[]};case"map":return{type:"success",example:op.map({map:[],keyType:e.keyType,valueType:e.valueType}),jsonExample:{}};default:Ot(e)}}function us_({fieldName:e,primitiveType:t}){switch(t.v1){case"STRING":return a$S({fieldName:e,default_:t$S(t.v2),validation:r$S(t.v2)});case"BASE_64":return{type:"success",example:Sn.base64(Tn.BASE64),jsonExample:Tn.BASE64};case"BOOLEAN":return{type:"success",example:Sn.boolean(Tn.BOOLEAN),jsonExample:Tn.BOOLEAN};case"DATE":return{type:"success",example:Sn.date(Tn.DATE),jsonExample:Tn.DATE};case"DATE_TIME":return{type:"success",example:Sn.datetime({datetime:new Date(Tn.DATE_TIME),raw:Tn.DATE_TIME}),jsonExample:Tn.DATE_TIME};case"DOUBLE":return o$S({fieldName:e,validation:i$S(t.v2)});case"FLOAT":return{type:"success",example:Sn.float(Tn.FLOAT),jsonExample:Tn.FLOAT};case"INTEGER":return u$S({fieldName:e,validation:n$S(t.v2)});case"UINT_64":return{type:"success",example:Sn.uint64(Tn.INT64),jsonExample:Tn.INT64};case"UINT":return{type:"success",example:Sn.uint(Tn.UINT),jsonExample:Tn.UINT};case"BIG_INTEGER":return{type:"success",example:Sn.bigInteger(Tn.INT64.toString()),jsonExample:`${Tn.INT64}`};case"LONG":return{type:"success",example:Sn.long(Tn.INT64),jsonExample:Tn.INT64};case"UUID":return{type:"success",example:Sn.uuid(Tn.UUID),jsonExample:Tn.UUID};default:Ot(t.v1)}}function t$S(e){if(e?.type==="string")return e.default}function r$S(e){if(e?.type==="string")return e.validation}function i$S(e){if(e?.type==="double")return e.validation}function n$S(e){if(e?.type==="integer")return e.validation}function os_(e){if(e<=Tn.SAMPLE_STRINGS.length){let t=Tn.SAMPLE_STRINGS[e-1];if(t)return t;throw new Error(`Unexpected undefined value in SAMPLE_STRINGS at index ${e-1}`)}return Tn.SAMPLE_STRINGS[Tn.SAMPLE_STRINGS.length-1]+".".repeat(e-Tn.SAMPLE_STRINGS.length)}function a$S({fieldName:e,default_:t,validation:r}){if(t!=null)return{type:"success",example:Sn.string({original:t}),jsonExample:t};if(r){let n=r.minLength,a=r.maxLength;if(n){let o=os_(n);return{type:"success",example:Sn.string({original:o}),jsonExample:o}}else if(a!=null&&a<10){let o=os_(a);return{type:"success",example:Sn.string({original:o}),jsonExample:o}}}let i=e??Tn.STRING;return{type:"success",example:Sn.string({original:i}),jsonExample:i}}function o$S({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Sn.double(r),jsonExample:r};if(i)return{type:"success",example:Sn.double(i),jsonExample:i}}return{type:"success",example:Sn.double(Tn.DOUBLE),jsonExample:Tn.DOUBLE}}function u$S({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Sn.integer(r),jsonExample:r};if(i)return{type:"success",example:Sn.integer(i),jsonExample:i}}return{type:"success",example:Sn.integer(Tn.INT),jsonExample:Tn.INT}}function s$S(e,t){if(e.type==="primitive"||e.type==="container"&&e.container.type==="literal")return!0;if(e.type==="named"){let r=t[e.typeId];if(r!=null&&r.shape.type==="enum")return!0}return!1}function TKi({fieldName:e,typeDeclarations:t,typeDeclaration:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){switch(r.shape.type){case"alias":{let o=MA({fieldName:e,typeDeclarations:t,typeReference:r.shape.aliasOf,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(o.type==="failure")return o;let{example:c,jsonExample:f}=o;return{type:"success",example:Bh.alias({value:c}),jsonExample:f}}case"enum":{let o=r.shape.values[0];return o==null?{type:"failure",message:"No enum values present"}:{type:"success",example:Bh.enum({value:o.name}),jsonExample:o.name.wireValue}}case"object":{let o={},c=[];if((r.shape.extendedProperties==null||r.shape.extendedProperties.length===0)&&r.shape.extends!=null)for(let l of r.shape.extends){let p=t[l.typeId];if(p==null)continue;let _=TKi({fieldName:e,typeDeclaration:p,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});_!=null&&_.type==="success"&&_.example.type==="object"&&(Object.assign(o,_.jsonExample),c.push(..._.example.properties))}let f=c$S({fieldName:e,typeDeclaration:r,objectTypeDeclaration:r.shape,typeDeclarations:t,currentDepth:n,maxDepth:i,skipOptionalProperties:a});if(f.type==="failure")return f;let{example:s,jsonExample:u}=f;return{type:"success",example:Bh.object({properties:[...c,...s.properties],extraProperties:s.extraProperties}),jsonExample:Object.assign({},o,u)}}case"undiscriminatedUnion":{let o=r.shape.members;if(o.every(s=>s$S(s.type,t))){let s=o.findIndex(u=>{if(u.type.type==="container"&&u.type.container.type==="literal")return!0;if(u.type.type==="named"){let l=t[u.type.typeId];if(l!=null&&l.shape.type==="enum")return l.shape.values.length>0}return!1});if(s!==-1){let u=o[s];if(u!=null){let l=MA({fieldName:e,typeReference:u.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(l.type==="success"){let{example:p,jsonExample:_}=l;return{type:"success",example:Bh.undiscriminatedUnion({index:s,singleUnionType:p}),jsonExample:_}}}}}let f=0;for(let s of o){let u=MA({fieldName:e,typeReference:s.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(u.type==="failure"){++f;continue}let{example:l,jsonExample:p}=u;return{type:"success",example:Bh.undiscriminatedUnion({index:f,singleUnionType:l}),jsonExample:p}}break}case"union":{let o=r.shape.discriminant,c={};if(r.shape.baseProperties!=null)for(let u of r.shape.baseProperties){let l=MA({fieldName:u.name.wireValue,typeReference:u.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});l.type==="success"&&(c[u.name.wireValue]=l.jsonExample)}let f=r.shape.baseProperties.map(u=>{let l=MA({fieldName:u.name.wireValue,typeReference:u.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(l.type==="failure")throw new Error(`Failed to generate example for union base property ${u.name.wireValue}`);let{example:p}=l;return{name:u.name,value:p}}),s=r.shape.extends.flatMap(u=>{let l=t[u.typeId];if(l==null)throw new Error(`Failed to find extended type declaration with id ${u.typeId}`);let p=TKi({fieldName:e,typeDeclaration:l,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(p==null||p.type==="failure")throw new Error(`Failed to generate example for extended type declaration ${l.name.typeId}`);if(p.example.type!=="object")throw new Error(`Extended type declaration ${l.name.typeId} is not an object`);return p.example.properties});for(let u of r.shape.types){let l=u.shape._visit({noProperties:()=>({type:"success",example:Bh.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:jB.noProperties()},baseProperties:f,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,...c}}),samePropertiesAsObject:p=>{let _=t[p.typeId];if(_==null)return{type:"failure",message:`Failed to find type declaration with id ${p.typeId}`};let h=TKi({currentDepth:n,maxDepth:i,fieldName:e,typeDeclaration:_,typeDeclarations:t,skipOptionalProperties:a});if(h==null)return{type:"failure",message:"Failed to generate example for type reference"};if(h.type==="failure")return h;let{example:y,jsonExample:b}=h;return{type:"success",example:Bh.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:jB.samePropertiesAsObject({typeId:_.name.typeId,object:y.type==="object"?y:{properties:[],extraProperties:void 0}})},baseProperties:f,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,...typeof b=="object"?b:{},...c}}},singleProperty:p=>{let _=MA({currentDepth:n+1,maxDepth:i,fieldName:e,typeReference:p.type,typeDeclarations:t,skipOptionalProperties:a});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;return{type:"success",example:Bh.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:jB.singleProperty(h)},baseProperties:f,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,[p.name.wireValue]:y,...c}}},_other:()=>{throw new Error("Encountered unknown union type")}});if(l.type!=="failure")return l}}}return{type:"failure",message:"Failed to generate example for type reference"}}function c$S({fieldName:e,typeDeclaration:t,objectTypeDeclaration:r,typeDeclarations:i,maxDepth:n,currentDepth:a,skipOptionalProperties:o}){let c={},f=[];for(let s of[...r.properties??[],...r.extendedProperties??[]]){let u=MA({fieldName:s.name.wireValue,typeReference:s.valueType,typeDeclarations:i,currentDepth:a+1,maxDepth:n,skipOptionalProperties:o});if(u.type==="failure"&&!i9t({typeDeclarations:i,typeReference:s.valueType}))return{type:"failure",message:`Failed to generate required property ${s.name.wireValue} b/c ${u.message}`};if(u.type==="failure")continue;let{example:l,jsonExample:p}=u;f.push({name:s.name,originalTypeDeclaration:t.name,value:l,propertyAccess:s.propertyAccess}),c[s.name.wireValue]=p}return{type:"success",example:Bh.object({properties:f,extraProperties:void 0}),jsonExample:c}}function MA({fieldName:e,typeReference:t,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){if(n>i)return{type:"failure",message:`Exceeded max depth of ${i}`};switch(t.type){case"named":{let o=r[t.typeId];if(o==null)return{type:"failure",message:`Failed to find type declaration with id ${t.typeId}`};let c=TKi({fieldName:e,typeDeclaration:o,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(c==null)return{type:"failure",message:"Failed to generate example for type declaration"};if(c.type==="failure")return c;let{example:f,jsonExample:s}=c;return{type:"success",example:{jsonExample:s,shape:lu.named({shape:f,typeName:o.name})},jsonExample:s}}case"container":{let o=as_({fieldName:e,containerType:t.container,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(o.type==="failure"){let{example:s,jsonExample:u}=n9t({containerType:t.container});return{type:"success",example:{jsonExample:u,shape:lu.container(s)},jsonExample:u}}let{example:c,jsonExample:f}=o;return{type:"success",example:{jsonExample:f,shape:lu.container(c)},jsonExample:f}}case"primitive":{let{jsonExample:o,example:c}=us_({fieldName:e,primitiveType:t.primitive});return{type:"success",example:{jsonExample:o,shape:lu.primitive(c)},jsonExample:o}}case"unknown":{let o={key:"value"};return{type:"success",example:{jsonExample:o,shape:lu.unknown(o)},jsonExample:o}}}}function RKi(e,t){let r=[];for(let i of e){let n=MA({fieldName:i.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function JFn(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&i9t({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=MA({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function bFo(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&i9t({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=MA({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??10,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,shape:i.allowMultiple?M1.exploded():M1.single(),value:n.example})}return{type:"success",example:r,jsonExample:void 0}}var Nac=ii.primitive({v1:Su.String,v2:bn.string({default:void 0,validation:void 0})});function $Fn({ir:e,endpoint:t,service:r,typeDeclarations:i,skipOptionalRequestProperties:n,generationResponse:a}){let o={name:void 0,endpointHeaders:[],endpointPathParameters:[],queryParameters:[],servicePathParameters:[],serviceHeaders:[],rootPathParameters:[],request:void 0,response:L0.ok(xP.body(void 0)),docs:void 0},c=RKi(t.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(c.type==="failure")return c;o.endpointPathParameters=c.example;let f=RKi(r.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(f.type==="failure")return f;o.servicePathParameters=f.example;let s=RKi(e.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(s.type==="failure")return s;o.rootPathParameters=s.example;let u=bFo(t.queryParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:10});if(u.type==="failure")return u;o.queryParameters=u.example;let l=JFn(t.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(l.type==="failure")return l;o.endpointHeaders=l.example;let p=JFn(r.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(p.type==="failure")return p;if(o.serviceHeaders=p.example,t.requestBody!=null)switch(t.requestBody.type){case"bytes":return{type:"failure",message:"Bytes request unsupported"};case"fileUpload":return{type:"failure",message:"File upload unsupported"};case"inlinedRequestBody":{let _={},h=[];if(t.requestBody.extends!=null)for(let y of t.requestBody.extends){let b=i[y.typeId];if(b==null)throw new Error(`Failed to find extended type declaration with id ${y.typeId}`);let v=TKi({typeDeclaration:b,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});v!=null&&v.type==="success"&&Object.assign(_,v.jsonExample)}for(let y of[...t.requestBody.properties??[],...t.requestBody.extendedProperties??[]]){let b=MA({fieldName:y.name.wireValue,typeReference:y.valueType,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});if(b.type==="failure"&&!i9t({typeDeclarations:i,typeReference:y.valueType}))return{type:"failure",message:`Failed to generate required property ${y.name.wireValue} b/c ${b.message}`};if(b.type==="failure")continue;let{example:v,jsonExample:O}=b;h.push({name:y.name,originalTypeDeclaration:void 0,value:v}),_[y.name.wireValue]=O}o.request=T3.inlinedRequestBody({jsonExample:_,properties:h,extraProperties:void 0});break}case"reference":{let _=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.requestBody.requestBodyType,skipOptionalProperties:n});if(_.type==="failure")return _;let{example:h}=_;o.request=T3.reference(h);break}default:Ot(t.requestBody)}if(a.type==="success"&&t.response?.body!=null)switch(t.response.body.type){case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":{let _=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.responseBodyType,skipOptionalProperties:!1});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=L0.ok(xP.body({...h,jsonExample:y}));break}case"streamParameter":{let _;switch(t.response.body.nonStreamResponse.type){case"bytes":return{type:"failure",message:"Bytes unsupported"};case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":_=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.nonStreamResponse.value.responseBodyType,skipOptionalProperties:!1});break;case"text":_=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:Nac,skipOptionalProperties:!1});break;default:Ot(t.response.body.nonStreamResponse)}if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=L0.ok(xP.body({...h,jsonExample:y}));break}case"streaming":{let _;switch(t.response.body.value.type){case"sse":{if(_=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=L0.ok(xP.sse([{data:{...h,jsonExample:y},event:""}]));break}case"json":{if(_=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=L0.ok(xP.stream([{...h,jsonExample:y}]));break}case"text":{if(_=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:Nac,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=L0.ok(xP.stream([{...h,jsonExample:y}]));break}default:Ot(t.response.body.value)}break}case"text":{let _=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:Nac,skipOptionalProperties:!1});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=L0.ok(xP.body({...h,jsonExample:y}));break}case"bytes":return{type:"failure",message:"Bytes unsupported"};default:Ot(t.response.body)}else if(a.type==="error")if(a.declaration.type==null)o.response=L0.error({body:void 0,error:a.declaration.name});else{let _=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:a.declaration.type,skipOptionalProperties:n});if(_.type==="failure")return _;let{example:h}=_;o.response=L0.error({body:h,error:a.declaration.name})}try{return{type:"success",example:{id:OCi(o),url:l$S(t,o),...o},jsonExample:void 0}}catch(_){return{type:"failure",message:`Parse failure with exceptions ${_}`}}}function l$S(e,t){let r={};[...t.rootPathParameters,...t.servicePathParameters,...t.endpointPathParameters].forEach(n=>{let a=n.value.jsonExample,o=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=o});let i=e.fullPath.head+e.fullPath.parts.map(n=>encodeURIComponent(`${r[n.pathParameter]}`)+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function Fac({ir:e,channel:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let n={name:void 0,pathParameters:[],headers:[],queryParameters:[],messages:[],docs:void 0},a=RKi(t.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(a.type==="failure")return a;n.pathParameters.push(...a.example);let o=RKi(e.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(o.type==="failure")return o;n.pathParameters.push(...o.example);let c=bFo(t.queryParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:10});if(c.type==="failure")return c;n.queryParameters=c.example;let f=JFn(t.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(f.type==="failure")return f;n.headers.push(...f.example);let s=JFn(e.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(s.type==="failure")return s;n.headers.push(...s.example);let l=t.messages.filter(h=>h.origin==="client")[0];if(l!=null){let h=ss_({message:l,typeDeclarations:r,skipOptionalRequestProperties:i});h!=null&&n.messages.push({type:l.type,body:h})}let _=t.messages.filter(h=>h.origin==="server")[0];if(_!=null){let h=ss_({message:_,typeDeclarations:r,skipOptionalRequestProperties:i});h!=null&&n.messages.push({type:_.type,body:h})}return{type:"success",example:{...n,url:f$S(t,n)},jsonExample:void 0}}function ss_({message:e,typeDeclarations:t,skipOptionalRequestProperties:r}){if(e.body.type==="inlinedBody")return;let i=MA({currentDepth:0,maxDepth:10,typeDeclarations:t,typeReference:e.body.bodyType,skipOptionalProperties:r});if(i.type==="success")return yhe.reference(i.example)}function f$S(e,t){let r={};[...t.pathParameters].forEach(n=>{let a=n.value.jsonExample,o=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=o});let i=e.path.head+e.path.parts.map(n=>encodeURIComponent(`${r[n.pathParameter]}`)+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function YFn(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{},i=Object.values(t)[0],n=Object.values(r)[0];return{userExample:i,autoExample:n}}function ACi(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{};return{userExamples:t,autoExamples:r}}function cs_({ir:e,endpoint:t,skipOptionalRequestProperties:r}){let i=e.types,n={pathParameters:{},queryParameters:{},headers:{}};for(let o of t.pathParameters){let{userExample:c,autoExample:f}=YFn(o.v2Examples);c!==void 0?n.pathParameters[o.name.originalName]=c:f!==void 0&&(n.pathParameters[o.name.originalName]=f)}for(let o of t.queryParameters){let{userExample:c,autoExample:f}=YFn(o.v2Examples);if(c!==void 0)n.queryParameters[o.name.name.originalName]=c;else if(f!==void 0){if(r&&i9t({typeReference:o.valueType,typeDeclarations:i}))continue;n.queryParameters[o.name.name.originalName]=f}}let a=[...t.headers,...e.headers,...e.idempotencyHeaders];for(let o of a){let{userExample:c,autoExample:f}=YFn(o.v2Examples);if(c!==void 0)n.headers[o.name.wireValue]=c;else if(f!==void 0){if(r&&i9t({typeReference:o.valueType,typeDeclarations:i}))continue;n.headers[o.name.wireValue]=f}}return n}function ls_({endpoint:e,ir:t,skipOptionalRequestProperties:r}){let{pathParameters:i,queryParameters:n,headers:a}=cs_({endpoint:e,ir:t,skipOptionalRequestProperties:r}),o={},c={},f={endpoint:{method:e.method,path:d$S(e)},baseUrl:void 0,environment:e.baseUrl,auth:void 0,pathParameters:i,queryParameters:n,headers:a,requestBody:void 0,docs:void 0};if(e.requestBody!=null)switch(e.requestBody.type){case"bytes":break;case"fileUpload":{let{userExamples:s,autoExamples:u}=ACi(e.requestBody.v2Examples);for(let[l,p]of Object.entries(s))o[l]={...f,requestBody:p};for(let[l,p]of Object.entries(u))c[l]={...f,requestBody:p};break}case"inlinedRequestBody":{let{userExamples:s,autoExamples:u}=ACi(e.requestBody.v2Examples);for(let[l,p]of Object.entries(s))o[l]={...f,requestBody:p};for(let[l,p]of Object.entries(u))c[l]={...f,requestBody:p};break}case"reference":{let{userExamples:s,autoExamples:u}=ACi(e.requestBody.v2Examples);for(let[l,p]of Object.entries(s))o[l]={...f,requestBody:p};for(let[l,p]of Object.entries(u))c[l]={...f,requestBody:p};break}default:Ot(e.requestBody)}return{userRequestExamples:o,autoRequestExamples:c,baseExample:f}}function d$S(e){let t={};[...e.pathParameters,...e.allPathParameters].forEach(i=>{let{userExample:n,autoExample:a}=YFn(i.v2Examples),o=n??a,c;o==null?c=i.name.originalName:c=typeof o=="string"?o:JSON.stringify(o),t[i.name.originalName]=c});let r=e.fullPath.head+e.fullPath.parts.map(i=>encodeURIComponent(`${t[i.pathParameter]}`)+i.tail).join("");return r.startsWith("/")||r===""?r:`/${r}`}function vFo({endpoint:e,responseObject:t}){let r=t!==void 0?t:e.response,i={},n={},a={statusCode:r?.statusCode,body:void 0,docs:void 0};if(r==null)return{userResponseExamples:{},autoResponseExamples:{},baseExample:a};if(r.body==null)return e.source?.type==="openrpc"?{userResponseExamples:{},autoResponseExamples:{},baseExample:{...a,body:CC.json(ePa(null))}}:{userResponseExamples:{},autoResponseExamples:{},baseExample:a};switch(r.body.type){case"bytes":break;case"fileDownload":break;case"text":{let o=r.body,{userExamples:c,autoExamples:f}=ACi(o.v2Examples);for(let[s,u]of Object.entries(c)){let l=e.source?.type==="openrpc"?ePa(u):u;i[s]={...a,body:CC.json(l)}}for(let[s,u]of Object.entries(f)){let l=e.source?.type==="openrpc"?ePa(u):u;n[s]={...a,body:CC.json(l)}}break}case"json":{let o=r.body.value;if(o.type==="response"){let{userExamples:c,autoExamples:f}=ACi(o.v2Examples);for(let[s,u]of Object.entries(c)){let l=e.source?.type==="openrpc"?ePa(u):u;i[s]={...a,body:CC.json(l)}}for(let[s,u]of Object.entries(f)){let l=e.source?.type==="openrpc"?ePa(u):u;n[s]={...a,body:CC.json(l)}}}break}case"streaming":{let o=r.body.value;if(o.type==="json"){let{userExamples:c,autoExamples:f}=ACi(o.v2Examples);for(let[s,u]of Object.entries(c))i[s]={...a,body:CC.stream([u])};for(let[s,u]of Object.entries(f))n[s]={...a,body:CC.stream([u])}}break}case"streamParameter":break;default:Ot(r.body)}return{userResponseExamples:i,autoResponseExamples:n,baseExample:a}}function ePa(e,t=1){return{id:t,jsonrpc:"2.0",result:e}}var XFn=(e,t,r)=>{let i;return e===t?i=`${e}`:i=`${e}_${t}`,r&&(i=`${i}_${r}`),i},p$S=({exampleStore:e,key:t,example:r})=>e.has(t)?!1:(e.set(t,r),!0);function gFo({key:e,displayName:t,request:r,response:i,exampleStore:n,userOrAutoStore:a}){if(!n.has(e)){let o={displayName:t,request:r,response:i,codeSamples:void 0};return a[e]=o,p$S({exampleStore:n,key:e,example:o}),!0}return!1}function fs_({endpoint:e,ir:t,skipOptionalRequestProperties:r}){let i={},n={},a=new Map,{userRequestExamples:o,autoRequestExamples:c,baseExample:f}=ls_({endpoint:e,ir:t,skipOptionalRequestProperties:r}),s=Object.keys(o)[0],u=Object.values(o)[0],l=Object.keys(c)[0],p=Object.values(c)[0],_=_$S({endpoint:e,userRequestExamples:o,baseRequestExample:f,firstUserRequestName:s,firstUserRequestExample:u,firstAutoRequestName:l,firstAutoRequestExample:p,userResults:i,autoResults:n,exampleStore:a});if(h$S({endpoint:e,userRequestExamples:o,requestExamplesUsed:_,userResults:i,exampleStore:a}),Object.keys(i).length===0&&Object.keys(n).length===0){let{baseExample:h}=vFo({endpoint:e}),y=XFn(l??"base","base",void 0);gFo({key:y,displayName:l??"base",request:p??f,response:h,exampleStore:a,userOrAutoStore:n})}return{userFullExamples:i,autoFullExamples:n}}function _$S({endpoint:e,userRequestExamples:t,baseRequestExample:r,firstUserRequestName:i,firstUserRequestExample:n,firstAutoRequestName:a,firstAutoRequestExample:o,userResults:c,autoResults:f,exampleStore:s}){let u=e.v2Responses?.responses??[e.response],l=new Set;for(let p of u){let _=!1,{userResponseExamples:h,autoResponseExamples:y,baseExample:b}=vFo({endpoint:e,responseObject:p}),v=Object.keys(y)[0],O=Object.values(y)[0];for(let[A,g]of Object.entries(h)){let m,j;t[A]?(j=t[A],l.add(A),m=XFn(A,A,p?.statusCode)):o&&a?(j=o,m=XFn(a,A,p?.statusCode)):(j=r,m=XFn("base",A,p?.statusCode)),gFo({key:m,displayName:A,request:j,response:g,exampleStore:s,userOrAutoStore:c})&&(_=!0)}if(!_){let A=Fo(`${e.name.originalName}_example`);i&&n&&l.add(i);let g=XFn(i??a??"base",v??"base",p?.statusCode);gFo({key:g,displayName:i??a??A,request:n??o??r,response:O??b,exampleStore:s,userOrAutoStore:f})&&(_=!0)}}return l}function h$S({endpoint:e,userRequestExamples:t,requestExamplesUsed:r,userResults:i,exampleStore:n}){let{userResponseExamples:a,autoResponseExamples:o,baseExample:c}=vFo({endpoint:e}),f=Object.values(a)[0],s=Object.keys(a)[0],u=Object.keys(o)[0],l=Object.values(o)[0],p=Object.entries(t).filter(([_])=>!r.has(_));for(let[_,h]of p){let y=XFn(_,s??u??"base",f?f.statusCode:l?l.statusCode:c.statusCode);gFo({key:y,displayName:_,request:h,response:f??l??c,exampleStore:n,userOrAutoStore:i})}}function tPa({ir:e,exampleGeneration:t}){let r={disabled:t.disabled,includeOptionalRequestPropertyExamples:t.includeOptionalRequestPropertyExamples??!1,skipAutogenerationIfManualExamplesExist:t.skipAutogenerationIfManualExamplesExist??!1,skipErrorAutogenerationIfManualErrorExamplesExist:t.skipErrorAutogenerationIfManualErrorExamplesExist??!1};for(let[i,n]of Object.entries(e.services))for(let a of n.endpoints){let o=[];if(a.userSpecifiedExamples.length===0||r.skipAutogenerationIfManualExamplesExist===!1){let c=$Fn({ir:e,service:n,endpoint:a,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples,generationResponse:{type:"success"}});c.type==="success"&&o.push({example:c.example})}if(a.userSpecifiedExamples.filter(c=>c.example?.response.type==="error").length===0||r.skipErrorAutogenerationIfManualErrorExamplesExist===!1)for(let c of a.errors){let f=e.errors[c.error.errorId];if(!f)continue;let s=$Fn({ir:e,service:n,endpoint:a,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples,generationResponse:{type:"error",declaration:f}});s.type==="success"&&o.push({example:s.example})}a.autogeneratedExamples=o}for(let[i,n]of Object.entries(e.websocketChannels??{})){if(n.examples.length>0&&r.skipAutogenerationIfManualExamplesExist===!0)continue;let a=Fac({ir:e,channel:n,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(a.type==="failure")continue;let{example:o}=a;n.examples=[...n.examples,o]}return e}function Qac({ir:e,exampleGeneration:t}){let r={disabled:t.disabled,includeOptionalRequestPropertyExamples:t.includeOptionalRequestPropertyExamples??!1,skipAutogenerationIfManualExamplesExist:t.skipAutogenerationIfManualExamplesExist??!1,skipErrorAutogenerationIfManualErrorExamplesExist:t.skipErrorAutogenerationIfManualErrorExamplesExist??!1};for(let[i,n]of Object.entries(e.services))for(let a of n.endpoints){a.v2Examples==null&&(a.v2Examples={userSpecifiedExamples:{},autogeneratedExamples:{}});let{userFullExamples:o,autoFullExamples:c}=fs_({endpoint:a,ir:e,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(Object.keys(a.v2Examples.userSpecifiedExamples).length>0){if(Object.values(a.v2Examples.userSpecifiedExamples).some(s=>s.request!=null||s.response!=null))continue;let f=Object.values(a.v2Examples.userSpecifiedExamples).filter(s=>s!=null).flatMap(s=>s.codeSamples??[]);for(let[s,u]of Object.entries(c))c[s]={...u,codeSamples:f};for(let[s,u]of Object.entries(o))o[s]={...u,codeSamples:f}}a.v2Examples.autogeneratedExamples=c,a.v2Examples.userSpecifiedExamples=o}for(let[i,n]of Object.entries(e.websocketChannels??{})){if(n.examples.length>0&&r.skipAutogenerationIfManualExamplesExist===!0)continue;let a=Fac({ir:e,channel:n,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(a.type==="failure")continue;let{example:o}=a;n.examples=[...n.examples,o]}return e}function ps_({filteredIr:e,singleUnionTypeProperties:t}){return t._visit({samePropertiesAsObject:r=>{let i=e.hasTypeId(r.typeId)?{...r,object:{...r.object,properties:r.object.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:GS({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)}}:void 0;return i!==void 0?jB.samePropertiesAsObject(i):void 0},singleProperty:r=>{let i=GS({filteredIr:e,exampleTypeReference:r});return i!==void 0?jB.singleProperty(i):void 0},noProperties:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}})}function GS({filteredIr:e,exampleTypeReference:t}){return t.shape._visit({primitive:()=>t,container:r=>r._visit({list:i=>({...t,shape:lu.container(op.list({...i,list:i.list.map(n=>GS({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),set:i=>({...t,shape:lu.container(op.set({...i,set:i.set.map(n=>GS({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),optional:i=>{let n=i.optional!=null?GS({filteredIr:e,exampleTypeReference:i.optional}):void 0;return n!=null?{...t,shape:lu.container(op.optional({optional:n,valueType:i.valueType}))}:void 0},nullable:i=>{let n=i.nullable!=null?GS({filteredIr:e,exampleTypeReference:i.nullable}):void 0;return n!=null?{...t,shape:lu.container(op.nullable({nullable:n,valueType:i.valueType}))}:void 0},map:i=>({...t,shape:lu.container(op.map({...i,map:i.map.map(n=>{let a=GS({filteredIr:e,exampleTypeReference:n.key}),o=GS({filteredIr:e,exampleTypeReference:n.value});return a!==void 0&&o!==void 0?{key:a,value:o}:void 0}).filter(n=>n!==void 0)}))}),literal:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}}),named:r=>e.hasTypeId(r.typeName.typeId)?r.shape._visit({alias:i=>{let n=GS({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...t,shape:lu.named({...r,shape:Bh.alias({...i,value:n})})}:void 0},enum:i=>({...t,shape:lu.named({...r,shape:Bh.enum(i)})}),object:i=>({...t,shape:lu.named({...r,shape:Bh.object({...i,properties:i.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:GS({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)})})}),union:i=>{let n=ps_({filteredIr:e,singleUnionTypeProperties:i.singleUnionType.shape});return n!==void 0?{...t,shape:lu.named({...r,shape:Bh.union({...i,singleUnionType:{...i.singleUnionType,shape:n}})})}:void 0},undiscriminatedUnion:i=>{let n=GS({filteredIr:e,exampleTypeReference:i.singleUnionType});return n!==void 0?{...t,shape:lu.named({...r,shape:Bh.undiscriminatedUnion({...i,singleUnionType:n})})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}}):void 0,unknown:()=>t,_other:()=>t})}function Uac({filteredIr:e,pathParameters:t}){return t.map(r=>{let i=GS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function y$S({filteredIr:e,queryParameters:t}){return t.map(r=>{let i=GS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function ds_({filteredIr:e,headers:t}){return t.map(r=>{let i=GS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function b$S({filteredIr:e,requestBody:t}){return t._visit({inlinedRequestBody:r=>({...t,properties:r.properties.filter(i=>i.originalTypeDeclaration?e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue):!0).map(i=>{let n=GS({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...i,value:n}:void 0}).filter(i=>i!==void 0)}),reference:r=>{let i=GS({filteredIr:e,exampleTypeReference:r});return i!==void 0?T3.reference(i):void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function v$S({filteredIr:e,response:t}){return t._visit({ok:r=>r._visit({body:i=>L0.ok(xP.body(i!=null?GS({filteredIr:e,exampleTypeReference:i}):void 0)),stream:i=>L0.ok(xP.stream(i.map(n=>GS({filteredIr:e,exampleTypeReference:n})).filter(Zu))),sse:i=>L0.ok(xP.sse(i.map(({event:n,data:a})=>{let o=GS({filteredIr:e,exampleTypeReference:a});return o!==void 0?{event:n,data:o}:void 0}).filter(Zu))),_other:({type:i})=>{throw new Error(`Received unknown type for OK example: ${i}`)}}),error:({error:r,body:i})=>L0.error({error:r,body:i!=null?GS({filteredIr:e,exampleTypeReference:i}):void 0}),_other:({type:r})=>{throw new Error(`Received unknown type for example: ${r}`)}})}function Lac({filteredIr:e,example:t}){return{...t,rootPathParameters:Uac({filteredIr:e,pathParameters:t.rootPathParameters}),servicePathParameters:Uac({filteredIr:e,pathParameters:t.servicePathParameters}),endpointPathParameters:Uac({filteredIr:e,pathParameters:t.endpointPathParameters}),serviceHeaders:ds_({filteredIr:e,headers:t.serviceHeaders}),endpointHeaders:ds_({filteredIr:e,headers:t.endpointHeaders}),queryParameters:y$S({filteredIr:e,queryParameters:t.queryParameters}),request:t.request!==void 0?b$S({filteredIr:e,requestBody:t.request}):void 0,response:v$S({filteredIr:e,response:t.response})}}function _s_({filteredIr:e,exampleType:t}){return t.shape._visit({alias:r=>{let i=GS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...t,shape:Bh.alias({...r,value:i})}:void 0},enum:()=>t,object:r=>({...t,shape:Bh.object({...r,properties:r.properties.filter(i=>e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue)).map(i=>({...i,value:GS({filteredIr:e,exampleTypeReference:i.value})})).filter(i=>i.value!==void 0)})}),union:r=>{let i=ps_({filteredIr:e,singleUnionTypeProperties:r.singleUnionType.shape});return i!==void 0?{...t,shape:Bh.union({...r,singleUnionType:{...r.singleUnionType,shape:i}})}:void 0},undiscriminatedUnion:r=>{let i=GS({filteredIr:e,exampleTypeReference:r.singleUnionType});return i!==void 0?{...t,shape:Bh.undiscriminatedUnion({...r,singleUnionType:i})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function Vac(e,t){if(t==null)return e;let r=Dxi(e.types,c=>t.hasType(c)),i=Object.fromEntries(Object.entries(r).map(([c,f])=>{let s=[];if(f.userProvidedExamples=f.userProvidedExamples.map(u=>_s_({filteredIr:t,exampleType:u})).filter(u=>u!==void 0),f.shape.type==="object"){for(let u of f.shape.properties)t.hasProperty(c,u.name.wireValue)&&s.push(u);return[c,{...f,shape:Yc.object({...f.shape,properties:s})}]}return[c,f]})),n=Object.fromEntries(Object.entries(e.webhookGroups).map(([c,f])=>{let s=f.filter(u=>t.hasWebhook(u)).map(u=>{let l=u.id;return u.payload.type==="inlinedPayload"&&l!=null&&(u.payload={...u.payload,properties:u.payload.properties.filter(p=>t.hasWebhookPayloadProperty(l,p.name.wireValue))}),u});return[c,s]})),a=e.websocketChannels!=null?Object.fromEntries(Object.entries(e.websocketChannels).filter(([c])=>t.hasChannel(c)).map(([c,f])=>[c,{...f}])):{},o=e.environments;if(o){switch(o.environments.type){case"singleBaseUrl":{o.environments.environments=o.environments.environments.filter(c=>t.hasEnvironmentId(c.id));break}case"multipleBaseUrls":{o.environments.environments=o.environments.environments.filter(c=>t.hasEnvironmentId(c.id));break}}o.defaultEnvironment&&(t.hasEnvironmentId(o.defaultEnvironment)||(o.defaultEnvironment=void 0))}return{...e,environments:o,types:i,errors:Dxi(e.errors,c=>t.hasError(c)),services:_n(Dxi(e.services,c=>t.hasService(c)),c=>({...c,endpoints:c.endpoints.filter(f=>t.hasEndpoint(f)).map(f=>(f.autogeneratedExamples=f.autogeneratedExamples.map(s=>({...s,example:Lac({filteredIr:t,example:s.example})})),f.userSpecifiedExamples=f.userSpecifiedExamples.map(s=>({...s,example:s.example!=null?Lac({filteredIr:t,example:s.example}):void 0})),f.queryParameters.length>0&&(f.queryParameters=f.queryParameters.filter(s=>t.hasQueryParameter(f.id,s.name.wireValue))),f.requestBody?.type==="inlinedRequestBody"?{...f,requestBody:{...f.requestBody,properties:f.requestBody.properties.filter(s=>t.hasRequestProperty(f.id,s.name.wireValue))}}:f))})),websocketChannels:a,webhookGroups:n,serviceTypeReferenceInfo:g$S(e.serviceTypeReferenceInfo,t)}}function g$S(e,t){if(t==null)return e;let r={};return Object.entries(e.typesReferencedOnlyByService).forEach(([i,n])=>{t.hasServiceId(i)&&(r[i]=n.filter(a=>t.hasTypeId(a)))}),{sharedTypes:e.sharedTypes.filter(i=>t.hasTypeId(i)),typesReferencedOnlyByService:r}}function zKi(e){let t={};for(let[r,i]of Object.entries(e))if(typeof i!="string")for(let n of i.audiences??[])t[n]==null&&(t[n]=new Set),t[n]?.add(r);return t}function ghe(e){return e.allParts.map(t=>t.originalName).join("/")}var up={generateTypeId:e=>`type_${ghe(e.fernFilepath)}:${e.name.originalName}`,generateErrorId:e=>`error_${ghe(e.fernFilepath)}:${e.name.originalName}`,generateServiceId:e=>`service_${ghe(e.fernFilepath)}`,generateServiceIdFromFernFilepath:e=>`service_${ghe(e)}`,generateSubpackageId:e=>`subpackage_${ghe(e)}`,generateEndpointId:(e,t)=>{let r=ghe(e.fernFilepath),i=t.name.originalName;return`endpoint_${r}.${i}`},generateWebhookGroupId:e=>`webhooks_${ghe(e)}`,generateWebhookId:(e,t)=>`webhooks_${ghe(e)}.${t}`,generateWebSocketChannelId:e=>`channel_${ghe(e)}`};function ZFn(e){return e.type!=null}var OFo=class{environments=new Set;types=new Set;properties;errors=new Set;services=new Set;endpoints=new Set;requestProperties;queryParameters;webhooks=new Set;webhookPayloadProperties;channels=new Set;subpackages=new Set;constructor({types:t,properties:r,errors:i,environments:n,services:a,endpoints:o,webhooks:c,subpackages:f,queryParameters:s,requestProperties:u,webhookPayloadProperties:l,channels:p}){this.environments=n,this.types=t,this.properties=r,this.errors=i,this.services=a,this.endpoints=o,this.webhooks=c,this.webhookPayloadProperties=l,this.subpackages=f,this.requestProperties=u,this.queryParameters=s,this.channels=p}hasTypeId(t){return this.types.has(t)}hasErrorId(t){return this.errors.has(t)}hasServiceId(t){return this.services.has(t)}hasSubpackageId(t){return this.subpackages.has(t)}hasType(t){let r=up.generateTypeId(t.name);return this.types.has(r)}hasProperty(t,r){let i=this.properties[t];return i==null?!0:i.has(r)}hasError(t){let r=up.generateErrorId(t.name);return this.errors.has(r)}hasService(t){let r=up.generateServiceId(t.name);return this.services.has(r)}hasEnvironmentId(t){return this.environments.has(t)}hasEndpoint(t){return this.endpoints.has(t.id)}hasRequestProperty(t,r){let i=this.requestProperties[t];return i==null?!0:i.has(r)}hasQueryParameter(t,r){let i=this.queryParameters[t];return i==null?!0:i.has(r)}hasSubpackage(t){return this.subpackages.has(t)}hasWebhook(t){return t.id?this.webhooks.has(t.id):!0}hasChannel(t){return t?this.channels.has(t):!0}hasWebhookPayloadProperty(t,r){let i=this.webhookPayloadProperties[t];return i==null?!0:i.has(r)}};var NKi=class{types={};properties={};queryParameters={};requestProperties={};webhookProperties={};errors={};endpoints={};webhooks={};channels={};audiences;typesReferencedByService={};environmentsNeededForAudience=new Set;typesNeededForAudience=new Set;servicesNeededForAudience=new Set;endpointsNeededForAudience=new Set;webhooksNeededForAudience=new Set;channelsNeededForAudience=new Set;subpackagesNeededForAudience=new Set;constructor(t){this.audiences=O$S(t)}addType({declaredTypeName:t,descendantTypeIds:r,descendantFilepaths:i,descendantTypeIdsByAudience:n,propertiesByAudience:a}){let o=up.generateTypeId(t),c={typeId:o,allDescendants:r,descendantsByAudience:n,referencedSubpackages:i};this.types[o]=c,this.typesReferencedByService[o]==null&&(this.typesReferencedByService[o]=new Set),this.properties[o]={typeId:o,propertiesByAudience:a}}markTypeForAudiences(t,r){let i=up.generateTypeId(t);this.hasAudience(r)&&(this.typesNeededForAudience.add(i),this.addSubpackages(t.fernFilepath),this.types[i]?.referencedSubpackages.forEach(n=>{this.addSubpackages(n)}))}markEnvironmentForAudiences(t,r,i){t&&(this.hasAudience(r)||i)&&this.environmentsNeededForAudience.add(t.id)}getTypesReferencedByService(){for(let t of Object.values(this.endpoints))for(let r of t.referencedTypes)this.markTypeForService(r,t.serviceId);return this.typesReferencedByService}addError(t){let r=up.generateErrorId(t.name),i=new Set,n=new Set;t.type!=null&&XE(t.type,i,n);let a={errorId:r,referencedTypes:i,referencedSubpackages:n};this.errors[r]=a}addEndpoint(t,r,i){let n=up.generateServiceId(t.name),a=r.id,o=new Set,c=new Set,f=new Set;for(let s of[...t.headers,...r.headers])XE(s.valueType,o,f);for(let s of[...t.pathParameters,...r.pathParameters])XE(s.valueType,o,f);for(let s of r.queryParameters)XE(s.valueType,o,f);if(i!=null&&i.request!=null&&typeof i.request!="string"){let s=zKi(i.request["query-parameters"]??{});this.queryParameters[a]={endpointId:a,parametersByAudience:s}}r.requestBody!=null&&UO._visit(r.requestBody,{inlinedRequestBody:s=>{for(let u of s.extends)AFo(u,o,f);for(let u of s.properties)XE(u.valueType,o,f);if(i!=null&&typeof i.request=="object"&&typeof i.request.body=="object"&&HP(i.request.body)){let u=zKi(i.request.body.properties??{});this.requestProperties[a]={endpointId:a,propertiesByAudience:u}}},reference:({requestBodyType:s})=>{XE(s,o,f)},fileUpload:({properties:s})=>{for(let u of s)qC._visit(u,{file:Mt,bodyProperty:({valueType:l})=>{XE(l,o,f)},_other:()=>{throw new Error("Unknown FileUploadRequestProperty: "+u.type)}})},bytes:()=>{},_other:()=>{throw new Error("Unknown HttpRequestBody: "+r.requestBody?.type)}}),r.response?.body!=null&&Xf._visit(r.response.body,{fileDownload:Mt,json:s=>{XE(s.responseBodyType,o,f)},streaming:s=>{s._visit({sse:u=>XE(u.payload,o,f),json:u=>XE(u.payload,o,f),text:Mt,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.type)}})},streamParameter:s=>{s.streamResponse._visit({sse:u=>XE(u.payload,o,f),json:u=>XE(u.payload,o,f),text:Mt,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.streamResponse.type)}}),s.nonStreamResponse.type==="json"&&XE(s.nonStreamResponse.value.responseBodyType,o,f)},text:Mt,bytes:Mt,_other:()=>{throw new Error("Unknown HttpResponse: "+r.response?.body?.type)}}),r.errors.forEach(s=>{c.add(up.generateErrorId(s.error)),f.add(s.error.fernFilepath)}),this.endpoints[a]={endpointId:a,serviceId:n,referencedTypes:o,referencedErrors:c,referencedSubpackages:f}}markEndpointForAudience(t,r,i){if(this.hasAudience(i)){let n=up.generateServiceId(t);this.servicesNeededForAudience.add(n),r.forEach(a=>{let o=a.id;this.endpointsNeededForAudience.add(o),this.endpoints[o]?.referencedSubpackages.forEach(c=>{this.addSubpackages(c)})}),this.servicesNeededForAudience.add(n),this.addSubpackages(t.fernFilepath)}}getFilteredSubpackages(){return this.subpackagesNeededForAudience}getFilteredServices(){return this.servicesNeededForAudience}getFilteredEndpoints(){return this.endpointsNeededForAudience}getFilteredChannels(){return this.channelsNeededForAudience}getFilteredWebhooks(){return this.webhooksNeededForAudience}addWebhook(t,r,i){let n=r.id;if(n==null)return;let a=new Set,o=new Set;r.payload!=null&&VQ._visit(r.payload,{inlinedPayload:c=>{for(let f of c.extends)AFo(f,a,o);for(let f of c.properties)XE(f.valueType,a,o);if(i?.payload!=null&&typeof i.payload=="object"&&!ZFn(i.payload)){let f=zKi(i.payload.properties??{});this.webhookProperties[n]={webhookId:n,propertiesByAudience:f}}},reference:({payloadType:c})=>{XE(c,a,o)},_other:()=>{throw new Error("Unknown WebhookPayload: "+r.payload?.type)}}),o.add(t),this.webhooks[n]={webhookId:n,referencedTypes:a,referencedSubpackages:o}}markWebhookForAudiences(t,r,i){let n=r.id;n!=null&&this.hasAudience(i)&&(this.webhooksNeededForAudience.add(n),this.addSubpackages(t))}addChannel(t,r,i,n){if(r==null)return;let a=new Set,o=new Set;for(let c of i.messages)nz._visit(c.body,{reference:({bodyType:f})=>{XE(f,a,o)},inlinedBody:f=>{for(let s of f.extends)AFo(s,a,o);for(let s of f.properties)XE(s.valueType,a,o)},_other:()=>{}});for(let c of i.queryParameters)XE(c.valueType,a,o);o.add(t),this.channels[r]={channelId:r,referencedTypes:a,referencedSubpackages:o}}markChannelForAudiences(t,r,i){r!=null&&this.hasAudience(i)&&(this.channelsNeededForAudience.add(r),this.addSubpackages(t))}build(){let t=new Set,r=new Set;for(let c of this.endpointsNeededForAudience.keys()){let f=this.getEndpointNode(c);for(let s of f.referencedErrors){if(r.has(s))continue;r.add(s);let u=this.getErrorNode(s);this.addReferencedTypes(t,u.referencedTypes)}this.addReferencedTypes(t,f.referencedTypes)}this.addReferencedTypes(t,this.typesNeededForAudience);for(let c of this.webhooksNeededForAudience.keys()){let f=this.getWebhookNode(c);this.addReferencedTypes(t,f.referencedTypes)}for(let c of this.channelsNeededForAudience.keys()){let f=this.getChannelNode(c);this.addReferencedTypes(t,f.referencedTypes)}let i={},n={},a={},o={};if(this.audiences.type==="filtered"){for(let[c,f]of Object.entries(this.properties)){if(!t.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.propertiesByAudience[u];l?.forEach(p=>{s.add(p)})}s.size>0&&(i[c]=s),i[c]=s.size>0?s:void 0}for(let[c,f]of Object.entries(this.requestProperties)){if(!this.endpointsNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.propertiesByAudience[u];l?.forEach(p=>{s.add(p)})}n[c]=s.size>0?s:void 0}for(let[c,f]of Object.entries(this.queryParameters)){if(!this.endpointsNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.parametersByAudience[u];l?.forEach(p=>{s.add(p)})}a[c]=s.size>0?s:void 0}for(let[c,f]of Object.entries(this.webhookProperties)){if(!this.webhooksNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.propertiesByAudience[u];l?.forEach(p=>{s.add(p)})}o[c]=s.size>0?s:void 0}}return new OFo({types:t,properties:i,errors:r,requestProperties:n,queryParameters:a,environments:this.environmentsNeededForAudience,services:this.servicesNeededForAudience,endpoints:this.endpointsNeededForAudience,webhooks:this.webhooksNeededForAudience,webhookPayloadProperties:o,subpackages:this.subpackagesNeededForAudience,channels:this.channelsNeededForAudience})}markTypeForService(t,r){let i=this.typesReferencedByService[t]??=new Set;if(i.has(r))return;i.add(r);let n=this.getTypeNode(t);for(let a of n.allDescendants)this.markTypeForService(a,r)}addReferencedTypes(t,r){for(let i of r){if(t.has(i))continue;t.add(i);let n=this.getTypeNode(i);if(this.audiences.type==="filtered")for(let a of this.audiences.audiences){let o=n.descendantsByAudience[a];if(o!=null)o.forEach(c=>{t.add(c)});else{n.allDescendants.forEach(c=>{t.add(c)});break}}else n.allDescendants.forEach(a=>{t.add(a)})}}getTypeNode(t){let r=this.types[t];if(r==null)throw new Error(`Failed to find type node with id ${t}`);return r}getErrorNode(t){let r=this.errors[t];if(r==null)throw new Error(`Failed to find error node with id ${t}`);return r}getEndpointNode(t){let r=this.endpoints[t];if(r==null)throw new Error(`Failed to find endpoint node with id ${t}`);return r}getWebhookNode(t){let r=this.webhooks[t];if(r==null)throw new Error(`Failed to find webhook node with id ${t}`);return r}getChannelNode(t){let r=this.channels[t];if(r==null)throw new Error(`Failed to find channel node with id ${t}`);return r}hasNoAudiences(){return this.audiences.type==="none"}hasAudience(t){let r=this.audiences;switch(r.type){case"none":return!0;case"filtered":return t.some(i=>r.audiences.has(i));default:Ot(r)}}addSubpackages(t){for(let r=1;r<=t.allParts.length;++r){let i={...t,allParts:t.allParts.slice(0,r)};this.subpackagesNeededForAudience.add(up.generateSubpackageId(i))}}};function O$S(e){switch(e.type){case"all":return{type:"none"};case"select":return{type:"filtered",audiences:new Set(e.audiences)};default:Ot(e)}}function XE(e,t,r){ii._visit(e,{container:i=>{A$S(i,t,r)},named:i=>{AFo(i,t,r)},primitive:Mt,unknown:Mt,_other:Mt})}function AFo(e,t,r){t.add(up.generateTypeId(e)),r.add(e.fernFilepath)}function A$S(e,t,r){ns._visit(e,{list:i=>{XE(i,t,r)},map:i=>{XE(i.keyType,t,r),XE(i.valueType,t,r)},optional:i=>{XE(i,t,r)},nullable:i=>{XE(i,t,r)},set:i=>{XE(i,t,r)},literal:Mt,_other:Mt})}var m$S=[vr.AvailabilityStatus.GeneralAvailability];function qvi(e){return e!==void 0&&!m$S.includes(e.status)}var Wac=class{errors;constructor(){this.errors=[]}add(t){this.errors.push({message:t})}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}},rPa=class{errors;constructor(){this.errors=new Wac}async check({from:t,to:r}){let i=this.toInternalIr(t),n=this.toInternalIr(r),a=OCi(i),o=OCi(n);if(a===o)return{bump:"no_change",isBreaking:!1,errors:[]};let c=this.checkBreaking({from:i,to:n});return{bump:c.isBreaking?"major":"minor",isBreaking:c.isBreaking,errors:c.errors}}toInternalIr(t){return{types:t.types,errors:t.errors,services:t.services}}checkBreaking({from:t,to:r}){this.checkTypeBreakingChanges({from:t.types,to:r.types}),this.checkErrorsBreakingChanges({from:t.errors,to:r.errors}),this.checkServicesBreakingChanges({from:t.services,to:r.services});let i=this.errors.hasErrors();return{bump:i?"major":"minor",isBreaking:i,errors:this.errors.getErrors()}}checkTypeBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){if(qvi(n.availability))continue;let a=r[i];if(!a){this.errors.add(`Type "${i}" was removed.`);continue}if(qvi(a.availability)){this.errors.add(`Type "${i}" was moved from stable to unstable availability status.`);continue}this.areTypeDeclarationsCompatible({from:n,to:a})||this.errors.add(`Type "${i}" has an incompatible change.`)}}checkErrorsBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){let a=Object.values(r).find(o=>o.name.errorId===n.name.errorId);if(!a){this.errors.add(`Error "${n.name.errorId}" with status code "${n.statusCode}" was removed.`);continue}this.checkErrorBreakingChanges({from:n,to:a})}}checkErrorBreakingChanges({from:t,to:r}){if(t.type!=null){if(r.type==null){this.errors.add(`Error "${t.name.errorId}" with status code "${t.statusCode}" had its type removed.`);return}this.areTypeReferencesCompatible({from:t.type,to:r.type})||this.errors.add(`Error "${t.name.errorId}" type reference changed.`)}this.areDeclaredErrorNamesCompatible({from:t.name,to:r.name})||this.errors.add(`Error "${t.name.errorId}" name changed.`),this.areNameAndWireValuesCompatible({from:t.discriminantValue,to:r.discriminantValue})||this.errors.add(`Error "${t.name.errorId}" discriminant value changed.`)}checkServicesBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){if(qvi(n.availability)||(n.endpoints?.every(o=>qvi(o.availability))??!1))continue;let a=r[i];if(!a){this.errors.add(`Service "${i}" was removed.`);continue}if(qvi(a.availability)){this.errors.add(`Service "${i}" was moved from stable to unstable availability status.`);continue}this.checkServiceBreakingChanges({id:i,from:n,to:a})}}checkServiceBreakingChanges({id:t,from:r,to:i}){this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),this.checkEndpointsBreakingChanges({id:t,from:r,to:i})}checkEndpointsBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.endpoints.map(o=>[o.id,o])),a=Object.fromEntries(i.endpoints.map(o=>[o.id,o]));for(let[o,c]of Object.entries(n)){if(qvi(c.availability))continue;let f=a[o];if(!f){this.errors.add(`Endpoint "${o}" was removed.`);continue}if(qvi(f.availability)){this.errors.add(`Endpoint "${o}" was moved from stable to unstable availability status.`);continue}this.checkEndpointBreakingChanges({id:o,from:c,to:f})}}checkEndpointBreakingChanges({id:t,from:r,to:i}){this.checkHttpMethodsBreakingChanges({id:t,from:r.method,to:i.method}),this.checkHttpPathsBreakingChanges({id:t,from:r.fullPath,to:i.fullPath}),this.checkPathParametersBreakingChanges({id:t,from:r.pathParameters,to:i.pathParameters}),this.checkQueryParametersBreakingChanges({id:t,from:r.queryParameters,to:i.queryParameters}),this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),r.requestBody!=null&&(i.requestBody!=null?this.checkHttpRequestBodiesCompatible({id:t,from:r.requestBody,to:i.requestBody}):this.errors.add(`Request body was removed from endpoint "${r.id}".`)),r.response!=null&&(i.response!=null?this.checkHttpResponseBreakingChanges({id:t,from:r.response,to:i.response}):this.errors.add(`Response was removed from endpoint "${r.id}".`)),(r.pagination!=null&&i.pagination==null||r.pagination==null&&i.pagination!=null)&&this.errors.add(`Pagination was ${r.pagination!=null?"added":"removed"} from endpoint "${r.id}".`)}checkPathParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.originalName,o])),a=Object.fromEntries(i.map(o=>[o.name.originalName,o]));for(let[o,c]of Object.entries(n)){let f=a[o];if(!f){this.errors.add(`Path parameter "${o}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:f.valueType})||this.errors.add(`Path parameter "${o}" type changed in endpoint "${t}".`)}}checkQueryParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.wireValue,o])),a=Object.fromEntries(i.map(o=>[o.name.wireValue,o]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([o,c])=>[o,c.valueType])),to:Object.fromEntries(Object.entries(a).map(([o,c])=>[o,c.valueType]))});for(let[o,c]of Object.entries(n)){let f=a[o];if(!f){this.errors.add(`Query parameter "${o}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:f.valueType})||this.errors.add(`Query parameter "${o}" type changed in endpoint "${t}".`),c.allowMultiple!==f.allowMultiple&&this.errors.add(`Query parameter "${o}" allow-multiple values changed in endpoint "${t}".`)}}checkHeadersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.wireValue,o])),a=Object.fromEntries(i.map(o=>[o.name.wireValue,o]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([o,c])=>[o,c.valueType])),to:Object.fromEntries(Object.entries(a).map(([o,c])=>[o,c.valueType]))});for(let[o,c]of Object.entries(n)){let f=a[o];if(!f){this.errors.add(`Header "${o}" was removed from ${t}.`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:f.valueType})||this.errors.add(`Header "${o}" type changed in ${t}.`)}}checkHttpMethodsBreakingChanges({id:t,from:r,to:i}){r!==i&&this.errors.add(`HTTP method changed in ${t}.`)}checkHttpPathsBreakingChanges({id:t,from:r,to:i}){this.areHttpPathsCompatible({from:r,to:i})||this.errors.add(`HTTP path changed in ${t}.`)}areHttpPathsCompatible({from:t,to:r}){if(t.head!==r.head||t.parts.length!==r.parts.length)return!1;for(let i=0;i<t.parts.length;i++){let n=t.parts[i];if(n==null)return!1;let a=r.parts[i];if(a==null||n.pathParameter!==a.pathParameter||n.tail!==a.tail)return!1}return!0}checkHttpRequestBodiesCompatible({id:t,from:r,to:i}){switch(r.type){case"inlinedRequestBody":if(i.type==="inlinedRequestBody"&&this.areInlinedRequestBodiesCompatible({from:r,to:i}))return;break;case"reference":if(i.type==="reference"&&this.areReferenceRequestBodiesCompatible({from:r,to:i}))return;break;case"fileUpload":if(i.type==="fileUpload"&&this.areFileUploadRequestBodiesCompatible({from:r,to:i}))return;break;case"bytes":if(i.type==="bytes")return;break;default:Ot(r)}this.errors.add(`Request body type changed from "${r.type}" to "${i.type}" in endpoint "${t}".`)}areInlinedRequestBodiesCompatible({from:t,to:r}){let i=this.getInlinedRequestBody(t),n=this.getInlinedRequestBody(r);return this.checkForNewInlinedRequestBodyProperties({from:i,to:n}),Object.entries(i).every(([a,o])=>{let c=n[a];return c?this.areTypeReferencesCompatible({from:o,to:c}):(this.errors.add(`Request body property "${a}" was removed.`),!1)})}areReferenceRequestBodiesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.requestBodyType,to:r.requestBodyType})}areFileUploadRequestBodiesCompatible({from:t,to:r}){let i=this.getFileUploadRequest(t.properties),n=this.getFileUploadRequest(r.properties);this.checkForNewFileUploadRequestProperties({from:i,to:n});for(let[a,o]of Object.entries(i)){let c=n[a];if(!c)return this.errors.add(`File upload property "${a}" was removed.`),!1;if(o==="file"&&c!=="file")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(o==="fileArray"&&c!=="fileArray")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(o!=="file"&&o!=="fileArray"&&c!=="file"&&c!=="fileArray"&&!this.areTypeReferencesCompatible({from:o,to:c}))return this.errors.add(`File upload property "${a}" type changed.`),!1}return!0}checkHttpResponseBreakingChanges({id:t,from:r,to:i}){if(r.statusCode!==i.statusCode&&this.errors.add(`Response status code changed from "${r.statusCode}" to "${i.statusCode}".`),!(r.body==null&&i.body==null)){if(r.body==null||i.body==null){this.errors.add(`Response body was ${r.body==null?"added":"removed"}.`);return}switch(r.body.type){case"json":if(i.body.type==="json"){this.areJsonResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"fileDownload":if(i.body.type==="fileDownload")return;break;case"text":if(i.body.type==="text")return;break;case"bytes":if(i.body.type==="bytes")return;break;case"streaming":if(i.body.type==="streaming"){this.areStreamingResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"streamParameter":if(i.body.type==="streamParameter"){this.areStreamingResponsesCompatible({from:r.body.streamResponse,to:i.body.streamResponse});return}break;default:Ot(r.body)}this.errors.add(`HTTP response type "${r.body.type}" defined for endpoint "${t}" is not compatible with type "${i.body.type}".`)}}areJsonResponsesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.responseBodyType,to:r.responseBodyType})}areStreamingResponsesCompatible({from:t,to:r}){switch(t.type){case"json":if(r.type==="json")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"sse":if(r.type==="sse")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"text":if(r.type==="text")return!0;break;default:Ot(t)}return this.errors.add(`Streaming response type "${t.type}" is not compatible with type "${r.type}".`),!1}areTypeDeclarationsCompatible({from:t,to:r}){return qvi(t.availability)?!0:this.areDeclaredTypeNamesCompatible({from:t.name,to:r.name})&&this.areTypeShapesCompatible({from:t.shape,to:r.shape})}areTypeShapesCompatible({from:t,to:r}){switch(t.type){case"alias":if(r.type==="alias")return this.areAliasTypesCompatible({from:t,to:r});break;case"enum":if(r.type==="enum")return this.areEnumTypesCompatible({from:t,to:r});break;case"object":if(r.type==="object")return this.areObjectTypesCompatible({from:t,to:r});break;case"union":if(r.type==="union")return this.areUnionTypesCompatible({from:t,to:r});break;case"undiscriminatedUnion":if(r.type==="undiscriminatedUnion")return this.areUndiscriminatedUnionTypesCompatible({from:t,to:r});break;default:Ot(t)}return this.errors.add(`Type "${t.type}" is not compatible with type "${r.type}".`),!1}areAliasTypesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.aliasOf,to:r.aliasOf})}areEnumTypesCompatible({from:t,to:r}){let i=Object.fromEntries(t.values.map(a=>[a.name.wireValue,a])),n=Object.fromEntries(r.values.map(a=>[a.name.wireValue,a]));return Object.keys(i).length!==Object.keys(n).length?!1:Object.values(i).every(a=>{let o=n[a.name.wireValue];return o?this.areNameAndWireValuesCompatible({from:a.name,to:o.name}):(this.errors.add(`Enum value "${a.name.wireValue}" was removed.`),!1)})}areObjectTypesCompatible({from:t,to:r}){let i=Object.fromEntries([...t.properties.map(a=>[a.name.wireValue,a]),...t.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]),n=Object.fromEntries([...r.properties.map(a=>[a.name.wireValue,a]),...r.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]);return this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(i).map(([a,o])=>[a,o.valueType])),to:Object.fromEntries(Object.entries(n).map(([a,o])=>[a,o.valueType]))}),Object.values(i).every(a=>{let o=n[a.name.wireValue];return o?this.areObjectPropertiesCompatible({from:a,to:o}):(this.errors.add(`Object property "${a.name.wireValue}" was removed.`),!1)})}areObjectPropertiesCompatible({from:t,to:r}){return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType})}areUnionTypesCompatible({from:t,to:r}){if(!this.areNameAndWireValuesCompatible({from:t.discriminant,to:r.discriminant}))return this.errors.add(`Union type with discriminant value "${t.discriminant.wireValue}" changed.`),!1;let i=new Set(t.extends.map(s=>this.getKeyForDeclaration(s))),n=new Set(r.extends.map(s=>this.getKeyForDeclaration(s)));for(let s of i)if(!n.has(s))return this.errors.add(`Extended type "${s}" was removed.`),!1;let a=Object.fromEntries(t.baseProperties.map(s=>[s.name.wireValue,s])),o=Object.fromEntries(r.baseProperties.map(s=>[s.name.wireValue,s]));for(let s of Object.values(a)){let u=o[s.name.wireValue];if(!u)return this.errors.add(`Union type with discriminant value "${s.name.wireValue}" no longer has a property named "${s.name.wireValue}".`),!1;if(!this.areObjectPropertiesCompatible({from:s,to:u}))return!1}this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(a).map(([s,u])=>[s,u.valueType])),to:Object.fromEntries(Object.entries(o).map(([s,u])=>[s,u.valueType]))});let c=Object.fromEntries(t.types.map(s=>[s.discriminantValue.wireValue,s])),f=Object.fromEntries(r.types.map(s=>[s.discriminantValue.wireValue,s]));return Object.values(c).every(s=>{let u=f[s.discriminantValue.wireValue];return u?this.areSingleUnionTypesCompatible({from:s.shape,to:u.shape}):(this.errors.add(`Union type for discriminant value "${s.discriminantValue.wireValue}" was removed.`),!1)})}areSingleUnionTypesCompatible({from:t,to:r}){switch(t.propertiesType){case"samePropertiesAsObject":if(r.propertiesType==="samePropertiesAsObject")return this.areDeclaredTypeNamesCompatible({from:t,to:r});break;case"singleProperty":if(r.propertiesType==="singleProperty")return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.type,to:r.type});break;case"noProperties":if(r.propertiesType==="noProperties")return!0;break;default:Ot(t)}return this.errors.add(`Single union type of style "${t.propertiesType}" is not compatible with style "${r.propertiesType}".`),!1}areUndiscriminatedUnionTypesCompatible({from:t,to:r}){return t.members.every((i,n)=>{let a=r.members[n];return a?this.areTypeReferencesCompatible({from:i.type,to:a.type}):(this.errors.add(`Undiscriminated union member at index ${n} was removed.`),!1)})}checkForNewRequiredTypeReferences({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewFileUploadRequestProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||n==="file"||n==="fileArray"||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewInlinedRequestBodyProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}areTypeReferencesCompatible({from:t,to:r}){switch(t.type){case"primitive":if(r.type==="primitive")return this.arePrimitiveTypesCompatible({from:t,to:r});break;case"container":if(r.type==="container")return this.areContainerTypesCompatible({from:t.container,to:r.container});break;case"named":if(r.type==="named")return this.areNamedTypesCompatible({from:t,to:r});break;case"unknown":if(r.type==="unknown")return!0;break;default:Ot(t)}return this.errors.add(`TypeReference "${t.type}" is not compatible with type "${r.type}".`),!1}arePrimitiveTypesCompatible({from:t,to:r}){return t.primitive.v1===r.primitive.v1}areContainerTypesCompatible({from:t,to:r}){switch(t.type){case"list":if(r.type==="list")return this.areTypeReferencesCompatible({from:t.list,to:r.list});break;case"set":if(r.type==="set")return this.areTypeReferencesCompatible({from:t.set,to:r.set});break;case"map":if(r.type==="map")return this.areTypeReferencesCompatible({from:t.keyType,to:r.keyType})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType});break;case"optional":if(r.type==="optional")return this.areTypeReferencesCompatible({from:t.optional,to:r.optional});break;case"nullable":if(r.type==="nullable")return this.areTypeReferencesCompatible({from:t.nullable,to:r.nullable});break;case"literal":if(r.type==="literal")return this.areLiteralsCompatible({from:t.literal,to:r.literal});break;default:Ot(t)}return this.errors.add(`Container type "${t.type}" is not compatible with type "${r.type}".`),!1}areNamedTypesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredTypeNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredErrorNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areNameAndWireValuesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&t.wireValue===r.wireValue}areLiteralsCompatible({from:t,to:r}){switch(t.type){case"boolean":if(r.type==="boolean")return t.boolean===r.boolean;break;case"string":if(r.type==="string")return t.string===r.string;break;default:Ot(t)}return!1}areFernFilepathsCompatible({from:t,to:r}){return t.allParts.length!==r.allParts.length?!1:t.allParts.every((i,n)=>{let a=r.allParts[n];return a==null?!1:this.areNamesCompatible({from:i,to:a})})}areNamesCompatible({from:t,to:r}){return t.originalName===r.originalName}getInlinedRequestBody(t){let r={};for(let i of[...t.extendedProperties??[],...t.properties])r[i.name.wireValue]=i.valueType;return r}getFileUploadRequest(t){let r={};for(let i of t)switch(i.type){case"file":r[i.value.key.wireValue]="file";break;case"bodyProperty":r[i.name.wireValue]=i.valueType;break;default:Ot(i)}return r}getKeyForDeclaration({name:t,fernFilepath:r}){return`${r.allParts.map(n=>n.camelCase.unsafeName).join(".")}.${t.pascalCase.unsafeName}`}};function FKi(e,t,r){let{environments:i,changedBaseUrlIds1:n,changedBaseUrlIds2:a}=j$S(e.environments,t.environments,r),{services:o,websocketChannels:c}=w$S(e,t,n,a);return{apiName:e.apiName,basePath:e.basePath,selfHosted:e.selfHosted&&t.selfHosted,apiDisplayName:e.apiDisplayName??t.apiDisplayName,apiDocs:e.apiDocs??t.apiDocs,auth:{requirement:e.auth?.requirement??t.auth?.requirement,schemes:t.auth?.schemes?.length!=null&&t.auth.schemes.length>(e.auth?.schemes?.length??0)?t.auth.schemes:e.auth?.schemes??[],docs:e.auth?.docs??t.auth?.docs},headers:[...e.headers??[],...t.headers??[]],environments:i,types:{...e.types??{},...t.types??{}},constants:{...e.constants??{},...t.constants??{}},errors:{...e.errors??{},...t.errors??{}},services:o,webhookGroups:{...e.webhookGroups??{},...t.webhookGroups??{}},subpackages:P$S(e.subpackages,t.subpackages),websocketChannels:c,rootPackage:{service:e.rootPackage.service??t.rootPackage.service,types:[...e.rootPackage.types??[],...t.rootPackage.types??[]],errors:[...e.rootPackage.errors??[],...t.rootPackage.errors??[]],subpackages:[...e.rootPackage.subpackages??[],...(t.rootPackage.subpackages??[]).filter(f=>!e.rootPackage.subpackages?.includes(f))],fernFilepath:e.rootPackage.fernFilepath??t.rootPackage.fernFilepath,webhooks:e.rootPackage.webhooks??t.rootPackage.webhooks,websocket:e.rootPackage.websocket??t.rootPackage.websocket,hasEndpointsInTree:e.rootPackage.hasEndpointsInTree||t.rootPackage.hasEndpointsInTree,navigationConfig:e.rootPackage.navigationConfig??t.rootPackage.navigationConfig,docs:e.rootPackage.docs??t.rootPackage.docs},fdrApiDefinitionId:e.fdrApiDefinitionId??t.fdrApiDefinitionId,apiVersion:e.apiVersion??t.apiVersion,idempotencyHeaders:[...e.idempotencyHeaders??[],...t.idempotencyHeaders??[]],pathParameters:[...e.pathParameters??[],...t.pathParameters??[]],errorDiscriminationStrategy:e.errorDiscriminationStrategy??t.errorDiscriminationStrategy,variables:[...e.variables??[],...t.variables??[]],serviceTypeReferenceInfo:e.serviceTypeReferenceInfo??t.serviceTypeReferenceInfo,readmeConfig:e.readmeConfig??t.readmeConfig,sourceConfig:e.sourceConfig??t.sourceConfig,publishConfig:e.publishConfig??t.publishConfig,dynamic:e.dynamic??t.dynamic,sdkConfig:e.sdkConfig??t.sdkConfig,audiences:[...e.audiences??[],...t.audiences??[]],generationMetadata:e.generationMetadata??t.generationMetadata,apiPlayground:e.apiPlayground??t.apiPlayground}}function P$S(e,t){let r=e;for(let[i,n]of Object.entries(t))r[i]==null?r[i]=n:r[i]={name:n.name,displayName:n.displayName,fernFilepath:n.fernFilepath,hasEndpointsInTree:r[i].hasEndpointsInTree||n.hasEndpointsInTree,navigationConfig:r[i].navigationConfig??n.navigationConfig,docs:r[i].docs??n.docs,service:r[i].service??n.service,subpackages:[...r[i].subpackages??[],...(n.subpackages??[]).filter(a=>!r[i]?.subpackages?.includes(a))],webhooks:r[i].webhooks??n.webhooks,websocket:r[i].websocket??n.websocket,errors:[...r[i].errors??[],...n.errors??[]],types:[...r[i].types??[],...n.types??[]]};return r}function j$S(e,t,r){if(e==null&&t==null)return{environments:void 0,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(t==null)return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(e==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(JSON.stringify(e)===JSON.stringify(t))return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let i=hs_(e),n=hs_(t);if(i&&n&&e.environments.type==="singleBaseUrl"&&t.environments.type==="singleBaseUrl")return{environments:{defaultEnvironment:e.defaultEnvironment??t.defaultEnvironment,environments:$E.singleBaseUrl({environments:[...e.environments.environments,...t.environments.environments]})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let a=i?t.defaultEnvironment:e.defaultEnvironment,o=e.environments,c=t.environments;if(o.type==="singleBaseUrl"&&c.type==="singleBaseUrl"){let f=i?c:o,s=i?o:c,u={},{deconflictedEnvironments2:l,changedBaseUrlIds2:p}=E$S(f,s,r);if(f.environments[0]==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let _="Base",h=r.generateName("Base");return f.environments.forEach(y=>{u[y.id]=_}),{environments:{defaultEnvironment:a,environments:$E.multipleBaseUrls({baseUrls:[{id:_,name:h},...l.environments.map(y=>({id:y.id,name:y.name}))],environments:f.environments.map(y=>({id:y.id,name:y.name,urls:{[_]:y.url,...Object.fromEntries(l.environments.map(b=>[b.id,b.url]))},docs:void 0}))})},changedBaseUrlIds1:i?p:u,changedBaseUrlIds2:i?u:p}}if(o.type==="multipleBaseUrls"&&c.type==="singleBaseUrl"||o.type==="singleBaseUrl"&&c.type==="multipleBaseUrls"){let f=o.type==="singleBaseUrl"?o:c,s=o.type==="multipleBaseUrls"?o:c,{deconflictedEnvironments1:u,changedBaseUrlIds1:l}=S$S(f,s,r);return{environments:{defaultEnvironment:a,environments:$E.multipleBaseUrls({baseUrls:[...s.baseUrls,...u.environments.map(p=>({id:p.id,name:p.name}))],environments:s.environments.map(p=>({...p,urls:{...p.urls,...Object.fromEntries(u.environments.map(_=>[_.id,_.url]))}}))})},changedBaseUrlIds1:o.type==="singleBaseUrl"?l:void 0,changedBaseUrlIds2:o.type==="singleBaseUrl"?void 0:l}}if(o.type==="multipleBaseUrls"&&c.type==="multipleBaseUrls"){let{deconflictedEnvironments:f,changedBaseUrlIds:s}=M$S(o,c,r);return{environments:{defaultEnvironment:a,environments:$E.multipleBaseUrls({baseUrls:[...o.baseUrls,...f.baseUrls],environments:o.environments.flatMap(u=>f.environments.map(l=>({...u,urls:{...u.urls,...l.urls}})))})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:s}}return{environments:e??t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0}}function w$S(e,t,r,i){if(r!=null)for(let[o,c]of Object.entries(r)){for(let f of Object.values(e.services))for(let s of Object.values(f.endpoints))s.baseUrl==o&&(s.baseUrl=c),s.v2BaseUrls?.includes(o)&&(s.v2BaseUrls=s.v2BaseUrls.map(u=>u===o?c:u));for(let f of Object.values(e.websocketChannels??{}))f.baseUrl==o&&(f.baseUrl=c)}if(i!=null)for(let[o,c]of Object.entries(i)){for(let f of Object.values(t.services))for(let s of Object.values(f.endpoints))s.baseUrl==o&&(s.baseUrl=c),s.v2BaseUrls?.includes(o)&&(s.v2BaseUrls=s.v2BaseUrls.map(u=>u===o?c:u));for(let f of Object.values(t.websocketChannels??{}))f.baseUrl==o&&(f.baseUrl=c)}let n=e.services;for(let[o,c]of Object.entries(t.services))n[o]==null?n[o]=c:n[o]={availability:c.availability,name:c.name,displayName:c.displayName,basePath:c.basePath,endpoints:[...n[o].endpoints??[],...c.endpoints],pathParameters:[...n[o].pathParameters??[],...c.pathParameters??[]],headers:[...n[o].headers??[],...c.headers??[]],encoding:c.encoding,transport:c.transport,audiences:[...n[o].audiences??[],...c.audiences??[]]};let a={...e.websocketChannels??{},...t.websocketChannels??{}};return{services:n,websocketChannels:a}}function E$S(e,t,r){let i={},n=new Set(e.environments.map(s=>s.id)),a=new Set(e.environments.map(s=>s.name)),o=new Map(e.environments.map(s=>[s.url,s.id])),c=t.environments.filter(s=>{let u=o.get(s.url);return u!=null?(i[s.id]=u,!1):!0}).map(s=>{if(n.has(s.id)||a.has(s.name)){let u=xac(s.id,n);return i[s.id]=u,{...s,id:u,name:r.generateName(u)}}return s});return{deconflictedEnvironments2:$E.singleBaseUrl({environments:c}),changedBaseUrlIds2:i}}function S$S(e,t,r){let i={},n=new Set(t.baseUrls.map(f=>f.id)),a=new Set(t.baseUrls.map(f=>f.name)),o=e.environments.map(f=>{if(n.has(f.id)||a.has(f.name)){let s=xac(f.id,n);return i[f.id]=s,{...f,id:s,name:r.generateName(s)}}return f});return{deconflictedEnvironments1:$E.singleBaseUrl({environments:o}),changedBaseUrlIds1:i}}function M$S(e,t,r){let i={},n=new Set(e.baseUrls.map(s=>s.id)),a=new Set(e.baseUrls.map(s=>s.name)),o=t.baseUrls.map(s=>{if(n.has(s.id)||a.has(s.name)){let u=xac(s.id,n);return i[s.id]=u,{...s,id:u,name:r.generateName(u)}}return s}),c=t.environments.map(s=>({...s,urls:Object.fromEntries(Object.entries(s.urls).map(([u,l])=>[i[u]??u,l]))}));return{deconflictedEnvironments:$E.multipleBaseUrls({baseUrls:o,environments:c}),changedBaseUrlIds:i}}function hs_(e){return e.environments.type==="singleBaseUrl"?e.environments.environments.some(t=>t.url&&(t.url.startsWith("ws://")||t.url.startsWith("wss://"))):e.environments.type==="multipleBaseUrls"?e.environments.environments.some(t=>Object.values(t.urls).some(r=>r&&(r.startsWith("ws://")||r.startsWith("wss://")))):!1}function xac(e,t){let r=e,i=1;for(;t.has(r);)r=`${e}-${i}`,i++;return r}var Oa=class e{breadcrumbs=[];context;static STRING=vr.TypeReference.primitive({v1:"STRING",v2:vr.PrimitiveTypeV2.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=vr.TypeReference.container(vr.ContainerType.optional(e.STRING));constructor({breadcrumbs:t=[],context:r}){this.breadcrumbs=t,this.context=r}};var bs_=require("fs/promises");var Gac=class{_map;_path;_lastScalar;_fragments;_count;constructor(){this._map={},this._path=[],this._lastScalar="",this._fragments=[],this._count=0}get map(){return this._map}resolveNode(t,r){if(t.path==="."&&(r="."),!this._map[r]){let{line:i,position:n,lineStart:a}=t;this._map[r]={line:i,position:n,lineStart:a}}t.children&&t.children.length>0&&t.children.forEach(i=>{this.resolveNode(i,(r==="."?"":r)+"."+i.path)})}iterFragments(t,r){for(let i=this._fragments.length-1;i>=0;i--){if(!this._fragments[i].path.startsWith(t)||this._fragments[i].path===t)continue;let n=this._fragments.pop();r(n)}}handleState(t,r){if(t==="close"){let i=r.result,n=r.kind,a=this._path.join(".");if(n==="scalar"){this._path.pop(),this._lastScalar=`${i}`;let{line:o,position:c,lineStart:f}=r;this._path.length===0?this._map["."+i]={line:o,position:c,lineStart:f}:this._fragments.push({path:this._path.join(".")+"."+i,line:o,position:c,lineStart:f})}else if(n==="mapping"){let o={path:a,children:[],line:0,position:0,lineStart:0},c=0;this.iterFragments(a,f=>{c++,!((!f.children||f.children.length===0)&&c%2===1)&&(this._path.length===1?this.resolveNode(f,f.path):(o.children.push({...f,path:f.path.slice(a.length+1)}),o.line=f.line,o.position=f.position,o.lineStart=f.lineStart))}),o.children&&o.children.length>0&&this._fragments.push(o),this._path.pop()}else if(n==="sequence"){let o={path:a,children:[],line:0,position:0,lineStart:0},c=new Set,f=i.length;this.iterFragments(a,s=>{c.has(s.position)||(f--,c.add(s.position),this._path.length===1?this.resolveNode(s,`${a}.${f}`):(o.children.push({...s,path:f.toString()}),o.line=s.line,o.position=s.position,o.lineStart=s.lineStart))}),o.children&&o.children.length>0&&this._fragments.push(o),this._path.pop()}else this._path.pop()}if(t==="open"){if(this._count===0){let{line:i,position:n,lineStart:a}=r;this._map["."]={line:i,position:n,lineStart:a}}this._path.push(this._lastScalar),this._count++}}listen(){return this.handleState.bind(this)}lookup(t){let r=t instanceof Array?t.map(n=>`${n}`).join("."):`${t}`;r.startsWith(".")||(r="."+r),r.startsWith("..")&&(r=r.slice(1)),r=r.replace(/\[/g,".").replace(/\]/g,"");let i=this._map[r];if(i)return{line:i.line+1,column:i.position-i.lineStart+1,position:i.position}}},ys_=Gac;var B1;(function(e){e.WARNING="warning",e.ERROR="error"})(B1||(B1={}));var z0e=class{errors=[];logger;breadcrumbToLineNumberMapper;relativeFilepathToSpec;constructor({logger:t,relativeFilepathToSpec:r}){this.logger=t,this.relativeFilepathToSpec=r,r&&(this.breadcrumbToLineNumberMapper=new Hac({logger:t,relativePathToFile:Ze.of(r)}))}collect(t){this.errors.push(t)}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}dedupe(){let t=[],r=new Set,i=0;for(let n of this.errors){let a=n.path?n.path.join("->"):"",o=`${n.message}|${n.level||B1.WARNING}|${a}`;r.has(o)?i++:(r.add(o),t.push(n))}return this.errors=t,i}getErrorStats(){this.dedupe();let t=0,r=0;for(let i of this.errors)i.level===B1.ERROR?t++:(i.level===B1.WARNING||i.level===void 0)&&r++;return{numErrors:t,numWarnings:r}}async logErrors({logWarnings:t}){this.dedupe();for(let r of this.errors){let i=r.level??B1.WARNING;if(!(i===B1.WARNING&&!t))switch(i){case B1.ERROR:if(this.logger.log($s.Debug,r.message),r.path&&r.path.length>0){let n=await this.breadcrumbToLineNumberMapper?.getSourceLocation(r.path),a=n?`${this.relativeFilepathToSpec}:${n.line}:${n.column}`:r.path.join(" -> ");this.logger.log($s.Debug,` - at location (${a})`)}break;case B1.WARNING:if(this.logger.log($s.Warn,r.message),r.path&&r.path.length>0){let n=await this.breadcrumbToLineNumberMapper?.getSourceLocation(r.path),a=n?`${this.relativeFilepathToSpec}:${n.line}:${n.column}`:r.path.join(" -> ");this.logger.log($s.Warn,` - at location (${a})`)}r.resolution&&this.logger.log($s.Warn,` - resolution: ${r.resolution}`);break}}}},Hac=class{logger;relativePathToFile;map=new ys_;initialized=!1;constructor({relativePathToFile:t,logger:r}){this.relativePathToFile=t,this.logger=r}async initialize(){if(!this.initialized)try{let t=await(0,bs_.readFile)(this.relativePathToFile,"utf-8");wi.load(t,{listener:this.map.listen()}),this.initialized=!0}catch(t){this.logger.log($s.Warn,`Failed to initialize line number mapping for ${this.relativePathToFile}: ${JSON.stringify(t)}`)}}async getSourceLocation(t){return this.initialized||await this.initialize(),this.map.lookup(t)}};var SB=class e{args;spec;settings;errorCollector;logger;generationLanguage;smartCasing;casingsGenerator;namespace;exampleGenerationArgs;authOverrides;environmentOverrides;globalHeaderOverrides;enableUniqueErrorsPerEndpoint;generateV1Examples;documentBaseDir;constructor(t){this.args=t,this.spec=t.spec,this.settings=t.settings,this.errorCollector=t.errorCollector,this.logger=t.logger,this.generationLanguage=t.generationLanguage,this.smartCasing=t.smartCasing,this.namespace=t.namespace,this.casingsGenerator=_x({generationLanguage:t.generationLanguage,keywords:void 0,smartCasing:t.smartCasing}),this.exampleGenerationArgs=t.exampleGenerationArgs,this.authOverrides=t.authOverrides,this.environmentOverrides=t.environmentOverrides,this.globalHeaderOverrides=t.globalHeaderOverrides,this.enableUniqueErrorsPerEndpoint=t.enableUniqueErrorsPerEndpoint,this.generateV1Examples=t.generateV1Examples,this.documentBaseDir=t.documentBaseDir}static BREADCRUMBS_TO_IGNORE=["properties","allOf","anyOf"];convertBreadcrumbsToName(t){let r=t.filter((n,a)=>!(/^\d+$/.test(n)||e.BREADCRUMBS_TO_IGNORE.includes(n)||a===0&&n==="components"||a===1&&n==="schemas"||t[0]==="paths"&&(a===0||a===1&&["get","post","put","delete","patch"].includes(n)||a===2&&t[1]!=null&&["get","post","put","delete","patch"].includes(t[1])&&n==="parameters"))),i=Fo(r.join("_"));return i.charAt(0).toUpperCase()+i.slice(1)}createFernFilepath(t={}){let r=this.namespace!=null?[this.casingsGenerator.generateName(this.namespace)]:[],i=t.name!=null?this.casingsGenerator.generateName(t.name):void 0;return{allParts:i?[...r,i]:r,packagePath:r,file:i}}resolveReference({reference:t,breadcrumbs:r,skipErrorCollector:i}){let n=this.spec,a=t.$ref.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(o=>o.replace(/~1/g,"/"));for(let o of a){if(typeof n!="object"||n==null)return i||this.errorCollector.collect({level:B1.ERROR,message:this.getErrorMessageForMissingRef({reference:t}),path:r}),{resolved:!1};n=n[o]}return n==null?(i||this.errorCollector.collect({level:B1.ERROR,message:this.getErrorMessageForMissingRef({reference:t}),path:r}),{resolved:!1}):{resolved:!0,value:n}}getErrorMessageForMissingRef({reference:t}){let r=t.$ref.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/");return r.length>=3&&r[0]==="components"&&r[1]==="schemas"?`Schema ${r[2]} does not exist`:`${t.$ref} does not exist`}async resolveMaybeExternalReference(t){let r=this.spec,i,n=!1,a=null,o;if(this.isExternalReference(t.$ref)){n=!0;let s=t.$ref.split("#"),u=s[0];if(i=s[1],!u)return{resolved:!1};o=u;let l=await fetch(u);if(!l.ok)return{resolved:!1};try{let p=await l.text();try{a=JSON.parse(p),r=a}catch{a=wi.load(p),r=a}if(r==null)return{resolved:!1}}catch{return{resolved:!1}}if(!i)return{resolved:!0,value:r}}let c=i??t.$ref;if(c==null||typeof c!="string")return{resolved:!1};let f=c.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(s=>s.replace(/~1/g,"/"));for(let s of f){if(typeof r!="object"||r==null)return{resolved:!1};r=r[s]}if(r==null)return{resolved:!1};if(n&&typeof r=="object"&&r!==null){let s=new Set;s.add(t.$ref),r=await this.resolveNestedExternalReferences(r,a,s,o)}return{resolved:!0,value:r}}async resolveNestedExternalReferences(t,r,i,n){if(t===null||typeof t!="object")return t;if(Array.isArray(t)){let o=[];for(let c of t)o.push(await this.resolveNestedExternalReferences(c,r,i,n));return o}if(this.isReferenceObject(t)){let o=t.$ref;if(this.isExternalReference(o)){if(i.has(o))return t;i.add(o);let c=await this.resolveMaybeExternalReference({$ref:o});if(i.delete(o),c.resolved)return c.value}else{let c=`${n}${o}`;if(i.has(c))return t;i.add(c);let f=r,s=o.substring(2).split("/").map(u=>u.replace(/~1/g,"/").replace(/~0/g,"~"));for(let u of s){if(typeof f!="object"||f===null)return t;f=f[u]}if(f!=null){let u=await this.resolveNestedExternalReferences(f,r,i,n);return i.delete(o),u}i.delete(o)}return t}let a={};for(let[o,c]of Object.entries(t))typeof c=="object"&&c!==null?a[o]=await this.resolveNestedExternalReferences(c,r,i,n):a[o]=c;return a}getExamplesFromSchema({schema:t,breadcrumbs:r}){if(t==null)return[];let i=t.example!=null?[t.example]:[];return t.examples!=null&&(Array.isArray(t.examples)?i.push(...t.examples):this.errorCollector.collect({message:"Received non-array schema examples",path:r})),i}getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:r,defaultExampleName:i}){if(t==null)return[];let n=[];if(t.example!=null){let a=this.generateUniqueName({prefix:i??`${r.join("_")}_example`,existingNames:[]});n.push([a,t.example])}return t.examples!=null&&n.push(...Object.entries(t.examples)),n}resolveMaybeReference({schemaOrReference:t,breadcrumbs:r,skipErrorCollector:i}){if(this.isReferenceObject(t)){let n=this.resolveReference({reference:t,breadcrumbs:r,skipErrorCollector:i});return n.resolved?n.value:void 0}return t}resolveExample(t){if(!this.isReferenceObject(t))return t;let r=this.resolveReference({reference:t});return r.resolved?this.returnExampleValue(r.value):void 0}resolveExampleWithValue(t){if(!this.isReferenceObject(t))return this.returnExampleValue(t);let r=this.resolveReference({reference:t});return r.resolved?this.returnExampleValue(r.value):void 0}returnExampleValue(t){return this.isExampleWithValue(t)?t.value:t}getPropertyAccess(t){let r=t;for(;this.isReferenceObject(r);){let a=this.resolveReference({reference:r});if(!a.resolved)return;r=a.value}let{readOnly:i,writeOnly:n}=this.getReadOnlyWriteOnlyFromSchema(r);if(!(i&&n)){if(i)return G6t.ReadOnly;if(n)return G6t.WriteOnly}}getReadOnlyWriteOnlyFromSchema(t){if(t.allOf&&t.allOf.length>0){let r=!0,i=!0;for(let n of t.allOf){let a=n;if(this.isReferenceObject(n)){let c=this.resolveReference({reference:n});if(!c.resolved)continue;a=c.value}let o=this.getReadOnlyWriteOnlyFromSchema(a);r=r&&o.readOnly,i=i&&o.writeOnly}return{readOnly:r,writeOnly:i}}else return{readOnly:!!t.readOnly,writeOnly:!!t.writeOnly}}getAudiences({operation:t,breadcrumbs:r}){let n=new I1.AudienceExtension({operation:t,breadcrumbs:r,context:this}).convert();if(n!=null)return n.audiences}getAvailability({node:t,breadcrumbs:r}){for(;this.isReferenceObject(t);){let a=this.resolveReference({reference:t});if(!a.resolved)return;t=a.value}let n=new I1.FernAvailabilityExtension({node:t,breadcrumbs:r,context:this}).convert();if(n!=null)return{status:n,message:void 0};if(t.deprecated===!0)return{status:IC.Deprecated,message:void 0}}getTypeIdFromSchemaReference(t){let r=t.$ref.match(/\/schemas\/(.+)$/);if(!(!r||!r[1]))return r[1]}createNamedTypeReference(t,r){return ii.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(t),typeId:t,displayName:r,default:void 0,inline:!1})}typeReferenceToDeclaredTypeName(t){if(t.type!=="named")return;let r=t.typeId;return{typeId:r,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r),displayName:t.displayName}}removeSchemaFromInlinedTypes({id:t,inlinedTypes:r}){return Object.fromEntries(Object.entries(r).filter(([i])=>i!==t))}static maybeTrimPrefix(t,r){return t.startsWith(r)?t.slice(r.length):t}generateUniqueName({prefix:t,existingNames:r}){if(!r.includes(t))return t;let i=0;for(;r.includes(`${t}_${i}`);)i++;return`${t}_${i}`}isReferenceObject(t){return typeof t=="object"&&t!==null&&"$ref"in t}isExternalReference(t){return typeof t=="string"&&(t.startsWith("http://")||t.startsWith("https://"))}isReferenceObjectWithIdentifier(t){return this.isReferenceObject(t)&&("title"in t||"name"in t||"messageId"in t||"summary"in t)}isExampleWithSummary(t){return typeof t=="object"&&t!=null&&"summary"in t}isExampleWithValue(t){return typeof t=="object"&&t!=null&&"value"in t}isOptional(t){return t.type==="container"&&t.container.type==="optional"}isNullable(t){return t.type==="container"&&t.container.type==="nullable"}isList(t){return t.type==="container"&&t.container.type==="list"}isFile(t){return t.type==="primitive"&&t.primitive.v2?.type==="string"&&t.primitive.v2.validation?.format==="binary"}getAsString(t){if(typeof t=="string")return t}getAsInteger(t){if(typeof t=="number"&&Number.isInteger(t))return t}getAsNumber(t){if(typeof t=="number")return t}getAsBoolean(t){if(typeof t=="boolean")return t}getAsArray(t){if(Array.isArray(t))return t}getAsObject(t){if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}getGroup({groupParts:t,namespace:r}){let i=[];return r!=null&&i.push(r),i.push(...t??[]),i}isObjectSchemaType(t){return t.type==="object"||t.properties!=null}};var Xc=class{breadcrumbs;context;constructor(t){this.breadcrumbs=t.breadcrumbs,this.context=t.context}getExtensionValue(t,r){if(typeof t!="object"||t==null)return;let i=t[this.key];if(i!=null)return i;if(r!=null)return t[r]}};var I1={};Yt(I1,{AudienceExtension:()=>mFo,FernAvailabilityExtension:()=>PFo,FernEnumExtension:()=>jFo,FernIgnoreExtension:()=>QKi,FernOptionalExtension:()=>wFo,FernTypeExtension:()=>DFo,FernTypeNameExtension:()=>BFo,SdkGroupNameExtension:()=>EFo,SdkMethodNameExtension:()=>SFo,ServerFromOperationNameExtension:()=>MFo});var mFo=class extends Xc{operation;key="x-fern-audiences";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=Array.isArray(t)?t.filter(i=>typeof i=="string"):typeof t=="string"?[t]:[];if(r.length!==0)return{audiences:r}}};var PFo=class extends Xc{node;key="x-fern-availability";constructor({breadcrumbs:t,node:r,context:i}){super({breadcrumbs:t,context:i}),this.node=r}convert(){let t=this.getExtensionValue(this.node);if(t==null||typeof t!="string")return;switch(t.toUpperCase().replace(/[-_\s]/g,"_")){case"IN_DEVELOPMENT":return IC.InDevelopment;case"PRE_RELEASE":case"BETA":return IC.PreRelease;case"GENERAL_AVAILABILITY":case"GA":return IC.GeneralAvailability;case"DEPRECATED":return IC.Deprecated;default:return}}};var D$S=Ct.object({snake:Ct.string().optional(),camel:Ct.string().optional(),screamingSnake:Ct.string().optional(),pascal:Ct.string().optional()}),B$S=Ct.object({description:Ct.string().optional(),name:Ct.string().optional(),casing:D$S.optional()}),vs_=Ct.record(B$S);var jFo=class extends Xc{schema;key="x-fern-enum";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(t==null)return;let r=vs_.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-enum extension: ${r.error.message}`,path:this.breadcrumbs});return}return r.data}};var QKi=class extends Xc{operation;key="x-fern-ignore";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-ignore",path:this.breadcrumbs});return}return t}}};var wFo=class extends Xc{parameter;key="x-fern-optional";constructor({breadcrumbs:t,parameter:r,context:i}){super({breadcrumbs:t,context:i}),this.parameter=r}convert(){let t=this.getExtensionValue(this.parameter);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-optional",path:this.breadcrumbs});return}return t}}};var EFo=class extends Xc{operation;key="x-fern-sdk-group-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=Array.isArray(t)?t.filter(i=>typeof i=="string"):typeof t=="string"?[t]:[];if(r.length!==0)return{groups:r}}};var SFo=class extends Xc{operation;key="x-fern-sdk-method-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null&&typeof t=="string")return{methodName:t}}};var MFo=class extends Xc{operation;key="x-fern-server-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation,"x-name");if(!(t==null||typeof t!="string"))return t}};var DFo=class extends Xc{schema;key="x-fern-type";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(t!=null&&typeof t=="string")return t}};var BFo=class extends Xc{schema;key="x-fern-type-name";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(typeof t=="string")return t}};var oFt=class extends Oa{ir;audiences;irGraph;constructor({breadcrumbs:t=[],context:r,audiences:i}){super({breadcrumbs:t,context:r}),this.audiences=i,this.irGraph=new NKi(i),this.ir={auth:{docs:void 0,requirement:vr.AuthSchemesRequirement.All,schemes:[]},selfHosted:!1,types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:vr.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:this.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}},audiences:void 0,generationMetadata:void 0,apiPlayground:void 0}}removeXFernIgnores({document:t,breadcrumbs:r=[]}){return Array.isArray(t)?t.filter((i,n)=>!new QKi({breadcrumbs:[...r,String(n)],operation:i,context:this.context}).convert()).map((i,n)=>this.removeXFernIgnores({document:i,breadcrumbs:[...r,String(n)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([i,n])=>!new QKi({breadcrumbs:[...r,i],operation:n,context:this.context}).convert()).map(([i,n])=>[i,this.removeXFernIgnores({document:n,breadcrumbs:[...r,i]})])):t}finalizeIr(){let t={...this.ir,apiName:this.context.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:this.context.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})},audiences:this.audiences.type==="select"?this.audiences.audiences:void 0};this.irGraph.hasNoAudiences()||(t=this.filterIrForAudiences(t));let r=this.context.exampleGenerationArgs,i=Qac({ir:t,exampleGeneration:r});if(this.context.generateV1Examples){let n=tPa({ir:t,exampleGeneration:r});return{...t,...n,...i}}return{...t,...i}}filterIrForAudiences(t){let r=this.irGraph.getFilteredEndpoints(),i=this.irGraph.getFilteredChannels(),n=this.irGraph.getFilteredWebhooks();for(let a of Object.values(t.services)){let o=[];for(let c of a.endpoints)r.has(c.id)&&o.push(c);a.endpoints=o}return t.websocketChannels=Object.fromEntries(Object.entries(t.websocketChannels??{}).filter(([a])=>i.has(a))),t.webhookGroups=Object.fromEntries(Object.entries(t.webhookGroups).filter(([a])=>n.has(a))),t}async resolveAllExternalRefs({spec:t}){let r=[t];for(;r.length>0;){let i=r.shift();i!=null&&(Array.isArray(i)?await this.resolveExternalRefsInArray(i,r):typeof i=="object"&&await this.resolveExternalRefsInObject(i,r))}return t}async resolveExternalRefsInArray(t,r){for(let i=0;i<t.length;i++)t[i]=await this.resolveReferenceChain(t[i],r)}async resolveExternalRefsInObject(t,r){for(let[i,n]of Object.entries(t))t[i]=await this.resolveReferenceChain(n,r)}async resolveReferenceChain(t,r){let i=t;if(!this.context.isReferenceObject(i))return r.push(i),t;for(;this.context.isReferenceObject(i);){let n=this.context.isExternalReference(i.$ref),a=await this.context.resolveMaybeExternalReference(i);if(a.resolved){if(i=a.value,n)return i}else return t}return t}shouldAddServerToCollectedServers({server:t,currentServers:r,specType:i="openapi"}){return i==="openapi"?!r.some(n=>n.url===t.url&&"x-fern-server-name"in n&&"x-fern-server-name"in t&&n["x-fern-server-name"]===t["x-fern-server-name"]):!r.some(n=>n.url===t.url&&"name"in n&&"name"in t&&n.name===t.name)}addEndpointToIr({endpoint:t,audiences:r,endpointGroup:i,endpointGroupDisplayName:n,serviceName:a}){let o=this.context.getGroup({groupParts:i,namespace:this.context.namespace}),c=this.getOrCreatePackage({group:i}),f=[...o].map(l=>this.context.casingsGenerator.generateName(l)),s=f[f.length-1];c.service==null&&(c.service=a??`service_${o.map(l=>Fo(l)).join("/")}`),this.ir.services[c.service]==null&&(this.ir.services[c.service]=this.createNewService({allParts:f,finalpart:s,endpointGroupDisplayName:n})),this.ir.services[c.service]?.endpoints.push(t);let u=this.ir.services[c.service];u!=null&&(this.irGraph.addEndpoint(u,t),this.irGraph.markEndpointForAudience(u.name,[t],r))}addWebhookToIr({webhook:t,operationId:r,audiences:i,group:n}){let a=n?.join(".")??r,o=this.getOrCreatePackage({group:n});this.ir.webhookGroups[a]==null&&(this.ir.webhookGroups[a]=[]),this.ir.webhookGroups[a].push(t),o.webhooks=a;let c=this.context.createFernFilepath();this.irGraph.addWebhook(c,t),i!=null&&this.irGraph.markWebhookForAudiences(c,t,i)}addWebsocketChannelToIr({websocketChannel:t,channelPath:r,audiences:i,websocketGroup:n}){let a=Fo(n?.join(".")),o=Fo(r),c=this.context.namespace?`${Fo(this.context.namespace)}/`:"",f=a?`channel_${c}${a}`:`channel_${c}${o}`,s=n?this.getOrCreatePackage({group:n}):this.getOrCreatePackage({group:[o]});this.ir.websocketChannels={...this.ir.websocketChannels,[f]:t},f!==""?s.websocket==null&&(s.websocket=f):this.ir.rootPackage.websocket="";let u=this.context.createFernFilepath();this.irGraph.addChannel(u,f,t),i!=null&&this.irGraph.markChannelForAudiences(u,f,i)}addAuthToIR(t){this.ir.auth=t}addErrorsToIr(t){this.ir.errors=t;for(let r of Object.values(t))this.irGraph.addError(r)}addGlobalHeadersToIr(t){this.ir.headers=t}addEnvironmentsToIr({environmentConfig:t,audiences:r}){if(this.ir.environments=t,r!=null)for(let[i,n]of Object.entries(t??{}))r[i]!=null&&this.irGraph.markEnvironmentForAudiences(n,r[i])}addTypeToRootPackage(t){this.ir.rootPackage.types.push(t)}addSchemaOutputToIr(t,r){let{convertedSchema:i,inlinedTypes:n}=r,o=Object.keys(n).some(c=>c===t)?`${t}Wrapper`:t;this.addTypeToPackage(o),this.addTypesToIr({...n,[o]:i})}addTypeToPackage(t){let r=this.context.getGroup({groupParts:[],namespace:this.context.namespace});this.getOrCreatePackage({group:r}).types.push(t)}addTypesToIr(t){Object.assign(this.ir.types,Object.fromEntries(Object.entries(t).map(([r,i])=>[r,i.typeDeclaration])));for(let r of Object.values(t))this.irGraph.addType({declaredTypeName:r.typeDeclaration.name,descendantTypeIds:r.typeDeclaration.referencedTypes,descendantTypeIdsByAudience:{},propertiesByAudience:r.propertiesByAudience,descendantFilepaths:new Set}),this.irGraph.markTypeForAudiences(r.typeDeclaration.name,r.audiences)}updateEndpointsWithDefaultUrl(t){if(t!=null)for(let r of Object.values(this.ir.services))for(let i of r.endpoints)i.baseUrl==null&&(i.baseUrl=t)}createNewService({allParts:t,finalpart:r,endpointGroupDisplayName:i}){return{name:{fernFilepath:{allParts:t,packagePath:t.slice(0,-1),file:r}},displayName:i,basePath:mD(""),headers:[],pathParameters:[],availability:void 0,endpoints:[],transport:void 0,encoding:void 0,audiences:void 0}}createPackage(t={}){return{fernFilepath:this.context.createFernFilepath(t),service:void 0,types:[],errors:[],subpackages:[],docs:void 0,webhooks:void 0,websocket:void 0,hasEndpointsInTree:!1,navigationConfig:void 0}}getOrCreatePackage({group:t}){let r=[];if(this.context.namespace!=null&&r.push(this.context.namespace),r.push(...(t??[]).map(n=>Fo(n))),r.length==0)return this.ir.rootPackage;let i=this.ir.rootPackage;for(let n=0;n<r.length;n++){let a=r[n]??"",c=`subpackage_${r.slice(0,n+1).join("/")}`;this.ir.subpackages[c]==null&&(this.ir.subpackages[c]={name:this.context.casingsGenerator.generateName(a),displayName:void 0,...this.createPackage({name:a})});let f=this.ir.subpackages[c];i.subpackages.includes(c)||i.subpackages.push(c),i=f}return i}};var LO={};Yt(LO,{AbstractConverters:()=>Jac,ExampleConverter:()=>U3,SchemaConverters:()=>Kac,ServersConverter:()=>Ohe});var Jac={};Yt(Jac,{AbstractMediaTypeObjectConverter:()=>qFo,AbstractParameterConverter:()=>TFo});var I$S=/^literal<\s*(?:"(.*)"|(true|false))\s*>$/;function C$S(e){return e.type==="array"||e.properties||e.oneOf||e.anyOf||e.allOf||e.additionalProperties?!1:!!(e.type==="string"||e.type==="number"||e.type==="integer"||e.type==="boolean"||e.const!==void 0||Array.isArray(e.enum)&&e.enum.length>0)}function gs_(e){if(e.const!==void 0)return e.const;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0]}var U3=class e extends Oa{MAX_DEPTH=12;EXAMPLE_STRING=Tn.STRING;EXAMPLE_NUMBER=Tn.DOUBLE;EXAMPLE_BOOLEAN=Tn.BOOLEAN;EXAMPLE_INTEGER=Tn.INT;EXAMPLE_DATE=Tn.DATE;EXAMPLE_DATE_TIME=Tn.DATE_TIME;schema;example;depth;exampleGenerationStrategy;generateOptionalProperties;seenRefs;constructor({breadcrumbs:t,context:r,schema:i,example:n,depth:a=0,exampleGenerationStrategy:o,generateOptionalProperties:c=!1,seenRefs:f=new Set}){super({breadcrumbs:t,context:r}),this.example=n,this.schema=i,this.depth=a,this.exampleGenerationStrategy=o,this.generateOptionalProperties=c,this.seenRefs=f}convert(){if(this.depth>this.MAX_DEPTH)return{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:typeof this.example<"u"?this.example:{},errors:[]};if(this.context.isReferenceObject(this.schema)){let i=this.schema.$ref;if(this.seenRefs.has(i))return{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:this.example,errors:[]}}let t=this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(t==null)return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:"Schema is not resolvable",path:this.breadcrumbs}]};if(typeof t!="object")return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:`Schema should be an object: ${JSON.stringify(t,null,2)}`,path:this.breadcrumbs}]};if("nullable"in t&&t.nullable===!0&&this.example===null)return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let r=this.maybeConvertLiteralFernType(t);return r??(Array.isArray(t.type)?this.convertSchemaTypeArray({resolvedSchema:t}):t.type=="null"?this.convertNull():t.type=="boolean"?this.convertBoolean():t.enum!=null?this.convertEnum(t):t.type=="number"?this.convertNumber():t.type=="string"?this.convertString():t.type=="integer"?this.convertInteger():t.type=="array"?this.convertArray({resolvedSchema:t}):"oneOf"in t&&t.oneOf!=null?this.convertOneOf({resolvedSchema:t}):"anyOf"in t&&t.anyOf!=null?this.convertAnyOf({resolvedSchema:t}):t.type=="object"||t.properties!=null||t.allOf!=null?this.convertObject({resolvedSchema:t}):typeof t=="object"&&Object.keys(t).length===0?{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:this.example,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:`Unsupported schema type: ${JSON.stringify(t,null,2)}`,path:this.breadcrumbs}]})}convertNull(){let t=this.example===null;return t?{isValid:t,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:`Example is not null: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertBoolean(){let t=typeof this.example=="boolean";if(t)return{isValid:t,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs})?.default:this.schema.default,i=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs})?.const:this.schema.const;return typeof r=="boolean"||typeof i=="boolean"?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i??r,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_BOOLEAN,errors:[{message:`Example is not a boolean: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertEnum(t){let r=t.enum?.includes(this.example)??!1;if(r)return{isValid:r,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let i=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return i!==void 0&&t.enum?.includes(i)?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i,errors:[]}:{isValid:r,coerced:!1,usedProvidedExample:!1,validExample:t.enum?.[0],errors:[{message:`Example is not one of the allowed enum values: ${JSON.stringify(t.enum,null,2)}`,path:this.breadcrumbs}]}}convertNumber(){if(typeof this.example=="number")return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let t=Number(this.example);if(!isNaN(t))return{isValid:!0,coerced:!0,usedProvidedExample:!0,validExample:t,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0}):this.schema,i=r?.default;return typeof i=="number"?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.adjustNumberToConstraints(this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_NUMBER,r),errors:[{message:`Example is not a number: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}adjustNumberToConstraints(t,r){if(r==null)return this.context.logger.debug("[ExampleConverter.adjustNumberToConstraints] Schema object is null, returning original number","number:",t.toString()),t;let{minimum:i,maximum:n,exclusiveMinimum:a,exclusiveMaximum:o}=r,c;a!=null?typeof a=="boolean"?c=i!=null?i+Math.max(Number.EPSILON,Math.abs(i)*1e-10):void 0:c=a+Math.max(Number.EPSILON,Math.abs(a)*1e-10):i!=null&&(c=i);let f;return o!=null?typeof o=="boolean"?f=n!=null?n-Math.max(Number.EPSILON,Math.abs(n)*Number.EPSILON):void 0:f=o-Math.max(Number.EPSILON,Math.abs(o)*Number.EPSILON):n!=null&&(f=n),c!==void 0&&f!==void 0?(t<c||t>f)&&(t=c+(f-c)/2):c!==void 0&&t<c?t=c+Math.abs(c*.1):f!==void 0&&t>f&&(t=f-Math.abs(f*.1)),Number(Number(t).toPrecision(3))}convertString(){if(typeof this.example=="string")return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};if(typeof this.example!="object"&&!Array.isArray(this.example)&&this.example!=null)return{isValid:!0,coerced:!0,usedProvidedExample:!0,validExample:String(this.example),errors:[]};let t=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;if(typeof t=="string")return{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:t,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0}):this.schema,i=r?.format==="date"?this.EXAMPLE_DATE:r?.format==="date-time"?this.EXAMPLE_DATE_TIME:this.EXAMPLE_STRING;return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.maybeResolveSchemaExample(this.schema)??i,errors:[{message:`Example cannot be converted to string: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertInteger(){if(typeof this.example=="number"&&Number.isInteger(this.example))return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};if(typeof this.example=="string"){let r=Number(this.example);if(!isNaN(r)&&Number.isInteger(r))return{isValid:!0,coerced:!0,usedProvidedExample:!0,validExample:r,errors:[]}}let t=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return typeof t=="number"&&Number.isInteger(t)?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:t,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_INTEGER,errors:[{message:`Example is not an integer: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertArray({resolvedSchema:t}){if(t.type!="array")return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[]};t.items==null&&(t.items={type:"string"});let r=this.example==null,i=this.example??t.example,a=(Array.isArray(i)?i:[i]).map(f=>new e({breadcrumbs:[...this.breadcrumbs,"items"],context:this.context,schema:t.items,example:f,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert()),o=a.every(f=>f?.isValid??!1)&&!r,c=!r&&a.some(f=>f.usedProvidedExample);return{isValid:o,coerced:!1,usedProvidedExample:c,validExample:a.map(f=>f.validExample),errors:o?[]:a.flatMap(f=>f.errors)}}convertObject({resolvedSchema:t}){if(t.type=="object"&&t.properties==null&&t.allOf==null)return{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:this.example??{},errors:[]};let r=typeof this.example!="object"||this.example==null?{}:this.example,i=Object.entries(t.properties??{}).map(([l,p])=>{if(typeof p!="object")return{key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if(this.isDeprecatedProperty(p)&&!this.isRequiredProperty({key:l,resolvedSchema:t}))return{key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if("readOnly"in p&&p.readOnly===!0&&"writeOnly"in p&&p.writeOnly===!0)return{key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if("readOnly"in p&&p.readOnly===!0&&this.exampleGenerationStrategy==="request")return{key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if("writeOnly"in p&&p.writeOnly===!0&&this.exampleGenerationStrategy==="response")return{key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};let _=!(l in r)||!("nullable"in p)&&r[l]==null||"nullable"in p&&p.nullable===!0&&r[l]===void 0,h=!t.required?.includes(l);if(_&&h){if(this.example===void 0&&this.generateOptionalProperties){let y=this.maybeResolveSchemaExample(p),b=new e({breadcrumbs:[...this.breadcrumbs,l],context:this.context,schema:p,example:y,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()});return{key:l,result:b.convert()}}return{key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}}}else{let b=r[l]??this.maybeResolveSchemaExample(p),O=new e({breadcrumbs:[...this.breadcrumbs,l],context:this.context,schema:p,example:b,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();return{key:l,result:O}}}),n=(t.allOf??[]).map((l,p)=>new e({breadcrumbs:[...this.breadcrumbs,`allOf[${p}]`],context:this.context,schema:{...t,...l,allOf:void 0},example:this.example,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert()),a=i.every(l=>l.result.isValid)&&n.every(l=>l.isValid),o=this.example!==void 0&&(i.some(({result:l})=>l.usedProvidedExample)||n.some(l=>l.usedProvidedExample)),c=Object.fromEntries(i.map(({key:l,result:p})=>[l,p.validExample]).filter(([l,p])=>p!==void 0));for(let l of n)if(typeof l.validExample=="object"&&l.validExample!==null){let p=l.validExample;c={...c,...Object.fromEntries(Object.entries(p).filter(([_,h])=>h!==void 0))}}let f=[],s=new Set(Object.keys(t.properties??{})),u=Object.keys(r).filter(l=>!s.has(l));u.length>0&&(t.additionalProperties===!1?u.forEach(l=>{let p=[...this.breadcrumbs,l].join("."),_={message:`Found unexpected property '${l}' in example. This property does not exist in the schema${p?` at path: ${p}`:""}`,path:[...this.breadcrumbs,l]};f.push({key:l,result:{isValid:!1,coerced:!1,usedProvidedExample:!0,validExample:void 0,errors:[_]}})}):u.forEach(l=>{let p=[...this.breadcrumbs,l].join("."),_={message:`Additional property ${l} is not allowed`,path:[...this.breadcrumbs,l]};f.push({key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:void 0,errors:[_]}})}));for(let{key:l,result:p}of f)p.validExample!==void 0&&c[l]===void 0&&(c[l]=p.validExample);if(Object.keys(c).length===0){let l=n.find(p=>p.validExample!==void 0&&(typeof p.validExample!="object"||p.validExample===null));l&&(c=l.validExample)}return{isValid:a,coerced:!1,usedProvidedExample:o,validExample:c,errors:[...i.flatMap(({result:l})=>l.errors),...n.flatMap(l=>l.errors),...f.flatMap(({result:l})=>l.errors)]}}convertSchemaTypeArray({resolvedSchema:t}){if(!Array.isArray(t.type))return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[]};if(t.type.length===1)return new e({breadcrumbs:this.breadcrumbs,context:this.context,schema:{...t,type:t.type[0]},example:this.example,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();let r=t.type.map((c,f)=>new e({breadcrumbs:[...this.breadcrumbs,`type[${f}]`],context:this.context,schema:{...t,type:c},example:this.example,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert()),i=r.some(c=>c?.isValid??!1),a=r.find(c=>c.isValid)?.validExample??r[0]?.validExample??null,o=r.some(c=>c.usedProvidedExample);return{isValid:i,coerced:!1,usedProvidedExample:o,validExample:a,errors:i?[]:r.flatMap(c=>c?.errors??[])}}convertUnion({resolvedSchema:t,unionType:r}){let i=r==="oneOf"?t.oneOf:t.anyOf;if(!(r in t)||i==null)return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[]};let n=this.example??this.maybeResolveSchemaExample(t);if(this.example===void 0){let p=[];for(let h of i){if(!h)continue;let y=this.context.resolveMaybeReference({schemaOrReference:h,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});y&&p.push(y)}if(p.length>0&&p.every(h=>C$S(h))){let h=p.findIndex(y=>gs_(y)!==void 0);if(h!==-1){let y=i[h],b=p[h];if(y&&b){let v=gs_(b),A=new e({breadcrumbs:[...this.breadcrumbs,`${r}[${h}]`],context:this.context,schema:r==="oneOf"?{...t,...y,oneOf:void 0}:y,example:v,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();if(A.isValid)return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:A.validExample,errors:[]}}}}}let a=[],o=null,c=null;for(let p=0;p<i.length;p++){let _=i[p];if(!_)continue;let h=r==="oneOf"?{...t,..._,oneOf:void 0}:_,y=n??this.maybeResolveSchemaExample(h),v=new e({breadcrumbs:[...this.breadcrumbs,`${r}[${p}]`],context:this.context,schema:h,example:y,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();if(v.isValid&&!v.coerced&&v.usedProvidedExample)return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:v.validExample,errors:[]};if(v.isValid&&!v.coerced)return{isValid:!0,coerced:!1,usedProvidedExample:v.usedProvidedExample,validExample:v.validExample,errors:[]};a.push(v),v.isValid&&v.usedProvidedExample&&c===null&&(c=v),v.isValid&&o===null&&(o=v)}let f=c??o,s=f!==null,u=f?.validExample??a[0]?.validExample,l=f?.usedProvidedExample??!1;return{isValid:s,coerced:!1,usedProvidedExample:l,validExample:u,errors:s?[]:a.flatMap(p=>p.errors)}}convertOneOf({resolvedSchema:t}){return this.convertUnion({resolvedSchema:t,unionType:"oneOf"})}convertAnyOf({resolvedSchema:t}){return this.convertUnion({resolvedSchema:t,unionType:"anyOf"})}getMaybeUpdatedSeenRefs(){let t=new Set(this.seenRefs);return this.context.isReferenceObject(this.schema)&&t.add(this.schema.$ref),t}maybeResolveSchemaExample(t){let r=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(r!=null){if("example"in r)return r.example;if("examples"in r){let i=r.examples;return Array.isArray(i)&&i.length>0?i[0]:Object.values(i??{})[0]}}}maybeConvertLiteralFernType(t){let r=t["x-fern-type"];if(typeof r!="string")return;let i=r.match(I$S);if(i!=null){if(i[1]!=null)return{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i[1],errors:[]};if(i[2]!=null)return{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i[2]==="true",errors:[]}}}isDeprecatedProperty(t){return t!=null&&"availability"in t&&t.availability==="deprecated"}isRequiredProperty({key:t,resolvedSchema:r}){return r.required?.includes(t)??!1}};var Kac={};Yt(Kac,{ArraySchemaConverter:()=>iQn,EnumSchemaConverter:()=>kFn,ObjectSchemaConverter:()=>eQn,OneOfSchemaConverter:()=>tQn,PrimitiveSchemaConverter:()=>rQn,SchemaConverter:()=>mCi,SchemaOrReferenceConverter:()=>L3});function Os_(e){return wB({type:e,_default:void 0,validation:void 0,visitor:{primitive:t=>{switch(t.v1){case"BASE_64":return ii.primitive({v1:"BASE_64",v2:bn.base64({})});case"BOOLEAN":return ii.primitive({v1:"BOOLEAN",v2:bn.boolean({default:void 0})});case"DATE":return ii.primitive({v1:"DATE",v2:bn.date({})});case"DATE_TIME":return ii.primitive({v1:"DATE_TIME",v2:bn.dateTime({})});case"FLOAT":return ii.primitive({v1:"FLOAT",v2:bn.float({})});case"DOUBLE":return ii.primitive({v1:"DOUBLE",v2:bn.double({default:void 0,validation:void 0})});case"UINT":return ii.primitive({v1:"UINT",v2:bn.uint({})});case"UINT_64":return ii.primitive({v1:"UINT_64",v2:bn.uint64({})});case"INTEGER":return ii.primitive({v1:"INTEGER",v2:bn.integer({default:void 0,validation:void 0})});case"LONG":return ii.primitive({v1:"LONG",v2:bn.long({default:void 0})});case"STRING":return ii.primitive({v1:"STRING",v2:bn.string({default:void 0,validation:void 0})});case"UUID":return ii.primitive({v1:"UUID",v2:bn.uuid({})});case"BIG_INTEGER":return ii.primitive({v1:"BIG_INTEGER",v2:bn.bigInteger({default:void 0})});default:return}},unknown:()=>ii.unknown(),map:({keyType:t,valueType:r})=>{if(!(t==null||r==null))return ii.container(ns.map({keyType:t,valueType:r}))},list:t=>{if(t!=null)return ii.container(ns.list(t))},optional:t=>{if(t!=null)return ii.container(ns.optional(t))},nullable:t=>{if(t!=null)return ii.container(ns.nullable(t))},set:t=>{if(t!=null)return ii.container(ns.set(t))},literal:t=>ii.container(ns.literal(t._visit({string:r=>iz.string(r),boolean:r=>iz.boolean(r),_other:()=>{throw new Error("Unexpected literal type")}}))),named:()=>{}}})}var kFn=class extends Oa{schema;maybeFernEnum;constructor({context:t,breadcrumbs:r,schema:i,maybeFernEnum:n}){super({context:t,breadcrumbs:r}),this.schema=i,this.maybeFernEnum=n}convert(){if(!this.schema.enum)return;let r=this.schema.enum.filter(n=>typeof n=="string"||typeof n=="number").map(n=>{let a=n.toString(),o=this.maybeFernEnum?.[a],c=o?.name??a;return{name:this.context.casingsGenerator.generateNameAndWireValue({name:c,wireValue:a}),docs:o?.description,availability:void 0,casing:o?.casing}});if(r.length===0){this.context.errorCollector.collect({message:`Received enum schema with no valid values: ${JSON.stringify(this.schema)}`,path:this.breadcrumbs});return}let i=this.context.getAsString(this.schema.default);return{type:Yc.enum({default:i!=null?r.find(n=>n.name.wireValue===i):void 0,values:r})}}};var IFo=class extends Oa{schemaOrReferenceOrBoolean;constructor({context:t,breadcrumbs:r,schemaOrReferenceOrBoolean:i}){super({context:t,breadcrumbs:r}),this.schemaOrReferenceOrBoolean=i}convert(){let t=this.tryConvertUnknownMap();if(t!=null)return t;let r=this.tryConvertTypedMap();if(r!=null)return r}tryConvertUnknownMap(){if(typeof this.schemaOrReferenceOrBoolean=="boolean"){let t=ii.container(ns.map({keyType:Oa.STRING,valueType:ii.unknown()}));return{type:Yc.alias({aliasOf:t,resolvedType:t}),referencedTypes:new Set,inlinedTypes:{}}}}tryConvertTypedMap(){if(typeof this.schemaOrReferenceOrBoolean=="boolean")return;let r=new L3({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReference:this.schemaOrReferenceOrBoolean}).convert();if(r!=null){let i=ii.container(ns.map({keyType:Oa.STRING,valueType:r.type})),n=new Set;for(let a of r.schema?.typeDeclaration.referencedTypes??[])n.add(a);for(let a of Object.keys(r.inlinedTypes))n.add(a);return{type:Yc.alias({aliasOf:i,resolvedType:i}),referencedTypes:n,inlinedTypes:r.inlinedTypes}}}};function iPa({properties:e,required:t,breadcrumbs:r,context:i,errorCollector:n}){let a=[],o={},c={},f=new Set;for(let[s,u]of Object.entries(e??{})){let l=[...r,"properties",s];if(typeof u!="object"){n.collect({message:`Schema property ${s} should be an object`,path:l});continue}let p=q$S(r,u,i)??i.convertBreadcrumbsToName(l),_="nullable"in u?u.nullable:!1,y=new L3({context:i,breadcrumbs:l,schemaOrReference:u,schemaIdOverride:p,wrapAsOptional:!t.includes(s),wrapAsNullable:_}).convert();if(y!=null){a.push({name:i.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),valueType:y.type,docs:u.description,availability:y.availability,propertyAccess:i.getPropertyAccess(u),v2Examples:y.schema?.typeDeclaration?.v2Examples??{userSpecifiedExamples:{},autogeneratedExamples:{}}}),o={...o,...y.inlinedTypes},y.schema?.typeDeclaration.referencedTypes!=null&&y.schema.typeDeclaration.referencedTypes.forEach(b=>{f.add(b)});for(let b of y.schema?.audiences??[])c[b]==null&&(c[b]=new Set),c[b].add(s)}}for(let s of Object.keys(o))f.add(s);return{convertedProperties:a,propertiesByAudience:c,inlinedTypesFromProperties:o,referencedTypes:f}}function q$S(e,t,r){return r.isReferenceObject(t)?void 0:new I1.FernTypeNameExtension({breadcrumbs:e,schema:t,context:r}).convert()}var eQn=class extends Oa{schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){let t=typeof this.schema.additionalProperties=="boolean"&&this.schema.additionalProperties;if(!this.schema.properties&&!this.schema.allOf)return{type:Yc.object({properties:[],extends:[],extendedProperties:[],extraProperties:t}),propertiesByAudience:{},inlinedTypes:{},referencedTypes:new Set};let{convertedProperties:r,inlinedTypesFromProperties:i,referencedTypes:n,propertiesByAudience:a}=iPa({properties:this.schema.properties??{},required:this.schema.required??[],breadcrumbs:this.breadcrumbs,context:this.context,errorCollector:this.context.errorCollector}),o=[],c=n,f=this.schema.required!=null&&this.schema.required.length>0,s=i,u=a;for(let[l,p]of(this.schema.allOf??[]).entries()){let _=[...this.breadcrumbs,"allOf",l.toString()],h;if(this.context.isReferenceObject(p)){let A=this.context.resolveMaybeReference({schemaOrReference:p,breadcrumbs:_});if(A==null){this.context.logger.debug?.(`[ObjectSchemaConverter] allOf[${l}] reference could not be resolved. Skipping: ${JSON.stringify(p)}`);continue}if(h=A,typeof h.additionalProperties=="boolean"&&h.additionalProperties&&(t=!0),!f||Object.keys(h.properties??{}).every(g=>!this.schema.required?.includes(g))){this.addTypeReferenceToExtends({reference:p,breadcrumbs:_,extends_:o,referencedTypes:c});continue}}else h=p;typeof h.additionalProperties=="boolean"&&h.additionalProperties&&(t=!0);let{convertedProperties:y,inlinedTypesFromProperties:b,referencedTypes:v,propertiesByAudience:O}=iPa({properties:h.properties??{},required:[...this.schema.required??[],...h.required??[]],breadcrumbs:_,context:this.context,errorCollector:this.context.errorCollector});r.push(...y),s={...s,...b},u={...u,...O},v.forEach(A=>{c.add(A)})}for(let l of Object.keys(s))c.add(l);return{type:Yc.object({properties:r,extends:o.map(l=>this.context.typeReferenceToDeclaredTypeName(l)).filter(Zu),extendedProperties:[],extraProperties:t}),propertiesByAudience:u,referencedTypes:c,inlinedTypes:s}}addTypeReferenceToExtends({reference:t,breadcrumbs:r,extends_:i,referencedTypes:n}){let a=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:r});a.ok&&i.push(a.reference);let o=this.context.getTypeIdFromSchemaReference(t);o!=null&&n.add(o)}};var CFo=class extends Xc{node;key="x-fern-discriminated";constructor({breadcrumbs:t,node:r,context:i}){super({breadcrumbs:t,context:i}),this.node=r}convert(){let t=this.getExtensionValue(this.node);if(t!=null&&typeof t=="boolean")return t}};var tQn=class extends Oa{schema;id;constructor({context:t,breadcrumbs:r,schema:i,id:n,inlinedTypes:a}){super({context:t,breadcrumbs:r}),this.schema=i,this.id=n}convert(){return this.shouldConvertAsNullableSchemaOrReference()?this.convertAsNullableSchemaOrReference():new CFo({context:this.context,breadcrumbs:this.breadcrumbs,node:this.schema}).convert()===!1?this.convertAsUndiscriminatedUnion():this.schema.discriminator!=null&&!this.unionVariantsContainLiteral({discriminantProperty:this.schema.discriminator.propertyName})?this.convertAsDiscriminatedUnion():this.convertAsUndiscriminatedUnion()}unionVariantsContainLiteral({discriminantProperty:t}){for(let[r,i]of Object.entries(this.schema.discriminator?.mapping??{})){let n=this.context.resolveReference({reference:{$ref:i},breadcrumbs:this.breadcrumbs});if(n.resolved&&!Object.keys(n.value.properties??{}).includes(t))return!1}return!0}convertAsDiscriminatedUnion(){if(this.schema.discriminator==null)return;let t=[],r=new Set,i={};for(let[f,s]of Object.entries(this.schema.discriminator.mapping??{})){let u=new L3({context:this.context,schemaOrReference:{$ref:s},breadcrumbs:[...this.breadcrumbs,"discriminator","mapping",f]}),l=this.context.getTypeIdFromSchemaReference({$ref:s});l!=null&&r.add(l);let p=u.convert();if(p?.type!=null&&l!=null){for(let h of Object.keys(p?.inlinedTypes??{}))r.add(h);for(let h of p.schema?.typeDeclaration.referencedTypes??[])r.add(h);let _=this.context.casingsGenerator.generateNameAndWireValue({name:f,wireValue:f});t.push({docs:void 0,discriminantValue:_,availability:p.availability,displayName:f,shape:rz.samePropertiesAsObject({typeId:l,name:this.context.casingsGenerator.generateName(l),fernFilepath:{allParts:[],packagePath:[],file:void 0},displayName:f})}),i={...i,...p.inlinedTypes}}}let{convertedProperties:n,referencedTypes:a,inlinedTypesFromProperties:o}=iPa({properties:this.schema.properties??{},required:this.schema.required??[],breadcrumbs:this.breadcrumbs,context:this.context,errorCollector:this.context.errorCollector});r=new Set([...r,...a]);let c=[];for(let[f,s]of(this.schema.allOf??[]).entries()){let u=[...this.breadcrumbs,"allOf",f.toString()];if(this.context.isReferenceObject(s)){let l=this.context.convertReferenceToTypeReference({reference:s,breadcrumbs:u});if(l.ok){let _=this.context.typeReferenceToDeclaredTypeName(l.reference);_!=null&&c.push(_)}let p=this.context.getTypeIdFromSchemaReference(s);p!=null&&r.add(p);continue}}for(let f of Object.keys({...i,...o}))r.add(f);return{type:Yc.union({baseProperties:n,discriminant:this.context.casingsGenerator.generateNameAndWireValue({name:this.schema.discriminator.propertyName,wireValue:this.schema.discriminator.propertyName}),extends:c,types:t}),referencedTypes:r,inlinedTypes:{...i,...o}}}convertAsUndiscriminatedUnion(){if(!this.schema.oneOf&&!this.schema.anyOf||this.schema.anyOf?.length===0&&this.schema.oneOf?.length===0)return;let t=[],r=new Set,i={},n=[...this.schema.oneOf??[],...this.schema.anyOf??[]].filter(a=>!this.context.isReferenceObject(a));for(let[a,o]of[...(this.schema.oneOf??[]).entries(),...(this.schema.anyOf??[]).entries()]){if(this.context.isReferenceObject(o)){let p;if(this.context.isReferenceObjectWithIdentifier(o))p=this.context.convertReferenceToTypeReference({reference:o,displayNameOverride:o.summary??o.title??o.name??o.messageId,displayNameOverrideSource:"reference_identifier"});else if(this.getDiscriminatorKeyForRef(o)!=null){let h=this.getDiscriminatorKeyForRef(o);p=this.context.convertReferenceToTypeReference({reference:o,displayNameOverride:h,displayNameOverrideSource:"discriminator_key"})}else p=this.context.convertReferenceToTypeReference({reference:o,displayNameOverride:o.$ref.split("/").pop(),displayNameOverrideSource:"schema_identifier"});p.ok&&t.push({type:p.reference,docs:o.description});let _=this.context.getTypeIdFromSchemaReference(o);_!=null&&r.add(_);continue}let c=this.extendSubSchema(o),f=this.context.convertBreadcrumbsToName([`${this.id}_${a}`]),s=o.title,l=new mCi({context:this.context,id:f,nameOverride:s,breadcrumbs:[...this.breadcrumbs,`oneOf[${a}]`],schema:c??o}).convert();if(l!=null){let p=l.convertedSchema.typeDeclaration.shape;p.type==="alias"&&this.typeReferenceIsWrappedPrimitive(p.aliasOf)?t.push({type:p.aliasOf,docs:o.description}):p.type==="object"&&p.properties.length===0&&p.extends.length===0?t.push({type:ii.container(ns.map({keyType:Oa.STRING,valueType:ii.unknown()})),docs:o.description}):(t.push({type:this.context.createNamedTypeReference(f,s),docs:o.description}),i={...i,...l.inlinedTypes,[f]:l.convertedSchema}),l.convertedSchema.typeDeclaration.referencedTypes.forEach(_=>{r.add(_)})}}return{type:Yc.undiscriminatedUnion({members:t}),referencedTypes:r,inlinedTypes:i}}shouldConvertAsNullableSchemaOrReference(){return this.schema.oneOf!=null?this.schema.oneOf.some(t=>t&&typeof t=="object"&&"type"in t&&t.type==="null"):this.schema.anyOf!=null?this.schema.anyOf.some(t=>t&&typeof t=="object"&&"type"in t&&t.type==="null"):!1}removeNullFromOneOfOrAnyOf(){let t=this.schema.oneOf??this.schema.anyOf,r=this.schema.oneOf!=null?"oneOf":"anyOf";if(t==null)return;let i=t.filter(n=>!("type"in n&&n.type==="null"));if(i.length===0){this.context.errorCollector.collect({message:`Received ${r} schema with no valid non-null types`,path:this.breadcrumbs});return}return i.length===1?{...this.schema,[r]:void 0,...i[0]}:{...this.schema,[r]:i}}convertAsNullableSchemaOrReference(){let t=this.removeNullFromOneOfOrAnyOf();if(t==null)return;let i=new L3({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReference:t}).convert();if(i==null)return;let n=this.wrapInNullable(i.type);return{type:Yc.alias({aliasOf:n,resolvedType:n}),referencedTypes:i.schema?.typeDeclaration.referencedTypes??new Set,inlinedTypes:i.inlinedTypes}}typeReferenceIsWrappedPrimitive(t){switch(t.type){case"container":return this.containerTypeIsWrappedPrimitive(t.container);case"named":return!1;case"primitive":return!0;case"unknown":return!0;default:return!1}}containerTypeIsWrappedPrimitive(t){switch(t.type){case"list":return this.typeReferenceIsWrappedPrimitive(t.list);case"map":return this.typeReferenceIsWrappedPrimitive(t.keyType)&&this.typeReferenceIsWrappedPrimitive(t.valueType);case"nullable":return this.typeReferenceIsWrappedPrimitive(t.nullable);case"optional":return this.typeReferenceIsWrappedPrimitive(t.optional);case"set":return this.typeReferenceIsWrappedPrimitive(t.set);case"literal":return!0;default:return!1}}wrapInNullable(t){return ii.container(ns.nullable(t))}mergeIntoObjectSchema(t,r){return{...t,properties:{...r,...t.properties??{}}}}extendSubSchema(t){if(Object.entries(this.schema.properties??{}).length===0)return t;if(t.type==="object")return this.mergeIntoObjectSchema(t,this.schema.properties??{});this.context.isObjectSchemaType(t)||this.context.errorCollector.collect({message:"Received additional object properties for oneOf/anyOf that are not objects",path:this.breadcrumbs})}getDiscriminatorKeyForRef(t){return Object.entries(this.schema.discriminator?.mapping??{}).find(([r,i])=>i===t.$ref)?.[0]}};var rQn=class extends Oa{schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){switch(this.schema.type){case"string":{let t=this.context.getAsString(this.schema.const);if(t!=null)return ii.container(ns.literal(iz.string(t)));if(this.context.settings.typeDatesAsStrings===!1){if(this.schema.format==="date")return ii.primitive({v1:Su.Date,v2:bn.date({})});if(this.schema.format==="date-time")return ii.primitive({v1:Su.DateTime,v2:bn.dateTime({})})}return ii.primitive({v1:"STRING",v2:bn.string({default:this.context.getAsString(this.schema.default),validation:this.getStringValidation(this.schema)})})}case"number":switch(this.schema.format){case"double":return ii.primitive({v1:"DOUBLE",v2:bn.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return ii.primitive({v1:"FLOAT",v2:bn.float({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return ii.primitive({v1:"INTEGER",v2:bn.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return ii.primitive({v1:"LONG",v2:bn.long({default:this.context.getAsNumber(this.schema.default)})});case"uint32":return ii.primitive({v1:"UINT",v2:bn.uint({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return ii.primitive({v1:"UINT_64",v2:bn.uint64({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return ii.primitive({v1:"DOUBLE",v2:bn.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"integer":switch(this.schema.format){case"double":return ii.primitive({v1:"DOUBLE",v2:bn.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return ii.primitive({v1:"FLOAT",v2:bn.float({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return ii.primitive({v1:"INTEGER",v2:bn.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return ii.primitive({v1:"LONG",v2:bn.long({default:this.context.getAsNumber(this.schema.default)})});case"uint32":return ii.primitive({v1:"UINT",v2:bn.uint({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return ii.primitive({v1:"UINT_64",v2:bn.uint64({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return ii.primitive({v1:"INTEGER",v2:bn.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"boolean":{let t=this.context.getAsBoolean(this.schema.const);return t!=null?ii.container(ns.literal(iz.boolean(t))):ii.primitive({v1:"BOOLEAN",v2:bn.boolean({default:this.schema.default})})}default:return}}getNumberValidation(t){return{max:t.maximum,min:t.minimum,exclusiveMax:typeof t.exclusiveMaximum=="boolean"?t.exclusiveMaximum:void 0,exclusiveMin:typeof t.exclusiveMinimum=="boolean"?t.exclusiveMinimum:void 0,multipleOf:t.multipleOf}}getStringValidation(t){return{minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,format:t.format}}};var T$S=["description","example","title","default","deprecated","readOnly","writeOnly","xml","externalDocs","extensions"],mCi=class e extends Oa{schema;id;inlined;audiences;nameOverride;constructor({context:t,breadcrumbs:r,schema:i,id:n,inlined:a=!1,nameOverride:o}){super({context:t,breadcrumbs:r}),this.schema=i,this.id=n,this.inlined=a,this.nameOverride=o,this.audiences=this.context.getAudiences({operation:this.schema,breadcrumbs:this.breadcrumbs})??[]}convert(){let t=this.tryConvertFernTypeDeclaration();if(t!=null)return t;let r=this.tryConvertEnumSchema();if(r!=null)return r;let i=this.tryConvertSingularAllOfSchema();if(i!=null)return i;let n=this.tryConvertPrimitiveSchema();if(n!=null)return n;let a=this.tryConvertArraySchema();if(a!=null)return a;let o=this.tryConvertTypeArraySchema();if(o!=null)return o;let c=this.tryConvertOneOfAnyOfSchema();if(c!=null)return c;let f=this.tryConvertMapSchema();if(f!=null)return f;let s=this.tryConvertObjectAllOfSchema();if(s!=null)return s;let u=this.tryConvertUntypedSchema();if(u!=null)return u;this.context.errorCollector.collect({message:`Failed to convert schema object: ${JSON.stringify(this.schema,null,2)}`,path:this.breadcrumbs})}tryConvertEnumSchema(){if(!this.schema.enum?.length)return;let r=new I1.FernEnumExtension({breadcrumbs:this.breadcrumbs,schema:this.schema,context:this.context}).convert(),n=new kFn({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema,maybeFernEnum:r}).convert();if(n!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:n.type,referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertSingularAllOfSchema(){if(this.schemaOnlyHasAllowedKeys(["allOf","type","title"])&&this.schema.allOf?.length===1&&this.schema.allOf[0]!=null){let r=this.context.resolveMaybeReference({schemaOrReference:this.schema.allOf[0],breadcrumbs:this.breadcrumbs});if(r!=null){let n=new e({context:this.context,breadcrumbs:[...this.breadcrumbs,"allOf","0"],schema:r,id:this.id,inlined:!0}).convert();if(n?.convertedSchema.typeDeclaration?.shape.type!=="object")return n}}if(this.schemaOnlyHasAllowedKeys(["allOf","type","title"])&&Array.isArray(this.schema.allOf)&&this.schema.allOf.length>=1){let r={};for(let n of this.schema.allOf??[]){if(this.context.isReferenceObject(n))return;r=wMn(r,n,(a,o)=>{if(o===n)return a;if(Array.isArray(a)&&Array.isArray(o))return[...a,...o]})}return new e({context:this.context,breadcrumbs:this.breadcrumbs,schema:r,id:this.id,inlined:!0}).convert()}}tryConvertPrimitiveSchema(){let r=new rQn({context:this.context,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Yc.alias({aliasOf:r,resolvedType:r}),referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertArraySchema(){if(this.schema.type==="array"){let r=new iQn({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Yc.alias({aliasOf:r.typeReference,resolvedType:r.typeReference}),referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertTypeArraySchema(){if(Array.isArray(this.schema.type)&&this.schema.type.length>0)return this.schema.type.length===1?this.schema.type=this.schema.type[0]:(this.schema.oneOf=this.schema.type.map(t=>({type:t})),this.schema.type=void 0),this.convert()}tryConvertOneOfAnyOfSchema(){if(this.schema.oneOf!=null||this.schema.anyOf!=null){let r=new tQn({id:this.id,context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertMapSchema(){if((typeof this.schema.additionalProperties=="object"||typeof this.schema.additionalProperties=="boolean")&&this.schema.additionalProperties!=null&&!this.schema.properties&&!this.schema.allOf){if(typeof this.schema.additionalProperties=="boolean"&&this.schema.additionalProperties===!1)return;let r=new IFo({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReferenceOrBoolean:this.schema.additionalProperties}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertObjectAllOfSchema(){if(this.schema.type==="object"||this.schema.properties!=null||this.schema.allOf!=null){let r=new eQn({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:r.propertiesByAudience},inlinedTypes:r.inlinedTypes}}}tryConvertUntypedSchema(){if(this.isUntypedSchema())return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Yc.alias({aliasOf:ii.unknown(),resolvedType:ii.unknown()}),referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertFernTypeDeclaration(){let r=new I1.FernTypeExtension({breadcrumbs:this.breadcrumbs,schema:this.schema,context:this.context}).convert();if(r==null)return;let i=Os_(r);if(i!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Yc.alias({aliasOf:i,resolvedType:i}),referencedTypes:new Set,omitV2Examples:!0}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}createTypeDeclaration({shape:t,referencedTypes:r,omitV2Examples:i}){return{name:this.convertDeclaredTypeName(),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:this.context.getAvailability({node:this.schema,breadcrumbs:this.breadcrumbs}),docs:this.schema.description,referencedTypes:r,source:void 0,inline:this.inlined,v2Examples:i?void 0:this.convertSchemaExamples()}}convertDeclaredTypeName(){return{typeId:this.id,fernFilepath:this.context.createFernFilepath(),name:this.context.casingsGenerator.generateName(this.id),displayName:this.nameOverride}}schemaOnlyHasAllowedKeys(t){let r=[...T$S,...t];return Object.keys(this.schema).every(n=>r.includes(n))}isUntypedSchema(){return!!(this.schema&&typeof this.schema=="object"&&!("oneOf"in this.schema)&&!("anyOf"in this.schema)&&!("allOf"in this.schema)&&!("items"in this.schema)&&!("properties"in this.schema))}convertSchemaExamples(){let t={userSpecifiedExamples:{},autogeneratedExamples:{}},r=this.context.getExamplesFromSchema({schema:this.schema,breadcrumbs:this.breadcrumbs});if(r.length===0){let i=this.generateOrValidateExample({example:void 0,ignoreErrors:!0});return t.autogeneratedExamples={[`${this.id}_example_autogenerated`]:i},t}return t.userSpecifiedExamples=this.convertUserSpecifiedExamples(r),t}convertUserSpecifiedExamples(t){let r={};for(let[i,n]of t.entries()){let a=this.context.resolveExample(n),o=this.generateOrValidateExample({example:a});r[`${this.id}_example_${i}`]=o}return r}generateOrValidateExample({example:t,ignoreErrors:r}){let i=new U3({breadcrumbs:this.breadcrumbs,context:this.context,schema:this.schema,example:t}),{validExample:n,errors:a}=i.convert();return r||a.forEach(o=>{this.context.errorCollector.collect({message:o.message,path:o.path})}),n}};var L3=class extends Oa{schemaOrReference;schemaIdOverride;wrapAsOptional;wrapAsNullable;constructor({context:t,breadcrumbs:r,schemaOrReference:i,schemaIdOverride:n,wrapAsOptional:a=!1,wrapAsNullable:o=!1}){super({context:t,breadcrumbs:r}),this.schemaOrReference=i,this.schemaIdOverride=n,this.wrapAsOptional=a,this.wrapAsNullable=o}convert(){let t=this.maybeConvertReferenceObject({schemaOrReference:this.schemaOrReference});if(t!=null)return t;let r=this.maybeConvertSingularAllOfReferenceObject();return r??this.convertSchemaObject({schema:this.schemaOrReference})}maybeConvertReferenceObject({schemaOrReference:t}){if(this.context.isReferenceObject(t)){let r=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:this.breadcrumbs});if(r.ok)return{type:this.wrapTypeReference(r.reference),inlinedTypes:r.inlinedTypes??{}}}}maybeConvertSingularAllOfReferenceObject(){if(this.context.isReferenceObject(this.schemaOrReference)||this.schemaOrReference.allOf==null||this.schemaOrReference.allOf.length!==1)return;let t=this.schemaOrReference.allOf[0];if(this.context.isReferenceObject(t)){let r=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:this.breadcrumbs});if(r.ok)return{type:this.wrapTypeReference(r.reference),inlinedTypes:{}}}}convertSchemaObject({schema:t}){let r=this.schemaIdOverride??this.context.convertBreadcrumbsToName(this.breadcrumbs),i=new mCi({context:this.context,breadcrumbs:this.breadcrumbs,schema:t,id:r}),n=this.context.getAvailability({node:t,breadcrumbs:this.breadcrumbs}),a=i.convert();if(a!=null){let o=a.convertedSchema.typeDeclaration.shape;return o.type==="alias"?{type:this.wrapTypeReference(o.aliasOf),schema:a.convertedSchema,inlinedTypes:a.inlinedTypes,availability:n}:{type:this.wrapTypeReference(this.context.createNamedTypeReference(r)),schema:a.convertedSchema,inlinedTypes:{...a.inlinedTypes,[r]:a.convertedSchema},availability:n}}}wrapTypeReference(t){return this.wrapAsOptional&&this.wrapAsNullable?this.wrapInOptional(this.wrapInNullable(t)):this.wrapAsOptional?this.wrapInOptional(t):this.wrapAsNullable?this.wrapInNullable(t):t}wrapInOptional(t){return ii.container(ns.optional(t))}wrapInNullable(t){return ii.container(ns.nullable(t))}};var iQn=class e extends Oa{static LIST_UNKNOWN=ii.container(ns.list(ii.unknown()));schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){if(this.schema.items!=null){Array.isArray(this.schema.items)&&(this.schema.items={oneOf:this.schema.items});let r=new L3({context:this.context,breadcrumbs:[...this.breadcrumbs,"items"],schemaOrReference:this.schema.items}).convert();if(r!=null){let i=new Set;for(let n of r.schema?.typeDeclaration.referencedTypes??[])i.add(n);return r.inlinedTypes!=null&&Object.values(r.inlinedTypes).forEach(n=>{n.typeDeclaration.referencedTypes.forEach(a=>{i.add(a)})}),{typeReference:ii.container(ns.list(r.type)),referencedTypes:i,inlinedTypes:r.inlinedTypes}}}return{typeReference:e.LIST_UNKNOWN,referencedTypes:new Set,inlinedTypes:{}}}};var qFo=class extends Oa{group;method;constructor({context:t,breadcrumbs:r,group:i,method:n}){super({context:t,breadcrumbs:r}),this.group=i,this.method=n}parseMediaTypeObject({mediaTypeObject:t,resolveSchema:r,contentType:i,schemaId:n}){if(t.schema==null)return;if(r){let f=this.context.resolveMaybeReference({schemaOrReference:t.schema,breadcrumbs:[...this.breadcrumbs,"content",i]});if(f==null)return;t.schema=f}let o=new L3({context:this.context,breadcrumbs:[...this.breadcrumbs,"content",i,"schema"],schemaOrReference:t.schema,schemaIdOverride:n}).convert();if(o==null)return;let c=t.examples!=null?Object.fromEntries(Object.entries(t.examples).map(([f,s])=>{if(this.context.isReferenceObject(s)){let u=this.context.resolveReference({reference:s,breadcrumbs:[...this.breadcrumbs,"content",i,"examples"],skipErrorCollector:!0});return u.resolved?[f,u.value.value??u.value]:null}return[f,s.value??s]}).filter(f=>f!=null)):void 0;return{...o,examples:c}}parseMediaTypeSchemaOrReference({schemaOrReference:t,schemaId:r}){let n=new L3({context:this.context,breadcrumbs:[...this.breadcrumbs],schemaOrReference:t,schemaIdOverride:r}).convert();if(n!=null)return{...n,examples:void 0}}convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:r,exampleGenerationStrategy:i}){let n={userSpecifiedExamples:{},autogeneratedExamples:{}},a=t?.schema,o=this.context.getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:this.breadcrumbs,defaultExampleName:`${[...this.group,this.method].join("_")}_example`});for(let[c,f]of o){let s=this.context.resolveExampleWithValue(f),u=this.context.isExampleWithSummary(f)?f.summary:c;s!=null&&(a!=null?n.userSpecifiedExamples[u]=this.generateOrValidateExample({schema:a,example:s,exampleGenerationStrategy:i}):n.userSpecifiedExamples[u]=s)}if(Object.keys(n.userSpecifiedExamples).length===0&&a!=null){let c=Fo(`${[...this.group,this.method].join("_")}_example`);n.autogeneratedExamples[c]=this.generateOrValidateExample({schema:a,example:void 0,ignoreErrors:!0,generateOptionalProperties:r,exampleGenerationStrategy:i})}return n}generateOrValidateExample({schema:t,example:r,ignoreErrors:i,generateOptionalProperties:n,exampleGenerationStrategy:a}){let o=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(o==null)return;let c=this.context.getExamplesFromSchema({schema:o,breadcrumbs:this.breadcrumbs}),f=new U3({breadcrumbs:this.breadcrumbs,context:this.context,schema:o,example:r??c[0],generateOptionalProperties:n??!1,exampleGenerationStrategy:a}),{validExample:s,errors:u}=f.convert();return i||u.forEach(l=>{this.context.errorCollector.collect({message:l.message,path:l.path})}),s}};var TFo=class extends Oa{parameter;constructor({context:t,breadcrumbs:r,parameter:i}){super({context:t,breadcrumbs:r}),this.parameter=i}convertToOutput({schema:t,typeReference:r,inlinedTypes:i}){let n=this.context.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs}),a=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs}),o=this.getParameterSchemaWithExampleOverride({schema:a});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:this.context.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:r??Oa.OPTIONAL_STRING,allowMultiple:this.parameter.explode??!1,v2Examples:this.convertParameterExamples({schema:o??t}),availability:n,explode:this.getExplodeForQueryParameter()},inlinedTypes:i};case"header":return{type:"header",parameter:{name:this.context.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:r??Oa.OPTIONAL_STRING,env:void 0,v2Examples:this.convertParameterExamples({schema:o??t}),availability:n},inlinedTypes:i};case"path":return{type:"path",parameter:{name:this.context.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:r??Oa.STRING,location:"ENDPOINT",variable:void 0,v2Examples:this.convertParameterExamples({schema:o??t}),explode:this.getExplodeForPathParameter()},inlinedTypes:i};default:return}}getParameterSchemaWithExampleOverride({schema:t}){if(t!=null)return t.type==="string"&&t.example==null?{...t,example:this.parameter.name}:t}convertParameterExamples({schema:t}){let r={userSpecifiedExamples:{},autogeneratedExamples:{}},i=this.parameter.example,n=this.parameter.examples;for(let[a,o]of Object.entries(n??{})){let c=this.context.resolveExampleWithValue(o);c!=null&&(r.userSpecifiedExamples[a]=this.generateOrValidateExample({schema:t,example:c}))}if(i!=null){let a=this.context.generateUniqueName({prefix:`${this.parameter.name}_example`,existingNames:Object.keys(r.userSpecifiedExamples)});r.userSpecifiedExamples[a]=this.generateOrValidateExample({schema:t,example:i})}if(Object.keys(r.userSpecifiedExamples).length===0){let a=`${this.parameter.name}_example`;r.autogeneratedExamples[a]=this.generateOrValidateExample({schema:t,example:void 0,ignoreErrors:!0})}return r}generateOrValidateExample({schema:t,ignoreErrors:r,example:i}){let n=new U3({breadcrumbs:this.breadcrumbs,context:this.context,schema:t,example:i}),{validExample:a,errors:o}=n.convert();return r||o.forEach(c=>{this.context.errorCollector.collect({message:c.message,path:c.path})}),a}getExplodeForQueryParameter(){let t=this.parameter.style??"form",r=this.parameter.explode;if(r!==void 0)return t==="form"?r===!0?void 0:r:r===!1?void 0:r}getExplodeForPathParameter(){let t=this.parameter.explode;if(t!==void 0)return t===!1?void 0:t}};var RFo=class extends Xc{server;key="x-fern-server-name";constructor({breadcrumbs:t,server:r,context:i}){super({breadcrumbs:t,context:i}),this.server=r}convert(){let t=this.getExtensionValue(this.server,"x-name");if(!(t==null||typeof t!="string"))return t}};var As_="Base",Ohe=class e extends Oa{servers;endpointLevelServers;constructor({breadcrumbs:t,context:r,servers:i,endpointLevelServers:n}){super({breadcrumbs:t,context:r}),this.servers=i,this.endpointLevelServers=n}convert(){if(this.servers==null||this.servers.length===0||this.servers[0]==null)return;if(this.endpointLevelServers!=null&&this.endpointLevelServers.length>0){let r=this.getDefaultBaseUrlName(),i={id:r,name:this.context.casingsGenerator.generateName(r)},n=this.endpointLevelServers.map(c=>{let f=e.getServerName({server:c,context:this.context});return{id:f,name:this.context.casingsGenerator.generateName(f)}}).filter((c,f,s)=>s.findIndex(u=>u.id===c.id)===f),a=[i,...n],o=this.servers.map(c=>{let f=e.getServerName({server:c,context:this.context}),s=this.endpointLevelServers?.map(u=>[e.getServerName({server:u,context:this.context}),this.getServerUrl(u)]);return{id:f,name:this.context.casingsGenerator.generateName(f),urls:{[r]:this.getServerUrl(c),...Object.fromEntries(s??[])},docs:c.description}});return{value:{defaultEnvironment:o[0]?.id,environments:$E.multipleBaseUrls({baseUrls:a,environments:o})},defaultUrl:i.id}}let t=this.withExplodedServers(this.servers).map(r=>{let i=e.getServerName({server:r,context:this.context});return{id:i,name:this.context.casingsGenerator.generateName(i),url:this.maybeRemoveTrailingSlashIfNotEmpty(this.getServerUrl(r)),docs:r.description}}).filter(Zu);return{value:{defaultEnvironment:t[0]?.id,environments:$E.singleBaseUrl({environments:t})},defaultUrl:t[0]?.id}}static getServerExtensionName({server:t,context:r}){return new RFo({breadcrumbs:[],server:t,context:r}).convert()}static getServerName({server:t,context:r}){return t.name!=null?t.name:e.getServerExtensionName({server:t,context:r})??t.description??t.url}getServerUrl(t){if(t.variables==null)return t.url;let r=t.url;for(let[i,n]of Object.entries(t.variables))n.default!=null&&(r=r.replace(`{${i}}`,encodeURIComponent(n.default)));return r}withExplodedServers(t){return t.flatMap(r=>{if(r.variables==null)return[r];let i=Object.entries(r.variables).filter(([c,f])=>f.enum!=null&&f.enum.length>0);if(i.length===0)return[r];let n=i[0];if(n==null)return[r];let[a,o]=n;return o.enum==null?[r]:o.enum.map(c=>{let f=r.url.replace(`{${a}}`,encodeURIComponent(c)),s={};for(let[l,p]of Object.entries(r.variables??{}))l!==a&&(s[l]=p);let u={...r,url:f,variables:Object.keys(s).length>0?s:void 0,"x-fern-server-name":r.description?`${r.description}_${c}`:`${c}`,description:r.description};return this.withExplodedServers([u])[0]})}).filter(Zu)}getDefaultBaseUrlName(){return this.servers==null||this.servers.length===0||this.servers[0]==null?As_:e.getServerExtensionName({server:this.servers[0],context:this.context})??As_}maybeRemoveTrailingSlashIfNotEmpty(t){return t.endsWith("/")&&t!=="/"?t.slice(0,-1):t}};var UKi=class{context;constructor({context:t}){this.context=t}validateExample({example:t,schema:r,breadcrumbs:i,exampleGenerationStrategy:n}){return new U3({breadcrumbs:i,context:this.context,schema:r,example:t,depth:0,exampleGenerationStrategy:n,generateOptionalProperties:!1}).convert()}validateEndpointExample({exampleToValidate:t}){let r=[],i=[],n=!0,a=!1,o,c=[t.endpointPath,t.method];if(t.requestExample!==void 0&&t.requestSchema!==void 0){let f=this.validateExample({example:t.requestExample,schema:t.requestSchema,breadcrumbs:[...c,"request"],exampleGenerationStrategy:"request"});if(!f.isValid){n=!1;let s=t.exampleSource==="human"?B1.WARNING:B1.ERROR;r.push(...f.errors.map(u=>({...u,level:s,message:`Invalid request example: ${u.message}`})))}f.coerced&&(a=!0,i.push({level:B1.WARNING,message:"Request example was coerced to match schema",path:[...c,"request"]})),o={request:f.validExample}}if(t.responseExample!==void 0&&t.responseSchema!==void 0){let f=this.validateExample({example:t.responseExample,schema:t.responseSchema,breadcrumbs:[...c,"response"],exampleGenerationStrategy:"response"});if(!f.isValid){n=!1;let s=t.exampleSource==="human"?B1.WARNING:B1.ERROR;r.push(...f.errors.map(u=>({...u,level:s,message:`Invalid response example: ${u.message}`})))}f.coerced&&(a=!0,i.push({level:B1.WARNING,message:"Response example was coerced to match schema",path:[...c,"response"]})),o={...typeof o=="object"&&o!==null?o:{},response:f.validExample}}return{isValid:n,errors:r,warnings:i,endpointPath:t.endpointPath,method:t.method,exampleSource:t.exampleSource,exampleName:t.exampleName,validExample:o,coerced:a}}validateAiExamples({aiExamples:t,spec:r}){let i=[],n=[];for(let a of t){let{requestSchema:o,responseSchema:c}=this.getSchemasForEndpoint({spec:r,endpointPath:a.endpointPath,method:a.method}),f={endpointPath:a.endpointPath,method:a.method,exampleSource:"ai",requestExample:a.request?.body,responseExample:a.response?.body,requestSchema:o,responseSchema:c},s=this.validateEndpointExample({exampleToValidate:f}),u=this.hasUnexpectedProperties({requestExample:a.request?.body,responseExample:a.response?.body,requestSchema:o,responseSchema:c}),l=s.errors.length>0||s.warnings.length>0;!s.isValid||l||u?n.push({example:a,validationResult:s}):i.push(a)}return{validExamples:i,invalidExamples:n}}hasUnexpectedProperties({requestExample:t,responseExample:r,requestSchema:i,responseSchema:n}){return!!(t&&i&&this.exampleHasUnexpectedProperties(t,i)||r&&n&&this.exampleHasUnexpectedProperties(r,n))}exampleHasUnexpectedProperties(t,r){if(!t||typeof t!="object"||t===null)return!1;let i=this.context.resolveMaybeReference({schemaOrReference:r,breadcrumbs:[],skipErrorCollector:!0});if(!i||!i.properties)return!1;let n=t,a=new Set(Object.keys(i.properties));return Object.keys(n).some(c=>!a.has(c))}validateHumanExamples({spec:t}){let r=[],i=0,n=0,a=0,o=[],c=[];if(!t.paths)return{endpoints:r,totalExamples:i,validExamples:n,invalidExamples:a,hasInvalidHumanExamples:!1,hasInvalidAiExamples:!1,invalidHumanExamples:o,invalidAiExamples:c};for(let[f,s]of Object.entries(t.paths)){if(!s)continue;let u=["get","post","put","delete","patch","options","head","trace"];for(let l of u){let p=s[l];if(!p)continue;let _=[],{requestSchema:h,responseSchema:y}=this.getSchemasForOperation({operation:p}),b=this.extractExamplesFromOperation({operation:p,path:f,method:l});for(let v of b){i++;let O={endpointPath:f,method:l,exampleName:v.name,exampleSource:v.source,requestExample:v.request,responseExample:v.response,requestSchema:h,responseSchema:y},A=this.validateEndpointExample({exampleToValidate:O});_.push(A),A.isValid?n++:(a++,v.source==="human"?o.push(A):v.source==="ai"&&c.push(A))}_.length>0&&r.push({endpointPath:f,method:l,results:_,hasInvalidExamples:_.some(v=>!v.isValid),invalidExampleCount:_.filter(v=>!v.isValid).length})}}return{endpoints:r,totalExamples:i,validExamples:n,invalidExamples:a,hasInvalidHumanExamples:o.length>0,hasInvalidAiExamples:c.length>0,invalidHumanExamples:o,invalidAiExamples:c}}getSchemasForEndpoint({spec:t,endpointPath:r,method:i}){let n=t.paths?.[r];if(!n)return{};let a=n[i.toLowerCase()];return!a||typeof a!="object"||!("responses"in a)?{}:this.getSchemasForOperation({operation:a})}getSchemasForOperation({operation:t}){let r,i;if(t.requestBody&&!this.context.isReferenceObject(t.requestBody)){let a=t.requestBody.content?.["application/json"];a?.schema&&(r=a.schema)}if(t.responses){let n=t.responses[200]||t.responses[201];if(n&&!this.context.isReferenceObject(n)){let o=n.content?.["application/json"];o?.schema&&(i=o.schema)}}return{requestSchema:r,responseSchema:i}}extractExamplesFromOperation({operation:t,path:r,method:i}){let n=[];if(t.requestBody&&!this.context.isReferenceObject(t.requestBody)){let c=t.requestBody.content?.["application/json"];if(c?.example!==void 0&&n.push({name:`${i}_${r}_request_example`,source:"openapi",request:c.example}),c?.examples)for(let[f,s]of Object.entries(c.examples)){let u=this.context.isReferenceObject(s)?this.context.resolveExample(s):s;u&&typeof u=="object"&&"value"in u&&n.push({name:f,source:"human",request:u.value})}}if(t.responses)for(let[o,c]of Object.entries(t.responses)){if(!c||this.context.isReferenceObject(c))continue;let s=c.content?.["application/json"];if(s?.example!==void 0){let u=n.find(l=>l.request!==void 0&&l.response===void 0);u?u.response=s.example:n.push({name:`${i}_${r}_response_${o}_example`,source:"openapi",response:s.example})}if(s?.examples)for(let[u,l]of Object.entries(s.examples)){let p=this.context.isReferenceObject(l)?this.context.resolveExample(l):l;if(p&&typeof p=="object"&&"value"in p){let _=n.find(h=>h.name===u);_?_.response=p.value:n.push({name:u,source:"human",response:p.value})}}}let a=t["x-fern-examples"];if(Array.isArray(a)){for(let o of a)if(typeof o=="object"&&o!==null){let c=o;n.push({name:c.name,source:"human",request:c.request?.body,response:c.response?.body})}}return n}};var zFo={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",498:"InvalidTokenError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},R$S=new Set(Object.values(zFo));var nQn=class{enabled=!0;write(t,...r){this.enabled&&process.stderr.write(`[${t}] ${r.join(" ")}
1352
+ `)}var Y0a=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function Bac(e){return e.scheme==="oauth"}var VJS={optional:"optional",nullable:"nullable",set:"set",list:"list",map:"map",literal:"literal"},xu_=new Set(Object.values(VJS));function xS(e){let t=e.match(/([\w.]+)<([\w,\s]+)>/);if(t?.[0]!=null&&t[1]!=null&&t[2]!=null&&!xu_.has(t[1].trim()))return{name:t[1].trim(),arguments:t[2].split(",").map(r=>r.trim())}}function T0e(e){return xS(e)!=null}function Iac(e){if(e.request!=null)return typeof e.request=="string"?e.request:e.request.body}var MKi=class{REFERENCE_REGEX=/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/;validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let i=t.match(this.REFERENCE_REGEX);if(!(i==null||i[1]==null||i[2]==null))return{method:i[1],path:i[2]}}};function HP(e){return typeof e=="string"?!1:e?.extends!=null||e?.properties!=null}function t9t(e){return e?e.proto!=null:!1}var WJS="text";function bCi(e){return e===WJS}var bx={integer:"integer",long:"long",uint:"uint",uint64:"uint64",float:"float",double:"double",boolean:"boolean",string:"string",datetime:"datetime",base64:"base64",uuid:"uuid",date:"date",bigint:"bigint",unknown:"unknown"};var YH={MAP:/^map<\s*([^,]*)\s*,\s*(.*)\s*>$/,LIST:/^list<\s*(.*)\s*>$/,SET:/^set<\s*(.*)\s*>$/,OPTIONAL:/^optional<\s*(.*)\s*>$/,NULLABLE:/^nullable<\s*(.*)\s*>$/,LITERAL:/^literal<\s*(?:"(.*)"|(true|false))\s*>$/};function DKi({type:e,_default:t,validation:r,visitor:i}){switch(e){case bx.integer:{let u=r??void 0;return i.primitive({v1:Su.Integer,v2:bn.integer({default:t??void 0,validation:u!=null?{min:u.min,max:u.max,exclusiveMin:u.exclusiveMin,exclusiveMax:u.exclusiveMax,multipleOf:u.multipleOf}:void 0})})}case bx.double:{let u=r??void 0;return i.primitive({v1:Su.Double,v2:bn.double({default:t??void 0,validation:u!=null?{min:u.min,max:u.max,exclusiveMin:u.exclusiveMin,exclusiveMax:u.exclusiveMax,multipleOf:u.multipleOf}:void 0})})}case bx.string:{let u=r??void 0;return i.primitive({v1:Su.String,v2:bn.string({default:t??void 0,validation:u!=null?{format:u.format,pattern:u.pattern,minLength:u.minLength,maxLength:u.maxLength}:void 0})})}case bx.float:return i.primitive({v1:Su.Float,v2:void 0});case bx.long:return i.primitive({v1:Su.Long,v2:bn.long({default:t??void 0})});case bx.boolean:return i.primitive({v1:Su.Boolean,v2:bn.boolean({default:t??void 0})});case bx.datetime:return i.primitive({v1:Su.DateTime,v2:void 0});case bx.date:return i.primitive({v1:Su.Date,v2:void 0});case bx.uuid:return i.primitive({v1:Su.Uuid,v2:void 0});case bx.base64:return i.primitive({v1:Su.Base64,v2:void 0});case bx.bigint:return i.primitive({v1:Su.BigInteger,v2:bn.bigInteger({default:t??void 0})});case bx.uint:return i.primitive({v1:Su.Uint,v2:void 0});case bx.uint64:return i.primitive({v1:Su.Uint64,v2:void 0});case bx.unknown:return i.unknown()}let n=e.match(YH.MAP);if(n?.[1]!=null&&n[2]!=null)return i.map({keyType:n[1],valueType:n[2]});let a=e.match(YH.LIST);if(a?.[1]!=null)return i.list(a[1]);let o=e.match(YH.SET);if(o?.[1]!=null)return i.set(o[1]);let c=e.match(YH.OPTIONAL);if(c?.[1]!=null)return i.optional(c[1]);let f=e.match(YH.NULLABLE);if(f?.[1]!=null)return i.nullable(f[1]);let s=e.match(YH.LITERAL);if(s?.[1]!=null)return i.literal(iz.string(s[1]));if(s?.[2]!=null){let u=s[2];switch(u){case"false":return i.literal(iz.boolean(!1));case"true":return i.literal(iz.boolean(!0));default:throw new Error(`Unsupported literal value: ${u}`)}}return i.named(e)}var Gu_="bytes";function R0e(e){if(e===Gu_)return{isOptional:!1};if(e.match(YH.OPTIONAL)?.[1]===Gu_)return{isOptional:!0}}function X0a(e){let t=typeof e=="string"?e:typeof e.body=="string"?e.body:void 0;if(t!=null)return R0e(t)}function Cac({input:e,typeName:t}){for(let r of e.arguments)if(typeof r=="string"){if(r===t)return!0}else if(Cac({input:r,typeName:t}))return!0;return!1}function Hu_(e){return Cac({input:e,typeName:"file"})}function Ku_(e){let t=0,r=0;function i(){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t>=e.length)return;let a="";for(;t<e.length&&e[t]!=="<"&&e[t]!==","&&e[t]!==">";)a+=e[t++];if(a.trim()){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t<e.length&&e[t]==="<"){if(t++,r++,r>128)throw new Error("Internal error; Exceeded maximum recursion depth while parsing generics.");let o={name:a.trim(),arguments:[]};for(;t<e.length&&e[t]!==">";){for(;t<e.length&&/[\s,]/.test(e[t]);)t++;if(t<e.length&&e[t]!==">"){let c=i();c&&o.arguments.push(c)}}if(t<e.length&&e[t]===">")t++,r--;else throw new Error("Malformed input: missing closing '>' for generic arguments.");return o}else return a.trim()}}let n=i();if(typeof n=="object")return n}var qac="file";function Ju_(e){return e.match(YH.LIST)?.[1]===qac}function XH(e){if(e===qac)return{isOptional:!1,isArray:!1};let t=e.match(YH.OPTIONAL);if(t?.[1]!==void 0){if(t[1]===qac)return{isOptional:!0,isArray:!1};if(Ju_(t[1]))return{isOptional:!0,isArray:!0}}if(Ju_(e))return{isOptional:!1,isArray:!0}}function xJS(e){return typeof e=="string"?!1:oO.parse(e["content-type"])?.isMultiPartFormData()??!1?!0:e.body==null?!1:!!(HP(e.body)&&Object.values(e.body.properties??[]).some(HJS))}function BKi(e){if(!(!xJS(e)||e.body==null)&&e.name!=null&&e.body!=null&&HP(e.body))return GJS(e.name,e.body)}function GJS(e,t){let r=Object.entries(t.properties??[]).reduce((i,[n,a])=>{let o=typeof a!="string"?a.docs:void 0,c=typeof a!="string"?a["content-type"]:void 0,f=typeof a!="string"?a.style:void 0,s=XH(typeof a=="string"?a:a.type);return s!=null?i.push({isFile:!0,key:n,docs:o,isOptional:s.isOptional,isArray:s.isArray,contentType:c,style:f}):i.push({isFile:!1,key:n,propertyType:a,docs:o,contentType:c,style:f}),i},[]);return t["extra-properties"],{name:e,extends:t.extends,properties:r}}function HJS(e){let t=typeof e=="string"?e:e.type;if(t==="file")return!0;if(!t.includes("file"))return!1;let r=Ku_(t);return r==null?!1:Hu_(r)}var $u_="text";function IKi(e){if(e===$u_)return{isOptional:!1};if(e.match(YH.OPTIONAL)?.[1]===$u_)return{isOptional:!0}}function wB({type:e,_default:t,validation:r,visitor:i}){return DKi({type:e,_default:t,validation:r,visitor:{primitive:i.primitive,map:({keyType:n,valueType:a})=>i.map({keyType:wB({type:n,_default:void 0,validation:void 0,visitor:i}),valueType:wB({type:a,_default:void 0,validation:void 0,visitor:i})}),list:n=>i.list(wB({type:n,_default:void 0,validation:void 0,visitor:i})),set:n=>i.set(wB({type:n,_default:void 0,validation:void 0,visitor:i})),optional:n=>i.optional(wB({type:n,_default:t,validation:r,visitor:i})),nullable:n=>i.nullable(wB({type:n,_default:t,validation:r,visitor:i})),literal:i.literal,named:i.named,unknown:i.unknown}})}function Tac(e,t){if(KJS(e))return t.sdk(e);if(JJS(e))return t.language(e);Ot(e)}function KJS(e){return e.sdk!=null}function JJS(e){return e.language!=null}function Yu_(e){return e["response-stream"]!=null&&(typeof e["response-stream"]=="string"||e["response-stream"].format==null||e["response-stream"].format==="json")}function Xu_(e){return e["response-stream"]!=null&&typeof e["response-stream"]!="string"&&e["response-stream"].format==="sse"}function CKi(e,t,r){return $JS(e,t)?r.stream(t):YJS(e,t)?r.events(t):r.body(t)}function $JS(e,t){return t.stream!==void 0&&Yu_(e)}function YJS(e,t){return t.stream!==void 0&&Xu_(e)}function qKi(e,t){if(Zu_(e))return t.single(e);if(ku_(e))return t.any(e);Ot(e)}function Zu_(e){return typeof e=="string"||e.scheme!=null}function ku_(e){let[t,...r]=Object.keys(e);return t==="any"&&r.length===0}function Z0a(e,t){if(es_(e))return t.header(e);switch(e.scheme){case"basic":return t.basic(e);case"bearer":return"get-token"in e?t.inferredBearer(e):t.tokenBearer(e);case"oauth":return t.oauth(e);default:Ot(e)}}function es_(e){return e.header!=null}function r9t(e,t){if(ts_(e))return t.singleBaseUrl(e);if(vhe(e))return t.multipleBaseUrls(e);Ot(e)}function ts_(e){return typeof e=="string"||"url"in e}function vhe(e){return typeof e!="string"&&"urls"in e}function HFn(e){return typeof e=="string"?e.startsWith("$"):"variable"in e}function EB(e,t){if(vCi(e))return t.alias(e);if(gCi(e))return t.discriminatedUnion(e);if(db(e))return t.object(e);if(KFn(e))return t.undiscriminatedUnion(e);if(aFt(e))return t.enum(e);Ot(e)}function vCi(e){return typeof e=="string"||e.type!=null}function db(e){return e.extends!=null||e.properties!=null}function gCi(e){return e.union!=null&&e.discriminated==null}function KFn(e){let t=e;return t.union!=null&&t.discriminated!=null}function aFt(e){return e.enum!=null}function Rac({rawApiFileSchema:e,casingsGenerator:t}){if(e.auth==null)return{docs:void 0,requirement:I3.All,schemes:[]};let r=typeof e.auth!="string"?e.auth.docs:void 0;return qKi(e.auth,{single:i=>{let n=rs_({reference:i,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t});return{docs:r,requirement:I3.All,schemes:[n]}},any:({any:i})=>({docs:r,requirement:I3.Any,schemes:i.map(n=>rs_({reference:n,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t}))})})}function rs_({reference:e,authSchemeDeclarations:t,casingsGenerator:r}){let i=(a,o)=>{let c=t?.[a];if(c==null)throw new Error("Unknown auth scheme: "+a);return Z0a(c,{header:f=>wA.header({key:a,docs:o,name:r.generateNameAndWireValue({name:f.name??a,wireValue:f.header}),valueType:ii.primitive({v1:Su.String,v2:bn.string({default:void 0,validation:void 0})}),prefix:f.prefix,headerEnvVar:f.env}),basic:f=>is_({key:a,casingsGenerator:r,docs:o,rawScheme:f}),tokenBearer:f=>yFo({key:a,casingsGenerator:r,docs:o,rawScheme:f}),inferredBearer(f){return yFo({key:a,casingsGenerator:r,docs:o,rawScheme:void 0})},oauth:f=>yFo({key:a,casingsGenerator:r,docs:o,rawScheme:void 0})})},n=typeof e=="string"?e:e.scheme;switch(n){case"bearer":case"oauth":return yFo({key:n,casingsGenerator:r,docs:void 0,rawScheme:void 0});case"basic":return is_({key:n,casingsGenerator:r,docs:void 0,rawScheme:void 0});default:return i(n,typeof e!="string"?e.docs:void 0)}}function yFo({key:e,casingsGenerator:t,docs:r,rawScheme:i}){return wA.bearer({key:e,docs:r,token:t.generateName(i?.token?.name??"token"),tokenEnvVar:i?.token?.env})}function is_({key:e,casingsGenerator:t,docs:r,rawScheme:i}){return wA.basic({key:e,docs:r,username:t.generateName(i?.username?.name??"username"),usernameEnvVar:i?.username?.env,password:t.generateName(i?.password?.name??"password"),passwordEnvVar:i?.password?.env})}function mD(e){let t=ZJS(e),{value:r,done:i}=zac(t,"{");return i?{head:r,parts:[]}:{head:r,parts:[...XJS(t)]}}function*XJS(e){let t;do{let{value:r}=zac(e,"}"),i=zac(e,"{");t=i.done,yield{pathParameter:r,tail:i.value}}while(!t)}function*ZJS(e){for(let t of e)yield t}function zac(e,t){let r="",i=e.next();for(;i.done!==!0&&i.value!==t;)r+=i.value,i=e.next();return{value:r,done:i.done??!1}}function k0a({rawApiFileSchema:{"default-environment":e,environments:t},casingsGenerator:r}){if(t==null)return;let i=Object.values(t)[0];if(i!=null)return{environmentsConfig:{defaultEnvironment:e??void 0,environments:r9t(i,{singleBaseUrl:()=>$E.singleBaseUrl(kJS({environments:t,casingsGenerator:r})),multipleBaseUrls:n=>$E.multipleBaseUrls(e$S({baseUrls:Object.keys(n.urls),environments:t,casingsGenerator:r}))})},audiences:{...Object.fromEntries(Object.entries(t).map(([n,a])=>[n,r9t(a,{singleBaseUrl:o=>[...typeof o=="string"?[]:o.audiences??[]],multipleBaseUrls:o=>[...o.audiences??[]]})]))}}}function kJS({environments:e,casingsGenerator:t}){return{environments:Object.entries(e).map(([r,i])=>r9t(i,{singleBaseUrl:n=>({docs:typeof n=="string"?void 0:n.docs,id:r,name:t.generateName(r),url:ns_(typeof n=="string"?n:n.url)}),multipleBaseUrls:()=>{throw new Error(`Environment ${r} has multiple base URLs`)}}))}}function e$S({baseUrls:e,environments:t,casingsGenerator:r}){return{baseUrls:e.map(i=>({id:i,name:r.generateName(i)})),environments:Object.entries(t).map(([i,n])=>r9t(n,{multipleBaseUrls:a=>({docs:a.docs,id:i,name:r.generateName(i),urls:_n(a.urls,o=>ns_(o))}),singleBaseUrl:()=>{throw new Error(`Environment ${i} does not have multiple base URLs`)}}))}}function ns_(e){return e.endsWith("/")?e.slice(0,-1):e}function OCi(e){let t=2166136261;function r(n,a){if(typeof n=="object"&&n!=null){if(a>64){i("[MaxDepthExceeded]");return}if(Array.isArray(n)){i("[");for(let o=0;o<n.length;o++)o>0&&i(","),r(n[o],a+1);i("]")}else i("{"),Object.keys(n).sort().forEach((c,f)=>{f>0&&i(","),i(c),i(":"),r(n[c],a+1)}),i("}")}else i(String(n))}function i(n){for(let a=0;a<n.length;a++){let o=n.charCodeAt(a);t^=o,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24),t>>>=0}}return r(e,0),t.toString(16)}function i9t({typeReference:e,typeDeclarations:t}){if(e.type==="container"&&e.container.type==="optional")return!0;if(e.type==="named"){let r=t?.[e.typeId];if(r?.shape.type==="alias"&&r?.shape.resolvedType.type==="container"&&r?.shape.resolvedType.container.type==="optional")return!0}return!1}function as_({fieldName:e,containerType:t,maxDepth:r,currentDepth:i,typeDeclarations:n,skipOptionalProperties:a}){if(i>=r)return n9t({containerType:t});switch(t.type){case"list":{let o=MA({fieldName:e,typeReference:t.list,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?n9t({containerType:t}):{type:"success",example:op.list({list:[o.example,o.example],itemType:t.list}),jsonExample:[o.jsonExample,o.jsonExample]}}case"literal":return{type:"success",example:op.literal({literal:t.literal._visit({boolean:o=>Sn.boolean(o),string:o=>Sn.string({original:o}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:t.literal._visit({boolean:o=>o,string:o=>o,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":{if(a)return n9t({containerType:t});let o=MA({fieldName:e,typeReference:t.optional,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?n9t({containerType:t}):{type:"success",example:op.optional({optional:o.example,valueType:t.optional}),jsonExample:o.jsonExample}}case"nullable":{if(a)return n9t({containerType:t});let o=MA({fieldName:e,typeReference:t.nullable,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?n9t({containerType:t}):{type:"success",example:op.nullable({nullable:o.example,valueType:t.nullable}),jsonExample:o.jsonExample}}case"set":{let o=MA({fieldName:e,typeReference:t.set,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?n9t({containerType:t}):{type:"success",example:op.set({set:[o.example],itemType:t.set}),jsonExample:[o.jsonExample]}}case"map":{let o=MA({fieldName:e,typeReference:t.keyType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a}),c=MA({fieldName:e,typeReference:t.valueType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"||c.type==="failure"?n9t({containerType:t}):{type:"success",example:op.map({map:[{key:o.example,value:c.example}],keyType:t.keyType,valueType:t.valueType}),jsonExample:{[o.jsonExample]:c.jsonExample}}}default:Ot(t)}}function n9t({containerType:e}){switch(e.type){case"list":return{type:"success",example:op.list({list:[],itemType:e.list}),jsonExample:[]};case"literal":return{type:"success",example:op.literal({literal:e.literal._visit({boolean:t=>Sn.boolean(t),string:t=>Sn.string({original:t}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:e.literal._visit({boolean:t=>t,string:t=>t,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":return{type:"success",example:op.optional({optional:void 0,valueType:e.optional}),jsonExample:void 0};case"nullable":return{type:"success",example:op.nullable({nullable:void 0,valueType:e.nullable}),jsonExample:void 0};case"set":return{type:"success",example:op.set({set:[],itemType:e.set}),jsonExample:[]};case"map":return{type:"success",example:op.map({map:[],keyType:e.keyType,valueType:e.valueType}),jsonExample:{}};default:Ot(e)}}function us_({fieldName:e,primitiveType:t}){switch(t.v1){case"STRING":return a$S({fieldName:e,default_:t$S(t.v2),validation:r$S(t.v2)});case"BASE_64":return{type:"success",example:Sn.base64(Tn.BASE64),jsonExample:Tn.BASE64};case"BOOLEAN":return{type:"success",example:Sn.boolean(Tn.BOOLEAN),jsonExample:Tn.BOOLEAN};case"DATE":return{type:"success",example:Sn.date(Tn.DATE),jsonExample:Tn.DATE};case"DATE_TIME":return{type:"success",example:Sn.datetime({datetime:new Date(Tn.DATE_TIME),raw:Tn.DATE_TIME}),jsonExample:Tn.DATE_TIME};case"DOUBLE":return o$S({fieldName:e,validation:i$S(t.v2)});case"FLOAT":return{type:"success",example:Sn.float(Tn.FLOAT),jsonExample:Tn.FLOAT};case"INTEGER":return u$S({fieldName:e,validation:n$S(t.v2)});case"UINT_64":return{type:"success",example:Sn.uint64(Tn.INT64),jsonExample:Tn.INT64};case"UINT":return{type:"success",example:Sn.uint(Tn.UINT),jsonExample:Tn.UINT};case"BIG_INTEGER":return{type:"success",example:Sn.bigInteger(Tn.INT64.toString()),jsonExample:`${Tn.INT64}`};case"LONG":return{type:"success",example:Sn.long(Tn.INT64),jsonExample:Tn.INT64};case"UUID":return{type:"success",example:Sn.uuid(Tn.UUID),jsonExample:Tn.UUID};default:Ot(t.v1)}}function t$S(e){if(e?.type==="string")return e.default}function r$S(e){if(e?.type==="string")return e.validation}function i$S(e){if(e?.type==="double")return e.validation}function n$S(e){if(e?.type==="integer")return e.validation}function os_(e){if(e<=Tn.SAMPLE_STRINGS.length){let t=Tn.SAMPLE_STRINGS[e-1];if(t)return t;throw new Error(`Unexpected undefined value in SAMPLE_STRINGS at index ${e-1}`)}return Tn.SAMPLE_STRINGS[Tn.SAMPLE_STRINGS.length-1]+".".repeat(e-Tn.SAMPLE_STRINGS.length)}function a$S({fieldName:e,default_:t,validation:r}){if(t!=null)return{type:"success",example:Sn.string({original:t}),jsonExample:t};if(r){let n=r.minLength,a=r.maxLength;if(n){let o=os_(n);return{type:"success",example:Sn.string({original:o}),jsonExample:o}}else if(a!=null&&a<10){let o=os_(a);return{type:"success",example:Sn.string({original:o}),jsonExample:o}}}let i=e??Tn.STRING;return{type:"success",example:Sn.string({original:i}),jsonExample:i}}function o$S({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Sn.double(r),jsonExample:r};if(i)return{type:"success",example:Sn.double(i),jsonExample:i}}return{type:"success",example:Sn.double(Tn.DOUBLE),jsonExample:Tn.DOUBLE}}function u$S({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Sn.integer(r),jsonExample:r};if(i)return{type:"success",example:Sn.integer(i),jsonExample:i}}return{type:"success",example:Sn.integer(Tn.INT),jsonExample:Tn.INT}}function s$S(e,t){if(e.type==="primitive"||e.type==="container"&&e.container.type==="literal")return!0;if(e.type==="named"){let r=t[e.typeId];if(r!=null&&r.shape.type==="enum")return!0}return!1}function TKi({fieldName:e,typeDeclarations:t,typeDeclaration:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){switch(r.shape.type){case"alias":{let o=MA({fieldName:e,typeDeclarations:t,typeReference:r.shape.aliasOf,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(o.type==="failure")return o;let{example:c,jsonExample:f}=o;return{type:"success",example:Bh.alias({value:c}),jsonExample:f}}case"enum":{let o=r.shape.values[0];return o==null?{type:"failure",message:"No enum values present"}:{type:"success",example:Bh.enum({value:o.name}),jsonExample:o.name.wireValue}}case"object":{let o={},c=[];if((r.shape.extendedProperties==null||r.shape.extendedProperties.length===0)&&r.shape.extends!=null)for(let l of r.shape.extends){let p=t[l.typeId];if(p==null)continue;let _=TKi({fieldName:e,typeDeclaration:p,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});_!=null&&_.type==="success"&&_.example.type==="object"&&(Object.assign(o,_.jsonExample),c.push(..._.example.properties))}let f=c$S({fieldName:e,typeDeclaration:r,objectTypeDeclaration:r.shape,typeDeclarations:t,currentDepth:n,maxDepth:i,skipOptionalProperties:a});if(f.type==="failure")return f;let{example:s,jsonExample:u}=f;return{type:"success",example:Bh.object({properties:[...c,...s.properties],extraProperties:s.extraProperties}),jsonExample:Object.assign({},o,u)}}case"undiscriminatedUnion":{let o=r.shape.members;if(o.every(s=>s$S(s.type,t))){let s=o.findIndex(u=>{if(u.type.type==="container"&&u.type.container.type==="literal")return!0;if(u.type.type==="named"){let l=t[u.type.typeId];if(l!=null&&l.shape.type==="enum")return l.shape.values.length>0}return!1});if(s!==-1){let u=o[s];if(u!=null){let l=MA({fieldName:e,typeReference:u.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(l.type==="success"){let{example:p,jsonExample:_}=l;return{type:"success",example:Bh.undiscriminatedUnion({index:s,singleUnionType:p}),jsonExample:_}}}}}let f=0;for(let s of o){let u=MA({fieldName:e,typeReference:s.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(u.type==="failure"){++f;continue}let{example:l,jsonExample:p}=u;return{type:"success",example:Bh.undiscriminatedUnion({index:f,singleUnionType:l}),jsonExample:p}}break}case"union":{let o=r.shape.discriminant,c={};if(r.shape.baseProperties!=null)for(let u of r.shape.baseProperties){let l=MA({fieldName:u.name.wireValue,typeReference:u.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});l.type==="success"&&(c[u.name.wireValue]=l.jsonExample)}let f=r.shape.baseProperties.map(u=>{let l=MA({fieldName:u.name.wireValue,typeReference:u.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(l.type==="failure")throw new Error(`Failed to generate example for union base property ${u.name.wireValue}`);let{example:p}=l;return{name:u.name,value:p}}),s=r.shape.extends.flatMap(u=>{let l=t[u.typeId];if(l==null)throw new Error(`Failed to find extended type declaration with id ${u.typeId}`);let p=TKi({fieldName:e,typeDeclaration:l,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(p==null||p.type==="failure")throw new Error(`Failed to generate example for extended type declaration ${l.name.typeId}`);if(p.example.type!=="object")throw new Error(`Extended type declaration ${l.name.typeId} is not an object`);return p.example.properties});for(let u of r.shape.types){let l=u.shape._visit({noProperties:()=>({type:"success",example:Bh.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:jB.noProperties()},baseProperties:f,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,...c}}),samePropertiesAsObject:p=>{let _=t[p.typeId];if(_==null)return{type:"failure",message:`Failed to find type declaration with id ${p.typeId}`};let h=TKi({currentDepth:n,maxDepth:i,fieldName:e,typeDeclaration:_,typeDeclarations:t,skipOptionalProperties:a});if(h==null)return{type:"failure",message:"Failed to generate example for type reference"};if(h.type==="failure")return h;let{example:y,jsonExample:b}=h;return{type:"success",example:Bh.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:jB.samePropertiesAsObject({typeId:_.name.typeId,object:y.type==="object"?y:{properties:[],extraProperties:void 0}})},baseProperties:f,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,...typeof b=="object"?b:{},...c}}},singleProperty:p=>{let _=MA({currentDepth:n+1,maxDepth:i,fieldName:e,typeReference:p.type,typeDeclarations:t,skipOptionalProperties:a});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;return{type:"success",example:Bh.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:jB.singleProperty(h)},baseProperties:f,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,[p.name.wireValue]:y,...c}}},_other:()=>{throw new Error("Encountered unknown union type")}});if(l.type!=="failure")return l}}}return{type:"failure",message:"Failed to generate example for type reference"}}function c$S({fieldName:e,typeDeclaration:t,objectTypeDeclaration:r,typeDeclarations:i,maxDepth:n,currentDepth:a,skipOptionalProperties:o}){let c={},f=[];for(let s of[...r.properties??[],...r.extendedProperties??[]]){let u=MA({fieldName:s.name.wireValue,typeReference:s.valueType,typeDeclarations:i,currentDepth:a+1,maxDepth:n,skipOptionalProperties:o});if(u.type==="failure"&&!i9t({typeDeclarations:i,typeReference:s.valueType}))return{type:"failure",message:`Failed to generate required property ${s.name.wireValue} b/c ${u.message}`};if(u.type==="failure")continue;let{example:l,jsonExample:p}=u;f.push({name:s.name,originalTypeDeclaration:t.name,value:l,propertyAccess:s.propertyAccess}),c[s.name.wireValue]=p}return{type:"success",example:Bh.object({properties:f,extraProperties:void 0}),jsonExample:c}}function MA({fieldName:e,typeReference:t,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){if(n>i)return{type:"failure",message:`Exceeded max depth of ${i}`};switch(t.type){case"named":{let o=r[t.typeId];if(o==null)return{type:"failure",message:`Failed to find type declaration with id ${t.typeId}`};let c=TKi({fieldName:e,typeDeclaration:o,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(c==null)return{type:"failure",message:"Failed to generate example for type declaration"};if(c.type==="failure")return c;let{example:f,jsonExample:s}=c;return{type:"success",example:{jsonExample:s,shape:lu.named({shape:f,typeName:o.name})},jsonExample:s}}case"container":{let o=as_({fieldName:e,containerType:t.container,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(o.type==="failure"){let{example:s,jsonExample:u}=n9t({containerType:t.container});return{type:"success",example:{jsonExample:u,shape:lu.container(s)},jsonExample:u}}let{example:c,jsonExample:f}=o;return{type:"success",example:{jsonExample:f,shape:lu.container(c)},jsonExample:f}}case"primitive":{let{jsonExample:o,example:c}=us_({fieldName:e,primitiveType:t.primitive});return{type:"success",example:{jsonExample:o,shape:lu.primitive(c)},jsonExample:o}}case"unknown":{let o={key:"value"};return{type:"success",example:{jsonExample:o,shape:lu.unknown(o)},jsonExample:o}}}}function RKi(e,t){let r=[];for(let i of e){let n=MA({fieldName:i.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function JFn(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&i9t({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=MA({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function bFo(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&i9t({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=MA({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??10,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,shape:i.allowMultiple?M1.exploded():M1.single(),value:n.example})}return{type:"success",example:r,jsonExample:void 0}}var Nac=ii.primitive({v1:Su.String,v2:bn.string({default:void 0,validation:void 0})});function $Fn({ir:e,endpoint:t,service:r,typeDeclarations:i,skipOptionalRequestProperties:n,generationResponse:a}){let o={name:void 0,endpointHeaders:[],endpointPathParameters:[],queryParameters:[],servicePathParameters:[],serviceHeaders:[],rootPathParameters:[],request:void 0,response:L0.ok(xP.body(void 0)),docs:void 0},c=RKi(t.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(c.type==="failure")return c;o.endpointPathParameters=c.example;let f=RKi(r.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(f.type==="failure")return f;o.servicePathParameters=f.example;let s=RKi(e.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(s.type==="failure")return s;o.rootPathParameters=s.example;let u=bFo(t.queryParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:10});if(u.type==="failure")return u;o.queryParameters=u.example;let l=JFn(t.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(l.type==="failure")return l;o.endpointHeaders=l.example;let p=JFn(r.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(p.type==="failure")return p;if(o.serviceHeaders=p.example,t.requestBody!=null)switch(t.requestBody.type){case"bytes":return{type:"failure",message:"Bytes request unsupported"};case"fileUpload":return{type:"failure",message:"File upload unsupported"};case"inlinedRequestBody":{let _={},h=[];if(t.requestBody.extends!=null)for(let y of t.requestBody.extends){let b=i[y.typeId];if(b==null)throw new Error(`Failed to find extended type declaration with id ${y.typeId}`);let v=TKi({typeDeclaration:b,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});v!=null&&v.type==="success"&&Object.assign(_,v.jsonExample)}for(let y of[...t.requestBody.properties??[],...t.requestBody.extendedProperties??[]]){let b=MA({fieldName:y.name.wireValue,typeReference:y.valueType,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});if(b.type==="failure"&&!i9t({typeDeclarations:i,typeReference:y.valueType}))return{type:"failure",message:`Failed to generate required property ${y.name.wireValue} b/c ${b.message}`};if(b.type==="failure")continue;let{example:v,jsonExample:O}=b;h.push({name:y.name,originalTypeDeclaration:void 0,value:v}),_[y.name.wireValue]=O}o.request=T3.inlinedRequestBody({jsonExample:_,properties:h,extraProperties:void 0});break}case"reference":{let _=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.requestBody.requestBodyType,skipOptionalProperties:n});if(_.type==="failure")return _;let{example:h}=_;o.request=T3.reference(h);break}default:Ot(t.requestBody)}if(a.type==="success"&&t.response?.body!=null)switch(t.response.body.type){case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":{let _=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.responseBodyType,skipOptionalProperties:!1});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=L0.ok(xP.body({...h,jsonExample:y}));break}case"streamParameter":{let _;switch(t.response.body.nonStreamResponse.type){case"bytes":return{type:"failure",message:"Bytes unsupported"};case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":_=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.nonStreamResponse.value.responseBodyType,skipOptionalProperties:!1});break;case"text":_=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:Nac,skipOptionalProperties:!1});break;default:Ot(t.response.body.nonStreamResponse)}if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=L0.ok(xP.body({...h,jsonExample:y}));break}case"streaming":{let _;switch(t.response.body.value.type){case"sse":{if(_=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=L0.ok(xP.sse([{data:{...h,jsonExample:y},event:""}]));break}case"json":{if(_=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=L0.ok(xP.stream([{...h,jsonExample:y}]));break}case"text":{if(_=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:Nac,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=L0.ok(xP.stream([{...h,jsonExample:y}]));break}default:Ot(t.response.body.value)}break}case"text":{let _=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:Nac,skipOptionalProperties:!1});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=L0.ok(xP.body({...h,jsonExample:y}));break}case"bytes":return{type:"failure",message:"Bytes unsupported"};default:Ot(t.response.body)}else if(a.type==="error")if(a.declaration.type==null)o.response=L0.error({body:void 0,error:a.declaration.name});else{let _=MA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:a.declaration.type,skipOptionalProperties:n});if(_.type==="failure")return _;let{example:h}=_;o.response=L0.error({body:h,error:a.declaration.name})}try{return{type:"success",example:{id:OCi(o),url:l$S(t,o),...o},jsonExample:void 0}}catch(_){return{type:"failure",message:`Parse failure with exceptions ${_}`}}}function l$S(e,t){let r={};[...t.rootPathParameters,...t.servicePathParameters,...t.endpointPathParameters].forEach(n=>{let a=n.value.jsonExample,o=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=o});let i=e.fullPath.head+e.fullPath.parts.map(n=>encodeURIComponent(`${r[n.pathParameter]}`)+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function Fac({ir:e,channel:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let n={name:void 0,pathParameters:[],headers:[],queryParameters:[],messages:[],docs:void 0},a=RKi(t.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(a.type==="failure")return a;n.pathParameters.push(...a.example);let o=RKi(e.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(o.type==="failure")return o;n.pathParameters.push(...o.example);let c=bFo(t.queryParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:10});if(c.type==="failure")return c;n.queryParameters=c.example;let f=JFn(t.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(f.type==="failure")return f;n.headers.push(...f.example);let s=JFn(e.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(s.type==="failure")return s;n.headers.push(...s.example);let l=t.messages.filter(h=>h.origin==="client")[0];if(l!=null){let h=ss_({message:l,typeDeclarations:r,skipOptionalRequestProperties:i});h!=null&&n.messages.push({type:l.type,body:h})}let _=t.messages.filter(h=>h.origin==="server")[0];if(_!=null){let h=ss_({message:_,typeDeclarations:r,skipOptionalRequestProperties:i});h!=null&&n.messages.push({type:_.type,body:h})}return{type:"success",example:{...n,url:f$S(t,n)},jsonExample:void 0}}function ss_({message:e,typeDeclarations:t,skipOptionalRequestProperties:r}){if(e.body.type==="inlinedBody")return;let i=MA({currentDepth:0,maxDepth:10,typeDeclarations:t,typeReference:e.body.bodyType,skipOptionalProperties:r});if(i.type==="success")return yhe.reference(i.example)}function f$S(e,t){let r={};[...t.pathParameters].forEach(n=>{let a=n.value.jsonExample,o=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=o});let i=e.path.head+e.path.parts.map(n=>encodeURIComponent(`${r[n.pathParameter]}`)+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function YFn(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{},i=Object.values(t)[0],n=Object.values(r)[0];return{userExample:i,autoExample:n}}function ACi(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{};return{userExamples:t,autoExamples:r}}function cs_({ir:e,endpoint:t,skipOptionalRequestProperties:r}){let i=e.types,n={pathParameters:{},queryParameters:{},headers:{}};for(let o of t.pathParameters){let{userExample:c,autoExample:f}=YFn(o.v2Examples);c!==void 0?n.pathParameters[o.name.originalName]=c:f!==void 0&&(n.pathParameters[o.name.originalName]=f)}for(let o of t.queryParameters){let{userExample:c,autoExample:f}=YFn(o.v2Examples);if(c!==void 0)n.queryParameters[o.name.name.originalName]=c;else if(f!==void 0){if(r&&i9t({typeReference:o.valueType,typeDeclarations:i}))continue;n.queryParameters[o.name.name.originalName]=f}}let a=[...t.headers,...e.headers,...e.idempotencyHeaders];for(let o of a){let{userExample:c,autoExample:f}=YFn(o.v2Examples);if(c!==void 0)n.headers[o.name.wireValue]=c;else if(f!==void 0){if(r&&i9t({typeReference:o.valueType,typeDeclarations:i}))continue;n.headers[o.name.wireValue]=f}}return n}function ls_({endpoint:e,ir:t,skipOptionalRequestProperties:r}){let{pathParameters:i,queryParameters:n,headers:a}=cs_({endpoint:e,ir:t,skipOptionalRequestProperties:r}),o={},c={},f={endpoint:{method:e.method,path:d$S(e)},baseUrl:void 0,environment:e.baseUrl,auth:void 0,pathParameters:i,queryParameters:n,headers:a,requestBody:void 0,docs:void 0};if(e.requestBody!=null)switch(e.requestBody.type){case"bytes":break;case"fileUpload":{let{userExamples:s,autoExamples:u}=ACi(e.requestBody.v2Examples);for(let[l,p]of Object.entries(s))o[l]={...f,requestBody:p};for(let[l,p]of Object.entries(u))c[l]={...f,requestBody:p};break}case"inlinedRequestBody":{let{userExamples:s,autoExamples:u}=ACi(e.requestBody.v2Examples);for(let[l,p]of Object.entries(s))o[l]={...f,requestBody:p};for(let[l,p]of Object.entries(u))c[l]={...f,requestBody:p};break}case"reference":{let{userExamples:s,autoExamples:u}=ACi(e.requestBody.v2Examples);for(let[l,p]of Object.entries(s))o[l]={...f,requestBody:p};for(let[l,p]of Object.entries(u))c[l]={...f,requestBody:p};break}default:Ot(e.requestBody)}return{userRequestExamples:o,autoRequestExamples:c,baseExample:f}}function d$S(e){let t={};[...e.pathParameters,...e.allPathParameters].forEach(i=>{let{userExample:n,autoExample:a}=YFn(i.v2Examples),o=n??a,c;o==null?c=i.name.originalName:c=typeof o=="string"?o:JSON.stringify(o),t[i.name.originalName]=c});let r=e.fullPath.head+e.fullPath.parts.map(i=>encodeURIComponent(`${t[i.pathParameter]}`)+i.tail).join("");return r.startsWith("/")||r===""?r:`/${r}`}function vFo({endpoint:e,responseObject:t}){let r=t!==void 0?t:e.response,i={},n={},a={statusCode:r?.statusCode,body:void 0,docs:void 0};if(r==null)return{userResponseExamples:{},autoResponseExamples:{},baseExample:a};if(r.body==null)return e.source?.type==="openrpc"?{userResponseExamples:{},autoResponseExamples:{},baseExample:{...a,body:CC.json(ePa(null))}}:{userResponseExamples:{},autoResponseExamples:{},baseExample:a};switch(r.body.type){case"bytes":break;case"fileDownload":break;case"text":{let o=r.body,{userExamples:c,autoExamples:f}=ACi(o.v2Examples);for(let[s,u]of Object.entries(c)){let l=e.source?.type==="openrpc"?ePa(u):u;i[s]={...a,body:CC.json(l)}}for(let[s,u]of Object.entries(f)){let l=e.source?.type==="openrpc"?ePa(u):u;n[s]={...a,body:CC.json(l)}}break}case"json":{let o=r.body.value;if(o.type==="response"){let{userExamples:c,autoExamples:f}=ACi(o.v2Examples);for(let[s,u]of Object.entries(c)){let l=e.source?.type==="openrpc"?ePa(u):u;i[s]={...a,body:CC.json(l)}}for(let[s,u]of Object.entries(f)){let l=e.source?.type==="openrpc"?ePa(u):u;n[s]={...a,body:CC.json(l)}}}break}case"streaming":{let o=r.body.value;if(o.type==="json"){let{userExamples:c,autoExamples:f}=ACi(o.v2Examples);for(let[s,u]of Object.entries(c))i[s]={...a,body:CC.stream([u])};for(let[s,u]of Object.entries(f))n[s]={...a,body:CC.stream([u])}}break}case"streamParameter":break;default:Ot(r.body)}return{userResponseExamples:i,autoResponseExamples:n,baseExample:a}}function ePa(e,t=1){return{id:t,jsonrpc:"2.0",result:e}}var XFn=(e,t,r)=>{let i;return e===t?i=`${e}`:i=`${e}_${t}`,r&&(i=`${i}_${r}`),i},p$S=({exampleStore:e,key:t,example:r})=>e.has(t)?!1:(e.set(t,r),!0);function gFo({key:e,displayName:t,request:r,response:i,exampleStore:n,userOrAutoStore:a}){if(!n.has(e)){let o={displayName:t,request:r,response:i,codeSamples:void 0};return a[e]=o,p$S({exampleStore:n,key:e,example:o}),!0}return!1}function fs_({endpoint:e,ir:t,skipOptionalRequestProperties:r}){let i={},n={},a=new Map,{userRequestExamples:o,autoRequestExamples:c,baseExample:f}=ls_({endpoint:e,ir:t,skipOptionalRequestProperties:r}),s=Object.keys(o)[0],u=Object.values(o)[0],l=Object.keys(c)[0],p=Object.values(c)[0],_=_$S({endpoint:e,userRequestExamples:o,baseRequestExample:f,firstUserRequestName:s,firstUserRequestExample:u,firstAutoRequestName:l,firstAutoRequestExample:p,userResults:i,autoResults:n,exampleStore:a});if(h$S({endpoint:e,userRequestExamples:o,requestExamplesUsed:_,userResults:i,exampleStore:a}),Object.keys(i).length===0&&Object.keys(n).length===0){let{baseExample:h}=vFo({endpoint:e}),y=XFn(l??"base","base",void 0);gFo({key:y,displayName:l??"base",request:p??f,response:h,exampleStore:a,userOrAutoStore:n})}return{userFullExamples:i,autoFullExamples:n}}function _$S({endpoint:e,userRequestExamples:t,baseRequestExample:r,firstUserRequestName:i,firstUserRequestExample:n,firstAutoRequestName:a,firstAutoRequestExample:o,userResults:c,autoResults:f,exampleStore:s}){let u=e.v2Responses?.responses??[e.response],l=new Set;for(let p of u){let _=!1,{userResponseExamples:h,autoResponseExamples:y,baseExample:b}=vFo({endpoint:e,responseObject:p}),v=Object.keys(y)[0],O=Object.values(y)[0];for(let[A,g]of Object.entries(h)){let m,j;t[A]?(j=t[A],l.add(A),m=XFn(A,A,p?.statusCode)):o&&a?(j=o,m=XFn(a,A,p?.statusCode)):(j=r,m=XFn("base",A,p?.statusCode)),gFo({key:m,displayName:A,request:j,response:g,exampleStore:s,userOrAutoStore:c})&&(_=!0)}if(!_){let A=Fo(`${e.name.originalName}_example`);i&&n&&l.add(i);let g=XFn(i??a??"base",v??"base",p?.statusCode);gFo({key:g,displayName:i??a??A,request:n??o??r,response:O??b,exampleStore:s,userOrAutoStore:f})&&(_=!0)}}return l}function h$S({endpoint:e,userRequestExamples:t,requestExamplesUsed:r,userResults:i,exampleStore:n}){let{userResponseExamples:a,autoResponseExamples:o,baseExample:c}=vFo({endpoint:e}),f=Object.values(a)[0],s=Object.keys(a)[0],u=Object.keys(o)[0],l=Object.values(o)[0],p=Object.entries(t).filter(([_])=>!r.has(_));for(let[_,h]of p){let y=XFn(_,s??u??"base",f?f.statusCode:l?l.statusCode:c.statusCode);gFo({key:y,displayName:_,request:h,response:f??l??c,exampleStore:n,userOrAutoStore:i})}}function tPa({ir:e,exampleGeneration:t}){let r={disabled:t.disabled,includeOptionalRequestPropertyExamples:t.includeOptionalRequestPropertyExamples??!1,skipAutogenerationIfManualExamplesExist:t.skipAutogenerationIfManualExamplesExist??!1,skipErrorAutogenerationIfManualErrorExamplesExist:t.skipErrorAutogenerationIfManualErrorExamplesExist??!1};for(let[i,n]of Object.entries(e.services))for(let a of n.endpoints){let o=[];if(a.userSpecifiedExamples.length===0||r.skipAutogenerationIfManualExamplesExist===!1){let c=$Fn({ir:e,service:n,endpoint:a,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples,generationResponse:{type:"success"}});c.type==="success"&&o.push({example:c.example})}if(a.userSpecifiedExamples.filter(c=>c.example?.response.type==="error").length===0||r.skipErrorAutogenerationIfManualErrorExamplesExist===!1)for(let c of a.errors){let f=e.errors[c.error.errorId];if(!f)continue;let s=$Fn({ir:e,service:n,endpoint:a,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples,generationResponse:{type:"error",declaration:f}});s.type==="success"&&o.push({example:s.example})}a.autogeneratedExamples=o}for(let[i,n]of Object.entries(e.websocketChannels??{})){if(n.examples.length>0&&r.skipAutogenerationIfManualExamplesExist===!0)continue;let a=Fac({ir:e,channel:n,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(a.type==="failure")continue;let{example:o}=a;n.examples=[...n.examples,o]}return e}function Qac({ir:e,exampleGeneration:t}){let r={disabled:t.disabled,includeOptionalRequestPropertyExamples:t.includeOptionalRequestPropertyExamples??!1,skipAutogenerationIfManualExamplesExist:t.skipAutogenerationIfManualExamplesExist??!1,skipErrorAutogenerationIfManualErrorExamplesExist:t.skipErrorAutogenerationIfManualErrorExamplesExist??!1};for(let[i,n]of Object.entries(e.services))for(let a of n.endpoints){a.v2Examples==null&&(a.v2Examples={userSpecifiedExamples:{},autogeneratedExamples:{}});let{userFullExamples:o,autoFullExamples:c}=fs_({endpoint:a,ir:e,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(Object.keys(a.v2Examples.userSpecifiedExamples).length>0){if(Object.values(a.v2Examples.userSpecifiedExamples).some(s=>s.request!=null||s.response!=null))continue;let f=Object.values(a.v2Examples.userSpecifiedExamples).filter(s=>s!=null).flatMap(s=>s.codeSamples??[]);for(let[s,u]of Object.entries(c))c[s]={...u,codeSamples:f};for(let[s,u]of Object.entries(o))o[s]={...u,codeSamples:f}}a.v2Examples.autogeneratedExamples=c,a.v2Examples.userSpecifiedExamples=o}for(let[i,n]of Object.entries(e.websocketChannels??{})){if(n.examples.length>0&&r.skipAutogenerationIfManualExamplesExist===!0)continue;let a=Fac({ir:e,channel:n,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(a.type==="failure")continue;let{example:o}=a;n.examples=[...n.examples,o]}return e}function ps_({filteredIr:e,singleUnionTypeProperties:t}){return t._visit({samePropertiesAsObject:r=>{let i=e.hasTypeId(r.typeId)?{...r,object:{...r.object,properties:r.object.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:GS({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)}}:void 0;return i!==void 0?jB.samePropertiesAsObject(i):void 0},singleProperty:r=>{let i=GS({filteredIr:e,exampleTypeReference:r});return i!==void 0?jB.singleProperty(i):void 0},noProperties:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}})}function GS({filteredIr:e,exampleTypeReference:t}){return t.shape._visit({primitive:()=>t,container:r=>r._visit({list:i=>({...t,shape:lu.container(op.list({...i,list:i.list.map(n=>GS({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),set:i=>({...t,shape:lu.container(op.set({...i,set:i.set.map(n=>GS({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),optional:i=>{let n=i.optional!=null?GS({filteredIr:e,exampleTypeReference:i.optional}):void 0;return n!=null?{...t,shape:lu.container(op.optional({optional:n,valueType:i.valueType}))}:void 0},nullable:i=>{let n=i.nullable!=null?GS({filteredIr:e,exampleTypeReference:i.nullable}):void 0;return n!=null?{...t,shape:lu.container(op.nullable({nullable:n,valueType:i.valueType}))}:void 0},map:i=>({...t,shape:lu.container(op.map({...i,map:i.map.map(n=>{let a=GS({filteredIr:e,exampleTypeReference:n.key}),o=GS({filteredIr:e,exampleTypeReference:n.value});return a!==void 0&&o!==void 0?{key:a,value:o}:void 0}).filter(n=>n!==void 0)}))}),literal:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}}),named:r=>e.hasTypeId(r.typeName.typeId)?r.shape._visit({alias:i=>{let n=GS({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...t,shape:lu.named({...r,shape:Bh.alias({...i,value:n})})}:void 0},enum:i=>({...t,shape:lu.named({...r,shape:Bh.enum(i)})}),object:i=>({...t,shape:lu.named({...r,shape:Bh.object({...i,properties:i.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:GS({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)})})}),union:i=>{let n=ps_({filteredIr:e,singleUnionTypeProperties:i.singleUnionType.shape});return n!==void 0?{...t,shape:lu.named({...r,shape:Bh.union({...i,singleUnionType:{...i.singleUnionType,shape:n}})})}:void 0},undiscriminatedUnion:i=>{let n=GS({filteredIr:e,exampleTypeReference:i.singleUnionType});return n!==void 0?{...t,shape:lu.named({...r,shape:Bh.undiscriminatedUnion({...i,singleUnionType:n})})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}}):void 0,unknown:()=>t,_other:()=>t})}function Uac({filteredIr:e,pathParameters:t}){return t.map(r=>{let i=GS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function y$S({filteredIr:e,queryParameters:t}){return t.map(r=>{let i=GS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function ds_({filteredIr:e,headers:t}){return t.map(r=>{let i=GS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function b$S({filteredIr:e,requestBody:t}){return t._visit({inlinedRequestBody:r=>({...t,properties:r.properties.filter(i=>i.originalTypeDeclaration?e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue):!0).map(i=>{let n=GS({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...i,value:n}:void 0}).filter(i=>i!==void 0)}),reference:r=>{let i=GS({filteredIr:e,exampleTypeReference:r});return i!==void 0?T3.reference(i):void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function v$S({filteredIr:e,response:t}){return t._visit({ok:r=>r._visit({body:i=>L0.ok(xP.body(i!=null?GS({filteredIr:e,exampleTypeReference:i}):void 0)),stream:i=>L0.ok(xP.stream(i.map(n=>GS({filteredIr:e,exampleTypeReference:n})).filter(Zu))),sse:i=>L0.ok(xP.sse(i.map(({event:n,data:a})=>{let o=GS({filteredIr:e,exampleTypeReference:a});return o!==void 0?{event:n,data:o}:void 0}).filter(Zu))),_other:({type:i})=>{throw new Error(`Received unknown type for OK example: ${i}`)}}),error:({error:r,body:i})=>L0.error({error:r,body:i!=null?GS({filteredIr:e,exampleTypeReference:i}):void 0}),_other:({type:r})=>{throw new Error(`Received unknown type for example: ${r}`)}})}function Lac({filteredIr:e,example:t}){return{...t,rootPathParameters:Uac({filteredIr:e,pathParameters:t.rootPathParameters}),servicePathParameters:Uac({filteredIr:e,pathParameters:t.servicePathParameters}),endpointPathParameters:Uac({filteredIr:e,pathParameters:t.endpointPathParameters}),serviceHeaders:ds_({filteredIr:e,headers:t.serviceHeaders}),endpointHeaders:ds_({filteredIr:e,headers:t.endpointHeaders}),queryParameters:y$S({filteredIr:e,queryParameters:t.queryParameters}),request:t.request!==void 0?b$S({filteredIr:e,requestBody:t.request}):void 0,response:v$S({filteredIr:e,response:t.response})}}function _s_({filteredIr:e,exampleType:t}){return t.shape._visit({alias:r=>{let i=GS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...t,shape:Bh.alias({...r,value:i})}:void 0},enum:()=>t,object:r=>({...t,shape:Bh.object({...r,properties:r.properties.filter(i=>e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue)).map(i=>({...i,value:GS({filteredIr:e,exampleTypeReference:i.value})})).filter(i=>i.value!==void 0)})}),union:r=>{let i=ps_({filteredIr:e,singleUnionTypeProperties:r.singleUnionType.shape});return i!==void 0?{...t,shape:Bh.union({...r,singleUnionType:{...r.singleUnionType,shape:i}})}:void 0},undiscriminatedUnion:r=>{let i=GS({filteredIr:e,exampleTypeReference:r.singleUnionType});return i!==void 0?{...t,shape:Bh.undiscriminatedUnion({...r,singleUnionType:i})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function Vac(e,t){if(t==null)return e;let r=Dxi(e.types,c=>t.hasType(c)),i=Object.fromEntries(Object.entries(r).map(([c,f])=>{let s=[];if(f.userProvidedExamples=f.userProvidedExamples.map(u=>_s_({filteredIr:t,exampleType:u})).filter(u=>u!==void 0),f.shape.type==="object"){for(let u of f.shape.properties)t.hasProperty(c,u.name.wireValue)&&s.push(u);return[c,{...f,shape:Yc.object({...f.shape,properties:s})}]}return[c,f]})),n=Object.fromEntries(Object.entries(e.webhookGroups).map(([c,f])=>{let s=f.filter(u=>t.hasWebhook(u)).map(u=>{let l=u.id;return u.payload.type==="inlinedPayload"&&l!=null&&(u.payload={...u.payload,properties:u.payload.properties.filter(p=>t.hasWebhookPayloadProperty(l,p.name.wireValue))}),u});return[c,s]})),a=e.websocketChannels!=null?Object.fromEntries(Object.entries(e.websocketChannels).filter(([c])=>t.hasChannel(c)).map(([c,f])=>[c,{...f}])):{},o=e.environments;if(o){switch(o.environments.type){case"singleBaseUrl":{o.environments.environments=o.environments.environments.filter(c=>t.hasEnvironmentId(c.id));break}case"multipleBaseUrls":{o.environments.environments=o.environments.environments.filter(c=>t.hasEnvironmentId(c.id));break}}o.defaultEnvironment&&(t.hasEnvironmentId(o.defaultEnvironment)||(o.defaultEnvironment=void 0))}return{...e,environments:o,types:i,errors:Dxi(e.errors,c=>t.hasError(c)),services:_n(Dxi(e.services,c=>t.hasService(c)),c=>({...c,endpoints:c.endpoints.filter(f=>t.hasEndpoint(f)).map(f=>(f.autogeneratedExamples=f.autogeneratedExamples.map(s=>({...s,example:Lac({filteredIr:t,example:s.example})})),f.userSpecifiedExamples=f.userSpecifiedExamples.map(s=>({...s,example:s.example!=null?Lac({filteredIr:t,example:s.example}):void 0})),f.queryParameters.length>0&&(f.queryParameters=f.queryParameters.filter(s=>t.hasQueryParameter(f.id,s.name.wireValue))),f.requestBody?.type==="inlinedRequestBody"?{...f,requestBody:{...f.requestBody,properties:f.requestBody.properties.filter(s=>t.hasRequestProperty(f.id,s.name.wireValue))}}:f))})),websocketChannels:a,webhookGroups:n,serviceTypeReferenceInfo:g$S(e.serviceTypeReferenceInfo,t)}}function g$S(e,t){if(t==null)return e;let r={};return Object.entries(e.typesReferencedOnlyByService).forEach(([i,n])=>{t.hasServiceId(i)&&(r[i]=n.filter(a=>t.hasTypeId(a)))}),{sharedTypes:e.sharedTypes.filter(i=>t.hasTypeId(i)),typesReferencedOnlyByService:r}}function zKi(e){let t={};for(let[r,i]of Object.entries(e))if(typeof i!="string")for(let n of i.audiences??[])t[n]==null&&(t[n]=new Set),t[n]?.add(r);return t}function ghe(e){return e.allParts.map(t=>t.originalName).join("/")}var up={generateTypeId:e=>`type_${ghe(e.fernFilepath)}:${e.name.originalName}`,generateErrorId:e=>`error_${ghe(e.fernFilepath)}:${e.name.originalName}`,generateServiceId:e=>`service_${ghe(e.fernFilepath)}`,generateServiceIdFromFernFilepath:e=>`service_${ghe(e)}`,generateSubpackageId:e=>`subpackage_${ghe(e)}`,generateEndpointId:(e,t)=>{let r=ghe(e.fernFilepath),i=t.name.originalName;return`endpoint_${r}.${i}`},generateWebhookGroupId:e=>`webhooks_${ghe(e)}`,generateWebhookId:(e,t)=>`webhooks_${ghe(e)}.${t}`,generateWebSocketChannelId:e=>`channel_${ghe(e)}`};function ZFn(e){return e.type!=null}var OFo=class{environments=new Set;types=new Set;properties;errors=new Set;services=new Set;endpoints=new Set;requestProperties;queryParameters;webhooks=new Set;webhookPayloadProperties;channels=new Set;subpackages=new Set;constructor({types:t,properties:r,errors:i,environments:n,services:a,endpoints:o,webhooks:c,subpackages:f,queryParameters:s,requestProperties:u,webhookPayloadProperties:l,channels:p}){this.environments=n,this.types=t,this.properties=r,this.errors=i,this.services=a,this.endpoints=o,this.webhooks=c,this.webhookPayloadProperties=l,this.subpackages=f,this.requestProperties=u,this.queryParameters=s,this.channels=p}hasTypeId(t){return this.types.has(t)}hasErrorId(t){return this.errors.has(t)}hasServiceId(t){return this.services.has(t)}hasSubpackageId(t){return this.subpackages.has(t)}hasType(t){let r=up.generateTypeId(t.name);return this.types.has(r)}hasProperty(t,r){let i=this.properties[t];return i==null?!0:i.has(r)}hasError(t){let r=up.generateErrorId(t.name);return this.errors.has(r)}hasService(t){let r=up.generateServiceId(t.name);return this.services.has(r)}hasEnvironmentId(t){return this.environments.has(t)}hasEndpoint(t){return this.endpoints.has(t.id)}hasRequestProperty(t,r){let i=this.requestProperties[t];return i==null?!0:i.has(r)}hasQueryParameter(t,r){let i=this.queryParameters[t];return i==null?!0:i.has(r)}hasSubpackage(t){return this.subpackages.has(t)}hasWebhook(t){return t.id?this.webhooks.has(t.id):!0}hasChannel(t){return t?this.channels.has(t):!0}hasWebhookPayloadProperty(t,r){let i=this.webhookPayloadProperties[t];return i==null?!0:i.has(r)}};var NKi=class{types={};properties={};queryParameters={};requestProperties={};webhookProperties={};errors={};endpoints={};webhooks={};channels={};audiences;typesReferencedByService={};environmentsNeededForAudience=new Set;typesNeededForAudience=new Set;servicesNeededForAudience=new Set;endpointsNeededForAudience=new Set;webhooksNeededForAudience=new Set;channelsNeededForAudience=new Set;subpackagesNeededForAudience=new Set;constructor(t){this.audiences=O$S(t)}addType({declaredTypeName:t,descendantTypeIds:r,descendantFilepaths:i,descendantTypeIdsByAudience:n,propertiesByAudience:a}){let o=up.generateTypeId(t),c={typeId:o,allDescendants:r,descendantsByAudience:n,referencedSubpackages:i};this.types[o]=c,this.typesReferencedByService[o]==null&&(this.typesReferencedByService[o]=new Set),this.properties[o]={typeId:o,propertiesByAudience:a}}markTypeForAudiences(t,r){let i=up.generateTypeId(t);this.hasAudience(r)&&(this.typesNeededForAudience.add(i),this.addSubpackages(t.fernFilepath),this.types[i]?.referencedSubpackages.forEach(n=>{this.addSubpackages(n)}))}markEnvironmentForAudiences(t,r,i){t&&(this.hasAudience(r)||i)&&this.environmentsNeededForAudience.add(t.id)}getTypesReferencedByService(){for(let t of Object.values(this.endpoints))for(let r of t.referencedTypes)this.markTypeForService(r,t.serviceId);return this.typesReferencedByService}addError(t){let r=up.generateErrorId(t.name),i=new Set,n=new Set;t.type!=null&&XE(t.type,i,n);let a={errorId:r,referencedTypes:i,referencedSubpackages:n};this.errors[r]=a}addEndpoint(t,r,i){let n=up.generateServiceId(t.name),a=r.id,o=new Set,c=new Set,f=new Set;for(let s of[...t.headers,...r.headers])XE(s.valueType,o,f);for(let s of[...t.pathParameters,...r.pathParameters])XE(s.valueType,o,f);for(let s of r.queryParameters)XE(s.valueType,o,f);if(i!=null&&i.request!=null&&typeof i.request!="string"){let s=zKi(i.request["query-parameters"]??{});this.queryParameters[a]={endpointId:a,parametersByAudience:s}}r.requestBody!=null&&UO._visit(r.requestBody,{inlinedRequestBody:s=>{for(let u of s.extends)AFo(u,o,f);for(let u of s.properties)XE(u.valueType,o,f);if(i!=null&&typeof i.request=="object"&&typeof i.request.body=="object"&&HP(i.request.body)){let u=zKi(i.request.body.properties??{});this.requestProperties[a]={endpointId:a,propertiesByAudience:u}}},reference:({requestBodyType:s})=>{XE(s,o,f)},fileUpload:({properties:s})=>{for(let u of s)qC._visit(u,{file:Mt,bodyProperty:({valueType:l})=>{XE(l,o,f)},_other:()=>{throw new Error("Unknown FileUploadRequestProperty: "+u.type)}})},bytes:()=>{},_other:()=>{throw new Error("Unknown HttpRequestBody: "+r.requestBody?.type)}}),r.response?.body!=null&&Xf._visit(r.response.body,{fileDownload:Mt,json:s=>{XE(s.responseBodyType,o,f)},streaming:s=>{s._visit({sse:u=>XE(u.payload,o,f),json:u=>XE(u.payload,o,f),text:Mt,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.type)}})},streamParameter:s=>{s.streamResponse._visit({sse:u=>XE(u.payload,o,f),json:u=>XE(u.payload,o,f),text:Mt,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.streamResponse.type)}}),s.nonStreamResponse.type==="json"&&XE(s.nonStreamResponse.value.responseBodyType,o,f)},text:Mt,bytes:Mt,_other:()=>{throw new Error("Unknown HttpResponse: "+r.response?.body?.type)}}),r.errors.forEach(s=>{c.add(up.generateErrorId(s.error)),f.add(s.error.fernFilepath)}),this.endpoints[a]={endpointId:a,serviceId:n,referencedTypes:o,referencedErrors:c,referencedSubpackages:f}}markEndpointForAudience(t,r,i){if(this.hasAudience(i)){let n=up.generateServiceId(t);this.servicesNeededForAudience.add(n),r.forEach(a=>{let o=a.id;this.endpointsNeededForAudience.add(o),this.endpoints[o]?.referencedSubpackages.forEach(c=>{this.addSubpackages(c)})}),this.servicesNeededForAudience.add(n),this.addSubpackages(t.fernFilepath)}}getFilteredSubpackages(){return this.subpackagesNeededForAudience}getFilteredServices(){return this.servicesNeededForAudience}getFilteredEndpoints(){return this.endpointsNeededForAudience}getFilteredChannels(){return this.channelsNeededForAudience}getFilteredWebhooks(){return this.webhooksNeededForAudience}addWebhook(t,r,i){let n=r.id;if(n==null)return;let a=new Set,o=new Set;r.payload!=null&&VQ._visit(r.payload,{inlinedPayload:c=>{for(let f of c.extends)AFo(f,a,o);for(let f of c.properties)XE(f.valueType,a,o);if(i?.payload!=null&&typeof i.payload=="object"&&!ZFn(i.payload)){let f=zKi(i.payload.properties??{});this.webhookProperties[n]={webhookId:n,propertiesByAudience:f}}},reference:({payloadType:c})=>{XE(c,a,o)},_other:()=>{throw new Error("Unknown WebhookPayload: "+r.payload?.type)}}),o.add(t),this.webhooks[n]={webhookId:n,referencedTypes:a,referencedSubpackages:o}}markWebhookForAudiences(t,r,i){let n=r.id;n!=null&&this.hasAudience(i)&&(this.webhooksNeededForAudience.add(n),this.addSubpackages(t))}addChannel(t,r,i,n){if(r==null)return;let a=new Set,o=new Set;for(let c of i.messages)nz._visit(c.body,{reference:({bodyType:f})=>{XE(f,a,o)},inlinedBody:f=>{for(let s of f.extends)AFo(s,a,o);for(let s of f.properties)XE(s.valueType,a,o)},_other:()=>{}});for(let c of i.queryParameters)XE(c.valueType,a,o);o.add(t),this.channels[r]={channelId:r,referencedTypes:a,referencedSubpackages:o}}markChannelForAudiences(t,r,i){r!=null&&this.hasAudience(i)&&(this.channelsNeededForAudience.add(r),this.addSubpackages(t))}build(){let t=new Set,r=new Set;for(let c of this.endpointsNeededForAudience.keys()){let f=this.getEndpointNode(c);for(let s of f.referencedErrors){if(r.has(s))continue;r.add(s);let u=this.getErrorNode(s);this.addReferencedTypes(t,u.referencedTypes)}this.addReferencedTypes(t,f.referencedTypes)}this.addReferencedTypes(t,this.typesNeededForAudience);for(let c of this.webhooksNeededForAudience.keys()){let f=this.getWebhookNode(c);this.addReferencedTypes(t,f.referencedTypes)}for(let c of this.channelsNeededForAudience.keys()){let f=this.getChannelNode(c);this.addReferencedTypes(t,f.referencedTypes)}let i={},n={},a={},o={};if(this.audiences.type==="filtered"){for(let[c,f]of Object.entries(this.properties)){if(!t.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.propertiesByAudience[u];l?.forEach(p=>{s.add(p)})}s.size>0&&(i[c]=s),i[c]=s.size>0?s:void 0}for(let[c,f]of Object.entries(this.requestProperties)){if(!this.endpointsNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.propertiesByAudience[u];l?.forEach(p=>{s.add(p)})}n[c]=s.size>0?s:void 0}for(let[c,f]of Object.entries(this.queryParameters)){if(!this.endpointsNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.parametersByAudience[u];l?.forEach(p=>{s.add(p)})}a[c]=s.size>0?s:void 0}for(let[c,f]of Object.entries(this.webhookProperties)){if(!this.webhooksNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.propertiesByAudience[u];l?.forEach(p=>{s.add(p)})}o[c]=s.size>0?s:void 0}}return new OFo({types:t,properties:i,errors:r,requestProperties:n,queryParameters:a,environments:this.environmentsNeededForAudience,services:this.servicesNeededForAudience,endpoints:this.endpointsNeededForAudience,webhooks:this.webhooksNeededForAudience,webhookPayloadProperties:o,subpackages:this.subpackagesNeededForAudience,channels:this.channelsNeededForAudience})}markTypeForService(t,r){let i=this.typesReferencedByService[t]??=new Set;if(i.has(r))return;i.add(r);let n=this.getTypeNode(t);for(let a of n.allDescendants)this.markTypeForService(a,r)}addReferencedTypes(t,r){for(let i of r){if(t.has(i))continue;t.add(i);let n=this.getTypeNode(i);if(this.audiences.type==="filtered")for(let a of this.audiences.audiences){let o=n.descendantsByAudience[a];if(o!=null)o.forEach(c=>{t.add(c)});else{n.allDescendants.forEach(c=>{t.add(c)});break}}else n.allDescendants.forEach(a=>{t.add(a)})}}getTypeNode(t){let r=this.types[t];if(r==null)throw new Error(`Failed to find type node with id ${t}`);return r}getErrorNode(t){let r=this.errors[t];if(r==null)throw new Error(`Failed to find error node with id ${t}`);return r}getEndpointNode(t){let r=this.endpoints[t];if(r==null)throw new Error(`Failed to find endpoint node with id ${t}`);return r}getWebhookNode(t){let r=this.webhooks[t];if(r==null)throw new Error(`Failed to find webhook node with id ${t}`);return r}getChannelNode(t){let r=this.channels[t];if(r==null)throw new Error(`Failed to find channel node with id ${t}`);return r}hasNoAudiences(){return this.audiences.type==="none"}hasAudience(t){let r=this.audiences;switch(r.type){case"none":return!0;case"filtered":return t.some(i=>r.audiences.has(i));default:Ot(r)}}addSubpackages(t){for(let r=1;r<=t.allParts.length;++r){let i={...t,allParts:t.allParts.slice(0,r)};this.subpackagesNeededForAudience.add(up.generateSubpackageId(i))}}};function O$S(e){switch(e.type){case"all":return{type:"none"};case"select":return{type:"filtered",audiences:new Set(e.audiences)};default:Ot(e)}}function XE(e,t,r){ii._visit(e,{container:i=>{A$S(i,t,r)},named:i=>{AFo(i,t,r)},primitive:Mt,unknown:Mt,_other:Mt})}function AFo(e,t,r){t.add(up.generateTypeId(e)),r.add(e.fernFilepath)}function A$S(e,t,r){ns._visit(e,{list:i=>{XE(i,t,r)},map:i=>{XE(i.keyType,t,r),XE(i.valueType,t,r)},optional:i=>{XE(i,t,r)},nullable:i=>{XE(i,t,r)},set:i=>{XE(i,t,r)},literal:Mt,_other:Mt})}var m$S=[vr.AvailabilityStatus.GeneralAvailability];function qvi(e){return e!==void 0&&!m$S.includes(e.status)}var Wac=class{errors;constructor(){this.errors=[]}add(t){this.errors.push({message:t})}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}},rPa=class{errors;constructor(){this.errors=new Wac}async check({from:t,to:r}){let i=this.toInternalIr(t),n=this.toInternalIr(r),a=OCi(i),o=OCi(n);if(a===o)return{bump:"no_change",isBreaking:!1,errors:[]};let c=this.checkBreaking({from:i,to:n});return{bump:c.isBreaking?"major":"minor",isBreaking:c.isBreaking,errors:c.errors}}toInternalIr(t){return{types:t.types,errors:t.errors,services:t.services}}checkBreaking({from:t,to:r}){this.checkTypeBreakingChanges({from:t.types,to:r.types}),this.checkErrorsBreakingChanges({from:t.errors,to:r.errors}),this.checkServicesBreakingChanges({from:t.services,to:r.services});let i=this.errors.hasErrors();return{bump:i?"major":"minor",isBreaking:i,errors:this.errors.getErrors()}}checkTypeBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){if(qvi(n.availability))continue;let a=r[i];if(!a){this.errors.add(`Type "${i}" was removed.`);continue}if(qvi(a.availability)){this.errors.add(`Type "${i}" was moved from stable to unstable availability status.`);continue}this.areTypeDeclarationsCompatible({from:n,to:a})||this.errors.add(`Type "${i}" has an incompatible change.`)}}checkErrorsBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){let a=Object.values(r).find(o=>o.name.errorId===n.name.errorId);if(!a){this.errors.add(`Error "${n.name.errorId}" with status code "${n.statusCode}" was removed.`);continue}this.checkErrorBreakingChanges({from:n,to:a})}}checkErrorBreakingChanges({from:t,to:r}){if(t.type!=null){if(r.type==null){this.errors.add(`Error "${t.name.errorId}" with status code "${t.statusCode}" had its type removed.`);return}this.areTypeReferencesCompatible({from:t.type,to:r.type})||this.errors.add(`Error "${t.name.errorId}" type reference changed.`)}this.areDeclaredErrorNamesCompatible({from:t.name,to:r.name})||this.errors.add(`Error "${t.name.errorId}" name changed.`),this.areNameAndWireValuesCompatible({from:t.discriminantValue,to:r.discriminantValue})||this.errors.add(`Error "${t.name.errorId}" discriminant value changed.`)}checkServicesBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){if(qvi(n.availability)||(n.endpoints?.every(o=>qvi(o.availability))??!1))continue;let a=r[i];if(!a){this.errors.add(`Service "${i}" was removed.`);continue}if(qvi(a.availability)){this.errors.add(`Service "${i}" was moved from stable to unstable availability status.`);continue}this.checkServiceBreakingChanges({id:i,from:n,to:a})}}checkServiceBreakingChanges({id:t,from:r,to:i}){this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),this.checkEndpointsBreakingChanges({id:t,from:r,to:i})}checkEndpointsBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.endpoints.map(o=>[o.id,o])),a=Object.fromEntries(i.endpoints.map(o=>[o.id,o]));for(let[o,c]of Object.entries(n)){if(qvi(c.availability))continue;let f=a[o];if(!f){this.errors.add(`Endpoint "${o}" was removed.`);continue}if(qvi(f.availability)){this.errors.add(`Endpoint "${o}" was moved from stable to unstable availability status.`);continue}this.checkEndpointBreakingChanges({id:o,from:c,to:f})}}checkEndpointBreakingChanges({id:t,from:r,to:i}){this.checkHttpMethodsBreakingChanges({id:t,from:r.method,to:i.method}),this.checkHttpPathsBreakingChanges({id:t,from:r.fullPath,to:i.fullPath}),this.checkPathParametersBreakingChanges({id:t,from:r.pathParameters,to:i.pathParameters}),this.checkQueryParametersBreakingChanges({id:t,from:r.queryParameters,to:i.queryParameters}),this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),r.requestBody!=null&&(i.requestBody!=null?this.checkHttpRequestBodiesCompatible({id:t,from:r.requestBody,to:i.requestBody}):this.errors.add(`Request body was removed from endpoint "${r.id}".`)),r.response!=null&&(i.response!=null?this.checkHttpResponseBreakingChanges({id:t,from:r.response,to:i.response}):this.errors.add(`Response was removed from endpoint "${r.id}".`)),(r.pagination!=null&&i.pagination==null||r.pagination==null&&i.pagination!=null)&&this.errors.add(`Pagination was ${r.pagination!=null?"added":"removed"} from endpoint "${r.id}".`)}checkPathParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.originalName,o])),a=Object.fromEntries(i.map(o=>[o.name.originalName,o]));for(let[o,c]of Object.entries(n)){let f=a[o];if(!f){this.errors.add(`Path parameter "${o}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:f.valueType})||this.errors.add(`Path parameter "${o}" type changed in endpoint "${t}".`)}}checkQueryParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.wireValue,o])),a=Object.fromEntries(i.map(o=>[o.name.wireValue,o]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([o,c])=>[o,c.valueType])),to:Object.fromEntries(Object.entries(a).map(([o,c])=>[o,c.valueType]))});for(let[o,c]of Object.entries(n)){let f=a[o];if(!f){this.errors.add(`Query parameter "${o}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:f.valueType})||this.errors.add(`Query parameter "${o}" type changed in endpoint "${t}".`),c.allowMultiple!==f.allowMultiple&&this.errors.add(`Query parameter "${o}" allow-multiple values changed in endpoint "${t}".`)}}checkHeadersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.wireValue,o])),a=Object.fromEntries(i.map(o=>[o.name.wireValue,o]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([o,c])=>[o,c.valueType])),to:Object.fromEntries(Object.entries(a).map(([o,c])=>[o,c.valueType]))});for(let[o,c]of Object.entries(n)){let f=a[o];if(!f){this.errors.add(`Header "${o}" was removed from ${t}.`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:f.valueType})||this.errors.add(`Header "${o}" type changed in ${t}.`)}}checkHttpMethodsBreakingChanges({id:t,from:r,to:i}){r!==i&&this.errors.add(`HTTP method changed in ${t}.`)}checkHttpPathsBreakingChanges({id:t,from:r,to:i}){this.areHttpPathsCompatible({from:r,to:i})||this.errors.add(`HTTP path changed in ${t}.`)}areHttpPathsCompatible({from:t,to:r}){if(t.head!==r.head||t.parts.length!==r.parts.length)return!1;for(let i=0;i<t.parts.length;i++){let n=t.parts[i];if(n==null)return!1;let a=r.parts[i];if(a==null||n.pathParameter!==a.pathParameter||n.tail!==a.tail)return!1}return!0}checkHttpRequestBodiesCompatible({id:t,from:r,to:i}){switch(r.type){case"inlinedRequestBody":if(i.type==="inlinedRequestBody"&&this.areInlinedRequestBodiesCompatible({from:r,to:i}))return;break;case"reference":if(i.type==="reference"&&this.areReferenceRequestBodiesCompatible({from:r,to:i}))return;break;case"fileUpload":if(i.type==="fileUpload"&&this.areFileUploadRequestBodiesCompatible({from:r,to:i}))return;break;case"bytes":if(i.type==="bytes")return;break;default:Ot(r)}this.errors.add(`Request body type changed from "${r.type}" to "${i.type}" in endpoint "${t}".`)}areInlinedRequestBodiesCompatible({from:t,to:r}){let i=this.getInlinedRequestBody(t),n=this.getInlinedRequestBody(r);return this.checkForNewInlinedRequestBodyProperties({from:i,to:n}),Object.entries(i).every(([a,o])=>{let c=n[a];return c?this.areTypeReferencesCompatible({from:o,to:c}):(this.errors.add(`Request body property "${a}" was removed.`),!1)})}areReferenceRequestBodiesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.requestBodyType,to:r.requestBodyType})}areFileUploadRequestBodiesCompatible({from:t,to:r}){let i=this.getFileUploadRequest(t.properties),n=this.getFileUploadRequest(r.properties);this.checkForNewFileUploadRequestProperties({from:i,to:n});for(let[a,o]of Object.entries(i)){let c=n[a];if(!c)return this.errors.add(`File upload property "${a}" was removed.`),!1;if(o==="file"&&c!=="file")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(o==="fileArray"&&c!=="fileArray")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(o!=="file"&&o!=="fileArray"&&c!=="file"&&c!=="fileArray"&&!this.areTypeReferencesCompatible({from:o,to:c}))return this.errors.add(`File upload property "${a}" type changed.`),!1}return!0}checkHttpResponseBreakingChanges({id:t,from:r,to:i}){if(r.statusCode!==i.statusCode&&this.errors.add(`Response status code changed from "${r.statusCode}" to "${i.statusCode}".`),!(r.body==null&&i.body==null)){if(r.body==null||i.body==null){this.errors.add(`Response body was ${r.body==null?"added":"removed"}.`);return}switch(r.body.type){case"json":if(i.body.type==="json"){this.areJsonResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"fileDownload":if(i.body.type==="fileDownload")return;break;case"text":if(i.body.type==="text")return;break;case"bytes":if(i.body.type==="bytes")return;break;case"streaming":if(i.body.type==="streaming"){this.areStreamingResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"streamParameter":if(i.body.type==="streamParameter"){this.areStreamingResponsesCompatible({from:r.body.streamResponse,to:i.body.streamResponse});return}break;default:Ot(r.body)}this.errors.add(`HTTP response type "${r.body.type}" defined for endpoint "${t}" is not compatible with type "${i.body.type}".`)}}areJsonResponsesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.responseBodyType,to:r.responseBodyType})}areStreamingResponsesCompatible({from:t,to:r}){switch(t.type){case"json":if(r.type==="json")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"sse":if(r.type==="sse")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"text":if(r.type==="text")return!0;break;default:Ot(t)}return this.errors.add(`Streaming response type "${t.type}" is not compatible with type "${r.type}".`),!1}areTypeDeclarationsCompatible({from:t,to:r}){return qvi(t.availability)?!0:this.areDeclaredTypeNamesCompatible({from:t.name,to:r.name})&&this.areTypeShapesCompatible({from:t.shape,to:r.shape})}areTypeShapesCompatible({from:t,to:r}){switch(t.type){case"alias":if(r.type==="alias")return this.areAliasTypesCompatible({from:t,to:r});break;case"enum":if(r.type==="enum")return this.areEnumTypesCompatible({from:t,to:r});break;case"object":if(r.type==="object")return this.areObjectTypesCompatible({from:t,to:r});break;case"union":if(r.type==="union")return this.areUnionTypesCompatible({from:t,to:r});break;case"undiscriminatedUnion":if(r.type==="undiscriminatedUnion")return this.areUndiscriminatedUnionTypesCompatible({from:t,to:r});break;default:Ot(t)}return this.errors.add(`Type "${t.type}" is not compatible with type "${r.type}".`),!1}areAliasTypesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.aliasOf,to:r.aliasOf})}areEnumTypesCompatible({from:t,to:r}){let i=Object.fromEntries(t.values.map(a=>[a.name.wireValue,a])),n=Object.fromEntries(r.values.map(a=>[a.name.wireValue,a]));return Object.keys(i).length!==Object.keys(n).length?!1:Object.values(i).every(a=>{let o=n[a.name.wireValue];return o?this.areNameAndWireValuesCompatible({from:a.name,to:o.name}):(this.errors.add(`Enum value "${a.name.wireValue}" was removed.`),!1)})}areObjectTypesCompatible({from:t,to:r}){let i=Object.fromEntries([...t.properties.map(a=>[a.name.wireValue,a]),...t.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]),n=Object.fromEntries([...r.properties.map(a=>[a.name.wireValue,a]),...r.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]);return this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(i).map(([a,o])=>[a,o.valueType])),to:Object.fromEntries(Object.entries(n).map(([a,o])=>[a,o.valueType]))}),Object.values(i).every(a=>{let o=n[a.name.wireValue];return o?this.areObjectPropertiesCompatible({from:a,to:o}):(this.errors.add(`Object property "${a.name.wireValue}" was removed.`),!1)})}areObjectPropertiesCompatible({from:t,to:r}){return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType})}areUnionTypesCompatible({from:t,to:r}){if(!this.areNameAndWireValuesCompatible({from:t.discriminant,to:r.discriminant}))return this.errors.add(`Union type with discriminant value "${t.discriminant.wireValue}" changed.`),!1;let i=new Set(t.extends.map(s=>this.getKeyForDeclaration(s))),n=new Set(r.extends.map(s=>this.getKeyForDeclaration(s)));for(let s of i)if(!n.has(s))return this.errors.add(`Extended type "${s}" was removed.`),!1;let a=Object.fromEntries(t.baseProperties.map(s=>[s.name.wireValue,s])),o=Object.fromEntries(r.baseProperties.map(s=>[s.name.wireValue,s]));for(let s of Object.values(a)){let u=o[s.name.wireValue];if(!u)return this.errors.add(`Union type with discriminant value "${s.name.wireValue}" no longer has a property named "${s.name.wireValue}".`),!1;if(!this.areObjectPropertiesCompatible({from:s,to:u}))return!1}this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(a).map(([s,u])=>[s,u.valueType])),to:Object.fromEntries(Object.entries(o).map(([s,u])=>[s,u.valueType]))});let c=Object.fromEntries(t.types.map(s=>[s.discriminantValue.wireValue,s])),f=Object.fromEntries(r.types.map(s=>[s.discriminantValue.wireValue,s]));return Object.values(c).every(s=>{let u=f[s.discriminantValue.wireValue];return u?this.areSingleUnionTypesCompatible({from:s.shape,to:u.shape}):(this.errors.add(`Union type for discriminant value "${s.discriminantValue.wireValue}" was removed.`),!1)})}areSingleUnionTypesCompatible({from:t,to:r}){switch(t.propertiesType){case"samePropertiesAsObject":if(r.propertiesType==="samePropertiesAsObject")return this.areDeclaredTypeNamesCompatible({from:t,to:r});break;case"singleProperty":if(r.propertiesType==="singleProperty")return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.type,to:r.type});break;case"noProperties":if(r.propertiesType==="noProperties")return!0;break;default:Ot(t)}return this.errors.add(`Single union type of style "${t.propertiesType}" is not compatible with style "${r.propertiesType}".`),!1}areUndiscriminatedUnionTypesCompatible({from:t,to:r}){return t.members.every((i,n)=>{let a=r.members[n];return a?this.areTypeReferencesCompatible({from:i.type,to:a.type}):(this.errors.add(`Undiscriminated union member at index ${n} was removed.`),!1)})}checkForNewRequiredTypeReferences({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewFileUploadRequestProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||n==="file"||n==="fileArray"||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewInlinedRequestBodyProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}areTypeReferencesCompatible({from:t,to:r}){switch(t.type){case"primitive":if(r.type==="primitive")return this.arePrimitiveTypesCompatible({from:t,to:r});break;case"container":if(r.type==="container")return this.areContainerTypesCompatible({from:t.container,to:r.container});break;case"named":if(r.type==="named")return this.areNamedTypesCompatible({from:t,to:r});break;case"unknown":if(r.type==="unknown")return!0;break;default:Ot(t)}return this.errors.add(`TypeReference "${t.type}" is not compatible with type "${r.type}".`),!1}arePrimitiveTypesCompatible({from:t,to:r}){return t.primitive.v1===r.primitive.v1}areContainerTypesCompatible({from:t,to:r}){switch(t.type){case"list":if(r.type==="list")return this.areTypeReferencesCompatible({from:t.list,to:r.list});break;case"set":if(r.type==="set")return this.areTypeReferencesCompatible({from:t.set,to:r.set});break;case"map":if(r.type==="map")return this.areTypeReferencesCompatible({from:t.keyType,to:r.keyType})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType});break;case"optional":if(r.type==="optional")return this.areTypeReferencesCompatible({from:t.optional,to:r.optional});break;case"nullable":if(r.type==="nullable")return this.areTypeReferencesCompatible({from:t.nullable,to:r.nullable});break;case"literal":if(r.type==="literal")return this.areLiteralsCompatible({from:t.literal,to:r.literal});break;default:Ot(t)}return this.errors.add(`Container type "${t.type}" is not compatible with type "${r.type}".`),!1}areNamedTypesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredTypeNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredErrorNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areNameAndWireValuesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&t.wireValue===r.wireValue}areLiteralsCompatible({from:t,to:r}){switch(t.type){case"boolean":if(r.type==="boolean")return t.boolean===r.boolean;break;case"string":if(r.type==="string")return t.string===r.string;break;default:Ot(t)}return!1}areFernFilepathsCompatible({from:t,to:r}){return t.allParts.length!==r.allParts.length?!1:t.allParts.every((i,n)=>{let a=r.allParts[n];return a==null?!1:this.areNamesCompatible({from:i,to:a})})}areNamesCompatible({from:t,to:r}){return t.originalName===r.originalName}getInlinedRequestBody(t){let r={};for(let i of[...t.extendedProperties??[],...t.properties])r[i.name.wireValue]=i.valueType;return r}getFileUploadRequest(t){let r={};for(let i of t)switch(i.type){case"file":r[i.value.key.wireValue]="file";break;case"bodyProperty":r[i.name.wireValue]=i.valueType;break;default:Ot(i)}return r}getKeyForDeclaration({name:t,fernFilepath:r}){return`${r.allParts.map(n=>n.camelCase.unsafeName).join(".")}.${t.pascalCase.unsafeName}`}};function FKi(e,t,r){let{environments:i,changedBaseUrlIds1:n,changedBaseUrlIds2:a}=j$S(e.environments,t.environments,r),{services:o,websocketChannels:c}=w$S(e,t,n,a);return{apiName:e.apiName,basePath:e.basePath,selfHosted:e.selfHosted&&t.selfHosted,apiDisplayName:e.apiDisplayName??t.apiDisplayName,apiDocs:e.apiDocs??t.apiDocs,auth:{requirement:e.auth?.requirement??t.auth?.requirement,schemes:t.auth?.schemes?.length!=null&&t.auth.schemes.length>(e.auth?.schemes?.length??0)?t.auth.schemes:e.auth?.schemes??[],docs:e.auth?.docs??t.auth?.docs},headers:[...e.headers??[],...t.headers??[]],environments:i,types:{...e.types??{},...t.types??{}},constants:{...e.constants??{},...t.constants??{}},errors:{...e.errors??{},...t.errors??{}},services:o,webhookGroups:{...e.webhookGroups??{},...t.webhookGroups??{}},subpackages:P$S(e.subpackages,t.subpackages),websocketChannels:c,rootPackage:{service:e.rootPackage.service??t.rootPackage.service,types:[...e.rootPackage.types??[],...t.rootPackage.types??[]],errors:[...e.rootPackage.errors??[],...t.rootPackage.errors??[]],subpackages:[...e.rootPackage.subpackages??[],...(t.rootPackage.subpackages??[]).filter(f=>!e.rootPackage.subpackages?.includes(f))],fernFilepath:e.rootPackage.fernFilepath??t.rootPackage.fernFilepath,webhooks:e.rootPackage.webhooks??t.rootPackage.webhooks,websocket:e.rootPackage.websocket??t.rootPackage.websocket,hasEndpointsInTree:e.rootPackage.hasEndpointsInTree||t.rootPackage.hasEndpointsInTree,navigationConfig:e.rootPackage.navigationConfig??t.rootPackage.navigationConfig,docs:e.rootPackage.docs??t.rootPackage.docs},fdrApiDefinitionId:e.fdrApiDefinitionId??t.fdrApiDefinitionId,apiVersion:e.apiVersion??t.apiVersion,idempotencyHeaders:[...e.idempotencyHeaders??[],...t.idempotencyHeaders??[]],pathParameters:[...e.pathParameters??[],...t.pathParameters??[]],errorDiscriminationStrategy:e.errorDiscriminationStrategy??t.errorDiscriminationStrategy,variables:[...e.variables??[],...t.variables??[]],serviceTypeReferenceInfo:e.serviceTypeReferenceInfo??t.serviceTypeReferenceInfo,readmeConfig:e.readmeConfig??t.readmeConfig,sourceConfig:e.sourceConfig??t.sourceConfig,publishConfig:e.publishConfig??t.publishConfig,dynamic:e.dynamic??t.dynamic,sdkConfig:e.sdkConfig??t.sdkConfig,audiences:[...e.audiences??[],...t.audiences??[]],generationMetadata:e.generationMetadata??t.generationMetadata,apiPlayground:e.apiPlayground??t.apiPlayground}}function P$S(e,t){let r=e;for(let[i,n]of Object.entries(t))r[i]==null?r[i]=n:r[i]={name:n.name,displayName:n.displayName,fernFilepath:n.fernFilepath,hasEndpointsInTree:r[i].hasEndpointsInTree||n.hasEndpointsInTree,navigationConfig:r[i].navigationConfig??n.navigationConfig,docs:r[i].docs??n.docs,service:r[i].service??n.service,subpackages:[...r[i].subpackages??[],...(n.subpackages??[]).filter(a=>!r[i]?.subpackages?.includes(a))],webhooks:r[i].webhooks??n.webhooks,websocket:r[i].websocket??n.websocket,errors:[...r[i].errors??[],...n.errors??[]],types:[...r[i].types??[],...n.types??[]]};return r}function j$S(e,t,r){if(e==null&&t==null)return{environments:void 0,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(t==null)return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(e==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(JSON.stringify(e)===JSON.stringify(t))return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let i=hs_(e),n=hs_(t);if(i&&n&&e.environments.type==="singleBaseUrl"&&t.environments.type==="singleBaseUrl")return{environments:{defaultEnvironment:e.defaultEnvironment??t.defaultEnvironment,environments:$E.singleBaseUrl({environments:[...e.environments.environments,...t.environments.environments]})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let a=i?t.defaultEnvironment:e.defaultEnvironment,o=e.environments,c=t.environments;if(o.type==="singleBaseUrl"&&c.type==="singleBaseUrl"){let f=i?c:o,s=i?o:c,u={},{deconflictedEnvironments2:l,changedBaseUrlIds2:p}=E$S(f,s,r);if(f.environments[0]==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let _="Base",h=r.generateName("Base");return f.environments.forEach(y=>{u[y.id]=_}),{environments:{defaultEnvironment:a,environments:$E.multipleBaseUrls({baseUrls:[{id:_,name:h},...l.environments.map(y=>({id:y.id,name:y.name}))],environments:f.environments.map(y=>({id:y.id,name:y.name,urls:{[_]:y.url,...Object.fromEntries(l.environments.map(b=>[b.id,b.url]))},docs:void 0}))})},changedBaseUrlIds1:i?p:u,changedBaseUrlIds2:i?u:p}}if(o.type==="multipleBaseUrls"&&c.type==="singleBaseUrl"||o.type==="singleBaseUrl"&&c.type==="multipleBaseUrls"){let f=o.type==="singleBaseUrl"?o:c,s=o.type==="multipleBaseUrls"?o:c,{deconflictedEnvironments1:u,changedBaseUrlIds1:l}=S$S(f,s,r);return{environments:{defaultEnvironment:a,environments:$E.multipleBaseUrls({baseUrls:[...s.baseUrls,...u.environments.map(p=>({id:p.id,name:p.name}))],environments:s.environments.map(p=>({...p,urls:{...p.urls,...Object.fromEntries(u.environments.map(_=>[_.id,_.url]))}}))})},changedBaseUrlIds1:o.type==="singleBaseUrl"?l:void 0,changedBaseUrlIds2:o.type==="singleBaseUrl"?void 0:l}}if(o.type==="multipleBaseUrls"&&c.type==="multipleBaseUrls"){let{deconflictedEnvironments:f,changedBaseUrlIds:s}=M$S(o,c,r);return{environments:{defaultEnvironment:a,environments:$E.multipleBaseUrls({baseUrls:[...o.baseUrls,...f.baseUrls],environments:o.environments.flatMap(u=>f.environments.map(l=>({...u,urls:{...u.urls,...l.urls}})))})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:s}}return{environments:e??t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0}}function w$S(e,t,r,i){if(r!=null)for(let[o,c]of Object.entries(r)){for(let f of Object.values(e.services))for(let s of Object.values(f.endpoints))s.baseUrl==o&&(s.baseUrl=c),s.v2BaseUrls?.includes(o)&&(s.v2BaseUrls=s.v2BaseUrls.map(u=>u===o?c:u));for(let f of Object.values(e.websocketChannels??{}))f.baseUrl==o&&(f.baseUrl=c)}if(i!=null)for(let[o,c]of Object.entries(i)){for(let f of Object.values(t.services))for(let s of Object.values(f.endpoints))s.baseUrl==o&&(s.baseUrl=c),s.v2BaseUrls?.includes(o)&&(s.v2BaseUrls=s.v2BaseUrls.map(u=>u===o?c:u));for(let f of Object.values(t.websocketChannels??{}))f.baseUrl==o&&(f.baseUrl=c)}let n=e.services;for(let[o,c]of Object.entries(t.services))n[o]==null?n[o]=c:n[o]={availability:c.availability,name:c.name,displayName:c.displayName,basePath:c.basePath,endpoints:[...n[o].endpoints??[],...c.endpoints],pathParameters:[...n[o].pathParameters??[],...c.pathParameters??[]],headers:[...n[o].headers??[],...c.headers??[]],encoding:c.encoding,transport:c.transport,audiences:[...n[o].audiences??[],...c.audiences??[]]};let a={...e.websocketChannels??{},...t.websocketChannels??{}};return{services:n,websocketChannels:a}}function E$S(e,t,r){let i={},n=new Set(e.environments.map(s=>s.id)),a=new Set(e.environments.map(s=>s.name)),o=new Map(e.environments.map(s=>[s.url,s.id])),c=t.environments.filter(s=>{let u=o.get(s.url);return u!=null?(i[s.id]=u,!1):!0}).map(s=>{if(n.has(s.id)||a.has(s.name)){let u=xac(s.id,n);return i[s.id]=u,{...s,id:u,name:r.generateName(u)}}return s});return{deconflictedEnvironments2:$E.singleBaseUrl({environments:c}),changedBaseUrlIds2:i}}function S$S(e,t,r){let i={},n=new Set(t.baseUrls.map(f=>f.id)),a=new Set(t.baseUrls.map(f=>f.name)),o=e.environments.map(f=>{if(n.has(f.id)||a.has(f.name)){let s=xac(f.id,n);return i[f.id]=s,{...f,id:s,name:r.generateName(s)}}return f});return{deconflictedEnvironments1:$E.singleBaseUrl({environments:o}),changedBaseUrlIds1:i}}function M$S(e,t,r){let i={},n=new Set(e.baseUrls.map(s=>s.id)),a=new Set(e.baseUrls.map(s=>s.name)),o=t.baseUrls.map(s=>{if(n.has(s.id)||a.has(s.name)){let u=xac(s.id,n);return i[s.id]=u,{...s,id:u,name:r.generateName(u)}}return s}),c=t.environments.map(s=>({...s,urls:Object.fromEntries(Object.entries(s.urls).map(([u,l])=>[i[u]??u,l]))}));return{deconflictedEnvironments:$E.multipleBaseUrls({baseUrls:o,environments:c}),changedBaseUrlIds:i}}function hs_(e){return e.environments.type==="singleBaseUrl"?e.environments.environments.some(t=>t.url&&(t.url.startsWith("ws://")||t.url.startsWith("wss://"))):e.environments.type==="multipleBaseUrls"?e.environments.environments.some(t=>Object.values(t.urls).some(r=>r&&(r.startsWith("ws://")||r.startsWith("wss://")))):!1}function xac(e,t){let r=e,i=1;for(;t.has(r);)r=`${e}-${i}`,i++;return r}var Oa=class e{breadcrumbs=[];context;static STRING=vr.TypeReference.primitive({v1:"STRING",v2:vr.PrimitiveTypeV2.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=vr.TypeReference.container(vr.ContainerType.optional(e.STRING));constructor({breadcrumbs:t=[],context:r}){this.breadcrumbs=t,this.context=r}};var bs_=require("fs/promises");var Gac=class{_map;_path;_lastScalar;_fragments;_count;constructor(){this._map={},this._path=[],this._lastScalar="",this._fragments=[],this._count=0}get map(){return this._map}resolveNode(t,r){if(t.path==="."&&(r="."),!this._map[r]){let{line:i,position:n,lineStart:a}=t;this._map[r]={line:i,position:n,lineStart:a}}t.children&&t.children.length>0&&t.children.forEach(i=>{this.resolveNode(i,(r==="."?"":r)+"."+i.path)})}iterFragments(t,r){for(let i=this._fragments.length-1;i>=0;i--){if(!this._fragments[i].path.startsWith(t)||this._fragments[i].path===t)continue;let n=this._fragments.pop();r(n)}}handleState(t,r){if(t==="close"){let i=r.result,n=r.kind,a=this._path.join(".");if(n==="scalar"){this._path.pop(),this._lastScalar=`${i}`;let{line:o,position:c,lineStart:f}=r;this._path.length===0?this._map["."+i]={line:o,position:c,lineStart:f}:this._fragments.push({path:this._path.join(".")+"."+i,line:o,position:c,lineStart:f})}else if(n==="mapping"){let o={path:a,children:[],line:0,position:0,lineStart:0},c=0;this.iterFragments(a,f=>{c++,!((!f.children||f.children.length===0)&&c%2===1)&&(this._path.length===1?this.resolveNode(f,f.path):(o.children.push({...f,path:f.path.slice(a.length+1)}),o.line=f.line,o.position=f.position,o.lineStart=f.lineStart))}),o.children&&o.children.length>0&&this._fragments.push(o),this._path.pop()}else if(n==="sequence"){let o={path:a,children:[],line:0,position:0,lineStart:0},c=new Set,f=i.length;this.iterFragments(a,s=>{c.has(s.position)||(f--,c.add(s.position),this._path.length===1?this.resolveNode(s,`${a}.${f}`):(o.children.push({...s,path:f.toString()}),o.line=s.line,o.position=s.position,o.lineStart=s.lineStart))}),o.children&&o.children.length>0&&this._fragments.push(o),this._path.pop()}else this._path.pop()}if(t==="open"){if(this._count===0){let{line:i,position:n,lineStart:a}=r;this._map["."]={line:i,position:n,lineStart:a}}this._path.push(this._lastScalar),this._count++}}listen(){return this.handleState.bind(this)}lookup(t){let r=t instanceof Array?t.map(n=>`${n}`).join("."):`${t}`;r.startsWith(".")||(r="."+r),r.startsWith("..")&&(r=r.slice(1)),r=r.replace(/\[/g,".").replace(/\]/g,"");let i=this._map[r];if(i)return{line:i.line+1,column:i.position-i.lineStart+1,position:i.position}}},ys_=Gac;var B1;(function(e){e.WARNING="warning",e.ERROR="error"})(B1||(B1={}));var z0e=class{errors=[];logger;breadcrumbToLineNumberMapper;relativeFilepathToSpec;constructor({logger:t,relativeFilepathToSpec:r}){this.logger=t,this.relativeFilepathToSpec=r,r&&(this.breadcrumbToLineNumberMapper=new Hac({logger:t,relativePathToFile:Ze.of(r)}))}collect(t){this.errors.push(t)}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}dedupe(){let t=[],r=new Set,i=0;for(let n of this.errors){let a=n.path?n.path.join("->"):"",o=`${n.message}|${n.level||B1.WARNING}|${a}`;r.has(o)?i++:(r.add(o),t.push(n))}return this.errors=t,i}getErrorStats(){this.dedupe();let t=0,r=0;for(let i of this.errors)i.level===B1.ERROR?t++:(i.level===B1.WARNING||i.level===void 0)&&r++;return{numErrors:t,numWarnings:r}}async logErrors({logWarnings:t}){this.dedupe();for(let r of this.errors){let i=r.level??B1.WARNING;if(!(i===B1.WARNING&&!t))switch(i){case B1.ERROR:if(this.logger.log($s.Debug,r.message),r.path&&r.path.length>0){let n=await this.breadcrumbToLineNumberMapper?.getSourceLocation(r.path),a=n?`${this.relativeFilepathToSpec}:${n.line}:${n.column}`:r.path.join(" -> ");this.logger.log($s.Debug,` - at location (${a})`)}break;case B1.WARNING:if(this.logger.log($s.Warn,r.message),r.path&&r.path.length>0){let n=await this.breadcrumbToLineNumberMapper?.getSourceLocation(r.path),a=n?`${this.relativeFilepathToSpec}:${n.line}:${n.column}`:r.path.join(" -> ");this.logger.log($s.Warn,` - at location (${a})`)}r.resolution&&this.logger.log($s.Warn,` - resolution: ${r.resolution}`);break}}}},Hac=class{logger;relativePathToFile;map=new ys_;initialized=!1;constructor({relativePathToFile:t,logger:r}){this.relativePathToFile=t,this.logger=r}async initialize(){if(!this.initialized)try{let t=await(0,bs_.readFile)(this.relativePathToFile,"utf-8");wi.load(t,{listener:this.map.listen()}),this.initialized=!0}catch(t){this.logger.log($s.Warn,`Failed to initialize line number mapping for ${this.relativePathToFile}: ${JSON.stringify(t)}`)}}async getSourceLocation(t){return this.initialized||await this.initialize(),this.map.lookup(t)}};var SB=class e{args;spec;settings;errorCollector;logger;generationLanguage;smartCasing;casingsGenerator;namespace;exampleGenerationArgs;authOverrides;environmentOverrides;globalHeaderOverrides;enableUniqueErrorsPerEndpoint;generateV1Examples;documentBaseDir;constructor(t){this.args=t,this.spec=t.spec,this.settings=t.settings,this.errorCollector=t.errorCollector,this.logger=t.logger,this.generationLanguage=t.generationLanguage,this.smartCasing=t.smartCasing,this.namespace=t.namespace,this.casingsGenerator=_x({generationLanguage:t.generationLanguage,keywords:void 0,smartCasing:t.smartCasing}),this.exampleGenerationArgs=t.exampleGenerationArgs,this.authOverrides=t.authOverrides,this.environmentOverrides=t.environmentOverrides,this.globalHeaderOverrides=t.globalHeaderOverrides,this.enableUniqueErrorsPerEndpoint=t.enableUniqueErrorsPerEndpoint,this.generateV1Examples=t.generateV1Examples,this.documentBaseDir=t.documentBaseDir}static BREADCRUMBS_TO_IGNORE=["properties","allOf","anyOf"];convertBreadcrumbsToName(t){let r=t.filter((n,a)=>!(/^\d+$/.test(n)||e.BREADCRUMBS_TO_IGNORE.includes(n)||a===0&&n==="components"||a===1&&n==="schemas"||t[0]==="paths"&&(a===0||a===1&&["get","post","put","delete","patch"].includes(n)||a===2&&t[1]!=null&&["get","post","put","delete","patch"].includes(t[1])&&n==="parameters"))),i=Fo(r.join("_"));return i.charAt(0).toUpperCase()+i.slice(1)}createFernFilepath(t={}){let r=this.namespace!=null?[this.casingsGenerator.generateName(this.namespace)]:[],i=t.name!=null?this.casingsGenerator.generateName(t.name):void 0;return{allParts:i?[...r,i]:r,packagePath:r,file:i}}resolveReference({reference:t,breadcrumbs:r,skipErrorCollector:i}){let n=this.spec,a=t.$ref.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(o=>o.replace(/~1/g,"/"));for(let o of a){if(typeof n!="object"||n==null)return i||this.errorCollector.collect({level:B1.ERROR,message:this.getErrorMessageForMissingRef({reference:t}),path:r}),{resolved:!1};n=n[o]}return n==null?(i||this.errorCollector.collect({level:B1.ERROR,message:this.getErrorMessageForMissingRef({reference:t}),path:r}),{resolved:!1}):{resolved:!0,value:n}}getErrorMessageForMissingRef({reference:t}){let r=t.$ref.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/");return r.length>=3&&r[0]==="components"&&r[1]==="schemas"?`Schema ${r[2]} does not exist`:`${t.$ref} does not exist`}async resolveMaybeExternalReference(t){let r=this.spec,i,n=!1,a=null,o;if(this.isExternalReference(t.$ref)){n=!0;let s=t.$ref.split("#"),u=s[0];if(i=s[1],!u)return{resolved:!1};o=u;let l=await fetch(u);if(!l.ok)return{resolved:!1};try{let p=await l.text();try{a=JSON.parse(p),r=a}catch{a=wi.load(p),r=a}if(r==null)return{resolved:!1}}catch{return{resolved:!1}}if(!i)return{resolved:!0,value:r}}let c=i??t.$ref;if(c==null||typeof c!="string")return{resolved:!1};let f=c.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(s=>s.replace(/~1/g,"/"));for(let s of f){if(typeof r!="object"||r==null)return{resolved:!1};r=r[s]}if(r==null)return{resolved:!1};if(n&&typeof r=="object"&&r!==null){let s=new Set;s.add(t.$ref),r=await this.resolveNestedExternalReferences(r,a,s,o)}return{resolved:!0,value:r}}async resolveNestedExternalReferences(t,r,i,n){if(t===null||typeof t!="object")return t;if(Array.isArray(t)){let o=[];for(let c of t)o.push(await this.resolveNestedExternalReferences(c,r,i,n));return o}if(this.isReferenceObject(t)){let o=t.$ref;if(this.isExternalReference(o)){if(i.has(o))return t;i.add(o);let c=await this.resolveMaybeExternalReference({$ref:o});if(i.delete(o),c.resolved)return c.value}else{let c=`${n}${o}`;if(i.has(c))return t;i.add(c);let f=r,s=o.substring(2).split("/").map(u=>u.replace(/~1/g,"/").replace(/~0/g,"~"));for(let u of s){if(typeof f!="object"||f===null)return t;f=f[u]}if(f!=null){let u=await this.resolveNestedExternalReferences(f,r,i,n);return i.delete(o),u}i.delete(o)}return t}let a={};for(let[o,c]of Object.entries(t))typeof c=="object"&&c!==null?a[o]=await this.resolveNestedExternalReferences(c,r,i,n):a[o]=c;return a}getExamplesFromSchema({schema:t,breadcrumbs:r}){if(t==null)return[];let i=t.example!=null?[t.example]:[];return t.examples!=null&&(Array.isArray(t.examples)?i.push(...t.examples):this.errorCollector.collect({message:"Received non-array schema examples",path:r})),i}getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:r,defaultExampleName:i}){if(t==null)return[];let n=[];if(t.example!=null){let a=this.generateUniqueName({prefix:i??`${r.join("_")}_example`,existingNames:[]});n.push([a,t.example])}return t.examples!=null&&n.push(...Object.entries(t.examples)),n}resolveMaybeReference({schemaOrReference:t,breadcrumbs:r,skipErrorCollector:i}){if(this.isReferenceObject(t)){let n=this.resolveReference({reference:t,breadcrumbs:r,skipErrorCollector:i});return n.resolved?n.value:void 0}return t}resolveExample(t){if(!this.isReferenceObject(t))return t;let r=this.resolveReference({reference:t});return r.resolved?this.returnExampleValue(r.value):void 0}resolveExampleWithValue(t){if(!this.isReferenceObject(t))return this.returnExampleValue(t);let r=this.resolveReference({reference:t});return r.resolved?this.returnExampleValue(r.value):void 0}returnExampleValue(t){return this.isExampleWithValue(t)?t.value:t}getPropertyAccess(t){let r=t;for(;this.isReferenceObject(r);){let a=this.resolveReference({reference:r});if(!a.resolved)return;r=a.value}let{readOnly:i,writeOnly:n}=this.getReadOnlyWriteOnlyFromSchema(r);if(!(i&&n)){if(i)return G6t.ReadOnly;if(n)return G6t.WriteOnly}}getReadOnlyWriteOnlyFromSchema(t){if(t.allOf&&t.allOf.length>0){let r=!0,i=!0;for(let n of t.allOf){let a=n;if(this.isReferenceObject(n)){let c=this.resolveReference({reference:n});if(!c.resolved)continue;a=c.value}let o=this.getReadOnlyWriteOnlyFromSchema(a);r=r&&o.readOnly,i=i&&o.writeOnly}return{readOnly:r,writeOnly:i}}else return{readOnly:!!t.readOnly,writeOnly:!!t.writeOnly}}getAudiences({operation:t,breadcrumbs:r}){let n=new I1.AudienceExtension({operation:t,breadcrumbs:r,context:this}).convert();if(n!=null)return n.audiences}getAvailability({node:t,breadcrumbs:r}){for(;this.isReferenceObject(t);){let a=this.resolveReference({reference:t});if(!a.resolved)return;t=a.value}let n=new I1.FernAvailabilityExtension({node:t,breadcrumbs:r,context:this}).convert();if(n!=null)return{status:n,message:void 0};if(t.deprecated===!0)return{status:IC.Deprecated,message:void 0}}getTypeIdFromSchemaReference(t){let r=t.$ref.match(/\/schemas\/(.+)$/);if(!(!r||!r[1]))return r[1]}createNamedTypeReference(t,r){return ii.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(t),typeId:t,displayName:r,default:void 0,inline:!1})}typeReferenceToDeclaredTypeName(t){if(t.type!=="named")return;let r=t.typeId;return{typeId:r,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r),displayName:t.displayName}}removeSchemaFromInlinedTypes({id:t,inlinedTypes:r}){return Object.fromEntries(Object.entries(r).filter(([i])=>i!==t))}static maybeTrimPrefix(t,r){return t.startsWith(r)?t.slice(r.length):t}generateUniqueName({prefix:t,existingNames:r}){if(!r.includes(t))return t;let i=0;for(;r.includes(`${t}_${i}`);)i++;return`${t}_${i}`}isReferenceObject(t){return typeof t=="object"&&t!==null&&"$ref"in t}isExternalReference(t){return typeof t=="string"&&(t.startsWith("http://")||t.startsWith("https://"))}isReferenceObjectWithIdentifier(t){return this.isReferenceObject(t)&&("title"in t||"name"in t||"messageId"in t||"summary"in t)}isExampleWithSummary(t){return typeof t=="object"&&t!=null&&"summary"in t}isExampleWithValue(t){return typeof t=="object"&&t!=null&&"value"in t}isOptional(t){return t.type==="container"&&t.container.type==="optional"}isNullable(t){return t.type==="container"&&t.container.type==="nullable"}isList(t){return t.type==="container"&&t.container.type==="list"}isFile(t){return t.type==="primitive"&&t.primitive.v2?.type==="string"&&t.primitive.v2.validation?.format==="binary"}getAsString(t){if(typeof t=="string")return t}getAsInteger(t){if(typeof t=="number"&&Number.isInteger(t))return t}getAsNumber(t){if(typeof t=="number")return t}getAsBoolean(t){if(typeof t=="boolean")return t}getAsArray(t){if(Array.isArray(t))return t}getAsObject(t){if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}getGroup({groupParts:t,namespace:r}){let i=[];return r!=null&&i.push(r),i.push(...t??[]),i}isObjectSchemaType(t){return t.type==="object"||t.properties!=null}};var Xc=class{breadcrumbs;context;constructor(t){this.breadcrumbs=t.breadcrumbs,this.context=t.context}getExtensionValue(t,r){if(typeof t!="object"||t==null)return;let i=t[this.key];if(i!=null)return i;if(r!=null)return t[r]}};var I1={};Yt(I1,{AudienceExtension:()=>mFo,FernAvailabilityExtension:()=>PFo,FernEnumExtension:()=>jFo,FernIgnoreExtension:()=>QKi,FernOptionalExtension:()=>wFo,FernTypeExtension:()=>DFo,FernTypeNameExtension:()=>BFo,SdkGroupNameExtension:()=>EFo,SdkMethodNameExtension:()=>SFo,ServerFromOperationNameExtension:()=>MFo});var mFo=class extends Xc{operation;key="x-fern-audiences";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=Array.isArray(t)?t.filter(i=>typeof i=="string"):typeof t=="string"?[t]:[];if(r.length!==0)return{audiences:r}}};var PFo=class extends Xc{node;key="x-fern-availability";constructor({breadcrumbs:t,node:r,context:i}){super({breadcrumbs:t,context:i}),this.node=r}convert(){let t=this.getExtensionValue(this.node);if(t==null||typeof t!="string")return;switch(t.toUpperCase().replace(/[-_\s]/g,"_")){case"IN_DEVELOPMENT":return IC.InDevelopment;case"PRE_RELEASE":case"BETA":return IC.PreRelease;case"GENERAL_AVAILABILITY":case"GA":return IC.GeneralAvailability;case"DEPRECATED":return IC.Deprecated;default:return}}};var D$S=Ct.object({snake:Ct.string().optional(),camel:Ct.string().optional(),screamingSnake:Ct.string().optional(),pascal:Ct.string().optional()}),B$S=Ct.object({description:Ct.string().optional(),name:Ct.string().optional(),casing:D$S.optional()}),vs_=Ct.record(B$S);var jFo=class extends Xc{schema;key="x-fern-enum";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(t==null)return;let r=vs_.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-enum extension: ${r.error.message}`,path:this.breadcrumbs});return}return r.data}};var QKi=class extends Xc{operation;key="x-fern-ignore";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-ignore",path:this.breadcrumbs});return}return t}}};var wFo=class extends Xc{parameter;key="x-fern-optional";constructor({breadcrumbs:t,parameter:r,context:i}){super({breadcrumbs:t,context:i}),this.parameter=r}convert(){let t=this.getExtensionValue(this.parameter);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-optional",path:this.breadcrumbs});return}return t}}};var EFo=class extends Xc{operation;key="x-fern-sdk-group-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=Array.isArray(t)?t.filter(i=>typeof i=="string"):typeof t=="string"?[t]:[];if(r.length!==0)return{groups:r}}};var SFo=class extends Xc{operation;key="x-fern-sdk-method-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null&&typeof t=="string")return{methodName:t}}};var MFo=class extends Xc{operation;key="x-fern-server-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation,"x-name");if(!(t==null||typeof t!="string"))return t}};var DFo=class extends Xc{schema;key="x-fern-type";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(t!=null&&typeof t=="string")return t}};var BFo=class extends Xc{schema;key="x-fern-type-name";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(typeof t=="string")return t}};var oFt=class extends Oa{ir;audiences;irGraph;constructor({breadcrumbs:t=[],context:r,audiences:i}){super({breadcrumbs:t,context:r}),this.audiences=i,this.irGraph=new NKi(i),this.ir={auth:{docs:void 0,requirement:vr.AuthSchemesRequirement.All,schemes:[]},selfHosted:!1,types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:vr.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:this.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}},audiences:void 0,generationMetadata:void 0,apiPlayground:void 0}}removeXFernIgnores({document:t,breadcrumbs:r=[]}){return Array.isArray(t)?t.filter((i,n)=>!new QKi({breadcrumbs:[...r,String(n)],operation:i,context:this.context}).convert()).map((i,n)=>this.removeXFernIgnores({document:i,breadcrumbs:[...r,String(n)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([i,n])=>!new QKi({breadcrumbs:[...r,i],operation:n,context:this.context}).convert()).map(([i,n])=>[i,this.removeXFernIgnores({document:n,breadcrumbs:[...r,i]})])):t}finalizeIr(){let t={...this.ir,apiName:this.context.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:this.context.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})},audiences:this.audiences.type==="select"?this.audiences.audiences:void 0};this.irGraph.hasNoAudiences()||(t=this.filterIrForAudiences(t));let r=this.context.exampleGenerationArgs,i=Qac({ir:t,exampleGeneration:r});if(this.context.generateV1Examples){let n=tPa({ir:t,exampleGeneration:r});return{...t,...n,...i}}return{...t,...i}}filterIrForAudiences(t){let r=this.irGraph.getFilteredEndpoints(),i=this.irGraph.getFilteredChannels(),n=this.irGraph.getFilteredWebhooks();for(let a of Object.values(t.services)){let o=[];for(let c of a.endpoints)r.has(c.id)&&o.push(c);a.endpoints=o}return t.websocketChannels=Object.fromEntries(Object.entries(t.websocketChannels??{}).filter(([a])=>i.has(a))),t.webhookGroups=Object.fromEntries(Object.entries(t.webhookGroups).filter(([a])=>n.has(a))),t}async resolveAllExternalRefs({spec:t}){let r=[t];for(;r.length>0;){let i=r.shift();i!=null&&(Array.isArray(i)?await this.resolveExternalRefsInArray(i,r):typeof i=="object"&&await this.resolveExternalRefsInObject(i,r))}return t}async resolveExternalRefsInArray(t,r){for(let i=0;i<t.length;i++)t[i]=await this.resolveReferenceChain(t[i],r)}async resolveExternalRefsInObject(t,r){for(let[i,n]of Object.entries(t))t[i]=await this.resolveReferenceChain(n,r)}async resolveReferenceChain(t,r){let i=t;if(!this.context.isReferenceObject(i))return r.push(i),t;for(;this.context.isReferenceObject(i);){let n=this.context.isExternalReference(i.$ref),a=await this.context.resolveMaybeExternalReference(i);if(a.resolved){if(i=a.value,n)return i}else return t}return t}shouldAddServerToCollectedServers({server:t,currentServers:r,specType:i="openapi"}){return i==="openapi"?!r.some(n=>n.url===t.url&&"x-fern-server-name"in n&&"x-fern-server-name"in t&&n["x-fern-server-name"]===t["x-fern-server-name"]):!r.some(n=>n.url===t.url&&"name"in n&&"name"in t&&n.name===t.name)}addEndpointToIr({endpoint:t,audiences:r,endpointGroup:i,endpointGroupDisplayName:n,serviceName:a}){let o=this.context.getGroup({groupParts:i,namespace:this.context.namespace}),c=this.getOrCreatePackage({group:i}),f=[...o].map(l=>this.context.casingsGenerator.generateName(l)),s=f[f.length-1];c.service==null&&(c.service=a??`service_${o.map(l=>Fo(l)).join("/")}`),this.ir.services[c.service]==null&&(this.ir.services[c.service]=this.createNewService({allParts:f,finalpart:s,endpointGroupDisplayName:n})),this.ir.services[c.service]?.endpoints.push(t);let u=this.ir.services[c.service];u!=null&&(this.irGraph.addEndpoint(u,t),this.irGraph.markEndpointForAudience(u.name,[t],r))}addWebhookToIr({webhook:t,operationId:r,audiences:i,group:n}){let a=n?.join(".")??r,o=this.getOrCreatePackage({group:n});this.ir.webhookGroups[a]==null&&(this.ir.webhookGroups[a]=[]),this.ir.webhookGroups[a].push(t),o.webhooks=a;let c=this.context.createFernFilepath();this.irGraph.addWebhook(c,t),i!=null&&this.irGraph.markWebhookForAudiences(c,t,i)}addWebsocketChannelToIr({websocketChannel:t,channelPath:r,audiences:i,websocketGroup:n}){let a=Fo(n?.join(".")),o=Fo(r),c=this.context.namespace?`${Fo(this.context.namespace)}/`:"",f=a?`channel_${c}${a}`:`channel_${c}${o}`,s=n?this.getOrCreatePackage({group:n}):this.getOrCreatePackage({group:[o]});this.ir.websocketChannels={...this.ir.websocketChannels,[f]:t},f!==""?s.websocket==null&&(s.websocket=f):this.ir.rootPackage.websocket="";let u=this.context.createFernFilepath();this.irGraph.addChannel(u,f,t),i!=null&&this.irGraph.markChannelForAudiences(u,f,i)}addAuthToIR(t){this.ir.auth=t}addErrorsToIr(t){this.ir.errors=t;for(let r of Object.values(t))this.irGraph.addError(r)}addGlobalHeadersToIr(t){this.ir.headers=t}addEnvironmentsToIr({environmentConfig:t,audiences:r}){if(this.ir.environments=t,r!=null)for(let[i,n]of Object.entries(t??{}))r[i]!=null&&this.irGraph.markEnvironmentForAudiences(n,r[i])}addTypeToRootPackage(t){this.ir.rootPackage.types.push(t)}addSchemaOutputToIr(t,r){let{convertedSchema:i,inlinedTypes:n}=r,o=Object.keys(n).some(c=>c===t)?`${t}Wrapper`:t;this.addTypeToPackage(o),this.addTypesToIr({...n,[o]:i})}addTypeToPackage(t){let r=this.context.getGroup({groupParts:[],namespace:this.context.namespace});this.getOrCreatePackage({group:r}).types.push(t)}addTypesToIr(t){Object.assign(this.ir.types,Object.fromEntries(Object.entries(t).map(([r,i])=>[r,i.typeDeclaration])));for(let r of Object.values(t))this.irGraph.addType({declaredTypeName:r.typeDeclaration.name,descendantTypeIds:r.typeDeclaration.referencedTypes,descendantTypeIdsByAudience:{},propertiesByAudience:r.propertiesByAudience,descendantFilepaths:new Set}),this.irGraph.markTypeForAudiences(r.typeDeclaration.name,r.audiences)}updateEndpointsWithDefaultUrl(t){if(t!=null)for(let r of Object.values(this.ir.services))for(let i of r.endpoints)i.baseUrl==null&&(i.baseUrl=t)}createNewService({allParts:t,finalpart:r,endpointGroupDisplayName:i}){return{name:{fernFilepath:{allParts:t,packagePath:t.slice(0,-1),file:r}},displayName:i,basePath:mD(""),headers:[],pathParameters:[],availability:void 0,endpoints:[],transport:void 0,encoding:void 0,audiences:void 0}}createPackage(t={}){return{fernFilepath:this.context.createFernFilepath(t),service:void 0,types:[],errors:[],subpackages:[],docs:void 0,webhooks:void 0,websocket:void 0,hasEndpointsInTree:!1,navigationConfig:void 0}}getOrCreatePackage({group:t}){let r=[];if(this.context.namespace!=null&&r.push(this.context.namespace),r.push(...(t??[]).map(n=>Fo(n))),r.length==0)return this.ir.rootPackage;let i=this.ir.rootPackage;for(let n=0;n<r.length;n++){let a=r[n]??"",c=`subpackage_${r.slice(0,n+1).join("/")}`;this.ir.subpackages[c]==null&&(this.ir.subpackages[c]={name:this.context.casingsGenerator.generateName(a),displayName:void 0,...this.createPackage({name:a})});let f=this.ir.subpackages[c];i.subpackages.includes(c)||i.subpackages.push(c),i=f}return i}};var LO={};Yt(LO,{AbstractConverters:()=>Jac,ExampleConverter:()=>U3,SchemaConverters:()=>Kac,ServersConverter:()=>Ohe});var Jac={};Yt(Jac,{AbstractMediaTypeObjectConverter:()=>qFo,AbstractParameterConverter:()=>TFo});var I$S=/^literal<\s*(?:"(.*)"|(true|false))\s*>$/;function C$S(e){return e.type==="array"||e.properties||e.oneOf||e.anyOf||e.allOf||e.additionalProperties?!1:!!(e.type==="string"||e.type==="number"||e.type==="integer"||e.type==="boolean"||e.const!==void 0||Array.isArray(e.enum)&&e.enum.length>0)}function gs_(e){if(e.const!==void 0)return e.const;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0]}var U3=class e extends Oa{MAX_DEPTH=12;EXAMPLE_STRING=Tn.STRING;EXAMPLE_NUMBER=Tn.DOUBLE;EXAMPLE_BOOLEAN=Tn.BOOLEAN;EXAMPLE_INTEGER=Tn.INT;EXAMPLE_DATE=Tn.DATE;EXAMPLE_DATE_TIME=Tn.DATE_TIME;schema;example;depth;exampleGenerationStrategy;generateOptionalProperties;seenRefs;constructor({breadcrumbs:t,context:r,schema:i,example:n,depth:a=0,exampleGenerationStrategy:o,generateOptionalProperties:c=!1,seenRefs:f=new Set}){super({breadcrumbs:t,context:r}),this.example=n,this.schema=i,this.depth=a,this.exampleGenerationStrategy=o,this.generateOptionalProperties=c,this.seenRefs=f}convert(){if(this.depth>this.MAX_DEPTH)return{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:typeof this.example<"u"?this.example:{},errors:[]};if(this.context.isReferenceObject(this.schema)){let i=this.schema.$ref;if(this.seenRefs.has(i))return{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:this.example,errors:[]}}let t=this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(t==null)return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:"Schema is not resolvable",path:this.breadcrumbs}]};if(typeof t!="object")return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:`Schema should be an object: ${JSON.stringify(t,null,2)}`,path:this.breadcrumbs}]};if("nullable"in t&&t.nullable===!0&&this.example===null)return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let r=this.maybeConvertLiteralFernType(t);return r??(Array.isArray(t.type)?this.convertSchemaTypeArray({resolvedSchema:t}):t.type=="null"?this.convertNull():t.type=="boolean"?this.convertBoolean():t.enum!=null?this.convertEnum(t):t.type=="number"?this.convertNumber():t.type=="string"?this.convertString():t.type=="integer"?this.convertInteger():t.type=="array"?this.convertArray({resolvedSchema:t}):"oneOf"in t&&t.oneOf!=null?this.convertOneOf({resolvedSchema:t}):"anyOf"in t&&t.anyOf!=null?this.convertAnyOf({resolvedSchema:t}):t.type=="object"||t.properties!=null||t.allOf!=null?this.convertObject({resolvedSchema:t}):typeof t=="object"&&Object.keys(t).length===0?{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:this.example,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:`Unsupported schema type: ${JSON.stringify(t,null,2)}`,path:this.breadcrumbs}]})}convertNull(){let t=this.example===null;return t?{isValid:t,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:`Example is not null: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertBoolean(){let t=typeof this.example=="boolean";if(t)return{isValid:t,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs})?.default:this.schema.default,i=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs})?.const:this.schema.const;return typeof r=="boolean"||typeof i=="boolean"?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i??r,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_BOOLEAN,errors:[{message:`Example is not a boolean: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertEnum(t){let r=t.enum?.includes(this.example)??!1;if(r)return{isValid:r,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let i=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return i!==void 0&&t.enum?.includes(i)?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i,errors:[]}:{isValid:r,coerced:!1,usedProvidedExample:!1,validExample:t.enum?.[0],errors:[{message:`Example is not one of the allowed enum values: ${JSON.stringify(t.enum,null,2)}`,path:this.breadcrumbs}]}}convertNumber(){if(typeof this.example=="number")return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let t=Number(this.example);if(!isNaN(t))return{isValid:!0,coerced:!0,usedProvidedExample:!0,validExample:t,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0}):this.schema,i=r?.default;return typeof i=="number"?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.adjustNumberToConstraints(this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_NUMBER,r),errors:[{message:`Example is not a number: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}adjustNumberToConstraints(t,r){if(r==null)return this.context.logger.debug("[ExampleConverter.adjustNumberToConstraints] Schema object is null, returning original number","number:",t.toString()),t;let{minimum:i,maximum:n,exclusiveMinimum:a,exclusiveMaximum:o}=r,c;a!=null?typeof a=="boolean"?c=i!=null?i+Math.max(Number.EPSILON,Math.abs(i)*1e-10):void 0:c=a+Math.max(Number.EPSILON,Math.abs(a)*1e-10):i!=null&&(c=i);let f;return o!=null?typeof o=="boolean"?f=n!=null?n-Math.max(Number.EPSILON,Math.abs(n)*Number.EPSILON):void 0:f=o-Math.max(Number.EPSILON,Math.abs(o)*Number.EPSILON):n!=null&&(f=n),c!==void 0&&f!==void 0?(t<c||t>f)&&(t=c+(f-c)/2):c!==void 0&&t<c?t=c+Math.abs(c*.1):f!==void 0&&t>f&&(t=f-Math.abs(f*.1)),Number(Number(t).toPrecision(3))}convertString(){if(typeof this.example=="string")return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};if(typeof this.example!="object"&&!Array.isArray(this.example)&&this.example!=null)return{isValid:!0,coerced:!0,usedProvidedExample:!0,validExample:String(this.example),errors:[]};let t=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;if(typeof t=="string")return{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:t,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0}):this.schema,i=r?.format==="date"?this.EXAMPLE_DATE:r?.format==="date-time"?this.EXAMPLE_DATE_TIME:this.EXAMPLE_STRING;return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.maybeResolveSchemaExample(this.schema)??i,errors:[{message:`Example cannot be converted to string: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertInteger(){if(typeof this.example=="number"&&Number.isInteger(this.example))return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};if(typeof this.example=="string"){let r=Number(this.example);if(!isNaN(r)&&Number.isInteger(r))return{isValid:!0,coerced:!0,usedProvidedExample:!0,validExample:r,errors:[]}}let t=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return typeof t=="number"&&Number.isInteger(t)?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:t,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_INTEGER,errors:[{message:`Example is not an integer: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertArray({resolvedSchema:t}){if(t.type!="array")return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[]};t.items==null&&(t.items={type:"string"});let r=this.example==null,i=this.example??t.example,a=(Array.isArray(i)?i:[i]).map(f=>new e({breadcrumbs:[...this.breadcrumbs,"items"],context:this.context,schema:t.items,example:f,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert()),o=a.every(f=>f?.isValid??!1)&&!r,c=!r&&a.some(f=>f.usedProvidedExample);return{isValid:o,coerced:!1,usedProvidedExample:c,validExample:a.map(f=>f.validExample),errors:o?[]:a.flatMap(f=>f.errors)}}convertObject({resolvedSchema:t}){if(t.type=="object"&&t.properties==null&&t.allOf==null)return{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:this.example??{},errors:[]};let r=typeof this.example!="object"||this.example==null?{}:this.example,i=Object.entries(t.properties??{}).map(([l,p])=>{if(typeof p!="object")return{key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if(this.isDeprecatedProperty(p)&&!this.isRequiredProperty({key:l,resolvedSchema:t}))return{key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if("readOnly"in p&&p.readOnly===!0&&"writeOnly"in p&&p.writeOnly===!0)return{key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if("readOnly"in p&&p.readOnly===!0&&this.exampleGenerationStrategy==="request")return{key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if("writeOnly"in p&&p.writeOnly===!0&&this.exampleGenerationStrategy==="response")return{key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};let _=!(l in r)||!("nullable"in p)&&r[l]==null||"nullable"in p&&p.nullable===!0&&r[l]===void 0,h=!t.required?.includes(l);if(_&&h){if(this.example===void 0&&this.generateOptionalProperties){let y=this.maybeResolveSchemaExample(p),b=new e({breadcrumbs:[...this.breadcrumbs,l],context:this.context,schema:p,example:y,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()});return{key:l,result:b.convert()}}return{key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}}}else{let b=r[l]??this.maybeResolveSchemaExample(p),O=new e({breadcrumbs:[...this.breadcrumbs,l],context:this.context,schema:p,example:b,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();return{key:l,result:O}}}),n=(t.allOf??[]).map((l,p)=>new e({breadcrumbs:[...this.breadcrumbs,`allOf[${p}]`],context:this.context,schema:{...t,...l,allOf:void 0},example:this.example,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert()),a=i.every(l=>l.result.isValid)&&n.every(l=>l.isValid),o=this.example!==void 0&&(i.some(({result:l})=>l.usedProvidedExample)||n.some(l=>l.usedProvidedExample)),c=Object.fromEntries(i.map(({key:l,result:p})=>[l,p.validExample]).filter(([l,p])=>p!==void 0));for(let l of n)if(typeof l.validExample=="object"&&l.validExample!==null){let p=l.validExample;c={...c,...Object.fromEntries(Object.entries(p).filter(([_,h])=>h!==void 0))}}let f=[],s=new Set(Object.keys(t.properties??{})),u=Object.keys(r).filter(l=>!s.has(l));u.length>0&&(t.additionalProperties===!1?u.forEach(l=>{let p=[...this.breadcrumbs,l].join("."),_={message:`Found unexpected property '${l}' in example. This property does not exist in the schema${p?` at path: ${p}`:""}`,path:[...this.breadcrumbs,l]};f.push({key:l,result:{isValid:!1,coerced:!1,usedProvidedExample:!0,validExample:void 0,errors:[_]}})}):u.forEach(l=>{let p=[...this.breadcrumbs,l].join("."),_={message:`Additional property ${l} is not allowed`,path:[...this.breadcrumbs,l]};f.push({key:l,result:{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:void 0,errors:[_]}})}));for(let{key:l,result:p}of f)p.validExample!==void 0&&c[l]===void 0&&(c[l]=p.validExample);if(Object.keys(c).length===0){let l=n.find(p=>p.validExample!==void 0&&(typeof p.validExample!="object"||p.validExample===null));l&&(c=l.validExample)}return{isValid:a,coerced:!1,usedProvidedExample:o,validExample:c,errors:[...i.flatMap(({result:l})=>l.errors),...n.flatMap(l=>l.errors),...f.flatMap(({result:l})=>l.errors)]}}convertSchemaTypeArray({resolvedSchema:t}){if(!Array.isArray(t.type))return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[]};if(t.type.length===1)return new e({breadcrumbs:this.breadcrumbs,context:this.context,schema:{...t,type:t.type[0]},example:this.example,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();let r=t.type.map((c,f)=>new e({breadcrumbs:[...this.breadcrumbs,`type[${f}]`],context:this.context,schema:{...t,type:c},example:this.example,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert()),i=r.some(c=>c?.isValid??!1),a=r.find(c=>c.isValid)?.validExample??r[0]?.validExample??null,o=r.some(c=>c.usedProvidedExample);return{isValid:i,coerced:!1,usedProvidedExample:o,validExample:a,errors:i?[]:r.flatMap(c=>c?.errors??[])}}convertUnion({resolvedSchema:t,unionType:r}){let i=r==="oneOf"?t.oneOf:t.anyOf;if(!(r in t)||i==null)return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[]};let n=this.example??this.maybeResolveSchemaExample(t);if(this.example===void 0){let p=[];for(let h of i){if(!h)continue;let y=this.context.resolveMaybeReference({schemaOrReference:h,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});y&&p.push(y)}if(p.length>0&&p.every(h=>C$S(h))){let h=p.findIndex(y=>gs_(y)!==void 0);if(h!==-1){let y=i[h],b=p[h];if(y&&b){let v=gs_(b),A=new e({breadcrumbs:[...this.breadcrumbs,`${r}[${h}]`],context:this.context,schema:r==="oneOf"?{...t,...y,oneOf:void 0}:y,example:v,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();if(A.isValid)return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:A.validExample,errors:[]}}}}}let a=[],o=null,c=null;for(let p=0;p<i.length;p++){let _=i[p];if(!_)continue;let h=r==="oneOf"?{...t,..._,oneOf:void 0}:_,y=n??this.maybeResolveSchemaExample(h),v=new e({breadcrumbs:[...this.breadcrumbs,`${r}[${p}]`],context:this.context,schema:h,example:y,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();if(v.isValid&&!v.coerced&&v.usedProvidedExample)return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:v.validExample,errors:[]};if(v.isValid&&!v.coerced)return{isValid:!0,coerced:!1,usedProvidedExample:v.usedProvidedExample,validExample:v.validExample,errors:[]};a.push(v),v.isValid&&v.usedProvidedExample&&c===null&&(c=v),v.isValid&&o===null&&(o=v)}let f=c??o,s=f!==null,u=f?.validExample??a[0]?.validExample,l=f?.usedProvidedExample??!1;return{isValid:s,coerced:!1,usedProvidedExample:l,validExample:u,errors:s?[]:a.flatMap(p=>p.errors)}}convertOneOf({resolvedSchema:t}){return this.convertUnion({resolvedSchema:t,unionType:"oneOf"})}convertAnyOf({resolvedSchema:t}){return this.convertUnion({resolvedSchema:t,unionType:"anyOf"})}getMaybeUpdatedSeenRefs(){let t=new Set(this.seenRefs);return this.context.isReferenceObject(this.schema)&&t.add(this.schema.$ref),t}maybeResolveSchemaExample(t){let r=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(r!=null){if("example"in r)return r.example;if("examples"in r){let i=r.examples;return Array.isArray(i)&&i.length>0?i[0]:Object.values(i??{})[0]}}}maybeConvertLiteralFernType(t){let r=t["x-fern-type"];if(typeof r!="string")return;let i=r.match(I$S);if(i!=null){if(i[1]!=null)return{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i[1],errors:[]};if(i[2]!=null)return{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i[2]==="true",errors:[]}}}isDeprecatedProperty(t){return t!=null&&"availability"in t&&t.availability==="deprecated"}isRequiredProperty({key:t,resolvedSchema:r}){return r.required?.includes(t)??!1}};var Kac={};Yt(Kac,{ArraySchemaConverter:()=>iQn,EnumSchemaConverter:()=>kFn,ObjectSchemaConverter:()=>eQn,OneOfSchemaConverter:()=>tQn,PrimitiveSchemaConverter:()=>rQn,SchemaConverter:()=>mCi,SchemaOrReferenceConverter:()=>L3});function Os_(e){return wB({type:e,_default:void 0,validation:void 0,visitor:{primitive:t=>{switch(t.v1){case"BASE_64":return ii.primitive({v1:"BASE_64",v2:bn.base64({})});case"BOOLEAN":return ii.primitive({v1:"BOOLEAN",v2:bn.boolean({default:void 0})});case"DATE":return ii.primitive({v1:"DATE",v2:bn.date({})});case"DATE_TIME":return ii.primitive({v1:"DATE_TIME",v2:bn.dateTime({})});case"FLOAT":return ii.primitive({v1:"FLOAT",v2:bn.float({})});case"DOUBLE":return ii.primitive({v1:"DOUBLE",v2:bn.double({default:void 0,validation:void 0})});case"UINT":return ii.primitive({v1:"UINT",v2:bn.uint({})});case"UINT_64":return ii.primitive({v1:"UINT_64",v2:bn.uint64({})});case"INTEGER":return ii.primitive({v1:"INTEGER",v2:bn.integer({default:void 0,validation:void 0})});case"LONG":return ii.primitive({v1:"LONG",v2:bn.long({default:void 0})});case"STRING":return ii.primitive({v1:"STRING",v2:bn.string({default:void 0,validation:void 0})});case"UUID":return ii.primitive({v1:"UUID",v2:bn.uuid({})});case"BIG_INTEGER":return ii.primitive({v1:"BIG_INTEGER",v2:bn.bigInteger({default:void 0})});default:return}},unknown:()=>ii.unknown(),map:({keyType:t,valueType:r})=>{if(!(t==null||r==null))return ii.container(ns.map({keyType:t,valueType:r}))},list:t=>{if(t!=null)return ii.container(ns.list(t))},optional:t=>{if(t!=null)return ii.container(ns.optional(t))},nullable:t=>{if(t!=null)return ii.container(ns.nullable(t))},set:t=>{if(t!=null)return ii.container(ns.set(t))},literal:t=>ii.container(ns.literal(t._visit({string:r=>iz.string(r),boolean:r=>iz.boolean(r),_other:()=>{throw new Error("Unexpected literal type")}}))),named:()=>{}}})}var kFn=class extends Oa{schema;maybeFernEnum;constructor({context:t,breadcrumbs:r,schema:i,maybeFernEnum:n}){super({context:t,breadcrumbs:r}),this.schema=i,this.maybeFernEnum=n}convert(){if(!this.schema.enum)return;let r=this.schema.enum.filter(n=>typeof n=="string"||typeof n=="number").map(n=>{let a=n.toString(),o=this.maybeFernEnum?.[a],c=o?.name??a;return{name:this.context.casingsGenerator.generateNameAndWireValue({name:c,wireValue:a}),docs:o?.description,availability:void 0,casing:o?.casing}});if(r.length===0){this.context.errorCollector.collect({message:`Received enum schema with no valid values: ${JSON.stringify(this.schema)}`,path:this.breadcrumbs});return}let i=this.context.getAsString(this.schema.default);return{type:Yc.enum({default:i!=null?r.find(n=>n.name.wireValue===i):void 0,values:r})}}};var IFo=class extends Oa{schemaOrReferenceOrBoolean;constructor({context:t,breadcrumbs:r,schemaOrReferenceOrBoolean:i}){super({context:t,breadcrumbs:r}),this.schemaOrReferenceOrBoolean=i}convert(){let t=this.tryConvertUnknownMap();if(t!=null)return t;let r=this.tryConvertTypedMap();if(r!=null)return r}tryConvertUnknownMap(){if(typeof this.schemaOrReferenceOrBoolean=="boolean"){let t=ii.container(ns.map({keyType:Oa.STRING,valueType:ii.unknown()}));return{type:Yc.alias({aliasOf:t,resolvedType:t}),referencedTypes:new Set,inlinedTypes:{}}}}tryConvertTypedMap(){if(typeof this.schemaOrReferenceOrBoolean=="boolean")return;let r=new L3({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReference:this.schemaOrReferenceOrBoolean}).convert();if(r!=null){let i=ii.container(ns.map({keyType:Oa.STRING,valueType:r.type})),n=new Set;for(let a of r.schema?.typeDeclaration.referencedTypes??[])n.add(a);for(let a of Object.keys(r.inlinedTypes))n.add(a);return{type:Yc.alias({aliasOf:i,resolvedType:i}),referencedTypes:n,inlinedTypes:r.inlinedTypes}}}};function iPa({properties:e,required:t,breadcrumbs:r,context:i,errorCollector:n}){let a=[],o={},c={},f=new Set;for(let[s,u]of Object.entries(e??{})){let l=[...r,"properties",s];if(typeof u!="object"){n.collect({message:`Schema property ${s} should be an object`,path:l});continue}let p=q$S(r,u,i)??i.convertBreadcrumbsToName(l),_="nullable"in u?u.nullable:!1,y=new L3({context:i,breadcrumbs:l,schemaOrReference:u,schemaIdOverride:p,wrapAsOptional:!t.includes(s),wrapAsNullable:_}).convert();if(y!=null){a.push({name:i.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),valueType:y.type,docs:u.description,availability:y.availability,propertyAccess:i.getPropertyAccess(u),v2Examples:y.schema?.typeDeclaration?.v2Examples??{userSpecifiedExamples:{},autogeneratedExamples:{}}}),o={...o,...y.inlinedTypes},y.schema?.typeDeclaration.referencedTypes!=null&&y.schema.typeDeclaration.referencedTypes.forEach(b=>{f.add(b)});for(let b of y.schema?.audiences??[])c[b]==null&&(c[b]=new Set),c[b].add(s)}}for(let s of Object.keys(o))f.add(s);return{convertedProperties:a,propertiesByAudience:c,inlinedTypesFromProperties:o,referencedTypes:f}}function q$S(e,t,r){return r.isReferenceObject(t)?void 0:new I1.FernTypeNameExtension({breadcrumbs:e,schema:t,context:r}).convert()}var eQn=class extends Oa{schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){let t=typeof this.schema.additionalProperties=="boolean"&&this.schema.additionalProperties;if(!this.schema.properties&&!this.schema.allOf)return{type:Yc.object({properties:[],extends:[],extendedProperties:[],extraProperties:t}),propertiesByAudience:{},inlinedTypes:{},referencedTypes:new Set};let{convertedProperties:r,inlinedTypesFromProperties:i,referencedTypes:n,propertiesByAudience:a}=iPa({properties:this.schema.properties??{},required:this.schema.required??[],breadcrumbs:this.breadcrumbs,context:this.context,errorCollector:this.context.errorCollector}),o=[],c=n,f=this.schema.required!=null&&this.schema.required.length>0,s=i,u=a;for(let[l,p]of(this.schema.allOf??[]).entries()){let _=[...this.breadcrumbs,"allOf",l.toString()],h;if(this.context.isReferenceObject(p)){let A=this.context.resolveMaybeReference({schemaOrReference:p,breadcrumbs:_});if(A==null){this.context.logger.debug?.(`[ObjectSchemaConverter] allOf[${l}] reference could not be resolved. Skipping: ${JSON.stringify(p)}`);continue}if(h=A,typeof h.additionalProperties=="boolean"&&h.additionalProperties&&(t=!0),!f||Object.keys(h.properties??{}).every(g=>!this.schema.required?.includes(g))){this.addTypeReferenceToExtends({reference:p,breadcrumbs:_,extends_:o,referencedTypes:c});continue}}else h=p;typeof h.additionalProperties=="boolean"&&h.additionalProperties&&(t=!0);let{convertedProperties:y,inlinedTypesFromProperties:b,referencedTypes:v,propertiesByAudience:O}=iPa({properties:h.properties??{},required:[...this.schema.required??[],...h.required??[]],breadcrumbs:_,context:this.context,errorCollector:this.context.errorCollector});r.push(...y),s={...s,...b},u={...u,...O},v.forEach(A=>{c.add(A)})}for(let l of Object.keys(s))c.add(l);return{type:Yc.object({properties:r,extends:o.map(l=>this.context.typeReferenceToDeclaredTypeName(l)).filter(Zu),extendedProperties:[],extraProperties:t}),propertiesByAudience:u,referencedTypes:c,inlinedTypes:s}}addTypeReferenceToExtends({reference:t,breadcrumbs:r,extends_:i,referencedTypes:n}){let a=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:r});a.ok&&i.push(a.reference);let o=this.context.getTypeIdFromSchemaReference(t);o!=null&&n.add(o)}};var CFo=class extends Xc{node;key="x-fern-discriminated";constructor({breadcrumbs:t,node:r,context:i}){super({breadcrumbs:t,context:i}),this.node=r}convert(){let t=this.getExtensionValue(this.node);if(t!=null&&typeof t=="boolean")return t}};var tQn=class extends Oa{schema;id;constructor({context:t,breadcrumbs:r,schema:i,id:n,inlinedTypes:a}){super({context:t,breadcrumbs:r}),this.schema=i,this.id=n}convert(){return this.shouldConvertAsNullableSchemaOrReference()?this.convertAsNullableSchemaOrReference():new CFo({context:this.context,breadcrumbs:this.breadcrumbs,node:this.schema}).convert()===!1?this.convertAsUndiscriminatedUnion():this.schema.discriminator!=null&&!this.unionVariantsContainLiteral({discriminantProperty:this.schema.discriminator.propertyName})?this.convertAsDiscriminatedUnion():this.convertAsUndiscriminatedUnion()}unionVariantsContainLiteral({discriminantProperty:t}){for(let[r,i]of Object.entries(this.schema.discriminator?.mapping??{})){let n=this.context.resolveReference({reference:{$ref:i},breadcrumbs:this.breadcrumbs});if(n.resolved&&!Object.keys(n.value.properties??{}).includes(t))return!1}return!0}convertAsDiscriminatedUnion(){if(this.schema.discriminator==null)return;let t=[],r=new Set,i={};for(let[f,s]of Object.entries(this.schema.discriminator.mapping??{})){let u=new L3({context:this.context,schemaOrReference:{$ref:s},breadcrumbs:[...this.breadcrumbs,"discriminator","mapping",f]}),l=this.context.getTypeIdFromSchemaReference({$ref:s});l!=null&&r.add(l);let p=u.convert();if(p?.type!=null&&l!=null){for(let h of Object.keys(p?.inlinedTypes??{}))r.add(h);for(let h of p.schema?.typeDeclaration.referencedTypes??[])r.add(h);let _=this.context.casingsGenerator.generateNameAndWireValue({name:f,wireValue:f});t.push({docs:void 0,discriminantValue:_,availability:p.availability,displayName:f,shape:rz.samePropertiesAsObject({typeId:l,name:this.context.casingsGenerator.generateName(l),fernFilepath:{allParts:[],packagePath:[],file:void 0},displayName:f})}),i={...i,...p.inlinedTypes}}}let{convertedProperties:n,referencedTypes:a,inlinedTypesFromProperties:o}=iPa({properties:this.schema.properties??{},required:this.schema.required??[],breadcrumbs:this.breadcrumbs,context:this.context,errorCollector:this.context.errorCollector});r=new Set([...r,...a]);let c=[];for(let[f,s]of(this.schema.allOf??[]).entries()){let u=[...this.breadcrumbs,"allOf",f.toString()];if(this.context.isReferenceObject(s)){let l=this.context.convertReferenceToTypeReference({reference:s,breadcrumbs:u});if(l.ok){let _=this.context.typeReferenceToDeclaredTypeName(l.reference);_!=null&&c.push(_)}let p=this.context.getTypeIdFromSchemaReference(s);p!=null&&r.add(p);continue}}for(let f of Object.keys({...i,...o}))r.add(f);return{type:Yc.union({baseProperties:n,discriminant:this.context.casingsGenerator.generateNameAndWireValue({name:this.schema.discriminator.propertyName,wireValue:this.schema.discriminator.propertyName}),extends:c,types:t}),referencedTypes:r,inlinedTypes:{...i,...o}}}convertAsUndiscriminatedUnion(){if(!this.schema.oneOf&&!this.schema.anyOf||this.schema.anyOf?.length===0&&this.schema.oneOf?.length===0)return;let t=[],r=new Set,i={},n=[...this.schema.oneOf??[],...this.schema.anyOf??[]].filter(a=>!this.context.isReferenceObject(a));for(let[a,o]of[...(this.schema.oneOf??[]).entries(),...(this.schema.anyOf??[]).entries()]){if(this.context.isReferenceObject(o)){let p;if(this.context.isReferenceObjectWithIdentifier(o))p=this.context.convertReferenceToTypeReference({reference:o,displayNameOverride:o.summary??o.title??o.name??o.messageId,displayNameOverrideSource:"reference_identifier"});else if(this.getDiscriminatorKeyForRef(o)!=null){let h=this.getDiscriminatorKeyForRef(o);p=this.context.convertReferenceToTypeReference({reference:o,displayNameOverride:h,displayNameOverrideSource:"discriminator_key"})}else p=this.context.convertReferenceToTypeReference({reference:o,displayNameOverride:o.$ref.split("/").pop(),displayNameOverrideSource:"schema_identifier"});p.ok&&t.push({type:p.reference,docs:o.description});let _=this.context.getTypeIdFromSchemaReference(o);_!=null&&r.add(_);continue}let c=this.extendSubSchema(o),f=this.context.convertBreadcrumbsToName([`${this.id}_${a}`]),s=o.title,l=new mCi({context:this.context,id:f,nameOverride:s,breadcrumbs:[...this.breadcrumbs,`oneOf[${a}]`],schema:c??o}).convert();if(l!=null){let p=l.convertedSchema.typeDeclaration.shape;p.type==="alias"&&this.typeReferenceIsWrappedPrimitive(p.aliasOf)?t.push({type:p.aliasOf,docs:o.description}):p.type==="object"&&p.properties.length===0&&p.extends.length===0?t.push({type:ii.container(ns.map({keyType:Oa.STRING,valueType:ii.unknown()})),docs:o.description}):(t.push({type:this.context.createNamedTypeReference(f,s),docs:o.description}),i={...i,...l.inlinedTypes,[f]:l.convertedSchema}),l.convertedSchema.typeDeclaration.referencedTypes.forEach(_=>{r.add(_)})}}return{type:Yc.undiscriminatedUnion({members:t}),referencedTypes:r,inlinedTypes:i}}shouldConvertAsNullableSchemaOrReference(){return this.schema.oneOf!=null?this.schema.oneOf.some(t=>t&&typeof t=="object"&&"type"in t&&t.type==="null"):this.schema.anyOf!=null?this.schema.anyOf.some(t=>t&&typeof t=="object"&&"type"in t&&t.type==="null"):!1}removeNullFromOneOfOrAnyOf(){let t=this.schema.oneOf??this.schema.anyOf,r=this.schema.oneOf!=null?"oneOf":"anyOf";if(t==null)return;let i=t.filter(n=>!("type"in n&&n.type==="null"));if(i.length===0){this.context.errorCollector.collect({message:`Received ${r} schema with no valid non-null types`,path:this.breadcrumbs});return}return i.length===1?{...this.schema,[r]:void 0,...i[0]}:{...this.schema,[r]:i}}convertAsNullableSchemaOrReference(){let t=this.removeNullFromOneOfOrAnyOf();if(t==null)return;let i=new L3({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReference:t}).convert();if(i==null)return;let n=this.wrapInNullable(i.type);return{type:Yc.alias({aliasOf:n,resolvedType:n}),referencedTypes:i.schema?.typeDeclaration.referencedTypes??new Set,inlinedTypes:i.inlinedTypes}}typeReferenceIsWrappedPrimitive(t){switch(t.type){case"container":return this.containerTypeIsWrappedPrimitive(t.container);case"named":return!1;case"primitive":return!0;case"unknown":return!0;default:return!1}}containerTypeIsWrappedPrimitive(t){switch(t.type){case"list":return this.typeReferenceIsWrappedPrimitive(t.list);case"map":return this.typeReferenceIsWrappedPrimitive(t.keyType)&&this.typeReferenceIsWrappedPrimitive(t.valueType);case"nullable":return this.typeReferenceIsWrappedPrimitive(t.nullable);case"optional":return this.typeReferenceIsWrappedPrimitive(t.optional);case"set":return this.typeReferenceIsWrappedPrimitive(t.set);case"literal":return!0;default:return!1}}wrapInNullable(t){return ii.container(ns.nullable(t))}mergeIntoObjectSchema(t,r){return{...t,properties:{...r,...t.properties??{}}}}extendSubSchema(t){if(Object.entries(this.schema.properties??{}).length===0)return t;if(t.type==="object")return this.mergeIntoObjectSchema(t,this.schema.properties??{});this.context.isObjectSchemaType(t)||this.context.errorCollector.collect({message:"Received additional object properties for oneOf/anyOf that are not objects",path:this.breadcrumbs})}getDiscriminatorKeyForRef(t){return Object.entries(this.schema.discriminator?.mapping??{}).find(([r,i])=>i===t.$ref)?.[0]}};var rQn=class extends Oa{schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){switch(this.schema.type){case"string":{let t=this.context.getAsString(this.schema.const);if(t!=null)return ii.container(ns.literal(iz.string(t)));if(this.context.settings.typeDatesAsStrings===!1){if(this.schema.format==="date")return ii.primitive({v1:Su.Date,v2:bn.date({})});if(this.schema.format==="date-time")return ii.primitive({v1:Su.DateTime,v2:bn.dateTime({})})}return ii.primitive({v1:"STRING",v2:bn.string({default:this.context.getAsString(this.schema.default),validation:this.getStringValidation(this.schema)})})}case"number":switch(this.schema.format){case"double":return ii.primitive({v1:"DOUBLE",v2:bn.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return ii.primitive({v1:"FLOAT",v2:bn.float({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return ii.primitive({v1:"INTEGER",v2:bn.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return ii.primitive({v1:"LONG",v2:bn.long({default:this.context.getAsNumber(this.schema.default)})});case"uint32":return ii.primitive({v1:"UINT",v2:bn.uint({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return ii.primitive({v1:"UINT_64",v2:bn.uint64({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return ii.primitive({v1:"DOUBLE",v2:bn.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"integer":switch(this.schema.format){case"double":return ii.primitive({v1:"DOUBLE",v2:bn.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return ii.primitive({v1:"FLOAT",v2:bn.float({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return ii.primitive({v1:"INTEGER",v2:bn.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return ii.primitive({v1:"LONG",v2:bn.long({default:this.context.getAsNumber(this.schema.default)})});case"uint32":return ii.primitive({v1:"UINT",v2:bn.uint({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return ii.primitive({v1:"UINT_64",v2:bn.uint64({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return ii.primitive({v1:"INTEGER",v2:bn.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"boolean":{let t=this.context.getAsBoolean(this.schema.const);return t!=null?ii.container(ns.literal(iz.boolean(t))):ii.primitive({v1:"BOOLEAN",v2:bn.boolean({default:this.schema.default})})}default:return}}getNumberValidation(t){return{max:t.maximum,min:t.minimum,exclusiveMax:typeof t.exclusiveMaximum=="boolean"?t.exclusiveMaximum:void 0,exclusiveMin:typeof t.exclusiveMinimum=="boolean"?t.exclusiveMinimum:void 0,multipleOf:t.multipleOf}}getStringValidation(t){return{minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,format:t.format}}};var T$S=["description","example","title","default","deprecated","readOnly","writeOnly","xml","externalDocs","extensions"],mCi=class e extends Oa{schema;id;inlined;audiences;nameOverride;constructor({context:t,breadcrumbs:r,schema:i,id:n,inlined:a=!1,nameOverride:o}){super({context:t,breadcrumbs:r}),this.schema=i,this.id=n,this.inlined=a,this.nameOverride=o,this.audiences=this.context.getAudiences({operation:this.schema,breadcrumbs:this.breadcrumbs})??[]}convert(){let t=this.tryConvertFernTypeDeclaration();if(t!=null)return t;let r=this.tryConvertEnumSchema();if(r!=null)return r;let i=this.tryConvertSingularAllOfSchema();if(i!=null)return i;let n=this.tryConvertPrimitiveSchema();if(n!=null)return n;let a=this.tryConvertArraySchema();if(a!=null)return a;let o=this.tryConvertTypeArraySchema();if(o!=null)return o;let c=this.tryConvertOneOfAnyOfSchema();if(c!=null)return c;let f=this.tryConvertMapSchema();if(f!=null)return f;let s=this.tryConvertObjectAllOfSchema();if(s!=null)return s;let u=this.tryConvertUntypedSchema();if(u!=null)return u;this.context.errorCollector.collect({message:`Failed to convert schema object: ${JSON.stringify(this.schema,null,2)}`,path:this.breadcrumbs})}tryConvertEnumSchema(){if(!this.schema.enum?.length)return;let r=new I1.FernEnumExtension({breadcrumbs:this.breadcrumbs,schema:this.schema,context:this.context}).convert(),n=new kFn({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema,maybeFernEnum:r}).convert();if(n!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:n.type,referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertSingularAllOfSchema(){if(this.schemaOnlyHasAllowedKeys(["allOf","type","title"])&&this.schema.allOf?.length===1&&this.schema.allOf[0]!=null){let r=this.context.resolveMaybeReference({schemaOrReference:this.schema.allOf[0],breadcrumbs:this.breadcrumbs});if(r!=null){let n=new e({context:this.context,breadcrumbs:[...this.breadcrumbs,"allOf","0"],schema:r,id:this.id,inlined:!0}).convert();if(n?.convertedSchema.typeDeclaration?.shape.type!=="object")return n}}if(this.schemaOnlyHasAllowedKeys(["allOf","type","title"])&&Array.isArray(this.schema.allOf)&&this.schema.allOf.length>=1){let r={};for(let n of this.schema.allOf??[]){if(this.context.isReferenceObject(n))return;r=wMn(r,n,(a,o)=>{if(o===n)return a;if(Array.isArray(a)&&Array.isArray(o))return[...a,...o]})}return new e({context:this.context,breadcrumbs:this.breadcrumbs,schema:r,id:this.id,inlined:!0}).convert()}}tryConvertPrimitiveSchema(){let r=new rQn({context:this.context,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Yc.alias({aliasOf:r,resolvedType:r}),referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertArraySchema(){if(this.schema.type==="array"){let r=new iQn({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Yc.alias({aliasOf:r.typeReference,resolvedType:r.typeReference}),referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertTypeArraySchema(){if(Array.isArray(this.schema.type)&&this.schema.type.length>0)return this.schema.type.length===1?this.schema.type=this.schema.type[0]:(this.schema.oneOf=this.schema.type.map(t=>({type:t})),this.schema.type=void 0),this.convert()}tryConvertOneOfAnyOfSchema(){if(this.schema.oneOf!=null||this.schema.anyOf!=null){let r=new tQn({id:this.id,context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertMapSchema(){if((typeof this.schema.additionalProperties=="object"||typeof this.schema.additionalProperties=="boolean")&&this.schema.additionalProperties!=null&&!this.schema.properties&&!this.schema.allOf){if(typeof this.schema.additionalProperties=="boolean"&&this.schema.additionalProperties===!1)return;let r=new IFo({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReferenceOrBoolean:this.schema.additionalProperties}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertObjectAllOfSchema(){if(this.schema.type==="object"||this.schema.properties!=null||this.schema.allOf!=null){let r=new eQn({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:r.propertiesByAudience},inlinedTypes:r.inlinedTypes}}}tryConvertUntypedSchema(){if(this.isUntypedSchema())return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Yc.alias({aliasOf:ii.unknown(),resolvedType:ii.unknown()}),referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertFernTypeDeclaration(){let r=new I1.FernTypeExtension({breadcrumbs:this.breadcrumbs,schema:this.schema,context:this.context}).convert();if(r==null)return;let i=Os_(r);if(i!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Yc.alias({aliasOf:i,resolvedType:i}),referencedTypes:new Set,omitV2Examples:!0}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}createTypeDeclaration({shape:t,referencedTypes:r,omitV2Examples:i}){return{name:this.convertDeclaredTypeName(),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:this.context.getAvailability({node:this.schema,breadcrumbs:this.breadcrumbs}),docs:this.schema.description,referencedTypes:r,source:void 0,inline:this.inlined,v2Examples:i?void 0:this.convertSchemaExamples()}}convertDeclaredTypeName(){return{typeId:this.id,fernFilepath:this.context.createFernFilepath(),name:this.context.casingsGenerator.generateName(this.id),displayName:this.nameOverride}}schemaOnlyHasAllowedKeys(t){let r=[...T$S,...t];return Object.keys(this.schema).every(n=>r.includes(n))}isUntypedSchema(){return!!(this.schema&&typeof this.schema=="object"&&!("oneOf"in this.schema)&&!("anyOf"in this.schema)&&!("allOf"in this.schema)&&!("items"in this.schema)&&!("properties"in this.schema))}convertSchemaExamples(){let t={userSpecifiedExamples:{},autogeneratedExamples:{}},r=this.context.getExamplesFromSchema({schema:this.schema,breadcrumbs:this.breadcrumbs});if(r.length===0){let i=this.generateOrValidateExample({example:void 0,ignoreErrors:!0});return t.autogeneratedExamples={[`${this.id}_example_autogenerated`]:i},t}return t.userSpecifiedExamples=this.convertUserSpecifiedExamples(r),t}convertUserSpecifiedExamples(t){let r={};for(let[i,n]of t.entries()){let a=this.context.resolveExample(n),o=this.generateOrValidateExample({example:a});r[`${this.id}_example_${i}`]=o}return r}generateOrValidateExample({example:t,ignoreErrors:r}){let i=new U3({breadcrumbs:this.breadcrumbs,context:this.context,schema:this.schema,example:t}),{validExample:n,errors:a}=i.convert();return r||a.forEach(o=>{this.context.errorCollector.collect({message:o.message,path:o.path})}),n}};var L3=class extends Oa{schemaOrReference;schemaIdOverride;wrapAsOptional;wrapAsNullable;constructor({context:t,breadcrumbs:r,schemaOrReference:i,schemaIdOverride:n,wrapAsOptional:a=!1,wrapAsNullable:o=!1}){super({context:t,breadcrumbs:r}),this.schemaOrReference=i,this.schemaIdOverride=n,this.wrapAsOptional=a,this.wrapAsNullable=o}convert(){let t=this.maybeConvertReferenceObject({schemaOrReference:this.schemaOrReference});if(t!=null)return t;let r=this.maybeConvertSingularAllOfReferenceObject();return r??this.convertSchemaObject({schema:this.schemaOrReference})}maybeConvertReferenceObject({schemaOrReference:t}){if(this.context.isReferenceObject(t)){let r=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:this.breadcrumbs});if(r.ok)return{type:this.wrapTypeReference(r.reference),inlinedTypes:r.inlinedTypes??{}}}}maybeConvertSingularAllOfReferenceObject(){if(this.context.isReferenceObject(this.schemaOrReference)||this.schemaOrReference.allOf==null||this.schemaOrReference.allOf.length!==1)return;let t=this.schemaOrReference.allOf[0];if(this.context.isReferenceObject(t)){let r=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:this.breadcrumbs});if(r.ok)return{type:this.wrapTypeReference(r.reference),inlinedTypes:{}}}}convertSchemaObject({schema:t}){let r=this.schemaIdOverride??this.context.convertBreadcrumbsToName(this.breadcrumbs),i=new mCi({context:this.context,breadcrumbs:this.breadcrumbs,schema:t,id:r}),n=this.context.getAvailability({node:t,breadcrumbs:this.breadcrumbs}),a=i.convert();if(a!=null){let o=a.convertedSchema.typeDeclaration.shape;return o.type==="alias"?{type:this.wrapTypeReference(o.aliasOf),schema:a.convertedSchema,inlinedTypes:a.inlinedTypes,availability:n}:{type:this.wrapTypeReference(this.context.createNamedTypeReference(r)),schema:a.convertedSchema,inlinedTypes:{...a.inlinedTypes,[r]:a.convertedSchema},availability:n}}}wrapTypeReference(t){return this.wrapAsOptional&&this.wrapAsNullable?this.wrapInOptional(this.wrapInNullable(t)):this.wrapAsOptional?this.wrapInOptional(t):this.wrapAsNullable?this.wrapInNullable(t):t}wrapInOptional(t){return ii.container(ns.optional(t))}wrapInNullable(t){return ii.container(ns.nullable(t))}};var iQn=class e extends Oa{static LIST_UNKNOWN=ii.container(ns.list(ii.unknown()));schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){if(this.schema.items!=null){Array.isArray(this.schema.items)&&(this.schema.items={oneOf:this.schema.items});let r=new L3({context:this.context,breadcrumbs:[...this.breadcrumbs,"items"],schemaOrReference:this.schema.items}).convert();if(r!=null){let i=new Set;for(let n of r.schema?.typeDeclaration.referencedTypes??[])i.add(n);return r.inlinedTypes!=null&&Object.values(r.inlinedTypes).forEach(n=>{n.typeDeclaration.referencedTypes.forEach(a=>{i.add(a)})}),{typeReference:ii.container(ns.list(r.type)),referencedTypes:i,inlinedTypes:r.inlinedTypes}}}return{typeReference:e.LIST_UNKNOWN,referencedTypes:new Set,inlinedTypes:{}}}};var qFo=class extends Oa{group;method;constructor({context:t,breadcrumbs:r,group:i,method:n}){super({context:t,breadcrumbs:r}),this.group=i,this.method=n}parseMediaTypeObject({mediaTypeObject:t,resolveSchema:r,contentType:i,schemaId:n}){if(t.schema==null)return;if(r){let f=this.context.resolveMaybeReference({schemaOrReference:t.schema,breadcrumbs:[...this.breadcrumbs,"content",i]});if(f==null)return;t.schema=f}let o=new L3({context:this.context,breadcrumbs:[...this.breadcrumbs,"content",i,"schema"],schemaOrReference:t.schema,schemaIdOverride:n}).convert();if(o==null)return;let c=t.examples!=null?Object.fromEntries(Object.entries(t.examples).map(([f,s])=>{if(this.context.isReferenceObject(s)){let u=this.context.resolveReference({reference:s,breadcrumbs:[...this.breadcrumbs,"content",i,"examples"],skipErrorCollector:!0});return u.resolved?[f,u.value.value??u.value]:null}return[f,s.value??s]}).filter(f=>f!=null)):void 0;return{...o,examples:c}}parseMediaTypeSchemaOrReference({schemaOrReference:t,schemaId:r}){let n=new L3({context:this.context,breadcrumbs:[...this.breadcrumbs],schemaOrReference:t,schemaIdOverride:r}).convert();if(n!=null)return{...n,examples:void 0}}convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:r,exampleGenerationStrategy:i}){let n={userSpecifiedExamples:{},autogeneratedExamples:{}},a=t?.schema,o=this.context.getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:this.breadcrumbs,defaultExampleName:`${[...this.group,this.method].join("_")}_example`});for(let[c,f]of o){let s=this.context.resolveExampleWithValue(f),u=this.context.isExampleWithSummary(f)?f.summary:c;s!=null&&(a!=null?n.userSpecifiedExamples[u]=this.generateOrValidateExample({schema:a,example:s,exampleGenerationStrategy:i}):n.userSpecifiedExamples[u]=s)}if(Object.keys(n.userSpecifiedExamples).length===0&&a!=null){let c=Fo(`${[...this.group,this.method].join("_")}_example`);n.autogeneratedExamples[c]=this.generateOrValidateExample({schema:a,example:void 0,ignoreErrors:!0,generateOptionalProperties:r,exampleGenerationStrategy:i})}return n}generateOrValidateExample({schema:t,example:r,ignoreErrors:i,generateOptionalProperties:n,exampleGenerationStrategy:a}){let o=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(o==null)return;let c=this.context.getExamplesFromSchema({schema:o,breadcrumbs:this.breadcrumbs}),f=new U3({breadcrumbs:this.breadcrumbs,context:this.context,schema:o,example:r??c[0],generateOptionalProperties:n??!1,exampleGenerationStrategy:a}),{validExample:s,errors:u}=f.convert();return i||u.forEach(l=>{this.context.errorCollector.collect({message:l.message,path:l.path})}),s}};var TFo=class extends Oa{parameter;constructor({context:t,breadcrumbs:r,parameter:i}){super({context:t,breadcrumbs:r}),this.parameter=i}convertToOutput({schema:t,typeReference:r,inlinedTypes:i}){let n=this.context.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs}),a=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs}),o=this.getParameterSchemaWithExampleOverride({schema:a});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:this.context.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:r??Oa.OPTIONAL_STRING,allowMultiple:this.parameter.explode??!1,v2Examples:this.convertParameterExamples({schema:o??t}),availability:n,explode:this.getExplodeForQueryParameter()},inlinedTypes:i};case"header":return{type:"header",parameter:{name:this.context.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:r??Oa.OPTIONAL_STRING,env:void 0,v2Examples:this.convertParameterExamples({schema:o??t}),availability:n},inlinedTypes:i};case"path":return{type:"path",parameter:{name:this.context.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:r??Oa.STRING,location:"ENDPOINT",variable:void 0,v2Examples:this.convertParameterExamples({schema:o??t}),explode:this.getExplodeForPathParameter()},inlinedTypes:i};default:return}}getParameterSchemaWithExampleOverride({schema:t}){if(t!=null)return t.type==="string"&&t.example==null?{...t,example:this.parameter.name}:t}convertParameterExamples({schema:t}){let r={userSpecifiedExamples:{},autogeneratedExamples:{}},i=this.parameter.example,n=this.parameter.examples;for(let[a,o]of Object.entries(n??{})){let c=this.context.resolveExampleWithValue(o);c!=null&&(r.userSpecifiedExamples[a]=this.generateOrValidateExample({schema:t,example:c}))}if(i!=null){let a=this.context.generateUniqueName({prefix:`${this.parameter.name}_example`,existingNames:Object.keys(r.userSpecifiedExamples)});r.userSpecifiedExamples[a]=this.generateOrValidateExample({schema:t,example:i})}if(Object.keys(r.userSpecifiedExamples).length===0){let a=`${this.parameter.name}_example`;r.autogeneratedExamples[a]=this.generateOrValidateExample({schema:t,example:void 0,ignoreErrors:!0})}return r}generateOrValidateExample({schema:t,ignoreErrors:r,example:i}){let n=new U3({breadcrumbs:this.breadcrumbs,context:this.context,schema:t,example:i}),{validExample:a,errors:o}=n.convert();return r||o.forEach(c=>{this.context.errorCollector.collect({message:c.message,path:c.path})}),a}getExplodeForQueryParameter(){let t=this.parameter.style??"form",r=this.parameter.explode;if(r!==void 0)return t==="form"?r===!0?void 0:r:r===!1?void 0:r}getExplodeForPathParameter(){let t=this.parameter.explode;if(t!==void 0)return t===!1?void 0:t}};var RFo=class extends Xc{server;key="x-fern-server-name";constructor({breadcrumbs:t,server:r,context:i}){super({breadcrumbs:t,context:i}),this.server=r}convert(){let t=this.getExtensionValue(this.server,"x-name");if(!(t==null||typeof t!="string"))return t}};var As_="Base",Ohe=class e extends Oa{servers;endpointLevelServers;constructor({breadcrumbs:t,context:r,servers:i,endpointLevelServers:n}){super({breadcrumbs:t,context:r}),this.servers=i,this.endpointLevelServers=n}convert(){if(this.servers==null||this.servers.length===0||this.servers[0]==null)return;if(this.endpointLevelServers!=null&&this.endpointLevelServers.length>0){let r=this.getDefaultBaseUrlName(),i={id:r,name:this.context.casingsGenerator.generateName(r)},n=this.endpointLevelServers.map(c=>{let f=e.getServerName({server:c,context:this.context});return{id:f,name:this.context.casingsGenerator.generateName(f)}}).filter((c,f,s)=>s.findIndex(u=>u.id===c.id)===f),a=[i,...n],o=this.servers.map(c=>{let f=e.getServerName({server:c,context:this.context}),s=this.endpointLevelServers?.map(u=>[e.getServerName({server:u,context:this.context}),this.getServerUrl(u)]);return{id:f,name:this.context.casingsGenerator.generateName(f),urls:{[r]:this.getServerUrl(c),...Object.fromEntries(s??[])},docs:c.description}});return{value:{defaultEnvironment:o[0]?.id,environments:$E.multipleBaseUrls({baseUrls:a,environments:o})},defaultUrl:i.id}}let t=this.withExplodedServers(this.servers).map(r=>{let i=e.getServerName({server:r,context:this.context});return{id:i,name:this.context.casingsGenerator.generateName(i),url:this.maybeRemoveTrailingSlashIfNotEmpty(this.getServerUrl(r)),docs:r.description}}).filter(Zu);return{value:{defaultEnvironment:t[0]?.id,environments:$E.singleBaseUrl({environments:t})},defaultUrl:t[0]?.id}}static getServerExtensionName({server:t,context:r}){return new RFo({breadcrumbs:[],server:t,context:r}).convert()}static getServerName({server:t,context:r}){return t.name!=null?t.name:e.getServerExtensionName({server:t,context:r})??t.description??t.url}getServerUrl(t){if(t.variables==null)return t.url;let r=t.url;for(let[i,n]of Object.entries(t.variables))n.default!=null&&(r=r.replace(`{${i}}`,encodeURIComponent(n.default)));return r}withExplodedServers(t){return t.flatMap(r=>{if(r.variables==null)return[r];let i=Object.entries(r.variables).filter(([c,f])=>f.enum!=null&&f.enum.length>0);if(i.length===0)return[r];let n=i[0];if(n==null)return[r];let[a,o]=n;return o.enum==null?[r]:o.enum.map(c=>{let f=r.url.replace(`{${a}}`,encodeURIComponent(c)),s={};for(let[l,p]of Object.entries(r.variables??{}))l!==a&&(s[l]=p);let u={...r,url:f,variables:Object.keys(s).length>0?s:void 0,"x-fern-server-name":r.description?`${r.description}_${c}`:`${c}`,description:r.description};return this.withExplodedServers([u])[0]})}).filter(Zu)}getDefaultBaseUrlName(){return this.servers==null||this.servers.length===0||this.servers[0]==null?As_:e.getServerExtensionName({server:this.servers[0],context:this.context})??As_}maybeRemoveTrailingSlashIfNotEmpty(t){return t.endsWith("/")&&t!=="/"?t.slice(0,-1):t}};var UKi=class{context;constructor({context:t}){this.context=t}validateExample({example:t,schema:r,breadcrumbs:i,exampleGenerationStrategy:n}){return new U3({breadcrumbs:i,context:this.context,schema:r,example:t,depth:0,exampleGenerationStrategy:n,generateOptionalProperties:!1}).convert()}validateEndpointExample({exampleToValidate:t}){let r=[],i=[],n=!0,a=!1,o,c=[t.endpointPath,t.method];if(t.requestExample!==void 0&&t.requestSchema!==void 0){let s=this.validateExample({example:t.requestExample,schema:t.requestSchema,breadcrumbs:[...c,"request"],exampleGenerationStrategy:"request"});if(!s.isValid){n=!1;let u=t.exampleSource==="human"?B1.WARNING:B1.ERROR;r.push(...s.errors.map(l=>({...l,level:u,message:`Invalid request example: ${l.message}`})))}s.coerced&&(a=!0,i.push({level:B1.WARNING,message:"Request example was coerced to match schema",path:[...c,"request"]})),o={request:s.validExample}}let f=this.getResponseSchemaForValidation(t);if(t.responseExample!==void 0&&f!==void 0){let s=this.validateExample({example:t.responseExample,schema:f,breadcrumbs:[...c,"response"],exampleGenerationStrategy:"response"});if(!s.isValid){n=!1;let u=t.exampleSource==="human"?B1.WARNING:B1.ERROR;r.push(...s.errors.map(l=>({...l,level:u,message:`Invalid response example: ${l.message}`})))}s.coerced&&(a=!0,i.push({level:B1.WARNING,message:"Response example was coerced to match schema",path:[...c,"response"]})),o={...typeof o=="object"&&o!==null?o:{},response:s.validExample}}return{isValid:n,errors:r,warnings:i,endpointPath:t.endpointPath,method:t.method,exampleSource:t.exampleSource,exampleName:t.exampleName,validExample:o,coerced:a}}getResponseSchemaForValidation(t){let{responseStatusCode:r,responseSchemas:i,responseSchema:n}=t;return i&&Object.keys(i).length>0?r&&i[r]?i[r]:i[200]??i[201]:n}validateAiExamples({aiExamples:t,spec:r}){let i=[],n=[];for(let a of t){let{requestSchema:o,responseSchema:c,responseSchemas:f}=this.getSchemasForEndpoint({spec:r,endpointPath:a.endpointPath,method:a.method}),s={endpointPath:a.endpointPath,method:a.method,exampleSource:"ai",requestExample:a.request?.body,responseExample:a.response?.body,requestSchema:o,responseSchema:c,responseSchemas:f},u=this.validateEndpointExample({exampleToValidate:s}),l=this.hasUnexpectedProperties({requestExample:a.request?.body,responseExample:a.response?.body,requestSchema:o,responseSchema:c}),p=u.errors.length>0||u.warnings.length>0;!u.isValid||p||l?n.push({example:a,validationResult:u}):i.push(a)}return{validExamples:i,invalidExamples:n}}hasUnexpectedProperties({requestExample:t,responseExample:r,requestSchema:i,responseSchema:n}){return!!(t&&i&&this.exampleHasUnexpectedProperties(t,i)||r&&n&&this.exampleHasUnexpectedProperties(r,n))}exampleHasUnexpectedProperties(t,r){if(!t||typeof t!="object"||t===null)return!1;let i=this.context.resolveMaybeReference({schemaOrReference:r,breadcrumbs:[],skipErrorCollector:!0});if(!i||!i.properties)return!1;let n=t,a=new Set(Object.keys(i.properties));return Object.keys(n).some(c=>!a.has(c))}validateHumanExamples({spec:t}){let r=[],i=0,n=0,a=0,o=[],c=[];if(!t.paths)return{endpoints:r,totalExamples:i,validExamples:n,invalidExamples:a,hasInvalidHumanExamples:!1,hasInvalidAiExamples:!1,invalidHumanExamples:o,invalidAiExamples:c};for(let[f,s]of Object.entries(t.paths)){if(!s)continue;let u=["get","post","put","delete","patch","options","head","trace"];for(let l of u){let p=s[l];if(!p)continue;let _=[],{requestSchema:h,responseSchema:y,responseSchemas:b}=this.getSchemasForOperation({operation:p}),v=this.extractExamplesFromOperation({operation:p,path:f,method:l});for(let O of v){i++;let A={endpointPath:f,method:l,exampleName:O.name,exampleSource:O.source,requestExample:O.request,responseExample:O.response,requestSchema:h,responseSchema:y,responseStatusCode:O.statusCode,responseSchemas:b},g=this.validateEndpointExample({exampleToValidate:A});_.push(g),g.isValid?n++:(a++,O.source==="human"?o.push(g):O.source==="ai"&&c.push(g))}_.length>0&&r.push({endpointPath:f,method:l,results:_,hasInvalidExamples:_.some(O=>!O.isValid),invalidExampleCount:_.filter(O=>!O.isValid).length})}}return{endpoints:r,totalExamples:i,validExamples:n,invalidExamples:a,hasInvalidHumanExamples:o.length>0,hasInvalidAiExamples:c.length>0,invalidHumanExamples:o,invalidAiExamples:c}}getSchemasForEndpoint({spec:t,endpointPath:r,method:i}){let n=t.paths?.[r];if(!n)return{responseSchemas:{}};let a=n[i.toLowerCase()];return!a||typeof a!="object"||!("responses"in a)?{responseSchemas:{}}:this.getSchemasForOperation({operation:a})}getSchemasForOperation({operation:t}){let r,i,n={};if(t.requestBody&&!this.context.isReferenceObject(t.requestBody)){let o=t.requestBody.content?.["application/json"];o?.schema&&(r=o.schema)}if(t.responses){for(let[a,o]of Object.entries(t.responses)){if(!o||this.context.isReferenceObject(o))continue;let f=o.content?.["application/json"];f?.schema&&(n[a]=f.schema)}i=n[200]??n[201]}return{requestSchema:r,responseSchema:i,responseSchemas:n}}extractExamplesFromOperation({operation:t,path:r,method:i}){let n=[];if(t.requestBody&&!this.context.isReferenceObject(t.requestBody)){let c=t.requestBody.content?.["application/json"];if(c?.example!==void 0&&n.push({name:`${i}_${r}_request_example`,source:"openapi",request:c.example}),c?.examples)for(let[f,s]of Object.entries(c.examples)){let u=this.context.isReferenceObject(s)?this.context.resolveExample(s):s;u&&typeof u=="object"&&"value"in u&&n.push({name:f,source:"human",request:u.value})}}if(t.responses)for(let[o,c]of Object.entries(t.responses)){if(!c||this.context.isReferenceObject(c))continue;let s=c.content?.["application/json"];if(s?.example!==void 0){let u=n.find(l=>l.request!==void 0&&l.response===void 0);u?(u.response=s.example,u.statusCode=o):n.push({name:`${i}_${r}_response_${o}_example`,source:"openapi",response:s.example,statusCode:o})}if(s?.examples)for(let[u,l]of Object.entries(s.examples)){let p=this.context.isReferenceObject(l)?this.context.resolveExample(l):l;if(p&&typeof p=="object"&&"value"in p){let _=n.find(h=>h.name===u);_?(_.response=p.value,_.statusCode=o):n.push({name:u,source:"human",response:p.value,statusCode:o})}}}let a=t["x-fern-examples"];if(Array.isArray(a)){for(let o of a)if(typeof o=="object"&&o!==null){let c=o;n.push({name:c.name,source:"human",request:c.request?.body,response:c.response?.body})}}return n}};var zFo={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",498:"InvalidTokenError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},R$S=new Set(Object.values(zFo));var nQn=class{enabled=!0;write(t,...r){this.enabled&&process.stderr.write(`[${t}] ${r.join(" ")}
1353
1353
  `)}disable(){this.enabled=!1}enable(){this.enabled=!0}trace(...t){this.write($s.Trace,...t)}debug(...t){this.write($s.Debug,...t)}info(...t){this.write($s.Info,...t)}warn(...t){this.write($s.Warn,...t)}error(...t){this.write($s.Error,...t)}log(t,...r){this.write(t,...r)}};function a9t(e){if(e?.deprecated)return{status:IC.Deprecated,message:"DEPRECATED"}}var uFt={FILE:{NAME:1,PACKAGE:2,DEPENDENCY:3,MESSAGE_TYPE:4,ENUM_TYPE:5,SERVICE:6,EXTENSION:7,OPTIONS:8,SOURCE_CODE_INFO:9,PUBLIC_DEPENDENCY:10,WEAK_DEPENDENCY:11,SYNTAX:12},MESSAGE:{NAME:1,FIELD:2,NESTED_TYPE:3,ENUM_TYPE:4,EXTENSION_RANGE:5,EXTENSION:6,OPTIONS:7,ONEOF_DECL:8,RESERVED_RANGE:9,RESERVED_NAME:10},ENUM:{NAME:1,VALUE:2,OPTIONS:3,RESERVED_RANGE:4,RESERVED_NAME:5},SERVICE:{NAME:1,METHOD:2,OPTIONS:3},METHOD:{NAME:1,INPUT_TYPE:2,OUTPUT_TYPE:3,OPTIONS:4,CLIENT_STREAMING:5,SERVER_STREAMING:6}},NFo={MESSAGE:4,ENUM:5,SERVICE:6};var FFo=class extends Oa{enum;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,enum:i,sourceCodeInfoPath:n}){super({context:t,breadcrumbs:r}),this.enum=i,this.sourceCodeInfoPath=n}convert(){let t=this.enum.value.map((r,i)=>{let n=r.name;return{name:{name:this.context.casingsGenerator.generateName(n),wireValue:n},docs:this.context.getCommentForPath([...this.sourceCodeInfoPath,uFt.ENUM.VALUE,i]),availability:void 0}});return{type:Yc.enum({default:void 0,values:t})}}};function ms_(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var Ps_=new Set([vf.DOUBLE,vf.FLOAT,vf.INT64,vf.UINT64,vf.INT32,vf.FIXED64,vf.FIXED32,vf.BOOL,vf.STRING,vf.BYTES,vf.UINT32,vf.SFIXED32,vf.SFIXED64,vf.SINT32,vf.SINT64]);var QFo=class e extends Oa{static LIST_UNKNOWN=ii.container(ns.list(ii.unknown()));field;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,field:i,sourceCodeInfoPath:n}){super({context:t,breadcrumbs:r}),this.field=i,this.sourceCodeInfoPath=n}convert(){if(this.field.label===3){let r=new PCi({context:this.context,breadcrumbs:this.breadcrumbs,field:{...this.field,label:iMn.OPTIONAL},sourceCodeInfoPath:this.sourceCodeInfoPath}).convert();if(r!=null){let i=new Set;return{typeReference:ii.container(ns.list(r.type)),referencedTypes:i,inlinedTypes:r.inlinedTypes}}}return{typeReference:e.LIST_UNKNOWN,referencedTypes:new Set,inlinedTypes:{}}}};var UFo=class extends Oa{field;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,field:i,sourceCodeInfoPath:n}){super({context:t,breadcrumbs:r}),this.field=i,this.sourceCodeInfoPath=n}convert(){switch(this.field.type){case vf.STRING:return ii.primitive({v1:Su.String,v2:bn.string({default:void 0,validation:void 0})});case vf.DOUBLE:return ii.primitive({v1:Su.Double,v2:bn.double({default:void 0,validation:void 0})});case vf.FLOAT:return ii.primitive({v1:Su.Float,v2:bn.float({})});case vf.INT32:return ii.primitive({v1:Su.Integer,v2:bn.integer({default:void 0,validation:void 0})});case vf.INT64:return ii.primitive({v1:Su.Long,v2:bn.long({default:void 0})});case vf.UINT32:return ii.primitive({v1:Su.Uint,v2:bn.uint({default:void 0})});case vf.UINT64:return ii.primitive({v1:Su.Uint64,v2:bn.uint64({default:void 0})});case vf.BOOL:return ii.primitive({v1:Su.Boolean,v2:bn.boolean({default:void 0})});default:return ii.unknown()}}};var PCi=class extends Oa{field;wrapAsOptional;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,field:i,wrapAsOptional:n,sourceCodeInfoPath:a}){super({context:t,breadcrumbs:r}),this.field=i,this.wrapAsOptional=n??!0,this.sourceCodeInfoPath=a}convert(){if(this.field.label===3){let i=new QFo({context:this.context,breadcrumbs:this.breadcrumbs,field:this.field,sourceCodeInfoPath:this.sourceCodeInfoPath}).convert();if(i!=null)return{type:this.wrapAsOptional?this.wrapInOptional(i.typeReference):i.typeReference,inlinedTypes:i.inlinedTypes,availability:a9t(this.field.options)}}if(Ps_.has(this.field.type)){let i=new UFo({context:this.context,breadcrumbs:this.breadcrumbs,field:this.field,sourceCodeInfoPath:this.sourceCodeInfoPath}).convert();if(i!=null)return{type:this.wrapAsOptional?this.wrapInOptional(i):i,inlinedTypes:{},availability:a9t(this.field.options)}}if((this.field.type===vf.MESSAGE||this.field.type===vf.ENUM)&&this.field.typeName!=null){let r=this.context.convertGrpcReferenceToTypeReference({typeName:this.field.typeName,displayNameOverride:this.field.name});if(r.ok)return{type:this.wrapAsOptional?this.wrapInOptional(r.reference):r.reference,inlinedTypes:{},availability:a9t(this.field.options)}}}wrapInOptional(t){return ii.container(ns.optional(t))}};function js_({fields:e,breadcrumbs:t,context:r,sourceCodeInfoPath:i}){let n=[],a={},o=new Set,c={};for(let[f,s]of e.entries()){let l=new PCi({context:r,breadcrumbs:[...t,"fields",s.name],field:s,sourceCodeInfoPath:[...i,uFt.MESSAGE.FIELD,f]}).convert();if(l!=null){let p={name:r.casingsGenerator.generateNameAndWireValue({name:s.name,wireValue:s.name}),valueType:l.type,docs:r.getCommentForPath([...i,uFt.MESSAGE.FIELD,f]),availability:l.availability,propertyAccess:void 0,v2Examples:void 0};if(Object.hasOwn(s,"oneofIndex")&&s.oneofIndex!=null){c[s.oneofIndex]==null&&(c[s.oneofIndex]=[]),c[s.oneofIndex].push(s);continue}n.push(p)}}return{convertedFields:n,referencedTypes:o,propertiesByAudience:a,oneOfFields:c}}var LFo=class extends Oa{oneOfFields;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,oneOfFields:i,sourceCodeInfoPath:n}){super({context:t,breadcrumbs:r}),this.oneOfFields=i,this.sourceCodeInfoPath=n}convert(){let t=[];for(let r of this.oneOfFields){let n=new PCi({context:this.context,breadcrumbs:this.breadcrumbs,field:r,wrapAsOptional:!1,sourceCodeInfoPath:this.sourceCodeInfoPath}).convert();n!=null&&t.push({type:n.type,docs:void 0})}return{type:Yc.undiscriminatedUnion({members:t}),referencedTypes:new Set,inlinedTypes:{},availability:a9t(this.getProtoAvailabilityOptions())}}getProtoAvailabilityOptions(){return{deprecated:this.oneOfFields.every(t=>t.options?.deprecated)}}};var VFo=class extends Oa{message;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,message:i,sourceCodeInfoPath:n}){super({context:t,breadcrumbs:r}),this.message=i,this.sourceCodeInfoPath=n}convert(){let t={},r=new Set,{convertedFields:i,referencedTypes:n,propertiesByAudience:a,oneOfFields:o}=js_({fields:this.message.field,breadcrumbs:this.breadcrumbs,context:this.context,sourceCodeInfoPath:this.sourceCodeInfoPath});for(let c of n)r.add(c);for(let[c,f]of this.message.nestedType.entries()){let u=new jCi({context:this.context,breadcrumbs:this.breadcrumbs,schema:f,sourceCodeInfoPath:[...this.sourceCodeInfoPath,uFt.MESSAGE.NESTED_TYPE,c],schemaIndex:c}).convert();if(u!=null){for(let l of u.convertedSchema.typeDeclaration.referencedTypes)r.add(l);t={...t,...Object.fromEntries(Object.entries(u.inlinedTypes).map(([l,p])=>[this.prependDelimitedParentMessageName(l),this.context.updateTypeId(p,this.prependDelimitedParentMessageName(l))])),[this.prependDelimitedParentMessageName(f.name)]:this.context.updateTypeId(u.convertedSchema,this.prependDelimitedParentMessageName(f.name))}}}for(let[c,f]of this.message.enumType.entries()){let u=new jCi({context:this.context,breadcrumbs:this.breadcrumbs,schema:f,sourceCodeInfoPath:[...this.sourceCodeInfoPath,uFt.MESSAGE.ENUM_TYPE,c],schemaIndex:c}).convert();if(u!=null){for(let l of u.convertedSchema.typeDeclaration.referencedTypes)r.add(l);t={...t,...Object.fromEntries(Object.entries(u.inlinedTypes).map(([l,p])=>[this.prependDelimitedParentMessageName(l),this.context.updateTypeId(p,this.prependDelimitedParentMessageName(l))])),[this.prependDelimitedParentMessageName(f.name)]:this.context.updateTypeId(u.convertedSchema,this.prependDelimitedParentMessageName(f.name))}}}for(let[c,f]of this.message.oneofDecl.entries()){let u=new LFo({context:this.context,breadcrumbs:this.breadcrumbs,oneOfFields:o[c]??[],sourceCodeInfoPath:[...this.sourceCodeInfoPath,uFt.MESSAGE.ONEOF_DECL,c]}).convert();if(u!=null){for(let _ of u.referencedTypes)r.add(_);let l={typeDeclaration:this.createTypeDeclaration({shape:u.type,referencedTypes:u.referencedTypes,typeName:this.prependParentMessageName(ms_(f.name))}),audiences:[],propertiesByAudience:{}},p=this.context.convertGrpcReferenceToTypeReference({typeName:this.context.maybePrependPackageName(l.typeDeclaration.name.typeId)});p.ok===!0&&(i.push({name:this.context.casingsGenerator.generateNameAndWireValue({name:f.name,wireValue:f.name}),valueType:p.reference,docs:void 0,availability:u.availability,propertyAccess:void 0,v2Examples:void 0}),t={...t,[l.typeDeclaration.name.typeId]:l})}}return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Yc.object({properties:i,extends:[],extendedProperties:[],extraProperties:!1}),referencedTypes:r,typeName:this.message.name,docs:this.context.getCommentForPath(this.sourceCodeInfoPath),availability:a9t(this.message.options)}),audiences:[],propertiesByAudience:a},inlinedTypes:t}}createTypeDeclaration({shape:t,referencedTypes:r,typeName:i,docs:n,availability:a}){return{name:this.convertDeclaredTypeName(i),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:a,docs:n,referencedTypes:r,source:void 0,inline:!1,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}convertDeclaredTypeName(t){let r=this.context.maybePrependPackageName(t);return{typeId:r,fernFilepath:this.context.createFernFilepath(),name:this.context.casingsGenerator.generateName(r),displayName:t}}prependDelimitedParentMessageName(t,r="."){return`${this.message.name}${r}${t}`}prependParentMessageName(t){return`${this.message.name}${t}`}};var jCi=class extends Oa{schema;audiences;sourceCodeInfoPath;schemaIndex;constructor({context:t,breadcrumbs:r,schema:i,sourceCodeInfoPath:n,schemaIndex:a}){super({context:t,breadcrumbs:r}),this.schema=i,this.sourceCodeInfoPath=n,this.schemaIndex=a,this.audiences=[]}convert(){let t=this.tryConvertGrpcEnum();if(t!=null)return t;let r=this.tryConvertGrpcMessage();if(r!=null)return r}tryConvertGrpcEnum(){if(this.schema.$typeName==="google.protobuf.EnumDescriptorProto"){let r=new FFo({context:this.context,breadcrumbs:[...this.breadcrumbs,this.schema.name],enum:this.schema,sourceCodeInfoPath:this.sourceCodeInfoPath}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:new Set,docs:this.context.getCommentForPath(this.sourceCodeInfoPath),availability:a9t(this.schema.options)}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}}tryConvertGrpcMessage(){if(this.schema.$typeName==="google.protobuf.DescriptorProto"){let r=new VFo({context:this.context,breadcrumbs:[...this.breadcrumbs,this.schema.name],message:this.schema,sourceCodeInfoPath:this.sourceCodeInfoPath}).convert();if(r!=null)return{convertedSchema:r.convertedSchema,inlinedTypes:r.inlinedTypes}}}createTypeDeclaration({shape:t,referencedTypes:r,docs:i,availability:n}){return{name:this.convertDeclaredTypeName(),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:n,docs:i,referencedTypes:r,source:void 0,inline:void 0,v2Examples:void 0}}convertDeclaredTypeName(){let t=this.context.maybePrependPackageName(this.schema.name);return{typeId:t,fernFilepath:this.context.createFernFilepath(),name:this.context.casingsGenerator.generateName(t),displayName:this.schema.name}}};var aQn=class extends SB{comments;codeGeneratorRequest;constructor({comments:t,codeGeneratorRequest:r,...i}){super(i),this.comments=t,this.codeGeneratorRequest=r}resolveTypeIdToProtoFile(t){if(t.startsWith(this.spec.package)){for(let r of this.spec.messageType)if(`${this.spec.package}.${r.name}`===this.maybeRemoveLeadingPeriod(t))return{ok:!0,message:r,protoFileName:this.spec.name}}for(let r of this.codeGeneratorRequest.protoFile.filter(i=>i.name!==this.spec.name))if(t.startsWith(r.package)){for(let i of r.messageType)if(`${r.package}.${i.name}`===this.maybeRemoveLeadingPeriod(t))return{ok:!0,message:i,protoFileName:r.name}}return{ok:!1}}getCodeGeneratorRequest(){return this.codeGeneratorRequest}maybePrependPackageName(t){return this.maybeRemoveLeadingPeriod(t).startsWith(this.spec.package)?t:this.spec.package+"."+t}convertReferenceToTypeReference({reference:t}){return{ok:!1}}convertGrpcReferenceToTypeReference({typeName:t,displayNameOverride:r}){return{ok:!0,reference:ii.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(this.maybeRemoveLeadingPeriod(t)),typeId:this.maybeRemoveLeadingPeriod(t),default:void 0,inline:!1,displayName:r})}}maybeRemoveLeadingPeriod(t){return t.startsWith(".")?t.slice(1):t}maybeRemoveGrpcPackagePrefix(t){let r=t.split(".").filter(n=>n!==""),i=this.spec.package.split(".").filter(n=>n!=="");for(;r.length>0&&i.length>0;){if(r[0]!==i[0])return t;r.shift(),i.shift()}return r.length===0?t:r.join(".")}updateTypeId(t,r){return{...t,typeDeclaration:{...t.typeDeclaration,name:{...t.typeDeclaration.name,typeId:r}}}}getCommentForPath(t){if(!t||t.length===0)return;let r=t[0];if(!(r in this.comments))return;let i=this.comments[r];for(let n=1;n<t.length;n++){let a=t[n];if(a===void 0||!i)return;i=i[a]}return i?._comment}};function $ac(){return{4:{},5:{},6:{}}}function ws_(e){let t=$ac();return e.package?.startsWith("google.protobuf")||e.sourceCodeInfo?.location.forEach(r=>{let i=r.path;if(!i||i.length===0)return;let n=i[0];if(!(n in t))return;let a=r.leadingComments||r.trailingComments||"";if(!a)return;let o=t[n];for(let c=1;c<i.length;c++){let f=i[c];f!=null&&(f in o||(o[f]={}),o=o[f])}o._comment=a.trim()}),t}var nPa=class e extends Oa{MAX_DEPTH=12;EXAMPLE_STRING="example";EXAMPLE_NUMBER=42;EXAMPLE_BOOL=!0;EXAMPLE_BYTES="bytes";message;type;depth;seenMessages;constructor({breadcrumbs:t,context:r,message:i,type:n,depth:a=0,seenMessages:o=new Set}){super({context:r,breadcrumbs:t}),this.message=i,this.type=n,this.depth=a,this.seenMessages=o}convert(){if(this.depth>this.MAX_DEPTH)return{isValid:!0,coerced:!1,validExample:{},errors:[]};let t=this.getFullyQualifiedMessageName(this.message);if(this.seenMessages.has(t))return{isValid:!0,coerced:!1,validExample:{},errors:[]};let r=new Set(this.seenMessages);r.add(t);try{return this.convertMessage(r)}catch(i){return{isValid:!1,coerced:!1,validExample:{},errors:[`Failed to convert message ${t}: ${i}`]}}}getFullyQualifiedMessageName(t){let r=this.context.spec.package||"",i=t.name||"";return r?`${r}.${i}`:i}convertMessage(t){let r=new Map,i=new Map,n=new Map;this.message.oneofDecl&&this.message.oneofDecl.forEach((u,l)=>{u.name&&n.set(l,u.name)});for(let u of this.message.field)Object.hasOwn(u,"oneofIndex")&&u.oneofIndex!=null&&(i.has(u.oneofIndex)||i.set(u.oneofIndex,u));for(let u of this.message.field){let l=u.name??"";if(!(!l||Object.hasOwn(u,"oneofIndex")&&u.oneofIndex!=null&&i.get(u.oneofIndex)!==u))try{let _=this.convertField({field:u,seenMessages:t,fieldName:l});r.set(l,{field:u,result:_})}catch(_){r.set(l,{field:u,result:{isValid:!1,coerced:!1,validExample:null,errors:[`Error converting field ${l}: ${_}`]}})}}let a=Array.from(r.values()),o=a.every(({result:u})=>u.isValid),c=a.flatMap(({result:u})=>u.errors),f={},s=new Map;for(let[u,{field:l,result:p}]of r.entries()){if(!p.isValid||p.validExample===null||p.validExample===void 0)continue;if(Object.hasOwn(l,"oneofIndex")&&l.oneofIndex!=null&&n.has(l.oneofIndex)){let h=n.get(l.oneofIndex)??void 0;h!=null&&s.set(h,{fieldName:u,value:p.validExample})}else f[u]=p.validExample}for(let[u,{fieldName:l,value:p}]of s.entries())f[u]={[l]:p};return{isValid:o,coerced:!1,validExample:f,errors:c}}convertField({field:t,seenMessages:r,fieldName:i}){return t.label===iMn.REPEATED?this.convertRepeatedField({field:t,seenMessages:r,fieldName:i}):this.convertSingleField({field:t,seenMessages:r,fieldName:i})}convertRepeatedField({field:t,seenMessages:r,fieldName:i}){let n=this.convertSingleField({field:t,seenMessages:r,fieldName:i});return{isValid:n.isValid,coerced:!1,validExample:n.isValid?[n.validExample]:[],errors:n.errors}}convertSingleField({field:t,seenMessages:r,fieldName:i}){switch(t.type){case vf.DOUBLE:case vf.FLOAT:case vf.INT64:case vf.UINT64:case vf.INT32:case vf.FIXED64:case vf.FIXED32:case vf.UINT32:case vf.SFIXED32:case vf.SFIXED64:case vf.SINT32:case vf.SINT64:return this.convertNumber();case vf.BOOL:return this.convertBoolean();case vf.STRING:return this.convertString(this.EXAMPLE_STRING);case vf.BYTES:return this.convertBytes();case vf.ENUM:return this.convertEnum(t);case vf.MESSAGE:return this.convertMessage_Field(t,r,i);default:return{isValid:!1,coerced:!1,validExample:null,errors:[`Unsupported field type: ${t.type}`]}}}convertNumber(){return{isValid:!0,coerced:!1,validExample:this.EXAMPLE_NUMBER,errors:[]}}convertBoolean(){return{isValid:!0,coerced:!1,validExample:this.EXAMPLE_BOOL,errors:[]}}convertString(t){return{isValid:!0,coerced:!1,validExample:t,errors:[]}}convertBytes(){return{isValid:!0,coerced:!1,validExample:this.EXAMPLE_BYTES,errors:[]}}convertEnum(t){let r=t.typeName??"",i=this.context.maybeRemoveLeadingPeriod(r),n=this.findEnumType(i);return n?n.value.length===0?{isValid:!0,coerced:!1,validExample:0,errors:[]}:{isValid:!0,coerced:!1,validExample:n.value[0]?.number??0,errors:[]}:{isValid:!1,coerced:!1,validExample:0,errors:[`Enum type ${t.typeName} not found`]}}convertMessage_Field(t,r,i){let n=t.typeName;if(!n)return{isValid:!1,coerced:!1,validExample:null,errors:[`Missing type name for message field ${i}`]};let a=this.context.maybeRemoveLeadingPeriod(n),o,c;if(this.context.getCodeGeneratorRequest())for(let s of this.context.getCodeGeneratorRequest().protoFile){let u=this.context.resolveTypeIdToProtoFile(a);if(u.ok){o=u.message,u.protoFileName!==this.context.spec.name?c=new aQn({...this.context,comments:$ac(),codeGeneratorRequest:this.context.getCodeGeneratorRequest(),spec:s,logger:new nQn}):c=this.context;break}}return!o||!c?{isValid:!0,coerced:!1,validExample:null,errors:[`Could not find message type ${a}`]}:new e({context:c,breadcrumbs:[...this.breadcrumbs,i],message:o,type:this.type,depth:this.depth+1,seenMessages:r}).convert()}findEnumType(t){let r=this.findEnumInFile(t,this.context.spec);if(!r&&this.context.getCodeGeneratorRequest()){for(let i of this.context.getCodeGeneratorRequest().protoFile)if(r=this.findEnumInFile(t,i),r!=null)break}return r}findEnumInFile(t,r){let i=r.package||"";for(let n of r.enumType)if((i?`${i}.${n.name}`:n.name||"")===t||n.name===t)return n;for(let n of r.messageType){let a=this.findEnumInMessage(t,n,i);if(a!=null)return a}}findEnumInMessage(t,r,i){let n=i?`${i}.${r.name}`:r.name||"";for(let a of r.enumType)if(`${n}.${a.name}`===t||a.name===t)return a;for(let a of r.nestedType){let o=this.findEnumInMessage(t,a,n);if(o!=null)return o}}};var WFo=class extends Oa{operation;serviceName;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,operation:i,serviceName:n,sourceCodeInfoPath:a}){super({context:t,breadcrumbs:r}),this.operation=i,this.serviceName=n,this.sourceCodeInfoPath=a}convert(){let t=this.context.spec.package,r=this.convertRequestBody(),i=this.convertResponseBody();return{group:[t,this.serviceName],endpoint:{id:this.operation.name,docs:this.context.getCommentForPath(this.sourceCodeInfoPath),name:this.context.casingsGenerator.generateName(this.context.maybePrependPackageName(this.operation.name)),requestBody:r?.requestBody,v2RequestBodies:void 0,response:i?.responseBody,v2Responses:void 0,displayName:this.context.maybeRemoveGrpcPackagePrefix(this.operation.name),method:WP.Post,baseUrl:void 0,v2BaseUrls:void 0,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:{}},path:{head:this.operation.name,parts:[]},pathParameters:[],queryParameters:[],headers:[],sdkRequest:void 0,errors:[],auth:!1,security:void 0,availability:void 0,userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:!1,basePath:void 0,fullPath:{head:this.operation.name,parts:[]},allPathParameters:[],pagination:void 0,transport:void 0,source:C3.proto({methodType:this.getGrpcMethodType()}),audiences:[],retries:void 0,apiPlayground:void 0}}}getGrpcMethodType(){return this.operation.clientStreaming&&this.operation.serverStreaming?eFt.BidirectionalStream:this.operation.clientStreaming?eFt.ClientStream:this.operation.serverStreaming?eFt.ServerStream:eFt.Unary}convertRequestBody(){let t=this.context.convertGrpcReferenceToTypeReference({typeName:this.operation.inputType,displayNameOverride:this.context.maybeRemoveGrpcPackagePrefix(this.operation.inputType)});return t.ok?{requestBody:UO.reference({contentType:"application/proto",docs:void 0,requestBodyType:t.reference,v2Examples:void 0}),requestExample:void 0}:{requestBody:void 0,requestExample:void 0}}convertResponseBody(){let t=this.context.convertGrpcReferenceToTypeReference({typeName:this.operation.outputType,displayNameOverride:this.context.maybeRemoveGrpcPackagePrefix(this.operation.outputType)});return t.ok?{responseBody:{body:Xf.json(mB.response({responseBodyType:t.reference,docs:void 0,v2Examples:void 0})),statusCode:void 0,isWildcardStatusCode:void 0,docs:void 0},responseExample:void 0}:{responseBody:void 0,responseExample:void 0}}};var xFo=class extends Oa{service;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,service:i,sourceCodeInfoPath:n}){super({context:t,breadcrumbs:r}),this.service=i,this.sourceCodeInfoPath=n}convert(){let t=[];for(let[r,i]of this.service.method.entries()){let a=new WFo({context:this.context,breadcrumbs:this.breadcrumbs,operation:i,serviceName:this.service.name,sourceCodeInfoPath:[...this.sourceCodeInfoPath,uFt.SERVICE.METHOD,r]}).convert();a!=null&&t.push(a)}return{endpoints:t,serviceName:this.context.maybePrependPackageName(this.service.name),serviceDisplayName:this.service.name,inlinedTypes:{}}}};function Es_(){return{displayName:void 0,request:{endpoint:{method:W6t.Post,path:""},baseUrl:void 0,environment:void 0,auth:void 0,headers:void 0,docs:void 0,pathParameters:void 0,queryParameters:void 0,requestBody:void 0},response:{statusCode:200,body:vr.V2HttpEndpointResponseBody.json({}),docs:void 0},codeSamples:[]}}var GFo=class extends oFt{constructor({breadcrumbs:t,context:r,audiences:i}){super({breadcrumbs:t,context:r,audiences:i})}convert(){return this.convertOptions(),this.convertEnumsAndMessages(),this.convertServices(),this.generateExamplesForServices(),this.finalizeIr()}convertOptions(){}convertEnumsAndMessages(){for(let[t,r]of this.context.spec.enumType.entries()){let n=new jCi({context:this.context,breadcrumbs:[...this.breadcrumbs,this.context.spec.package],schema:r,sourceCodeInfoPath:[NFo.ENUM,t],schemaIndex:t}).convert();n!=null&&this.addTypesToIr({...Ss_(n.inlinedTypes,this.context.maybePrependPackageName.bind(this.context)),[this.context.maybePrependPackageName(r.name)]:n.convertedSchema})}for(let[t,r]of this.context.spec.messageType.entries()){let n=new jCi({context:this.context,breadcrumbs:[...this.breadcrumbs,this.context.spec.package],schema:r,sourceCodeInfoPath:[NFo.MESSAGE,t],schemaIndex:t}).convert();n!=null&&this.addTypesToIr({...Ss_(n.inlinedTypes,this.context.maybePrependPackageName.bind(this.context)),[this.context.maybePrependPackageName(r.name)]:n.convertedSchema})}}convertServices(){for(let[t,r]of this.context.spec.service.entries()){let n=new xFo({context:this.context,breadcrumbs:this.breadcrumbs,service:r,sourceCodeInfoPath:[NFo.SERVICE,t]}).convert();if(n!=null)for(let a of n.endpoints)this.addEndpointToIr({endpointGroup:a.group,endpoint:a.endpoint,audiences:[],serviceName:n.serviceName,endpointGroupDisplayName:n.serviceDisplayName})}}generateExamplesForServices(){for(let[t,r]of Object.entries(this.ir.services))for(let[i,n]of Object.entries(r.endpoints)){let a=Es_(),o=this.constructRequestBodyExample(n),c=this.constructResponseBodyExample(n);o!=null&&a.request!=null&&(a.request.requestBody=o),c!=null&&a.response!=null&&(a.response.body=CC.json(c)),n.v2Examples={userSpecifiedExamples:{},autogeneratedExamples:{[i]:a}}}}constructRequestBodyExample(t){let r=t.requestBody.requestBodyType.typeId,i=this.context.resolveTypeIdToProtoFile(r);if(i.ok)return new nPa({context:this.context,breadcrumbs:this.breadcrumbs,message:i.message,type:"request"}).convert().validExample}constructResponseBodyExample(t){let r=(t.response?.body).value.responseBodyType.typeId,i=this.context.resolveTypeIdToProtoFile(r);if(i.ok)return new nPa({context:this.context,breadcrumbs:this.breadcrumbs,message:i.message,type:"response"}).convert().validExample}addEndpointToIr({endpoint:t,audiences:r,endpointGroup:i,endpointGroupDisplayName:n,serviceName:a}){let o=this.context.getGroup({groupParts:i,namespace:this.context.namespace}),c=this.getOrCreatePackage({group:i}),f=[...o].map(l=>this.context.casingsGenerator.generateName(l)),s=f[f.length-1];c.service==null&&(c.service=a??`service_${o.map(l=>Fo(l)).join("/")}`),this.ir.services[c.service]==null&&(this.ir.services[c.service]=this.createNewService({allParts:f,finalpart:s,endpointGroupDisplayName:n})),this.ir.services[c.service]?.endpoints.push(t);let u=this.ir.services[c.service];u!=null&&(this.irGraph.addEndpoint(u,t),this.irGraph.markEndpointForAudience(u.name,[t],r))}getOrCreatePackage({group:t}){let r=[];if(this.context.namespace!=null&&r.push(this.context.namespace),r.push(...t??[]),r.length==0)return this.ir.rootPackage;let i=this.ir.rootPackage;for(let n=0;n<r.length;n++){let a=r[n]??"",c=`subpackage_${r.slice(0,n+1).join("/")}`;this.ir.subpackages[c]==null&&(this.ir.subpackages[c]={name:this.context.casingsGenerator.generateName(a),displayName:a,...this.createPackage({name:a})});let f=this.ir.subpackages[c];i.subpackages.includes(c)||i.subpackages.push(c),i=f}return i}finalizeIr(){return{...this.ir,apiName:this.context.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:this.context.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})},audiences:this.audiences.type==="select"?this.audiences.audiences:void 0}}};function Ss_(e,t){return Object.fromEntries(Object.entries(e).map(([r,i])=>[t(r),i]))}function Ms_({req:e,options:t}){let r,i=_x({generationLanguage:void 0,keywords:void 0,smartCasing:!1});for(let a of e.protoFile){let c=new GFo({context:new aQn({codeGeneratorRequest:e,spec:a,settings:{},errorCollector:new z0e({logger:{log:(f,...s)=>{}},relativeFilepathToSpec:void 0}),logger:new nQn,generationLanguage:void 0,smartCasing:!1,exampleGenerationArgs:{disabled:!0},enableUniqueErrorsPerEndpoint:!1,generateV1Examples:!1,comments:ws_(a)}),breadcrumbs:[],audiences:{type:"all"}}).convert();c!=null&&(r=r===void 0?c:FKi(r,c,i))}let n=Cn.IntermediateRepresentation.json(r,{allowUnrecognizedEnumValues:!0,skipValidation:!0});return n.ok?{name:"ir.json",content:JSON.stringify(n.value,null,2)}:{name:"ir.json",content:JSON.stringify(n.errors,null,2)}}function Ds_(e){return{}}var Yac=z$S({name:"protoc-gen-fern",version:`v${String(Qa_)}`,run:Ms_});function z$S({name:e,version:t,run:r}){return{name:e,version:t,run(i){let n=Ds_(i.parameter),a=r({req:i,options:n});return N$S([a],Q0d,U0d)}}}function N$S(e,t,r){return Rfa(Kto,{supportedFeatures:q0.parse(Vfa.PROTO3_OPTIONAL|Vfa.SUPPORTS_EDITIONS),minimumEdition:t,maximumEdition:r,file:e})}var Cs_=ue(require("net"),1),qs_=ue(require("os"),1),HFo=class extends Error{constructor(t){super(`${t} is locked`)}},oQn={old:new Set,young:new Set},F$S=1e3*15;var aPa,Q$S=()=>{let e=qs_.default.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(e))for(let i of r)t.add(i.address);return t},Bs_=e=>new Promise((t,r)=>{let i=Cs_.default.createServer();i.unref(),i.on("error",r),i.listen(e,()=>{let{port:n}=i.address();i.close(()=>{t(n)})})}),Is_=async(e,t)=>{if(e.host||e.port===0)return Bs_(e);for(let r of t)try{await Bs_({port:e.port,host:r})}catch(i){if(!["EADDRNOTAVAIL","EINVAL"].includes(i.code))throw i}return e.port},U$S=function*(e){e&&(yield*e),yield 0};async function uQn(e){let t,r=new Set;if(e&&(e.port&&(t=typeof e.port=="number"?[e.port]:e.port),e.exclude)){let n=e.exclude;if(typeof n[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let a of n){if(typeof a!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(a))throw new TypeError(`Number ${a} in the exclude option is not a safe integer and can't be used`)}r=new Set(n)}aPa===void 0&&(aPa=setTimeout(()=>{aPa=void 0,oQn.old=oQn.young,oQn.young=new Set},F$S),aPa.unref&&aPa.unref());let i=Q$S();for(let n of U$S(t))try{if(r.has(n))continue;let a=await Is_({...e,port:n},i);for(;oQn.old.has(a)||oQn.young.has(a);){if(n!==0)throw new HFo(n);a=await Is_({...e,port:n},i)}return oQn.young.add(a),a}catch(a){if(!["EADDRINUSE","EACCES"].includes(a.code)&&!(a instanceof HFo))throw a}throw new Error("No available ports found")}hc_();var jl_=ue(Pl_(),1),{applyExtends:XYS,cjsPlatformShim:ZYS,Parser:kYS,processArgv:eXS,Yargs:yQo}=jl_.default;yQo.applyExtends=(e,t,r)=>XYS(e,t,r,ZYS);yQo.hideBin=eXS.hideBin;yQo.Parser=kYS;var wl_=yQo;var El_=require("fs/promises");var Sl_=require("path"),Ml_=ue(BW(),1);async function Dl_({url:e,logger:t}){try{let r=await tXS({url:e,logger:t}),i=await Ml_.default.dir(),n=(0,Sl_.join)(i.path,e.endsWith(".json")?"openapi.json":"openapi.yaml");return t.debug("tmpDir",i.path),t.debug("filePath",n),await(0,El_.writeFile)(n,r),{status:"success",filePath:n}}catch(r){return t.debug(`Encountered an error while loading OpenAPI spec: ${JSON.stringify(r)}`),{status:"failure",errorMessage:`Failed to load OpenAPI spec from ${e}`}}}async function tXS({url:e,logger:t}){let r=await _B.get(e),i=r.headers["content-type"]??"";return i.includes("json")||e.endsWith(".json")?typeof r.data=="string"?r.data:JSON.stringify(r.data,null,2):i.includes("yaml")||e.endsWith(".yml")||e.endsWith(".yaml")?typeof r.data=="string"?r.data:O6i(r.data):(t.warn(`Unrecognized Content-Type "${i}" from endpoint ${e}. Please ensure you're pointing to a URL that returns JSON or YAML and not HTML (e.g. Swagger UI webpage)`),O6i(r.data))}var bPa=ue(A_e(),1);function Hoc(e,t){if(e=bPa.default.parse(e),t=bPa.default.parse(t),!(bPa.default.compareBuild(e,t)>=0))return bPa.default.diff(e,t)||"build"}var rXS=/^([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-([a-z0-9])+$/,iXS=/^([0-9]+)\.([0-9]+)\.([0-9]+)-rc[.-]?([0-9]+)-([0-9]+)-([a-z0-9])+$/,nXS=/^([0-9]+)\.([0-9]+)\.([0-9]+)-rc[.-]?([0-9]+)$/,aXS=/^([0-9]+)\.([0-9]+)\.([0-9]+)$/,oXS=/^([0-9]+)\.([0-9]+)\.([0-9]+)-alpha[.-]?([0-9]+)$/,uXS=/^([0-9]+)\.([0-9]+)\.([0-9]+)-beta[.-]?([0-9]+)$/;function kKi(e){let t=e.match(oXS);if(t!=null){let[c,f,s,u,l]=t,p=ZE(f),_=ZE(s),h=ZE(u),y=ZE(l);if(p==null||_==null||h==null||y==null)throw new Error("Cannot parse alpha version: "+e);return{type:"alpha",major:p,minor:_,patch:h,index:y}}let r=e.match(uXS);if(r!=null){let[c,f,s,u,l]=r,p=ZE(f),_=ZE(s),h=ZE(u),y=ZE(l);if(p==null||_==null||h==null||y==null)throw new Error("Cannot parse beta version: "+e);return{type:"beta",major:p,minor:_,patch:h,index:y}}let i=e.match(rXS);if(i!=null){let[c,f,s,u,l]=i,p=ZE(f),_=ZE(s),h=ZE(u),y=ZE(l);if(p==null||_==null||h==null||y==null)throw new Error("Cannot parse post-release commit version: "+e);return{type:"post-release-commit",major:p,minor:_,patch:h,commitIndex:y}}let n=e.match(nXS);if(n!=null){let[c,f,s,u,l]=n,p=ZE(f),_=ZE(s),h=ZE(u),y=ZE(l);if(p==null||_==null||h==null||y==null)throw new Error("Cannot parse RC version: "+e);return{type:"rc",major:p,minor:_,patch:h,releaseCandidateIndex:y}}let a=e.match(iXS);if(a!=null){let[c,f,s,u,l,p]=a,_=ZE(f),h=ZE(s),y=ZE(u),b=ZE(l),v=ZE(p);if(_==null||h==null||y==null||b==null||v==null)throw new Error("Cannot parse post-RC version: "+e);return{type:"post-rc-commit",major:_,minor:h,patch:y,releaseCandidateIndex:b,commitIndex:v}}let o=e.match(aXS);if(o!=null){let[c,f,s,u]=o,l=ZE(f),p=ZE(s),_=ZE(u);if(l==null||p==null||_==null)throw new Error("Cannot parse release version: "+e);return{type:"release",major:l,minor:p,patch:_}}throw new Error("Failed to parse version: "+e)}function ZE(e){if(e==null||e.length===0)return;let t=Number(e);if(!isNaN(t))return t}function ZH(e,t){if(e===t)return!1;let r=kKi(e),i=kKi(t);if(r.major!==i.major||r.minor!==i.minor||r.patch!==i.patch)return Hoc(Bl_(r),Bl_(i))==null;if(r.type==="post-release-commit")return i.type!=="post-release-commit"||r.commitIndex>i.commitIndex;if(r.type==="release")return i.type!=="post-release-commit";if(r.type==="rc"){switch(i.type){case"release":case"post-release-commit":return!1;case"alpha":case"beta":return!0}return r.releaseCandidateIndex!==i.releaseCandidateIndex&&r.releaseCandidateIndex>i.releaseCandidateIndex}if(r.type==="post-rc-commit"){switch(i.type){case"release":case"post-release-commit":return!1;case"alpha":case"beta":return!0}if(i.type==="post-rc-commit")return r.releaseCandidateIndex!==i.releaseCandidateIndex?r.releaseCandidateIndex>i.releaseCandidateIndex:r.commitIndex>i.commitIndex}if(r.type==="beta"){switch(i.type){case"release":case"post-release-commit":case"rc":case"post-rc-commit":return!1;case"alpha":return!0}return r.index>i.index}if(r.type==="alpha"){switch(i.type){case"release":case"post-release-commit":case"rc":case"post-rc-commit":return!1}return r.index>i.index}return!ZH(t,e)}function Bl_(e){return`${e.major}.${e.minor}.${e.patch}`}var HQ=(e,t=[])=>e.name==="up"||t.includes("vim")&&e.name==="k"||t.includes("emacs")&&e.ctrl&&e.name==="p",kH=(e,t=[])=>e.name==="down"||t.includes("vim")&&e.name==="j"||t.includes("emacs")&&e.ctrl&&e.name==="n",Koc=e=>e.name==="space",eJi=e=>e.name==="backspace",zvi=e=>e.name==="tab",vPa=e=>"1234567890".includes(e.name),BB=e=>e.name==="enter"||e.name==="return";var bQo=class extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(t){super(),this.cause=t?.cause}},vQo=class extends Error{name="CancelPromptError";message="Prompt was canceled"},gPa=class extends Error{name="ExitPromptError"},gQo=class extends Error{name="HookError"},s9t=class extends Error{name="ValidationError"};var Tl_=require("async_hooks");var OQo=require("async_hooks");var Il_=new OQo.AsyncLocalStorage;function sXS(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Cl_(e,t){let r=sXS(e);return Il_.run(r,()=>{function i(n){r.handleChange=()=>{r.index=0,n()},r.handleChange()}return t(i)})}function tJi(){let e=Il_.getStore();if(!e)throw new gQo("[Inquirer] Hook functions can only be called from within a prompt");return e}function Joc(){return tJi().rl}function $oc(e){let t=(...r)=>{let i=tJi(),n=!1,a=i.handleChange;i.handleChange=()=>{n=!0};let o=e(...r);return n&&a(),i.handleChange=a,o};return OQo.AsyncResource.bind(t)}function yQn(e){let t=tJi(),{index:r}=t,i={get(){return t.hooks[r]},set(a){t.hooks[r]=a},initialized:r in t.hooks},n=e(i);return t.index++,n}function ql_(){tJi().handleChange()}var rJi={queue(e){let t=tJi(),{index:r}=t;t.hooksEffect.push(()=>{t.hooksCleanup[r]?.();let i=e(Joc());if(i!=null&&typeof i!="function")throw new s9t("useEffect return value must be a cleanup function or nothing.");t.hooksCleanup[r]=i})},run(){let e=tJi();$oc(()=>{e.hooksEffect.forEach(t=>{t()}),e.hooksEffect.length=0})()},clearAll(){let e=tJi();e.hooksCleanup.forEach(t=>{t?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function Ul(e){return yQn(t=>{let r=Tl_.AsyncResource.bind(function(a){t.get()!==a&&(t.set(a),ql_())});if(t.initialized)return[t.get(),r];let i=typeof e=="function"?e():e;return t.set(i),[i,r]})}function Ehe(e,t){yQn(r=>{let i=r.get();(!Array.isArray(i)||t.some((a,o)=>!Object.is(a,i[o])))&&rJi.queue(e),r.set(t)})}var V0e=ue(y1(),1);var Rl_={prefix:{idle:V0e.default.blue("?"),done:V0e.default.green(bC.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map(e=>V0e.default.yellow(e))},style:{answer:V0e.default.cyan,message:V0e.default.bold,error:e=>V0e.default.red(`> ${e}`),defaultAnswer:e=>V0e.default.dim(`(${e})`),help:V0e.default.dim,highlight:V0e.default.cyan,key:e=>V0e.default.cyan(V0e.default.bold(`<${e}>`))}};function zl_(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Nl_(...e){let t={};for(let r of e)for(let[i,n]of Object.entries(r)){let a=t[i];t[i]=zl_(a)&&zl_(n)?Nl_(a,n):n}return t}function HS(...e){let t=[Rl_,...e.filter(r=>r!=null)];return Nl_(...t)}function IB({status:e="idle",theme:t}){let[r,i]=Ul(!1),[n,a]=Ul(0),{prefix:o,spinner:c}=HS(t);return Ehe(()=>{if(e==="loading"){let s,u=-1,l=setTimeout(()=>{i(!0),s=setInterval(()=>{u=u+1,a(u%c.frames.length)},c.interval)},300);return()=>{clearTimeout(l),clearInterval(s)}}else i(!1)},[e]),r?c.frames[n]:typeof o=="string"?o:o[e==="loading"?"idle":e]??o.idle}function eK(e,t){return yQn(r=>{let i=r.get();if(!i||i.dependencies.length!==t.length||i.dependencies.some((n,a)=>n!==t[a])){let n=e();return r.set({value:n,dependencies:t}),n}return i.value})}function W0e(e){return Ul({current:e})[0]}function CB(e){let t=W0e(e);t.current=e,Ehe(r=>{let i=!1,n=$oc((a,o)=>{i||t.current(o,r)});return r.input.on("keypress",n),()=>{i=!0,r.input.removeListener("keypress",n)}},[])}var Fl_=ue(Jxs(),1),Ql_=ue(r6s(),1);function OPa(e,t){return e.split(`
1354
1354
  `).flatMap(r=>(0,Ql_.default)(r,t,{trim:!1,hard:!0}).split(`
1355
1355
  `).map(i=>i.trimEnd())).join(`
@@ -1391,7 +1391,7 @@ ${g}${O}${m}${bQn}`});function SQo({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.`),zBi(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function wuc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!Pf_(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 kXS(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?zBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function kXS(e){let r=await new mf_.FernRegistryClient({environment:"https://registry.buildwithfern.com"}).generators.getGeneratorByImage({dockerImage:e});if(!r.ok||r.body==null)throw new Error(`Generator ${e} not found`);return r.body.displayName}async function eZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await wf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=TMi(u.name,l),_=await fNt({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 wf_({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=TMi(s.name,u),p=await fNt({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 wf_({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 J_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 Ef_(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=ZH(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 IQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await eZS({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...Ef_(s,f,t.logger));else o.push(...Ef_(c.versions,void 0,t.logger))}return o}var MPa=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 AQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Euc=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),Sf_=typeof globalThis.AbortController=="function",Mf_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Df_=typeof globalThis.ReadableStream=="function",Bf_=typeof globalThis.FormData=="function",CQo=["get","post","put","patch","head","delete"],tZS=()=>{};tZS();var If_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},qQo=2147483647,Cf_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,TQo=Symbol("stop"),qf_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Tf_={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 rZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=Cf_,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},Rf_=(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))}}))},zf_=(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(Rf_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},Nf_=(e,t,r)=>{if(!e.body)return e;let i=rZS(r??e.body);return new Request(e,{duplex:"half",body:Rf_(e.body,i,t)})};var mQn=e=>e!==null&&typeof e=="object";var DPa=(...e)=>{for(let t of e)if((!mQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Duc({},...e)},Suc=(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 RQo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Duc(e[r]??[],t[r]??[])}var Muc=(e={},t={})=>({beforeRequest:RQo(e,t,"beforeRequest"),beforeRetry:RQo(e,t,"beforeRetry"),afterResponse:RQo(e,t,"afterResponse"),beforeError:RQo(e,t,"beforeError")}),Duc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(mQn(n)){for(let[a,o]of Object.entries(n))mQn(o)&&a in t&&(o=Duc(t[a],o)),t={...t,[a]:o};mQn(n.hooks)&&(i=Muc(i,n.hooks),t.hooks=i),mQn(n.headers)&&(r=Suc(r,n.headers),t.headers=r)}return t};var Qf_=e=>CQo.includes(e)?e.toUpperCase():e,iZS=["get","put","head","delete","options","trace"],nZS=[408,413,429,500,502,503,504],aZS=[413,429,503],Ff_={limit:2,methods:iZS,statusCodes:nZS,afterStatusCodes:aZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Uf_=(e={})=>{if(typeof e=="number")return{...Ff_,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{...Ff_,...e}};async function Buc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new AQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function Iuc(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 Lf_=(e,t)=>{let r={};for(let i in t)!(i in Tf_)&&!(i in qf_)&&!(i in e)&&(r[i]=t[i]);return r},Vf_=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 BPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>qQo)throw new RangeError(`The \`timeout\` option cannot be greater than ${qQo}`);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 MPa(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(!Df_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return zf_(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(If_))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:Suc(this._input.headers,r.headers),hooks:Muc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Qf_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:Uf_(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(Sf_&&Mf_){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(Euc&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),Vf_(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);(Bf_&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Euc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Nf_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof AQn)throw t;if(t instanceof MPa){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),qQo);if(this._retryCount<1)throw r;await Iuc(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})===TQo)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=Lf_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):Buc(this._originalRequest,t,this.abortController,this._options)}};var Cuc=e=>{let t=(r,i)=>BPa.create(r,DPa(e,i));for(let r of CQo)t[r]=(i,n)=>BPa.create(i,DPa(e,n,{method:r}));return t.create=r=>Cuc(DPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Cuc(DPa(e,r))),t.stop=TQo,t},oZS=Cuc(),Wf_=oZS;var dd_=ue(fd_(),1);function Nuc(e){let t=(0,dd_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var op_=ue(ap_(),1),up_=ue(A_e(),1),Yuc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Xuc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function Zuc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Nuc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,op_.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 Wf_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new Yuc(e):l}if(t.allVersions)return s;let u=new Xuc(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=up_.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 zPa(e,t){let{version:r}=await Zuc(e.toLowerCase(),t);return r}async function BCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:zPa(e.packageName,{version:t?"prerelease":"latest"})}var sp_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],KQo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new BQo(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.21.0"}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,SQo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await bTn()).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 jf_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1394
+ `,i?zBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function kXS(e){let r=await new mf_.FernRegistryClient({environment:"https://registry.buildwithfern.com"}).generators.getGeneratorByImage({dockerImage:e});if(!r.ok||r.body==null)throw new Error(`Generator ${e} not found`);return r.body.displayName}async function eZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await wf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=TMi(u.name,l),_=await fNt({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 wf_({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=TMi(s.name,u),p=await fNt({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 wf_({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 J_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 Ef_(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=ZH(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 IQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await eZS({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...Ef_(s,f,t.logger));else o.push(...Ef_(c.versions,void 0,t.logger))}return o}var MPa=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 AQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Euc=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),Sf_=typeof globalThis.AbortController=="function",Mf_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Df_=typeof globalThis.ReadableStream=="function",Bf_=typeof globalThis.FormData=="function",CQo=["get","post","put","patch","head","delete"],tZS=()=>{};tZS();var If_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},qQo=2147483647,Cf_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,TQo=Symbol("stop"),qf_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Tf_={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 rZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=Cf_,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},Rf_=(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))}}))},zf_=(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(Rf_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},Nf_=(e,t,r)=>{if(!e.body)return e;let i=rZS(r??e.body);return new Request(e,{duplex:"half",body:Rf_(e.body,i,t)})};var mQn=e=>e!==null&&typeof e=="object";var DPa=(...e)=>{for(let t of e)if((!mQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Duc({},...e)},Suc=(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 RQo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Duc(e[r]??[],t[r]??[])}var Muc=(e={},t={})=>({beforeRequest:RQo(e,t,"beforeRequest"),beforeRetry:RQo(e,t,"beforeRetry"),afterResponse:RQo(e,t,"afterResponse"),beforeError:RQo(e,t,"beforeError")}),Duc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(mQn(n)){for(let[a,o]of Object.entries(n))mQn(o)&&a in t&&(o=Duc(t[a],o)),t={...t,[a]:o};mQn(n.hooks)&&(i=Muc(i,n.hooks),t.hooks=i),mQn(n.headers)&&(r=Suc(r,n.headers),t.headers=r)}return t};var Qf_=e=>CQo.includes(e)?e.toUpperCase():e,iZS=["get","put","head","delete","options","trace"],nZS=[408,413,429,500,502,503,504],aZS=[413,429,503],Ff_={limit:2,methods:iZS,statusCodes:nZS,afterStatusCodes:aZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Uf_=(e={})=>{if(typeof e=="number")return{...Ff_,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{...Ff_,...e}};async function Buc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new AQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function Iuc(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 Lf_=(e,t)=>{let r={};for(let i in t)!(i in Tf_)&&!(i in qf_)&&!(i in e)&&(r[i]=t[i]);return r},Vf_=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 BPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>qQo)throw new RangeError(`The \`timeout\` option cannot be greater than ${qQo}`);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 MPa(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(!Df_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return zf_(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(If_))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:Suc(this._input.headers,r.headers),hooks:Muc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Qf_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:Uf_(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(Sf_&&Mf_){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(Euc&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),Vf_(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);(Bf_&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Euc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Nf_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof AQn)throw t;if(t instanceof MPa){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),qQo);if(this._retryCount<1)throw r;await Iuc(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})===TQo)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=Lf_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):Buc(this._originalRequest,t,this.abortController,this._options)}};var Cuc=e=>{let t=(r,i)=>BPa.create(r,DPa(e,i));for(let r of CQo)t[r]=(i,n)=>BPa.create(i,DPa(e,n,{method:r}));return t.create=r=>Cuc(DPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Cuc(DPa(e,r))),t.stop=TQo,t},oZS=Cuc(),Wf_=oZS;var dd_=ue(fd_(),1);function Nuc(e){let t=(0,dd_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var op_=ue(ap_(),1),up_=ue(A_e(),1),Yuc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Xuc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function Zuc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Nuc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,op_.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 Wf_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new Yuc(e):l}if(t.allVersions)return s;let u=new Xuc(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=up_.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 zPa(e,t){let{version:r}=await Zuc(e.toLowerCase(),t);return r}async function BCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:zPa(e.packageName,{version:t?"prerelease":"latest"})}var sp_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],KQo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new BQo(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.21.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,SQo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await bTn()).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 jf_({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=nws(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 mPa(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 bTn()).sendEvent(t)}logger=K8t((t,...r)=>this.log(t,...r));stderr=K8t((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=cp_(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?cp_(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=sp_[this.numTasks++%sp_.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=>rMi.indexOf(n.level)>=rMi.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 BCi({cliEnvironment:this.environment,includePreReleases:t}),i=ZH(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await IQo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await puc({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 cuc({message:t.message,default:t.default})}};function cp_(e){return`[${e}]:`}var _Ft=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};function JQo(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)=>JQo.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 lp_(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 fp_(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 dp_=Function.bind,pp_=dp_.bind(dp_);function _p_(e,t,r){let i=pp_(fp_,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]=pp_(lp_,null).apply(null,a)})}function d2S(){let e=Symbol("Singular"),t={registry:{}},r=JQo.bind(null,t,e);return _p_(r,t,e),r}function p2S(){let e={registry:{}},t=JQo.bind(null,e);return _p_(t,e),t}var hp_={Singular:d2S,Collection:p2S};var _2S="0.0.0-development",h2S=`octokit-endpoint.js/${_2S} ${qR()}`,y2S={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":h2S},mediaType:{format:""}};function b2S(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}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)}function vp_(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(i=>{v2S(t[i])?i in e?r[i]=vp_(e[i],t[i]):Object.assign(r,{[i]:t[i]}):Object.assign(r,{[i]:t[i]})}),r}function yp_(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function esc(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),yp_(r),yp_(r.headers);let i=vp_(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(i.mediaType.previews=e.mediaType.previews.filter(n=>!i.mediaType.previews.includes(n)).concat(i.mediaType.previews)),i.mediaType.previews=(i.mediaType.previews||[]).map(n=>n.replace(/-preview/,""))),i}function g2S(e,t){let r=/\?/.test(e)?"&":"?",i=Object.keys(t);return i.length===0?e:e+r+i.map(n=>n==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${n}=${encodeURIComponent(t[n])}`).join("&")}var O2S=/\{[^{}}]+\}/g;function A2S(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function m2S(e){let t=e.match(O2S);return t?t.map(A2S).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 gp_(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 BQn(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function NPa(e,t,r){return t=e==="+"||e==="#"?gp_(t):BQn(t),r?BQn(r)+"="+t:t}function DQn(e){return e!=null}function kuc(e){return e===";"||e==="&"||e==="?"}function P2S(e,t,r,i){var n=e[r],a=[];if(DQn(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(NPa(t,n,kuc(t)?r:""));else if(i==="*")Array.isArray(n)?n.filter(DQn).forEach(function(o){a.push(NPa(t,o,kuc(t)?r:""))}):Object.keys(n).forEach(function(o){DQn(n[o])&&a.push(NPa(t,n[o],o))});else{let o=[];Array.isArray(n)?n.filter(DQn).forEach(function(c){o.push(NPa(t,c))}):Object.keys(n).forEach(function(c){DQn(n[c])&&(o.push(BQn(c)),o.push(NPa(t,n[c].toString())))}),kuc(t)?a.push(BQn(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?DQn(n)&&a.push(BQn(r)):n===""&&(t==="&"||t==="?")?a.push(BQn(r)+"="):n===""&&a.push("");return a}function j2S(e){return{expand:w2S.bind(null,e)}}function w2S(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(P2S(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 gp_(a)}),e==="/"?e:e.replace(/\/$/,"")}function Op_(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=m2S(r);r=j2S(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=g2S(r,f):"data"in f?n=f.data:Object.keys(f).length&&(n=f),!i["content-type"]&&typeof n<"u"&&(i["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof n>"u"&&(n=""),Object.assign({method:t,url:r,headers:i},typeof n<"u"?{body:n}:null,e.request?{request:e.request}:null)}function E2S(e,t,r){return Op_(esc(e,t,r))}function Ap_(e,t){let r=esc(e,t),i=E2S.bind(null,r);return Object.assign(i,{DEFAULTS:r,defaults:Ap_.bind(null,r),merge:esc.bind(null,r),parse:Op_})}var mp_=Ap_(null,y2S);var Mp_=ue(Ep_(),1);var hFt=class extends Error{name;status;request;response;constructor(t,r,i){super(t),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in i&&(this.response=i.response);let n=Object.assign({},i.request);i.request.headers.authorization&&(n.headers=Object.assign({},i.request.headers,{authorization:i.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),n.url=n.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=n}};var S2S="10.0.6",M2S={headers:{"user-agent":`octokit-request.js/${S2S} ${qR()}`}};function D2S(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 Sp_(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=D2S(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([l,p])=>[l,String(p)])),o;try{o=await t(e.url,{method:e.method,body:n,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(l){let p="Unknown Error";if(l instanceof Error){if(l.name==="AbortError")throw l.status=500,l;p=l.message,l.name==="TypeError"&&"cause"in l&&(l.cause instanceof Error?p=l.cause.message:typeof l.cause=="string"&&(p=l.cause))}let _=new hFt(p,500,{request:e});throw _.cause=l,_}let c=o.status,f=o.url,s={};for(let[l,p]of o.headers)s[l]=p;let u={url:f,status:c,headers:s,data:""};if("deprecation"in s){let l=s.link&&s.link.match(/<([^<>]+)>; rel="deprecation"/),p=l&&l.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${s.sunset}${p?`. See ${p}`:""}`)}if(c===204||c===205)return u;if(e.method==="HEAD"){if(c<400)return u;throw new hFt(o.statusText,c,{response:u,request:e})}if(c===304)throw u.data=await tsc(o),new hFt("Not modified",c,{response:u,request:e});if(c>=400)throw u.data=await tsc(o),new hFt(I2S(u.data),c,{response:u,request:e});return u.data=i?await tsc(o):o.body,u}async function tsc(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,Mp_.safeParse)(t);if(B2S(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 B2S(e){return e.type==="application/json"||e.type==="application/scim+json"}function I2S(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 rsc(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 Sp_(r.parse(o));let c=(f,s)=>Sp_(r.parse(r.merge(f,s)));return Object.assign(c,{endpoint:r,defaults:rsc.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:rsc.bind(null,r)})}var VO=rsc(mp_,M2S);var C2S="0.0.0-development";function q2S(e){return`Request failed due to following response errors: